summaryrefslogtreecommitdiff
path: root/debian/libpam-runtime.postinst
blob: 178d0e2378a8fc27f535d8482b49242a7ee79cb3 (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
55
56
57
58
59
60
61
#!/bin/sh -e

. /usr/share/debconf/confmodule

# pam-auth-update is introduced in 1.0.1-6
# Between 1.0.1-6 and 1.0.1-10 it is possible to get empty profiles
if [ "x$2" != "x" ] ;then
    if dpkg --compare-versions $2 lt 1.0.1-10 && dpkg --compare-versions $2 ge 1.0.1-6 ; then
	db_get libpam-runtime/profiles
	if [ "x$RET" = "x" ] ; then
	    UHOH=1
	fi
    fi
fi

calculate_md5sum()
{
	configfile="$1"
	sed -n -e'1,/# here are the per-package modules (the "Primary" block)/p;
	          /# here.s the fallback if no module succeeds/,/# and here are more per-package modules (the "Additional" block)/p;
	          /# end of pam-auth-update config/,$p' \
	    /etc/pam.d/"$configfile" | md5sum | awk '{ print $1 }'
}

# If the user has removed the config file, respect this sign of dementia
# -- only create on package install.
force=
if [ -z "$2" ] || dpkg --compare-versions "$2" lt 1.0.1-11
then
	force=--force
	for configfile in common-auth common-account common-session  \
	    common-password
	do
		if [ -f /etc/pam.d/$configfile ] && \
		    ! fgrep -q $(calculate_md5sum $configfile) \
		    /usr/share/pam/$configfile.md5sums 2>/dev/null
		then
			force=
		fi
	done
fi

pam-auth-update --package $force

if [ -n "$force" ]; then
	rm -f /etc/pam.d/common-auth.pam-old \
	      /etc/pam.d/common-account.pam-old \
	      /etc/pam.d/common-password.pam-old \
	      /etc/pam.d/common-session.pam-old
elif dpkg --compare-versions "$2" lt-nl 1.1.0-1 \
        && [ ! -e /etc/pam.d/common-session-noninteractive ]
then
	cp -a /etc/pam.d/common-session /etc/pam.d/common-session-noninteractive
fi

if [ -n "$UHOH" ]; then
	db_input critical libpam-runtime/you-had-no-auth || true
	db_go
fi

#DEBHELPER#