Lennyのセキュリティサポート終了後の「sources.list」の設定

2/6でDebian Lennyのセキュリティサポートの提供が終了しました。

 参考:debian-volatile プロジェクト
 http://www.debian.org/volatile/

 参考:volatile replaced by new updates suite
 http://lists.debian.org/debian-volatile-announce/2011/msg00000.html

■squidのapt経由のアクセスログを確認

 http://ftp.jp.debian.org/debian/dists/lenny/
 http://security.debian.org/dists/lenny/updates/
 http://volatile.debian.org/debian-volatile

■ブラウザでアクセスして以下を確認

 http://security.debian.org/dists/oldstable/updates/
 http://ftp.jp.debian.org/debian/dists/lenny-proposed-updates/

■上記を踏まえて以下に編集

$ vim sources.list
#
# deb cdrom:[Debian GNU/Linux 5.0.8 _Lenny_ - Official amd64 NETINST Binary-1 20110123-01:13]/ lenny main

#deb cdrom:[Debian GNU/Linux 5.0.8 _Lenny_ - Official amd64 NETINST Binary-1 20110123-01:13]/ lenny main

deb http://ftp.jp.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ lenny main contrib non-free

deb http://ftp.jp.debian.org/debian/ lenny-proposed-updates main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ lenny-proposed-updates main contrib non-free

deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main

deb http://security.debian.org/ oldstable/updates main
deb-src http://security.debian.org/ oldstable/updates main

deb http://volatile.debian.org/debian-volatile lenny/volatile main
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main

■更新して、HTTPステータスコードが「200」であるアクセスを確認します。

$ apt-get update && apt-get upgrade

$ sudo grep " 200 " /var/log/squid/access.log | \
     awk -F\" '{print $2}' | sed s%"/main.*\|/contrib.*\|/non-free.*\|Release.*"%%g | \
     sed s%" HTTP/.*"%%g | sed s/"GET "//g | sort | uniq
http://ftp.jp.debian.org/debian/dists/lenny-proposed-updates
http://ftp.jp.debian.org/debian/dists/lenny-proposed-updates/
http://ftp.jp.debian.org/debian/pool
http://security.debian.org/dists/lenny/updates
http://security.debian.org/dists/lenny/updates/
http://security.debian.org/dists/oldstable/updates
http://security.debian.org/dists/oldstable/updates/
http://volatile.debian.org/debian-volatile/dists/lenny/volatile/

■上記と更新なしが一致する事を確認します。

$ sudo grep " 304 " /var/log/squid/access.log | awk -F\" '{print $2}' | \
    sed s%"/main.*\|/contrib.*\|/non-free.*\|Release.*"%%g | \
    sed s%" HTTP/.*"%%g | sed s/"GET "//g | sort | uniq
http://ftp.jp.debian.org/debian/dists/lenny
http://ftp.jp.debian.org/debian/dists/lenny-proposed-updates
http://ftp.jp.debian.org/debian/dists/lenny-proposed-updates/
http://ftp.jp.debian.org/debian/dists/lenny/
http://security.debian.org/dists/lenny/updates
http://security.debian.org/dists/lenny/updates/
http://security.debian.org/dists/oldstable/updates
http://security.debian.org/dists/oldstable/updates/
http://volatile.debian.org/debian-volatile/dists/lenny/volatile
http://volatile.debian.org/debian-volatile/dists/lenny/volatile/

■おまけ

 HTTPのステータスコードの「304」は更新なし。「404」となる理由は様々だけど、
 もうページが存在しない可能性もある。
 ⇒実際にブラウザアクセスして確認して、本当に存在しなくなっていたら、sources.listからも除外する。
  「apt-get update」時に存在しないURLに行けば直ぐに分かるので、余り役には立たないので、おまけとする。

■スクリプトについて

 1.combined形式のsquidのログから、「Debian APT-HTTP」クライアントを抽出
 2.GREPLISTのURLに絞込み、「.deb 」ファイルは除く。
 3.HTTPステータスコードが300より大きい場合に、「HTTP STATUS:XXX」の形式で出力
 4.URLから「http://」と「/」の間(つまりドメイン部分)のみを抽出
 5.並べ替えと重複をカウント(重複が無い場合は出力しない)

$ sudo vim squid_lennycheck.sh
#!/bin/bash

if [ `id -u` -ne 0 ];then
  echo "Not Permite User"
  exit 1
fi

GREPLIST="ftp.jp.debian.org security.debian.org volatile.debian.org"
for list in ${GREPLIST};do
  grep 'Debian APT-HTTP' /var/log/squid/access.log | \
    grep "$list" | grep -v ".deb " | \
    awk -F\" '{print $2 "," $3}' | \
    awk '($4 > 300) {print "HTTP STATUS:" $4 " " $2}' | \
    sed s%http://%%g | awk -F\/ '{print $1}' | \
    sort | uniq -c -d
done

■出力結果は以下の通り。

$ sudo ./squid_lennycheck.sh
     64 HTTP STATUS:304 ftp.jp.debian.org
     71 HTTP STATUS:404 ftp.jp.debian.org
     24 HTTP STATUS:304 security.debian.org
     22 HTTP STATUS:404 security.debian.org
     19 HTTP STATUS:304 volatile.debian.org
     18 HTTP STATUS:404 volatile.debian.org