[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Safe removal of a user while purging


I'm trying to remove the clamav user when purging the clamav package. The 
user clamav is created in postinst using:

adduser --system --no-create-home \
--disabled-password --disabled-login \
--shell /bin/false --home /var clamav

resulting in the entries
/etc/shadow: clamav:!:11867:0:99999:7:::
/etc/passwd: clamav:x:103:65534::/var:/bin/false

Is there any maintainer script but postrm that get info about a purge?
If not, is there any good way to remove the user (I.e not by hand),
while avoiding to break policy 7.2?

"...Note, however, that the postrm cannot rely on any non-essential packages 
to be present during the purge phase...." (deluser isn't essential). 

If there aren't any way, is this script safe enough?

#! /bin/sh
set -e

case "$1" in
	chown root:root $TMPFILE
	chmod 600 $TMPFILE

	sed 's/clamav:!:[0-9]*:[0-9]*:[0-9]*:[0-9]*::://' /etc/shadow > $TMPFILE
	sed '/^$/d' $TMPFILE > /etc/shadow

	sed 's/clamav:x:[0-9]*:[0-9]*::\/var:\/bin\/false//' /etc/passwd > $TMPFILE
	sed '/^$/d' $TMPFILE > /etc/passwd

        echo "postrm called with unknown argument \`$1'" >&2
        exit 0

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.


Magnus Ekdahl 0739-287181 magnus@debian.org maguno@ludd.luth.se
public key available at http://oxtan.campus.luth.se/magnus.public
Key fingerprint = 18DE CB62 8A86 374E 824E  09ED 1987 4B18 1213 79F6

To UNSUBSCRIBE, email to debian-mentors-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: