忍者ブログ
PCメモ
PC関係のメモ、気付いたこと。 simhとChromium OSをいじって遊んでいます。 Chromium OSのカスタムビルドを配布しています。(http://chromiumosde.gozaru.jp) twitter: @zui22904336 PGP fingerprint: 45FC 0E47 A68A FA06 02FE 2BEF B72C C6E6 F9FF 1C19
Admin / Write
2024/04/29 (Mon) 07:19
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。



2014/03/09 (Sun) 00:00
前回はUNIX V7側でのUUCPの着信設定を行いましたが、今回はホストOSのLinux CentOS6でUUCPの発信設定を行います。UNIX V7からLinuxへは接続しにいけないので、Linux側は発信設定のみで着信設定はしません。

Linux側の発信設定


Taylor UUCPのダウンロード


EPELなどの外部リポジトリを有効にしていればyumコマンドでUUCPをインストールすることができるようですが、今回は自分でソースからビルドしてみたので、その手順を書きます。

UUCPのソースコードは以下のURLからダウンロードします。

http://airs.com/ian/uucp.html

こちらにアクセスして、download the source codeのリンクからダウンロードします。

ビルド


ダウンロードしたuucp-1.07.tar.gzを展開し、policy.hを編集します。

linux$ tar zxvf uucp-1.07.tar.gz
linux$ cd uucp-1.07
linux$ vi policy.h
/* If you use other programs that also lock devices, such as cu or
   uugetty, the other programs and UUCP must agree on whether a device
   is locked.  This is typically done by creating a lock file in a
   specific directory; the lock files are generally named
   LCK..something or LK.something.  If the LOCKDIR macro is defined,
   these lock files will be placed in the named directory; otherwise
   they will be placed in the default spool directory.  On some HDB
   systems the lock files are placed in /etc/locks.  On some they are
   placed in /usr/spool/locks.  On the NeXT they are placed in
   /usr/spool/uucp/LCK.  */
/* #define LOCKDIR "/usr/spool/uucp" */
#define LOCKDIR "/var/spool/uucp"   ← この行を追加
/* #define LOCKDIR "/etc/locks" */
/* #define LOCKDIR "/usr/spool/locks" */
/* #define LOCKDIR "/usr/spool/uucp/LCK" */
/* #define LOCKDIR "/var/spool/lock" */
/* #define LOCKDIR "/var/lock" */


policy.hを編集したら、以下の手順でビルドします。

linux$ ./configure --prefix=/usr/local
linux$ make
linux$ sudo make install

UUCPの設定


/usr/local/conf/uucpディレクトリを作成して、アーカイブのsamplesにあるファイルをコピーします。以降、この/usr/local/conf/uucpディレクトリで作業を行います。

linux$ sudo mkdir /usr/local/conf/uucp
linux$ sudo cp samples/* /usr/local/conf/uucp/
linux$ cd /usr/local/conf/uucp

続いて、コピーしたファイルのうち、configファイルを編集します。
まず、nodenameという項目を探してサイト名を定義します。今回はcentos6とします。 また、スプールディレクトリのデフォルトが/usr/spoolになっているのですべて/var/spoolに書き換えます。 以下に編集内容のdiffを示します。

linux$ diff -u ./sample/config /usr/local/conf/uucp/config 
--- ./sample/config	2003-05-29 15:08:48.000000000 +0900
+++ /usr/local/conf/uucp/config	2014-03-05 00:04:24.494808788 +0900
@@ -20,12 +20,14 @@
 # you want to use, you do not need to set the name in this file.
 # Otherwise uncomment and edit the following line.
 # nodename uucp				# The UUCP name of this system
+nodename centos6				# The UUCP name of this system
 
 # The default spool directory is set in policy.h (the default is
 # /usr/spool/uucp).  All UUCP jobs and status information are kept in
 # the spool directory.  If you wish to change it, use the spool
 # command.
 # spool /usr/spool/uucp			# The UUCP spool directory
+spool /var/spool/uucp			# The UUCP spool directory
 
 # The default public directory is set in policy.h (the default is
 # /usr/spool/uucppublic).  Remote systems may refer to a file in this
@@ -34,6 +36,7 @@
 # of.  If you wish to change the public directory, use the pubdir
 # command.
 # pubdir /usr/spool/uucppublic		# The UUCP public directory
+pubdir /var/spool/uucppublic		# The UUCP public directory
 
 # The names of the UUCP log files are set in policy.h.  The default
 # names depend on the logging option you have chosen.  If
@@ -43,8 +46,11 @@
 # /usr/spool/uucp/Debug.  These file names may be set by the following
 # commands.
 # logfile /usr/spool/uucp/Log		# The UUCP log file
+logfile /var/spool/uucp/Log		# The UUCP log file
 # statfile /usr/spool/uucp/Stats	# The UUCP statistics file
+statfile /var/spool/uucp/Stats	# The UUCP statistics file
 # debugfile /usr/spool/uucp/Debug	# The UUCP debugging file
+debugfile /var/spool/uucp/Debug	# The UUCP debugging file
 
 # uuxqt is the program which executes UUCP requests from other
 # systems.  Normally one is started after each run of uucico, the
linux$ 


続いて、sysという名前で以下の内容でファイルを作成します。

call-login *
call-password *
local-send /
remote-send /
local-receive /
remote-receive /
time any
system unixv7
port TCP
address 127.0.0.1
protocol g

これもセキュリティについての考慮は全くなしです。
続いて、callファイルにUNIX V7に接続しに行くときの接続先サイト名、ユーザ名、パスワードを定義します。以下の行を追加します。

unixv7 uucp !uucp ← 前回の記事でUNIX V7側のuucpユーザのパスワードとして設定した文字列

続いて、portファイルを開いて、以下の記述を追加します。

port TCP
type tcp
service 4096 ← UNIX V7にtelnet接続する際のポート番号を指定します。

スプールディレクトリの作成


linux側でもuucp用のスプールディレクトリの作成を行います。
linux$ su -
linux# mkdir /var/spool/uucp
linux# mkdir /var/spool/uucppublic
linux# chown uucp:uucp /var/spool/uucp
linux# chown uucp:uucp /var/spool/uucppublic

設定の確認


uuchkコマンドを実行してエラーが出ていないか確認します。 ここまで設定した後のuuchkの出力結果は以下のようになりました。

linux$ uuchk
config file: /usr/local/conf/uucp/config
sys file: /usr/local/conf/uucp/sys
port file: /usr/local/conf/uucp/port
dial file: /usr/local/conf/uucp/dial
dialcode file: /usr/local/conf/uucp/dialcode
passwd file: /usr/local/conf/uucp/passwd
call file: /usr/local/conf/uucp/call
Local node name centos6
Spool directory /var/spool/uucp
Public directory /var/spool/uucppublic
Lock directory /var/spool/uucp
Log file /var/spool/uucp/Log
Statistics file /var/spool/uucp/Stats
Debug file /var/spool/uucp/Debug
Global debugging level 
uucico -l will strip login names and passwords
uucico will strip UUCP protocol commands
Start uuxqt once per uucico invocation

System: unixv7
 When called using any login name
 Call out using port TCP
 The possible ports are:
  Port name TCP
   Port type tcp
   TCP service 4096
   Characteristics: eight-bit-clean reliable end-to-end fullduplex
 Remote address 127.0.0.1
 Chat script "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P
 Chat script timeout 10
 Chat script incoming bytes stripped to seven bits
 Login name uucp
 Password !uucp
 At any time may call if any work
 May retry the call up to 26 times
 May make local requests when calling
 May make local requests when called
 May send by local request: /
 May send by remote request: /
 May accept by local request: /
 May receive by remote request: /
 May execute rnews rmail
 Execution path /bin /usr/bin /usr/local/bin
 Will leave 50000 bytes available
 Public directory is /var/spool/uucppublic
 Will use protocols g


uucpコマンドによるファイルコピー(linux>UNIX V7)


ここまで設定すればuucpコマンドでファイルがコピーできるようになります。
Linuxからファイルをコピーするときは以下のようにします。

linux$ uucp /usr/local/conf/uucp/passwd 'unixv7!/tmp/passwd'

コピー先の指定方法は’相手先サイト名!ファイル名’となります。
ここで、uucpコマンドでファイルをUNIX V7にコピーできるのは、前回の記事に書いた通り、UNIX V7側で/usr/lib/uucp/USERFILEに定義したユーザだけであることに注意が必要です。定義されていないユーザでuucpを実行した場合、コピー指示は無視され、UNIX V7側の/usr/spool/uucp/LOGFILEに以下のような出力が現れます。

uucp centos6 (3/3-7:2) PERMISSION (DENIED)

uucpコマンドは単にファイルをスプールに貯めるだけで、すぐにコピーされるとは限りません。前回の記事でも書いた通り、UUCPはダイヤルアップ接続を前提にしており、デフォルトでは一度接続した後一定時間経過しないと再接続せず、その間の要求はすべてスプールに貯めておくようになっています。
送信要求がキューにたまっているときは、uustatコマンドを実行した時に以下のように出力されます。

linux$ uustat
unixv7.NON1uU6AAFEC unixv7 user 03-09 00:11 Sending /usr/local/conf/uucp/passwd (936 bytes) to /tmp/passwd


送信が終わるとuustatコマンドの出力は空になります。リトライ待ちの時はuulogコマンドでuucpのログを見たときに以下のように出力されます。
linux$ uulog
(略)
uucico unixv7 - (2014-03-09 00:19:14.25 19601) Retry time not reached

この場合は、uucicoコマンドを手動で実行することで即時に接続を実行させることができます。

linux$ uucico -S unixv7

コピーがうまくいくと、uulogコマンドを実行したときに以下のような出力が得られます。
linux$ uulog
(略)
uucico unixv7 - (2014-03-09 00:29:38.08 19677) Calling system unixv7 (port TCP)
uucico unixv7 - (2014-03-09 00:29:39.53 19677) Login successful
uucico unixv7 - (2014-03-09 00:29:39.69 19677) Handshake successful (protocol 'g' sending packet/window 64/3 receiving 64/7)
uucico unixv7 user (2014-03-09 00:29:39.77 19677) Sending /usr/local/conf/uucp/passwd (936 bytes)


UNIX V7側には、/usr/spool/uucp/LOGFILESに以下のような出力が現れます。
uucp centos6 (3/6-23:32) REQUESTED (S /usr/local/conf/uucp/passwd /temp/passwd user)
user centos6 (3/6-23:32) COPY (SUCCEEDED)


uucpコマンドによるファイルコピー(UNIX V7>linux)


UNIX V7からファイルをコピーするときも、同様にuucpコマンドを使います。

unixv7# uucp /usr/src/games/quiz.c 'centos6!/tmp/quiz.c'

ただし、UNIX V7からはLinux側に接続しに行くことができないので、UNIX V7側でuucpコマンドを実行した後に、linux側から上で書いたuucicoコマンドの手動実行により接続を行います。このタイミングでUNIX V7のキューにたまっていたファイルがLinux側に引き取られます。
送信がうまくいくと、UNIX V7の/usr/spool/uucp/LOGFILEに以下のような出力が得られます。
root centos6 (3/6-22:56) REQUEST (S /usr/src/games/quiz.c /tmp/quiz.c root)
root centos6 (3/6-22:56) REQUEST (SUCCEEDED)


一方、Linux側には以下のようなログが得られます。

uucico unixv7 - (2014-03-08 23:52:25.38 19303) Calling system unixv7 (port TCP)
uucico unixv7 - (2014-03-08 23:52:25.59 19303) Login successful
uucico unixv7 - (2014-03-08 23:52:25.72 19303) Handshake successful (protocol 'g' sending packet/window 64/3 receiving 64/7)
uucico unixv7 root (2014-03-08 23:52:25.90 19303) Receiving /tmp/quiz.c
uucico unixv7 - (2014-03-08 23:52:26.75 19303) Protocol 'g' packets: sent 5, resent 0, received 104
uucico unixv7 - (2014-03-08 23:52:26.80 19303) Call complete (1 seconds 6339 bytes 6339 bps)


uucp使用時の注意事項


UUCPで送信できるのはテキストファイルのみです。バイナリファイルはuuencodeでエンコードして送信することになるのですが、UNIX V7にはデフォルトではuuencodeやuudecodeはありません。そのためどこかからソースを持ってきてコンパイルする必要がありますが、まだ試してはいません。

[関連記事]





ランキングに参加してみました。クリックしていただければ嬉しいです。

にほんブログ村 IT技術ブログ IT技術メモへ
にほんブログ村

パソコン ブログランキングへ

拍手[0回]

PR


Comment
Name
Title
Mail
URL
Comment
Pass   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
  HOME   18  17  15  14  13  12  11  10  9  8  7 
プロフィール
HN:
zui
性別:
非公開
PR
忍者カウンター
忍者ブログ [PR]