COPS のインストール

河本孝之(KAWAMOTO Takayuki)

Contact: takayuki.kawamoto@markupdancing.net

ORCID iD iconORCID, Google Scholar, PhilPapers.

First appeared: 2018-11-01 15:59:21,
Modified: [BLANK],
Last modified: 2019-09-18 10:51:36.

はじめに

COPS(Computer Oracle and Password System)は、ダン・ファーマー(Daniel Farmer)さんが1989年から開発を始めた、セキュリティ監査用のツールを集めたスイートです。UNIX/Linux 用のセキュリティ監査ツールとしては最初期に当たるものとされており、古典的な脆弱性検査の指針・設計・技術を実装した実例として、僕は現在でも学ぶことがあると思って当サイトで紹介しました。このページでは、実際に COPS を2018年現在の Debian や FreeBSD で使うことを想定して、手順をご紹介します。他のプラットフォームで導入される方の参考になれば幸いです。なお、COPS を紹介している日本語のページは非常に少ないのですが、kozupon.com の解説ページでもインストール手順が紹介されているので、そちらも参照してみてください。

冒頭に戻る

ソースコードのダウンロードからインストールに必要な環境の整備まで

本稿では、まず Debian GNU/Linux 9.5(コードネーム “stretch” の系統に属しているリリース・バージョン。2018年7月14日に公開)、AMD64 版(amd64/x86-64、つまり 64 ビット版)での作業を仮定しています。Debian でのインストール手順を紹介したら、その次に、FreeBSD 12.0 RELEASE(r341666 GENERIC for amd64, 2018年12月11日に公開)での作業もご紹介します(実は Debian を動かしていた会社のマシンが電源の故障で動作しなくなり、新しいマシンへは FreeBSD を入れたためです)。恐らく多くの UNIX/Linux ディストリビューション、とりわけ Debian の系列として開発されている Ubuntu や、FreeBSD と同じく UNIX の BSD 系列であれば、ほぼ同じ作業で COPS をインストールできると思いますが、不足しているソフトウェアやライブラリを追加する場合は、それぞれの OS でサポートされている方法(パッケージ管理システム。Debian なら apt / dpkg、CentOS なら rpm / yum、FreeBSD なら ports など)や、ソースからのコンパイル方法などは今後も必要になると思うので、それぞれ調べて学んでください。本稿は LPIC 講座ではないので、特に Debian GNU/Linux や BSD 系統の UNIX 全般の運用については、基本的なコマンドやディレクトリ構造などの知識は読者が既にご存知であると仮定します。

なお、FreeBSD でのインストールを先に読みたい方は、このリンクを使ってください。

冒頭に戻る

Debian 9.5 でのインストール

さて、COPS はソースコードが無料で公開されていて、それをコンパイルして各自のコンピュータにインストールします。そこで、まずファーマーさんがパデュー大学のサーバでホストしてもらっているソースコードをダウンロードしましょう*。なお、本稿のプロンプト画面の表記(<code> 要素として反転させてある表記)では、特別な表記がない限り、常に root(スーパーユーザ)で作業しているものとします。作業ディレクトリは /root です。

*ソースコードがダウンロードできなくなっている場合は、当サイトでもホストしているので、以下からダウンロードしてください。なお、ファーマーさん本人によって、ZIP 形式で GitHub でもホストされているようです。

また、それぞれの OS でサポートされているパッケージとしてインストールできる場合があります。Debian のパッケージはありませんが、FreeBSD では /security/cops があるようです。パッケージ管理システムを使うと、依存関係を調整しながら自動でインストールできるため、本稿の解説は不要となるかもしれません。

# wget ftp://coast.cs.purdue.edu/pub/tools/unix/scanners/cops/cops.1.04.tar.gz --2018-10-31 13:52:24-- ftp://coast.cs.purdue.edu/pub/tools/unix/scanners/cops/cops.1.04.tar.gz => ‘cops.1.04.tar.gz’ Resolving coast.cs.purdue.edu (coast.cs.purdue.edu)... 128.10.252.10 Connecting to coast.cs.purdue.edu (coast.cs.purdue.edu)|128.10.252.10|:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD (1) /pub/tools/unix/scanners/cops ... done. ==> SIZE cops.1.04.tar.gz ... done. ==> PASV ... done. ==> RETR cops.1.04.tar.gz ... done. [...] 2018-10-31 13:52:29 (152 KB/s) - ‘cops.1.04.tar.gz’ saved [290863]

