Debian Codegraph @

etc/sudo.pp

raw
1 %set
2 if test -n "$flavor"; then
3 name="sudo-$flavor"
4 else
5 name="sudo"
6 fi
7 summary="Provide limited super-user privileges to specific users"
8 description="Sudo is a program designed to allow a sysadmin to give \
9 limited root privileges to users and log root activity. \
10 The basic philosophy is to give as few privileges as possible but \
11 still allow people to get their work done."
12 vendor="Todd C. Miller"
13 copyright="Copyright 1994-1996,1998-2025 Todd C. Miller"
14 sudoedit_man=`echo ${pp_destdir}$mandir/*/sudoedit.*|sed "s:^${pp_destdir}::"`
15 sudoedit_man_target=`basename $sudoedit_man | sed 's/edit//'`
16
17 %if [aix]
18 # AIX package summary is limited to 40 characters
19 summary="Configurable super-user privileges"
20
21 # Convert to 4 part version for AIX, including patch level
22 pp_aix_version=`echo $version|sed -e 's/^\([0-9]*\.[0-9]*\.[0-9]*\)p\([0-9]*\)$/\1.\2/' -e 's/^\([0-9]*\.[0-9]*\.[0-9]*\)[^0-9\.].*$/\1/' -e 's/^\([0-9]*\.[0-9]*\.[0-9]*\)$/\1.0/'`
23
24 # Don't use sudo to list the package.
25 pp_aix_sudo=
26 %endif
27
28 %if [sd]
29 pp_sd_vendor_tag="TCM"
30 %endif
31
32 %if [solaris]
33 pp_solaris_name="TCM${name}"
34 pp_solaris_pstamp=`/usr/bin/date "+%B %d, %Y"`
35 %endif
36
37 %if [macos]
38 # System Integrity Protection on macOS won't allow us to write
39 # directly to /etc or /var. We must install in /private instead.
40 case "$sysconfdir" in
41 /etc|/etc/*)
42 mkdir -p ${pp_destdir}/private
43 chmod 755 ${pp_destdir}/private
44 if test -d ${pp_destdir}/etc; then
45 mv ${pp_destdir}/etc ${pp_destdir}/private/etc
46 fi
47 sysconfdir="/private${sysconfdir}"
48 ;;
49 esac
50 case "$vardir" in
51 /var|/var/*)
52 mkdir -p ${pp_destdir}/private
53 chmod 755 ${pp_destdir}/private
54 if test -d ${pp_destdir}/var; then
55 mv ${pp_destdir}/var ${pp_destdir}/private/var
56 fi
57 vardir="/private${vardir}"
58 ;;
59 esac
60 case "$rundir" in
61 /var|/var/*)
62 mkdir -p ${pp_destdir}/private
63 chmod 755 ${pp_destdir}/private
64 if test -d ${pp_destdir}/var; then
65 mv ${pp_destdir}/var ${pp_destdir}/private/var
66 fi
67 rundir="/private${rundir}"
68 ;;
69 esac
70 %endif
71
72 %if [rpm,deb]
73 # Convert patch level into release and remove from version
74 pp_rpm_release="`expr \( $version : '.*p\([0-9][0-9]*\)$' \| 0 \) + 1`"
75 pp_rpm_version="`expr \( $version : '\(.*\)p[0-9][0-9]*$' \| $version \)`"
76 pp_rpm_license="BSD"
77 pp_rpm_url="https://www.sudo.ws"
78 pp_rpm_group="Applications/System"
79 pp_rpm_packager="Todd C. Miller <[email protected]>"
80 if test -n "$linux_audit"; then
81 pp_rpm_requires="audit-libs >= $linux_audit"
82 fi
83 # The package manager will handle an existing sudoers file
84 rm -f ${pp_destdir}${sysconfdir}/sudoers.dist
85 %else
86 # For all but RPM and Debian we copy sudoers in a post-install script.
87 rm -f ${pp_destdir}${sysconfdir}/sudoers
88 # We install sudo.conf from the example dir in a post-install script.
89 rm -f ${pp_destdir}${sysconfdir}/sudo.conf
90 %endif
91
92 # Stash original docdir and exampledir
93 odocdir="${docdir}"
94 oexampledir="${exampledir}"
95
96 # For RedHat the doc dir is expected to include version and release
97 case "$pp_rpm_distro" in
98 centos*|rhel*|f[0-9]*)
99 docdir="${docdir}-${pp_rpm_version}-${pp_rpm_release}"
100 exampledir="${docdir}/examples"
101 ;;
102 esac
103
104 if test -n "$flavor"; then
105 # docdir and exampledir are installed with "sudo" as the package
106 # name which is not be correct for flavors.
107 docdir="`echo \"${docdir}\" | sed \"s#/sudo#/${name}#g\"`"
108 exampledir="`echo \"${exampledir}\" | sed \"s#/sudo#/${name}#g\"`"
109 fi
110
111 # Copy docdir and exampledir to new names if needed
112 if test ! -d "${pp_destdir}${docdir}"; then
113 cp -R ${pp_destdir}${odocdir} ${pp_destdir}${docdir}
114 find ${pp_destdir}${docdir} -depth | sed "s#^${pp_destdir}##" >> ${pp_wrkdir}/pp_cleanup
115 fi
116 if test ! -d "${pp_destdir}${exampledir}"; then
117 cp -R ${pp_destdir}${oexampledir} ${pp_destdir}${exampledir}
118 find ${pp_destdir}${exampledir} -depth | sed "s#^${pp_destdir}##" >> ${pp_wrkdir}/pp_cleanup
119 fi
120
121 %if [deb]
122 pp_deb_maintainer="$pp_rpm_packager"
123 pp_deb_release="$pp_rpm_release"
124 pp_deb_version="$pp_rpm_version"
125 pp_deb_section=admin
126 install -D -m 644 ${pp_destdir}$docdir/LICENSE.md ${pp_wrkdir}/${name}/usr/share/doc/${name}/copyright
127 install -D -m 644 ${pp_destdir}$docdir/ChangeLog ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog
128 gzip -9f ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog
129 printf "$name ($pp_deb_version-$pp_deb_release) admin; urgency=low\n\n * see upstream changelog\n\n -- $pp_deb_maintainer `date '+%a, %d %b %Y %T %z'`\n" > ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog.Debian
130 chmod 644 ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog.Debian
131 gzip -9f ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog.Debian
132 # Create lintian override file, must be tab indented for "<<-"
133 mkdir -p ${pp_wrkdir}/${name}/usr/share/lintian/overrides
134 cat >${pp_wrkdir}/${name}/usr/share/lintian/overrides/${name} <<-EOF
135 # The sudo binary must be setuid root
136 $name: setuid-binary usr/bin/sudo 4755 root/root
137 # Sudo configuration and data dirs must not be world-readable
138 $name: non-standard-file-perm etc/sudoers 0440 != 0644
139 $name: non-standard-dir-perm etc/sudoers.d/ 0750 != 0755
140 $name: non-standard-dir-perm var/lib/sudo/ 0700 != 0755
141 # Sudo ships with debugging symbols
142 $name: unstripped-binary-or-object
143 EOF
144 chmod 644 ${pp_wrkdir}/${name}/usr/share/lintian/overrides/${name}
145 # If libssl_dep not passed in, try to figure it out
146 if test -z "$libssl_dep"; then
147 libssl_dep="`ldd $libexecdir/sudo/sudoers.so 2>&1 | sed -n 's/^[ ]*libssl\.so\([0-9.]*\).*/libssl\1/p'`"
148 fi
149 %endif
150
151 %if [rpm]
152 # Used to set rpm_arch to x86_64_v2 on Alma Linux
153 if test -n "$pp_rpm_arch_override"; then
154 pp_rpm_arch="$pp_rpm_arch_override"
155 fi
156
157 # Add distro info to release
158 osrelease=`echo "$pp_rpm_distro" | sed -e 's/^[^0-9]*\([0-9]\{1,3\}\).*/\1/'`
159 case "$pp_rpm_distro" in
160 centos*|rhel*|f[0-9]*)
161 # CentOS Stream has a single-digit version
162 if test $osrelease -lt 10; then
163 osrelease="${osrelease}0"
164 fi
165 pp_rpm_release="$pp_rpm_release.el${osrelease%[0-9]}"
166 ;;
167 sles*)
168 pp_rpm_release="$pp_rpm_release.sles$osrelease"
169 ;;
170 esac
171
172 # Uncomment some Defaults in sudoers
173 case "$pp_rpm_distro" in
174 centos*|rhel*|f[0-9]*)
175 sed -e '/Locale settings/{ N;s/\(\n\)# /\1/; }' -e '/Desktop path settings/{ N;s/\(\n\)# /\1/; }' -e '/allow members of group wheel to execute any command/{ N;s/\(\n\)# /\1/; }' ${pp_destdir}${sysconfdir}/sudoers > ${pp_destdir}${sysconfdir}/sudoers.$$
176 mv -f ${pp_destdir}${sysconfdir}/sudoers.$$ ${pp_destdir}${sysconfdir}/sudoers
177 ;;
178 sles*)
179 sed -e '/Locale settings/{ N;s/\(\n\)# /\1/; }' -e '/ConsoleKit session/{ N;s/\(\n\)# /\1/; }' -e '/allow any user to run sudo if they know the password/{ N;N;N;s/\(\n\)# /\1/g; }' ${pp_destdir}${sysconfdir}/sudoers > ${pp_destdir}${sysconfdir}/sudoers.$$
180 mv -f ${pp_destdir}${sysconfdir}/sudoers.$$ ${pp_destdir}${sysconfdir}/sudoers
181 ;;
182 esac
183
184 # Choose the correct PAM file by distro, must be tab indented for "<<-"
185 case "$pp_rpm_distro" in
186 centos*|rhel*)
187 mkdir -p ${pp_destdir}/etc/pam.d
188 if test $osrelease -lt 50; then
189 cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
190 #%PAM-1.0
191 auth required pam_stack.so service=system-auth
192 account required pam_stack.so service=system-auth
193 password required pam_stack.so service=system-auth
194 session required pam_limits.so
195 EOF
196 else
197 cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
198 #%PAM-1.0
199 auth include system-auth
200 account include system-auth
201 password include system-auth
202 session optional pam_keyinit.so revoke
203 session required pam_limits.so
204 EOF
205 cat > ${pp_destdir}/etc/pam.d/sudo-i <<-EOF
206 #%PAM-1.0
207 auth include sudo
208 account include sudo
209 password include sudo
210 session optional pam_keyinit.so force revoke
211 session required pam_limits.so
212 EOF
213 fi
214 ;;
215 f[0-9]*)
216 # XXX - share with rhel
217 mkdir -p ${pp_destdir}/etc/pam.d
218 cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
219 #%PAM-1.0
220 auth include system-auth
221 account include system-auth
222 password include system-auth
223 session optional pam_keyinit.so revoke
224 session required pam_limits.so
225 EOF
226 cat > ${pp_destdir}/etc/pam.d/sudo-i <<-EOF
227 #%PAM-1.0
228 auth include sudo
229 account include sudo
230 password include sudo
231 session optional pam_keyinit.so force revoke
232 session required pam_limits.so
233 EOF
234 ;;
235 sles*)
236 mkdir -p ${pp_destdir}/etc/pam.d
237 if test $osrelease -lt 10; then
238 cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
239 #%PAM-1.0
240 auth required pam_unix2.so
241 session required pam_limits.so
242 EOF
243 else
244 cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
245 #%PAM-1.0
246 auth include common-auth
247 account include common-account
248 password include common-password
249 session include common-session
250 # session optional pam_xauth.so
251 EOF
252 fi
253 ;;
254 esac
255 %endif
256
257 %if [deb]
258 # Uncomment some Defaults and the %sudo rule in sudoers
259 sed -e '/Locale settings/{ N;s/\(\n\)# /\1/; }' -e '/X11 resource/{ N;s/\(\n\)# /\1/; }' -e 's/^# \(Defaults secure_path\)/\1/' -e 's/^# \(Defaults mail_badpass\)/\1/' -e 's/^# \(\%sudo\)/\1/' ${pp_destdir}${sysconfdir}/sudoers > ${pp_destdir}${sysconfdir}/sudoers.$$
260 mv -f ${pp_destdir}${sysconfdir}/sudoers.$$ ${pp_destdir}${sysconfdir}/sudoers
261 mkdir -p ${pp_destdir}/etc/pam.d
262 # Create Debian PAM file, must be tab indented for "<<-"
263 cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
264 #%PAM-1.0
265
266 @include common-auth
267 @include common-account
268
269 session required pam_permit.so
270 session required pam_limits.so
271 EOF
272 %endif
273
274 %if [macos]
275 pp_macos_pkg_type=flat
276 pp_macos_bundle_id=ws.sudo.pkg.sudo
277 pp_macos_pkg_background=${srcdir}/etc/macos-background.png
278 pp_macos_pkg_background_dark=${srcdir}/etc/macos-background.png
279 pp_macos_pkg_license=${pp_destdir}$docdir/LICENSE.md
280 pp_macos_pkg_readme=${pp_wrkdir}/ReadMe.txt
281 perl -pe 'last if (/^What/i && $seen++)' ${pp_destdir}$docdir/NEWS > ${pp_wrkdir}/ReadMe.txt
282 %endif
283
284 %if X"$aix_freeware" = X"true"
285 # Create links from /opt/freeware/{bin,sbin} -> /usr/{bin,sbin}
286 mkdir -p ${pp_destdir}/usr/bin ${pp_destdir}/usr/sbin
287 ln -s -f ${bindir}/cvtsudoers ${pp_destdir}/usr/bin
288 ln -s -f ${bindir}/sudo ${pp_destdir}/usr/bin
289 ln -s -f ${bindir}/sudoedit ${pp_destdir}/usr/bin
290 ln -s -f ${bindir}/sudoreplay ${pp_destdir}/usr/bin
291 ln -s -f ${sbindir}/sudo_sendlog ${pp_destdir}/usr/sbin
292 ln -s -f ${sbindir}/visudo ${pp_destdir}/usr/sbin
293 %endif
294
295 %if [!rpm,deb]
296 # Package parent directories when not installing under /usr
297 if test "${prefix}" != "/usr"; then
298 extradirs=`echo ${pp_destdir}${mandir}/[mc]* | sed "s#${pp_destdir}##g"`
299 extradirs="$extradirs `dirname $docdir` `dirname $rundir` `dirname $vardir`"
300 test "`dirname $exampledir`" != "$docdir" && extradirs="$extradirs `dirname $exampledir`"
301 test -d ${pp_destdir}${localedir} && extradirs="$extradirs $localedir"
302 for dir in $bindir $sbindir $libexecdir $includedir $extradirs; do
303 # Only package directories that match the prefix,
304 # otherwise we could package directories like /var.
305 case "$dir" in
306 ${prefix}*)
307 while test "$dir" != "/"; do
308 parentdirs="${parentdirs}${parentdirs+ }$dir/"
309 dir=`dirname $dir`
310 done
311 ;;
312 esac
313 done
314 parentdirs=`echo $parentdirs | tr " " "\n" | sort -u`
315 fi
316 %endif
317
318 %depend [deb]
319 libc6, libpam0g, libpam-modules, zlib1g, libapparmor1
320
321 %fixup [deb]
322 # Add Conflicts, Replaces headers and add libldap dependency as needed.
323 DEPENDS="%{linux_audit}"
324 if test -z "%{flavor}"; then
325 echo "Conflicts: sudo-ldap" >> %{pp_wrkdir}/%{name}/DEBIAN/control
326 echo "Replaces: sudo-ldap" >> %{pp_wrkdir}/%{name}/DEBIAN/control
327 elif test "%{flavor}" = "ldap"; then
328 echo "Conflicts: sudo" >> %{pp_wrkdir}/%{name}/DEBIAN/control
329 echo "Replaces: sudo" >> %{pp_wrkdir}/%{name}/DEBIAN/control
330 echo "Provides: sudo" >> %{pp_wrkdir}/%{name}/DEBIAN/control
331 DEPENDS="${DEPENDS}${DEPENDS:+, }libldap-2.4-2"
332 fi
333 if test -n "%{libssl_dep}"; then
334 DEPENDS="${DEPENDS}${DEPENDS:+, }%{libssl_dep}"
335 fi
336 cp -p %{pp_wrkdir}/%{name}/DEBIAN/control %{pp_wrkdir}/%{name}/DEBIAN/control.$$
337 if test -n "${DEPENDS}"; then
338 sed "s/^\(Depends:.*\) *$/\1, ${DEPENDS}/" %{pp_wrkdir}/%{name}/DEBIAN/control.$$ > %{pp_wrkdir}/%{name}/DEBIAN/control
339 fi
340 rm -f %{pp_wrkdir}/%{name}/DEBIAN/control.$$
341 echo "Homepage: https://www.sudo.ws" >> %{pp_wrkdir}/%{name}/DEBIAN/control
342 echo "Bugs: https://bugzilla.sudo.ws" >> %{pp_wrkdir}/%{name}/DEBIAN/control
343
344 %fixup [rpm]
345 # Must be tab indented for "<<-".
346 cat > %{pp_wrkdir}/${name}.spec.sed <<-'EOF'
347 /^%files/ {
348 i\
349 %clean\
350 :\
351
352 }
353 EOF
354 mv %{pp_wrkdir}/${name}.spec %{pp_wrkdir}/${name}.spec.bak
355 sed -f %{pp_wrkdir}/${name}.spec.sed %{pp_wrkdir}/${name}.spec.bak > %{pp_wrkdir}/${name}.spec
356
357 %files
358 %if X"$parentdirs" != X""
359 $parentdirs -
360 %endif
361 %if X"$odocdir" != X"$docdir"
362 $odocdir/ ignore
363 $odocdir/** ignore
364 %endif
365 %if X"$oexampledir" != X"$exampledir" -a X"$exampledir" != X"$docdir/examples"
366 $oexampledir/ ignore
367 $oexampledir/** ignore
368 %endif
369 $bindir/cvtsudoers 0755 root:
370 $bindir/sudo 4755 root:
371 $bindir/sudoedit 0755 root: symlink sudo
372 $bindir/sudoreplay 0755
373 $sbindir/sudo_sendlog 0755
374 $sbindir/sudo_logsrvd optional,ignore
375 $sbindir/visudo 0755
376 $includedir/sudo_plugin.h 0644
377 $libexecdir/sudo/ 0755
378 $libexecdir/sudo/sesh 0755 optional,ignore-others
379 $libexecdir/sudo/python* optional,ignore,ignore-others
380 $libexecdir/sudo/* $shlib_mode optional
381 $sysconfdir/sudoers.d/ 0750 $sudoers_uid:$sudoers_gid
382 $rundir/ 0711 root:
383 $vardir/ 0711 root: ignore-others
384 $vardir/lectured/ 0700 root:
385 $docdir/ 0755
386 $docdir/** 0644
387 %if [deb]
388 $docdir/LICENSE.md ignore,ignore-others
389 $docdir/ChangeLog ignore,ignore-others
390 %endif
391 $exampledir/ 0755 ignore-others
392 %if X"$exampledir" != X"$docdir/examples"
393 $exampledir/* 0644
394 %endif
395 $exampledir/sudo_logsrv* optional,ignore,ignore-others
396 $exampledir/*.py optional,ignore,ignore-others
397 $localedir/*/ - optional
398 $localedir/*/LC_MESSAGES/ - optional
399 $localedir/*/LC_MESSAGES/* 0644 optional
400 /etc/pam.d/* 0644 volatile,optional
401 %if [rpm,deb]
402 $sysconfdir/sudoers $sudoers_mode $sudoers_uid:$sudoers_gid volatile
403 $sysconfdir/sudo.conf 0644 root: volatile
404 %else
405 $sysconfdir/sudoers.dist $sudoers_mode $sudoers_uid:$sudoers_gid
406 %endif
407 $sysconfdir/sudo_logsrvd.conf optional,ignore,ignore-others
408 %if X"$aix_freeware" = X"true"
409 # Links for binaries from /opt/freeware to /usr
410 /usr/bin/cvtsudoers 0755 root: symlink $bindir/cvtsudoers
411 /usr/bin/sudo 0755 root: symlink $bindir/sudo
412 /usr/bin/sudoedit 0755 root: symlink $bindir/sudoedit
413 /usr/bin/sudoreplay 0755 root: symlink $bindir/sudoreplay
414 /usr/sbin/sudo_sendlog 0755 root: symlink $sbindir/sendlog
415 /usr/sbin/visudo 0755 root: symlink $sbindir/visudo
416 %endif
417 %if [rpm]
418 /etc/rc.d/init.d/sudo 0755 root: optional
419 %endif
420 %if [aix]
421 /etc/rc.d/ ignore
422 /etc/rc.d/rc2.d/ ignore
423 /etc/rc.d/rc2.d/** ignore
424 /etc/rc.d/init.d/ ignore
425 /etc/rc.d/init.d/sudo 0755 root:
426 %endif
427 %if [sd]
428 /sbin/ ignore
429 /sbin/rc2.d/ ignore
430 /sbin/rc2.d/** ignore
431 /sbin/init.d/ ignore
432 /sbin/init.d/sudo 0755 root:
433 %endif
434 $mandir/man*/* 0644
435 $mandir/man*/sudo_logsrv* ignore,ignore-others
436 $mandir/man*/*python* ignore,ignore-others
437 $sudoedit_man 0644 symlink,ignore-others $sudoedit_man_target
438
439 %pre [aix]
440 if rpm -q %{name} >/dev/null 2>&1; then
441 echo "Another version of sudo is currently installed via rpm." 2>&1
442 echo "Please either uninstall the rpm version of sudo by running \"rpm -e sudo\"" 2>&1
443 echo "or upgrade the existing version of sudo using the .rpm packagae instead" 2>&1
444 echo "instead of the .bff package." 2>&1
445 echo "" 2>&1
446 echo "Note that you may need to pass rpm the --oldpackage flag when upgrading" 2>&1
447 echo "the AIX Toolbox version of sudo to the latest sudo rpm from sudo.ws." 2>&1
448 echo "" 2>&1
449 exit 1
450 fi
451
452 %post [!rpm,deb]
453 # Don't overwrite existing sudoers or sudo.conf files
454 %if [solaris]
455 sysconfdir=${PKG_INSTALL_ROOT}%{sysconfdir}
456 exampledir=${PKG_INSTALL_ROOT}%{exampledir}
457 %else
458 sysconfdir=%{sysconfdir}
459 exampledir=%{exampledir}
460 %endif
461 if test ! -r $sysconfdir/sudoers; then
462 cp $sysconfdir/sudoers.dist $sysconfdir/sudoers
463 chmod %{sudoers_mode} $sysconfdir/sudoers
464 chown %{sudoers_uid} $sysconfdir/sudoers
465 chgrp %{sudoers_gid} $sysconfdir/sudoers
466 fi
467 if test ! -r $sysconfdir/sudo.conf; then
468 cp $exampledir/sudo.conf $sysconfdir/sudo.conf
469 chmod 644 $sysconfdir/sudo.conf
470 chown root $sysconfdir/sudo.conf
471 fi
472
473 %post [deb]
474 set -e
475
476 # dpkg-deb does not maintain the mode on the sudoers file, and
477 # installs it 0640 when sudo requires 0440
478 chmod %{sudoers_mode} %{sysconfdir}/sudoers
479
480 # create symlink to ease transition to new path for ldap config
481 # if old config file exists and new one doesn't
482 if test X"%{flavor}" = X"ldap" -a \
483 -r /etc/ldap/ldap.conf -a ! -r /etc/sudo-ldap.conf; then
484 ln -s /etc/ldap/ldap.conf /etc/sudo-ldap.conf
485 fi
486
487 # Debian uses a sudo group in its default sudoers file
488 perl -e '
489 exit 0 if getgrnam("sudo");
490 $gid = 27; # default debian sudo gid
491 setgrent();
492 while (getgrgid($gid)) { $gid++; }
493 if ($gid != 27) {
494 print "On Debian we normally use gid 27 for \"sudo\".\n";
495 $gname = getgrgid(27);
496 print "However, on your system gid 27 is group \"$gname\".\n\n";
497 print "Would you like me to stop configuring sudo so that you can change this? [n] ";
498 $ans = <STDIN>;
499 if ($ans =~ /^[yY]/) {
500 print "\"dpkg --pending --configure\" will restart the configuration.\n\n";
501 exit 1;
502 }
503 }
504 print "Creating group \"sudo\" with gid = $gid\n";
505 system("groupadd -g $gid sudo");
506 exit 0;
507 '
508
509 %post [rpm]
510 case "%{pp_rpm_distro}" in
511 aix*)
512 # Create /etc/rc.d/rc2.d/S90sudo link if possible
513 if [ -d /etc/rc.d/rc2.d ]; then
514 rm -f /etc/rc.d/rc2.d/S90sudo
515 ln -s /etc/rc.d/init.d/sudo /etc/rc.d/rc2.d/S90sudo
516 fi
517 ;;
518 esac
519
520 %post [rpm,deb]
521 # Create /usr/lib/tmpfiles.d/sudo.conf if systemd is configured.
522 # Must be tab indented for "<<-".
523 if [ -f /usr/lib/tmpfiles.d/systemd.conf ]; then
524 cat > /usr/lib/tmpfiles.d/sudo.conf <<-EOF
525 # Create an empty sudo time stamp directory on OSes using systemd.
526 # Sudo will create the directory itself but this can cause problems
527 # on systems that have SELinux enabled since the directories will be
528 # created with the user's security context.
529 d %{rundir} 0711 root root
530 D %{rundir}/ts 0700 root root
531 EOF
532 fi
533
534 %post [aix]
535 # Create /etc/rc.d/rc2.d/S90sudo link if /etc/rc.d exists
536 if [ -d /etc/rc.d ]; then
537 rm -f /etc/rc.d/rc2.d/S90sudo
538 ln -s /etc/rc.d/init.d/sudo /etc/rc.d/rc2.d/S90sudo
539 fi
540
541 %post [sd]
542 # Create /sbin/rc2.d/S900sudo link
543 rm -f /sbin/rc2.d/S900sudo
544 ln -s /sbin/init.d/sudo /sbin/rc2.d/S900sudo
545
546 %preun
547 # Remove the time stamp dir and its contents
548 # We currently leave the lecture status files installed
549 rm -rf %{rundir}/ts
550 %if [deb]
551 set -e
552
553 # Remove the /etc/ldap/ldap.conf -> /etc/sudo-ldap.conf symlink if
554 # it matches what we created in the postinstall script.
555 if test X"%{flavor}" = X"ldap" -a \
556 X"`readlink /etc/sudo-ldap.conf 2>/dev/null`" = X"/etc/ldap/ldap.conf"; then
557 rm -f /etc/sudo-ldap.conf
558 fi
559
560 # Remove systemd tmpfile config
561 rm -f /usr/lib/tmpfiles.d/sudo.conf
562 %endif
563 %if [rpm]
564 case "%{pp_rpm_distro}" in
565 aix*)
566 # Remove /etc/rc.d/rc2.d/S90sudo link
567 rm -f /etc/rc.d/rc2.d/S90sudo
568 ;;
569 *)
570 # Remove systemd tmpfile config
571 rm -f /usr/lib/tmpfiles.d/sudo.conf
572 ;;
573 esac
574 %endif
575 %if [aix]
576 # Remove /etc/rc.d/rc2.d/S90sudo link
577 rm -f /etc/rc.d/rc2.d/S90sudo
578 %endif
579 %if [sd]
580 # Remove /sbin/rc2.d/S900sudo link
581 rm -f /sbin/rc2.d/S900sudo
582 %endif