]> granicus.if.org Git - sudo/commitdiff
First cut add installing an init.d file for HP-UX and AIX to remove
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 16 Feb 2014 17:22:43 +0000 (10:22 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 16 Feb 2014 17:22:43 +0000 (10:22 -0700)
old sudo timestamp files at boot time.

.hgignore
MANIFEST
configure
configure.ac
init.d/aix.sh.in [new file with mode: 0644]
init.d/hpux.sh.in [new file with mode: 0644]
src/Makefile.in
sudo.pp

index 718d8872df74478387435c01f728f6dae9a3acb1..95b10cf221f2f4e06f0fd38ed917ddf4bece5d78 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -22,6 +22,8 @@ Makefile$
 ^doc/.*\.mdoc\.sed$
 ^doc/varsub$
 
+^init.d/*.sh$
+
 ^pathnames\.h$
 ^src/sudo$
 ^src/sesh$
index 829e60d7f563eea2e434739b222314d87ce61aa8..6474cedded10f3f2a2c0e0e30922170e7edea0c1 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -159,6 +159,8 @@ include/sudo_event.h
 include/sudo_plugin.h
 include/sudo_util.h
 indent.pro
+init.d/aix.sh.in
+init.d/hpux.sh.in
 install-sh
 ltmain.sh
 m4/ax_check_compile_flag.m4
@@ -410,7 +412,6 @@ src/locale_stub.c
 src/net_ifs.c
 src/openbsd.c
 src/parse_args.c
-src/preserve_fds.c
 src/po/README
 src/po/cs.mo
 src/po/cs.po
@@ -460,6 +461,7 @@ src/po/vi.po
 src/po/zh_CN.mo
 src/po/zh_CN.po
 src/preload.c
+src/preserve_fds.c
 src/regress/ttyname/check_ttyname.c
 src/selinux.c
 src/sesh.c
index c864d9e67a5df9d63ef5543a6929d3df2bdddbf8..b55eced05c4cc269203ff933f3da5322f0cb4139 100755 (executable)
--- a/configure
+++ b/configure
@@ -719,6 +719,9 @@ timeout
 vardir
 rundir
 iolog_dir
+RC_LINK
+INIT_DIR
+INIT_SCRIPT
 NO_VIZ
 SSP_CFLAGS
 SSP_LDFLAGS
@@ -2966,6 +2969,9 @@ $as_echo "$as_me: Configuring Sudo version $PACKAGE_VERSION" >&6;}
 
 
 
+
+
+
 
 
 
@@ -3046,6 +3052,9 @@ LT_LDEXPORTS="-export-symbols \$(shlib_exp)"
 LT_LDDEP="\$(shlib_exp)"
 NO_VIZ="-DNO_VIZ"
 OS_INIT=os_init_common
+INIT_SCRIPT=
+INIT_DIR=
+RC_LINK=
 
 CHECKSHADOW=true
 shadow_defs=
                    RTLD_PRELOAD_VAR="LDR_PRELOAD"
                fi
 
+               # Remove timedir on boot, AIX does not have /var/run
+               INIT_SCRIPT=aix.sh
+               INIT_DIR=/etc/rc.d/init.d
+               RC_LINK=/etc/rc.d/rc2.d/S90sudo
+
                # AIX-specific functions
                for ac_func in getuserattr setauthdb setrlimit64
 do :
@@ -14253,6 +14267,11 @@ done
                : ${mansectsu='1m'}
                : ${mansectform='4'}
 
+               # HP-UX does not clear /var/run so we need to do it
+               INIT_SCRIPT=hpux.sh
+               INIT_DIR=/etc/rc.d/init.d
+               RC_LINK=/sbin/rc2.d/S900sudo
+
                # HP-UX shared libs must be executable
                SHLIB_MODE=0755
 
@@ -22388,7 +22407,7 @@ test "$localedir" = '${datarootdir}/locale' && localedir='$(datarootdir)/locale'
 test "$localstatedir" = '${prefix}/var' && localstatedir='$(prefix)/var'
 test "$sysconfdir" = '${prefix}/etc' -a X"$with_stow" != X"yes" && sysconfdir='/etc'
 
-ac_config_files="$ac_config_files Makefile common/Makefile compat/Makefile doc/Makefile include/Makefile src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers"
+ac_config_files="$ac_config_files Makefile common/Makefile compat/Makefile doc/Makefile include/Makefile init.d/aix.sh init.d/hpux.sh src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -23376,6 +23395,8 @@ do
     "compat/Makefile") CONFIG_FILES="$CONFIG_FILES compat/Makefile" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
+    "init.d/aix.sh") CONFIG_FILES="$CONFIG_FILES init.d/aix.sh" ;;
+    "init.d/hpux.sh") CONFIG_FILES="$CONFIG_FILES init.d/hpux.sh" ;;
     "src/sudo_usage.h") CONFIG_FILES="$CONFIG_FILES src/sudo_usage.h" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "plugins/sample/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sample/Makefile" ;;
@@ -24465,19 +24486,12 @@ $as_echo "$as_me: You will need to customize sample.pam and install it as /etc/p
            ;;
     esac
 fi
-clear_rundir=0
-case $host_os in
-    hpux*|aix*)
-       clear_rundir=1
+case "$rundir" in
+    /var/run*)
+       clear_rundir=0
        ;;
     *)
-       case "$rundir" in
-           /var/run*)
-               ;;
-           *)
-               clear_rundir=1
-               ;;
-       esac
+       clear_rundir=1
        ;;
 esac
 if test $clear_rundir -eq 1; then
index 8b5ad9bbfa694b6747c2530387c2dbac5c5fd325..6d21732cb4d5a4e95ed105eca95ee31b5963a438 100644 (file)
@@ -86,6 +86,9 @@ AC_SUBST([PIE_CFLAGS])
 AC_SUBST([SSP_LDFLAGS])
 AC_SUBST([SSP_CFLAGS])
 AC_SUBST([NO_VIZ])
+AC_SUBST([INIT_SCRIPT])
+AC_SUBST([INIT_DIR])
+AC_SUBST([RC_LINK])
 dnl
 dnl Variables that get substituted in docs (not overridden by environment)
 dnl
@@ -209,6 +212,9 @@ LT_LDEXPORTS="-export-symbols \$(shlib_exp)"
 LT_LDDEP="\$(shlib_exp)"
 NO_VIZ="-DNO_VIZ"
 OS_INIT=os_init_common
+INIT_SCRIPT=
+INIT_DIR=
+RC_LINK=
 
 dnl
 dnl Other vaiables
@@ -1672,6 +1678,11 @@ case "$host" in
                    RTLD_PRELOAD_VAR="LDR_PRELOAD"
                fi
 
+               # Remove timedir on boot, AIX does not have /var/run
+               INIT_SCRIPT=aix.sh
+               INIT_DIR=/etc/rc.d/init.d
+               RC_LINK=/etc/rc.d/rc2.d/S90sudo
+
                # AIX-specific functions
                AC_CHECK_FUNCS(getuserattr setauthdb setrlimit64)
                COMMON_OBJS="${COMMON_OBJS} aix.lo"
@@ -1691,6 +1702,11 @@ case "$host" in
                : ${mansectsu='1m'}
                : ${mansectform='4'}
 
+               # HP-UX does not clear /var/run so we need to do it
+               INIT_SCRIPT=hpux.sh
+               INIT_DIR=/etc/rc.d/init.d
+               RC_LINK=/sbin/rc2.d/S900sudo
+
                # HP-UX shared libs must be executable
                SHLIB_MODE=0755
 
@@ -3778,7 +3794,7 @@ test "$sysconfdir" = '${prefix}/etc' -a X"$with_stow" != X"yes" && sysconfdir='/
 dnl
 dnl Substitute into the Makefile and man pages
 dnl
-AC_CONFIG_FILES([Makefile common/Makefile compat/Makefile doc/Makefile include/Makefile src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers])
+AC_CONFIG_FILES([Makefile common/Makefile compat/Makefile doc/Makefile include/Makefile init.d/aix.sh init.d/hpux.sh src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers])
 AC_OUTPUT
 
 dnl
@@ -3798,22 +3814,14 @@ if test "$with_pam" = "yes"; then
     esac
 fi
 dnl
-dnl AIX and HP-UX do not clear /var/run
-dnl Also point out other non-cleared dirs
+dnl Warn user if they may need to clear rundir manually.
 dnl
-clear_rundir=0
-case $host_os in
-    hpux*|aix*)
-       clear_rundir=1
+case "$rundir" in
+    /var/run*)
+       clear_rundir=0
        ;;
     *)
-       case "$rundir" in
-           /var/run*)
-               ;;
-           *)
-               clear_rundir=1
-               ;;
-       esac
+       clear_rundir=1
        ;;
 esac
 if test $clear_rundir -eq 1; then
diff --git a/init.d/aix.sh.in b/init.d/aix.sh.in
new file mode 100644 (file)
index 0000000..3d11241
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Simple AIX rc.d script to remove the sudo timestamp directory on boot.
+# This is needed because AIX does not have /var/run.
+# Install as /etc/rc.d/init.d/sudo with a link /etc/rc.d/rc2.d/S90sudo
+#
+
+PATH=/usr/sbin:/usr/bin:/sbin
+export PATH
+
+TSDIR="@rundir@/ts"
+rval=0
+
+case "$1" in
+start)
+    echo "Removing the $TSDIR directory"
+    rm -rf "$TSDIR"
+    ;;
+*)
+    echo "usage: $0 start"
+    rval=1
+    ;;
+esac
+
+exit $rval
diff --git a/init.d/hpux.sh.in b/init.d/hpux.sh.in
new file mode 100644 (file)
index 0000000..5a76bd2
--- /dev/null
@@ -0,0 +1,27 @@
+#!/sbin/sh
+#
+# Simple HP-UX init.d script to remove the sudo timestamp directory on boot.
+# This is needed because HP-UX does not clear /var/run on its own.
+# Install as /sbin/init.d/sudo with a link /sbin/rc2.d/S900sudo
+#
+
+PATH=/usr/sbin:/usr/bin:/sbin
+export PATH
+
+TSDIR="@rundir@/ts"
+rval=0
+
+case "$1" in
+start_msg)
+    echo "Removing the $TSDIR directory"
+    ;;
+start)
+    rm -rf "$TSDIR"
+    ;;
+*)
+    echo "usage: $0 {start|start_msg}"
+    rval=1
+    ;;
+esac
+
+exit $rval
index 4e3c1499c22dada4cccdfdf656443a730c137514..c33b1662d5d2c724396b8901057bd97a4e3af514 100644 (file)
@@ -79,6 +79,11 @@ install_gid = 0
 shlib_ext = @SHLIB_EXT@
 shlib_mode = @SHLIB_MODE@
 
+# Optional init script and rc.d link
+INIT_DIR=@INIT_DIR@
+INIT_SCRIPT=@INIT_SCRIPT@
+RC_LINK=@RC_LINK@
+
 TEST_PROGS = check_ttyname
 TEST_LIBS = @LIBS@ @LIBINTL@ $(LT_LIBS)
 TEST_LDFLAGS = @LDFLAGS@
@@ -135,12 +140,21 @@ check_ttyname: $(CHECK_TTYNAME_OBJS) $(top_builddir)/common/libsudo_util.la $(LI
 
 pre-install:
 
-install: install-binaries @INSTALL_NOEXEC@
+install: install-binaries install-rc @INSTALL_NOEXEC@
 
 install-dirs:
        $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(bindir) \
            $(DESTDIR)$(libexecdir)/sudo $(DESTDIR)$(noexecdir)
 
+install-rc:
+       @if [ -n "$(INIT_SCRIPT)" ]; then \
+           $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(INIT_DIR) \
+               `echo $(DESTDIR)$(RC_LINK)|sed 's,/[^/]*$$,,'`; \
+           $(INSTALL) -O $(install_uid) -G $(install_gid) -m 0755 $(top_srcdir)/init.d/$(INIT_SCRIPT) $(DESTDIR)$(INIT_DIR)/sudo; \
+           rm -f $(DESTDIR)$(RC_LINK); \
+           ln -s $(INIT_DIR)/sudo $(DESTDIR)$(RC_LINK); \
+       fi
+
 install-binaries: install-dirs $(PROGS)
        $(INSTALL) -b~ -O $(install_uid) -G $(install_gid) -m 04755 sudo $(DESTDIR)$(bindir)/sudo
        rm -f $(DESTDIR)$(bindir)/sudoedit
diff --git a/sudo.pp b/sudo.pp
index e869a9b382d7ee8d0f7a4d50dc76db7e3a0c2e91..74344bfc5c6b0de322e1c6cb3b63727bdfa57830 100644 (file)
--- a/sudo.pp
+++ b/sudo.pp
@@ -291,6 +291,12 @@ still allow people to get their work done."
        /usr/bin/sudoreplay     0755 root: symlink $bindir/sudoreplay
        /usr/sbin/visudo        0755 root: symlink $sbindir/visudo
 %endif
+%if [aix]
+       /etc/rc.d/init.d/sudo   0755 root:
+%endif
+%if [sd]
+       /sbin/init.d/sudo       0755 root:
+%endif
 
 %files [!aix]
        $sudoedit_man           0644 symlink,ignore-others $sudoedit_man_target
@@ -365,6 +371,18 @@ still allow people to get their work done."
                exit 0;
        '
 
+%post [aix]
+       # Create /etc/rc.d/rc2.d/S90sudo link if /etc/rc.d exists
+       if [ -d /etc/rc.d ]; then
+               rm -f /etc/rc.d/rc2.d/S90sudo
+               ln -s /etc/rc.d/init.d/sudo /etc/rc.d/rc2.d/S90sudo
+       fi
+%endif
+%post [sd]
+       # Create /sbin/rc2.d/S900sudo link
+       rm -f /sbin/rc2.d/S900sudo
+       ln -s /sbin/init.d/sudo /sbin/rc2.d/S900sudo
+%endif
 %preun
        # Remove the time stamp dir and its contents
        # We currently leave the lecture status files installed
@@ -379,3 +397,11 @@ still allow people to get their work done."
                rm -f /etc/sudo-ldap.conf
        fi
 %endif
+%if [aix]
+       # Remove /etc/rc.d/rc2.d/S90sudo link
+       rm -f /etc/rc.d/rc2.d/S90sudo
+%endif
+%if [sd]
+       # Remove /sbin/rc2.d/S900sudo link
+       rm -f /sbin/rc2.d/S900sudo
+%endif