ソースのアーカイブをダウンロードしたら、tar コマンドで展開してみましょう。

# tar zxvf cops.1.04.tar.gz cops_104/ cops_104/MANIFEST cops_104/bug.chk cops_104/README.1 cops_104/README.3 cops_104/passwd.chk cops_104/XTRA_CREDIT cops_104/chk_strings cops_104/bug.chk.aix cops_104/cops cops_104/bug_cmp cops_104/cover_letter cops_104/crc.chk cops_104/crc_list cops_104/cron.chk cops_104/dev.chk cops_104/bug.chk.dec cops_104/disclaimer cops_104/docs/ cops_104/docs/COPS.report cops_104/docs/KUANG.README cops_104/docs/SUID.README cops_104/docs/cops cops_104/docs/dev.chk cops_104/docs/CRC.README cops_104/docs/home.chk cops_104/docs/pass.chk cops_104/docs/is_able cops_104/docs/kuang.1 cops_104/docs/kuang.man cops_104/docs/rc.chk cops_104/docs/is_able.chk cops_104/docs/release.notes cops_104/docs/suid.man cops_104/docs/tilde cops_104/docs/warnings cops_104/docs/root.chk cops_104/docs/cron.chk cops_104/docs/group.chk cops_104/docs/pass_diff.chk cops_104/docs/user.chk cops_104/docs/makefile cops_104/docs/passwd.chk cops_104/docs/misc.chk cops_104/docs/ftp.chk cops_104/docs/COPS.tex cops_104/docs/readme.sequent cops_104/docs/is_writable cops_104/docs/readme.C2 cops_104/docs/readme.apollo cops_104/docs/readme.ibm cops_104/docs/readme.shadow cops_104/docs/readme.svr4 cops_104/docs/readme.xenix cops_104/docs/readme.yp cops_104/docs/bug.chk cops_104/docs/readme.filter cops_104/docs/obligitory.joke cops_104/docs/obligitory.album cops_104/extensions/ cops_104/extensions/THINGS_2_DO cops_104/extensions/YAR cops_104/extensions/crypto-stuff cops_104/extensions/netstuff cops_104/extensions/passwords cops_104/extensions/questions cops_104/extensions/uucp.hardening cops_104/extensions/writing.suid cops_104/bug.chk.sgi cops_104/ftp.chk cops_104/kuang cops_104/group.chk cops_104/init_kuang cops_104/is_able.chk cops_104/rc.chk cops_104/is_able.lst cops_104/kuang.pl.shar cops_104/makefile cops_104/misc.chk cops_104/pass.words cops_104/pass_diff.chk cops_104/bug.chk.sun cops_104/patchlevel.h cops_104/quick_start cops_104/bug.chk.apollo cops_104/bug.chk.next cops_104/bug.chk.svr4 cops_104/platform cops_104/cops_filter cops_104/reconfig cops_104/res_diff cops_104/root.chk cops_104/src/ cops_104/src/addto.c cops_104/src/clearfiles.c cops_104/src/crc.c cops_104/src/crc_check.c cops_104/src/filewriters.c cops_104/src/home.chk.c cops_104/src/is_able.c cops_104/src/is_something.c cops_104/src/members.c cops_104/src/pass.c cops_104/src/tilde.c cops_104/src/user.chk.c cops_104/src/conf.h cops_104/src/crack-fcrypt.c cops_104/src/crack-lib.c cops_104/src/crack.h cops_104/suid.chk cops_104/yp_pass.chk cops_104/extra_src/ cops_104/extra_src/diff_last.sh cops_104/extra_src/mail.chk cops_104/extra_src/trust.pl cops_104/extra_src/bad_dir.pl cops_104/extra_src/stop.make cops_104/extra_src/README cops_104/extra_src/uucp_quick.chk cops_104/extra_src/uucp_2.shar cops_104/extra_src/rhosts_sweeper cops_104/extra_src/pass.mail cops_104/extra_src/uucp_1.shar cops_104/checkacct/ cops_104/checkacct/Article cops_104/checkacct/Intro cops_104/checkacct/Makefile cops_104/checkacct/README.FIRST cops_104/checkacct/bsd.m4 cops_104/checkacct/ca.src cops_104/checkacct/chkacct.1l cops_104/checkacct/dotwrite cops_104/checkacct/effect.dotwrit cops_104/checkacct/effect.owners cops_104/checkacct/effect.read cops_104/checkacct/effect.rhosts cops_104/checkacct/effect.setuid cops_104/checkacct/effect.write cops_104/checkacct/owners cops_104/checkacct/prm.mm cops_104/checkacct/prompt.help cops_104/checkacct/readable cops_104/checkacct/rhosts cops_104/checkacct/rhosts.pl cops_104/checkacct/setuid cops_104/checkacct/sysV.m4 cops_104/checkacct/write cops_104/carp/ cops_104/carp/carp.1 cops_104/carp/carp cops_104/carp/carp.anlz cops_104/carp/carp.table cops_104/carp/carp.awk cops_104/carp/carp.anlz.1 cops_104/carp/carp2ps cops_104/carp/carp2ps.1 cops_104/carp/README cops_104/carp/How2Change cops_104/perl/ cops_104/perl/shadow.sh cops_104/perl/README.kuang cops_104/perl/cops.cf.orig cops_104/perl/cops.cf cops_104/perl/chk_strings cops_104/perl/chk_strings.pl cops_104/perl/cops cops_104/perl/cron.chk cops_104/perl/dev.chk cops_104/perl/fgrep.pl cops_104/perl/file_mode.pl cops_104/perl/file_owner.pl cops_104/perl/ftp.chk cops_104/perl/get-cf cops_104/perl/getopts.pl cops_104/perl/glob.pl cops_104/perl/group.chk cops_104/perl/hostname.pl cops_104/perl/is_able.chk cops_104/perl/is_able.lst cops_104/perl/kuang cops_104/perl/is_able.pl cops_104/perl/kuang.1 cops_104/perl/misc.chk cops_104/perl/pass.chk cops_104/perl/pass.cache.pl cops_104/perl/passwd.chk cops_104/perl/pathconf.pl cops_104/perl/pathconf.sh cops_104/perl/rc.chk cops_104/perl/reconfig.pl cops_104/perl/root.chk cops_104/perl/rules.pl cops_104/perl/stat.pl cops_104/perl/suckline.pl cops_104/perl/suid.chk cops_104/perl/suid.stop cops_104/perl/user.chk cops_104/perl/yagrip.pl cops_104/perl/prl.patch cops_104/perl/README.sgi cops_104/README.2.sh cops_104/README.2.pl cops_104/README.FIRST cops_104/suid.stop

