File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sudo / sudo.pp
Revision 1.1.1.5 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 16:12:54 2014 UTC (9 years, 11 months ago) by misho
Branches: sudo, MAIN
CVS tags: v1_8_10p3_0, v1_8_10p3, HEAD
sudo v 1.8.10p3

    1: %set
    2: 	if test -n "$flavor"; then
    3: 		name="sudo-$flavor"
    4: 		pp_kit_package="sudo_$flavor"
    5: 	else
    6: 		name="sudo"
    7: 		pp_kit_package="sudo"
    8: 	fi
    9: 	summary="Provide limited super-user privileges to specific users"
   10: 	description="Sudo is a program designed to allow a sysadmin to give \
   11: limited root privileges to users and log root activity.  \
   12: The basic philosophy is to give as few privileges as possible but \
   13: still allow people to get their work done."
   14: 	vendor="Todd C. Miller"
   15: 	copyright="(c) 1993-1996,1998-2014 Todd C. Miller"
   16: 	sudoedit_man=`echo ${pp_destdir}$mandir/*/sudoedit.*|sed "s:^${pp_destdir}::"`
   17: 	sudoedit_man_target=`basename $sudoedit_man | sed 's/edit//'`
   18: 
   19: %if [aix]
   20: 	# AIX package summary is limited to 40 characters
   21: 	summary="Configurable super-user privileges"
   22: 
   23: 	# Convert to 4 part version for AIX, including patch level
   24: 	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/'`
   25: %endif
   26: 
   27: %if [kit]
   28: 	# Strip off patchlevel for kit which only supports xyz versions
   29: 	pp_kit_version="`echo $version|sed -e 's/\.//g' -e 's/[^0-9][^0-9]*[0-9][0-9]*$//'`"
   30: 	pp_kit_name="TCM"
   31: %endif
   32: 
   33: %if [sd]
   34: 	pp_sd_vendor_tag="TCM"
   35: %endif
   36: 
   37: %if [solaris]
   38: 	pp_solaris_name="TCM${name}"
   39: 	pp_solaris_pstamp=`/usr/bin/date "+%B %d, %Y"`
   40: %endif
   41: 
   42: %if [rpm,deb]
   43: 	# Convert patch level into release and remove from version
   44: 	pp_rpm_release="`expr \( $version : '.*p\([0-9][0-9]*\)' \| 0 \) + 1`"
   45: 	pp_rpm_version="`expr $version : '\(.*\)p[0-9][0-9]*'`"
   46: 	pp_rpm_license="BSD"
   47: 	pp_rpm_url="http://www.sudo.ws/"
   48: 	pp_rpm_group="Applications/System"
   49: 	pp_rpm_packager="Todd C. Miller <Todd.Miller@courtesan.com>"
   50: 	if test -n "$linux_audit"; then
   51: 		pp_rpm_requires="audit-libs >= $linux_audit"
   52: 	fi
   53: %else
   54: 	# For all but RPM and Debian we need to install sudoers with a different
   55: 	# name and make a copy of it if there is no existing file.
   56: 	mv ${pp_destdir}$sudoersdir/sudoers ${pp_destdir}$sudoersdir/sudoers.dist
   57: %endif
   58: 
   59: %if [deb]
   60: 	pp_deb_maintainer="$pp_rpm_packager"
   61: 	pp_deb_release="$pp_rpm_release"
   62: 	pp_deb_version="$pp_rpm_version"
   63: 	pp_deb_section=admin
   64: 	install -D -m 644 ${pp_destdir}$docdir/LICENSE ${pp_wrkdir}/${name}/usr/share/doc/${name}/copyright
   65: 	install -D -m 644 ${pp_destdir}$docdir/ChangeLog ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog
   66: 	gzip -9f ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog
   67: 	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
   68: 	chmod 644 ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog.Debian
   69: 	gzip -9f ${pp_wrkdir}/${name}/usr/share/doc/${name}/changelog.Debian
   70: 	# Create lintian override file
   71: 	mkdir -p ${pp_wrkdir}/${name}/usr/share/lintian/overrides
   72: 	cat >${pp_wrkdir}/${name}/usr/share/lintian/overrides/${name} <<-EOF
   73: 	# The sudo binary must be setuid root
   74: 	$name: setuid-binary usr/bin/sudo 4755 root/root
   75: 	# Sudo configuration and data dirs must not be world-readable
   76: 	$name: non-standard-file-perm etc/sudoers 0440 != 0644
   77: 	$name: non-standard-dir-perm etc/sudoers.d/ 0750 != 0755
   78: 	$name: non-standard-dir-perm var/lib/sudo/ 0700 != 0755
   79: 	# Sudo ships with debugging symbols
   80: 	$name: unstripped-binary-or-object
   81: 	EOF
   82: 	chmod 644 ${pp_wrkdir}/${name}/usr/share/lintian/overrides/${name}
   83: %endif
   84: 
   85: %if [rpm]
   86: 	# Add distro info to release
   87: 	osrelease=`echo "$pp_rpm_distro" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`
   88: 	case "$pp_rpm_distro" in
   89: 	centos*|rhel*)
   90: 		pp_rpm_release="$pp_rpm_release.el${osrelease%%[0-9]}"
   91: 		;;
   92: 	sles*)
   93: 		pp_rpm_release="$pp_rpm_release.sles$osrelease"
   94: 		;;
   95: 	esac
   96: 
   97: 	# Uncomment some Defaults in sudoers
   98: 	# Note that the order must match that of sudoers.
   99: 	case "$pp_rpm_distro" in
  100: 	centos*|rhel*)
  101: 		chmod u+w ${pp_destdir}${sudoersdir}/sudoers
  102: 		/bin/ed - ${pp_destdir}${sudoersdir}/sudoers <<-'EOF'
  103: 		/Locale settings/+1,s/^# //
  104: 		/Desktop path settings/+1,s/^# //
  105: 		w
  106: 		q
  107: 		EOF
  108: 		chmod u-w ${pp_destdir}${sudoersdir}/sudoers
  109: 		;;
  110: 	sles*)
  111: 		chmod u+w ${pp_destdir}${sudoersdir}/sudoers
  112: 		/bin/ed - ${pp_destdir}${sudoersdir}/sudoers <<-'EOF'
  113: 		/Locale settings/+1,s/^# //
  114: 		/ConsoleKit session/+1,s/^# //
  115: 		/allow any user to run sudo if they know the password/+2,s/^# //
  116: 		/allow any user to run sudo if they know the password/+3,s/^# //
  117: 		w
  118: 		q
  119: 		EOF
  120: 		chmod u-w ${pp_destdir}${sudoersdir}/sudoers
  121: 		;;
  122: 	esac
  123: 
  124: 	# For RedHat the doc dir is expected to include version and release
  125: 	case "$pp_rpm_distro" in
  126: 	centos*|rhel*)
  127: 		mv ${pp_destdir}/${docdir} ${pp_destdir}/${docdir}-${version}-${pp_rpm_release}
  128: 		docdir=${docdir}-${version}-${pp_rpm_release}
  129: 		;;
  130: 	esac
  131: 
  132: 	# Choose the correct PAM file by distro, must be tab indented for "<<-"
  133: 	case "$pp_rpm_distro" in
  134: 	centos*|rhel*)
  135: 		mkdir -p ${pp_destdir}/etc/pam.d
  136: 		if test $osrelease -lt 50; then
  137: 			cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
  138: 			#%PAM-1.0
  139: 			auth       required	pam_stack.so service=system-auth
  140: 			account    required	pam_stack.so service=system-auth
  141: 			password   required	pam_stack.so service=system-auth
  142: 			session    required	pam_limits.so
  143: 			EOF
  144: 		else
  145: 			cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
  146: 			#%PAM-1.0
  147: 			auth       include	system-auth
  148: 			account    include	system-auth
  149: 			password   include	system-auth
  150: 			session    optional	pam_keyinit.so revoke
  151: 			session    required	pam_limits.so
  152: 			EOF
  153: 			cat > ${pp_destdir}/etc/pam.d/sudo-i <<-EOF
  154: 			#%PAM-1.0
  155: 			auth       include	sudo
  156: 			account    include	sudo
  157: 			password   include	sudo
  158: 			session    optional	pam_keyinit.so force revoke
  159: 			session    required	pam_limits.so
  160: 			EOF
  161: 		fi
  162: 		;;
  163: 	  sles*)
  164: 		mkdir -p ${pp_destdir}/etc/pam.d
  165: 		if test $osrelease -lt 10; then
  166: 			cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
  167: 			#%PAM-1.0
  168: 			auth     required       pam_unix2.so
  169: 			session  required       pam_limits.so
  170: 			EOF
  171: 		else
  172: 			cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
  173: 			#%PAM-1.0
  174: 			auth     include	common-auth
  175: 			account  include	common-account
  176: 			password include	common-password
  177: 			session  include	common-session
  178: 			# session  optional	pam_xauth.so
  179: 			EOF
  180: 		fi
  181: 		;;
  182: 	esac
  183: %endif
  184: 
  185: %if [deb]
  186: 	# Uncomment some Defaults and the %sudo rule in sudoers
  187: 	# Note that the order must match that of sudoers and be tab-indented.
  188: 	chmod u+w ${pp_destdir}${sudoersdir}/sudoers
  189: 	/bin/ed - ${pp_destdir}${sudoersdir}/sudoers <<-'EOF'
  190: 	/Locale settings/+1,s/^# //
  191: 	/X11 resource/+1,s/^# //
  192: 	/^# \%sudo/,s/^# //
  193: 	w
  194: 	q
  195: 	EOF
  196: 	chmod u-w ${pp_destdir}${sudoersdir}/sudoers
  197: 	mkdir -p ${pp_destdir}/etc/pam.d
  198: 	cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
  199: 	#%PAM-1.0
  200: 
  201: 	@include common-auth
  202: 	@include common-account
  203: 
  204: 	session required pam_permit.so
  205: 	session required pam_limits.so
  206: 	EOF
  207: %endif
  208: 
  209: %if [macos]
  210: 	pp_macos_pkg_type=flat
  211: 	pp_macos_bundle_id=ws.sudo.pkg.sudo
  212: 	pp_macos_pkg_license=doc/LICENSE
  213: 	pp_macos_pkg_readme=${pp_wrkdir}/ReadMe.txt
  214: 	perl -pe 'last if (/^What/i && $seen++)' NEWS > ${pp_wrkdir}/ReadMe.txt
  215: %endif
  216: 
  217: %if X"$aix_freeware" = X"true"
  218: 	# Create links from /opt/freeware/{bin,sbin} -> /usr/{bin.sbin}
  219: 	mkdir -p ${pp_destdir}/usr/bin ${pp_destdir}/usr/sbin
  220: 	ln -s -f ${bindir}/sudo ${pp_destdir}/usr/bin
  221: 	ln -s -f ${bindir}/sudoedit ${pp_destdir}/usr/bin
  222: 	ln -s -f ${bindir}/sudoreplay ${pp_destdir}/usr/bin
  223: 	ln -s -f ${sbindir}/visudo ${pp_destdir}/usr/sbin
  224: %endif
  225: 
  226: 	# OS-level directories that should generally exist but might not.
  227: 	extradirs=`echo ${pp_destdir}/${mandir}/[mc]* | sed "s#${pp_destdir}/##g"`
  228: 	extradirs="$extradirs `dirname $docdir` `dirname $rundir` `dirname $vardir`"
  229: 	test -d ${pp_destdir}${localedir} && extradirs="$extradirs $localedir"
  230: 	test -d ${pp_destdir}/etc/pam.d && extradirs="${extradirs} /etc/pam.d"
  231: 	for dir in $bindir $sbindir $libexecdir $includedir $extradirs; do
  232: 		while test "$dir" != "/"; do
  233: 			osdirs="${osdirs}${osdirs+ }$dir/"
  234: 			dir=`dirname $dir`
  235: 		done
  236: 	done
  237: 	osdirs=`echo $osdirs | tr " " "\n" | sort -u`
  238: 
  239: %depend [deb]
  240: 	libc6, libpam0g, libpam-modules, zlib1g, libselinux1
  241: 
  242: %fixup [deb]
  243: 	# Add Conflicts, Replaces headers and add libldap depedency as needed.
  244: 	if test -z "%{flavor}"; then
  245: 	    echo "Conflicts: sudo-ldap" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  246: 	    echo "Replaces: sudo-ldap" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  247: 	elif test "%{flavor}" = "ldap"; then
  248: 	    echo "Conflicts: sudo" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  249: 	    echo "Replaces: sudo" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  250: 	    echo "Provides: sudo" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  251: 	    cp -p %{pp_wrkdir}/%{name}/DEBIAN/control %{pp_wrkdir}/%{name}/DEBIAN/control.$$
  252: 	    sed 's/^\(Depends:.*\) *$/\1, libldap-2.4-2/' %{pp_wrkdir}/%{name}/DEBIAN/control.$$ > %{pp_wrkdir}/%{name}/DEBIAN/control
  253: 	    rm -f %{pp_wrkdir}/%{name}/DEBIAN/control.$$
  254: 	fi
  255: 	echo "Homepage: http://www.sudo.ws/sudo/" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  256: 	echo "Bugs: http://www.sudo.ws/bugs/" >> %{pp_wrkdir}/%{name}/DEBIAN/control
  257: 
  258: %files
  259: 	$osdirs			-
  260: 	$bindir/sudo        	4755 root:
  261: 	$bindir/sudoedit    	0755 root: symlink sudo
  262: 	$sbindir/visudo     	0755
  263: 	$bindir/sudoreplay  	0755
  264: 	$includedir/sudo_plugin.h 0644
  265: 	$libexecdir/sudo/	0755
  266: 	$libexecdir/sudo/sesh	0755 optional,ignore-others
  267: 	$libexecdir/sudo/*	$shlib_mode optional
  268: 	$sudoersdir/sudoers.d/	0750 $sudoers_uid:$sudoers_gid
  269: 	$rundir/		0711 root:
  270: 	$vardir/		0711 root: ignore-others
  271: 	$docdir/		0755
  272: 	$docdir/sudoers2ldif	0755 optional,ignore-others
  273: %if [deb]
  274: 	$docdir/LICENSE		ignore,ignore-others
  275: 	$docdir/ChangeLog	ignore,ignore-others
  276: %endif
  277: 	$docdir/*		0644
  278: 	$localedir/*/		-    optional
  279: 	$localedir/*/LC_MESSAGES/ -    optional
  280: 	$localedir/*/LC_MESSAGES/* 0644    optional
  281: 	/etc/pam.d/*		0644 volatile,optional
  282: %if [rpm,deb]
  283: 	$sudoersdir/sudoers $sudoers_mode $sudoers_uid:$sudoers_gid volatile
  284: %else
  285: 	$sudoersdir/sudoers.dist $sudoers_mode $sudoers_uid:$sudoers_gid volatile
  286: %endif
  287: %if X"$aix_freeware" = X"true"
  288: 	# Links for binaries from /opt/freeware to /usr
  289: 	/usr/bin/sudo    	0755 root: symlink $bindir/sudo
  290: 	/usr/bin/sudoedit    	0755 root: symlink $bindir/sudoedit
  291: 	/usr/bin/sudoreplay    	0755 root: symlink $bindir/sudoreplay
  292: 	/usr/sbin/visudo    	0755 root: symlink $sbindir/visudo
  293: %endif
  294: %if [rpm]
  295: 	/etc/rc.d/init.d/sudo	0755 root: optional
  296: %endif
  297: %if [aix]
  298: 	/etc/rc.d/		ignore
  299: 	/etc/rc.d/rc2.d/	ignore
  300: 	/etc/rc.d/rc2.d/**	ignore
  301: 	/etc/rc.d/init.d/	ignore
  302: 	/etc/rc.d/init.d/sudo	0755 root:
  303: %endif
  304: %if [sd]
  305: 	/sbin/			ignore
  306: 	/sbin/rc2.d/		ignore
  307: 	/sbin/rc2.d/**		ignore
  308: 	/sbin/init.d/		ignore
  309: 	/sbin/init.d/sudo	0755 root:
  310: %endif
  311: 
  312: %files [!aix]
  313: 	$sudoedit_man		0644 symlink,ignore-others $sudoedit_man_target
  314: 	$mandir/man*/*		0644
  315: 
  316: %files [aix]
  317: 	# Some versions use catpages, some use manpages.
  318: 	$sudoedit_man		0644 symlink,ignore-others $sudoedit_man_target
  319: 	$mandir/cat*/*		0644 optional
  320: 	$mandir/man*/*		0644 optional
  321: 
  322: %pre [aix]
  323: 	if rpm -q %{name} >/dev/null 2>&1; then
  324: 		echo "Another version of sudo is currently installed via rpm." 2>&1
  325: 		echo "Please either uninstall the rpm version of sudo by running \"rpm -e sudo\"" 2>&1
  326: 		echo "or upgrade the existing version of sudo using the .rpm packagae instead" 2>&1
  327: 		echo "instead of the .bff package." 2>&1
  328: 		echo "" 2>&1
  329: 		echo "Note that you may need to pass rpm the --oldpackage flag when upgrading" 2>&1
  330: 		echo "the AIX Toolbox version of sudo to the latest sudo rpm from sudo.ws." 2>&1
  331: 		echo "" 2>&1
  332: 		exit 1
  333: 	fi
  334: 
  335: %post [!rpm,deb]
  336: 	# Don't overwrite an existing sudoers file
  337: %if [solaris]
  338: 	sudoersdir=${PKG_INSTALL_ROOT}%{sudoersdir}
  339: %else
  340: 	sudoersdir=%{sudoersdir}
  341: %endif
  342: 	if test ! -r $sudoersdir/sudoers; then
  343: 		cp $sudoersdir/sudoers.dist $sudoersdir/sudoers
  344: 		chmod %{sudoers_mode} $sudoersdir/sudoers
  345: 		chown %{sudoers_uid} $sudoersdir/sudoers
  346: 		chgrp %{sudoers_gid} $sudoersdir/sudoers
  347: 	fi
  348: 
  349: %post [deb]
  350: 	set -e
  351: 
  352: 	# dpkg-deb does not maintain the mode on the sudoers file, and
  353: 	# installs it 0640 when sudo requires 0440
  354: 	chmod %{sudoers_mode} %{sudoersdir}/sudoers
  355: 
  356: 	# create symlink to ease transition to new path for ldap config
  357: 	# if old config file exists and new one doesn't
  358: 	if test X"%{flavor}" = X"ldap" -a \
  359: 	    -r /etc/ldap/ldap.conf -a ! -r /etc/sudo-ldap.conf; then
  360: 		ln -s /etc/ldap/ldap.conf /etc/sudo-ldap.conf
  361: 	fi
  362: 
  363: 	# Debian uses a sudo group in its default sudoers file
  364: 	perl -e '
  365: 		exit 0 if getgrnam("sudo");
  366: 		$gid = 27; # default debian sudo gid
  367: 		setgrent();
  368: 		while (getgrgid($gid)) { $gid++; }
  369: 		if ($gid != 27) {
  370: 			print "On Debian we normally use gid 27 for \"sudo\".\n";
  371: 			$gname = getgrgid(27);
  372: 			print "However, on your system gid 27 is group \"$gname\".\n\n";
  373: 			print "Would you like me to stop configuring sudo so that you can change this? [n] "; 
  374: 			$ans = <STDIN>;
  375: 			if ($ans =~ /^[yY]/) {
  376: 				print "\"dpkg --pending --configure\" will restart the configuration.\n\n";
  377: 				exit 1;
  378: 			}
  379: 		}
  380: 		print "Creating group \"sudo\" with gid = $gid\n";
  381: 		system("groupadd -g $gid sudo");
  382: 		exit 0;
  383: 	'
  384: 
  385: %post [rpm]
  386: 	case "%{pp_rpm_distro}" in
  387: 	aix*)
  388: 		# Create /etc/rc.d/rc2.d/S90sudo link if /etc/rc.d exists
  389: 		if [ -d /etc/rc.d ]; then
  390: 			rm -f /etc/rc.d/rc2.d/S90sudo
  391: 			ln -s /etc/rc.d/init.d/sudo /etc/rc.d/rc2.d/S90sudo
  392: 		fi
  393: 		;;
  394: 	esac
  395: 
  396: %post [aix]
  397: 	# Create /etc/rc.d/rc2.d/S90sudo link if /etc/rc.d exists
  398: 	if [ -d /etc/rc.d ]; then
  399: 		rm -f /etc/rc.d/rc2.d/S90sudo
  400: 		ln -s /etc/rc.d/init.d/sudo /etc/rc.d/rc2.d/S90sudo
  401: 	fi
  402: 
  403: %post [sd]
  404: 	# Create /sbin/rc2.d/S900sudo link
  405: 	rm -f /sbin/rc2.d/S900sudo
  406: 	ln -s /sbin/init.d/sudo /sbin/rc2.d/S900sudo
  407: 
  408: %preun
  409: 	# Remove the time stamp dir and its contents
  410: 	# We currently leave the lecture status files installed
  411: 	rm -rf %{rundir}/ts
  412: %if [deb]
  413: 	set -e
  414: 
  415: 	# Remove the /etc/ldap/ldap.conf -> /etc/sudo-ldap.conf symlink if
  416: 	# it matches what we created in the postinstall script.
  417: 	if test X"%{flavor}" = X"ldap" -a \
  418: 	    X"`readlink /etc/sudo-ldap.conf 2>/dev/null`" = X"/etc/ldap/ldap.conf"; then
  419: 		rm -f /etc/sudo-ldap.conf
  420: 	fi
  421: %endif
  422: %if [rpm]
  423: 	case "%{pp_rpm_distro}" in
  424: 	aix*)
  425: 		# Remove /etc/rc.d/rc2.d/S90sudo link
  426: 		rm -f /etc/rc.d/rc2.d/S90sudo
  427: 		;;
  428: 	esac
  429: %endif
  430: %if [aix]
  431: 	# Remove /etc/rc.d/rc2.d/S90sudo link
  432: 	rm -f /etc/rc.d/rc2.d/S90sudo
  433: %endif
  434: %if [sd]
  435: 	# Remove /sbin/rc2.d/S900sudo link
  436: 	rm -f /sbin/rc2.d/S900sudo
  437: %endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>