| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | #!/bin/sh -e# checking debian-tor accountuid=`getent passwd debian-tor | cut -d ":" -f 3`home=`getent passwd debian-tor | cut -d ":" -f 6`# if there is the uid the account is there and we can do# the sanit(ar)y checks otherwise we can safely create it.if [ "$uid" ]; then	if [ "$home" = "/var/lib/tor" ]; then		:		#echo "debian-tor homedir check: ok"	else		echo "ERROR: debian-tor account has an unexpected home directory!"		echo "It should be '/var/lib/tor', but it is '$home'."		echo "Removing the debian-tor user might fix this, but the question"		echo "remains how you got into this mess to begin with."		exit 1	fielse	adduser --quiet \		--system \		--disabled-password \		--home /var/lib/tor \		--no-create-home \		--shell /bin/bash \		--group \		debian-torfifor i in lib run log; do	if ! [ -d "/var/$i/tor" ]; then		echo "Something or somebody made /var/$i/tor disappear."		echo "Creating one for you again."		mkdir "/var/$i/tor"	fidonefind /var/lib/tor \( \( ! -user debian-tor \) -o \( ! -group debian-tor \) \) -print0 | xargs -0 --no-run-if-empty chown debian-tor:debian-torfind /var/lib/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02700find /var/lib/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00600find /var/run/tor \( \( ! -user debian-tor \) -o \( ! -group debian-tor \) \) -print0 | xargs -0 --no-run-if-empty chown debian-tor:debian-torfind /var/run/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02750find /var/run/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00600find /var/log/tor \( \( ! -user debian-tor \) -o \( ! -group adm \) \) -print0 | xargs -0 --no-run-if-empty chown debian-tor:admfind /var/log/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02750find /var/log/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00640move_away_keys=0if [ "$1" = "configure" ] &&   [ -e /var/lib/tor/keys ] &&   [ ! -z "$2" ]; then	if dpkg --compare-versions "$2" lt 0.1.2.19-2; then		move_away_keys=1	elif dpkg --compare-versions "$2" gt 0.2.0 &&	     dpkg --compare-versions "$2" lt 0.2.0.26-rc; then		move_away_keys=1	fifiif [ "$move_away_keys" = "1" ]; then	echo "Retiring possibly compromised keys.  See /usr/share/doc/tor/NEWS.Debian.gz"	echo "and /var/lib/tor/keys/moved-away-by-tor-package/README.REALLY for"	echo "further information."	if ! [ -d /var/lib/tor/keys/moved-away-by-tor-package ]; then		mkdir /var/lib/tor/keys/moved-away-by-tor-package		cat > /var/lib/tor/keys/moved-away-by-tor-package/README.REALLY << EOFIt has been discovered that the random number generator in Debian'sopenssl package is predictable.  This is caused by an incorrectDebian-specific change to the openssl package (CVE-2008-0166).  As aresult, cryptographic key material may be guessable.See Debian Security Advisory number 1571 (DSA-1571) for more information:http://lists.debian.org/debian-security-announce/2008/msg00152.htmlThe Debian package for Tor has moved away the onion keys upon packageupgrade, and it will have moved away your identity key if it was createdin the affected timeframe.  There is no sure way to automatically tellif your key was created with an affected openssl library, so this moveis done unconditionally.If you have restarted Tor since this change (and the package probablydid that for you already unless you configured your system differently)then the Tor daemon already created new keys for itself and in alllikelyhood is already working just fine with new keys.If you are absolutely certain that your identity key was created witha non-affected version of openssl and for some reason you have to retainthe old identity, then you can move back the copy of secret_id_key to/var/lib/tor/keys.  Do not move back the onion keys, they were createdonly recently since they are temporary keys with a lifetime of only a fewdays anyway.Sincerely,Peter Palfrader, Tue, 13 May 2008 13:32:23 +0200EOF	fi	for f in secret_onion_key secret_onion_key.old; do		if [ -e /var/lib/tor/keys/"$f" ]; then			mv -v /var/lib/tor/keys/"$f" /var/lib/tor/keys/moved-away-by-tor-package/"$f"		fi	done	if [ -e /var/lib/tor/keys/secret_id_key ]; then		id_mtime=`/usr/bin/stat -c %Y /var/lib/tor/keys/secret_id_key`		sept=`date -d '2006-09-10' +%s`		if [ "$id_mtime" -gt "$sept" ] ; then			mv -v /var/lib/tor/keys/secret_id_key /var/lib/tor/keys/moved-away-by-tor-package/secret_id_key		fi	fifi#DEBHELPER#exit 0
 |