ここで早速 make してみると、make というコマンドがないというエラーが出る場合があります。そういうエラーが出たら、まだそのマシンではソースをコンパイルするための環境が整備されていない可能性があるので、apt-get コマンドで必要なパッケージを追加しておきましょう。

# make bash: make: command not found # apt-get install gcc make [...] Do you want to continue? [Y/n] Y [...] #

もちろん、gcc や make を個別にインストールしなくても、代わりに build-essential をインストールしても構いません。

# apt-get install build-essential [...] Do you want to continue? [Y/n] Y [...] Setting up build-essential (12.3) ... Processing triggers for libc-bin (2.24-11+deb9u3) ... #

終わったら、以下のようにバージョンを確認できるかどうか試してみましょう。

# gcc --version gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # make --version GNU Make 4.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

これで COPS をインストールする準備は整いました(本稿では、Perl 版の COPS を使うことは想定していません)。次に、アーカイブを展開して作成された cops_104 というディレクトリに移動し、COPS のコンパイルを始めるにあたって、reconfig というプログラムを実行します。これは、COPS で使われているプログラムにハードコーディングされているパスを書き換えるための設定変更ツールです。

# ./reconfig checking to make sure all the target(s) are here... So far so good... Looking for all the commands now... Warning! tftp not found! misc.chk will not work as planned. Warning! uudecode not found! misc.chk will not work as planned. Ok, now doing substitutions on the shell scripts... Changing paths in makefile... Changing paths in docs/makefile... Changing paths in chk_strings... Changing paths in cops... Changing paths in crc.chk... Changing paths in misc.chk... Changing paths in dev.chk... Changing paths in ftp.chk... Changing paths in is_able.chk... Changing paths in cron.chk... Changing paths in group.chk... Changing paths in passwd.chk... Changing paths in rc.chk... Changing paths in root.chk... Changing paths in suid.chk... Changing paths in kuang... Changing paths in init_kuang... Changing paths in res_diff... Changing paths in pass_diff.chk... Changing paths in yp_pass.chk...

