File: libc.postinst

package info (click to toggle)
glibc 2.19-18%2Bdeb8u9
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 204,712 kB
  • ctags: 145,148
  • sloc: ansic: 970,427; asm: 241,207; sh: 10,069; makefile: 8,476; cpp: 3,595; perl: 2,077; pascal: 1,839; awk: 1,704; yacc: 317; sed: 73
file content (262 lines) | stat: -rw-r--r-- 8,193 bytes parent folder | download | duplicates (10)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/sh
set -e
export LC_ALL=C

type=$1
preversion=$2

package_name()
{
    if dpkg --assert-multi-arch 2>/dev/null; then
        echo LIBC:${DPKG_MAINTSCRIPT_ARCH}
    else
        echo LIBC
    fi
}

# element() is a helper function for file-rc:
element() {
    local element list IFS

    element="$1"

    [ "$2" = "in" ] && shift
    list="$2"
    [ "$list" = "-" ] && return 1
    [ "$list" = "*" ] && return 0

    IFS=","
    set -- $list
    case $element in
	"$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
	    return 0
    esac
    return 1
}

# filerc (runlevel, service) returns /etc/init.d/service, if service is
# running in $runlevel:
filerc() {
    local runlevel basename
    runlevel=$1
    basename=$2
    while read LINE
    do
	case $LINE in
	    \#*|"") continue
	esac

	set -- $LINE
	SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
	[ "$CMD" = "/etc/init.d/$basename" ] || continue

	if element "$runlevel" in "$START" || element "S" in "$START"
	then
	    echo "/etc/init.d/$basename"
	    return 0
	fi
    done < /etc/runlevel.conf
    echo ""
}

