
Bnews の設定を追加しました。
[gcc/linux/alpha]
[証券会社で遊ぼう]
[メルセンヌ素数]
[永遠の「bit 1985年4月号」]
[netnewsを読む]
[Twingoに乗ろう]
[バイクに乗っていた頃]
[俺たちのサーキット]
[業界悪魔の辞典]
[UUCPやろうぜ]
[一太郎やーい]
[動け!コンピュータ]
[琴電讃岐うどんの旅]
[2002年11月16日のFUJIC]
[Bnews forever]
[流し撮りMotoGP]
[Nikon DSLR on Unix]
[のら猫]
[56 game hitting streak]
[分散コンピューティングは死んだか]
[PlayStation 3 を使ったフェルマー数の因数の素数判定]
[Post-it]
[SIGPS]
[Google Log]
[大部屋俳優]
[沖縄 2004]
[沖縄 2008]
[2008/9/11,12,13 reno air race]
[Other Links]
はじめに
UUCP(Unix to Unix copy)はまだ TCP/IP などなかった頃から
Unix マシン同士をお話させてメールやニュースを実現してきた
仕組みです。
UUCPの設定
商用uucpサービスをしている多分日本で唯一のプロバイダリムネットに
接続するための設定ファイルの内容です。
UUCPログイン名: Uduke
UUCPパスワード: goma
UUCPノード名 : duke
UUCPドメイン名: domdom
リムネット側のUUCPサーバのノード名: rim
リムネット側のUUCPサーバのホスト名: xxx.rim.or.jp
として記述しています。
メールアドレスは、〜@domdom.rim.or.jp となります。
bash-2.01$ pwd
/etc/uucp
bash-2.01$ cat config
spool /var/spool/uucp # The UUCP spool directory
pubdir /var/spool/uucppublic # The UUCP public directory
logfile /var/spool/uucp/Log # The UUCP log file
statfile /var/spool/uucp/Stats # The UUCP statistics file
debugfile /var/spool/uucp/Debug # The UUCP debugging file
sysfile sys # Default "sys"
portfile port # Default "port"
dialfile dial # Default "dial"
dialcodefile dialcode # Default "dialcode"
callfile call # Default "call"
passwdfile passwd # Default "passwd"
bash-2.01$ cat sys
system rim
time Any
#call-timegrade Z Any0900-2200 # ここを有効にすると 9:00〜22:00 はメールだけ受取ます。
chat-timeout 55
protocol t
port type tcp
address xxx.rim.or.jp
chat ogin:--ogin:--ogin: Uduke ssword: goma
send-request true
called-transfer true
local-receive /
ファイルのパーミッションに注意してください。
さらにこのマシンで他のマシンからのuucp接続を受けるようにするには、
uucp のユーザを追加登録して、
sys ファイルに対象のマシンを登録して、
/etc/inetd.conf ファイルでuucp サービスを有効に
してください。
C-NEWSの設定
私のうまくいった c-news の設定です。dbz を使うようにしてますが、
こうすると mnews など history ファイルを参照するプログラム
は全て dbz 対応に自分で make する必要があります。
bash-2.01$ ./quiz
This interactive command will set up control files needed to build
and install C News. It will not actually build or install anything
itself, so feel free to abort and start again.
You probably need your system manuals handy. You definitely need pencil
and paper handy, for taking notes.
When a question is asked in the form `How are you [okay]? ', the
answer in brackets is what you will get if you just hit RETURN.
(If you want to give an empty string as the answer, type a single
`-' instead.) If you type a line starting with `!', the rest of
the line will be run as a shell command, and the question will be
asked again.
Do you want to use your previous answers as defaults [no]? yes
Picking up defaults, from last run...
got them
C News wants to keep most of its files under a uid which preferably
should be all its own. Its programs, however, can and probably should
be owned by another user, typically the same one who owns most of the
rest of the system. (Note that on a system running NFS, any program
not owned by "root" is a gaping security hole.)
What user id should be used for news files [news]?
What group id should be used for news files [news]?
You have to decide the locations, in the file system, of four major
parts of C News: the article tree, the overview files (which may be
in the article tree, or may be elsewhere), the control files, and the
programs. These locations are known, within much of the software, by
the names of the environment variables used to hold them. There are
some traditional choices, not always the most reasonable in retrospect,
that some reader software may depend on.
purpose variable traditional location reasonable location
------- -------- -------------------- -------------------
article tree NEWSARTS /usr/spool/news /var/news
overview files NEWSOV /usr/spool/news /var/news
control files NEWSCTL /usr/lib/news /etc/news
programs NEWSBIN /usr/lib/newsbin /usr/libexec/news
Where should the article tree go [/var/news]?
Where should overview files go [/var/news]?
Where should control files go [/etc/news]?
Where should programs go [/usr/libexec/news]?
Is /bin:/usr/bin:/urk
the correct path to follow to find standard programs on your
system [yes]?
C News normally uses a umask of 022, turning off only the others-write and
group-write bits in the permissions of files it creates. (The correspondence
between bits and number is: rwx = 421, so turning off group-write bits and
all others-access bits would be a mask of 027, for example.) Usually
a umask of 002 or 022 is appropriate.
What umask should C News use [022]?
The shell files that are everywhere in C News want to pick up their
configuration parameters (mostly, the last few questions you have
answered) from a file at a known location; this is very hard to avoid
unless you play tricks with environment variables (see documentation).
Where should the shell configuration file be
located [/etc/news/bin/config]?
C News wants to mail some kinds of trouble and status reports. These are
divided into urgent reports (something went badly wrong) and non-urgent
reports (routine status info). The mailing addresses for these should
probably be system mailboxes, rather than those of specific people, so you
won't have to change the software when you get a new administrator.
Where should C News mail urgent reports [root]?
Where should C News mail non-urgent reports [root]?
C News has libraries for "small" address spaces (16 bits) and "big"
ones (preferably 32 bits, but anything rather bigger than 16).
Which best describes your system [big]?
Systems vary in whether certain library functions and system calls
are present. C News contains reasonably-portable versions of the
possibly-missing library functions, and fake versions of the
possibly-missing system calls, but it needs to know which are missing.
Does your system have fcntl() [yes]?
Does your system have fgetline() [no]?
Does your system have getopt() [yes]?
Does your system have gettimeofday() [yes]?
Does your system have memcpy() [yes]?
Does your system have mkdir() [yes]?
Does your system have putenv() [yes]?
Does your system have remove() [yes]?
Does your system have rename() [yes]?
Does your system have strchr() [yes]?
Does your system have strerror() [yes]?
Does your system have strspn() [yes]?
Does your system have symlink() [yes]?
We strongly, repeat STRONGLY, recommend that all news processing
(as opposed to reading) be done on the machine that has the disks.
NFS's imitation of the Unix filesystem semantics is too sloppy for
reliable processing. Keeping processing local also speeds it up,
and permits C News to take some shortcuts.
Will processing be done over NFS [yes]?
The news software uses an indexing package to maintain an index into
its history file. Originally this was the old Version Seven "dbm".
Nowadays the "dbz" package, which is specialized for news (and runs
much faster, with much smaller files) is normally used. Everything
using the news database has to be compiled with the same package, as
they are generally not file-compatible.
Do you want to use the "dbz" package [yes]?
Some old systems have implementations of the Standard I/O library ("stdio")
in which fgets, fputs, fread, and fwrite are quite slow. We supply versions
of these functions which are faster; they are compatible with most old
AT&T-derived stdios. (They tend not to work on modern systems, but modern
stdio implementations are usually respectably fast.) They can be a major
performance win for C News. There is a fairly thorough compatibility check
run before a commitment is made to use our speedups; as far as we know, if
the test works, the functions do.
Do you want to use our stdio speedups [no]?
The strchr() function is usually slower than in-line C code
when small strings are involved, unless your compiler is very
clever and can generate in-line code for strchr(). Is your
compiler that good (okay to guess) [no]?
Some systems have header files that others lack, and C News
is prepared to fake missing ones.
Does your system have an ANSI-C-conforming [no]?
Does your system have an ANSI-C-conforming [no]?
Does your system have an ANSI-C-conforming [no]?
Very old Unix systems needed the order of object modules in a library
chosen very carefully. V7 introduced "ranlib" which removes the need
for this. Many modern systems have the same facility built into "ar"
(look for the "symdef" or "symbol table" feature in the "ar" manual page)
so ranlib is not needed. (Caution: some SCO systems reportedly have
a ranlib, but use it only for cross-compiling, not for native programs.)
C News can cope with either (if you have neither, you're in trouble).
Does your system use ranlib [yes]?
Usually "make" is named just "make", but sometimes there is more than
one version on a system.
What is the name of the make to be used [make]?
C News relies heavily on being able to put an "include" command in
a makefile, so that the contents of another file is automatically
inserted there when make runs. The syntax for this varies. The
possibilities for including a file named "../include/config.make" are:
svr4 include ../include/config.make
bsd .include "../include/config.make"
other something else
noway make has no such feature
Sun systems use the svr4 syntax, as does GNU make.
Which one is appropriate [bsd]?
Historically the C compiler is named "cc", but this is not true on
some systems, and on others there are several different C compilers.
"Make" usually has a default C compiler, but you may want another.
Do you want to use a compiler other than make's default [no]?
Historically the only normal compilation option needed for most
programs is -O, but again compilers, especially newer ones, differ.
(NOTE: many 386/486 compilers miscompile dbz if -O is used!)
What options should be given to the compiler [-O]?
The final linking ("ld") step of compiling might need an option,
such as -n or -i, to produce the preferred form of executable file.
On most modern systems the default is right. What options, if any,
should be given for linking []?
On unusual systems it may be necessary to link C News programs with
libraries other than the usual C library. These can be specified as
either full pathnames or -l... options. What libraries, in addition
to the one(s) picked up automatically by the compiler, should be used
when linking C News []?
C News tries to limit the backlog of news batches spooled up for
transmission to a site, to control use of disk space. To do this,
it needs to be able to determine the length of the queue of news
batches for a particular site. This is UUCP-version-dependent.
There is a good chance that you will have to customize the "queuelen"
program. C News knows about several versions:
svr4 System V Release 4 uucp
hdb pre-SVR4 Honey DanBer, aka Basic Networking Utilities
tay Taylor UUCP, native mode
sub old uucp with subdirectories (e.g. /usr/spool/uucp/C.)
vo very old uucp, no subdirectories
pre prehistoric uucp, no subdirectories, no -g option on uux
null don't run uucp or don't care about queue lengths
Which one is most appropriate [tay]?
C News often wants to ask how much disk space is available. The
format of output from the "df" command unfortunately varies a lot,
as does the availability of a system call to get the same information.
C News knows about several different versions (the first four are
preferred):
statfs system with standard statfs() (4.4BSD, some System Vs)
ultrix DEC Ultrix with DEC's own bizarre statfs()
statvfs system with statvfs() (many modern System Vs)
ustat system with ustat() (most System Vs)
bsd 4.2/4.3BSD
sysv old System Vs
xenix some (all?) Xenixes; some System Vs, e.g. Microport, HP?
sgi Silicon Graphics Iris systems
v7 plain old style: no headers or fluff, just name and number
null don't know or don't care how much space is available
Which one is most appropriate [bsd]?
Some "df" commands, especially on old systems, must be given
the name of a device. Modern ones can be given any directory
name and the system handles the details of figuring out what
device is meant. A few will take a directory only if it is
the "top" of a filesystem. Will "df" accept any directory
name as an argument [yes]?
Are you planning to use expire to archive news on disk [no]?
Are you particularly short of disk space [no]?
You may want to inspect "spacefor" to make sure its defaults
for things like desired free space are appropriate for your
system, although the defaults are fairly conservative.
Are you running C News on a group of machines hooked together with NFS,
run essentially as a single system with a single administration,
with articles filed on one "server" machine [no]?
The "rnews" and "cunbatch" commands (which are identical, the latter
being purely for backward compatibility with seriously-old systems)
have to be installed somewhere where uucp can find them to execute
them. It is not normally necessary for users to be able to run
them, so they need not go in the directories searched for normal
commands... although uucp often searches only those directories.
Where should "rnews" and "cunbatch" be put [/usr/libexec/news/input]?
The inews command, and also readnews+postnews+checknews if you're
going to use them, should go in one of the directories searched for
normal commands, so users can run them without special arrangements.
What directory should these commands go in [/usr/bin]?
saving defaults...
building conf/makeinc...
unchanged, old one left in place
building conf/substitutions...
unchanged, old one left in place
building include/config.make...
done
bash-2.01$
bash-2.01$cat sys
ME:control,fj
rim/uucp1.rim.or.jp:fj/all:f:
ME に自分のニュースサーバで有効なニュースグループ名を設定する。
この中にあって、active ファイル内に無いニュースグループへの記事
だけがjunkに落ちる。(junk に落ちないと自分のニュースサーバから
転送しているサイトに送られない)
rim の行が rim に転送するニュースグループ名の設定。
記事の Path: フィールドに rim の記述が無い記事のみが送られるが
rim から転送されてくる記事には、 rim が含まれていないのでそれ
だけでは記事を逆送してしまう。リムネットの uucp のニュースサーバ
は uucp1.rim.or.jp という システム名を Path: フィールドに追加する
のでそれも rim に送らないように rim/uucp1.rim.or.jp と記述する。
逆送しても Message-ID: が来た記事のままならば リムネットのニュース
サーバで破棄されるので帯域の無駄になるだけである。(古い記事は?)
bash-2.01$ cat batchparms
# 500KB, after compress, is 4 minutes at 1000cps
# 20 batches is somewhat arbitrary, about 5MB per site
# site class size queue command
# ---- ----- ---- ----- -------
# defaults: cunbatch header, transfer by uux
/default/ u 500000 20 batcher | compcun | viauux
この行だけで、rim 向けのニュースは、サイズを500kbyte を上限と
する20個のcompressされたファイルとして uucp のスプールに送られる。
このサイズ以下でも一定時間毎にスプールに送られる。
記事をまとめないでスプールに送る設定は自分で調べてください。
Cnews は、compress を使うが、gzip は compress されたファイルも
扱えるので gzip で圧縮して送ってもリムネット側で正しく処理され
るかもしれない。
bash-2.01$ cat active
control 0000000186 00100 y
fj.1st-readme 0000000109 00100 m
junk 0000011109 00100 y
このニュースサーバで有効なニュースグループの定義ファイル。
間の空白は1文字じゃないと正しく動かない。
左の数字が最新の記事番号、右の数字が存在している最古の
記事番号。この2つだけで管理するから確かに expire はポスト
日付けじゃまずい。最後の英文字の「m」はモデレートされた
ニュースグループを示す。
bash-2.01$ cat explist
# hold onto history lines 14 days, nobody gets >90 days
/expired/ x 14 -
/bounds/ x 0-1-90 -
fj x never -
junk x 7 -
all x 14 -
毎晩12:59になると古い記事を削除するために expire プログラム
が起動される。記事の期限を決める定義ファイル。
fjの記事は削除せず、junk の記事は7日で削除、それ以外の記事は
14日で削除する設定。
/expired/ の14という指定は記事が削除された後も14日はhistory
ファイルに記事が削除されたことを覚えておくという指定。同じ
Message-ID: の記事が送られて来た時に破棄するために使われる。
Cnewsめも
expire は、ファイルの日付で行うようだ。
古いニュースが配送されてきた時はちゃんとファイルの中の
Date を見て(はじいて)いるようなのに、処理の重さの関係だろうか。
su news -c mkhistory する場合は、history ファイルを削除して
からやらないと以前のヒストリに追加される形になる。
3日以上過去の記事はうけつけないので、relay/relaynews を
改造してはじかないようにした。
Cnews では、クロスポストされた記事はクロスポストされたニュース
グループのディレクトリ全部に実体があるので領域を消費する。
(うそでした。ハードリンクされているようです)
リムネットでは、ニュースの圧縮を compress でなくて gzip で
行うように変更もしてくれるがその場合は、Cnews の newsrun を
newsrun:
124 # Decompress if necessary.
125 case $f in
126 # *.Z) text=`echo $f | sed 's/Z\$/t/'`
127 # uncompress <$f >$text
128 # ;;
129 *.Z) text=`echo $f | sed 's/Z\$/t/'`
130 gzip -d <$f >$text
131 ;;
のように変更する。gzip は、uncompress の機能も包含しているので
compress したファイルもこれでうけとれる。
/var/news/out.going/A/togo
にマシンA に行く記事の番号がたまるが、/var/news/out.going/A という
ディレクトリを自動では作ってくれないようだ。
www.wide.ad.jp/document/reports/pdf1991/part12.pdf
たまに(数年に一度、ニュースシステムに問題のあった時)リムネットの
ニュースシステム(多分 Cnews) から system!news (system はあなたの
system 名)へメールが来る。受け取れる設定になっていた方が良い。
Bnews 設定
Bnews を動かしてみる。
http://www.landfield.com/software/ftp.landfield.com/news/bnews-2.11/
Index of /software/ftp.landfield.com/news/bnews-2.11
Name Last modified Size Description
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[DIR] Parent Directory 14-Jan-1997 14:57 -
[ ] caesar.c 29-Jun-2001 00:48 0k
[ ] cvt.tar.Z 29-Jun-2001 00:48 2k
[ ] doc.tar.Z 29-Jun-2001 00:48 110k
[ ] man.tar.Z 29-Jun-2001 00:48 28k
[ ] misc.tar.Z 29-Jun-2001 00:48 45k
[DIR] patches/ 01-Jul-2001 11:40 -
[ ] src.tar.Z 29-Jun-2001 00:48 268k
[ ] uucp.tar.Z 29-Jun-2001 00:48 18k
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ftp://ftp.digital.com/pub/news/b/
にもある。
patch は当たっているようだ。
src.tar.Z を展開した。
cp localize.4.3 localize.sh して実行した。
defs.dist には、いろいろ中身があるので必要なら変更する。
make
-ldbm がないと怒られるので Cnews から dbz をもってくる。
make update した。
ニュースを投稿すると
active:
fj.books 01800020001 y
comp.ai.digest 00000 00001 y
のように active ファイルがこわれる。
inews.c
913 /*fprintf(actfp, "%s %07ld", ngname, ngsize+1);*/
914 fprintf(actfp, "%s %05d", ngname, ngsize+1);
expire は、
fj.sys.sun 0000000 0000001 y
のように書き換えてしまうので、これに会わせる必要がある。
inews.c
914 fprintf(actfp, "%s %07d", ngname, ngsize+1);
とした。make update が作る active ファイルもまずいわけ。
active ファイルの内容(番号)を変えたら history ファイルも初期化しておく。
ここまでの修正で postnews で投稿はできるようになった。
compaq ~$/usr/news/postnews
warning: this program uses gets(), which is unsafe.
Is this message in response to some other message?
Subject: joke
Keywords:
Newsgroups (enter one at a time, end with a blank line):
The most relevant newsgroup should be the first, you should
add others only if your article really MUST be read by people
who choose not to read the appropriate group for your article.
But DO use multiple newsgroups rather than posting many times.
For a list of newsgroups, type ?
> fj.jokes
>
Distribution (default='world', '?' for help) :
What now? [send, edit, list, quit, write, append] send
Posting article...
inews: : Unparsable date "8 Feb 04 08:17:53 GMT"
inews: : Unparsable date "8 Feb 04 08:17:53 GMT"
Article posted successfully.
日付が不正とおこられる。
getdate.y:
time_t
dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
int mm, dd, yy, h, m, s, mer, zone, dayflag;
{
time_t tod, jdate;
register int i;
time_t timeconv();
if (yy < 0) yy = -yy;
if (yy < 100) yy += 1900;
mdays[1] = 28 + (yy%4 == 0 && (yy%100 != 0 || yy%400 == 0));
/*if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 ||*/
if (yy < epoch || mm < 1 || mm > 12 ||
if (mm < 1 || mm > 12 ||
dd < 1 || dd > mdays[--mm]) return (-1);
jdate = dd-1;
1970 年からの日付をもとめている。
この修正で動くようだが、ファイルに保存される年は下 2 桁に
なる。leaf node なら問題ない。
expire からも参照されているちゃんと日付を見ているようだ。
expire は、history ファイルの日付を見て行っているようだ。
日本語が化ける。
inews.c:
/*for (cp = bfr; c = toascii(*cp); cp++) {*/
/* if (isprint(c) || isspace(c) || c == '\b')*/
/* putc(c, tmpfp);*/
for (cp = bfr; c = *cp; cp++) {
putc(c, tmpfp);
見事に日本語を拒絶していて気持ちがいい位だ。
Subject: は化けるままだが Google 風でいいかもしれない。
/usr/news/lib/news/compress の リンクを gzip にはる。
いくつか fj に流れている記事でうけつけないものがあるようだ。
本文のサイズに制限はがありはじかれる。
References フィールドの長さにも制限があり長過ぎると
途中までできりすててうけつける。
Newsgroups が多過ぎるとうけつけない。
同じ メッセージ ID の記事を受け付けてしまう場合がある。
Message-ID: <401CEBDE.3040809@lares.dti.ne.jp>
大文字が含まれていると必ず受け付けてしまうようだ。DB には小文字で
登録しているのかもしれない。
RFC822 には、大文字小文字の区別なしと書いてあるから、比較の所が
いけないのかもしれない。
<132@compaq.UUCP> も受け付けてしまう。
UUCP の時の @ の右側には 大文字が多いのになんでかな。
しつこくやってたら今度は拒否した。なんでだ。
inews.c:
/* always check history */
if (history(&header)) {
log("Duplicate article %s rejected. Path: %s",
header.ident, header.path);
xxit(0);
ifuncs.c:
/*
* Return TRUE if we have seen this file before, else FALSE.
*/
history(hp)
/*
* Make the article ID case insensitive.
*/
(void) strcpy(lcident, hp->ident);
lcase(lcident); 小文字に変換している。
#ifndef NFSCLIENT
idlock(lcident);
#ifdef DBM
initdbm(ARTFILE);
lhs.dptr = lcident;
lhs.dsize = strlen(lhs.dptr) + 1;
rhs = fetch(lhs);
if (rhs.dptr) {
idunlock();
return(TRUE);
}
savehist(hline)
char *hline;
......
datum lhs, rhs;
/* We assume that history has already been called, calling dbminit. */
strcpy(tmphline,hline);
p = index(tmphline, '\t');
if (p)
*p = 0;
lcase(tmphline);
lhs.dptr = tmphline;
lhs.dsize = strlen(lhs.dptr) + 1;
rhs.dptr = (char *)&fpos;
rhs.dsize = sizeof fpos;
store(lhs, rhs);
}
あたりか。
コンパイルは dbm のオプションで行っているのでそれが問題だろうか。
Cnews は、小文字に変換せずに処理しているようなので
いくつかある lcase をコメントアウトするとちゃんと動くようだ。
Bnews には DBM なしのオプションもあるのでそれを試すといいかもしれない。
Subject の日本語化は、
header.c:
772 /*if (isprint(c) || c == '\b' || c == ' ' || c == '\t') {*/
773 {
774 *cp++ = c;
775 n++;
776 }
あたりか。
Date フィールドの出力は
header.c:
fprintf(fp, "Date: %s\n", arpadate(&t));
ここらへん。
funcs2.c:
p = &ud[22]; /* 1979 */
if (*p == '9') {
*q++ = '1';
*q++ = '9';
} else {
*q++ = '2';
*q++ = '0';
}
これで、4桁年号になる。
Bnews は、Cnews と違って Date を 几帳面に GMT に変換して格納する。
もちろん他のサーバにリレーする時もそうする。
大きな batch ファイルを rnews に食わせるとバスエラーになる。
Program received signal SIGBUS, Bus error.
0x280e91aa in mktemp () from /usr/lib/libc.so.4
(gdb) where
#0 0x280e91aa in mktemp () from /usr/lib/libc.so.4
#1 0x280e90fb in _mktemp () from /usr/lib/libc.so.4
#2 0x280e912a in mktemp () from /usr/lib/libc.so.4
#3 0x805395a in checkbatch () at ifuncs.c:1399
#4 0x804a68d in main (argc=0, argv=0xbfbffc54) at inews.c:529
#5 0x80499ed in _start ()
(gdb)
ifuncs.c:
if (!tfilename) {
tfilename = "/tmp/unbnewsXXXXXX";
/*MKTEMP(tfilename);*/
}
FreeBSD 2.2.8 では、何故かここで落ちるのでコメントアウトする。
XXXXXX がそのままになるが、ここに来るのは圧縮されたニュースファイルが
rnews に渡された場合だけのようなので 私の環境では多重起動される心配が
無いため大丈夫そう。
ifuncs.c:
#define CPBFSZ 8192
char buf[CPBFSZ];
ここのサイズを 81920 程度にすれば MKTEMP の場所は通らなくなる
ようなので今のマシンではそれでも良いだろう。
(gdb) r < 1070-2053
Starting program: /usr/news/rnews < 1070-2053
Program received signal SIGSEGV, Segmentation fault.
0x280eec3a in vfprintf () from /usr/lib/libc.so.4
(gdb) where
#0 0x280eec3a in vfprintf () from /usr/lib/libc.so.4
#1 0x280ed965 in fprintf () from /usr/lib/libc.so.4
#2 0x8059f18 in ihwrite (hp=0x8067fa0, fp=0x28113d98, wr=1) at header.c:731
#3 0x804bb98 in insert () at inews.c:1159
#4 0x804a8f8 in main (argc=0, argv=0xbfbffc54) at inews.c:595
#5 0x80499ed in _start ()
(gdb)
Newsgroup があまりに多いと落ちるようだ。
bash-2.01# /bin/rnews < D.netnewsd004X
inews: Not contributor: posted by kinki777@gray, and you are m@netnews
Cnews と違って、本人以外の cancel はうけつけない。(配送もしない)
control.c:
697 if (!su && STRNCMP(whatsisname, poster, strlen(poster))) {
698 error("Not contributor: posted by %s, and you are %s", poster, whatsisname);
References が欠けるのは
defs.h:
#if defined(pdp11) || defined(SMALL_ADDRESS_SPACE)
# define BUFLEN 128 /* standard buffer size */
#else
# define BUFLEN 256 /* standard buffer size */
# define BUFLEN 1024 /* standard buffer size */
#endif
#define LBUFLEN 1024 /* big buffer size */
#define MBUFLEN 256 /* medium buffer size */
#define MBUFLEN 1024 /* medium buffer size */
#define SBUFLEN 32 /* small buffer size (for system names, etc) */
#define LNCNT 14 /* Articles with > LNCNT lines go through pager */
で修正できる。
defs.dist
#define DFLTEXP 2*WEEKS /* default no. of seconds to expire in */
#define HISTEXP 4*WEEKS /* default no. of seconds to forget in */
expire の既定値と histoiry ファイルから消されるのの既定値。
rnews で受け入れた記事が HISTEXP 以上過去だと junk 送りになる。
2日と4日にしてみたが動きがおかしくなったそのままが良いかもしれない。
active:
fj.1st-readme 1000019 0099999 y
fj.1st-readme.discussion 1000013 0000011 y
都合があって、active ファイルの第二フィールドを 1000000 からに
したところどうやら expire のプログラムはまだ 7桁に対応していない
ようだ。
expire.c:
minart = 99999L;
minart = 9999999L;
/* Change a group name from a.b.c to a/b/c */
でしょうか。
dbm 無しでの使い方がわかった。
-DDBM 無しでコンパイルすると
/usr/news/lib/news/history.d/0 〜 9 の10個のファイルを history ファイル
として使う。インストール時には touch で空のファイルを作っておく。
history ファイルを 10個に分けることで高速化しているようだ。
残念ながら1つの history ファイルだけで動くするようにするのは
むずかしそうだ。
defs.dist
#define NORMGROUPS "all" /* Don't execute rmgroups, just notify. */
/* #define NONEWGROUPS "all" /* Don't create new groups, just notify.*/
既定値では、newgroup は受け入れ、rmgroup は拒否になっている。
control.c:
c_sendsys(argc, argv)
char **argv;
{
Bnews は、sendsys と version というコントロールメッセージが送られてくると
その記事の From: に対して返信を行う。踏台にされるかもしれない。
sys:
vax:world,fj::
Bnews の sys ファイルには、配布範囲(world) と配布する group(fj)を書く。
history.d/0:
1077790391 fj.rec.rail.cars/1000170
1077790391 fj.rec.tv.drama/1000063
1077792328~1078892245 fj.news.lists.filters/1001142
history ファイルには、ID と 記事が到着した日付、ニュースグループ名が書かれる。
Expires: が明示されている記事の場合はそれも書かれる。
(この指示は expire の既定値よりも強い)
expire されるとニュースグループ名が削除される。
さらに一定の日付がたつと全ての情報が削除される。
expire -e 4 で 4 日経過した記事が expire される。
expire -f "hoge@hoge hoge" で hoge の記事が expire の対象となる。
defs.dist:
#define LINES 512 /* maximum no. of lines in .newsrc */
newsgroups 数にあわせて増やしておく。
$readnews -n all
------------------
Newsgroup fj.jokes
------------------
Article 1001090 of 1001178, Thu 20:56.
Subject: Space Mountain
From: subscribe@KenFuny.com
(47 lines) More? [ynq] y
Joke is at the bottom!
Subcribe to KenFuny
readnews で ニュースを読むこともできる。
f を入力するとフォローできるがちゃんと
Followup-To: 指定を守る。かしこい。
ftp://ftp.iij.ad.jp/pub/news/bnews/
に日本語化された Bnews がまだ保存されているようだ。
Path: compaq!galaxy.trc.rwcp.or.jp
From: anand@accent
Newsgroups: fj.personal-ads.friends,fj.personal-ads.misc,fj.personal-ads.penpals,fj.questions.misc,fj.questions.unix,fj.rec.aerospace,fj.rec.animation,fj.rec.autos,fj.rec.autos.sports,fj.rec.autos.wagon,fj.rec.av,fj.rec.bicycles,fj.rec.bus,fj.rec.comics,fj.rec.drink,fj.rec.drink.liquor,fj.rec.fine-arts,fj.rec.fishing,fj.rec.food,fj.rec.games,fj.rec.games.arcade.pinball,fj.rec.games.mahjong,fj.rec.games.pachinko,fj.rec.games.roguelike,fj.rec.games.video.arcade,fj.rec.games.video.arcade.kakutou,fj.rec.games.video.home,fj.rec.games.video.home.playstation,fj.rec.games.video.home.saturn,fj.rec.games.video.home.superfamicom,fj.rec.games.video.pc,fj.rec.gardens,fj.rec.ham,fj.rec.idol,fj.rec.marine,fj.rec.misc,fj.rec.models
Subject: EASY MONEY!!!
Message-ID: <26401b$blr@newsfeeder>
Date: 28 Feb 2004 09:44:11 GMT
Lines: 365
If YOU ARE REALLY INTERESTED IN MAKING LARGE AMOUNTS OF CASH FAST,
で落ちる。
rnews in free(): warning: junk pointer, too high to make sense
rnews in free(): warning: junk pointer, too high to make sense
Program received signal SIGSEGV, Segmentation fault.
0x804bf97 in insert () at inews.c:1195
1195 free(artlinks[c]);
(gdb) where
#0 0x804bf97 in insert () at inews.c:1195
#1 0x804a8fc in main (argc=0, argv=0xbfbffc60) at inews.c:596
#2 0x80499f1 in _start ()
(gdb)
inews.c:
static char *artlinks[128];
で直る。(Newsgroups フィールドに使うバッファを拡張した結果、ニュースグループ
数が増え、ここが足りなくなった)
Path: galaxy.trc.rwcp.or.jp!coconuts.jaist!wnoc-tyo-news!spinnews!spin-hsd0-tky!news-relay.jpn!yan.hp.com!hpujjpo!hpscit.sc.hp.com!sdd.hp.com!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!news.ecn.bgu.edu!ixc.ixc.net!pm1-57.ixc.net!user
From: shyamala@fidonet.org
Newsgroups: misc.test,fj.os.minix,,fj.os.misc,,fj.os.msdos,,fj.os.os2,,fj.os.windows-nt,,fj.ptt,,fj.questions.misc,,fj.questions.unix,,fj.rec.aerospace,,fj.rec.animation,,fj.rec.autos,,fj.rec.autos.wagon,,fj.rec.av,,fj.rec.bicycles,,fj.rec.bus,,fj.rec.bus,,fj.rec.comics,,fj.rec.fine-arts,,fj.rec.fishing,,fj.rec.food,,fj.rec.games,,fj.rec.games.arcade.pinball,,fj.rec.games.mahjong,,fj.rec.games.pachinko,,fj.rec.games.video,,fj.rec.games.video.arcade,,fj.rec.games.video.home,,fj.rec.games.video.home.playstation,,fj.rec.games.video.home.saturn,,fj.rec.games.video.home.superfamicom,fj.rec.games.video.pc,,fj.rec.ham,,fj.rec.idol,,fj.rec.marine,,fj.rec.misc,,fj.rec.models,,fj.rec.motorcycles,,fj.rec.movies,,fj.rec.music,,fj.rec.music.classical,,fj.rec.music.progressive,,fj.rec.mystery,,fj.rec.outdoor,,fj.rec.pets,,fj.rec.pets.aqua,,fj.rec.photo,,fj.rec.play,,fj.rec.radio,,fj.rec.rail,,fj.rec.seiyu,,fj.rec.sf,,fj.rec.sf.startrek
Subject: ===>> A FREE 1 yr. Magazine Sub for You! Over 315 Popular USA Titles/to all countries!
Date: 28 Feb 2004 21:57:09 GMT
Lines: 144
Message-ID:
X-reformat-com
で落ちる。
(gdb) r < /home/msft/fj/fj/fj.questions.unix/p
Starting program: /usr/news/rnews < /home/msft/fj/fj/fj.questions.unix/p
inews: Duplicate fj.rec.bus removed
Program received signal SIGSEGV, Segmentation fault.
0x280efc3a in vfprintf () from /usr/lib/libc.so.4
(gdb) where
#0 0x280efc3a in vfprintf () from /usr/lib/libc.so.4
#1 0x280ee965 in fprintf () from /usr/lib/libc.so.4
#2 0x805a1d4 in ihwrite (hp=0x8071200, fp=0x28114c90, wr=1) at header.c:731
#3 0x804bdb8 in insert () at inews.c:1160
#4 0x804a8fc in main (argc=0, argv=0xbfbffc64) at inews.c:596
#5 0x80499f1 in _start ()
(gdb)
header.c:
729 for (iu = 0; iu < NUNREC; iu++) {
730 if (hp->unrec[iu])
731 fprintf(fp, "%s\n", &hp->unrec[iu][0]);
732 }
733 putc('\n', fp);
ifunc.c:
/*
* Check that header.nbuf contains only valid newsgroup names;
* exit with error if not valid.
*/
ngfcheck(user, isproc, is_mod_init)
char *user;
{
で header の newsgroup の解析をしている。
Newsgroups: フィールドに収まるかはチェックしているがそれより
サイズが大きくなる Xref: のチェックはしていないので同じサイズ
で確保している xref[] が足りなくて unrec[] を壊しているようだ。
header.h:
#ifdef DOXREFS
/* char xref[MBUFLEN]; */ /* Xref: */
char xref[2048]; /* Xref: */
#endif /* DOXREFS */
char *unrec[NUNREC]; /* unrecognized lines */
};
でとおる。
Xref: は必ずしも必要でないので localize.sh から DOXREF を
取っても良い。
# mnews は、Xref: を使って クロスポストを2度読ませないようだ
各バッファのサイズを元の値に戻して動きを見たところ history ファイルに
も問題がでるようだ。history ファイルの1行のサイズには制限がありそこに
おさまらない分の newsgroup は切り捨てられて格納される。その結果、
expire 処理で削除されない記事ができてしまう。
ngfcheck でのチェックをこれらの問題がおこらないように保証しなければ
ならない。
ifunc.c:
for (i = 0; i < ngcount; ++i) {
if (uses[i] < pass)
continue;
if (pass == 1)
j = strlen(ngsbug[i] == (char *) NULL ? ngs[i] : ngsbug[i]);
else
j = strlen(ngs[i]);
if (i > 2) {
logerr("Redone Newsgroups too long");
break;
}
if (j + 2 > avail) {
logerr("Redone Newsgroups too long");
break;
}
これで、newsgroups 数は3までに制限される。やりすぎか。
Newsgroups フィールドのバッファのサイズでニュースグループ数を制限する
コードは入っているが、Xref フィールドは、自ホスト名や各ニュースグループ
での記事番号が入っていて同じバッファのサイズなのでそこで落ちてしまう。
また、history ファイルは同じバッファのサイズで Measeage-ID 、Date 、
ニュースグループ名、記事番号を書く、バッファが足りない場合は勝手に
ニュースグループ名、記事番号を減らしてしまうが、スプールに記事は
存在するので expire 処理で削除されない記事ができてしまう。
記事の番号を 7 桁化したことや、最近の Meseage-ID がやたら長いこと
も関係している。ネストの深い newsgroup 名 も問題か。
松田浩平さんによる Bnews-2.12(Y2K対応済み)
Bnews-2.12.tar.gz http://www.kakio.gr.jp/~jetta/soft/
をみつけた。vnews を日本語化した jnews も含まれている。
jnews は、FreeBSD でも素直にコンパイルでき日本語の記事がちゃんと
表示される。(EUC に対応していないので kterm を SJIS にする必要がある)
Y2K 対応はとても丁寧にされている。SUN でお使いのようだ。
バッファサイズは、
# define BUFLEN 4096 /* standard buffer size */
#define LBUFLEN 32678 /* big buffer size */
#define MBUFLEN 4096 /* medium buffer size */
#define SBUFLEN 512 /* small buffer size (for system names, etc) */
とかなり拡張されている。
inews.c:static char *artlinks[32];
はオリジナルのままだが、32以上のクロスポストの記事が来た時に落ちないのだろうか。
apache
bash-2.01$ cat /usr/local/etc/rc.d/apache.sh
#!/bin/sh
[ -x /usr/local/sbin/httpd ] && /usr/local/sbin/httpd && echo -n ' httpd'
この時に apache に指定したサーバのアドレスが解決できないといけない
のでひっかかった。
bash-2.01# kill -HUP `cat /var/run/httpd.pid`
で再起動。
apache の ログのローテートに関しては、
http://docomo.dyndns.org/logrotate.htm
にヒントあり。
apache の ログの日本語化に関しては、
http://www.inwonder.net/~dayan/soft.html
にヒントあり。
ログを newsyslog を使ってきりつめる。
planet msft ~$cat /etc/newsyslog.conf
# logfilename owner.group mode count size time [ZB]
/var/cron/log 600 3 100 * Z
#
/var/log/httpd-access.log 664 7 * 24 - /var/run/httpd.pid
/var/log/httpd-error.log 664 7 1000 * Z
これで、24時間毎に httpd-access.log を置き換えて kill -HUP `cat /var/run/httpd.pid'
するので ちゃんと log がとれつづける。- は過去分を圧縮しない指定。
apache に mod_gzip を加える
2ch閉鎖の危機を救ったという mod_gzip を apache に加えて html を gzip で
圧縮してからブラウザに送るようにしてみる。
http://www.schroepl.net/projekte/mod_gzip/index.htm
からソースをもってくる。
/apache/src/modules/gzip というディレクトリを作成して
mod_gzip_debug.c Makefile mod_gzip.c
mod_gzip_debug.h Makefile.libdir mod_gzip.h
Makefile.tmpl mod_gzip_compress.c
をそこへコピー。
./configure --activate-module=src/modules/gzip/mod_gzip.a
を指定して apache を confiure してから make。
設定は、
http://www.planet-green.com/linux/mod_gzip.html
が参考になります。
動かしてみると
「DECLINED:NO_ACCEPT_ENCODING」というエラーになり殆ど圧縮せずに送っている。
理由は、ブラウザが送って来る情報に
「HTTP_ACCEPT_ENCODING =gzip」が含まれていないために gzip をしていいか判断
できないため。最近のセキュリティーソフトとかのせいなのでお手上げ。
無視するように改造もできるが、2ch はどうしてるのかしら。
log 管理
/var/log にできる log が大きくなるので、
bash-2.01$ cat /etc/newsyslog.conf
# logfilename owner.group mode count size time [ZB]
/var/cron/log 600 3 100 * Z
の仲間に入れる。
コンソールのメモリも回収
仮想コンソールを止める。
sh-2.01$ cat /etc/ttys
# name getty type status comments
# This entry needed for asking password when init goes to single-user mode
# If you want to be asked for password, change "secure" to "insecure" here
console none unknown off secure
#
ttyv0 "/usr/libexec/getty Pc" cons25 on secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" cons25 off secure
ttyv2 "/usr/libexec/getty Pc" cons25 off secure
ttyv3 "/usr/libexec/getty Pc" cons25 off secure
# Serial terminals
mnewsコンパイルする
mnews の1.21を使用していたが mboxo の日付が2000年対応していない(201 とかになる)
ことに今ごろ気づき1.22をコンパイルインストールした。
(FCC)機能を on にしてコンパイルするとTo:とReply-To:が異なるメールにリプライすると
To:のアドレスをCc:にコピーする。これを知らずに恥をかいた。
.mnews_setup で sort のキーをRefarenceにすると見違える。
1.21 の2000年問題を直す。(もう1900年台はこないということで)
$cat fcc.c
now_time = time((time_t*)NULL);
tm = localtime(&now_time);
if (j) {
fprintf(fp2, "%s%s %s %s %2d %02d:%02d:%02d 20%02d\n", FCC_FROM_FIELD, from,
day_string[tm->tm_wday + 1], month_string[tm->tm_mon + 1],
tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year-100);
}
$cat mnews.c
#endif /* !DONT_HAVE_FTIME */
sprintf(ptr, "%s %s, %d %s 20%02d %02d:%02d:%02d ", DATE_FIELD,
day_string[tm->tm_wday + 1],
tm->tm_mday,
month_string[tm->tm_mon + 1],
tm->tm_year-100,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
while (*ptr) {
ptr++;
}
日本語 Subject を見るために MIMEエンコードを有効にすると
マルチパート対応も有効になるために 添付ファイル付きの spam
でセーブするか聞かれたり、スペースバーを押す回数が増えるの
でそこらへんだけ無効にする。
$cat mnews.c
case 2: /* Content-Type: */
#ifdef MIME
if (mime_format) {
ptr3 = mime_get_type(buff3 + strlen(CONTENT_TYPE_FIELD),
ここと
/*
* 本文部分の変換
*/
#ifdef MIME
if ((mime_mtype != M_MTYPE_UNKNOWN) && (mime_mtype != M_MTYPE_TEXT)) {
status = mime_manage(fp1, mime_mtype, mime_stype, mime_ttype, file_name);
ここの ifdef が無効になるようにする。
日本語perlをコンパイルする
日本語対応 perl のソースは、ソースとパッチの形で置かれているので両方を持って来る。
パッチの内部にある注意書きを良く読む。
TimeDateのインストール
http://search.cpan.org/でダウンロードできる
場所を探す。
sh-2.01$ tar -zxvf TimeDate-1.14.tar.gz
TimeDate-1.14/
TimeDate-1.14/lib/
TimeDate-1.14/lib/Date/
〜〜〜
sh-2.01$ cd TimeDate-1.14
sh-2.01$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for TimeDate
sh-2.01$ make
mkdir blib
mkdir blib/lib
cp lib/Date/Language.pm blib/lib/Date/Language.pm
〜〜〜
sh-2.01$ make test
〜〜〜
All tests successful.
sh-2.01$ make install
Installing /usr/local/lib/perl5/site_perl/5.005/Date/Language.pm
Installing /usr/local/lib/perl5/site_perl/5.005/Date/Language/Italian.pm
〜〜〜
sendmail からDNSサポートをはずす
uucp のみでメールをやりとりしている場合は DNS は使わないが
sendmail の既定値では DNS を参照するためにかなり動作が遅く
なる。(ppp 接続をしているマシンでだけ、何故だろう)
-DNAME_BIND=0 を付けて make することで高速化する。
sendmail で特定 domain からのメールを拒否する
spam が増えてきたので、フィルターをかける。
conf.c:
int
checkcompat(to, e)
register ADDRESS *to;
register ENVELOPE *e;
{
# ifdef lint
if (to == NULL)
to++;
# endif /* lint */
if (tTd(49, 1))
printf("checkcompat(to=%s, from=%s)\n",
to->q_paddr, e->e_from.q_paddr);
/* docomo.ne.jp からのメールは全て User unkown */
if (strstr(e->e_from.q_paddr, "@docomo.ne.jp") != NULL)
{
return (EX_NOUSER);
}
i586_bcopy問題
がらくた箱から初代チャンドラーを出して来てFreeBSDをインストールして
サーバにしたところ1週間程は問題なく動いていたが数時間毎にフリーズ
するようになってしまった。bcopy の解決策で解決したようだ。
bcopy問題ならインストールからひっかかるはずだが。
perlで mimeヘッダをデコードする
Jcodeを参考にしてJcode を
導入する。
ダイナミック DNS に登録する
自宅WWWサーバをして遊ぶために
ダイナミック DNS を使う。
DynDNS.rogに登録する。
実際に自分のサーバを登録する画面
New Dynamic DNS Host
Hostname:[欲しいDNS名を入力する].dyndns.org
IP Address:[自分のサーバのIPADRESSを入力する]
Enable Wildcard (optional):[ここにチェックするとwww.登録した名前とかでもアドレスが解決される]
Mail Exchanger (optional):[ここにIPADRESSを入れると登録したDNS名に対するメールがここへ送付される]
Backup MX? [ここにチェックするとサーバにアクセスできなかった時に Mail Exchanger のアドレスにメールが送付される]
メールを受け取るサーバはちゃんとその DNS名のメールを自分へのメールとして
処理できるように sendmail 等の設定がしてある必要がある。
FreeBSD で、IPADRESS が変わった時に DynDNS.org に登録してもらうために
ddup-3.0.1-unix.tar.gz を使う。
展開して、
>./install
する。
> ddup --host xxx.dyndns.org --ip xxx.xxx.xxx.xx
で登録される。サーバ自身の場合は --ip 以下は不要。
再接続した再に自動で新しいIPADRESSを得て登録に行くようにする。
#!/bin/sh
IFCHECK=$(/sbin/ifconfig tun0|grep ask|awk '{print $2}'|cut -d ':' -f2)
/sbin/ddup --host xxx.dyndns.org --ip $IFCHECK
DynDNSの使い方
ddup-3.0.1のインストール・メモ
pppで内側へのパケットをフィルタリングする
>cat ppp.conf
〜〜〜
set ifilter 0 deny tcp dst eq 23
set ifilter 2 permit 0/0 0/0
これで、外側からの telnet のパケットを通さなくなる。
調査中に気づいたが、サーバの再起動後1回目の ppp の時だけ自分の外部アドレスに
telnetができるようだ。(外部のサーバにはいつでもできる)
使えるメモリ
Netscape を使っているとシステムのメモリには余裕があるのにメモリが
使えなくて終了する。root だとその制限がなくなるようだが危険。
$ulimit -d 32768
で、sh で使うメモリを32kbyteにできる。
でもこれにも上限があるようだ。
/etc/login.conf:
default:\
:cputime=infinity:\
:datasize-cur=16M:\
:stacksize-cur=8M:\
:memorylocked-cur=10M:\
:memoryuse-cur=30M:\
:filesize=infinity:\
:coredumpsize=infinity:\
:maxproc-cur=64:\
:openfiles-cur=64:\
:priority=0:\
:requirehome@:\
:umask=022:\
:tc=auth-defaults:
を変更すると使えるメモリが増えるようだ。
wwwoffleを使う
wwwoffle は、軽い proxy サーバで非力なマシンで
も使うことができる。
コンパイル、インストールするだけで設定ファイル
/etc/wwwoffle.conf
を変更しなくても、実行することができた。
WWWOFFLE を FreeBSDに導入
が参考になる。
create-history-indexes = no
で prevtime* 配下のファイルを作成しなくなる。
$wwwoffle -purge で cache の掃除が行われる。
CDを使う
GENERIC:
controller snd0
device sb0 at isa? port 0x220 irq 5 drq 1 vector sbintr
を有効にして kernel を make する。
cdpaly をインストールすると
$cdplay -d /dev/wcd0a
で CD が聞ける。
mpg123 をインストールして mp3 を聞く。
/dev で ./MAKEDEV snd0
して、/dev/dsp を作ることと
BIOS の設定で sb16 の DMA を1に変更する必要があった。
今度は CD から音楽ファイルの読みだし
dagrab というコマンドを使って CD から wav ファイルを
作成するが、/dev/wcd0c では、TOC エラーになるため
/dev/acd0c を作成する必要がある。
GENELIC:
# Use either the acd or the wcd device, not both!
#device wcd0 #IDE CD-ROM
device acd0 #IDE CD-ROM & CD-R/RW
wcd から acd を有効に書き換えて kernel make 。
/dev/MAKEDEV の wcd の部分を参考に acd を作成して、
$./MKEDEV acd0
で /dev/acd0 のエントリを作成する。
$dagrab -d /dev/acd0c -a
で、CDROM から wav ファイルが作成される。
FreeBSD上でIDE CDROMから音楽データを取り出す方法(dagrabを用いる)
を参考にさせていただいた。
lame をインストールして wav ファイルから mp3 への変換を行う。
$lame input.wav
で input.wav.mp3 というファイルが作成される。(低速だ)
elvis で扱えるファイルサイズを大きくする
config.h の BLKSIZE を大きくする。
config.h
933 #ifndef BLKSIZE
934 # ifdef CRUNCH
935 # define BLKSIZE 1024
936 # else
937 # define BLKSIZE 8192
938 # endif
939 #endif
suck
suck は、NNTPをサポートしているニュースサーバからニュースをダウンロードする
プログラムです。netscape などのブラウザをニュースサーバにつないでニュースを読む
のに比較してあらかじめ指定したニュースグループのニュースをまとめてダウンロード
するので高速です。
suck の代表的なコマンドの説明をします。
-a
suck が、ppp の切断などで異常終了した時も batch ファイルを
作成します。 suck は異常終了した時ももう一度 suck を起動
すれば続きからダウンロードしてくれるので 指定しなくてよさそう
です。
-B
suck が前回異常終了した時は、ダウンロードをする前に batch
ファイルを作ります。
-dd dirname
sucknewsrc のありかを指定します。
-dt dirname
suck が一時的に作成するファイルの置き場所を指定します。
-dm dirname
suck が落したニュースを一時的に格納するディレクトリを指定します。
ディレクトリが無ければ、suck が作成します。
-H
history ファイルのチェックを省略します。
-R
再起動時にニュースサーバから最新の残り記事数を落さない
ようにします。ニュースサーバに落ちて来る記事数が自分の
回線速度より速くて全ての記事がダウンロードできない時
に指定するといいでしょう。
-U userid -P password
NNTP サーバがユーザIDとパスワードを要求するタイプなどの
場合に指定します。
-br filename
出力するバッチファイル名を指定します。
wget
$wget -r -H -A html -Dwww.test.com,www.html.com http://www.html.com/index.html
で、www.html.com/index.html からたどれる www.test.com、www.html.com 配下の html
を持ってくくる。
-r
再帰的に link をたどる。
-H
host をまたいでたどる。
-A
指定した拡張子のファイルだけを持ってくる。
-k
取得したファイルの絶対指定を相対指定に書き換える。
-D
指定した host 内のみを参照する。
-l DEPTH
リンクをたどる階層数を指定する。(ディフォルトは 5)
-nc
一度とりこんだファイルを再度とりこまない。
$ lftp http://www.html.com/~test
lftp> get *.html
もあり。
AirH"で ppp
AirH" で ppp 接続をする場合にパケットの間隔が5秒以上空くと
レスポンスが悪化するようだ。
#ping -i 6 -c 10 yahoo.co.jp
PING yahoo.co.jp (202.229.198.216): 56 data bytes
64 bytes from 202.229.198.216: icmp_seq=0 ttl=246 time=367.764 ms
64 bytes from 202.229.198.216: icmp_seq=1 ttl=246 time=770.159 ms
64 bytes from 202.229.198.216: icmp_seq=2 ttl=246 time=940.214 ms
64 bytes from 202.229.198.216: icmp_seq=3 ttl=246 time=1210.248 ms
64 bytes from 202.229.198.216: icmp_seq=4 ttl=246 time=1000.258 ms
64 bytes from 202.229.198.216: icmp_seq=5 ttl=246 time=1180.224 ms
64 bytes from 202.229.198.216: icmp_seq=6 ttl=246 time=1080.244 ms
64 bytes from 202.229.198.216: icmp_seq=7 ttl=246 time=1210.228 ms
64 bytes from 202.229.198.216: icmp_seq=8 ttl=246 time=1190.254 ms
64 bytes from 202.229.198.216: icmp_seq=9 ttl=246 time=1290.245 ms
#ping -i 5 -c 10 yahoo.co.jp
PING yahoo.co.jp (210.81.150.5): 56 data bytes
64 bytes from 210.81.150.5: icmp_seq=0 ttl=240 time=387.802 ms
64 bytes from 210.81.150.5: icmp_seq=1 ttl=240 time=380.220 ms
64 bytes from 210.81.150.5: icmp_seq=2 ttl=240 time=410.241 ms
64 bytes from 210.81.150.5: icmp_seq=3 ttl=240 time=400.263 ms
64 bytes from 210.81.150.5: icmp_seq=4 ttl=240 time=460.302 ms
64 bytes from 210.81.150.5: icmp_seq=5 ttl=240 time=450.297 ms
64 bytes from 210.81.150.5: icmp_seq=6 ttl=240 time=440.254 ms
64 bytes from 210.81.150.5: icmp_seq=7 ttl=240 time=390.292 ms
64 bytes from 210.81.150.5: icmp_seq=8 ttl=240 time=380.281 ms
64 bytes from 210.81.150.5: icmp_seq=9 ttl=240 time=370.293 ms
ケーブルTVでインターネット
ケーブルTVのプロバイダに接続するための設定
DHCPでグローバルアドレスを与えられるタイプ
なので、FreeBSDの notePC にイーサネットカード
を2枚差ししてed0はDHCPでプロバイダに接続
ed1はお家ネットワークに接続、natd で他の
パソコンからもインターネットを使えるようにする。
まずイーサカードを2枚差しする設定。
/etc/pccard.conf
# Accton EN2216 EtherCard
card "ACCTON" "EN2216-PCMCIA-ETHERNET"
# config 0x22 "ed0" any 0x10
config 0x22 "ed1" any 0x10
ether 0x1c0 00:00:e8
insert /etc/pccard_ether $device
insert echo Accton EN2216 inserted
remove /etc/pccard_ether_remove $device
remove echo Accton EN2216 removed
/etc/rc.conf
pccard_ether="ed0 ed1 ep0 fe0 sn0" # Pccard ethernet interfaces (or NO).
ifconfig_ed0="DHCP"
ifconfig_ed1="inet 10.16.29.77 netmask 255.255.255.0"
これで2枚差ししてイントラ側からこのマシンへの telnet と
このマシンで インタネットへの接続が可能になった。
次に NAT の設定をしてイントラの他のマシンからインタネットに
接続できるようにする。
/usr/src/sys/i386/conf/GENERIC
options IPFIREWALL #firewall
options IPDIVERT #divert sockets
を追加してカーネルを make する。
このカーネルはちゃんと natd を設定しないと
イントラネットからも login できない。
/etc/services
natd 8668/divert
を追加する。
/etc/natd.cf
log yes
deny_incoming no
use_sockets no
same_ports yes
verbose no
port 6668
interface ed0
unregistered_only no
# redirect_port tcp bsd:telnet telnet この行を有効にすると telnet は bsd へ
を追加する。
/usr/local/etc/rc.d/natd.sh
#! /bin/sh
# Start up Network Address Translation Daemon (natd)
/sbin/ipfw -f flush
/sbin/ipfw add divert 6668 ip from any to any via ed0
#/sbin/ipfw add deny all from any to any 32 via ed0 # telnet をマスクする
/sbin/ipfw add pass all from any to any
/usr/sbin/natd -f /etc/natd.cf;
echo 'Network Address Translation Daemon (natd)';
この場所だと、mountd や nfsd より後に起動されるので問題があるかもしれない。
テスト中は、nameserver はとりあえず他のプロバイダのでも使えるようだ。
usb 接続の webcam を使う
[webcam]
参照。
bt848,bt878 のボードを使ってビデオキャプチャをする
私が買ったのは、
GV-BCTV5E。
bt878 という chip を使っていて Linux,freebsd と相性がいいらしい。
kernel のコンフィグファイルに次の1行を追加する。
device bktr0
以下を追加。
$cat /etc/sysctl.conf
hw.bt848.card=16
hw.bt848.tuner=9
ここまでで、kernel にカードが認識される。
/kernel: bktr0: mem 0x40500000-0x40500fff irq 11 at device 10.0 on pci2
/kernel: bktr0: Warning - card vendor 0x10fc (model 0xd018) unknown.
/kernel: bktr0: Pinnacle/Miro TV, Philips SECAM tuner.
fxtv: bt848 からの画像を表示、キャプチャするソフト。キャプチャ中に画面が表示されない。
画像が乱れていたのが fxtv -disableDirectV でちゃんと出るようになった。
キャプチャをするには
/usr/ports/audio/mpegaudio
/usr/ports/audio/sox
/usr/ports/multimedia/mplex
も必要。
キャプチャを実行すると
======FRAMES READ: 231
::STATUS:: 0
::EXEC:: sox -t raw -s -w -c 2 -r 44100 test.AUDraw -t aiff -s -w test.aiff && mpeg_musicin -l 2 -p 1 test.aiff test.mp2
>>> Using Audio IFF sound file headers
Sound data is not PCM in "test.aiff".
::STATUS:: 1
Command Failed:
sox -t raw -s -w -c 2 -r 44100 test.AUDraw -t aiff -s -w test.aiff && mpeg_musicin -l 2 -p 1 test.aiff test.mp2
Conversion Aborted.
$
とエラーになる。
こちらを参考に
fxtv_cnvt.sh を
out_soxfn="$out_fnbase.wav"
out_soxfmt="WAV"
aiff→wavと変更する。
sox で生成した wav,aiff ファイルと 入力の raw ファイルを比較すると
$od -x test.wav | tail -n 3
3016020 ecee e64a ecad e39c ef77 dc5e f547 d495
3016040 fac7 cdaa fecf c83a 0207 c6bd
3016054
$od -x test.aiff | tail -n 3
3016100 77ef 5edc 47f5 95d4 c7fa aacd cffe 3ac8
3016120 0702 bdc6
3016124
$od -x test.AUDraw | tail -n 3
3015740 ee17 e415 ecee e64a ecad e39c ef77 dc5e
3015760 f547 d495 fac7 cdaa fecf c83a 0207 c6bd
3016000
と確かに aiff ファイルは リトルインディアン、ビッグインディアンの問題そう
だが、 aiff は Mac のフォーマットだそうでそれでいいのかも、わからん。
音声はサウンドカードの音声入力につないだ。
WAV ファイルを使うようにしてとりあえず問題は回避されたが
ファイルのサイズが大きくなると? 今度は mp2 生成の途中で引っかかる。
とりあえず流れは
$fxtv -batch streamavcap -streaminput test.AVraw -frameformat PPM
-videotarget - -streamfps 30 -audiotarget test.AUDraw |
mpeg_encode test.param
$sox -t raw -s -w -c 2 -r 44100 test.AUDraw -t wav -s -w test.wav
$mpeg_musicin -l 2 -p 1 test.wav test.mp2
$mplex test.mpg test.mp2 test.mps
mpeg_musicin の処理が終らない。
{148230}{148231}
Program received signal SIGINT, Interrupt.
0x8055b0a in subsampling (power=0x8086000, ltg=0x808e000, tone=0xbfbfe4f4,
noise=0xbfbfe4f0) at tonal.c:485
485 if(power[i].x < ltg[power[i].map].hear){
(gdb) step
0x8055b0d 485 if(power[i].x < ltg[power[i].map].hear){
なんか i が -100 になってる。
こんな感じで無限ループしているようだ。
void II_tonal_label(power, tone) /* this function extracts (tonal) */
の STOP → LAST にしたらとりあえず終了する。(中身はみてません)
おもしろいことに mpeg_musicin は wav ファイルじゃなくて raw を直接食わせて
も動くようだ。
ports/multimedia/mjpegtools をインストールして、
$mp2enc -b 384 -o test.mp2 < test.wav
で mp2 ファイルを作る手もある。こちらの方がビットレートも変更できるので
いいかも。ただし、mjpegtools には mplex が含まれていて ports/multimedia/mplex
とオプションが違う上に こけるので ports/multimedia/mplex で上書きすることを忘れずに。
$mp2enc -b 128 -o x-files1.mp2 < x-files1.wav
**ERROR: [mp2enc] failure reading WAV file
wav ファイルがおおきすぎるとエラーになるようだ。
結局
fxtv そのままの設定で取り込むと
処理時間が(私のパソコンでは)キャプチャ時間の何倍もかかる上に
320x240 で raw ファイルが(私のパソコンでは)ばかでかいのに mpg
の圧縮が効きすぎで画像が荒いので、160x120 にして、mpg 圧縮の
パラメータを
#IQSCALE 8
#PQSCALE 10
#BQSCALE 25
IQSCALE 4
PQSCALE 5
BQSCALE 25
と変更して圧縮率を弱めた。また、これだと画像ファイルより音声
ファイルの方が大きいので、mp2 圧縮のビットレートを 128 にした。
mpeg2enc を使うこともできる。
$fxtv -batch streamavcap -streaminput test.AVraw -frameformat PPM
-videotarget - -streamfps 30 -audiotarget test.AUDraw > test.ppm
$ppmtoy4m test.ppm | mpeg2enc -o test.mpg
あまりサイズはかわらないようだ。
その他のツール。
xawtv:bt848からの画像を表示する。
mplayer:mpegを見るツール。ステレオで音声も再生される。
mtv:mpegを見るツール。音声も再生される。モノラルかな。mtvp でも可。
aviplay:mpegを見るツール。音声も再生される。
xmmix:音量をコントロールする。
wavplay:WAVファイルを再生。
splay:mp?音声ファイルを再生。
xwave:WAV音声ファイルを再生。
xine:mpegを見るツール。音声も再生される。完成度が高いが重い。
avidemux:ffmpeg で生成した avi ファイルを編集できる GUI。
ここまで来て ffmpeg というツールがあることを発見。
ffmpeg out.mpg で直接 bt878 から mpeg ファイルに落せてしまうようだ。
でも私のマシンでは処理が追い付かず音飛びしてしまう。
とりあえず、
$ffmpeg -i x-files1.wav -ab 128 x-files1.mp2
で wav → mp2 の変換ができる。
$ffmpeg -i test.mps -f avi test.avi
で、fxtv の生成物を MPEG-4 にできる。サイズが数分の一になる、画質はそれなり。
$ffmpeg -i test.mps -f avi -acodec mp3 test.avi
と指定すると audio が mp3 になる。
$ffmpeg -t 30 -s 320x240 -r 29.97 -b 2500 -ab 224 -ac 2 -f avi test.avi
でビデオ入力から30秒間の録画ができる音飛びもない。
-b がビットレートの指定でこれが出力ファイルのサイズに効いて来る。
320x240 なら 1000 位がいいかもしれない。
これで作成されるファイルは、MotionJPEG なようでサイズもそれなりなので
もう一度 ffmpeg に通してやるとサイズが小さくなる。(ただし ffmpeg に
入力できるサイズに上限があるようで数時間分のファイルは処理できなかった)
ffmpeg は batch で実行できるのでこれで 不在時にも録画ができる。
ports/audio/cam でボリュームのコントロールをする。
ffmpeg で録画する前に録音のレベルを設定するのに使用する。
$cam -l 20,20 -r 20,20
どうも録音するかどうかというフラグがあって(xmmix参照)それは
cam では設定できないようなので、
ports/audio/ermixer を使う
$ermixer -a
vol is set to -> [0:0] -> RECORDABLE
pcm is set to -> [61:61] -> PLAY
speaker is set to -> [0:0] -> MUTE
line is set to -> [75:75] -> RECORDABLE
mic is set to -> [75:75] -> RECORDING
cd is set to -> [75:75] -> RECORDABLE
rec is set to -> [75:75] -> PLAY
line1 is set to -> [0:0] -> RECORDABLE
phin is set to -> [0:0] -> RECORDABLE
phout is set to -> [0:0] -> RECORDABLE
video is set to -> [75:75] -> RECORDABLE
monitor is set to -> [75:75] -> PLAY
で各チャネルの状態が表示される。私は、line に音声の入力をつないで
いるので、 line にボリュームを設定して RECORDING にし、rec にも
ボリュームを設定する。
$ermixer line 75:75
$ermixer rec 75:75
$ermixer +rec line
at コマンドについて
at コマンドは任意の時刻にjobを実行できる batch 処理プログラム
$echo "who" | at 1500
で今日の 15:00 に who を実行する。
$echo "who" | at 1500 tomorrow
で明日の 15:00 に who を実行する。
at コマンドが job を投入するのは、5分おきのようだ、 at 1501 と
指定すると 15:05 に実行が開始されるようだ。
$atq でキューに入っている job が表示される。
$atrm job番号 で job が削除される。
root 以外のユーザに at コマンドを許可するには、
/var/at/at.allow にユーザ名を記述する。
nice コマンドについて
エンコード処理を実行しているとマシンが重くなるので優先度を調整してやる。
$nice -10 who
で優先度 10 で who が実行される。数が小さい方が優先度が高く、通常の
コマンドは 0 で実行されている。
FreeBSD 4.7 あれこれ
i815 を使って X を動かすためには、カーネルの 再 make も
必要なようなので、「FreeBSD XF86Config i815」あたりを指定
して google する。
startx で X を起動すると xhost で許可しても他のマシンから
Window をひらけない。 xinit ではひらける。
linux 版 の netscape48 でうまく 日本語のブックマークが表示され
ない。とりあえず mozilla を使う。
FreeBSD 4.8-STABLE あれこれ
3000円で買って来た Compaq の P5-120Mhz にインストールした。
boot 時に毎回 エラーが出るが F1 キーを押すことで(Compaq のBIOSのメッセージ)
180Gbyte のIDE-HDDが使えている。(この HDD の mbr から boot している)
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ad0s1a 128990 46292 72380 39% /
/dev/ad0s1f 257998 4 237356 0% /tmp
/dev/ad0s1g 153101746 18377028 122476580 13% /usr
/dev/ad0s1e 257998 1416 235944 1% /var
procfs 4 4 0 100% /proc
kernel を make しようとしたが、kernel のソースしかインストールしなかったので
ftp サイトから 全ソースを wget した。
2枚のNE2000互換ISAカードを使う。(10BASE-5 が泣かせる)
kernel の GENERIC に ed1 のエントリを追加して kernel を make。
そのカーネルで起動時に boot -c をすると ed1 のエントリがあるので
それを有効化する。(何故か反映されないので /boot/kernel.conf を直接 edit した)
/stand/sysinstall に ed1 のエントリが現れるので設定する。
ftp できなかったがそれは、/etc/group にユーザ名を加えたせいだった。
Unixあれこれ
$nohup command &
で、端末を閉じても実行が継続される。
$hexdump -x filename
$ ps agx | grep kterm | grep -v grep | awk '{print $1}'
$ sort -u
で同じ行は1行出力。
$grep -v
でその word を含まない行を出力。
# cd /usr/src
# make buildkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL
でカーネル置換。
$sed "s/{.*}//" < input > output
wget -c について
http.c:
1236 logputs (LOG_VERBOSE, _("\
1237 \n The file is already fully retrieved; nothing to do.\n\n"));
1238 /* In case the caller inspects. */
1239 hs->len = contlen;
1240 hs->res = 0;
1241 /* Mark as successfully retrieved. */
1242 *dt |= RETROKF;
1243 FREE_MAYBE (type);
1244 FREE_MAYBE (all_headers);
1245 CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
1246 might be more bytes in the body.
1247 return RETRUNNEEDED;
1248 }
1249
1250 /* Check for condition #1. */
1251 if (hs->no_truncate)
1252 {
1253 logprintf (LOG_NOTQUIET,
1254 _("\
1255 \n\
1256 Continued download failed on this file, which conflicts with `-c'.\n\
1257 Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
1258 FREE_MAYBE (type);
1259 FREE_MAYBE (all_headers);
1260 CLOSE_INVALIDATE (sock);
1261 return CONTNOTSUPPORTED;
1262 }
ここで -c の時にダウンロードする必要の有無をきめている。
http.c:
705 if (hs->restval)
706 {
707 range = (char *)alloca (13 + numdigit (hs->restval) + 4);
708 /* Gag me! Some servers (e.g. WebSitePro) have been known to
709 respond to the following `Range' format by generating a
710 multipart/x-byte-ranges MIME document! This MIME type was
711 present in an old draft of the byteranges specification.
712 HTTP/1.1 specifies a multipart/byte-ranges MIME type, but
713 only if multiple non-overlapping ranges are requested --
714 which Wget never does. */
715 sprintf (range, "Range: bytes=%ld-\r\n", hs->restval);
716 }
717 else
718 range = NULL;
ここで、-c の場合にサーバに要求する開始 byte を
決めている。Range: は終了 byte も指定できる。
845 /* Construct the request. */
846 sprintf (request, "\
847 %s %s HTTP/1.0\r\n\
848 User-Agent: %s\r\n\
849 Host: %s%s\r\n\
850 Accept: %s\r\n\
851 %s%s%s%s%s%s%s%s\r\n",
852 command, full_path,
853 useragent, u->host,
854 port_maybe ? port_maybe : "",
855 HTTP_ACCEPT,
856 request_keep_alive ? request_keep_alive : "",
857 referer ? referer : "",
858 cookies ? cookies : "",
859 wwwauth ? wwwauth : "",
860 proxyauth ? proxyauth : "",
861 range ? range : "",
862 pragma_h,
863 opt.user_header ? opt.user_header : "");
864 DEBUGP (("---request begin---\n%s---request end---\n", request));
ここらが送るリクエストの内容。
1371 /* Get the contents of the document. */
1372 hs->res = get_contents (sock, fp, &hs->len, hs->restval,
1373 (contlen != -1 ? contlen : 0),
1374 &rbuf, keep_alive, &hs->dltime);
ここで、ダウンロードした内容を fd に書き出している。
1592 /* Try fetching the document, or at least its head. */
1593 err = gethttp (u, &hstat, dt, proxy);
1660 case RETRUNNEEDED:
1661 /* The file was already fully retrieved. */
1662 free_hstat (&hstat);
1663 FREE_MAYBE (dummy);
1664 return RETROK;
1665 break;
すでに落としてあったファイルと同じサイズだった場合。
1835 else if (!opt.kill_longer) /* meaning we got more than expecte
1836 {
1837 logprintf (LOG_VERBOSE,
1838 _("%s (%s) - `%s' saved [%ld/%ld])\n\n"),
1839 tms, tmrate, locf, hstat.len, hstat.contlen);
1840 logprintf (LOG_NONVERBOSE,
1841 "%s URL:%s [%ld/%ld] -> \"%s\" [%d]\n",
1842 tms, u->url, hstat.len, hstat.contlen, locf, co
1843 ++opt.numurls;
1844 downloaded_increase (hstat.len);
出力ファイルに書き出したよのメッセージ。
retr.c
137 get_contents (int fd, FILE *fp, long *len, long restval, long expected,
138 struct rbuf *rbuf, int use_expected, long *elapsed)
139 {
140 int res = 0;
141 static char c[8192];
142 void *progress = NULL;
143 struct wget_timer *timer = wtimer_allocate ();
144 long dltime = 0, last_dltime = 0;
145
146 *len = restval;
147
148 if (opt.verbose)
149 progress = progress_create (restval, expected);
150
151 if (rbuf && RBUF_FD (rbuf) == fd)
152 {
153 int sz = 0;
154 while ((res = rbuf_flush (rbuf, c, sizeof (c))) != 0)
155 {
156 fwrite (c, sizeof (char), res, fp);
内容をコピーしている。
suck について
batch.c:
150 /* first put #! rnews size */
151 fprintf(fptr, "#! rnews %ld\n", (long) sbuf.st_size);
ここで batch ファイルの先頭を書き出している。
lpost というプログラムがついている。
$cat in.file | lpost
とするとローカルの c-news サーバにpostしてくれる。
$cat .forward
"| sed -e \"s/^To: hoge/Newsgroups: org.freebsd.jp.freebsd-users-jp/\"| lpost "
なんて書くとメーリングリストのメールをローカルのニュースサーバに
ポストしてくれる。
mail2news について
http://tack.fukui-med.ac.jp/NetBSD/ja/mail2news.html
/etc/aliases
nnrpd - クライアント用 NNTP サーバ
nnrpd [ -b address ] [ -D ] [ -g shadowgroup ] [ -o ] [ -p
port ] [ -r reason ] [ -R ] [ -s title padding ] [ -t ]
2ch-nntpd - simple and optimistic implementation of 2ch-to-NNTP gateway
nntpd
Mail2News Mini-Howtoが c-news でも変更なく使えた。
w3m で 2ch.cgi を使う
2ch の dat ファイルを使って遊んでみたいので テキストブラウザ w3m で使える
2ch.cgi というのを使ってみる。
w3m は ports からインストールする。
2ch.cgi は、
http://www.mit.edu/afs/sipb/project/sandbox/fustflum/src/w3m-0.4.1/Bonus/
から持ってくる。
このままでは最近2chにかかっている check のせいで使えないので、
http://mi.med.tohoku.ac.jp/~satodai/w3m-dev/200304.month/3883.html
にある patch を適用する。(ようするに User-Agent を指定してやる)
http://www.mnet.ne.jp/%7Etnomura/w3m2.html
を参考に
$ cd ~/
$ mkdir cgi-bin
しそこに 2cg.cgi を置く。
$w3m .
で w3m を立ち上げ「o」を押しオプションメニューの画面に行きカーソルで
ディレクトリ設定の「/cgi-bin で表されるディレクトリ」 で return を押して
cgi-bin のディレクトリを設定する
━━━━━━━━━━━━━━━━━━━━━━━━
ディレクトリ設定
/ で表されるディレクトリ(document root) [ ]
/~user で表されるディレクトリ [ ]
/cgi-bin で表されるディレクトリ [/home/hoge/cgi-bin ]
各ディレクトリのインデックスファイル [ ]
[OK]
━━━━━━━━━━━━━━━━━━━━━━━━
「q」で抜ける。これで設定は完了したので起動する。
$w3m file:/cgi-bin/2ch.cgi?http://pc.2ch.net/test/read.cgi/unix/1066574642/
抜けて .w3m2ch/pc.2ch.net/test/dat/ 配下に dat ファイルがあれば成功。
この cgi では、 wget -c というコマンドを使って dat ファイルを取得している。
-c オプションというのは、ローカルにあるファイルのサイズの byte 数を越える
部分をサーバに要求するもので転送量がすくなくなる。
だが、2ch には あぼーんという処理があり、サーバ側の dat ファイルの途中が
削除されることがある この dat ファイルに対して あぼーん以前にロードした
dat ファイルを指定して wget -c をかけると変な継ぎはぎの dat ファイルが
できてしまう。
2ちゃんねるの仕様
あぼーんについて
RFC2616
そこで、あぼーんに対応するように wget を修正した。動きは、
通常の dat ファイルの byte 数分以降をサーバに要求
→ダウンロードできたら、元の dat ファイルの最後の 1byte 分をサーバに要求
→それが'\n'なら終了。違うならあぼーんされたとして全てをダウンロードする。
wget-1.8.2 をアボーン対応にするパッチ
wget-1.9 をアボーン対応にするパッチ
PuRoxy - 2chブラウザ
PuRoxy は、2ch.cgi と同様の cgi でより高機能。
インストールは、wget と gzip のパスと menu ページの URL を変更してやる
必要がある。このツールにも wget の patch は有効。
$cont =~ s|Message-ID: <([\041-\073\075-\177]{2,})>|Message-ID: <$1><\/a>|g;
で netnews 対応。
Puoxy の wget に指定されているオプションは、
wget -q -U -c -x -T -t -P
-q: ログ出力なし
-U: User Agent指定。
-c: 継続処理
-x: ローカルにディレクトリを作成する。
-T: タイムアウト秒数。
-t: 試行回数の指定
-P: ローカルディレクトリ指定。
http://www.mirv.net/gappa/my2ch.cgi.txt
http://masarin.dip.jp/~hoge/
もおもしろい。
wget おもしろいオプション
-N: タイムスタンプでダウンロードを判定する。
--header=Accept-Encoding: gzip
を wget に指定するとサーバが対応していれば gzip で圧縮したファイルで
送られてくる。
2ch では、html ファイルは gzip して送られてくるが .dat ファイルは常に
非圧縮で送られる仕様のようだ。
856 名前:名無しさん@お腹いっぱい。投稿日: 02/03/27 00:58 ID:???
場合わけをきちんとしようや。
・更新があるばあい
・Head(stat) [+ Get(read)]
・ims-Get(stat&read)
・ない場合。
・Head(stat)
・ims-Get(stat)
で、どっちにしろ、更新があれば中身をみたくなるわけで、
むしろIf-Modified-SinceをつけたGetの方が軽いのでは?
というのがすくなくとも8ヶ月前の結論だったわけですが。
xpbiff
xpbiff は、メールがくるとSubjectをPopup して知らせてくれる
プログラム。しかも日本語 Subject 対応。
だが最近2,3日に一回は落ちるようになった。
調べてみると
(gdb) r
Starting program: xpbiff
Program received signal SIGSEGV, Segmentation fault.
0x804be76 in jis2euc (src=0x805f70f '\216' ...)
at xpbiff.c:1503
1503 *dst++ = (*src++ | 128);
(gdb)
(gdb) p *src
$1 = -114 '\216'
(gdb) p *dst
Error accessing memory address 0x806a000: Bad address.
(gdb) list
1498 *dst++ = (*src++ | 128);
1499 *dst++ = (*src++ | 128);
1500 }
1501 else if ((kana == True) || (*src & 128)) {
1502 *dst++ = 142;
1503 *dst++ = (*src++ | 128);
1504 }
1505 else
1506 *dst++ = *src++;
1507 }
(gdb)
Subject の日本語変換のところで落ちている。
落ちるメールをつめていくと
$cat p
Subject: 1234,1234
$od -x p
0000000 7553 6a62 6365 3a74 3120 3332 ae34 312c
0000020 3332 0a34
0000024
なんか「,」だけじゃなくて 0xae が入っていてこけている。
0xae なので 1501 の if で別にカナじゃないけど 1502 の処理にいく、
ここで *src の方はインクリメントしないのに *dst の方だけインクリメント
するので 結局 *src の方が足りなくてアボートする。
とりあえず、1501 と 1502 の間に *src++; を追加した。
Byte Bench 2.1
Byte Bench の Bug を見つけたと思った。
$nbench
BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)
TEST : Iterations/sec. : Old Index : New Index
: : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT : 329.63 : 8.45 : 2.78
STRING SORT : 23.872 : 10.67 : 1.65
BITFIELD : 9.896e+07 : 16.98 : 3.55
FP EMULATION : 20.592 : 9.88 : 2.28
FOURIER : 5020.5 : 5.71 : 3.21
Segmentation fault (core dumped)
nbench1.c:
1823 for(i=0;i