画面からは幾つかのファイルのパスが書き換えられたことが分かります。そして、書き換えられる前のファイルは “.old” という文字列が追加された別名で保存されていますので、どこが変わっているのかは両者を比較すれば分かります。試しに passwd.chk というファイルの差分を確認してみましょう。

# diff ./passwd.chk ./passwd.chk.old 35,36c35,36 < AWK=/usr/bin/gawk < TEST=/usr/bin/test --- > AWK=/bin/awk > TEST=/bin/test

上記から、passwd.chk では35行目と36行目が書き換えられていることが分かります。このように、それぞれ変更されたファイルの異同について後から確認できますので、インストールの途中で特定のファイルだけインストールできなかったような場合には、パスの指定が依然として不適切である可能性もありますから、再確認する方法として覚えておくのがよいかもしれません(ただし、diff は変更された箇所しか示さないので、変更されていないがためにインストールに失敗したような状況では、原因の特定に役立たない可能性もあります)。

次に、make するに当っては reconfig で変更された内容だけだと不十分である可能性があるため、/cops_104/makefile というファイルを開いて確認します。COPS のスクリプトの内容は1992年の OS なり実行環境を元に書かれているため、2018年の現在と比較しても25年以上の開きがあり、ポータブルに書かれたシェルプログラミングのコードだとしても、実行するにあたっては丁寧に確認しておく方が望ましいでしょう。

# Simple Makefile for the COPS system; compiles, and chmods # the programs. # # make all -- makes everything # make install -- puts things in their place # make -- make a given program INSTALL_DIR= sun EXECUTABLE = home.chk user.chk pass.chk is_writable crc crc_check \ addto clearfiles filewriters members tilde is_able C_SRC = home.chk.c user.chk.c is_able.c pass.c is_something.c \ addto.c clearfiles.c filewriters.c members.c tilde.c \ crc.c crc_check.c SHELL_PROGS= chk_strings root.chk dev.chk cron.chk is_able.chk \ cops group.chk rc.chk passwd.chk ftp.chk crc.chk \ misc.chk suid.chk kuang init_kuang reconfig res_diff \ yp_pass.chk bug.chk bug.chk.aix bug.chk.apollo \ bug.chk.dec bug.chk.next bug.chk.sgi bug.chk.sun \ bug.chk.svr4 bug_cmp SUPPORT = is_able.lst suid.stop crc_list # CFLAGS = -O # sequents need "-lseq" as well... uncomment this if you're running on one: # SEQFLAGS = -lseq # Certain systems need to uncomment this to compile the pass.chk; Xenix, # some SysV: # BRAINDEADFLAGS = -lcrypt # # systems without rindex need to uncomment this: # CRC_FLAG=-Dstrrchr=rindex # # Where the programs are.... # CHMOD=/bin/chmod TEST=/usr/bin/test MKDIR=/bin/mkdir CP=/bin/cp CC=/usr/bin/cc RM=/bin/rm # make default default: $(EXECUTABLE) $(CHMOD) u+x $(SHELL_PROGS) # make all all: $(EXECUTABLE) cd docs; make $(CHMOD) u+x $(SHELL_PROGS) # hammer the binaries and formatted docs; if compiled fcrypt stuff, # will trash the *.o files, too. clean: $(RM) -f $(EXECUTABLE) pass.o crack-fcrypt.o crack-lib.o cd docs; make clean man: cd docs; make # make a dir and shove everything in the proper place install: -if $(TEST) ! -d $(INSTALL_DIR) ; then mkdir $(INSTALL_DIR) ; fi $(CP) $(EXECUTABLE) $(SHELL_PROGS) $(SUPPORT) $(INSTALL_DIR) # make the programs addto: src/addto.c $(CC) $(CFLAGS) -o addto src/addto.c clearfiles: src/clearfiles.c $(CC) $(CFLAGS) -o clearfiles src/clearfiles.c filewriters: src/filewriters.c $(CC) $(CFLAGS) -o filewriters src/filewriters.c members: src/members.c $(CC) $(CFLAGS) -o members src/members.c home.chk: src/home.chk.c $(CC) $(CFLAGS) -o home.chk src/home.chk.c user.chk: src/user.chk.c $(CC) $(CFLAGS) -o user.chk src/user.chk.c is_able: src/is_able.c $(CC) $(CFLAGS) -o is_able src/is_able.c is_writable: src/is_something.c $(CC) $(CFLAGS) -DWRITABLE -o is_writable src/is_something.c # If fast crypt will work, comment the first CC line, uncomment # the next two: pass.chk: src/pass.c $(CC) $(CFLAGS) -o pass.chk src/pass.c $(BRAINDEADFLAGS) # $(CC) $(CFLAGS) -Dcrypt=fcrypt -DFCRYPT -o pass.chk src/pass.c \ # src/crack-fcrypt.c src/crack-lib.c $(BRAINDEADFLAGS) tilde: src/tilde.c $(CC) $(CFLAGS) -o tilde src/tilde.c crc: src/crc.c $(CC) $(CFLAGS) -o crc src/crc.c $(SEQFLAGS) crc_check: src/crc_check.c $(CC) $(CFLAGS) $(CRC_FLAG) -o crc_check src/crc_check.c $(SEQFLAGS) # the end

