File: sudo.prerm

package info (click to toggle)
sudo 1.8.5p2-1%2Bnmu3%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 12,556 kB
  • sloc: ansic: 39,731; sh: 16,999; makefile: 1,974; yacc: 1,471; lex: 1,037; perl: 436
file content (45 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (9)
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
#!/bin/sh

set -e

check_password() {
    if [ ! "$SUDO_FORCE_REMOVE" = "yes" ]; then
	# let's check whether the root account is locked.
	# if it is, we're not going another step. No Sirreee!
	passwd=$(getent shadow root|cut -f2 -d:)
	passwd1=$(echo "$passwd" |cut -c1)
	# Note: we do need the 'xfoo' syntax here, since POSIX special-cases
	# the $passwd value '!' as negation.
	if [ "x$passwd" = "x*" ] || [ "x$passwd1" = "x!" ]; then
	    # yup, password is locked
	    echo "You have asked that the sudo package be removed,"
	    echo "but no root password has been set."
	    echo "Without sudo, you may not be able to gain administrative privileges."
	    echo
	    echo "If you would prefer to access the root account with su(1)"
	    echo "or by logging in directly,"
	    echo "you must set a root password with \"sudo passwd\"."
	    echo 
	    echo "If you have arranged other means to access the root account,"
	    echo "and you are sure this is what you want,"
	    echo "you may bypass this check by setting an environment variable "
	    echo "(export SUDO_FORCE_REMOVE=yes)."
	    echo
	    echo "Refusing to remove sudo."
	    exit 1
	fi
    fi
}
	
case $1 in
	remove)
		check_password;
		;;
	*)
		;;
esac

#DEBHELPER#

exit 0