Author: jajcus
Date: Mon May 10 10:10:47 2010
New Revision: 11416

Added:
   rc-scripts/branches/upstart_native/init/   (props changed)
   rc-scripts/branches/upstart_native/init/Makefile.am
   rc-scripts/branches/upstart_native/init/random.conf
Modified:
   rc-scripts/branches/upstart_native/Makefile.am
   rc-scripts/branches/upstart_native/configure.ac
   rc-scripts/branches/upstart_native/rc.d/init.d/random
Log:
- 'random' implemented as an upstart job – this is an important dependency 
  for sensitive services


Modified: rc-scripts/branches/upstart_native/Makefile.am
==============================================================================
--- rc-scripts/branches/upstart_native/Makefile.am      (original)
+++ rc-scripts/branches/upstart_native/Makefile.am      Mon May 10 10:10:47 2010
@@ -2,7 +2,7 @@
 #      $Id$
 #
 
-SUBDIRS = src ppp isapnp sysconfig rc.d doc man po
+SUBDIRS = src ppp isapnp sysconfig rc.d doc man po init
 
 sysconf_DATA = \
        adjtime \

Modified: rc-scripts/branches/upstart_native/configure.ac
==============================================================================
--- rc-scripts/branches/upstart_native/configure.ac     (original)
+++ rc-scripts/branches/upstart_native/configure.ac     Mon May 10 10:10:47 2010
@@ -28,6 +28,7 @@
 downdir='${sysconfigdir}/interfaces/down.d'
 networkscriptsdir='${sysconfigdir}/network-scripts'
 rcdir='${sysconfdir}/rc.d'
+initdir='${sysconfdir}/init'
 docdir="${prefix}/doc/$PACKAGE-$VERSION"
 
 dnl i18n support
@@ -106,6 +107,7 @@
 AC_SUBST(updir)
 AC_SUBST(downdir)
 AC_SUBST(rcdir)
+AC_SUBST(initdir)
 AC_SUBST(docdir)
 AC_SUBST(GLIBDIR)
 AC_SUBST(GLIBNAME)
@@ -222,5 +224,6 @@
        sysconfig/interfaces/down.d/tnl/Makefile \
        rc.d/Makefile rc.d/init.d/Makefile \
        po/Makefile \
+       init/Makefile \
        ])
 AC_OUTPUT

Added: rc-scripts/branches/upstart_native/init/Makefile.am
==============================================================================
--- (empty file)
+++ rc-scripts/branches/upstart_native/init/Makefile.am Mon May 10 10:10:47 2010
@@ -0,0 +1,7 @@
+...@set_make@
+
+initdir = @initdir@
+
+init_DATA = random.conf
+
+EXTRA_DIST = $(init_DATA)

Added: rc-scripts/branches/upstart_native/init/random.conf
==============================================================================
--- (empty file)
+++ rc-scripts/branches/upstart_native/init/random.conf Mon May 10 10:10:47 2010
@@ -0,0 +1,27 @@
+description "Save random entropy on shutdown and restore it at boot time" 
+
+start on pld.sysinit_done
+stop on pld.shutdown_started
+
+env SEED_FILE=/var/run/random-seed
+
+pre-start script
+       poolfile=/proc/sys/kernel/random/poolsize
+       [ -r $poolfile ] && bytes="$(cat $poolfile)" || bytes=512
+       if [ -f $SEED_FILE ]; then
+               cat $SEED_FILE >/dev/urandom
+       else
+               touch $SEED_FILE
+       fi
+       chmod 600 $SEED_FILE
+       dd if=/dev/urandom of=$SEED_FILE count=1 bs=$bytes 2>/dev/null
+end script
+
+post-stop script
+       poolfile=/proc/sys/kernel/random/poolsize
+       [ -r $poolfile ] && bytes="$(cat $poolfile)" || bytes=512
+       touch $SEED_FILE
+       chmod 600 $SEED_FILE
+       dd if=/dev/urandom of=$SEED_FILE count=1 bs=$bytes 2>/dev/null
+end script
+

Modified: rc-scripts/branches/upstart_native/rc.d/init.d/random
==============================================================================
--- rc-scripts/branches/upstart_native/rc.d/init.d/random       (original)
+++ rc-scripts/branches/upstart_native/rc.d/init.d/random       Mon May 10 
10:10:47 2010
@@ -12,16 +12,20 @@
 # Source function library.
 . /etc/rc.d/init.d/functions
 
+upstart_controlled start stop
+
 random_seed=/var/run/random-seed
 
 poolfile=/proc/sys/kernel/random/poolsize
 [ -r $poolfile ] && bytes="$(cat $poolfile)" || bytes=512
 
+
 # See how we were called.
 case "$1" in
   start)
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/random ]; then
+               emit starting JOB=random
                show "Initializing random number generator"
                busy
                # Carry a random seed from start-up to start-up
@@ -35,11 +39,13 @@
                touch /var/lock/subsys/random
                deltext
                ok
+               emit started JOB=random
        fi
        ;;
   stop)
        if [ -f /var/lock/subsys/random ]; then
                # Carry a random seed from shut-down to start-up
+               emit stopping JOB=random
                show "Saving random seed"
                busy
                touch $random_seed
@@ -49,6 +55,7 @@
                rm -f /var/lock/subsys/random
                deltext
                ok
+               emit stopped JOB=random
        fi
        ;;
   status)
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to