上記の中で強調してある箇所は kozupon.com さんのサイトで解説されている makefile の変更箇所です(これに加えて、docs/makefile も修正する必要があります)。そして、コメントアウトしたりコメントアウトを解除する際には、コマンド行の先頭に不要な半角スペースが残っていないかどうか確認しましょう。この確認を怠ってコメント行の先頭に半角スペースが残ってしまうと、make しても即座に停まってしまいます。

# make makefile:96: *** missing separator. Stop.

これは makefile というファイルで行の先頭で半角スペースを使っていることが原因で起きているエラーです。このような場合は、make の処理を混乱させないように、コマンド行の先頭では半角スペースの代わりにタブ文字を使わなくてはなりません。この点について、色々と過去へ遡って掲示板やウェブページを検索してみましたが、なぜそうなっているのかという重要なポイントを理解して説明している人は少なく、しょせん「ヘビーユーザ」と言われる人たちの多くはバッドノウハウの経験者にすぎないと分かります。

ターゲット: 依存ファイル(複数可)
[タブ文字] コマンド

上記のような書式は、makefile においてシンタクスとして決まっており、タブ文字はターゲット行とコマンド行を区別するためのセパレータとして必要なのです。よって、コマンドの前に挿入するタブ文字は、あってもなくてもいいインデント用のあしらいではありませんから、インデントできればいいとばかりに半角スペースを使うというのは、そもそも書式を理解していない証拠です。また、半角スペースでエラーが出ているからといって「インデントするからだ」とスペースを単純に削除するのも間違いであることが分かります。

冒頭に戻る

make からインストールまで

ということで、makefile ファイルを編集しなおしてから、改めて make してみましょう・・・。

# make /usr/bin/cc -O -o home.chk src/home.chk.c src/home.chk.c:58:1: warning: return type defaults to ‘int’ [-Wimplicit-int] main(argc,argv) ^~~~ src/home.chk.c: In function ‘main’: src/home.chk.c:58:1: warning: type of ‘argc’ defaults to ‘int’ [-Wimplicit-int] src/home.chk.c:67:3: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration] printf("Usage: %s\n",argv[0]); ^~~~~~ src/home.chk.c:67:3: warning: incompatible implicit declaration of built-in function ‘printf’ src/home.chk.c:67:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ src/home.chk.c:68:3: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration] exit(1); ^~~~ src/home.chk.c:68:3: warning: incompatible implicit declaration of built-in function ‘exit’ src/home.chk.c:68:3: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’ src/home.chk.c:80:4: warning: incompatible implicit declaration of built-in function ‘printf’ printf("Warning! User %s's home directory %s is not a directory! (mode 0%o)\n", ^~~~~~ src/home.chk.c:80:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ src/home.chk.c:90:3: warning: incompatible implicit declaration of built-in function ‘printf’ printf("Warning! User %s's home directory %s is mode 0%3.3o!\n", ^~~~~~ src/home.chk.c:90:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ src/home.chk.c:95:2: warning: incompatible implicit declaration of built-in function ‘exit’ exit(0); ^~~~ src/home.chk.c:95:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’ /usr/bin/cc -O -o user.chk src/user.chk.c src/user.chk.c:32:13: warning: conflicting types for built-in function ‘malloc’ char *ftr, *malloc(); ^~~~~~ [...] src/is_able.c:220:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’ /bin/chmod u+x chk_strings root.chk dev.chk cron.chk is_able.chk cops group.chk rc.chk passwd.chk ftp.chk crc.chk misc.chk suid.chk kuang init_kuang reconfig res_diff yp_pass.chk bug.chk bug.chk.aix bug.chk.apollo bug.chk.dec bug.chk.next bug.chk.sgi bug.chk.sun bug.chk.svr4 bug_cmp

