summaryrefslogtreecommitdiff
path: root/debian/libnss-mapuser.postinst
blob: ee6a70de684069c9e6bae7f9c3b3dae1e617a433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# postinst script for libnss-mapuser
#
# see: dh_installdeb(1)

set -e

case "$1" in
    configure)
		# Add mapname and user to /etc/nsswitch.conf, since it's necessary
		# for this package.  uid must be first, and mapname must be last
		# so uids for mapped users return the mapped name, and on the name,
		# we only want to map if no other matches were found
		# handle case where a comment follows the plugin list
		( set +e;
		rgroup=radius_users
		if [ -e "/etc/nsswitch.conf" ]; then
			sed -i -e '/\smapname/b' \
				-e '/^passwd:/s/\s\s*/&mapuid /' \
				-e '/^passwd:.*#/s/#.*/ mapname &/' \
				-e '/^passwd:[^#]*$/s/$/ mapname &/' \
				-e '/^group:.*#/s/#.*/ mapname &/' \
				-e '/^group:[^#]*$/s/: */& mapname /' \
				/etc/nsswitch.conf
		fi
		addgroup --quiet $rgroup 2>&1 | grep -v 'already exists'
		adduser --quiet --firstuid 1000 --disabled-login --ingroup $rgroup \
		    --gecos "radius user" radius_user 2>&1 | grep -v 'already exists'
		adduser --quiet --firstuid 1000 --disabled-login --ingroup $rgroup \
		    --gecos "radius privileged user" radius_priv_user 2>&1 | grep -v 'already exists'
		# regular radius logins can run net show commands
		adduser --quiet radius_user netshow
		# privileged radius logins can run net config commands, as well as show
		adduser --quiet radius_priv_user netedit
		exit 0
		)
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# needed for install, upgrade, remove, and purge, including aborts
pam-auth-update --package


#DEBHELPER#

exit 0