checkpkgver () {
    local status pkg
    pkg=$1
    status=$(dpkg -s $pkg 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
    if [ -n "$status" ] && [ "$status" != "not-installed" ] && [ "$status" != "config-files" ]; then
	echo $(dpkg -s $pkg 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//');
    fi
}

if [ "$type" = "configure" ]
then
    # We don't use a registry anymore, remove the old file
    rm -f /etc/ld.so.hwcappkgs
 
    # /etc/ld.so.nohwcap code: NOHWCAP

    # Load debconf module if available
    if [ -f /usr/share/debconf/confmodule ] ; then
	. /usr/share/debconf/confmodule
    fi

    if [ -n "$preversion" ]; then
	if [ ! -d /var/mail ] && [ ! -L /var/mail ]; then
	    ln -sf spool/mail /var/mail
	fi
	if dpkg --compare-versions "$preversion" lt 2.19; then
	    check="apache2.2-common apache apache-ssl apache-perl autofs at"
	    check="$check boa cucipop courier-authdaemon cron cups exim"
	    check="$check exim4-base dovecot-common cucipop incron lprng lpr"
	    check="$check lpr-ppd mysql-server nis openbsd-inetd"
	    check="$check openldapd proftpd postfix postfix-tls rsync samba"
	    check="$check sasl2-bin slapd smail sendmail snmpd ssh"
	    check="$check spamassassin vsftpd wu-ftpd wu-ftpd-academ wwwoffle"
	    check="$check webmin dropbear gdm"
	    # NSS services check: NSS_CHECK
	    if [ -n "$services" ]; then

	        if [ -f /usr/share/debconf/confmodule ] ; then
		    db_version 2.0
		    db_input critical libraries/restart-without-asking || true
		    db_go || true
		    db_get libraries/restart-without-asking
		    if [ "$RET" != true ]; then
			db_reset glibc/restart-services
			db_set glibc/restart-services "$services"
			db_input critical glibc/restart-services || true
			db_go || true
			db_get glibc/restart-services
			if [ "x$RET" != "x" ]
			then
			    services="$RET"
			else
			    services=""
			fi
		    fi
		else
		    echo
		    echo "Name Service Switch update in the C Library: post-installation question."
		    echo
		    echo "Running services and programs that are using NSS need to be restarted,"
		    echo "otherwise they might not be able to do lookup or authentication any more"
		    echo "(for services such as ssh, this can affect your ability to login)."
		    echo "Note: restarting sshd/telnetd should not affect any existing connections."
		    echo
		    echo "The services detected are: "
		    echo "        $services"
		    echo
		    echo "If other services have begun to fail mysteriously after this upgrade, it is"
		    echo "probably necessary to restart them too.  We recommend that you reboot your"
		    echo "machine after the upgrade to avoid NSS-related troubles."
		    echo
		    frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
		    if [ "$frontend" = noninteractive ]; then
		    	echo "Non-interactive mode, restarting services"
		    	answer=yes
		    else
		    	echo -n "Do you wish to restart services? [Y/n] "
		    	read answer
		    	case $answer in
			    N*|n*) services="" ;;
			    *) ;;
		        esac
		    fi
		fi
		echo
		if [ "$services" != "" ]; then
		    echo "Restarting services possibly affected by the upgrade:"
		    failed=""
		    for service in $services; do
			# We can't just use a generic rewrite here, as it was
			# samba in wheezy and smbd in jessie, which confuses.
			if [ "$service" = "samba" ]; then
			    if [ -x /etc/init.d/smbd ] || [ -f /etc/init/smbd ]; then
				service="smbd"
			    fi
			fi
		    	if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
			    idl="invoke-rc.d ${service}"
			elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
			    idl=$(filerc $rl $service)
			else
			    idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
			fi
			case "$service" in
			    gdm)
				echo -n "  $service: reloading..."
				if $idl reload > /dev/null 2>&1; then
				    echo "done."
				else
				    echo "FAILED! ($?)"
				    failed="$service $failed"
				fi
				;;
			    *)
				echo -n "  $service: restarting..."
				if $idl restart > /dev/null 2>&1; then
				    echo "done."
				else
				    echo "FAILED! ($?)"
				    failed="$service $failed"
				fi
				;;
			esac
		    done
		    echo
		    if [ -n "$failed" ]; then
	        	if [ -f /usr/share/debconf/confmodule ] ; then
		    	    db_fset glibc/restart-failed seen false
			    db_subst glibc/restart-failed services "$failed"
			    db_input critical glibc/restart-failed || true
			    db_go || true
			else
			    echo "The following services failed to start: $failed"
			    echo
			    echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
			    echo "If the service still fails to start, you may need to file a bug on"
			    echo "$(package_name) or the service involved."
			    frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
			    if [ "$frontend" != noninteractive ]; then
			    	echo
			    	echo -n "Press ENTER to continue: "
			    	read foo
			    fi
			fi
		    else
			echo "Services restarted successfully."
                    fi
		fi
                # Shut down the frontend, to make sure none of the
		# restarted services keep a connection open to it
	        if [ -f /usr/share/debconf/confmodule ] ; then
		    db_stop
		fi
	    else
		echo "Nothing to restart."
	    fi
	fi # end upgrading and $preversion lt 2.19
    fi # Upgrading

    # Restart init.  Currently handles chroots, systemd and upstart, and
    # assumes anything else is going to not fail at behaving like
    # sysvinit:
    TELINIT=yes
    if ischroot 2>/dev/null; then
        # Don't bother trying to re-exec init from a chroot:
        TELINIT=no
    elif [ -d /run/systemd/system ]; then
        # Skip if systemd is the active PID 1, since systemd doesn't
        # need a reexec for a clean shutdown
        TELINIT=no
    elif [ -x "`which initctl`" ]; then
        UPSTART=$(initctl version 2>/dev/null | awk '/upstart/ {print $3}' | tr -d ')')
        if dpkg --compare-versions "$UPSTART" lt-nl 1.6.1; then
            # This is an old upstart that can't re-exec statefully:
            TELINIT=no
            touch /var/run/init.upgraded
        fi
    fi
    if [ "$TELINIT" = "yes" ]; then
        telinit u 2>/dev/null || true ; sleep 1
    fi
fi

# We now use the multiarch triplet instead of the GNU triplet for the ld.so
# configuration file, in order to keep a stable path. Remove the old file.
case ${DPKG_MAINTSCRIPT_ARCH:-$(dpkg --print-architecture)} in
    hurd-i386)
        dpkg-maintscript-helper rm_conffile /etc/ld.so.conf.d/i486-gnu.conf 2.19-11~ libc0.3:hurd-i386 -- "$@"
        dpkg-maintscript-helper rm_conffile /etc/ld.so.conf.d/i486-gnu-gnu.conf 2.19-11~ libc0.3:hurd-i386 -- "$@"
        ;;
    i386)
        dpkg-maintscript-helper rm_conffile /etc/ld.so.conf.d/i486-linux-gnu.conf 2.19-4~ libc6:i386 -- "$@"
        ;;
    kfreebsd-i386)
        dpkg-maintscript-helper rm_conffile /etc/ld.so.conf.d/i486-kfreebsd-gnu.conf 2.19-11~ libc0.1:kfreebsd-i386 -- "$@"
        ;;
esac

#DEBHELPER#

exit 0