敢えて全ての出力内容は掲載しませんが、このように夥しい数の警告が出ます。とは言え、致命的なエラーでストップしているわけではないため、そのまま続行は出来ます。

# make all cd docs; make make[1]: Entering directory '/root/cops_104/docs' /usr/bin/nroff suid.man > suid.man.ms /usr/bin/nroff kuang.man > kuang.man.ms /usr/bin/nroff -man cops > cops.1 cops:99: warning: can't find special character `vV\' /usr/bin/nroff -man cron.chk > cron.chk.1 /usr/bin/nroff -man dev.chk > dev.chk.1 /usr/bin/nroff -man group.chk > group.chk.1 /usr/bin/nroff -man is_able.chk > is_able.chk.1 /usr/bin/nroff -man passwd.chk > passwd.chk.1 /usr/bin/nroff -man is_able > is_able.1 /usr/bin/nroff -man home.chk > home.chk.1 /usr/bin/nroff -man user.chk > user.chk.1 /usr/bin/nroff -man pass.chk > pass.chk.1 /usr/bin/nroff -man root.chk > root.chk.1 /usr/bin/nroff -man rc.chk > rc.chk.1 /usr/bin/nroff -man pass_diff.chk > pass_diff.chk.1 /usr/bin/nroff -man misc.chk > misc.chk.1 /usr/bin/nroff -man is_writable > is_writable.1 /usr/bin/nroff -man bug.chk > bug.chk.1 make[1]: Leaving directory '/root/cops_104/docs' /bin/chmod u+x chk_strings root.chk dev.chk cron.chk is_able.chk cops group.chk rc.chk passwd.chk ftp.chk crc.chk misc.chk suid.chk kuang init_kuang reconfig res_diff yp_pass.chk bug.chk bug.chk.aix bug.chk.apollo bug.chk.dec bug.chk.next bug.chk.sgi bug.chk.sun bug.chk.svr4 bug_cmp # make install if /usr/bin/test ! -d /usr/local/cops ; then mkdir /usr/local/cops ; fi /bin/cp home.chk user.chk pass.chk is_writable crc crc_check addto clearfiles filewriters members tilde is_able chk_strings root.chk dev.chk cron.chk is_able.chk cops group.chk rc.chk passwd.chk ftp.chk crc.chk misc.chk suid.chk kuang init_kuang reconfig res_diff yp_pass.chk bug.chk bug.chk.aix bug.chk.apollo bug.chk.dec bug.chk.next bug.chk.sgi bug.chk.sun bug.chk.svr4 bug_cmp is_able.lst suid.stop crc_list /usr/local/cops

これで、/usr/local/cops に一連のプログラムがインストールされています。

# ls -al total 364 drwxr-sr-x 2 root staff 4096 Nov 1 15:47 . drwxrwsr-x 11 root staff 4096 Nov 1 12:26 .. -rwxr-xr-x 1 root staff 13240 Nov 1 15:47 addto -rwx------ 1 root staff 3531 Nov 1 15:47 bug.chk -rwx------ 1 root staff 1204 Nov 1 15:47 bug.chk.aix -rwx------ 1 root staff 1087 Nov 1 15:47 bug.chk.apollo -rwx------ 1 root staff 1120 Nov 1 15:47 bug.chk.dec -rwx------ 1 root staff 1901 Nov 1 15:47 bug.chk.next -rwx------ 1 root staff 999 Nov 1 15:47 bug.chk.sgi -rwx------ 1 root staff 5683 Nov 1 15:47 bug.chk.sun -rwx------ 1 root staff 1393 Nov 1 15:47 bug.chk.svr4 -rwx------ 1 root staff 1364 Nov 1 15:47 bug_cmp -rwxr--r-- 1 root staff 2028 Nov 1 15:47 chk_strings -rwxr-xr-x 1 root staff 9024 Nov 1 15:47 clearfiles -rwxr--r-- 1 root staff 10016 Nov 1 15:47 cops -rwxr-xr-x 1 root staff 14008 Nov 1 15:47 crc -rwxr-xr-x 1 root staff 13352 Nov 1 15:47 crc_check -rwxr--r-- 1 root staff 2220 Nov 1 15:47 crc.chk -rwxr-xr-x 1 root staff 1143 Nov 1 15:47 crc_list -rwxr--r-- 1 root staff 2295 Nov 1 15:47 cron.chk -rwxr--r-- 1 root staff 3452 Nov 1 15:47 dev.chk -rwxr-xr-x 1 root staff 9152 Nov 1 15:47 filewriters -rwxr--r-- 1 root staff 8396 Nov 1 15:47 ftp.chk -rwxr--r-- 1 root staff 5961 Nov 1 15:47 group.chk -rwxr-xr-x 1 root staff 8840 Nov 1 15:47 home.chk -rwxr--r-- 1 root staff 950 Nov 1 15:47 init_kuang -rwxr-xr-x 1 root staff 13168 Nov 1 15:47 is_able -rwxr--r-- 1 root staff 2345 Nov 1 15:47 is_able.chk -rwxr-xr-x 1 root staff 1678 Nov 1 15:47 is_able.lst -rwxr-xr-x 1 root staff 8944 Nov 1 15:47 is_writable -rwxr--r-- 1 root staff 5978 Nov 1 15:47 kuang -rwxr-xr-x 1 root staff 9048 Nov 1 15:47 members -rwxr--r-- 1 root staff 4107 Nov 1 15:47 misc.chk -rwxr-xr-x 1 root staff 34136 Nov 1 15:47 pass.chk -rwxr--r-- 1 root staff 6591 Nov 1 15:47 passwd.chk -rwxr--r-- 1 root staff 3282 Nov 1 15:47 rc.chk -rwx------ 1 root staff 5636 Nov 1 15:47 reconfig -rwxr--r-- 1 root staff 1342 Nov 1 15:47 res_diff -rwxr--r-- 1 root staff 4939 Nov 1 15:47 root.chk -rwxr--r-- 1 root staff 6587 Nov 1 15:47 suid.chk -rwxr-xr-x 1 root staff 644 Nov 1 15:47 suid.stop -rwxr-xr-x 1 root staff 8744 Nov 1 15:47 tilde -rwxr-xr-x 1 root staff 13296 Nov 1 15:47 user.chk -rwxr--r-- 1 root staff 890 Nov 1 15:47 yp_pass.chk

冒頭に戻る

FreeBSD 12.0-RELEASE でのインストール

FreeBSD 12.0-RELEASE では、Ports というパッケージ(ソフトウェアのインストール・データ一式)のコレクションがあって、COPS も最初から FreeBSD でのインストール用に調整されて、この Ports というコレクションに入っています。

# cd /usr/ports/security/cops

これで、COPS の port(パッケージ)があるツリーに移動できます。ふつうのディレクトリ移動と同じことです。本来、httpd や python のようなソフトウェアであれば、最新版をインストールするために portsnap update というコマンドを使ってコレクションを更新しなくてはなりません。COPS の場合は、既に更新が止まっていることが明らかなので、Ports 全体を更新する必要はないでしょう。cops ディレクトリの中を見てみましょう。

# ls -la total 60 drwxr-xr-x 3 root wheel 512 Sep 6 17:11 . drwxr-xr-x 1331 root wheel 31232 Sep 6 17:12 .. -rw-r--r-- 1 root wheel 1467 May 31 2017 Makefile -rw-r--r-- 1 root wheel 124 Jan 23 2014 distinfo drwxr-xr-x 2 root wheel 512 Sep 6 17:11 files -rw-r--r-- 1 root wheel 462 Jan 23 2014 pkg-descr -rw-r--r-- 1 root wheel 4586 Nov 13 2014 pkg-plist

では、COPS をインストールしてみましょう。make install で始まります。途中のプロセスで、一度だけドキュメントを一緒にビルドするかどうか問われますので、必要ならチェックして続行してください・・・どうでしょうか。失敗したと思います。

