diff -urN tiarra-20031109/ChangeLog tiarra-20031116/ChangeLog --- tiarra-20031109/ChangeLog 2003-11-09 18:04:52.000000000 +0900 +++ tiarra-20031116/ChangeLog 2003-11-17 07:44:39.000000000 +0900 @@ -1,11 +1,24 @@ +2003-11-17 Topia + + * module/Log/Channel.pm: enhancement/need reload. + + デフォルトのログファイルパーミッションを 644 から 600 にした。 + ディレクトリ作成時のパーミッションを指定できるようにした。(dir-mode) + デフォルトは 700 。 + + * tiarra: enhancement. + + --dumpversion を追加した。 + パッケージ作成時にバージョン情報を得るため等に使う予定。 + 2003-11-09 Topia - * Reload.pm (message_arrived): bugfix/need reload. + * module/System/Reload.pm (message_arrived): bugfix/need reload. Timer を使って遅延処理することによって、reload command での 自分自身のリロードを可能にした。 - * RunLoop.pm (run): bugfix(single-server-mode)/need reboot. + * main/RunLoop.pm (run): bugfix(single-server-mode)/need reboot. single-server-mode 時の、クライアントから送られて来た PRIVMSG/NOTICE のブロードキャストで、 network-suffix 付きの @@ -1042,7 +1055,7 @@ * これ以前のログは書いていません。 -# Id: $Id: ChangeLog,v 1.118 2003/11/09 09:04:17 topia Exp $ +# Id: $Id: ChangeLog,v 1.119 2003/11/16 19:04:39 topia Exp $ # Author: $Author: topia $ -# Date: $Date: 2003/11/09 09:04:17 $ -# Revision: $Revision: 1.118 $ +# Date: $Date: 2003/11/16 19:04:39 $ +# Revision: $Revision: 1.119 $ diff -urN tiarra-20031109/NEWS tiarra-20031116/NEWS --- tiarra-20031109/NEWS 2003-11-09 18:04:52.000000000 +0900 +++ tiarra-20031116/NEWS 2003-11-17 07:44:39.000000000 +0900 @@ -1,3 +1,11 @@ +2003-11-17 Topia + + * Log::Channel + mode のデフォルトが 644 から 600 に変更されました。 + mode をコメントアウトしている場合は注意してください。 + dir-mode が追加され、デフォルトが 700 です。 + これも、必要に応じて 755 を指定するようにしてください。 + 2003-11-09 Topia * System::Reload diff -urN tiarra-20031109/module/Log/Channel.pm tiarra-20031116/module/Log/Channel.pm --- tiarra-20031109/module/Log/Channel.pm 2003-11-09 18:04:55.000000000 +0900 +++ tiarra-20031116/module/Log/Channel.pm 2003-11-17 07:44:42.000000000 +0900 @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Channel.pm,v 1.10 2003/09/22 18:02:05 admin Exp $ +# $Id: Channel.pm,v 1.11 2003/11/16 19:04:39 topia Exp $ # ----------------------------------------------------------------------------- # Local: $Clovery: tiarra/module/Log/Channel.pm,v 1.4 2003/02/11 07:53:40 topia Exp $ package Log::Channel; @@ -47,7 +47,7 @@ }, $this, 'S_PRIVMSG','C_PRIVMSG','S_NOTICE','C_NOTICE'); - + $this->_init; } @@ -61,7 +61,7 @@ } push @{$this->{channels}},[$dirname,$mask]; } - + $this; } @@ -88,7 +88,7 @@ # syncは有効で、クライアントから受け取ったメッセージであり、かつ今回のコマンドがsyncに一致しているか? if (defined $this->{sync_command} && $sender->isa('IrcIO::Client') && - $message->command eq $this->{sync_command}) { + $message->command eq $this->{sync_command}) { # 開いているファイルを全てflush。 # 他のモジュールも同じコマンドでsyncするかも知れないので、 # do-not-send-to-servers => 1は設定するが @@ -97,12 +97,12 @@ $message->remark('do-not-send-to-servers',1); return $message; } - + # Log::Channel/commandにマッチするか? - if (Mask::match(lc($this->config->command || '*'),lc($message->command))) { + if (Mask::match(lc($this->config->command || '*'),lc($message->command))) { $this->{logger}->log($message,$sender); } - + $message; } @@ -134,7 +134,7 @@ } else { my $format = do { - if ($this->{distinguish_myself} && $sender->isa('IrcIO::Client')) { + if ($this->{distinguish_myself} && $sender->isa('IrcIO::Client')) { $cmd eq 'PRIVMSG' ? '>%s:%s< %s' : ')%s:%s( %s'; } else { @@ -154,7 +154,7 @@ sprintf $format,$msg->param(0),$nick,$msg->param(1); } }; - + [$is_priv ? 'priv' : $msg->param(0),$line]; } @@ -180,7 +180,7 @@ # マッチした。 my $fname_format = $this->config->filename || '%Y.%m.%d.txt'; my $fpath_format = $ch->[0]."/$fname_format"; - + $this->{matching_cache}->{$channel} = $fpath_format; return $fpath_format; } @@ -219,7 +219,7 @@ oct('0'.$mode_conf); } else { - 0644; + 0600; } }; # ディレクトリが無ければ作る。 @@ -227,7 +227,7 @@ # ファイルに追記 my $make_path_fh_set = sub { [$concrete_fpath, - IO::File->new($concrete_fpath,'a')]; + IO::File->new($concrete_fpath,O_CREAT | O_APPEND | O_WRONLY,$mode)]; }; my $fh = sub { # キャッシュは有効か? @@ -249,7 +249,7 @@ $cached_elem->[1]->flush; $cached_elem->[1]->close; }; - # 新たなファイルハンドルを生成。 + # 新たなファイルハンドルを生成。 @$cached_elem = @{$make_path_fh_set->()}; return $cached_elem->[1]; } @@ -259,7 +259,7 @@ #print "$concrete_fpath: *cached*\n"; my $cached_elem = $this->{filehandle_cache}->{$channel} = - $make_path_fh_set->(); + $make_path_fh_set->(); return $cached_elem->[1]; } } @@ -272,13 +272,14 @@ $fh->print( Unicode::Japanese->new("$header $line\n",'utf8')->conv( $this->config->charset || 'jis')); - chmod $mode,$concrete_fpath; } } sub mkdirs { my ($this,$file) = @_; my (undef,$directories,undef) = File::Spec->splitpath($file); + my $dir_mode = undef; + # 直接の親が存在するか if ($directories eq '' || -d $directories) { # これ以上辿れないか、存在するので終了。 @@ -290,7 +291,16 @@ foreach (0 .. (scalar @dirs - 2)) { my $dir = File::Spec->catdir(@dirs[0 .. $_]); unless (-d $dir) { - mkdir $dir; + $dir_mode ||= do { + my $mode_conf = $this->config->dir_mode; + if (defined $mode_conf) { + oct('0'.$mode_conf); + } + else { + 0700; + } + }; + mkdir $dir, $dir_mode; } } } @@ -318,3 +328,69 @@ } 1; + +=pod +info: チャンネルやprivのログを取るモジュール。 +default: off + +# Log系のモジュールでは、以下のように日付や時刻の置換が行なわれる。 +# %% : % +# %Y : 年(4桁) +# %m : 月(2桁) +# %d : 日(2桁) +# %H : 時間(2桁) +# %M : 分(2桁) +# %S : 秒(2桁) + +# ログを保存するディレクトリ。Tiarraが起動した位置からの相対パス。~指定は使えない。 +directory: log + +# ログファイルの文字コード。省略されたらjis。 +charset: sjis + +# 各行のヘッダのフォーマット。省略されたら'%H:%M'。 +header: %H:%M:%S + +# ファイル名のフォーマット。省略されたら'%Y.%m.%d.txt' +filename: %Y.%m.%d.txt + +# ログファイルのモード(8進数)。省略されたら600 +mode: 600 + +# ログディレクトリのモード(8進数)。省略されたら700 +dir-mode: 700 + +# ログを取るコマンドを表すマスク。省略されたら記録出来るだけのコマンドを記録する。 +command: privmsg,join,part,kick,invite,mode,nick,quit,kill,topic,notice + +# PRIVMSGとNOTICEを記録する際に、自分の発言と他人の発言でフォーマットを変えるかどうか。1/0。デフォルトで1。 +distinguish-myself: 1 + +# 各ログファイルを開きっぱなしにするかどうか。 +# このオプションは多くの場合、ディスクアクセスを抑えて効率良くログを保存しますが +# ログを記録すべき全てのファイルを開いたままにするので、50や100のチャンネルを +# 別々のファイルにログを取るような場合には使うべきではありません。 +-keep-file-open: 1 + +# keep-file-openを有効にした場合、発言の度にログファイルに追記するのではなく +# 一定の分量が溜まってから書き込まれる。そのため、ファイルを開いても +# 最近の発言はまだ書き込まれていない可能性がある。 +# syncを設定すると、即座にログをディスクに書き込むためのコマンドが追加される。 +# 省略された場合はコマンドを追加しない。 +sync: sync + +# 各チャンネルの設定。チャンネル名の部分はマスクである。 +# 個人宛てに送られたPRIVMSGやNOTICEはチャンネル名"priv"として検索される。 +# 記述された順序で検索されるので、全てのチャンネルにマッチする"*"などは最後に書かなければならない。 +# 指定されたディレクトリが存在しなかったら、Log::Channelはそれを勝手に作る。 +# フォーマットは次の通り。 +# channel: <ディレクトリ名> (<チャンネル名> / 'priv') +# 例: +# filename: %Y.%m.%d.txt +# channel: IRCDanwasitu #IRC談話室@ircnet +# channel: others * +# この例では、#IRC談話室@ircnetのログはIRCDanwasitu/%Y.%m.%d.txtに、 +# それ以外(privも含む)のログはothers/%Y.%m.%d.txtに保存される。 +channel: priv priv +channel: others * +=cut diff -urN tiarra-20031109/sample.conf tiarra-20031116/sample.conf --- tiarra-20031109/sample.conf 2003-11-09 18:04:52.000000000 +0900 +++ tiarra-20031116/sample.conf 2003-11-17 07:44:39.000000000 +0900 @@ -1,6 +1,6 @@ # -*- tiarra-conf -*- # ----------------------------------------------------------------------------- -# $Id: sample.conf,v 1.60 2003/10/15 16:23:42 admin Exp $ +# $Id: sample.conf,v 1.61 2003/11/16 19:04:39 topia Exp $ # ----------------------------------------------------------------------------- # tiarra.conf サンプル # @@ -778,11 +778,10 @@ save-lists: 1 } -- Log::Channel -{ +- Log::Channel { # チャンネルやprivのログを取るモジュール。 - - # Log系のモジュールでは、以下のように日付けや時刻の置換が行なわれる。 + + # Log系のモジュールでは、以下のように日付や時刻の置換が行なわれる。 # %% : % # %Y : 年(4桁) # %m : 月(2桁) @@ -803,8 +802,11 @@ # ファイル名のフォーマット。省略されたら'%Y.%m.%d.txt' filename: %Y.%m.%d.txt - # ログファイルのモード(8進数)。省略されたら644 - mode: 644 + # ログファイルのモード(8進数)。省略されたら600 + mode: 600 + + # ログディレクトリのモード(8進数)。省略されたら700 + dir-mode: 700 # ログを取るコマンドを表すマスク。省略されたら記録出来るだけのコマンドを記録する。 command: privmsg,join,part,kick,invite,mode,nick,quit,kill,topic,notice diff -urN tiarra-20031109/tiarra tiarra-20031116/tiarra --- tiarra-20031109/tiarra 2003-11-09 18:04:52.000000000 +0900 +++ tiarra-20031116/tiarra 2003-11-17 07:44:39.000000000 +0900 @@ -5,7 +5,7 @@ # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # ----------------------------------------------------------------------------- -# $Id: tiarra,v 1.27 2003/11/09 07:32:12 admin Exp $ +# $Id: tiarra,v 1.28 2003/11/16 19:04:39 topia Exp $ # ----------------------------------------------------------------------------- require 5.006; use strict; @@ -63,6 +63,7 @@ print "\n"; print "options:\n"; print " --help print this message\n"; + print " --dumpversion print version\n"; print " --version print version infomation\n"; print " --config= tiarra configuration file; default is 'tiarra.conf'\n"; print " --quiet don't output any messages to stdout and stderr\n"; @@ -113,11 +114,12 @@ if (&find_option('help')) { &help; exit; -} - -if (&find_option('version')) { +} elsif (&find_option('version')) { print join("\n",get_credit()) . "\n"; exit; +} elsif (&find_option('dumpversion')) { + print &version . "\n"; + exit; } if (&find_option('debug')) {