# make install ===> cops-1.04_1 depends on file: /usr/local/sbin/pkg - not found ===> Building/installing dialog4ports as it is required for the config dialog ===> Cleaning for dialog4ports-0.1.6 ===> License BSD2CLAUSE accepted by the user ===> dialog4ports-0.1.6 depends on file: /usr/local/sbin/pkg - not found ===> Skipping 'config' as NO_DIALOG is defined ===> License BSD2CLAUSE accepted by the user => freebsd-pkg-1.11.1_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/. => Attempting to fetch https://codeload.github.com/freebsd/pkg/tar.gz/1.11.1?dummy=/freebsd-pkg-1.11.1_GH0.tar.gz fetch: https://codeload.github.com/freebsd/pkg/tar.gz/1.11.1?dummy=/freebsd-pkg-1.11.1_GH0.tar.gz: size unknown fetch: https://codeload.github.com/freebsd/pkg/tar.gz/1.11.1?dummy=/freebsd-pkg-1.11.1_GH0.tar.gz: size of remote file is not known freebsd-pkg-1.11.1_GH0.tar.gz 0 B 0 Bpsfreebsd-pkg-1.11.1_GH0.tar.gz 1952 kB 5381 kBpsfreebsd-pkg-1.11.1_GH0.tar.gz 3477 kB 5717 kBps 01s ===> Fetching all distfiles required by pkg-1.11.1 for building ===> Extracting for pkg-1.11.1 ===> License BSD2CLAUSE accepted by the user ===> Fetching all distfiles required by pkg-1.11.1 for building => SHA256 Checksum OK for freebsd-pkg-1.11.1_GH0.tar.gz. ===> Patching for pkg-1.11.1 ===> Configuring for pkg-1.11.1 No installed jimsh or tclsh, building local bootstrap jimsh0 Host System...x86_64-unknown-freebsd12.0 Build System...x86_64-unknown-freebsd12.0 C compiler... cc -O2 -pipe -Wno-error -fstack-protector-strong -fno-strict-aliasing C++ compiler... c++ -O2 -pipe -Wno-error -fstack-protector-strong -fno-strict-aliasing Build C compiler...cc Checking for stdlib.h...ok Checking for git...no [...] ====> Compressing man pages (compress-man) ===> Installing for pkg-1.11.1 ===> Checking if pkg is already installed ===> pkg-1.11.1 is already installed You may wish to ``make deinstall'' and install this port again by ``make reinstall'' to upgrade it properly. If you really wish to overwrite the old port of pkg without deleting it first, set the variable "FORCE_PKG_REGISTER" in your environment or the "make install" command line. *** Error code 1 Stop. make[3]: stopped in /usr/ports/ports-mgmt/pkg *** Error code 1 Stop. make[2]: stopped in /usr/ports/ports-mgmt/pkg *** Error code 1 Stop. make[1]: stopped in /usr/ports/ports-mgmt/pkg *** Error code 1 Stop. make: stopped in /usr/ports/security/cops

メッセージには make reinstall すればいいかもしれないと出ていますが、実際は同じエラーが発生します。正しくインストールするには、pkg install cops とするのが良さそうです。

# pkg install cops Updating FreeBSD repository catalogue... pkg: Repository FreeBSD load error: access repo file(/var/db/pkg/repo-FreeBSD.sqlite) failed: No such file or directory Fetching meta.txz: 0%Fetching meta.txz: 100% 944 B 0.9kB/s 00:01 [...] New version of pkg detected; it needs to be installed first. The following 1 package(s) will be affected (of 0 checked): Installed packages to be UPGRADED: pkg: 1.10.5_5 -> 1.11.1 Number of packages to be upgraded: 1 3 MiB to be downloaded. [...] Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 2 package(s) will be affected (of 0 checked): New packages to be INSTALLED: cops: 1.04_1 perl5: 5.28.2 Number of packages to be installed: 2 The process will require 60 MiB more space. 14 MiB to be downloaded. [...] The /usr/bin/perl symlink has been removed starting with Perl 5.20. For shebangs, you should either use: #!/usr/local/bin/perl or #!/usr/bin/env perl The first one will only work if you have a /usr/local/bin/perl, the second will work as long as perl is in PATH.

このようにして、Debian の場合と同じく /usr/local/cops に COPS のファイル一式がインストールされます。

これでインストール作業はひととおり完了です。COPS はプログラムの一式なので、passwd.chk のような個々のプログラムを実行して検査してもいいのですが、一括して検査する cops を使いたい場合は設定ファイルで事前に幾つかの調整が必要ですから、これについては別のページで解説します。

冒頭に戻る


※ 以下の SNS 共有ボタンは JavaScript を使っておらず、ボタンを押すまでは SNS サイトと全く通信しません。

Twitter Facebook