From 812f8fb6eb6a46b69cf0d773dec84dcfc646d48b Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 17 Feb 2010 03:23:42 +0000 Subject: [PATCH 01/61] Initialize branch F-13 for upstart --- branch | 1 + 1 file changed, 1 insertion(+) create mode 100644 branch diff --git a/branch b/branch new file mode 100644 index 0000000..baa94ef --- /dev/null +++ b/branch @@ -0,0 +1 @@ +F-13 From 491dadb43eee21f15e97db085c0a556ac04bb8b8 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 17 Feb 2010 14:56:39 +0000 Subject: [PATCH 02/61] move init-system-dbus.conf from sources to cvs clean .cvsignore --- .cvsignore | 2 -- init-system-dbus.conf | 6 ++++++ sources | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 init-system-dbus.conf diff --git a/.cvsignore b/.cvsignore index f21fdee..6c5c773 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,3 +1 @@ upstart-0.6.3.tar.bz2 -upstart-remove-tests.patch -init-system-dbus.conf diff --git a/init-system-dbus.conf b/init-system-dbus.conf new file mode 100644 index 0000000..0fc6a8a --- /dev/null +++ b/init-system-dbus.conf @@ -0,0 +1,6 @@ +# init-system-dbus - tell init process to connect to system dbus server + +start on started messagebus + +task +exec /bin/kill -USR1 1 diff --git a/sources b/sources index d83faa8..dfeb0a7 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ ef9d2704426423f75d1e0c309ecfceb4 upstart-0.6.3.tar.bz2 -bf835fea1be622a5d68f168bd63f91e5 init-system-dbus.conf From fb3df4161b2ea87ecb10304016efe6397b223899 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 17 Feb 2010 15:30:54 +0000 Subject: [PATCH 03/61] upgrade to upstart-0.6.5 removed obsolete patches --- upstart-audit-events.patch | 783 +++++++++++++++++++++++-- upstart-nih-alloc.patch | 63 -- upstart-save-state-across-reexec.patch | 429 -------------- upstart.spec | 37 +- 4 files changed, 749 insertions(+), 563 deletions(-) delete mode 100644 upstart-nih-alloc.patch delete mode 100644 upstart-save-state-across-reexec.patch diff --git a/upstart-audit-events.patch b/upstart-audit-events.patch index f728d66..07df654 100644 --- a/upstart-audit-events.patch +++ b/upstart-audit-events.patch @@ -1,63 +1,753 @@ -diff --git a/util/Makefile.in b/util/Makefile.in -index 26025ce..f7b61a3 100644 ---- a/util/Makefile.in -+++ b/util/Makefile.in -@@ -376,6 +376,7 @@ reboot_SOURCES = \ - reboot_LDFLAGS = -static +diff --git a/Makefile.in b/Makefile.in +index a9550df..bdd0def 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -49,17 +49,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ +@@ -132,6 +133,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/aclocal.m4 b/aclocal.m4 +index 3d3673e..6e09291 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -1066,6 +1066,7 @@ m4_include([m4/lcmessage.m4]) + m4_include([m4/lib-ld.m4]) + m4_include([m4/lib-link.m4]) + m4_include([m4/lib-prefix.m4]) ++m4_include([m4/libaudit.m4]) + m4_include([m4/libnih.m4]) + m4_include([m4/libtool.m4]) + m4_include([m4/lock.m4]) +diff --git a/conf/Makefile.in b/conf/Makefile.in +index 29fd9b7..82c3f99 100644 +--- a/conf/Makefile.in ++++ b/conf/Makefile.in +@@ -46,17 +46,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -100,6 +101,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/config.h.in b/config.h.in +index 8a7d63f..8d000aa 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -118,6 +118,9 @@ + /* Define if your file defines LC_MESSAGES. */ + #undef HAVE_LC_MESSAGES + ++/* linux audit support */ ++#undef HAVE_LIBAUDIT ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_LIMITS_H + +diff --git a/configure b/configure +index 9bad2db..2f93ef5 100755 +--- a/configure ++++ b/configure +@@ -751,6 +751,7 @@ ac_subst_vars='am__EXEEXT_FALSE + am__EXEEXT_TRUE + LTLIBOBJS + LIBOBJS ++AUDIT_LDADD + DBUS_LIBS + DBUS_CFLAGS + NIH_DBUS_LIBS +@@ -938,6 +939,7 @@ with_included_gettext + with_libintl_prefix + with_local_libnih + enable_threading ++with_libaudit + enable_compiler_warnings + enable_compiler_optimisations + enable_compiler_coverage +@@ -1620,6 +1622,7 @@ Optional Packages: + --without-libintl-prefix don't search for libintl in includedir and libdir + --with-local-libnih[=DIR] + Use libnih from source tree DIR ++ --with-libaudit=auto/yes/no Add Linux audit support default=auto + + Some influential environment variables: + CC C compiler command +@@ -5220,13 +5223,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : + else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext +- (eval echo "\"\$as_me:5223: $ac_compile\"" >&5) ++ (eval echo "\"\$as_me:5226: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 +- (eval echo "\"\$as_me:5226: $NM \\\"conftest.$ac_objext\\\"\"" >&5) ++ (eval echo "\"\$as_me:5229: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 +- (eval echo "\"\$as_me:5229: output\"" >&5) ++ (eval echo "\"\$as_me:5232: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" +@@ -6431,7 +6434,7 @@ ia64-*-hpux*) + ;; + *-*-irix6*) + # Find out which ABI we are using. +- echo '#line 6434 "configure"' > conftest.$ac_ext ++ echo '#line 6437 "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? +@@ -7693,11 +7696,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:7696: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:7699: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 +- echo "$as_me:7700: \$? = $ac_status" >&5 ++ echo "$as_me:7703: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. +@@ -8032,11 +8035,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:8035: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:8038: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 +- echo "$as_me:8039: \$? = $ac_status" >&5 ++ echo "$as_me:8042: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. +@@ -8137,11 +8140,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:8140: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:8143: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 +- echo "$as_me:8144: \$? = $ac_status" >&5 ++ echo "$as_me:8147: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized +@@ -8192,11 +8195,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:8195: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:8198: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 +- echo "$as_me:8199: \$? = $ac_status" >&5 ++ echo "$as_me:8202: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized +@@ -10576,7 +10579,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 10579 "configure" ++#line 10582 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -10672,7 +10675,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 10675 "configure" ++#line 10678 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -17209,6 +17212,72 @@ fi + + # Checks for library functions. + ++ ++# Check whether --with-libaudit was given. ++if test "${with_libaudit+set}" = set; then : ++ withval=$with_libaudit; ++else ++ with_libaudit=auto ++fi ++ ++ ++ # Check for Linux auditing API ++ # ++ # libaudit detection ++ ++ if test x$with_libaudit = xno ; then ++ have_libaudit=no; ++ else ++ # See if we have audit daemon library ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for audit_log_user_message in -laudit" >&5 ++$as_echo_n "checking for audit_log_user_message in -laudit... " >&6; } ++if test "${ac_cv_lib_audit_audit_log_user_message+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-laudit $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char audit_log_user_message (); ++int ++main () ++{ ++return audit_log_user_message (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_audit_audit_log_user_message=yes ++else ++ ac_cv_lib_audit_audit_log_user_message=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_audit_audit_log_user_message" >&5 ++$as_echo "$ac_cv_lib_audit_audit_log_user_message" >&6; } ++if test "x$ac_cv_lib_audit_audit_log_user_message" = x""yes; then : ++ AUDIT_LDADD=-laudit ++fi ++ ++ fi ++ ++ if test x$AUDIT_LDADD != x ; then ++ ++$as_echo "#define HAVE_LIBAUDIT 1" >>confdefs.h ++ ++ fi ++ ++ + # Other checks + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include sbindir in PATH" >&5 + $as_echo_n "checking whether to include sbindir in PATH... " >&6; } +diff --git a/configure.ac b/configure.ac +index fb79a13..3dc1550 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -54,6 +54,7 @@ AM_PROG_CC_C_O + NIH_C_THREAD + + # Checks for library functions. ++LINUX_AUDIT + + # Other checks + AC_MSG_CHECKING([whether to include sbindir in PATH]) +diff --git a/contrib/Makefile.in b/contrib/Makefile.in +index dfe910b..32c7ebd 100644 +--- a/contrib/Makefile.in ++++ b/contrib/Makefile.in +@@ -44,17 +44,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -75,6 +76,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/dbus/Makefile.in b/dbus/Makefile.in +index 8294845..38a55ad 100644 +--- a/dbus/Makefile.in ++++ b/dbus/Makefile.in +@@ -46,17 +46,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -100,6 +101,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/doc/Makefile.in b/doc/Makefile.in +index b17181c..add3022 100644 +--- a/doc/Makefile.in ++++ b/doc/Makefile.in +@@ -44,17 +44,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -75,6 +76,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/init/Makefile.in b/init/Makefile.in +index c677761..9ca3de6 100644 +--- a/init/Makefile.in ++++ b/init/Makefile.in +@@ -55,17 +55,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -283,6 +284,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/m4/libaudit.m4 b/m4/libaudit.m4 +new file mode 100644 +index 0000000..6865fb8 +--- /dev/null ++++ b/m4/libaudit.m4 +@@ -0,0 +1,25 @@ ++# libaudit.m4 - Checks for the Linux Audit System support ++# Copyright (c) 2009 Steve Grubb sgrubb@redhat.com ++# ++AC_DEFUN([LINUX_AUDIT], ++[ ++ AC_ARG_WITH(libaudit, ++ [ --with-libaudit=[auto/yes/no] Add Linux audit support [default=auto]],, ++ with_libaudit=auto) ++ ++ # Check for Linux auditing API ++ # ++ # libaudit detection ++ ++ if test x$with_libaudit = xno ; then ++ have_libaudit=no; ++ else ++ # See if we have audit daemon library ++ AC_CHECK_LIB(audit, audit_log_user_message, ++ AUDIT_LDADD=-laudit,) ++ fi ++ AC_SUBST(AUDIT_LDADD) ++ if test x$AUDIT_LDADD != x ; then ++ AC_DEFINE(HAVE_LIBAUDIT,1,[linux audit support]) ++ fi ++]) +diff --git a/util/Makefile.am b/util/Makefile.am +index 0b49c10..9a772d5 100644 +--- a/util/Makefile.am ++++ b/util/Makefile.am +@@ -45,14 +45,17 @@ reboot_SOURCES = \ + utmp.c utmp.h reboot_LDADD = \ - ../nih/libnih.la \ -+ -laudit \ - $(LTLIBINTL) + $(LTLIBINTL) \ +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) ++ runlevel_SOURCES = \ -@@ -399,6 +400,7 @@ shutdown_LDFLAGS = -static - shutdown_LDADD = \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ + runlevel.c \ + utmp.c utmp.h + runlevel_LDADD = \ $(LTLIBINTL) \ - $(DBUS_LIBS) +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) -@@ -414,6 +416,7 @@ telinit_LDFLAGS = -static - telinit_LDADD = \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ + shutdown_SOURCES = \ + shutdown.c \ +@@ -64,7 +67,8 @@ shutdown_LDADD = \ $(LTLIBINTL) \ - $(DBUS_LIBS) + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) -@@ -477,6 +480,7 @@ test_sysv_LDADD = \ - sysv.o utmp.o \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ + telinit_SOURCES = \ + telinit.c \ +@@ -76,7 +80,8 @@ telinit_LDADD = \ $(LTLIBINTL) \ - $(DBUS_LIBS) + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) -@@ -489,6 +493,7 @@ test_telinit_LDADD = \ + + com_ubuntu_Upstart_OUTPUTS = \ +@@ -201,7 +206,8 @@ test_sysv_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + test_telinit_SOURCES = tests/test_telinit.c telinit.c + test_telinit_CFLAGS = $(AM_CFLAGS) -DTEST +@@ -211,7 +217,8 @@ test_telinit_LDADD = \ com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ - $(DBUS_LIBS) + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + + .PHONY: tests +diff --git a/util/Makefile.in b/util/Makefile.in +index 55e17e5..40776d5 100644 +--- a/util/Makefile.in ++++ b/util/Makefile.in +@@ -51,17 +51,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -88,20 +89,24 @@ am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) + am__v_lt_0 = --silent + am_reboot_OBJECTS = reboot.$(OBJEXT) utmp.$(OBJEXT) + reboot_OBJECTS = $(am_reboot_OBJECTS) +-reboot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++reboot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_runlevel_OBJECTS = runlevel.$(OBJEXT) utmp.$(OBJEXT) + runlevel_OBJECTS = $(am_runlevel_OBJECTS) +-runlevel_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++runlevel_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_shutdown_OBJECTS = shutdown.$(OBJEXT) utmp.$(OBJEXT) sysv.$(OBJEXT) + nodist_shutdown_OBJECTS = $(am__objects_1) + shutdown_OBJECTS = $(am_shutdown_OBJECTS) $(nodist_shutdown_OBJECTS) + shutdown_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_telinit_OBJECTS = telinit.$(OBJEXT) utmp.$(OBJEXT) sysv.$(OBJEXT) + nodist_telinit_OBJECTS = $(am__objects_1) + telinit_OBJECTS = $(am_telinit_OBJECTS) $(nodist_telinit_OBJECTS) + telinit_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_test_initctl_OBJECTS = test_initctl-test_initctl.$(OBJEXT) \ + test_initctl-initctl.$(OBJEXT) + test_initctl_OBJECTS = $(am_test_initctl_OBJECTS) +@@ -118,14 +123,14 @@ test_sysv_OBJECTS = $(am_test_sysv_OBJECTS) \ + $(nodist_test_sysv_OBJECTS) + test_sysv_DEPENDENCIES = sysv.o utmp.o $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + am_test_telinit_OBJECTS = test_telinit-test_telinit.$(OBJEXT) \ + test_telinit-telinit.$(OBJEXT) + test_telinit_OBJECTS = $(am_test_telinit_OBJECTS) + test_telinit_DEPENDENCIES = sysv.o utmp.o com.ubuntu.Upstart.o \ + com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + test_telinit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_telinit_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@@ -216,6 +221,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +@@ -419,7 +425,8 @@ reboot_SOURCES = \ + + reboot_LDADD = \ + $(LTLIBINTL) \ +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) + + runlevel_SOURCES = \ + runlevel.c \ +@@ -427,7 +434,8 @@ runlevel_SOURCES = \ + + runlevel_LDADD = \ + $(LTLIBINTL) \ +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) + + shutdown_SOURCES = \ + shutdown.c \ +@@ -441,7 +449,8 @@ shutdown_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + telinit_SOURCES = \ + telinit.c \ +@@ -455,7 +464,8 @@ telinit_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + com_ubuntu_Upstart_OUTPUTS = \ + com.ubuntu.Upstart.c \ +@@ -515,7 +525,8 @@ test_sysv_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + test_telinit_SOURCES = tests/test_telinit.c telinit.c + test_telinit_CFLAGS = $(AM_CFLAGS) -DTEST +@@ -525,7 +536,8 @@ test_telinit_LDADD = \ + com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/util/reboot.c b/util/reboot.c -index dda2935..eef9ed2 100644 +index 7a9c071..15028eb 100644 --- a/util/reboot.c +++ b/util/reboot.c @@ -36,6 +36,10 @@ #include #include -+#if 1 /* HAVE_LIBAUDIT */ ++#ifdef HAVE_LIBAUDIT +#include +#endif + #include "utmp.h" -@@ -96,7 +100,6 @@ static int poweroff = FALSE; +@@ -103,7 +107,6 @@ static int poweroff = FALSE; **/ static int exit_only = FALSE; @@ -65,7 +755,7 @@ index dda2935..eef9ed2 100644 /** * options: * -@@ -119,6 +122,7 @@ static NihOption options[] = { +@@ -127,6 +130,7 @@ static NihOption options[] = { NIH_OPTION_LAST }; @@ -73,7 +763,7 @@ index dda2935..eef9ed2 100644 int main (int argc, -@@ -216,6 +220,8 @@ main (int argc, +@@ -227,6 +231,8 @@ main (int argc, /* Re-enable Control-Alt-Delete in case it breaks */ reboot (RB_ENABLE_CAD); @@ -82,7 +772,7 @@ index dda2935..eef9ed2 100644 /* Do the syscall */ switch (mode) { case REBOOT: -@@ -237,3 +243,21 @@ main (int argc, +@@ -248,3 +254,21 @@ main (int argc, return 0; } @@ -95,7 +785,7 @@ index dda2935..eef9ed2 100644 +static void +send_audit_event (void) +{ -+#if 1 /* HAVE_LIBAUDIT */ ++#ifdef HAVE_LIBAUDIT + int fd = audit_open (); + if (fd < 0) + return; @@ -105,20 +795,23 @@ index dda2935..eef9ed2 100644 +#endif +} diff --git a/util/sysv.c b/util/sysv.c -index fbca39f..32b5540 100644 +index fbca39f..5476f79 100644 --- a/util/sysv.c +++ b/util/sysv.c -@@ -36,6 +36,9 @@ +@@ -36,6 +36,12 @@ #include #include +#include ++#ifdef HAVE_LIBAUDIT ++#include +#include ++#endif + #include "dbus/upstart.h" #include "utmp.h" -@@ -54,6 +57,7 @@ +@@ -54,6 +60,7 @@ /* Prototypes for static functions */ static void error_handler (NihError **err, NihDBusMessage *message); @@ -126,7 +819,7 @@ index fbca39f..32b5540 100644 /** -@@ -161,6 +165,8 @@ sysv_change_runlevel (int runlevel, +@@ -161,6 +168,8 @@ sysv_change_runlevel (int runlevel, runlevel, prevlevel) < 0) nih_free (nih_error_get ()); @@ -135,7 +828,7 @@ index fbca39f..32b5540 100644 /* Make the EmitEvent call, we don't wait for the event to finish * because sysvinit never did. */ -@@ -199,3 +205,41 @@ error_handler (NihError ** err, +@@ -199,3 +208,41 @@ error_handler (NihError ** err, { *err = nih_error_steal (); } @@ -151,7 +844,7 @@ index fbca39f..32b5540 100644 +static void +send_audit_event (int old, int level) +{ -+#if 1 /* HAVE_LIBAUDIT */ ++#ifdef HAVE_LIBAUDIT + int fd = audit_open (); + + if (fd < 0) diff --git a/upstart-nih-alloc.patch b/upstart-nih-alloc.patch deleted file mode 100644 index 208b05f..0000000 --- a/upstart-nih-alloc.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- upstart-0.6.3/nih/alloc.c.orig 2010-01-17 17:28:33.000000000 +0000 -+++ upstart-0.6.3/nih/alloc.c 2010-01-17 17:28:38.000000000 +0000 -@@ -54,6 +54,8 @@ - NihDestructor destructor; - } NihAllocCtx; - -+#define NIH_ALLOC_CTX_SIZE (sizeof(NihAllocCtx) + __alignof__(NihAllocCtx)) -+ - /** - * NihAllocRef: - * @children_entry: list head in parent's children list, -@@ -82,7 +84,7 @@ - * - * Returns: pointer to NihAllocCtx structure. - **/ --#define NIH_ALLOC_CTX(ptr) ((NihAllocCtx *)(ptr) - 1) -+#define NIH_ALLOC_CTX(ptr) ((NihAllocCtx *)((void*)ptr - NIH_ALLOC_CTX_SIZE)) - - /** - * NIH_ALLOC_PTR: -@@ -93,7 +95,7 @@ - * - * Returns: pointer to block of memory. - **/ --#define NIH_ALLOC_PTR(ctx) ((void *)((NihAllocCtx *)(ctx) + 1)) -+#define NIH_ALLOC_PTR(ctx) ((void*)((void*)ctx + NIH_ALLOC_CTX_SIZE)) - - /** - * NIH_ALLOC_FINALISED: -@@ -145,7 +147,7 @@ - { - NihAllocCtx *ctx; - -- ctx = __nih_malloc (sizeof (NihAllocCtx) + size); -+ ctx = __nih_malloc (NIH_ALLOC_CTX_SIZE + size); - if (! ctx) - return NULL; - -@@ -230,7 +232,7 @@ - /* Now do the actual realloc(), if this fails then we can just - * return NULL since we've not actually changed anything. - */ -- ctx = __nih_realloc (ctx, sizeof (NihAllocCtx) + size); -+ ctx = __nih_realloc (ctx, NIH_ALLOC_CTX_SIZE + size); - if (! ctx) - return NULL; - -@@ -562,7 +564,7 @@ - nih_assert (child != NULL); - nih_assert (child->destructor != NIH_ALLOC_FINALISED); - -- ref = NIH_MUST (malloc (sizeof (NihAllocRef))); -+ ref = NIH_MUST (malloc (NIH_ALLOC_CTX_SIZE)); - - nih_list_init (&ref->children_entry); - nih_list_init (&ref->parents_entry); -@@ -739,5 +741,5 @@ - ctx = NIH_ALLOC_CTX (ptr); - nih_assert (ctx->destructor != NIH_ALLOC_FINALISED); - -- return malloc_usable_size (ctx) - sizeof (NihAllocCtx); -+ return malloc_usable_size (ctx) - NIH_ALLOC_CTX_SIZE; - } diff --git a/upstart-save-state-across-reexec.patch b/upstart-save-state-across-reexec.patch deleted file mode 100644 index 68001d1..0000000 --- a/upstart-save-state-across-reexec.patch +++ /dev/null @@ -1,429 +0,0 @@ -diff -uNr upstart-0.3.9.orig/init/main.c upstart-0.3.9/init/main.c ---- upstart-0.3.9.orig/init/main.c 2009-01-23 13:44:32.000000000 -0500 -+++ upstart-0.3.9/init/main.c 2009-01-23 13:44:54.000000000 -0500 -@@ -59,6 +59,7 @@ - #include "cfgfile.h" - #include "paths.h" - #include "tty.h" -+#include "restore.h" - - - /* Prototypes for static functions */ -@@ -278,6 +279,10 @@ - exit (1); - } - -+ /* Restore the state of previously active jobs, if re-exec'd by -+ * a previously running init. */ -+ -+ if (restart) restore_configuration(args); - - /* Generate and run the startup event or read the state from the - * init daemon that exec'd us -@@ -534,6 +539,8 @@ - NihError *err; - const char *loglevel; - sigset_t mask, oldmask; -+ char **args; -+ size_t len; - - nih_assert (argv0 != NULL); - nih_assert (signal != NULL); -@@ -559,7 +566,20 @@ - } else { - loglevel = NULL; - } -- execl (argv0, argv0, "--restart", loglevel, NULL); -+ args = nih_str_array_new(NULL); -+ len = 0; -+ if (args) args = nih_str_array_add(&args, NULL, &len, argv0); -+ if (args) args = nih_str_array_add(&args, NULL, &len, "--restart"); -+ if (args && loglevel) -+ args = nih_str_array_add(&args, NULL, &len, loglevel); -+ if (args) save_current_configuration(&args, NULL, &len); -+ if (args) { -+ execv (argv0, args); -+ nih_free(args); -+ } else { -+ nih_warn (_("Unable to save list of currently running jobs")); -+ execl(argv0, argv0, "--restart", loglevel, NULL); -+ } - nih_error_raise_system (); - - err = nih_error_get (); -diff -uNr upstart-0.3.9.orig/init/Makefile.in upstart-0.3.9/init/Makefile.in ---- upstart-0.3.9.orig/init/Makefile.in 2009-01-23 13:44:32.000000000 -0500 -+++ upstart-0.3.9/init/Makefile.in 2009-01-23 13:44:54.000000000 -0500 -@@ -72,7 +72,7 @@ - PROGRAMS = $(sbin_PROGRAMS) - am_init_OBJECTS = main.$(OBJEXT) tty.$(OBJEXT) process.$(OBJEXT) \ - job.$(OBJEXT) event.$(OBJEXT) control.$(OBJEXT) \ -- notify.$(OBJEXT) cfgfile.$(OBJEXT) -+ notify.$(OBJEXT) cfgfile.$(OBJEXT) restore.$(OBJEXT) - init_OBJECTS = $(am_init_OBJECTS) - am__DEPENDENCIES_1 = - init_DEPENDENCIES = ../upstart/libupstart.la ../nih/libnih.la \ -@@ -315,7 +315,8 @@ - event.c event.h \ - control.c control.h \ - notify.c notify.h \ -- cfgfile.c cfgfile.h -+ cfgfile.c cfgfile.h \ -+ restore.c restore.h - - init_LDFLAGS = -static - init_LDADD = \ -diff -uNr upstart-0.3.9.orig/init/restore.c upstart-0.3.9/init/restore.c ---- upstart-0.3.9.orig/init/restore.c 1969-12-31 19:00:00.000000000 -0500 -+++ upstart-0.3.9/init/restore.c 2009-01-23 13:44:54.000000000 -0500 -@@ -0,0 +1,333 @@ -+/* Modifications to upstart to allow passing of the state of currently -+ * running jobs when upstart re-execs itself. -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif /* HAVE_CONFIG_H */ -+ -+ -+#include -+#include -+#include -+#include -+#include -+#include "job.h" -+#include "restore.h" -+ -+ -+/** -+ * store_pid: -+ * @proc: pointer to a JobProcess structure or NULL -+ * @args: array of arguments -+ * @parent: parent of @args -+ * @len: current length of @args -+ * -+ * Does nothing if @args is null. -+ * Pushes "X" onto @args if @args is non-null but @process is null. -+ * Otherwise: extracts the pid from @process, creates a hexadecimal string -+ * form of it, pushes a copy onto the array @args, then frees the original. -+ */ -+ -+void store_pid(JobProcess *proc, char ***args, const void *parent, size_t *len) -+{ -+ char *pidstr; -+ if (! *args) return; -+ pidstr = (proc ? nih_sprintf(NULL, "%x", proc->pid) : "X"); -+ -+ if (! pidstr) { -+ nih_error("Unable to allocate storage to save process id"); -+ *args = NULL; -+ return; -+ } -+ if (! nih_str_array_add(args, parent, len, pidstr)) { -+ nih_error("Unable to add process id to argument list"); -+ *args = NULL; -+ } -+ -+ if (proc) nih_free(pidstr); -+} -+ -+/** -+ * unpack_pid: -+ * @pidstr: hexadecimal string created by pack_pid -+ * @err: pointer to flag to set if error occurs -+ * -+ * Returns the process id corresponding to the string passed in pidstr. -+ * If an error occurs, returns 0 and sets the flag pointed to by @err. -+ **/ -+ -+pid_t unpack_pid(char *pidstr, int *err) { -+ pid_t result = 0; -+ while (*pidstr) { -+ unsigned char c = *pidstr++; -+ result <<= 4; -+ if (c >= '0' && c <= '9') result += (c-'0'); -+ else if (c >= 'a' && c <= 'f') result += 10 + (c-'a'); -+ else { -+ *err = 1; -+ return 0; -+ } -+ } -+ return result; -+} -+ -+/** -+ * retrieve_pid: -+ * @arg: pointer to array of arguments from which to read pid string -+ * @jobname: name of job whose pids are being retrieved -+ * @err: pointer to flag to set if error occurs -+ * @pid: pointer to location to hold the retrieved process id -+ * @present: pointer to a location to hold 1 if the process id was present -+ * -+ * Reads a process id or no-process-present indicator from the hexadecimal -+ * string pointed to by @arg, increments @arg to point to the next string in -+ * the array unless it already points to a null string, and stores into -+ * @present a value of 0 or 1 indicating whether or not a process id is -+ * present, and stores into @pid the unpacked process id (or zero if there -+ * is no process present or an error occurred). If an error occured, sets -+ * the flag pointed to by @err and printes an error message. -+ **/ -+ -+void retrieve_pid(char ***arg, char *jobname, int *err, -+ pid_t *pid, int *present) -+{ -+ *pid = 0; -+ *present = 0; -+ char *str; -+ if (! arg || ! *arg || ! **arg) { -+ nih_error("Ran out of arguments when restoring job %s", -+ jobname); -+ *err = 1; -+ return; -+ } -+ str = **arg; -+ if (str) ++(*arg); -+ if (strcmp(str, "X")==0) return; -+ *present = 1; -+ *pid = unpack_pid(str, err); -+ if (*err) nih_error("Cannot parse pid %s for job %s", str, jobname); -+} -+ -+/** -+ * restore_pid: -+ * @proc: pointer to a JobProcess structure, or NULL -+ * @pid: process id -+ * @present: integer which is 1 if process id is applicable -+ * @jobname: name of job whose process ids are being restored -+ * -+ * Checks that the non-null status of @proc matches the true/false -+ * status of @present. If there is a mismatch, prints an error message. -+ * If @present is true and @proc is non-null, stores the process id from -+ * @pid into the JobProcess structure pointed to by @proc. -+ */ -+ -+void restore_pid(JobProcess *proc, pid_t pid, int present, char *jobname) -+{ -+ if (proc == NULL && ! present) return; -+ if (proc != NULL && present) { -+ proc->pid = pid; -+ return; -+ } -+ nih_error("Unable to restore process id for job %s", jobname); -+} -+ -+/** -+ * save_current_configuration: -+ * @args: array of arguments to pass to new init -+ * @parent: parent of @args -+ * @len: current length of @args -+ * -+ * Pushes, onto the array @args, information about currently running -+ * jobs. Each job consists of seven arguments: -+ * (1) The job name -+ * (2) A 3-character state/goal string: -+ * First character for the goal: 0=goal JOB_STOP, 1=goal JOB_START -+ * Second character for the current state: -+ * W=JOB_WAITING, -+ * S=JOB_STARTING, A=JOB_PRE_START, B=JOB_SPAWNED, C=JOB_POST_START, -+ * R=JOB_RUNNING, -+ * T=JOB_STOPPING, X=JOB_PRE_STOP, Y=JOB_KILLED, Z=JOB_POST_STOP -+ * Third character: N=normal job, I=instance job -+ * (3) The associated PROCESS_MAIN process id -+ * (4) The associated PROCESS_PRE_START process id -+ * (5) The associated PROCESS_POST_START process id -+ * (6) The associated PROCESS_PRE_STOP process id -+ * (7) The associated PROCESS_POST_STOP process id -+ * Process ids are in hexadecimal using lower-case letters (0-9,a-f), -+ * or 0 if there is a JobProcess structure but no running process, or -+ * "X" if there is no JobProcess structure. -+ * -+ */ -+ -+void save_current_configuration(char ***args, const void *parent, size_t *len) -+{ -+ NIH_HASH_FOREACH(jobs, iter) { -+ Job *job = (Job *) iter; -+ char goal_state[4]; -+ JobProcess **pids; -+ -+ -+ if (job->replacement_for != NULL) continue; -+ if (job->state == JOB_DELETED) continue; -+ if (job->instance && ! job->instance_of) continue; -+ -+ if (! nih_str_array_add(args, parent, len, job->name)) -+ return; -+ -+ if (job->goal == JOB_START) goal_state[0] = '1'; -+ else goal_state[0] = '0'; -+ -+ switch (job->state) -+ { -+ case JOB_WAITING: goal_state[1] = 'W'; break; -+ case JOB_STARTING: goal_state[1] = 'S'; break; -+ case JOB_PRE_START: goal_state[1] = 'A'; break; -+ case JOB_SPAWNED: goal_state[1] = 'B'; break; -+ case JOB_POST_START: goal_state[1] = 'C'; break; -+ case JOB_RUNNING: goal_state[1] = 'R'; break; -+ case JOB_STOPPING: goal_state[1] = 'T'; break; -+ case JOB_PRE_STOP: goal_state[1] = 'X'; break; -+ case JOB_KILLED: goal_state[1] = 'Y'; break; -+ case JOB_POST_STOP: goal_state[1] = 'Z'; break; -+ default: goal_state[1] = '?'; -+ } -+ if (job->instance_of) goal_state[2] = 'I'; -+ else goal_state[2] = 'N'; -+ goal_state[3] = 0; -+ -+ if (! nih_str_array_add(args, parent, len, goal_state)) -+ return; -+ -+ pids = job->process; -+ store_pid(pids[PROCESS_MAIN], args, parent, len); -+ store_pid(pids[PROCESS_PRE_START], args, parent, len); -+ store_pid(pids[PROCESS_POST_START], args, parent, len); -+ store_pid(pids[PROCESS_PRE_STOP], args, parent, len); -+ store_pid(pids[PROCESS_POST_STOP], args, parent, len); -+ } -+} -+ -+/** -+ * restore_job_state: -+ * @jobname: name of job whose state we are to restore -+ * @goal_state: the goal/state string generated by save_current_configuration -+ * @pids: array of five process ids -+ * @presents: array of five integers indicating which process ids are applicable -+ */ -+ -+void restore_job_state (char *jobname, char *goal_state, -+ pid_t *pids, int *presents) -+{ -+ Job *job; -+ JobGoal goal = JOB_STOP; -+ JobState state = JOB_WAITING; -+ int is_instance = 0; -+ int is_invalid = 0; -+ JobProcess **procs; -+ -+ if (jobname == NULL) { -+ nih_error("Missing name for restored job"); -+ return; -+ } -+ -+ if (goal_state == NULL) { -+ nih_error("Missing goal/state for restored job %s", jobname); -+ return; -+ } -+ -+ if (strlen(goal_state) != 3) { -+ nih_error("Invalid length goal/state %s for restored job %s", -+ goal_state, jobname); -+ return; -+ } -+ -+ switch (goal_state[0]) -+ { -+ case '0': goal = JOB_STOP; break; -+ case '1': goal = JOB_START; break; -+ default: is_invalid = 1; break; -+ } -+ -+ switch (goal_state[1]) -+ { -+ case 'W': state = JOB_WAITING; break; -+ case 'S': state = JOB_STARTING; break; -+ case 'A': state = JOB_PRE_START; break; -+ case 'B': state = JOB_SPAWNED; break; -+ case 'C': state = JOB_POST_START; break; -+ case 'R': state = JOB_RUNNING; break; -+ case 'T': state = JOB_STOPPING; break; -+ case 'X': state = JOB_PRE_STOP; break; -+ case 'Y': state = JOB_KILLED; break; -+ case 'Z': state = JOB_POST_STOP; break; -+ default: is_invalid = 1; -+ } -+ -+ switch (goal_state[2]) -+ { -+ case 'N': break; -+ case 'I': is_instance = 1; break; -+ default: is_invalid = 1; -+ } -+ -+ if (is_invalid) { -+ nih_error("Invalid goal/state %s for restored job %s", -+ goal_state, jobname); -+ return; -+ } -+ job = job_find_by_name(jobname); -+ if (! job) { -+ nih_error("Unknown job %s passed to re-exec", jobname); -+ return; -+ } -+ if (is_instance) { -+ if (! job->instance) { -+ nih_error("Can not restore job %s as instance job", -+ jobname); -+ return; -+ } -+ job = job_instance(job); -+ } else { -+ if (job->instance) { -+ nih_error("Can not restore job %s as non-instance job", -+ jobname); -+ return; -+ } -+ } -+ job->goal = goal; -+ job->state = state; -+ procs=job->process; -+ restore_pid(procs[PROCESS_MAIN], pids[0], presents[0], jobname); -+ restore_pid(procs[PROCESS_PRE_START], pids[1], presents[1], jobname); -+ restore_pid(procs[PROCESS_POST_START], pids[2], presents[2], jobname); -+ restore_pid(procs[PROCESS_PRE_STOP], pids[3], presents[3], jobname); -+ restore_pid(procs[PROCESS_POST_STOP], pids[4], presents[4], jobname); -+} -+ -+/** -+ * restore_current_configuration: -+ * @args: non-option arguments that were passed to the new init -+ */ -+ -+void restore_configuration(char **args) -+{ -+ if (! args) return; -+ -+ char **arg = args; -+ while (arg && *arg) { -+ char *jobname = *(arg++); -+ char *goal_state = *arg; -+ pid_t pids[5]; -+ int presents[5]; -+ int is_invalid = 0; -+ -+ if (*arg) ++arg; -+ for (int i = 0; i < 5; i++) -+ retrieve_pid(&arg, jobname, &is_invalid, -+ &pids[i], &presents[i]); -+ -+ if (! is_invalid) -+ restore_job_state (jobname, goal_state, pids, presents); -+ } -+} -diff -uNr upstart-0.3.9.orig/init/restore.h upstart-0.3.9/init/restore.h ---- upstart-0.3.9.orig/init/restore.h 1969-12-31 19:00:00.000000000 -0500 -+++ upstart-0.3.9/init/restore.h 2009-01-23 13:44:54.000000000 -0500 -@@ -0,0 +1,13 @@ -+#ifndef INIT_RESTORE_H -+#define INIT_RESTORE_H -+ -+#include -+ -+NIH_BEGIN_EXTERN -+ -+void save_current_configuration(char ***args, const void *parent, size_t *len); -+void restore_configuration(char **args); -+ -+NIH_END_EXTERN -+ -+#endif /* INIT_RESTORE_H */ diff --git a/upstart.spec b/upstart.spec index 6165e05..bcc1930 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,27 +1,20 @@ Name: upstart -Version: 0.6.3 -Release: 7%{?dist} +Version: 0.6.5 +Release: 1%{?dist} Summary: An event-driven init system Group: System Environment/Base License: GPLv2 and LGPLv2+ URL: http://upstart.ubuntu.com -Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.bz2 +Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf -# remove tests which fail in koji -Patch0: upstart-remove-tests.patch -Patch1: upstart-telinit.patch -Patch2: upstart-audit-events.patch -# pulled from https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/436758 -# sparc specific allignment errors -Patch3: upstart-nih-alloc.patch -# SIGUSR1 handler - connect to system dbus -Patch4: upstart-usr1-handler.patch +Patch1: upstart-telinit.patch +Patch2: upstart-audit-events.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 BuildRequires: gettext, audit-libs-devel, expat-devel -BuildRequires: dbus-devel >= 1:1.2.16 +BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel %description Upstart is an event-based replacement for the /sbin/init daemon which @@ -30,11 +23,8 @@ during shutdown and supervising them while the system is running. %prep %setup -q -%patch0 -p1 -b .tests %patch1 -p1 -b .u %patch2 -p1 -b .audit -%patch3 -p1 -b .alignment -%patch4 -p1 -b .usr1 %build %configure --sbindir=/sbin --libdir=/%{_lib} @@ -44,16 +34,6 @@ make %{?_smp_mflags} rm -rf %{buildroot} make install DESTDIR=%{buildroot} -# libupstart and libnih aren't shipped -rm -f %{buildroot}/%{_lib}/libupstart.* -rm -f %{buildroot}/%{_lib}/libnih.* -rm -f %{buildroot}/%{_includedir}/libnih.h -rm -f %{buildroot}/%{_includedir}/libupstart.h -rm -rf %{buildroot}/%{_includedir}/nih -rm -rf %{buildroot}/%{_includedir}/upstart -rm -rf %{buildroot}/%{_datadir}/aclocal/compiler.m4 -rm -rf %{buildroot}/%{_datadir}/aclocal/linker.m4 -rm -rf %{buildroot}/%{_datadir}/aclocal/misc.m4 # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ @@ -88,6 +68,7 @@ rm -rf %{buildroot} /sbin/stop /sbin/restart /sbin/telinit +/sbin/reload %{_mandir}/man5/init.5.gz %{_mandir}/man5/inittab.5.gz %{_mandir}/man7/control-alt-delete.7.gz @@ -112,8 +93,12 @@ rm -rf %{buildroot} %{_mandir}/man8/status.8.gz %{_mandir}/man8/stop.8.gz %{_mandir}/man8/telinit.8.gz +%{_mandir}/man8/reload.8.gz %changelog +* Wed Feb 17 2010 Petr Lautrbach 0.6.5-1 +- upgrade to 0.6.5 + * Fri Jan 29 2010 Petr Lautrbach 0.6.3-7 - add SIGUSR1 handler and init-system-dbus.conf (#559660) From 6eb4550aff9d6e2c0b3ce36126043fbec23e83f5 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Fri, 19 Feb 2010 21:03:26 +0000 Subject: [PATCH 04/61] New source to go along with 0.6.5 spec --- .cvsignore | 2 +- sources | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.cvsignore b/.cvsignore index 6c5c773..6c1b28b 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -upstart-0.6.3.tar.bz2 +upstart-0.6.5.tar.gz diff --git a/sources b/sources index dfeb0a7..46ac626 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -ef9d2704426423f75d1e0c309ecfceb4 upstart-0.6.3.tar.bz2 +f9466bba72b655c2408353b64105853f upstart-0.6.5.tar.gz From 95bf015b0ddca0cc4aa67fdb733140ee3bdf9606 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Fri, 19 Feb 2010 21:04:58 +0000 Subject: [PATCH 05/61] more specificity about which libnih we want --- upstart.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/upstart.spec b/upstart.spec index bcc1930..1634024 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 1%{?dist} +Release: 2%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -14,7 +14,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 BuildRequires: gettext, audit-libs-devel, expat-devel -BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel +BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 %description Upstart is an event-based replacement for the /sbin/init daemon which @@ -96,6 +96,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Fri Feb 19 2010 Casey Dahlin 0.6.5-2 +- be more specific about which libnih we need. + * Wed Feb 17 2010 Petr Lautrbach 0.6.5-1 - upgrade to 0.6.5 From 27df622c49f4270f8eda4f6f35e28fe26c3bee4d Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 23 Feb 2010 08:36:43 +0000 Subject: [PATCH 06/61] already included in upstream source --- upstart-usr1-handler.patch | 55 -------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 upstart-usr1-handler.patch diff --git a/upstart-usr1-handler.patch b/upstart-usr1-handler.patch deleted file mode 100644 index 8657c7e..0000000 --- a/upstart-usr1-handler.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff --git a/init/main.c b/init/main.c -index 2836583..0fb6a64 100644 ---- a/init/main.c -+++ b/init/main.c -@@ -66,6 +66,7 @@ static void cad_handler (void *data, NihSignal *signal); - static void kbd_handler (void *data, NihSignal *signal); - static void pwr_handler (void *data, NihSignal *signal); - static void hup_handler (void *data, NihSignal *signal); -+static void usr1_handler (void *data, NihSignal *signal); - #endif /* DEBUG */ - - -@@ -234,6 +235,10 @@ main (int argc, - /* SIGHUP instructs us to re-load our configuration */ - nih_signal_set_handler (SIGHUP, nih_signal_handler); - NIH_MUST (nih_signal_add_handler (NULL, SIGHUP, hup_handler, NULL)); -+ -+ /* SIGHUSR1 instructs us to reconnect to system bus */ -+ nih_signal_set_handler (SIGUSR1, nih_signal_handler); -+ NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); - #endif /* DEBUG */ - - -@@ -465,4 +470,31 @@ hup_handler (void *data, - } - } - } -+ -+/** -+ * usr1_handler: -+ * @data: unused, -+ * @signal: signal that called this handler. -+ * -+ * Handle having recieved the SIGHUSR1 signal, which we use to instruct us to -+ * connect to system bus. -+ **/ -+static void -+usr1_handler (void *data, -+ NihSignal *signal) -+{ -+ -+ if (! control_bus) { -+ nih_info (_("Connecting to system bus")); -+ -+ if (control_bus_open () < 0) { -+ NihError *err; -+ -+ err = nih_error_get (); -+ nih_warn ("%s: %s", _("Unable to connect to the system bus"), -+ err->message); -+ nih_free (err); -+ } -+ } -+} - #endif /* DEBUG */ From 59d2e48f65419e3c90a04ef0292243281f7de5ac Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 24 Feb 2010 13:11:34 +0000 Subject: [PATCH 07/61] run make check only with --with check to avoid test fails in koji --- upstart.spec | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/upstart.spec b/upstart.spec index 1634024..0c5dbf2 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 2%{?dist} +Release: 3%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -41,7 +41,11 @@ install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ %find_lang %{name} %check -make check +#some tests fail in koji while pass in mock and local build +#to run make check use "--with check" +%if %{?_with_check:1}%{!?_with_check:0} + make check +%endif %clean rm -rf %{buildroot} @@ -96,6 +100,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Wed Feb 24 2010 Petr Lautrbach 0.6.5-3 +- run "make check" only with --with check + * Fri Feb 19 2010 Casey Dahlin 0.6.5-2 - be more specific about which libnih we need. From 938443e9cab0a4894f2e7f298aaa5ef8bb536b16 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Fri, 26 Feb 2010 13:11:17 +0000 Subject: [PATCH 08/61] sync with devel branch to upstart-0.6.5-3 --- .cvsignore | 4 +- init-system-dbus.conf | 6 + sources | 3 +- upstart-audit-events.patch | 783 +++++++++++++++++++++++-- upstart-nih-alloc.patch | 63 -- upstart-save-state-across-reexec.patch | 429 -------------- upstart-usr1-handler.patch | 55 -- upstart.spec | 49 +- 8 files changed, 768 insertions(+), 624 deletions(-) create mode 100644 init-system-dbus.conf delete mode 100644 upstart-nih-alloc.patch delete mode 100644 upstart-save-state-across-reexec.patch delete mode 100644 upstart-usr1-handler.patch diff --git a/.cvsignore b/.cvsignore index f21fdee..6c1b28b 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,3 +1 @@ -upstart-0.6.3.tar.bz2 -upstart-remove-tests.patch -init-system-dbus.conf +upstart-0.6.5.tar.gz diff --git a/init-system-dbus.conf b/init-system-dbus.conf new file mode 100644 index 0000000..0fc6a8a --- /dev/null +++ b/init-system-dbus.conf @@ -0,0 +1,6 @@ +# init-system-dbus - tell init process to connect to system dbus server + +start on started messagebus + +task +exec /bin/kill -USR1 1 diff --git a/sources b/sources index d83faa8..46ac626 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -ef9d2704426423f75d1e0c309ecfceb4 upstart-0.6.3.tar.bz2 -bf835fea1be622a5d68f168bd63f91e5 init-system-dbus.conf +f9466bba72b655c2408353b64105853f upstart-0.6.5.tar.gz diff --git a/upstart-audit-events.patch b/upstart-audit-events.patch index f728d66..07df654 100644 --- a/upstart-audit-events.patch +++ b/upstart-audit-events.patch @@ -1,63 +1,753 @@ -diff --git a/util/Makefile.in b/util/Makefile.in -index 26025ce..f7b61a3 100644 ---- a/util/Makefile.in -+++ b/util/Makefile.in -@@ -376,6 +376,7 @@ reboot_SOURCES = \ - reboot_LDFLAGS = -static +diff --git a/Makefile.in b/Makefile.in +index a9550df..bdd0def 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -49,17 +49,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ +@@ -132,6 +133,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/aclocal.m4 b/aclocal.m4 +index 3d3673e..6e09291 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -1066,6 +1066,7 @@ m4_include([m4/lcmessage.m4]) + m4_include([m4/lib-ld.m4]) + m4_include([m4/lib-link.m4]) + m4_include([m4/lib-prefix.m4]) ++m4_include([m4/libaudit.m4]) + m4_include([m4/libnih.m4]) + m4_include([m4/libtool.m4]) + m4_include([m4/lock.m4]) +diff --git a/conf/Makefile.in b/conf/Makefile.in +index 29fd9b7..82c3f99 100644 +--- a/conf/Makefile.in ++++ b/conf/Makefile.in +@@ -46,17 +46,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -100,6 +101,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/config.h.in b/config.h.in +index 8a7d63f..8d000aa 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -118,6 +118,9 @@ + /* Define if your file defines LC_MESSAGES. */ + #undef HAVE_LC_MESSAGES + ++/* linux audit support */ ++#undef HAVE_LIBAUDIT ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_LIMITS_H + +diff --git a/configure b/configure +index 9bad2db..2f93ef5 100755 +--- a/configure ++++ b/configure +@@ -751,6 +751,7 @@ ac_subst_vars='am__EXEEXT_FALSE + am__EXEEXT_TRUE + LTLIBOBJS + LIBOBJS ++AUDIT_LDADD + DBUS_LIBS + DBUS_CFLAGS + NIH_DBUS_LIBS +@@ -938,6 +939,7 @@ with_included_gettext + with_libintl_prefix + with_local_libnih + enable_threading ++with_libaudit + enable_compiler_warnings + enable_compiler_optimisations + enable_compiler_coverage +@@ -1620,6 +1622,7 @@ Optional Packages: + --without-libintl-prefix don't search for libintl in includedir and libdir + --with-local-libnih[=DIR] + Use libnih from source tree DIR ++ --with-libaudit=auto/yes/no Add Linux audit support default=auto + + Some influential environment variables: + CC C compiler command +@@ -5220,13 +5223,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : + else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext +- (eval echo "\"\$as_me:5223: $ac_compile\"" >&5) ++ (eval echo "\"\$as_me:5226: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 +- (eval echo "\"\$as_me:5226: $NM \\\"conftest.$ac_objext\\\"\"" >&5) ++ (eval echo "\"\$as_me:5229: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 +- (eval echo "\"\$as_me:5229: output\"" >&5) ++ (eval echo "\"\$as_me:5232: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" +@@ -6431,7 +6434,7 @@ ia64-*-hpux*) + ;; + *-*-irix6*) + # Find out which ABI we are using. +- echo '#line 6434 "configure"' > conftest.$ac_ext ++ echo '#line 6437 "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? +@@ -7693,11 +7696,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:7696: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:7699: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 +- echo "$as_me:7700: \$? = $ac_status" >&5 ++ echo "$as_me:7703: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. +@@ -8032,11 +8035,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:8035: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:8038: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 +- echo "$as_me:8039: \$? = $ac_status" >&5 ++ echo "$as_me:8042: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. +@@ -8137,11 +8140,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:8140: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:8143: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 +- echo "$as_me:8144: \$? = $ac_status" >&5 ++ echo "$as_me:8147: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized +@@ -8192,11 +8195,11 @@ else + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` +- (eval echo "\"\$as_me:8195: $lt_compile\"" >&5) ++ (eval echo "\"\$as_me:8198: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 +- echo "$as_me:8199: \$? = $ac_status" >&5 ++ echo "$as_me:8202: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized +@@ -10576,7 +10579,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 10579 "configure" ++#line 10582 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -10672,7 +10675,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 10675 "configure" ++#line 10678 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -17209,6 +17212,72 @@ fi + + # Checks for library functions. + ++ ++# Check whether --with-libaudit was given. ++if test "${with_libaudit+set}" = set; then : ++ withval=$with_libaudit; ++else ++ with_libaudit=auto ++fi ++ ++ ++ # Check for Linux auditing API ++ # ++ # libaudit detection ++ ++ if test x$with_libaudit = xno ; then ++ have_libaudit=no; ++ else ++ # See if we have audit daemon library ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for audit_log_user_message in -laudit" >&5 ++$as_echo_n "checking for audit_log_user_message in -laudit... " >&6; } ++if test "${ac_cv_lib_audit_audit_log_user_message+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-laudit $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char audit_log_user_message (); ++int ++main () ++{ ++return audit_log_user_message (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_audit_audit_log_user_message=yes ++else ++ ac_cv_lib_audit_audit_log_user_message=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_audit_audit_log_user_message" >&5 ++$as_echo "$ac_cv_lib_audit_audit_log_user_message" >&6; } ++if test "x$ac_cv_lib_audit_audit_log_user_message" = x""yes; then : ++ AUDIT_LDADD=-laudit ++fi ++ ++ fi ++ ++ if test x$AUDIT_LDADD != x ; then ++ ++$as_echo "#define HAVE_LIBAUDIT 1" >>confdefs.h ++ ++ fi ++ ++ + # Other checks + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include sbindir in PATH" >&5 + $as_echo_n "checking whether to include sbindir in PATH... " >&6; } +diff --git a/configure.ac b/configure.ac +index fb79a13..3dc1550 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -54,6 +54,7 @@ AM_PROG_CC_C_O + NIH_C_THREAD + + # Checks for library functions. ++LINUX_AUDIT + + # Other checks + AC_MSG_CHECKING([whether to include sbindir in PATH]) +diff --git a/contrib/Makefile.in b/contrib/Makefile.in +index dfe910b..32c7ebd 100644 +--- a/contrib/Makefile.in ++++ b/contrib/Makefile.in +@@ -44,17 +44,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -75,6 +76,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/dbus/Makefile.in b/dbus/Makefile.in +index 8294845..38a55ad 100644 +--- a/dbus/Makefile.in ++++ b/dbus/Makefile.in +@@ -46,17 +46,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -100,6 +101,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/doc/Makefile.in b/doc/Makefile.in +index b17181c..add3022 100644 +--- a/doc/Makefile.in ++++ b/doc/Makefile.in +@@ -44,17 +44,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -75,6 +76,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/init/Makefile.in b/init/Makefile.in +index c677761..9ca3de6 100644 +--- a/init/Makefile.in ++++ b/init/Makefile.in +@@ -55,17 +55,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -283,6 +284,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +diff --git a/m4/libaudit.m4 b/m4/libaudit.m4 +new file mode 100644 +index 0000000..6865fb8 +--- /dev/null ++++ b/m4/libaudit.m4 +@@ -0,0 +1,25 @@ ++# libaudit.m4 - Checks for the Linux Audit System support ++# Copyright (c) 2009 Steve Grubb sgrubb@redhat.com ++# ++AC_DEFUN([LINUX_AUDIT], ++[ ++ AC_ARG_WITH(libaudit, ++ [ --with-libaudit=[auto/yes/no] Add Linux audit support [default=auto]],, ++ with_libaudit=auto) ++ ++ # Check for Linux auditing API ++ # ++ # libaudit detection ++ ++ if test x$with_libaudit = xno ; then ++ have_libaudit=no; ++ else ++ # See if we have audit daemon library ++ AC_CHECK_LIB(audit, audit_log_user_message, ++ AUDIT_LDADD=-laudit,) ++ fi ++ AC_SUBST(AUDIT_LDADD) ++ if test x$AUDIT_LDADD != x ; then ++ AC_DEFINE(HAVE_LIBAUDIT,1,[linux audit support]) ++ fi ++]) +diff --git a/util/Makefile.am b/util/Makefile.am +index 0b49c10..9a772d5 100644 +--- a/util/Makefile.am ++++ b/util/Makefile.am +@@ -45,14 +45,17 @@ reboot_SOURCES = \ + utmp.c utmp.h reboot_LDADD = \ - ../nih/libnih.la \ -+ -laudit \ - $(LTLIBINTL) + $(LTLIBINTL) \ +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) ++ runlevel_SOURCES = \ -@@ -399,6 +400,7 @@ shutdown_LDFLAGS = -static - shutdown_LDADD = \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ + runlevel.c \ + utmp.c utmp.h + runlevel_LDADD = \ $(LTLIBINTL) \ - $(DBUS_LIBS) +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) -@@ -414,6 +416,7 @@ telinit_LDFLAGS = -static - telinit_LDADD = \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ + shutdown_SOURCES = \ + shutdown.c \ +@@ -64,7 +67,8 @@ shutdown_LDADD = \ $(LTLIBINTL) \ - $(DBUS_LIBS) + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) -@@ -477,6 +480,7 @@ test_sysv_LDADD = \ - sysv.o utmp.o \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ + telinit_SOURCES = \ + telinit.c \ +@@ -76,7 +80,8 @@ telinit_LDADD = \ $(LTLIBINTL) \ - $(DBUS_LIBS) + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) -@@ -489,6 +493,7 @@ test_telinit_LDADD = \ + + com_ubuntu_Upstart_OUTPUTS = \ +@@ -201,7 +206,8 @@ test_sysv_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + test_telinit_SOURCES = tests/test_telinit.c telinit.c + test_telinit_CFLAGS = $(AM_CFLAGS) -DTEST +@@ -211,7 +217,8 @@ test_telinit_LDADD = \ com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ - ../nih/libnih.la \ - ../nih-dbus/libnih-dbus.la \ -+ -laudit \ - $(DBUS_LIBS) + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + + .PHONY: tests +diff --git a/util/Makefile.in b/util/Makefile.in +index 55e17e5..40776d5 100644 +--- a/util/Makefile.in ++++ b/util/Makefile.in +@@ -51,17 +51,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ +- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ +- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ +- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ +- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ +- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ +- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ +- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ +- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ +- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ +- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ +- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ ++ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ ++ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ ++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ ++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ ++ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ ++ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ ++ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ ++ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ ++ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ ++ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ ++ $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + mkinstalldirs = $(install_sh) -d +@@ -88,20 +89,24 @@ am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) + am__v_lt_0 = --silent + am_reboot_OBJECTS = reboot.$(OBJEXT) utmp.$(OBJEXT) + reboot_OBJECTS = $(am_reboot_OBJECTS) +-reboot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++reboot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_runlevel_OBJECTS = runlevel.$(OBJEXT) utmp.$(OBJEXT) + runlevel_OBJECTS = $(am_runlevel_OBJECTS) +-runlevel_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++runlevel_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_shutdown_OBJECTS = shutdown.$(OBJEXT) utmp.$(OBJEXT) sysv.$(OBJEXT) + nodist_shutdown_OBJECTS = $(am__objects_1) + shutdown_OBJECTS = $(am_shutdown_OBJECTS) $(nodist_shutdown_OBJECTS) + shutdown_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_telinit_OBJECTS = telinit.$(OBJEXT) utmp.$(OBJEXT) sysv.$(OBJEXT) + nodist_telinit_OBJECTS = $(am__objects_1) + telinit_OBJECTS = $(am_telinit_OBJECTS) $(nodist_telinit_OBJECTS) + telinit_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_1) + am_test_initctl_OBJECTS = test_initctl-test_initctl.$(OBJEXT) \ + test_initctl-initctl.$(OBJEXT) + test_initctl_OBJECTS = $(am_test_initctl_OBJECTS) +@@ -118,14 +123,14 @@ test_sysv_OBJECTS = $(am_test_sysv_OBJECTS) \ + $(nodist_test_sysv_OBJECTS) + test_sysv_DEPENDENCIES = sysv.o utmp.o $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + am_test_telinit_OBJECTS = test_telinit-test_telinit.$(OBJEXT) \ + test_telinit-telinit.$(OBJEXT) + test_telinit_OBJECTS = $(am_test_telinit_OBJECTS) + test_telinit_DEPENDENCIES = sysv.o utmp.o com.ubuntu.Upstart.o \ + com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +- $(am__DEPENDENCIES_1) ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + test_telinit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_telinit_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@@ -216,6 +221,7 @@ ALLOCA = @ALLOCA@ + AMTAR = @AMTAR@ + AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ + AR = @AR@ ++AUDIT_LDADD = @AUDIT_LDADD@ + AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ +@@ -419,7 +425,8 @@ reboot_SOURCES = \ + + reboot_LDADD = \ + $(LTLIBINTL) \ +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) + + runlevel_SOURCES = \ + runlevel.c \ +@@ -427,7 +434,8 @@ runlevel_SOURCES = \ + + runlevel_LDADD = \ + $(LTLIBINTL) \ +- $(NIH_LIBS) ++ $(NIH_LIBS) \ ++ $(AUDIT_LDADD) + + shutdown_SOURCES = \ + shutdown.c \ +@@ -441,7 +449,8 @@ shutdown_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + telinit_SOURCES = \ + telinit.c \ +@@ -455,7 +464,8 @@ telinit_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + com_ubuntu_Upstart_OUTPUTS = \ + com.ubuntu.Upstart.c \ +@@ -515,7 +525,8 @@ test_sysv_LDADD = \ + $(LTLIBINTL) \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) + + test_telinit_SOURCES = tests/test_telinit.c telinit.c + test_telinit_CFLAGS = $(AM_CFLAGS) -DTEST +@@ -525,7 +536,8 @@ test_telinit_LDADD = \ + com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ +- $(DBUS_LIBS) ++ $(DBUS_LIBS) \ ++ $(AUDIT_LDADD) all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/util/reboot.c b/util/reboot.c -index dda2935..eef9ed2 100644 +index 7a9c071..15028eb 100644 --- a/util/reboot.c +++ b/util/reboot.c @@ -36,6 +36,10 @@ #include #include -+#if 1 /* HAVE_LIBAUDIT */ ++#ifdef HAVE_LIBAUDIT +#include +#endif + #include "utmp.h" -@@ -96,7 +100,6 @@ static int poweroff = FALSE; +@@ -103,7 +107,6 @@ static int poweroff = FALSE; **/ static int exit_only = FALSE; @@ -65,7 +755,7 @@ index dda2935..eef9ed2 100644 /** * options: * -@@ -119,6 +122,7 @@ static NihOption options[] = { +@@ -127,6 +130,7 @@ static NihOption options[] = { NIH_OPTION_LAST }; @@ -73,7 +763,7 @@ index dda2935..eef9ed2 100644 int main (int argc, -@@ -216,6 +220,8 @@ main (int argc, +@@ -227,6 +231,8 @@ main (int argc, /* Re-enable Control-Alt-Delete in case it breaks */ reboot (RB_ENABLE_CAD); @@ -82,7 +772,7 @@ index dda2935..eef9ed2 100644 /* Do the syscall */ switch (mode) { case REBOOT: -@@ -237,3 +243,21 @@ main (int argc, +@@ -248,3 +254,21 @@ main (int argc, return 0; } @@ -95,7 +785,7 @@ index dda2935..eef9ed2 100644 +static void +send_audit_event (void) +{ -+#if 1 /* HAVE_LIBAUDIT */ ++#ifdef HAVE_LIBAUDIT + int fd = audit_open (); + if (fd < 0) + return; @@ -105,20 +795,23 @@ index dda2935..eef9ed2 100644 +#endif +} diff --git a/util/sysv.c b/util/sysv.c -index fbca39f..32b5540 100644 +index fbca39f..5476f79 100644 --- a/util/sysv.c +++ b/util/sysv.c -@@ -36,6 +36,9 @@ +@@ -36,6 +36,12 @@ #include #include +#include ++#ifdef HAVE_LIBAUDIT ++#include +#include ++#endif + #include "dbus/upstart.h" #include "utmp.h" -@@ -54,6 +57,7 @@ +@@ -54,6 +60,7 @@ /* Prototypes for static functions */ static void error_handler (NihError **err, NihDBusMessage *message); @@ -126,7 +819,7 @@ index fbca39f..32b5540 100644 /** -@@ -161,6 +165,8 @@ sysv_change_runlevel (int runlevel, +@@ -161,6 +168,8 @@ sysv_change_runlevel (int runlevel, runlevel, prevlevel) < 0) nih_free (nih_error_get ()); @@ -135,7 +828,7 @@ index fbca39f..32b5540 100644 /* Make the EmitEvent call, we don't wait for the event to finish * because sysvinit never did. */ -@@ -199,3 +205,41 @@ error_handler (NihError ** err, +@@ -199,3 +208,41 @@ error_handler (NihError ** err, { *err = nih_error_steal (); } @@ -151,7 +844,7 @@ index fbca39f..32b5540 100644 +static void +send_audit_event (int old, int level) +{ -+#if 1 /* HAVE_LIBAUDIT */ ++#ifdef HAVE_LIBAUDIT + int fd = audit_open (); + + if (fd < 0) diff --git a/upstart-nih-alloc.patch b/upstart-nih-alloc.patch deleted file mode 100644 index 208b05f..0000000 --- a/upstart-nih-alloc.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- upstart-0.6.3/nih/alloc.c.orig 2010-01-17 17:28:33.000000000 +0000 -+++ upstart-0.6.3/nih/alloc.c 2010-01-17 17:28:38.000000000 +0000 -@@ -54,6 +54,8 @@ - NihDestructor destructor; - } NihAllocCtx; - -+#define NIH_ALLOC_CTX_SIZE (sizeof(NihAllocCtx) + __alignof__(NihAllocCtx)) -+ - /** - * NihAllocRef: - * @children_entry: list head in parent's children list, -@@ -82,7 +84,7 @@ - * - * Returns: pointer to NihAllocCtx structure. - **/ --#define NIH_ALLOC_CTX(ptr) ((NihAllocCtx *)(ptr) - 1) -+#define NIH_ALLOC_CTX(ptr) ((NihAllocCtx *)((void*)ptr - NIH_ALLOC_CTX_SIZE)) - - /** - * NIH_ALLOC_PTR: -@@ -93,7 +95,7 @@ - * - * Returns: pointer to block of memory. - **/ --#define NIH_ALLOC_PTR(ctx) ((void *)((NihAllocCtx *)(ctx) + 1)) -+#define NIH_ALLOC_PTR(ctx) ((void*)((void*)ctx + NIH_ALLOC_CTX_SIZE)) - - /** - * NIH_ALLOC_FINALISED: -@@ -145,7 +147,7 @@ - { - NihAllocCtx *ctx; - -- ctx = __nih_malloc (sizeof (NihAllocCtx) + size); -+ ctx = __nih_malloc (NIH_ALLOC_CTX_SIZE + size); - if (! ctx) - return NULL; - -@@ -230,7 +232,7 @@ - /* Now do the actual realloc(), if this fails then we can just - * return NULL since we've not actually changed anything. - */ -- ctx = __nih_realloc (ctx, sizeof (NihAllocCtx) + size); -+ ctx = __nih_realloc (ctx, NIH_ALLOC_CTX_SIZE + size); - if (! ctx) - return NULL; - -@@ -562,7 +564,7 @@ - nih_assert (child != NULL); - nih_assert (child->destructor != NIH_ALLOC_FINALISED); - -- ref = NIH_MUST (malloc (sizeof (NihAllocRef))); -+ ref = NIH_MUST (malloc (NIH_ALLOC_CTX_SIZE)); - - nih_list_init (&ref->children_entry); - nih_list_init (&ref->parents_entry); -@@ -739,5 +741,5 @@ - ctx = NIH_ALLOC_CTX (ptr); - nih_assert (ctx->destructor != NIH_ALLOC_FINALISED); - -- return malloc_usable_size (ctx) - sizeof (NihAllocCtx); -+ return malloc_usable_size (ctx) - NIH_ALLOC_CTX_SIZE; - } diff --git a/upstart-save-state-across-reexec.patch b/upstart-save-state-across-reexec.patch deleted file mode 100644 index 68001d1..0000000 --- a/upstart-save-state-across-reexec.patch +++ /dev/null @@ -1,429 +0,0 @@ -diff -uNr upstart-0.3.9.orig/init/main.c upstart-0.3.9/init/main.c ---- upstart-0.3.9.orig/init/main.c 2009-01-23 13:44:32.000000000 -0500 -+++ upstart-0.3.9/init/main.c 2009-01-23 13:44:54.000000000 -0500 -@@ -59,6 +59,7 @@ - #include "cfgfile.h" - #include "paths.h" - #include "tty.h" -+#include "restore.h" - - - /* Prototypes for static functions */ -@@ -278,6 +279,10 @@ - exit (1); - } - -+ /* Restore the state of previously active jobs, if re-exec'd by -+ * a previously running init. */ -+ -+ if (restart) restore_configuration(args); - - /* Generate and run the startup event or read the state from the - * init daemon that exec'd us -@@ -534,6 +539,8 @@ - NihError *err; - const char *loglevel; - sigset_t mask, oldmask; -+ char **args; -+ size_t len; - - nih_assert (argv0 != NULL); - nih_assert (signal != NULL); -@@ -559,7 +566,20 @@ - } else { - loglevel = NULL; - } -- execl (argv0, argv0, "--restart", loglevel, NULL); -+ args = nih_str_array_new(NULL); -+ len = 0; -+ if (args) args = nih_str_array_add(&args, NULL, &len, argv0); -+ if (args) args = nih_str_array_add(&args, NULL, &len, "--restart"); -+ if (args && loglevel) -+ args = nih_str_array_add(&args, NULL, &len, loglevel); -+ if (args) save_current_configuration(&args, NULL, &len); -+ if (args) { -+ execv (argv0, args); -+ nih_free(args); -+ } else { -+ nih_warn (_("Unable to save list of currently running jobs")); -+ execl(argv0, argv0, "--restart", loglevel, NULL); -+ } - nih_error_raise_system (); - - err = nih_error_get (); -diff -uNr upstart-0.3.9.orig/init/Makefile.in upstart-0.3.9/init/Makefile.in ---- upstart-0.3.9.orig/init/Makefile.in 2009-01-23 13:44:32.000000000 -0500 -+++ upstart-0.3.9/init/Makefile.in 2009-01-23 13:44:54.000000000 -0500 -@@ -72,7 +72,7 @@ - PROGRAMS = $(sbin_PROGRAMS) - am_init_OBJECTS = main.$(OBJEXT) tty.$(OBJEXT) process.$(OBJEXT) \ - job.$(OBJEXT) event.$(OBJEXT) control.$(OBJEXT) \ -- notify.$(OBJEXT) cfgfile.$(OBJEXT) -+ notify.$(OBJEXT) cfgfile.$(OBJEXT) restore.$(OBJEXT) - init_OBJECTS = $(am_init_OBJECTS) - am__DEPENDENCIES_1 = - init_DEPENDENCIES = ../upstart/libupstart.la ../nih/libnih.la \ -@@ -315,7 +315,8 @@ - event.c event.h \ - control.c control.h \ - notify.c notify.h \ -- cfgfile.c cfgfile.h -+ cfgfile.c cfgfile.h \ -+ restore.c restore.h - - init_LDFLAGS = -static - init_LDADD = \ -diff -uNr upstart-0.3.9.orig/init/restore.c upstart-0.3.9/init/restore.c ---- upstart-0.3.9.orig/init/restore.c 1969-12-31 19:00:00.000000000 -0500 -+++ upstart-0.3.9/init/restore.c 2009-01-23 13:44:54.000000000 -0500 -@@ -0,0 +1,333 @@ -+/* Modifications to upstart to allow passing of the state of currently -+ * running jobs when upstart re-execs itself. -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif /* HAVE_CONFIG_H */ -+ -+ -+#include -+#include -+#include -+#include -+#include -+#include "job.h" -+#include "restore.h" -+ -+ -+/** -+ * store_pid: -+ * @proc: pointer to a JobProcess structure or NULL -+ * @args: array of arguments -+ * @parent: parent of @args -+ * @len: current length of @args -+ * -+ * Does nothing if @args is null. -+ * Pushes "X" onto @args if @args is non-null but @process is null. -+ * Otherwise: extracts the pid from @process, creates a hexadecimal string -+ * form of it, pushes a copy onto the array @args, then frees the original. -+ */ -+ -+void store_pid(JobProcess *proc, char ***args, const void *parent, size_t *len) -+{ -+ char *pidstr; -+ if (! *args) return; -+ pidstr = (proc ? nih_sprintf(NULL, "%x", proc->pid) : "X"); -+ -+ if (! pidstr) { -+ nih_error("Unable to allocate storage to save process id"); -+ *args = NULL; -+ return; -+ } -+ if (! nih_str_array_add(args, parent, len, pidstr)) { -+ nih_error("Unable to add process id to argument list"); -+ *args = NULL; -+ } -+ -+ if (proc) nih_free(pidstr); -+} -+ -+/** -+ * unpack_pid: -+ * @pidstr: hexadecimal string created by pack_pid -+ * @err: pointer to flag to set if error occurs -+ * -+ * Returns the process id corresponding to the string passed in pidstr. -+ * If an error occurs, returns 0 and sets the flag pointed to by @err. -+ **/ -+ -+pid_t unpack_pid(char *pidstr, int *err) { -+ pid_t result = 0; -+ while (*pidstr) { -+ unsigned char c = *pidstr++; -+ result <<= 4; -+ if (c >= '0' && c <= '9') result += (c-'0'); -+ else if (c >= 'a' && c <= 'f') result += 10 + (c-'a'); -+ else { -+ *err = 1; -+ return 0; -+ } -+ } -+ return result; -+} -+ -+/** -+ * retrieve_pid: -+ * @arg: pointer to array of arguments from which to read pid string -+ * @jobname: name of job whose pids are being retrieved -+ * @err: pointer to flag to set if error occurs -+ * @pid: pointer to location to hold the retrieved process id -+ * @present: pointer to a location to hold 1 if the process id was present -+ * -+ * Reads a process id or no-process-present indicator from the hexadecimal -+ * string pointed to by @arg, increments @arg to point to the next string in -+ * the array unless it already points to a null string, and stores into -+ * @present a value of 0 or 1 indicating whether or not a process id is -+ * present, and stores into @pid the unpacked process id (or zero if there -+ * is no process present or an error occurred). If an error occured, sets -+ * the flag pointed to by @err and printes an error message. -+ **/ -+ -+void retrieve_pid(char ***arg, char *jobname, int *err, -+ pid_t *pid, int *present) -+{ -+ *pid = 0; -+ *present = 0; -+ char *str; -+ if (! arg || ! *arg || ! **arg) { -+ nih_error("Ran out of arguments when restoring job %s", -+ jobname); -+ *err = 1; -+ return; -+ } -+ str = **arg; -+ if (str) ++(*arg); -+ if (strcmp(str, "X")==0) return; -+ *present = 1; -+ *pid = unpack_pid(str, err); -+ if (*err) nih_error("Cannot parse pid %s for job %s", str, jobname); -+} -+ -+/** -+ * restore_pid: -+ * @proc: pointer to a JobProcess structure, or NULL -+ * @pid: process id -+ * @present: integer which is 1 if process id is applicable -+ * @jobname: name of job whose process ids are being restored -+ * -+ * Checks that the non-null status of @proc matches the true/false -+ * status of @present. If there is a mismatch, prints an error message. -+ * If @present is true and @proc is non-null, stores the process id from -+ * @pid into the JobProcess structure pointed to by @proc. -+ */ -+ -+void restore_pid(JobProcess *proc, pid_t pid, int present, char *jobname) -+{ -+ if (proc == NULL && ! present) return; -+ if (proc != NULL && present) { -+ proc->pid = pid; -+ return; -+ } -+ nih_error("Unable to restore process id for job %s", jobname); -+} -+ -+/** -+ * save_current_configuration: -+ * @args: array of arguments to pass to new init -+ * @parent: parent of @args -+ * @len: current length of @args -+ * -+ * Pushes, onto the array @args, information about currently running -+ * jobs. Each job consists of seven arguments: -+ * (1) The job name -+ * (2) A 3-character state/goal string: -+ * First character for the goal: 0=goal JOB_STOP, 1=goal JOB_START -+ * Second character for the current state: -+ * W=JOB_WAITING, -+ * S=JOB_STARTING, A=JOB_PRE_START, B=JOB_SPAWNED, C=JOB_POST_START, -+ * R=JOB_RUNNING, -+ * T=JOB_STOPPING, X=JOB_PRE_STOP, Y=JOB_KILLED, Z=JOB_POST_STOP -+ * Third character: N=normal job, I=instance job -+ * (3) The associated PROCESS_MAIN process id -+ * (4) The associated PROCESS_PRE_START process id -+ * (5) The associated PROCESS_POST_START process id -+ * (6) The associated PROCESS_PRE_STOP process id -+ * (7) The associated PROCESS_POST_STOP process id -+ * Process ids are in hexadecimal using lower-case letters (0-9,a-f), -+ * or 0 if there is a JobProcess structure but no running process, or -+ * "X" if there is no JobProcess structure. -+ * -+ */ -+ -+void save_current_configuration(char ***args, const void *parent, size_t *len) -+{ -+ NIH_HASH_FOREACH(jobs, iter) { -+ Job *job = (Job *) iter; -+ char goal_state[4]; -+ JobProcess **pids; -+ -+ -+ if (job->replacement_for != NULL) continue; -+ if (job->state == JOB_DELETED) continue; -+ if (job->instance && ! job->instance_of) continue; -+ -+ if (! nih_str_array_add(args, parent, len, job->name)) -+ return; -+ -+ if (job->goal == JOB_START) goal_state[0] = '1'; -+ else goal_state[0] = '0'; -+ -+ switch (job->state) -+ { -+ case JOB_WAITING: goal_state[1] = 'W'; break; -+ case JOB_STARTING: goal_state[1] = 'S'; break; -+ case JOB_PRE_START: goal_state[1] = 'A'; break; -+ case JOB_SPAWNED: goal_state[1] = 'B'; break; -+ case JOB_POST_START: goal_state[1] = 'C'; break; -+ case JOB_RUNNING: goal_state[1] = 'R'; break; -+ case JOB_STOPPING: goal_state[1] = 'T'; break; -+ case JOB_PRE_STOP: goal_state[1] = 'X'; break; -+ case JOB_KILLED: goal_state[1] = 'Y'; break; -+ case JOB_POST_STOP: goal_state[1] = 'Z'; break; -+ default: goal_state[1] = '?'; -+ } -+ if (job->instance_of) goal_state[2] = 'I'; -+ else goal_state[2] = 'N'; -+ goal_state[3] = 0; -+ -+ if (! nih_str_array_add(args, parent, len, goal_state)) -+ return; -+ -+ pids = job->process; -+ store_pid(pids[PROCESS_MAIN], args, parent, len); -+ store_pid(pids[PROCESS_PRE_START], args, parent, len); -+ store_pid(pids[PROCESS_POST_START], args, parent, len); -+ store_pid(pids[PROCESS_PRE_STOP], args, parent, len); -+ store_pid(pids[PROCESS_POST_STOP], args, parent, len); -+ } -+} -+ -+/** -+ * restore_job_state: -+ * @jobname: name of job whose state we are to restore -+ * @goal_state: the goal/state string generated by save_current_configuration -+ * @pids: array of five process ids -+ * @presents: array of five integers indicating which process ids are applicable -+ */ -+ -+void restore_job_state (char *jobname, char *goal_state, -+ pid_t *pids, int *presents) -+{ -+ Job *job; -+ JobGoal goal = JOB_STOP; -+ JobState state = JOB_WAITING; -+ int is_instance = 0; -+ int is_invalid = 0; -+ JobProcess **procs; -+ -+ if (jobname == NULL) { -+ nih_error("Missing name for restored job"); -+ return; -+ } -+ -+ if (goal_state == NULL) { -+ nih_error("Missing goal/state for restored job %s", jobname); -+ return; -+ } -+ -+ if (strlen(goal_state) != 3) { -+ nih_error("Invalid length goal/state %s for restored job %s", -+ goal_state, jobname); -+ return; -+ } -+ -+ switch (goal_state[0]) -+ { -+ case '0': goal = JOB_STOP; break; -+ case '1': goal = JOB_START; break; -+ default: is_invalid = 1; break; -+ } -+ -+ switch (goal_state[1]) -+ { -+ case 'W': state = JOB_WAITING; break; -+ case 'S': state = JOB_STARTING; break; -+ case 'A': state = JOB_PRE_START; break; -+ case 'B': state = JOB_SPAWNED; break; -+ case 'C': state = JOB_POST_START; break; -+ case 'R': state = JOB_RUNNING; break; -+ case 'T': state = JOB_STOPPING; break; -+ case 'X': state = JOB_PRE_STOP; break; -+ case 'Y': state = JOB_KILLED; break; -+ case 'Z': state = JOB_POST_STOP; break; -+ default: is_invalid = 1; -+ } -+ -+ switch (goal_state[2]) -+ { -+ case 'N': break; -+ case 'I': is_instance = 1; break; -+ default: is_invalid = 1; -+ } -+ -+ if (is_invalid) { -+ nih_error("Invalid goal/state %s for restored job %s", -+ goal_state, jobname); -+ return; -+ } -+ job = job_find_by_name(jobname); -+ if (! job) { -+ nih_error("Unknown job %s passed to re-exec", jobname); -+ return; -+ } -+ if (is_instance) { -+ if (! job->instance) { -+ nih_error("Can not restore job %s as instance job", -+ jobname); -+ return; -+ } -+ job = job_instance(job); -+ } else { -+ if (job->instance) { -+ nih_error("Can not restore job %s as non-instance job", -+ jobname); -+ return; -+ } -+ } -+ job->goal = goal; -+ job->state = state; -+ procs=job->process; -+ restore_pid(procs[PROCESS_MAIN], pids[0], presents[0], jobname); -+ restore_pid(procs[PROCESS_PRE_START], pids[1], presents[1], jobname); -+ restore_pid(procs[PROCESS_POST_START], pids[2], presents[2], jobname); -+ restore_pid(procs[PROCESS_PRE_STOP], pids[3], presents[3], jobname); -+ restore_pid(procs[PROCESS_POST_STOP], pids[4], presents[4], jobname); -+} -+ -+/** -+ * restore_current_configuration: -+ * @args: non-option arguments that were passed to the new init -+ */ -+ -+void restore_configuration(char **args) -+{ -+ if (! args) return; -+ -+ char **arg = args; -+ while (arg && *arg) { -+ char *jobname = *(arg++); -+ char *goal_state = *arg; -+ pid_t pids[5]; -+ int presents[5]; -+ int is_invalid = 0; -+ -+ if (*arg) ++arg; -+ for (int i = 0; i < 5; i++) -+ retrieve_pid(&arg, jobname, &is_invalid, -+ &pids[i], &presents[i]); -+ -+ if (! is_invalid) -+ restore_job_state (jobname, goal_state, pids, presents); -+ } -+} -diff -uNr upstart-0.3.9.orig/init/restore.h upstart-0.3.9/init/restore.h ---- upstart-0.3.9.orig/init/restore.h 1969-12-31 19:00:00.000000000 -0500 -+++ upstart-0.3.9/init/restore.h 2009-01-23 13:44:54.000000000 -0500 -@@ -0,0 +1,13 @@ -+#ifndef INIT_RESTORE_H -+#define INIT_RESTORE_H -+ -+#include -+ -+NIH_BEGIN_EXTERN -+ -+void save_current_configuration(char ***args, const void *parent, size_t *len); -+void restore_configuration(char **args); -+ -+NIH_END_EXTERN -+ -+#endif /* INIT_RESTORE_H */ diff --git a/upstart-usr1-handler.patch b/upstart-usr1-handler.patch deleted file mode 100644 index 8657c7e..0000000 --- a/upstart-usr1-handler.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff --git a/init/main.c b/init/main.c -index 2836583..0fb6a64 100644 ---- a/init/main.c -+++ b/init/main.c -@@ -66,6 +66,7 @@ static void cad_handler (void *data, NihSignal *signal); - static void kbd_handler (void *data, NihSignal *signal); - static void pwr_handler (void *data, NihSignal *signal); - static void hup_handler (void *data, NihSignal *signal); -+static void usr1_handler (void *data, NihSignal *signal); - #endif /* DEBUG */ - - -@@ -234,6 +235,10 @@ main (int argc, - /* SIGHUP instructs us to re-load our configuration */ - nih_signal_set_handler (SIGHUP, nih_signal_handler); - NIH_MUST (nih_signal_add_handler (NULL, SIGHUP, hup_handler, NULL)); -+ -+ /* SIGHUSR1 instructs us to reconnect to system bus */ -+ nih_signal_set_handler (SIGUSR1, nih_signal_handler); -+ NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); - #endif /* DEBUG */ - - -@@ -465,4 +470,31 @@ hup_handler (void *data, - } - } - } -+ -+/** -+ * usr1_handler: -+ * @data: unused, -+ * @signal: signal that called this handler. -+ * -+ * Handle having recieved the SIGHUSR1 signal, which we use to instruct us to -+ * connect to system bus. -+ **/ -+static void -+usr1_handler (void *data, -+ NihSignal *signal) -+{ -+ -+ if (! control_bus) { -+ nih_info (_("Connecting to system bus")); -+ -+ if (control_bus_open () < 0) { -+ NihError *err; -+ -+ err = nih_error_get (); -+ nih_warn ("%s: %s", _("Unable to connect to the system bus"), -+ err->message); -+ nih_free (err); -+ } -+ } -+} - #endif /* DEBUG */ diff --git a/upstart.spec b/upstart.spec index 6165e05..0c5dbf2 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,27 +1,20 @@ Name: upstart -Version: 0.6.3 -Release: 7%{?dist} +Version: 0.6.5 +Release: 3%{?dist} Summary: An event-driven init system Group: System Environment/Base License: GPLv2 and LGPLv2+ URL: http://upstart.ubuntu.com -Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.bz2 +Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf -# remove tests which fail in koji -Patch0: upstart-remove-tests.patch -Patch1: upstart-telinit.patch -Patch2: upstart-audit-events.patch -# pulled from https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/436758 -# sparc specific allignment errors -Patch3: upstart-nih-alloc.patch -# SIGUSR1 handler - connect to system dbus -Patch4: upstart-usr1-handler.patch +Patch1: upstart-telinit.patch +Patch2: upstart-audit-events.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 BuildRequires: gettext, audit-libs-devel, expat-devel -BuildRequires: dbus-devel >= 1:1.2.16 +BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 %description Upstart is an event-based replacement for the /sbin/init daemon which @@ -30,11 +23,8 @@ during shutdown and supervising them while the system is running. %prep %setup -q -%patch0 -p1 -b .tests %patch1 -p1 -b .u %patch2 -p1 -b .audit -%patch3 -p1 -b .alignment -%patch4 -p1 -b .usr1 %build %configure --sbindir=/sbin --libdir=/%{_lib} @@ -44,16 +34,6 @@ make %{?_smp_mflags} rm -rf %{buildroot} make install DESTDIR=%{buildroot} -# libupstart and libnih aren't shipped -rm -f %{buildroot}/%{_lib}/libupstart.* -rm -f %{buildroot}/%{_lib}/libnih.* -rm -f %{buildroot}/%{_includedir}/libnih.h -rm -f %{buildroot}/%{_includedir}/libupstart.h -rm -rf %{buildroot}/%{_includedir}/nih -rm -rf %{buildroot}/%{_includedir}/upstart -rm -rf %{buildroot}/%{_datadir}/aclocal/compiler.m4 -rm -rf %{buildroot}/%{_datadir}/aclocal/linker.m4 -rm -rf %{buildroot}/%{_datadir}/aclocal/misc.m4 # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ @@ -61,7 +41,11 @@ install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ %find_lang %{name} %check -make check +#some tests fail in koji while pass in mock and local build +#to run make check use "--with check" +%if %{?_with_check:1}%{!?_with_check:0} + make check +%endif %clean rm -rf %{buildroot} @@ -88,6 +72,7 @@ rm -rf %{buildroot} /sbin/stop /sbin/restart /sbin/telinit +/sbin/reload %{_mandir}/man5/init.5.gz %{_mandir}/man5/inittab.5.gz %{_mandir}/man7/control-alt-delete.7.gz @@ -112,8 +97,18 @@ rm -rf %{buildroot} %{_mandir}/man8/status.8.gz %{_mandir}/man8/stop.8.gz %{_mandir}/man8/telinit.8.gz +%{_mandir}/man8/reload.8.gz %changelog +* Wed Feb 24 2010 Petr Lautrbach 0.6.5-3 +- run "make check" only with --with check + +* Fri Feb 19 2010 Casey Dahlin 0.6.5-2 +- be more specific about which libnih we need. + +* Wed Feb 17 2010 Petr Lautrbach 0.6.5-1 +- upgrade to 0.6.5 + * Fri Jan 29 2010 Petr Lautrbach 0.6.3-7 - add SIGUSR1 handler and init-system-dbus.conf (#559660) From e403b47b7ec99dab1d397a2b8eadf68fa1ab9fc9 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Tue, 6 Apr 2010 20:34:49 +0000 Subject: [PATCH 09/61] Reload init after install --- upstart.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 0c5dbf2..169997b 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 3%{?dist} +Release: 4%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -50,6 +50,9 @@ install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ %clean rm -rf %{buildroot} +%triggerpostun -- upstart < 0.6.0 +[ -f /proc/1/exe -a -d /proc/1/root ] && kill -TERM 1 + %files -f %{name}.lang %defattr(-,root,root,-) %doc AUTHORS @@ -100,6 +103,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Tue Apr 6 2010 Casey Dahlin 0.6.5-4 +- Reload init after install + * Wed Feb 24 2010 Petr Lautrbach 0.6.5-3 - run "make check" only with --with check From 29b380cda104275efc1bf1a186b2a03e9b687b28 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Tue, 6 Apr 2010 20:34:49 +0000 Subject: [PATCH 10/61] Reload init after install --- upstart.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 0c5dbf2..169997b 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 3%{?dist} +Release: 4%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -50,6 +50,9 @@ install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ %clean rm -rf %{buildroot} +%triggerpostun -- upstart < 0.6.0 +[ -f /proc/1/exe -a -d /proc/1/root ] && kill -TERM 1 + %files -f %{name}.lang %defattr(-,root,root,-) %doc AUTHORS @@ -100,6 +103,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Tue Apr 6 2010 Casey Dahlin 0.6.5-4 +- Reload init after install + * Wed Feb 24 2010 Petr Lautrbach 0.6.5-3 - run "make check" only with --with check From 09b57d713c715d1954ad0d58d587772c7b0bddb2 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 4 May 2010 20:27:15 +0000 Subject: [PATCH 11/61] Re-add SIGTERM handler. This allows 'kill -TERM 1' on shutdown to work, avoiding busy inodes when we update glibc/gcc/etc. (#576662) --- upstart-reexec.patch | 65 ++++++++++++++++++++++++++++++++++++++++++++ upstart.spec | 7 ++++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 upstart-reexec.patch diff --git a/upstart-reexec.patch b/upstart-reexec.patch new file mode 100644 index 0000000..324c3a2 --- /dev/null +++ b/upstart-reexec.patch @@ -0,0 +1,65 @@ +diff -up upstart-0.6.5/init/main.c.foo upstart-0.6.5/init/main.c +--- upstart-0.6.5/init/main.c.foo 2010-04-30 19:38:07.846260462 -0400 ++++ upstart-0.6.5/init/main.c 2010-04-30 21:35:38.690487114 -0400 +@@ -67,6 +67,7 @@ static void kbd_handler (void *data, + static void pwr_handler (void *data, NihSignal *signal); + static void hup_handler (void *data, NihSignal *signal); + static void usr1_handler (void *data, NihSignal *signal); ++static void term_handler (void *data, NihSignal *signal); + #endif /* DEBUG */ + + +@@ -241,6 +242,10 @@ main (int argc, + /* SIGUSR1 instructs us to reconnect to D-Bus */ + nih_signal_set_handler (SIGUSR1, nih_signal_handler); + NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); ++ ++ /* SIGTERM instructs us to re-exec ourselves */ ++ nih_signal_set_handler (SIGTERM, nih_signal_handler); ++ NIH_MUST (nih_signal_add_handler (NULL, SIGTERM, term_handler, NULL)); + #endif /* DEBUG */ + + +@@ -485,4 +490,42 @@ usr1_handler (void *data, + } + } + } ++ ++/** ++ * term_handler: ++ * @data: unused, ++ * @signal: signal that called this handler ++ * ++ * This is called when we recieve the TERM signal, which instructs us ++ * to reexec ourselves. ++ **/ ++static void ++term_handler (void *data, ++ NihSignal *signal) ++{ ++ NihError *err; ++ sigset_t mask, oldmask; ++ ++ nih_assert (argv0 != NULL); ++ nih_assert (signal != NULL); ++ ++ nih_warn (_("Re-executing %s"), argv0); ++ ++ /* Block signals while we work. We're the last signal handler ++ * installed so this should mean that they're all handled now. ++ * ++ * The child must make sure that it unblocks these again when ++ * it's ready. ++ */ ++ sigfillset (&mask); ++ sigprocmask (SIG_BLOCK, &mask, &oldmask); ++ execl (argv0, argv0, "--restart", NULL); ++ nih_error_raise_system (); ++ ++ err = nih_error_get (); ++ nih_error (_("Failed to re-execute %s: %s"), argv0, err->message); ++ nih_free (err); ++ ++ sigprocmask (SIG_SETMASK, &oldmask, NULL); ++} + #endif /* DEBUG */ diff --git a/upstart.spec b/upstart.spec index 169997b..784205e 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 4%{?dist} +Release: 5%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -10,6 +10,7 @@ Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch +Patch3: upstart-reexec.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 @@ -25,6 +26,7 @@ during shutdown and supervising them while the system is running. %setup -q %patch1 -p1 -b .u %patch2 -p1 -b .audit +%patch3 -p1 -b .reexec %build %configure --sbindir=/sbin --libdir=/%{_lib} @@ -103,6 +105,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Tue May 4 2010 Bill Nottingham 0.6.5-5 +- re-add SIGTERM handler so restart on shutdown works, avoiding dirty inodes (#576662) + * Tue Apr 6 2010 Casey Dahlin 0.6.5-4 - Reload init after install From 13dcb2a8d84bcfb53e1d14ba46e4b56145b7846a Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 4 May 2010 20:27:16 +0000 Subject: [PATCH 12/61] Re-add SIGTERM handler. This allows 'kill -TERM 1' on shutdown to work, avoiding busy inodes when we update glibc/gcc/etc. (#576662) --- upstart-reexec.patch | 65 ++++++++++++++++++++++++++++++++++++++++++++ upstart.spec | 7 ++++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 upstart-reexec.patch diff --git a/upstart-reexec.patch b/upstart-reexec.patch new file mode 100644 index 0000000..324c3a2 --- /dev/null +++ b/upstart-reexec.patch @@ -0,0 +1,65 @@ +diff -up upstart-0.6.5/init/main.c.foo upstart-0.6.5/init/main.c +--- upstart-0.6.5/init/main.c.foo 2010-04-30 19:38:07.846260462 -0400 ++++ upstart-0.6.5/init/main.c 2010-04-30 21:35:38.690487114 -0400 +@@ -67,6 +67,7 @@ static void kbd_handler (void *data, + static void pwr_handler (void *data, NihSignal *signal); + static void hup_handler (void *data, NihSignal *signal); + static void usr1_handler (void *data, NihSignal *signal); ++static void term_handler (void *data, NihSignal *signal); + #endif /* DEBUG */ + + +@@ -241,6 +242,10 @@ main (int argc, + /* SIGUSR1 instructs us to reconnect to D-Bus */ + nih_signal_set_handler (SIGUSR1, nih_signal_handler); + NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); ++ ++ /* SIGTERM instructs us to re-exec ourselves */ ++ nih_signal_set_handler (SIGTERM, nih_signal_handler); ++ NIH_MUST (nih_signal_add_handler (NULL, SIGTERM, term_handler, NULL)); + #endif /* DEBUG */ + + +@@ -485,4 +490,42 @@ usr1_handler (void *data, + } + } + } ++ ++/** ++ * term_handler: ++ * @data: unused, ++ * @signal: signal that called this handler ++ * ++ * This is called when we recieve the TERM signal, which instructs us ++ * to reexec ourselves. ++ **/ ++static void ++term_handler (void *data, ++ NihSignal *signal) ++{ ++ NihError *err; ++ sigset_t mask, oldmask; ++ ++ nih_assert (argv0 != NULL); ++ nih_assert (signal != NULL); ++ ++ nih_warn (_("Re-executing %s"), argv0); ++ ++ /* Block signals while we work. We're the last signal handler ++ * installed so this should mean that they're all handled now. ++ * ++ * The child must make sure that it unblocks these again when ++ * it's ready. ++ */ ++ sigfillset (&mask); ++ sigprocmask (SIG_BLOCK, &mask, &oldmask); ++ execl (argv0, argv0, "--restart", NULL); ++ nih_error_raise_system (); ++ ++ err = nih_error_get (); ++ nih_error (_("Failed to re-execute %s: %s"), argv0, err->message); ++ nih_free (err); ++ ++ sigprocmask (SIG_SETMASK, &oldmask, NULL); ++} + #endif /* DEBUG */ diff --git a/upstart.spec b/upstart.spec index 169997b..784205e 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 4%{?dist} +Release: 5%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -10,6 +10,7 @@ Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch +Patch3: upstart-reexec.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 @@ -25,6 +26,7 @@ during shutdown and supervising them while the system is running. %setup -q %patch1 -p1 -b .u %patch2 -p1 -b .audit +%patch3 -p1 -b .reexec %build %configure --sbindir=/sbin --libdir=/%{_lib} @@ -103,6 +105,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Tue May 4 2010 Bill Nottingham 0.6.5-5 +- re-add SIGTERM handler so restart on shutdown works, avoiding dirty inodes (#576662) + * Tue Apr 6 2010 Casey Dahlin 0.6.5-4 - Reload init after install From 4b54411e244d9550c547cf66366fecff238c6d74 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 27 May 2010 15:55:38 +0000 Subject: [PATCH 13/61] Add a conflict on older versions of initscripts. (#596835) --- upstart.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/upstart.spec b/upstart.spec index 784205e..c423fd3 100644 --- a/upstart.spec +++ b/upstart.spec @@ -16,6 +16,7 @@ Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 +Conflicts: initscripts < 9.12 %description Upstart is an event-based replacement for the /sbin/init daemon which From 118787f9320d1bb84879e81b7063917807163d1c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 27 May 2010 15:55:38 +0000 Subject: [PATCH 14/61] Add a conflict on older versions of initscripts. (#596835) --- upstart.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/upstart.spec b/upstart.spec index 784205e..c423fd3 100644 --- a/upstart.spec +++ b/upstart.spec @@ -16,6 +16,7 @@ Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 +Conflicts: initscripts < 9.12 %description Upstart is an event-based replacement for the /sbin/init daemon which From 369b9c245d214f69ac46f9f735eb642f0692e955 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 24 Jul 2010 00:44:03 +0000 Subject: [PATCH 15/61] Split off -sysvinit to make Upstart parallel installable with systemd --- upstart.spec | 77 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/upstart.spec b/upstart.spec index c423fd3..13aae64 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 5%{?dist} +Release: 6%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -12,9 +12,7 @@ Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch Patch3: upstart-reexec.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 -Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 -BuildRequires: gettext, audit-libs-devel, expat-devel +BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 Conflicts: initscripts < 9.12 @@ -23,6 +21,17 @@ Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running. +%package sysvinit +Group: System Environment/Base +Summary: Upstart System V init tools +Requires: %{name} = %{version}-%{release} +Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 +Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 +Conflicts: systemd-sysvinit + +%description sysvinit +Drop-in replacement for the System V init tools, provided by Upstart. + %prep %setup -q %patch1 -p1 -b .u @@ -37,6 +46,28 @@ make %{?_smp_mflags} rm -rf %{buildroot} make install DESTDIR=%{buildroot} +# Rename common SysV binaries and symlink them to allow parallel +# installation with systemd. We move the utility binaries into a +# subdirectory, so that program_name stays the same and Upstart still +# can check argv[0] properly in various places. +mv %{buildroot}/sbin/init %{buildroot}/sbin/upstart +rm %{buildroot}/sbin/halt +rm %{buildroot}/sbin/poweroff +mkdir -p -m 755 %{buildroot}/lib/upstart +mv %{buildroot}/sbin/reboot %{buildroot}/lib/upstart/reboot +mv %{buildroot}/sbin/runlevel %{buildroot}/lib/upstart/runlevel +mv %{buildroot}/sbin/shutdown %{buildroot}/lib/upstart/shutdown +mv %{buildroot}/sbin/telinit %{buildroot}/lib/upstart/telinit +ln -sf upstart %{buildroot}/sbin/init +ln -sf reboot %{buildroot}/lib/upstart/poweroff +ln -sf reboot %{buildroot}/lib/upstart/halt +ln -sf ../lib/upstart/reboot %{buildroot}/sbin/halt +ln -sf ../lib/upstart/reboot %{buildroot}/sbin/poweroff +ln -sf ../lib/upstart/reboot %{buildroot}/sbin/reboot +ln -sf ../lib/upstart/runlevel %{buildroot}/sbin/runlevel +ln -sf ../lib/upstart/shutdown %{buildroot}/sbin/shutdown +ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit + # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ @@ -66,18 +97,19 @@ rm -rf %{buildroot} %doc HACKING %{_sysconfdir}/init/ %config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf -/sbin/halt -/sbin/init +%dir /lib/upstart +/lib/upstart/halt +/sbin/upstart /sbin/initctl -/sbin/poweroff -/sbin/reboot -/sbin/runlevel -/sbin/shutdown +/lib/upstart/poweroff +/lib/upstart/reboot +/lib/upstart/runlevel +/lib/upstart/shutdown /sbin/start /sbin/status /sbin/stop /sbin/restart -/sbin/telinit +/lib/upstart/telinit /sbin/reload %{_mandir}/man5/init.5.gz %{_mandir}/man5/inittab.5.gz @@ -92,20 +124,33 @@ rm -rf %{buildroot} %{_mandir}/man7/stopping.7.gz %{_mandir}/man7/upstart.7.gz %{_mandir}/man8/restart.8.gz +%{_mandir}/man8/initctl.8.gz +%{_mandir}/man8/start.8.gz +%{_mandir}/man8/status.8.gz +%{_mandir}/man8/stop.8.gz +%{_mandir}/man8/reload.8.gz + +%files sysvinit +%defattr(-,root,root,-) +/sbin/halt +/sbin/init +/sbin/poweroff +/sbin/reboot +/sbin/runlevel +/sbin/shutdown +/sbin/telinit %{_mandir}/man8/halt.8.gz %{_mandir}/man8/init.8.gz -%{_mandir}/man8/initctl.8.gz %{_mandir}/man8/poweroff.8.gz %{_mandir}/man8/reboot.8.gz %{_mandir}/man8/runlevel.8.gz %{_mandir}/man8/shutdown.8.gz -%{_mandir}/man8/start.8.gz -%{_mandir}/man8/status.8.gz -%{_mandir}/man8/stop.8.gz %{_mandir}/man8/telinit.8.gz -%{_mandir}/man8/reload.8.gz %changelog +* Sat Jul 24 2010 Lennart Poettering - 0.6.5-6 +- Split off -sysvinit to make Upstart parallel installable with systemd + * Tue May 4 2010 Bill Nottingham 0.6.5-5 - re-add SIGTERM handler so restart on shutdown works, avoiding dirty inodes (#576662) From 7aec19654fd5c967d809166f979a7128bc265876 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Sat, 24 Jul 2010 01:50:59 +0000 Subject: [PATCH 16/61] Fix broken upgrades from package split --- upstart.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 13aae64..81dde16 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 6%{?dist} +Release: 7%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -15,6 +15,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 Conflicts: initscripts < 9.12 +Requires: sysvinit-userspace %description Upstart is an event-based replacement for the /sbin/init daemon which @@ -27,6 +28,7 @@ Summary: Upstart System V init tools Requires: %{name} = %{version}-%{release} Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 +Provides: sysvinit-userspace Conflicts: systemd-sysvinit %description sysvinit @@ -148,6 +150,9 @@ rm -rf %{buildroot} %{_mandir}/man8/telinit.8.gz %changelog +* Sat Jul 24 2010 Casey Dahlin - 0.6.5-7 +- Make upgrades work correctly now that -sysvinit is split off + * Sat Jul 24 2010 Lennart Poettering - 0.6.5-6 - Split off -sysvinit to make Upstart parallel installable with systemd From 5831b51228d261f9a6b5ed1064ed8993c56a4496 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 29 Jul 2010 14:46:16 +0000 Subject: [PATCH 17/61] dist-git conversion --- .cvsignore => .gitignore | 0 Makefile | 21 --------------------- branch | 1 - 3 files changed, 22 deletions(-) rename .cvsignore => .gitignore (100%) delete mode 100644 Makefile delete mode 100644 branch diff --git a/.cvsignore b/.gitignore similarity index 100% rename from .cvsignore rename to .gitignore diff --git a/Makefile b/Makefile deleted file mode 100644 index b4ab50a..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: upstart -# $Id: Makefile,v 1.1 2008/02/07 02:32:39 kevin Exp $ -NAME := upstart -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/branch b/branch deleted file mode 100644 index baa94ef..0000000 --- a/branch +++ /dev/null @@ -1 +0,0 @@ -F-13 From a5f64464a13bb9854ec6b59c6bc2a4b8676abe15 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 29 Jul 2010 14:46:22 +0000 Subject: [PATCH 18/61] dist-git conversion --- .cvsignore => .gitignore | 0 Makefile | 21 --------------------- 2 files changed, 21 deletions(-) rename .cvsignore => .gitignore (100%) delete mode 100644 Makefile diff --git a/.cvsignore b/.gitignore similarity index 100% rename from .cvsignore rename to .gitignore diff --git a/Makefile b/Makefile deleted file mode 100644 index b4ab50a..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: upstart -# $Id: Makefile,v 1.1 2008/02/07 02:32:39 kevin Exp $ -NAME := upstart -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) From 2348e3ee26c9f9153b3500903085c38a42957b9c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 17 Sep 2010 10:33:39 -0400 Subject: [PATCH 19/61] Bump release. --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 81dde16..e8ec588 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 7%{?dist} +Release: 8%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -150,6 +150,9 @@ rm -rf %{buildroot} %{_mandir}/man8/telinit.8.gz %changelog +* Fri Sep 17 2010 Bill Nottingham - 0.6.5-8 +- ensure F15 version is newer than F-14 + * Sat Jul 24 2010 Casey Dahlin - 0.6.5-7 - Make upgrades work correctly now that -sysvinit is split off From 013ebf0ed2028b015840c90a51e5460079f49382 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 21 Sep 2010 13:06:26 +0200 Subject: [PATCH 20/61] upstart-utmp.patch - set DEAD_PROCESS for died process with pid in utmp table --- upstart-utmp.patch | 317 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 upstart-utmp.patch diff --git a/upstart-utmp.patch b/upstart-utmp.patch new file mode 100644 index 0000000..255bc50 --- /dev/null +++ b/upstart-utmp.patch @@ -0,0 +1,317 @@ +diff --git a/init/job_class.c b/init/job_class.c +index b521cf4..1b8d1cf 100644 +--- a/init/job_class.c ++++ b/init/job_class.c +@@ -218,6 +218,8 @@ job_class_new (const void *parent, + class->chroot = NULL; + class->chdir = NULL; + ++ class->utmp_id = NULL; ++ + class->deleted = FALSE; + + return class; +diff --git a/init/job_class.h b/init/job_class.h +index b7d4eed..1d29c59 100644 +--- a/init/job_class.h ++++ b/init/job_class.h +@@ -145,6 +145,7 @@ typedef struct job_class { + struct rlimit *limits[RLIMIT_NLIMITS]; + char *chroot; + char *chdir; ++ char *utmp_id; + + int deleted; + } JobClass; +diff --git a/init/job_process.c b/init/job_process.c +index e3080d8..8ce2f72 100644 +--- a/init/job_process.c ++++ b/init/job_process.c +@@ -38,6 +38,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -361,11 +363,13 @@ job_process_spawn (JobClass *class, + char * const *env, + int trace) + { +- sigset_t child_set, orig_set; +- pid_t pid; +- int i, fds[2]; +- char filename[PATH_MAX]; +- FILE *fd; ++ sigset_t child_set, orig_set; ++ pid_t pid; ++ int i, fds[2]; ++ char filename[PATH_MAX]; ++ FILE *fd; ++ struct utmpx utmp; ++ struct timeval tv; + + nih_assert (class != NULL); + +@@ -524,6 +528,20 @@ job_process_spawn (JobClass *class, + } + } + ++ /* Write utmp INIT_PROCESS entry */ ++ if (class->utmp_id) { ++ memset(&utmp, 0, sizeof(struct utmpx)); ++ strncpy(utmp.ut_id, class->utmp_id, sizeof(utmp.ut_id)); ++ utmp.ut_pid = getpid(); ++ utmp.ut_type = INIT_PROCESS; ++ gettimeofday(&tv, NULL); ++ utmp.ut_tv.tv_sec = tv.tv_sec; ++ utmp.ut_tv.tv_usec = tv.tv_usec; ++ setutxent(); ++ pututxline(&utmp); ++ endutxent(); ++ } ++ + /* Execute the process, if we escape from here it failed */ + if (execvp (argv[0], argv) < 0) { + nih_error_raise_system (); +@@ -967,6 +985,8 @@ job_process_terminated (Job *job, + int status) + { + int failed = FALSE, stop = FALSE, state = TRUE; ++ struct utmpx *utmptr; ++ struct timeval tv; + + nih_assert (job != NULL); + +@@ -1129,6 +1149,36 @@ job_process_terminated (Job *job, + job->kill_process = -1; + } + ++ /* Find existing utmp entry for the process pid */ ++ setutxent(); ++ while ((utmptr = getutxent()) != NULL) { ++ if (utmptr->ut_pid == job->pid[process]) { ++ /* set type and clean ut_user, ut_host, ++ * ut_time as described in utmp(5) ++ */ ++ utmptr->ut_type = DEAD_PROCESS; ++ memset(utmptr->ut_user, 0, UT_NAMESIZE); ++ memset(utmptr->ut_host, 0, UT_HOSTSIZE); ++ utmptr->ut_time = 0; ++ ++ /* Set class utmp_id for next spawn */ ++ job->class->utmp_id = nih_strdup (job->class, utmptr->ut_id); ++ ++ /* Update existing utmp file. */ ++ pututxline(utmptr); ++ ++ /* set ut_time for log */ ++ gettimeofday(&tv, NULL); ++ utmptr->ut_tv.tv_sec = tv.tv_sec; ++ utmptr->ut_tv.tv_usec = tv.tv_usec; ++ /* Write wtmp entry */ ++ updwtmpx (_PATH_WTMP, utmptr); ++ ++ break; ++ } ++ } ++ endutxent(); ++ + /* Clear the process pid field */ + job->pid[process] = 0; + +diff --git a/init/tests/test_job_process.c b/init/tests/test_job_process.c +index d43fa6e..b4f94e4 100644 +--- a/init/tests/test_job_process.c ++++ b/init/tests/test_job_process.c +@@ -36,6 +36,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -4474,6 +4476,171 @@ test_find (void) + } + + ++void ++test_utmp (void) ++{ ++ JobClass * class; ++ Job * job = NULL; ++ Blocked * blocked = NULL; ++ Event * event; ++ FILE * output; ++ char utmpname[PATH_MAX]; ++ struct utmpx utmp, *utmptr; ++ struct timeval tv; ++ ++ TEST_FUNCTION ("job_process_handler"); ++ program_name = "test"; ++ ++ class = job_class_new (NULL, "test"); ++ class->process[PROCESS_MAIN] = process_new (class); ++ class->process[PROCESS_MAIN]->command = "echo"; ++ ++ class->start_on = event_operator_new (class, EVENT_MATCH, ++ "foo", NULL); ++ class->stop_on = event_operator_new (class, EVENT_MATCH, ++ "foo", NULL); ++ nih_hash_add (job_classes, &class->entry); ++ ++ event = event_new (NULL, "foo", NULL); ++ ++ TEST_FILENAME(utmpname); ++ ++ /* Check that utmp record for the running task of the job terminating ++ * is properly changed to DEAD_PROCESS ++ */ ++ TEST_FEATURE ("with LOGIN_PROCESS utmp entry"); ++ TEST_ALLOC_FAIL { ++ TEST_ALLOC_SAFE { ++ job = job_new (class, ""); ++ ++ blocked = blocked_new (job, BLOCKED_EVENT, event); ++ event_block (event); ++ nih_list_add (&job->blocking, &blocked->entry); ++ } ++ ++ job->goal = JOB_START; ++ job->state = JOB_RUNNING; ++ job->pid[PROCESS_MAIN] = 1; ++ ++ TEST_FREE_TAG (blocked); ++ ++ job->blocker = NULL; ++ event->failed = FALSE; ++ ++ job->failed = FALSE; ++ job->failed_process = -1; ++ job->exit_status = 0; ++ ++ output = fopen (utmpname, "w"); ++ fclose (output); ++ ++ /* set utmp file */ ++ utmpxname(utmpname); ++ ++ /* set up utmp entries */ ++ memset (&utmp, 0, sizeof utmp); ++ ++ strcpy(utmp.ut_id, "2"); ++ utmp.ut_type = LOGIN_PROCESS; ++ utmp.ut_pid = 2; ++ ++ gettimeofday(&tv, NULL); ++ utmp.ut_tv.tv_sec = tv.tv_sec; ++ utmp.ut_tv.tv_usec = tv.tv_usec; ++ ++ setutxent(); ++ pututxline(&utmp); ++ ++ strcpy(utmp.ut_id, "1"); ++ utmp.ut_pid = 1; ++ pututxline(&utmp); ++ ++ endutxent(); ++ ++ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); ++ ++ setutxent(); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 2); ++ TEST_EQ(utmptr->ut_type, LOGIN_PROCESS); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 1); ++ TEST_EQ(utmptr->ut_type, DEAD_PROCESS); ++ ++ nih_free (job); ++ } ++ TEST_FEATURE ("with USER_PROCESS utmp entry"); ++ TEST_ALLOC_FAIL { ++ TEST_ALLOC_SAFE { ++ job = job_new (class, ""); ++ ++ blocked = blocked_new (job, BLOCKED_EVENT, event); ++ event_block (event); ++ nih_list_add (&job->blocking, &blocked->entry); ++ } ++ ++ job->goal = JOB_START; ++ job->state = JOB_RUNNING; ++ job->pid[PROCESS_MAIN] = 1; ++ ++ TEST_FREE_TAG (blocked); ++ ++ job->blocker = NULL; ++ event->failed = FALSE; ++ ++ job->failed = FALSE; ++ job->failed_process = -1; ++ job->exit_status = 0; ++ ++ output = fopen (utmpname, "w"); ++ fclose (output); ++ ++ /* set utmp file */ ++ utmpxname(utmpname); ++ ++ /* set up utmp entries */ ++ memset (&utmp, 0, sizeof utmp); ++ ++ strcpy(utmp.ut_id, "2"); ++ utmp.ut_type = USER_PROCESS; ++ utmp.ut_pid = 2; ++ ++ gettimeofday(&tv, NULL); ++ utmp.ut_tv.tv_sec = tv.tv_sec; ++ utmp.ut_tv.tv_usec = tv.tv_usec; ++ ++ setutxent(); ++ pututxline(&utmp); ++ ++ strcpy(utmp.ut_id, "1"); ++ utmp.ut_pid = 1; ++ pututxline(&utmp); ++ ++ endutxent(); ++ ++ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); ++ ++ setutxent(); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 2); ++ TEST_EQ(utmptr->ut_type, USER_PROCESS); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 1); ++ TEST_EQ(utmptr->ut_type, DEAD_PROCESS); ++ ++ nih_free (job); ++ } ++} ++ ++ + int + main (int argc, + char *argv[]) +@@ -4505,6 +4672,7 @@ main (int argc, + test_spawn (); + test_kill (); + test_handler (); ++ test_utmp (); + + test_find (); + From 6c8f335774a1e5b4903097e691034f64fe631fe1 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 21 Sep 2010 13:20:19 +0200 Subject: [PATCH 21/61] upstart-shutdown-exitcode.patch - exit shutdown with nonzero exitcode when fails shutdown --- upstart-shutdown-exitcode.patch | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 upstart-shutdown-exitcode.patch diff --git a/upstart-shutdown-exitcode.patch b/upstart-shutdown-exitcode.patch new file mode 100644 index 0000000..0b70308 --- /dev/null +++ b/upstart-shutdown-exitcode.patch @@ -0,0 +1,28 @@ +diff --git a/util/shutdown.c b/util/shutdown.c +index 0a6d8bf..2ef847a 100644 +--- a/util/shutdown.c ++++ b/util/shutdown.c +@@ -459,6 +459,7 @@ shutdown_now (void) + { + nih_local char **extra_env = NULL; + NihDBusError * dbus_err; ++ int exit_val = 0; + + if (init_halt) { + char *e; +@@ -486,12 +487,14 @@ shutdown_now (void) + * yet rebooted ... so try /dev/initctl + */ + sysvinit_shutdown (); ++ nih_fatal ("Unable to shutdown system"); ++ exit_val = 1; + } + + unlink (ETC_NOLOGIN); + nih_main_unlink_pidfile (); + +- exit (0); ++ exit (exit_val); + } + + /** From adfc4f92f04713729364fbaf5cb921f9e6d6d5b0 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 21 Sep 2010 13:20:41 +0200 Subject: [PATCH 22/61] upstart-0.6.5-9.fc15 --- upstart.spec | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/upstart.spec b/upstart.spec index e8ec588..030eff1 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 8%{?dist} +Release: 9%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -10,7 +10,11 @@ Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch -Patch3: upstart-reexec.patch +# set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) +Patch3: upstart-utmp.patch +Patch4: upstart-reexec.patch +# shutdown exits with nonzero exitcode when fails +Patch5: upstart-shutdown-exitcode.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 @@ -38,7 +42,9 @@ Drop-in replacement for the System V init tools, provided by Upstart. %setup -q %patch1 -p1 -b .u %patch2 -p1 -b .audit -%patch3 -p1 -b .reexec +%patch3 -p1 -b .utmp +%patch4 -p1 -b .reexec +%patch5 -p1 -b .exitcode %build %configure --sbindir=/sbin --libdir=/%{_lib} @@ -150,6 +156,10 @@ rm -rf %{buildroot} %{_mandir}/man8/telinit.8.gz %changelog +* Tue Sep 21 2010 Petr Lautrbach 0.6.5-9 +- set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) +- exit shutdown with nonzero exitcode when fails shutdown + * Fri Sep 17 2010 Bill Nottingham - 0.6.5-8 - ensure F15 version is newer than F-14 From db45477d6b5adb686163aba970ff8062f2801e98 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 21 Sep 2010 13:06:26 +0200 Subject: [PATCH 23/61] upstart-utmp.patch - set DEAD_PROCESS for died process with pid in utmp table --- upstart-utmp.patch | 317 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 upstart-utmp.patch diff --git a/upstart-utmp.patch b/upstart-utmp.patch new file mode 100644 index 0000000..255bc50 --- /dev/null +++ b/upstart-utmp.patch @@ -0,0 +1,317 @@ +diff --git a/init/job_class.c b/init/job_class.c +index b521cf4..1b8d1cf 100644 +--- a/init/job_class.c ++++ b/init/job_class.c +@@ -218,6 +218,8 @@ job_class_new (const void *parent, + class->chroot = NULL; + class->chdir = NULL; + ++ class->utmp_id = NULL; ++ + class->deleted = FALSE; + + return class; +diff --git a/init/job_class.h b/init/job_class.h +index b7d4eed..1d29c59 100644 +--- a/init/job_class.h ++++ b/init/job_class.h +@@ -145,6 +145,7 @@ typedef struct job_class { + struct rlimit *limits[RLIMIT_NLIMITS]; + char *chroot; + char *chdir; ++ char *utmp_id; + + int deleted; + } JobClass; +diff --git a/init/job_process.c b/init/job_process.c +index e3080d8..8ce2f72 100644 +--- a/init/job_process.c ++++ b/init/job_process.c +@@ -38,6 +38,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -361,11 +363,13 @@ job_process_spawn (JobClass *class, + char * const *env, + int trace) + { +- sigset_t child_set, orig_set; +- pid_t pid; +- int i, fds[2]; +- char filename[PATH_MAX]; +- FILE *fd; ++ sigset_t child_set, orig_set; ++ pid_t pid; ++ int i, fds[2]; ++ char filename[PATH_MAX]; ++ FILE *fd; ++ struct utmpx utmp; ++ struct timeval tv; + + nih_assert (class != NULL); + +@@ -524,6 +528,20 @@ job_process_spawn (JobClass *class, + } + } + ++ /* Write utmp INIT_PROCESS entry */ ++ if (class->utmp_id) { ++ memset(&utmp, 0, sizeof(struct utmpx)); ++ strncpy(utmp.ut_id, class->utmp_id, sizeof(utmp.ut_id)); ++ utmp.ut_pid = getpid(); ++ utmp.ut_type = INIT_PROCESS; ++ gettimeofday(&tv, NULL); ++ utmp.ut_tv.tv_sec = tv.tv_sec; ++ utmp.ut_tv.tv_usec = tv.tv_usec; ++ setutxent(); ++ pututxline(&utmp); ++ endutxent(); ++ } ++ + /* Execute the process, if we escape from here it failed */ + if (execvp (argv[0], argv) < 0) { + nih_error_raise_system (); +@@ -967,6 +985,8 @@ job_process_terminated (Job *job, + int status) + { + int failed = FALSE, stop = FALSE, state = TRUE; ++ struct utmpx *utmptr; ++ struct timeval tv; + + nih_assert (job != NULL); + +@@ -1129,6 +1149,36 @@ job_process_terminated (Job *job, + job->kill_process = -1; + } + ++ /* Find existing utmp entry for the process pid */ ++ setutxent(); ++ while ((utmptr = getutxent()) != NULL) { ++ if (utmptr->ut_pid == job->pid[process]) { ++ /* set type and clean ut_user, ut_host, ++ * ut_time as described in utmp(5) ++ */ ++ utmptr->ut_type = DEAD_PROCESS; ++ memset(utmptr->ut_user, 0, UT_NAMESIZE); ++ memset(utmptr->ut_host, 0, UT_HOSTSIZE); ++ utmptr->ut_time = 0; ++ ++ /* Set class utmp_id for next spawn */ ++ job->class->utmp_id = nih_strdup (job->class, utmptr->ut_id); ++ ++ /* Update existing utmp file. */ ++ pututxline(utmptr); ++ ++ /* set ut_time for log */ ++ gettimeofday(&tv, NULL); ++ utmptr->ut_tv.tv_sec = tv.tv_sec; ++ utmptr->ut_tv.tv_usec = tv.tv_usec; ++ /* Write wtmp entry */ ++ updwtmpx (_PATH_WTMP, utmptr); ++ ++ break; ++ } ++ } ++ endutxent(); ++ + /* Clear the process pid field */ + job->pid[process] = 0; + +diff --git a/init/tests/test_job_process.c b/init/tests/test_job_process.c +index d43fa6e..b4f94e4 100644 +--- a/init/tests/test_job_process.c ++++ b/init/tests/test_job_process.c +@@ -36,6 +36,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -4474,6 +4476,171 @@ test_find (void) + } + + ++void ++test_utmp (void) ++{ ++ JobClass * class; ++ Job * job = NULL; ++ Blocked * blocked = NULL; ++ Event * event; ++ FILE * output; ++ char utmpname[PATH_MAX]; ++ struct utmpx utmp, *utmptr; ++ struct timeval tv; ++ ++ TEST_FUNCTION ("job_process_handler"); ++ program_name = "test"; ++ ++ class = job_class_new (NULL, "test"); ++ class->process[PROCESS_MAIN] = process_new (class); ++ class->process[PROCESS_MAIN]->command = "echo"; ++ ++ class->start_on = event_operator_new (class, EVENT_MATCH, ++ "foo", NULL); ++ class->stop_on = event_operator_new (class, EVENT_MATCH, ++ "foo", NULL); ++ nih_hash_add (job_classes, &class->entry); ++ ++ event = event_new (NULL, "foo", NULL); ++ ++ TEST_FILENAME(utmpname); ++ ++ /* Check that utmp record for the running task of the job terminating ++ * is properly changed to DEAD_PROCESS ++ */ ++ TEST_FEATURE ("with LOGIN_PROCESS utmp entry"); ++ TEST_ALLOC_FAIL { ++ TEST_ALLOC_SAFE { ++ job = job_new (class, ""); ++ ++ blocked = blocked_new (job, BLOCKED_EVENT, event); ++ event_block (event); ++ nih_list_add (&job->blocking, &blocked->entry); ++ } ++ ++ job->goal = JOB_START; ++ job->state = JOB_RUNNING; ++ job->pid[PROCESS_MAIN] = 1; ++ ++ TEST_FREE_TAG (blocked); ++ ++ job->blocker = NULL; ++ event->failed = FALSE; ++ ++ job->failed = FALSE; ++ job->failed_process = -1; ++ job->exit_status = 0; ++ ++ output = fopen (utmpname, "w"); ++ fclose (output); ++ ++ /* set utmp file */ ++ utmpxname(utmpname); ++ ++ /* set up utmp entries */ ++ memset (&utmp, 0, sizeof utmp); ++ ++ strcpy(utmp.ut_id, "2"); ++ utmp.ut_type = LOGIN_PROCESS; ++ utmp.ut_pid = 2; ++ ++ gettimeofday(&tv, NULL); ++ utmp.ut_tv.tv_sec = tv.tv_sec; ++ utmp.ut_tv.tv_usec = tv.tv_usec; ++ ++ setutxent(); ++ pututxline(&utmp); ++ ++ strcpy(utmp.ut_id, "1"); ++ utmp.ut_pid = 1; ++ pututxline(&utmp); ++ ++ endutxent(); ++ ++ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); ++ ++ setutxent(); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 2); ++ TEST_EQ(utmptr->ut_type, LOGIN_PROCESS); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 1); ++ TEST_EQ(utmptr->ut_type, DEAD_PROCESS); ++ ++ nih_free (job); ++ } ++ TEST_FEATURE ("with USER_PROCESS utmp entry"); ++ TEST_ALLOC_FAIL { ++ TEST_ALLOC_SAFE { ++ job = job_new (class, ""); ++ ++ blocked = blocked_new (job, BLOCKED_EVENT, event); ++ event_block (event); ++ nih_list_add (&job->blocking, &blocked->entry); ++ } ++ ++ job->goal = JOB_START; ++ job->state = JOB_RUNNING; ++ job->pid[PROCESS_MAIN] = 1; ++ ++ TEST_FREE_TAG (blocked); ++ ++ job->blocker = NULL; ++ event->failed = FALSE; ++ ++ job->failed = FALSE; ++ job->failed_process = -1; ++ job->exit_status = 0; ++ ++ output = fopen (utmpname, "w"); ++ fclose (output); ++ ++ /* set utmp file */ ++ utmpxname(utmpname); ++ ++ /* set up utmp entries */ ++ memset (&utmp, 0, sizeof utmp); ++ ++ strcpy(utmp.ut_id, "2"); ++ utmp.ut_type = USER_PROCESS; ++ utmp.ut_pid = 2; ++ ++ gettimeofday(&tv, NULL); ++ utmp.ut_tv.tv_sec = tv.tv_sec; ++ utmp.ut_tv.tv_usec = tv.tv_usec; ++ ++ setutxent(); ++ pututxline(&utmp); ++ ++ strcpy(utmp.ut_id, "1"); ++ utmp.ut_pid = 1; ++ pututxline(&utmp); ++ ++ endutxent(); ++ ++ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); ++ ++ setutxent(); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 2); ++ TEST_EQ(utmptr->ut_type, USER_PROCESS); ++ ++ utmptr = getutxent(); ++ TEST_NE_P(utmptr, NULL); ++ TEST_EQ(utmptr->ut_pid, 1); ++ TEST_EQ(utmptr->ut_type, DEAD_PROCESS); ++ ++ nih_free (job); ++ } ++} ++ ++ + int + main (int argc, + char *argv[]) +@@ -4505,6 +4672,7 @@ main (int argc, + test_spawn (); + test_kill (); + test_handler (); ++ test_utmp (); + + test_find (); + From 71798b30adaacdd513e5493a64b254c9d5ff0390 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 21 Sep 2010 13:20:19 +0200 Subject: [PATCH 24/61] upstart-shutdown-exitcode.patch - exit shutdown with nonzero exitcode when fails shutdown --- upstart-shutdown-exitcode.patch | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 upstart-shutdown-exitcode.patch diff --git a/upstart-shutdown-exitcode.patch b/upstart-shutdown-exitcode.patch new file mode 100644 index 0000000..0b70308 --- /dev/null +++ b/upstart-shutdown-exitcode.patch @@ -0,0 +1,28 @@ +diff --git a/util/shutdown.c b/util/shutdown.c +index 0a6d8bf..2ef847a 100644 +--- a/util/shutdown.c ++++ b/util/shutdown.c +@@ -459,6 +459,7 @@ shutdown_now (void) + { + nih_local char **extra_env = NULL; + NihDBusError * dbus_err; ++ int exit_val = 0; + + if (init_halt) { + char *e; +@@ -486,12 +487,14 @@ shutdown_now (void) + * yet rebooted ... so try /dev/initctl + */ + sysvinit_shutdown (); ++ nih_fatal ("Unable to shutdown system"); ++ exit_val = 1; + } + + unlink (ETC_NOLOGIN); + nih_main_unlink_pidfile (); + +- exit (0); ++ exit (exit_val); + } + + /** From 6f361193c152d35b264ab565f86cd57318523bb1 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 21 Sep 2010 14:21:50 +0200 Subject: [PATCH 25/61] upstart-0.6.5-6.fc13 --- upstart.spec | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/upstart.spec b/upstart.spec index c423fd3..607de6b 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 5%{?dist} +Release: 6%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -10,7 +10,11 @@ Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch -Patch3: upstart-reexec.patch +# set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) +Patch3: upstart-utmp.patch +Patch4: upstart-reexec.patch +# shutdown exits with nonzero exitcode when fails +Patch5: upstart-shutdown-exitcode.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 @@ -27,7 +31,9 @@ during shutdown and supervising them while the system is running. %setup -q %patch1 -p1 -b .u %patch2 -p1 -b .audit -%patch3 -p1 -b .reexec +%patch3 -p1 -b .utmp +%patch4 -p1 -b .reexec +%patch5 -p1 -b .exitcode %build %configure --sbindir=/sbin --libdir=/%{_lib} @@ -106,6 +112,10 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Tue Sep 21 2010 Petr Lautrbach 0.6.5-6 +- set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) +- exit shutdown with nonzero exitcode when fails shutdown + * Tue May 4 2010 Bill Nottingham 0.6.5-5 - re-add SIGTERM handler so restart on shutdown works, avoiding dirty inodes (#576662) From dd3667fd150fe066b3446af4b3c2a821bf6494e3 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 24 Sep 2010 13:13:09 -0400 Subject: [PATCH 26/61] Add in basic boot jobs. (#637099) --- .gitignore | 1 + sources | 1 + upstart.spec | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6c1b28b..c70584d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ upstart-0.6.5.tar.gz +/initjobs.tar.gz diff --git a/sources b/sources index 46ac626..104e863 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ f9466bba72b655c2408353b64105853f upstart-0.6.5.tar.gz +972676df8c1f67d9b2761a1fb02d170f initjobs.tar.gz diff --git a/upstart.spec b/upstart.spec index 030eff1..c807fdc 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 9%{?dist} +Release: 10%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -8,6 +8,8 @@ License: GPLv2 and LGPLv2+ URL: http://upstart.ubuntu.com Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf +# These are taken from http://git.fedorahosted.org/git/?p=initscripts.git +Source2: initjobs.tar.gz Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) @@ -39,7 +41,7 @@ Conflicts: systemd-sysvinit Drop-in replacement for the System V init tools, provided by Upstart. %prep -%setup -q +%setup -q -a 2 %patch1 -p1 -b .u %patch2 -p1 -b .audit %patch3 -p1 -b .utmp @@ -79,6 +81,10 @@ ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ +for file in initjobs/*.conf ; do + install -m 644 $file %{buildroot}/%{_sysconfdir}/init/$file +done + %find_lang %{name} @@ -156,6 +162,9 @@ rm -rf %{buildroot} %{_mandir}/man8/telinit.8.gz %changelog +* Fri Sep 24 2010 Bill Nottingham 0.6.5-10 +- merge in basic boot jobs here (#637099) + * Tue Sep 21 2010 Petr Lautrbach 0.6.5-9 - set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) - exit shutdown with nonzero exitcode when fails shutdown From b9ae6c686ddaef892f08c8467f52838441fb5627 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 24 Sep 2010 13:19:37 -0400 Subject: [PATCH 27/61] Fix build --- upstart.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index c807fdc..efad485 100644 --- a/upstart.spec +++ b/upstart.spec @@ -82,7 +82,7 @@ ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ for file in initjobs/*.conf ; do - install -m 644 $file %{buildroot}/%{_sysconfdir}/init/$file + install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ done From 85706b32e85d7296439dbe3894c28a935085e581 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 29 Sep 2010 15:25:09 -0700 Subject: [PATCH 28/61] - Rebuilt for gcc bug 634757 --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index efad485..5f4dc42 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 10%{?dist} +Release: 11%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -162,6 +162,9 @@ rm -rf %{buildroot} %{_mandir}/man8/telinit.8.gz %changelog +* Wed Sep 29 2010 jkeating - 0.6.5-11 +- Rebuilt for gcc bug 634757 + * Fri Sep 24 2010 Bill Nottingham 0.6.5-10 - merge in basic boot jobs here (#637099) From 60860f398180a3a1bec043a724448cb2dea4924e Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 14 Oct 2010 16:22:47 +0200 Subject: [PATCH 29/61] disable -sysvinit due the conflicts with systemd (#635323) --- upstart.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 5f4dc42..ddfceb2 100644 --- a/upstart.spec +++ b/upstart.spec @@ -22,6 +22,7 @@ BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 Conflicts: initscripts < 9.12 Requires: sysvinit-userspace +Obsoletes: upstart-sysvinit %description Upstart is an event-based replacement for the /sbin/init daemon which @@ -68,15 +69,20 @@ mv %{buildroot}/sbin/reboot %{buildroot}/lib/upstart/reboot mv %{buildroot}/sbin/runlevel %{buildroot}/lib/upstart/runlevel mv %{buildroot}/sbin/shutdown %{buildroot}/lib/upstart/shutdown mv %{buildroot}/sbin/telinit %{buildroot}/lib/upstart/telinit -ln -sf upstart %{buildroot}/sbin/init ln -sf reboot %{buildroot}/lib/upstart/poweroff ln -sf reboot %{buildroot}/lib/upstart/halt +%if 0 +# disabled due the conflicts with systemd +ln -sf upstart %{buildroot}/sbin/init ln -sf ../lib/upstart/reboot %{buildroot}/sbin/halt ln -sf ../lib/upstart/reboot %{buildroot}/sbin/poweroff ln -sf ../lib/upstart/reboot %{buildroot}/sbin/reboot ln -sf ../lib/upstart/runlevel %{buildroot}/sbin/runlevel ln -sf ../lib/upstart/shutdown %{buildroot}/sbin/shutdown ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit +%endif +# Remove these files due the conflicts with systemd +rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown,telinit}.* # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* @@ -144,6 +150,8 @@ rm -rf %{buildroot} %{_mandir}/man8/stop.8.gz %{_mandir}/man8/reload.8.gz +%if 0 +# disabled due the conflicts with systemd %files sysvinit %defattr(-,root,root,-) /sbin/halt @@ -160,6 +168,7 @@ rm -rf %{buildroot} %{_mandir}/man8/runlevel.8.gz %{_mandir}/man8/shutdown.8.gz %{_mandir}/man8/telinit.8.gz +%endif %changelog * Wed Sep 29 2010 jkeating - 0.6.5-11 From 98a4f2d7fa3266544a22d7e5d9c603de71e00649 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 14 Oct 2010 16:23:06 +0200 Subject: [PATCH 30/61] upstart-0.6.5-12.fc15 --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index ddfceb2..2b61828 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 11%{?dist} +Release: 12%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -171,6 +171,9 @@ rm -rf %{buildroot} %endif %changelog +* Thu Oct 14 2010 Petr Lautrbach 0.6.5-12 +- Disable -sysvinit to avoid conflicts with systemd (#635323) + * Wed Sep 29 2010 jkeating - 0.6.5-11 - Rebuilt for gcc bug 634757 From f420835c3edc467e38f1b7825b6bf95735dc4d88 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 19 Oct 2010 12:14:51 +0200 Subject: [PATCH 31/61] Rename init(8) to upstart(7) (#644249) --- upstart.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 2b61828..5897ee9 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 12%{?dist} +Release: 13%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -81,6 +81,8 @@ ln -sf ../lib/upstart/runlevel %{buildroot}/sbin/runlevel ln -sf ../lib/upstart/shutdown %{buildroot}/sbin/shutdown ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit %endif +# Rename init.8.gz to upstart.7.gz (#644249) +mv %{buildroot}/%{_mandir}/man8/init.8 %{buildroot}/%{_mandir}/man7/upstart.7 # Remove these files due the conflicts with systemd rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown,telinit}.* @@ -171,6 +173,9 @@ rm -rf %{buildroot} %endif %changelog +* Tue Oct 19 2010 Petr Lautrbach 0.6.5-13 +- Rename init(8) to upstart(7) (#644249) + * Thu Oct 14 2010 Petr Lautrbach 0.6.5-12 - Disable -sysvinit to avoid conflicts with systemd (#635323) From 6ea36c75744159eb8447193f6de2f47b7d1bbf80 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 26 Oct 2010 17:35:41 +0200 Subject: [PATCH 32/61] send close fd command to shell first (#646894) --- upstart-close-fd.patch | 23 +++++++++++++++++++++++ upstart.spec | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 upstart-close-fd.patch diff --git a/upstart-close-fd.patch b/upstart-close-fd.patch new file mode 100644 index 0000000..04391d1 --- /dev/null +++ b/upstart-close-fd.patch @@ -0,0 +1,23 @@ +diff --git a/init/job_process.c b/init/job_process.c +index 8ce2f72..c2c96cb 100644 +--- a/init/job_process.c ++++ b/init/job_process.c +@@ -298,6 +298,7 @@ job_process_run (Job *job, + + /* Feed the script to the child process */ + if (shell) { ++ nih_local char *cmd = NULL; + NihIo *io; + + /* Clean up and close the reading end (we don't need it) */ +@@ -317,6 +318,10 @@ job_process_run (Job *job, + nih_free (err); + } + ++ /* Close leaking fd first */ ++ cmd = NIH_MUST (nih_sprintf (NULL, "<&%d- ;", fds[0])); ++ NIH_ZERO (nih_io_write (io, cmd, strlen (cmd))); ++ + NIH_ZERO (nih_io_write (io, script, strlen (script))); + nih_io_shutdown (io); + } diff --git a/upstart.spec b/upstart.spec index 5897ee9..054601e 100644 --- a/upstart.spec +++ b/upstart.spec @@ -17,6 +17,8 @@ Patch3: upstart-utmp.patch Patch4: upstart-reexec.patch # shutdown exits with nonzero exitcode when fails Patch5: upstart-shutdown-exitcode.patch +# send close fd command to shell first (#646894) +Patch6: upstart-close-fd.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 @@ -48,6 +50,7 @@ Drop-in replacement for the System V init tools, provided by Upstart. %patch3 -p1 -b .utmp %patch4 -p1 -b .reexec %patch5 -p1 -b .exitcode +%patch6 -p1 -b .closefd %build %configure --sbindir=/sbin --libdir=/%{_lib} From 6df30f1d93cd8c5d4e320d0b41da34abc4fe58f8 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 26 Oct 2010 17:36:34 +0200 Subject: [PATCH 33/61] upstart-0.6.5-14.fc15 --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 054601e..8bb1444 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 13%{?dist} +Release: 14%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -176,6 +176,9 @@ rm -rf %{buildroot} %endif %changelog +* Tue Oct 26 2010 Petr Lautrbach 0.6.5-14 +- send close fd command to shell first (#646894) + * Tue Oct 19 2010 Petr Lautrbach 0.6.5-13 - Rename init(8) to upstart(7) (#644249) From 40ea9ad01dd993ad6803727d996f5f27bb4e17ec Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 26 Oct 2010 17:35:41 +0200 Subject: [PATCH 34/61] send close fd command to shell first (#646894) --- upstart-close-fd.patch | 23 +++++++++++++++++++++++ upstart.spec | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 upstart-close-fd.patch diff --git a/upstart-close-fd.patch b/upstart-close-fd.patch new file mode 100644 index 0000000..04391d1 --- /dev/null +++ b/upstart-close-fd.patch @@ -0,0 +1,23 @@ +diff --git a/init/job_process.c b/init/job_process.c +index 8ce2f72..c2c96cb 100644 +--- a/init/job_process.c ++++ b/init/job_process.c +@@ -298,6 +298,7 @@ job_process_run (Job *job, + + /* Feed the script to the child process */ + if (shell) { ++ nih_local char *cmd = NULL; + NihIo *io; + + /* Clean up and close the reading end (we don't need it) */ +@@ -317,6 +318,10 @@ job_process_run (Job *job, + nih_free (err); + } + ++ /* Close leaking fd first */ ++ cmd = NIH_MUST (nih_sprintf (NULL, "<&%d- ;", fds[0])); ++ NIH_ZERO (nih_io_write (io, cmd, strlen (cmd))); ++ + NIH_ZERO (nih_io_write (io, script, strlen (script))); + nih_io_shutdown (io); + } diff --git a/upstart.spec b/upstart.spec index 607de6b..d259725 100644 --- a/upstart.spec +++ b/upstart.spec @@ -15,6 +15,8 @@ Patch3: upstart-utmp.patch Patch4: upstart-reexec.patch # shutdown exits with nonzero exitcode when fails Patch5: upstart-shutdown-exitcode.patch +# send close fd command to shell first (#646894) +Patch6: upstart-close-fd.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 @@ -34,6 +36,7 @@ during shutdown and supervising them while the system is running. %patch3 -p1 -b .utmp %patch4 -p1 -b .reexec %patch5 -p1 -b .exitcode +%patch6 -p1 -b .closefd %build %configure --sbindir=/sbin --libdir=/%{_lib} From 907b62673606c01d9769cb2860423d3d66bbf171 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 26 Oct 2010 18:04:19 +0200 Subject: [PATCH 35/61] upstart-0.6.5-7.fc13 --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index d259725..78bb641 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,6 +1,6 @@ Name: upstart Version: 0.6.5 -Release: 6%{?dist} +Release: 7%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -115,6 +115,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Tue Oct 26 2010 Petr Lautrbach 0.6.5-7 +- send close fd command to shell first (#646894) + * Tue Sep 21 2010 Petr Lautrbach 0.6.5-6 - set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) - exit shutdown with nonzero exitcode when fails shutdown From 07d626226cb2a2b18b3e468a49a34d429a5cb6f3 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 25 Oct 2010 15:11:25 +0200 Subject: [PATCH 36/61] use autoreconf for upstart-audit-events.patch --- upstart-audit-events.patch | 605 +------------------------------------ upstart.spec | 3 +- 2 files changed, 4 insertions(+), 604 deletions(-) diff --git a/upstart-audit-events.patch b/upstart-audit-events.patch index 07df654..f0a2892 100644 --- a/upstart-audit-events.patch +++ b/upstart-audit-events.patch @@ -1,45 +1,3 @@ -diff --git a/Makefile.in b/Makefile.in -index a9550df..bdd0def 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -49,17 +49,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ -@@ -132,6 +133,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ diff --git a/aclocal.m4 b/aclocal.m4 index 3d3673e..6e09291 100644 --- a/aclocal.m4 @@ -52,48 +10,6 @@ index 3d3673e..6e09291 100644 m4_include([m4/libnih.m4]) m4_include([m4/libtool.m4]) m4_include([m4/lock.m4]) -diff --git a/conf/Makefile.in b/conf/Makefile.in -index 29fd9b7..82c3f99 100644 ---- a/conf/Makefile.in -+++ b/conf/Makefile.in -@@ -46,17 +46,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - mkinstalldirs = $(install_sh) -d -@@ -100,6 +101,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ diff --git a/config.h.in b/config.h.in index 8a7d63f..8d000aa 100644 --- a/config.h.in @@ -108,212 +24,11 @@ index 8a7d63f..8d000aa 100644 /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H -diff --git a/configure b/configure -index 9bad2db..2f93ef5 100755 ---- a/configure -+++ b/configure -@@ -751,6 +751,7 @@ ac_subst_vars='am__EXEEXT_FALSE - am__EXEEXT_TRUE - LTLIBOBJS - LIBOBJS -+AUDIT_LDADD - DBUS_LIBS - DBUS_CFLAGS - NIH_DBUS_LIBS -@@ -938,6 +939,7 @@ with_included_gettext - with_libintl_prefix - with_local_libnih - enable_threading -+with_libaudit - enable_compiler_warnings - enable_compiler_optimisations - enable_compiler_coverage -@@ -1620,6 +1622,7 @@ Optional Packages: - --without-libintl-prefix don't search for libintl in includedir and libdir - --with-local-libnih[=DIR] - Use libnih from source tree DIR -+ --with-libaudit=auto/yes/no Add Linux audit support default=auto - - Some influential environment variables: - CC C compiler command -@@ -5220,13 +5223,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : - else - lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext -- (eval echo "\"\$as_me:5223: $ac_compile\"" >&5) -+ (eval echo "\"\$as_me:5226: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 -- (eval echo "\"\$as_me:5226: $NM \\\"conftest.$ac_objext\\\"\"" >&5) -+ (eval echo "\"\$as_me:5229: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 -- (eval echo "\"\$as_me:5229: output\"" >&5) -+ (eval echo "\"\$as_me:5232: output\"" >&5) - cat conftest.out >&5 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" -@@ -6431,7 +6434,7 @@ ia64-*-hpux*) - ;; - *-*-irix6*) - # Find out which ABI we are using. -- echo '#line 6434 "configure"' > conftest.$ac_ext -+ echo '#line 6437 "configure"' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? -@@ -7693,11 +7696,11 @@ else - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:7696: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:7699: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 -- echo "$as_me:7700: \$? = $ac_status" >&5 -+ echo "$as_me:7703: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. -@@ -8032,11 +8035,11 @@ else - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:8035: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:8038: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 -- echo "$as_me:8039: \$? = $ac_status" >&5 -+ echo "$as_me:8042: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. -@@ -8137,11 +8140,11 @@ else - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:8140: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:8143: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 -- echo "$as_me:8144: \$? = $ac_status" >&5 -+ echo "$as_me:8147: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized -@@ -8192,11 +8195,11 @@ else - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:8195: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:8198: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 -- echo "$as_me:8199: \$? = $ac_status" >&5 -+ echo "$as_me:8202: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized -@@ -10576,7 +10579,7 @@ else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 10579 "configure" -+#line 10582 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -@@ -10672,7 +10675,7 @@ else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 10675 "configure" -+#line 10678 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -@@ -17209,6 +17212,72 @@ fi - - # Checks for library functions. - -+ -+# Check whether --with-libaudit was given. -+if test "${with_libaudit+set}" = set; then : -+ withval=$with_libaudit; -+else -+ with_libaudit=auto -+fi -+ -+ -+ # Check for Linux auditing API -+ # -+ # libaudit detection -+ -+ if test x$with_libaudit = xno ; then -+ have_libaudit=no; -+ else -+ # See if we have audit daemon library -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for audit_log_user_message in -laudit" >&5 -+$as_echo_n "checking for audit_log_user_message in -laudit... " >&6; } -+if test "${ac_cv_lib_audit_audit_log_user_message+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-laudit $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char audit_log_user_message (); -+int -+main () -+{ -+return audit_log_user_message (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_audit_audit_log_user_message=yes -+else -+ ac_cv_lib_audit_audit_log_user_message=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_audit_audit_log_user_message" >&5 -+$as_echo "$ac_cv_lib_audit_audit_log_user_message" >&6; } -+if test "x$ac_cv_lib_audit_audit_log_user_message" = x""yes; then : -+ AUDIT_LDADD=-laudit -+fi -+ -+ fi -+ -+ if test x$AUDIT_LDADD != x ; then -+ -+$as_echo "#define HAVE_LIBAUDIT 1" >>confdefs.h -+ -+ fi -+ -+ - # Other checks - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include sbindir in PATH" >&5 - $as_echo_n "checking whether to include sbindir in PATH... " >&6; } diff --git a/configure.ac b/configure.ac -index fb79a13..3dc1550 100644 +index 49544e3..1513500 100644 --- a/configure.ac +++ b/configure.ac -@@ -54,6 +54,7 @@ AM_PROG_CC_C_O +@@ -40,6 +40,7 @@ AM_PROG_CC_C_O NIH_C_THREAD # Checks for library functions. @@ -321,174 +36,6 @@ index fb79a13..3dc1550 100644 # Other checks AC_MSG_CHECKING([whether to include sbindir in PATH]) -diff --git a/contrib/Makefile.in b/contrib/Makefile.in -index dfe910b..32c7ebd 100644 ---- a/contrib/Makefile.in -+++ b/contrib/Makefile.in -@@ -44,17 +44,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - mkinstalldirs = $(install_sh) -d -@@ -75,6 +76,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ -diff --git a/dbus/Makefile.in b/dbus/Makefile.in -index 8294845..38a55ad 100644 ---- a/dbus/Makefile.in -+++ b/dbus/Makefile.in -@@ -46,17 +46,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - mkinstalldirs = $(install_sh) -d -@@ -100,6 +101,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ -diff --git a/doc/Makefile.in b/doc/Makefile.in -index b17181c..add3022 100644 ---- a/doc/Makefile.in -+++ b/doc/Makefile.in -@@ -44,17 +44,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - mkinstalldirs = $(install_sh) -d -@@ -75,6 +76,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ -diff --git a/init/Makefile.in b/init/Makefile.in -index c677761..9ca3de6 100644 ---- a/init/Makefile.in -+++ b/init/Makefile.in -@@ -55,17 +55,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - mkinstalldirs = $(install_sh) -d -@@ -283,6 +284,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ diff --git a/m4/libaudit.m4 b/m4/libaudit.m4 new file mode 100644 index 0000000..6865fb8 @@ -584,154 +131,6 @@ index 0b49c10..9a772d5 100644 .PHONY: tests -diff --git a/util/Makefile.in b/util/Makefile.in -index 55e17e5..40776d5 100644 ---- a/util/Makefile.in -+++ b/util/Makefile.in -@@ -51,17 +51,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ -- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnih.m4 \ -- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lock.m4 \ -- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ -- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ -- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ -- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ -- $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ -- $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ -- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/visibility.m4 \ -- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wint_t.m4 \ -- $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/configure.ac -+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libaudit.m4 \ -+ $(top_srcdir)/m4/libnih.m4 $(top_srcdir)/m4/libtool.m4 \ -+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ -+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ -+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ -+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \ -+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf-posix.m4 \ -+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/size_max.m4 \ -+ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ -+ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ -+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ -+ $(top_srcdir)/configure.ac - am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) - mkinstalldirs = $(install_sh) -d -@@ -88,20 +89,24 @@ am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) - am__v_lt_0 = --silent - am_reboot_OBJECTS = reboot.$(OBJEXT) utmp.$(OBJEXT) - reboot_OBJECTS = $(am_reboot_OBJECTS) --reboot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -+reboot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -+ $(am__DEPENDENCIES_1) - am_runlevel_OBJECTS = runlevel.$(OBJEXT) utmp.$(OBJEXT) - runlevel_OBJECTS = $(am_runlevel_OBJECTS) --runlevel_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -+runlevel_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -+ $(am__DEPENDENCIES_1) - am_shutdown_OBJECTS = shutdown.$(OBJEXT) utmp.$(OBJEXT) sysv.$(OBJEXT) - nodist_shutdown_OBJECTS = $(am__objects_1) - shutdown_OBJECTS = $(am_shutdown_OBJECTS) $(nodist_shutdown_OBJECTS) - shutdown_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -+ $(am__DEPENDENCIES_1) - am_telinit_OBJECTS = telinit.$(OBJEXT) utmp.$(OBJEXT) sysv.$(OBJEXT) - nodist_telinit_OBJECTS = $(am__objects_1) - telinit_OBJECTS = $(am_telinit_OBJECTS) $(nodist_telinit_OBJECTS) - telinit_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -+ $(am__DEPENDENCIES_1) - am_test_initctl_OBJECTS = test_initctl-test_initctl.$(OBJEXT) \ - test_initctl-initctl.$(OBJEXT) - test_initctl_OBJECTS = $(am_test_initctl_OBJECTS) -@@ -118,14 +123,14 @@ test_sysv_OBJECTS = $(am_test_sysv_OBJECTS) \ - $(nodist_test_sysv_OBJECTS) - test_sysv_DEPENDENCIES = sysv.o utmp.o $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -- $(am__DEPENDENCIES_1) -+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) - am_test_telinit_OBJECTS = test_telinit-test_telinit.$(OBJEXT) \ - test_telinit-telinit.$(OBJEXT) - test_telinit_OBJECTS = $(am_test_telinit_OBJECTS) - test_telinit_DEPENDENCIES = sysv.o utmp.o com.ubuntu.Upstart.o \ - com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -- $(am__DEPENDENCIES_1) -+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) - test_telinit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_telinit_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -@@ -216,6 +221,7 @@ ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - AR = @AR@ -+AUDIT_LDADD = @AUDIT_LDADD@ - AUTOCONF = @AUTOCONF@ - AUTOHEADER = @AUTOHEADER@ - AUTOMAKE = @AUTOMAKE@ -@@ -419,7 +425,8 @@ reboot_SOURCES = \ - - reboot_LDADD = \ - $(LTLIBINTL) \ -- $(NIH_LIBS) -+ $(NIH_LIBS) \ -+ $(AUDIT_LDADD) - - runlevel_SOURCES = \ - runlevel.c \ -@@ -427,7 +434,8 @@ runlevel_SOURCES = \ - - runlevel_LDADD = \ - $(LTLIBINTL) \ -- $(NIH_LIBS) -+ $(NIH_LIBS) \ -+ $(AUDIT_LDADD) - - shutdown_SOURCES = \ - shutdown.c \ -@@ -441,7 +449,8 @@ shutdown_LDADD = \ - $(LTLIBINTL) \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - telinit_SOURCES = \ - telinit.c \ -@@ -455,7 +464,8 @@ telinit_LDADD = \ - $(LTLIBINTL) \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - com_ubuntu_Upstart_OUTPUTS = \ - com.ubuntu.Upstart.c \ -@@ -515,7 +525,8 @@ test_sysv_LDADD = \ - $(LTLIBINTL) \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - test_telinit_SOURCES = tests/test_telinit.c telinit.c - test_telinit_CFLAGS = $(AM_CFLAGS) -DTEST -@@ -525,7 +536,8 @@ test_telinit_LDADD = \ - com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/util/reboot.c b/util/reboot.c index 7a9c071..15028eb 100644 --- a/util/reboot.c diff --git a/upstart.spec b/upstart.spec index 8bb1444..00678d1 100644 --- a/upstart.spec +++ b/upstart.spec @@ -20,7 +20,7 @@ Patch5: upstart-shutdown-exitcode.patch # send close fd command to shell first (#646894) Patch6: upstart-close-fd.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: gettext, audit-libs-devel, expat-devel +BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 Conflicts: initscripts < 9.12 Requires: sysvinit-userspace @@ -53,6 +53,7 @@ Drop-in replacement for the System V init tools, provided by Upstart. %patch6 -p1 -b .closefd %build +autoreconf %configure --sbindir=/sbin --libdir=/%{_lib} make %{?_smp_mflags} From 25454a5bc6b775de8ee613025f29f9a2edf07740 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 25 Oct 2010 15:12:29 +0200 Subject: [PATCH 37/61] rename initjobs.tar.gz to initjobs-%{initscripts}.tar.gz --- .gitignore | 2 +- sources | 2 +- upstart.spec | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c70584d..440042a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ upstart-0.6.5.tar.gz -/initjobs.tar.gz +/initjobs-20101025.tar.gz diff --git a/sources b/sources index 104e863..e9f0aad 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ f9466bba72b655c2408353b64105853f upstart-0.6.5.tar.gz -972676df8c1f67d9b2761a1fb02d170f initjobs.tar.gz +f3ba8fbe72310e5c22751f1f90bd127b initjobs-20101025.tar.gz diff --git a/upstart.spec b/upstart.spec index 00678d1..5e657d8 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,3 +1,5 @@ +%define initscripts 20101025 + Name: upstart Version: 0.6.5 Release: 14%{?dist} @@ -9,7 +11,7 @@ URL: http://upstart.ubuntu.com Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf # These are taken from http://git.fedorahosted.org/git/?p=initscripts.git -Source2: initjobs.tar.gz +Source2: initjobs-%{initscripts}.tar.gz Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) @@ -93,7 +95,7 @@ rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown, # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ -for file in initjobs/*.conf ; do +for file in initjobs-%{initscripts}/*.conf ; do install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ done From 03b0903bf705ed2c435700d9e319785e43ec1470 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 25 Oct 2010 15:13:05 +0200 Subject: [PATCH 38/61] upstart-0.6.6-1.fc15 --- .gitignore | 2 +- sources | 2 +- upstart.spec | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 440042a..1b5fc53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -upstart-0.6.5.tar.gz +upstart-0.6.6.tar.gz /initjobs-20101025.tar.gz diff --git a/sources b/sources index e9f0aad..c382c6d 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -f9466bba72b655c2408353b64105853f upstart-0.6.5.tar.gz +5a2e9962a4cea719fbe07c33e2591b06 upstart-0.6.6.tar.gz f3ba8fbe72310e5c22751f1f90bd127b initjobs-20101025.tar.gz diff --git a/upstart.spec b/upstart.spec index 5e657d8..8f3dc6c 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,8 +1,8 @@ %define initscripts 20101025 Name: upstart -Version: 0.6.5 -Release: 14%{?dist} +Version: 0.6.6 +Release: 1%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -179,6 +179,10 @@ rm -rf %{buildroot} %endif %changelog +* Wed Oct 27 2010 Petr Lautrbach 0.6.6-1 +- upgrade to 0.6.6 +- boot jobs source renamed + * Tue Oct 26 2010 Petr Lautrbach 0.6.5-14 - send close fd command to shell first (#646894) From 077e54a5e5db2fab1a5daa1f6d722704eb506bb9 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 16 Nov 2010 22:23:12 -0500 Subject: [PATCH 39/61] Require /etc/rc.d/rc.sysinit to pull in new initscripts-legacy package when necessary. --- upstart.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/upstart.spec b/upstart.spec index 8f3dc6c..85e74a3 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 0.6.6 -Release: 1%{?dist} +Release: 2%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -25,7 +25,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 Conflicts: initscripts < 9.12 -Requires: sysvinit-userspace +Requires: sysvinit-userspace /etc/rc.d/rc.sysinit Obsoletes: upstart-sysvinit %description @@ -179,6 +179,9 @@ rm -rf %{buildroot} %endif %changelog +* Tue Nov 16 2010 Bill Nottingham 0.6.6-2 +- require /etc/rc.d/rc.sysinit to pull in new initscripts-legacy package where needed + * Wed Oct 27 2010 Petr Lautrbach 0.6.6-1 - upgrade to 0.6.6 - boot jobs source renamed From 3edc9e71569a56700a17d229b6d165b88502928b Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 29 Nov 2010 15:01:42 +0100 Subject: [PATCH 40/61] create missing files and directories according to /etc/tmpfiles.d/ --- tmpfiles.conf | 43 +++++++++++++++++++++++++++++++++++++++++++ upstart.spec | 3 +++ 2 files changed, 46 insertions(+) create mode 100644 tmpfiles.conf diff --git a/tmpfiles.conf b/tmpfiles.conf new file mode 100644 index 0000000..2f8d3b8 --- /dev/null +++ b/tmpfiles.conf @@ -0,0 +1,43 @@ +# tmpfiles - create missing directories in /var/{lock,run} according to +# /etc/tmpfiles.d/ + +start on stopping rcS + +task + +script + [ -d /etc/tmpfiles.d ] || exit 0 + + SELINUX_RESTORE= + + # Check SELinux status + SELINUX_STATE= + if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then + if [ -r "/selinux/enforce" ] ; then + SELINUX_STATE=$(cat "/selinux/enforce") + else + # assume enforcing if you can't read it + SELINUX_STATE=1 + fi + fi + + for i in /etc/tmpfiles.d/*; do + while read type path mode uid gid age; do + # only directories + [ -n "$type" ] || continue + [ $type = "d" ] || [ $type = "D" ] || continue + # only /var/run and /var/lock + [ $path != ${path#/var/run/} ] || [ $path != ${path#/var/lock/} ] || continue + if [ ! -d $path ]; then + mkdir -p $path || continue + SELINUX_RESTORE=1 + chmod $mode $path + chown $uid:$gid $path + fi + done < $i; + done + + if [ -n "$SELINUX_STATE" ] && [ -n "$SELINUX_RESTORE" ]; then + /sbin/restorecon -R /var/lock /var/run 2> /dev/null + fi +end script diff --git a/upstart.spec b/upstart.spec index 85e74a3..74edcfa 100644 --- a/upstart.spec +++ b/upstart.spec @@ -12,6 +12,8 @@ Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz Source1: init-system-dbus.conf # These are taken from http://git.fedorahosted.org/git/?p=initscripts.git Source2: initjobs-%{initscripts}.tar.gz +# create missing files and directories according to /etc/tmpfiles.d/ +Source3: tmpfiles.conf Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) @@ -95,6 +97,7 @@ rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown, # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ +install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init/ for file in initjobs-%{initscripts}/*.conf ; do install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ done From a26acc5633ef7cce3b528d89c770fe957e72dfe0 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 29 Nov 2010 15:02:12 +0100 Subject: [PATCH 41/61] upstart-0.6.6-3.fc15 --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 74edcfa..07e102d 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 0.6.6 -Release: 2%{?dist} +Release: 3%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -182,6 +182,9 @@ rm -rf %{buildroot} %endif %changelog +* Fri Nov 26 2010 Petr Lautrbach 0.6.6-3 +- create missing files and directories according to /etc/init/tmpfiles.conf + * Tue Nov 16 2010 Bill Nottingham 0.6.6-2 - require /etc/rc.d/rc.sysinit to pull in new initscripts-legacy package where needed From 360fa1af70c7b34fe9abbe37d9c1e8cf6e50af1c Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 6 Dec 2010 22:11:25 +0100 Subject: [PATCH 42/61] Stop tty and serial also on runlevel 's' - upstart-0.6.6-4.fc15 --- .gitignore | 2 +- sources | 2 +- upstart.spec | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1b5fc53..d4d1482 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ upstart-0.6.6.tar.gz -/initjobs-20101025.tar.gz +/initjobs-20101206.tar.gz diff --git a/sources b/sources index c382c6d..e694a4e 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ 5a2e9962a4cea719fbe07c33e2591b06 upstart-0.6.6.tar.gz -f3ba8fbe72310e5c22751f1f90bd127b initjobs-20101025.tar.gz +53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz diff --git a/upstart.spec b/upstart.spec index 07e102d..22a3973 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,8 +1,8 @@ -%define initscripts 20101025 +%define initscripts 20101206 Name: upstart Version: 0.6.6 -Release: 3%{?dist} +Release: 4%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -182,6 +182,9 @@ rm -rf %{buildroot} %endif %changelog +* Mon Dec 06 2010 Petr Lautrbach 0.6.6-4 +- Stop tty and serial also on runlevel 's' + * Fri Nov 26 2010 Petr Lautrbach 0.6.6-3 - create missing files and directories according to /etc/init/tmpfiles.conf From 89d1ab7597af086f471765bc0a5bcec5a04cef29 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Fri, 17 Dec 2010 18:56:17 +0100 Subject: [PATCH 43/61] upstart-utmp.patch rebased for 0.6.7 --- upstart-utmp.patch | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/upstart-utmp.patch b/upstart-utmp.patch index 255bc50..3d61bc3 100644 --- a/upstart-utmp.patch +++ b/upstart-utmp.patch @@ -1,18 +1,18 @@ diff --git a/init/job_class.c b/init/job_class.c -index b521cf4..1b8d1cf 100644 +index eeec83d..00eb13d 100644 --- a/init/job_class.c +++ b/init/job_class.c -@@ -218,6 +218,8 @@ job_class_new (const void *parent, +@@ -219,6 +219,8 @@ job_class_new (const void *parent, class->chroot = NULL; class->chdir = NULL; + class->utmp_id = NULL; + class->deleted = FALSE; + class->debug = FALSE; - return class; diff --git a/init/job_class.h b/init/job_class.h -index b7d4eed..1d29c59 100644 +index d40e750..e5b5190 100644 --- a/init/job_class.h +++ b/init/job_class.h @@ -145,6 +145,7 @@ typedef struct job_class { @@ -22,9 +22,9 @@ index b7d4eed..1d29c59 100644 + char *utmp_id; int deleted; - } JobClass; + int debug; diff --git a/init/job_process.c b/init/job_process.c -index e3080d8..8ce2f72 100644 +index 282bf17..996000b 100644 --- a/init/job_process.c +++ b/init/job_process.c @@ -38,6 +38,8 @@ @@ -36,7 +36,7 @@ index e3080d8..8ce2f72 100644 #include #include -@@ -361,11 +363,13 @@ job_process_spawn (JobClass *class, +@@ -359,11 +361,13 @@ job_process_spawn (JobClass *class, char * const *env, int trace) { @@ -55,7 +55,7 @@ index e3080d8..8ce2f72 100644 nih_assert (class != NULL); -@@ -524,6 +528,20 @@ job_process_spawn (JobClass *class, +@@ -556,6 +560,20 @@ job_process_spawn (JobClass *class, } } @@ -76,7 +76,7 @@ index e3080d8..8ce2f72 100644 /* Execute the process, if we escape from here it failed */ if (execvp (argv[0], argv) < 0) { nih_error_raise_system (); -@@ -967,6 +985,8 @@ job_process_terminated (Job *job, +@@ -999,6 +1017,8 @@ job_process_terminated (Job *job, int status) { int failed = FALSE, stop = FALSE, state = TRUE; @@ -85,7 +85,7 @@ index e3080d8..8ce2f72 100644 nih_assert (job != NULL); -@@ -1129,6 +1149,36 @@ job_process_terminated (Job *job, +@@ -1161,6 +1181,36 @@ job_process_terminated (Job *job, job->kill_process = -1; } @@ -123,7 +123,7 @@ index e3080d8..8ce2f72 100644 job->pid[process] = 0; diff --git a/init/tests/test_job_process.c b/init/tests/test_job_process.c -index d43fa6e..b4f94e4 100644 +index 5946da8..1454afe 100644 --- a/init/tests/test_job_process.c +++ b/init/tests/test_job_process.c @@ -36,6 +36,8 @@ @@ -135,7 +135,7 @@ index d43fa6e..b4f94e4 100644 #include #include -@@ -4474,6 +4476,171 @@ test_find (void) +@@ -4501,6 +4503,171 @@ test_find (void) } @@ -307,7 +307,7 @@ index d43fa6e..b4f94e4 100644 int main (int argc, char *argv[]) -@@ -4505,6 +4672,7 @@ main (int argc, +@@ -4532,6 +4699,7 @@ main (int argc, test_spawn (); test_kill (); test_handler (); From 039741aedd71ae0ec966af2e0b8175a56be10587 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Fri, 17 Dec 2010 18:56:45 +0100 Subject: [PATCH 44/61] upstart-0.6.7 --- upstart.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/upstart.spec b/upstart.spec index 22a3973..540a9de 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,8 +1,8 @@ %define initscripts 20101206 Name: upstart -Version: 0.6.6 -Release: 4%{?dist} +Version: 0.6.7 +Release: 1%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -182,6 +182,9 @@ rm -rf %{buildroot} %endif %changelog +* Fri Dec 17 2010 Petr Lautrbach 0.6.7-1 +- upgrade to 0.6.7 + * Mon Dec 06 2010 Petr Lautrbach 0.6.6-4 - Stop tty and serial also on runlevel 's' From 1891e83e6755057d9d713b70c74268b2a702379e Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Fri, 17 Dec 2010 19:32:31 +0100 Subject: [PATCH 45/61] upstart-0.6.7.tar.gz --- .gitignore | 1 + sources | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d4d1482..78795c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ upstart-0.6.6.tar.gz /initjobs-20101206.tar.gz +/upstart-0.6.7.tar.gz diff --git a/sources b/sources index e694a4e..caea663 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -5a2e9962a4cea719fbe07c33e2591b06 upstart-0.6.6.tar.gz +37740f81b6d12a53072603fadee451c9 upstart-0.6.7.tar.gz 53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz From c36c4032a31b5146d8cc1e054277f4cfac4915a4 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Mon, 7 Feb 2011 18:33:35 -0600 Subject: [PATCH 46/61] - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 540a9de..731ce26 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 0.6.7 -Release: 1%{?dist} +Release: 2%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -182,6 +182,9 @@ rm -rf %{buildroot} %endif %changelog +* Mon Feb 07 2011 Fedora Release Engineering - 0.6.7-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + * Fri Dec 17 2010 Petr Lautrbach 0.6.7-1 - upgrade to 0.6.7 From 2944a231852a343da3bf0a8cda93b140af620808 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Fri, 4 Mar 2011 14:51:14 +0100 Subject: [PATCH 47/61] upstart-1.0-1.fc16 --- .gitignore | 1 + sources | 2 +- upstart-utmp.patch | 255 ++------------------------------------------- upstart.spec | 12 +-- 4 files changed, 17 insertions(+), 253 deletions(-) diff --git a/.gitignore b/.gitignore index 78795c2..8a23c35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ upstart-0.6.6.tar.gz /initjobs-20101206.tar.gz /upstart-0.6.7.tar.gz +/upstart-1.0.tar.gz diff --git a/sources b/sources index caea663..3a75af1 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -37740f81b6d12a53072603fadee451c9 upstart-0.6.7.tar.gz 53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz +bbcdf7580d5cd35b4b1da44bcb12de9f upstart-1.0.tar.gz diff --git a/upstart-utmp.patch b/upstart-utmp.patch index 3d61bc3..ccda548 100644 --- a/upstart-utmp.patch +++ b/upstart-utmp.patch @@ -24,19 +24,10 @@ index d40e750..e5b5190 100644 int deleted; int debug; diff --git a/init/job_process.c b/init/job_process.c -index 282bf17..996000b 100644 +index 70fa2bf..544f5e3 100644 --- a/init/job_process.c +++ b/init/job_process.c -@@ -38,6 +38,8 @@ - #include - #include - #include -+#include -+#include - - #include - #include -@@ -359,11 +361,13 @@ job_process_spawn (JobClass *class, +@@ -361,11 +361,13 @@ job_process_spawn (JobClass *class, char * const *env, int trace) { @@ -55,7 +46,7 @@ index 282bf17..996000b 100644 nih_assert (class != NULL); -@@ -556,6 +560,20 @@ job_process_spawn (JobClass *class, +@@ -558,6 +560,20 @@ job_process_spawn (JobClass *class, } } @@ -76,242 +67,14 @@ index 282bf17..996000b 100644 /* Execute the process, if we escape from here it failed */ if (execvp (argv[0], argv) < 0) { nih_error_raise_system (); -@@ -999,6 +1017,8 @@ job_process_terminated (Job *job, - int status) - { - int failed = FALSE, stop = FALSE, state = TRUE; -+ struct utmpx *utmptr; -+ struct timeval tv; - - nih_assert (job != NULL); - -@@ -1161,6 +1181,36 @@ job_process_terminated (Job *job, - job->kill_process = -1; - } - -+ /* Find existing utmp entry for the process pid */ -+ setutxent(); -+ while ((utmptr = getutxent()) != NULL) { -+ if (utmptr->ut_pid == job->pid[process]) { -+ /* set type and clean ut_user, ut_host, -+ * ut_time as described in utmp(5) -+ */ -+ utmptr->ut_type = DEAD_PROCESS; -+ memset(utmptr->ut_user, 0, UT_NAMESIZE); -+ memset(utmptr->ut_host, 0, UT_HOSTSIZE); -+ utmptr->ut_time = 0; +@@ -1176,6 +1192,10 @@ job_process_terminated (Job *job, + memset(utmptr->ut_user, 0, UT_NAMESIZE); + memset(utmptr->ut_host, 0, UT_HOSTSIZE); + utmptr->ut_time = 0; + + /* Set class utmp_id for next spawn */ + job->class->utmp_id = nih_strdup (job->class, utmptr->ut_id); + -+ /* Update existing utmp file. */ -+ pututxline(utmptr); -+ -+ /* set ut_time for log */ -+ gettimeofday(&tv, NULL); -+ utmptr->ut_tv.tv_sec = tv.tv_sec; -+ utmptr->ut_tv.tv_usec = tv.tv_usec; -+ /* Write wtmp entry */ -+ updwtmpx (_PATH_WTMP, utmptr); -+ -+ break; -+ } -+ } -+ endutxent(); -+ - /* Clear the process pid field */ - job->pid[process] = 0; - -diff --git a/init/tests/test_job_process.c b/init/tests/test_job_process.c -index 5946da8..1454afe 100644 ---- a/init/tests/test_job_process.c -+++ b/init/tests/test_job_process.c -@@ -36,6 +36,8 @@ - #include - #include - #include -+#include -+#include - - #include - #include -@@ -4501,6 +4503,171 @@ test_find (void) - } - - -+void -+test_utmp (void) -+{ -+ JobClass * class; -+ Job * job = NULL; -+ Blocked * blocked = NULL; -+ Event * event; -+ FILE * output; -+ char utmpname[PATH_MAX]; -+ struct utmpx utmp, *utmptr; -+ struct timeval tv; -+ -+ TEST_FUNCTION ("job_process_handler"); -+ program_name = "test"; -+ -+ class = job_class_new (NULL, "test"); -+ class->process[PROCESS_MAIN] = process_new (class); -+ class->process[PROCESS_MAIN]->command = "echo"; -+ -+ class->start_on = event_operator_new (class, EVENT_MATCH, -+ "foo", NULL); -+ class->stop_on = event_operator_new (class, EVENT_MATCH, -+ "foo", NULL); -+ nih_hash_add (job_classes, &class->entry); -+ -+ event = event_new (NULL, "foo", NULL); -+ -+ TEST_FILENAME(utmpname); -+ -+ /* Check that utmp record for the running task of the job terminating -+ * is properly changed to DEAD_PROCESS -+ */ -+ TEST_FEATURE ("with LOGIN_PROCESS utmp entry"); -+ TEST_ALLOC_FAIL { -+ TEST_ALLOC_SAFE { -+ job = job_new (class, ""); -+ -+ blocked = blocked_new (job, BLOCKED_EVENT, event); -+ event_block (event); -+ nih_list_add (&job->blocking, &blocked->entry); -+ } -+ -+ job->goal = JOB_START; -+ job->state = JOB_RUNNING; -+ job->pid[PROCESS_MAIN] = 1; -+ -+ TEST_FREE_TAG (blocked); -+ -+ job->blocker = NULL; -+ event->failed = FALSE; -+ -+ job->failed = FALSE; -+ job->failed_process = -1; -+ job->exit_status = 0; -+ -+ output = fopen (utmpname, "w"); -+ fclose (output); -+ -+ /* set utmp file */ -+ utmpxname(utmpname); -+ -+ /* set up utmp entries */ -+ memset (&utmp, 0, sizeof utmp); -+ -+ strcpy(utmp.ut_id, "2"); -+ utmp.ut_type = LOGIN_PROCESS; -+ utmp.ut_pid = 2; -+ -+ gettimeofday(&tv, NULL); -+ utmp.ut_tv.tv_sec = tv.tv_sec; -+ utmp.ut_tv.tv_usec = tv.tv_usec; -+ -+ setutxent(); -+ pututxline(&utmp); -+ -+ strcpy(utmp.ut_id, "1"); -+ utmp.ut_pid = 1; -+ pututxline(&utmp); -+ -+ endutxent(); -+ -+ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); -+ -+ setutxent(); -+ -+ utmptr = getutxent(); -+ TEST_NE_P(utmptr, NULL); -+ TEST_EQ(utmptr->ut_pid, 2); -+ TEST_EQ(utmptr->ut_type, LOGIN_PROCESS); -+ -+ utmptr = getutxent(); -+ TEST_NE_P(utmptr, NULL); -+ TEST_EQ(utmptr->ut_pid, 1); -+ TEST_EQ(utmptr->ut_type, DEAD_PROCESS); -+ -+ nih_free (job); -+ } -+ TEST_FEATURE ("with USER_PROCESS utmp entry"); -+ TEST_ALLOC_FAIL { -+ TEST_ALLOC_SAFE { -+ job = job_new (class, ""); -+ -+ blocked = blocked_new (job, BLOCKED_EVENT, event); -+ event_block (event); -+ nih_list_add (&job->blocking, &blocked->entry); -+ } -+ -+ job->goal = JOB_START; -+ job->state = JOB_RUNNING; -+ job->pid[PROCESS_MAIN] = 1; -+ -+ TEST_FREE_TAG (blocked); -+ -+ job->blocker = NULL; -+ event->failed = FALSE; -+ -+ job->failed = FALSE; -+ job->failed_process = -1; -+ job->exit_status = 0; -+ -+ output = fopen (utmpname, "w"); -+ fclose (output); -+ -+ /* set utmp file */ -+ utmpxname(utmpname); -+ -+ /* set up utmp entries */ -+ memset (&utmp, 0, sizeof utmp); -+ -+ strcpy(utmp.ut_id, "2"); -+ utmp.ut_type = USER_PROCESS; -+ utmp.ut_pid = 2; -+ -+ gettimeofday(&tv, NULL); -+ utmp.ut_tv.tv_sec = tv.tv_sec; -+ utmp.ut_tv.tv_usec = tv.tv_usec; -+ -+ setutxent(); -+ pututxline(&utmp); -+ -+ strcpy(utmp.ut_id, "1"); -+ utmp.ut_pid = 1; -+ pututxline(&utmp); -+ -+ endutxent(); -+ -+ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); -+ -+ setutxent(); -+ -+ utmptr = getutxent(); -+ TEST_NE_P(utmptr, NULL); -+ TEST_EQ(utmptr->ut_pid, 2); -+ TEST_EQ(utmptr->ut_type, USER_PROCESS); -+ -+ utmptr = getutxent(); -+ TEST_NE_P(utmptr, NULL); -+ TEST_EQ(utmptr->ut_pid, 1); -+ TEST_EQ(utmptr->ut_type, DEAD_PROCESS); -+ -+ nih_free (job); -+ } -+} -+ -+ - int - main (int argc, - char *argv[]) -@@ -4532,6 +4699,7 @@ main (int argc, - test_spawn (); - test_kill (); - test_handler (); -+ test_utmp (); - - test_find (); + /* Update existing utmp file. */ + pututxline(utmptr); diff --git a/upstart.spec b/upstart.spec index 731ce26..d1ac266 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,14 +1,14 @@ %define initscripts 20101206 Name: upstart -Version: 0.6.7 -Release: 2%{?dist} +Version: 1.0 +Release: 1%{?dist} Summary: An event-driven init system Group: System Environment/Base License: GPLv2 and LGPLv2+ URL: http://upstart.ubuntu.com -Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz +Source0: http://launchpad.net/upstart/1.x/1.0/+download/upstart-%{version}.tar.gz Source1: init-system-dbus.conf # These are taken from http://git.fedorahosted.org/git/?p=initscripts.git Source2: initjobs-%{initscripts}.tar.gz @@ -19,8 +19,6 @@ Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) Patch3: upstart-utmp.patch Patch4: upstart-reexec.patch -# shutdown exits with nonzero exitcode when fails -Patch5: upstart-shutdown-exitcode.patch # send close fd command to shell first (#646894) Patch6: upstart-close-fd.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -53,7 +51,6 @@ Drop-in replacement for the System V init tools, provided by Upstart. %patch2 -p1 -b .audit %patch3 -p1 -b .utmp %patch4 -p1 -b .reexec -%patch5 -p1 -b .exitcode %patch6 -p1 -b .closefd %build @@ -182,6 +179,9 @@ rm -rf %{buildroot} %endif %changelog +* Thu Mar 03 2011 Petr Lautrbach 1.0-1 +- upgrade to 1.0 - https://launchpad.net/upstart/1.x/1.0 + * Mon Feb 07 2011 Fedora Release Engineering - 0.6.7-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild From 4bbee5dbc7f94e59342cd8ca45968364e2c62391 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 15 Mar 2011 16:14:49 +0100 Subject: [PATCH 48/61] move jobs to /lib/upstart/init and make symlinks in /etc/init --- upstart.spec | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/upstart.spec b/upstart.spec index d1ac266..28e820d 100644 --- a/upstart.spec +++ b/upstart.spec @@ -69,7 +69,7 @@ make install DESTDIR=%{buildroot} mv %{buildroot}/sbin/init %{buildroot}/sbin/upstart rm %{buildroot}/sbin/halt rm %{buildroot}/sbin/poweroff -mkdir -p -m 755 %{buildroot}/lib/upstart +mkdir -p -m 755 %{buildroot}/lib/upstart/init mv %{buildroot}/sbin/reboot %{buildroot}/lib/upstart/reboot mv %{buildroot}/sbin/runlevel %{buildroot}/lib/upstart/runlevel mv %{buildroot}/sbin/shutdown %{buildroot}/lib/upstart/shutdown @@ -93,10 +93,10 @@ rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown, # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* -install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ -install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init/ +install -m 644 %{SOURCE1} %{buildroot}/lib/upstart/init/ +install -m 644 %{SOURCE3} %{buildroot}/lib/upstart/init/ for file in initjobs-%{initscripts}/*.conf ; do - install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ + install -m 644 $file %{buildroot}/lib/upstart/init/ done @@ -112,8 +112,36 @@ done %clean rm -rf %{buildroot} -%triggerpostun -- upstart < 0.6.0 -[ -f /proc/1/exe -a -d /proc/1/root ] && kill -TERM 1 +%post +#create symlinks to /lib/upstart/init after instalation +if [ $1 -eq 1 ]; then + cd /lib/upstart/init + for j in *.conf; do + if [ ! -e /etc/init/$j ]; then + ln -sf /lib/upstart/init/$j /etc/init + fi + done +fi + +%postun +#remove broken symlinks from /etc/init +if [ $1 -eq 0 ]; then + for j in $(find -L /etc/init/ -type l); do + if ls -l $j | grep -q '/lib/upstart/init/'; then + rm -f $j + fi + done +fi + +%triggerpostun -- upstart < 1.0-2 +#version before 1.0-2 didn't use symlinks to /lib/upstart/init +cd /lib/upstart/init +for j in *.conf; do + if [ ! -e /etc/init/$j ]; then + ln -sf /lib/upstart/init/$j /etc/init + fi +done +initctl reload-configuration || : %files -f %{name}.lang %defattr(-,root,root,-) @@ -123,7 +151,8 @@ rm -rf %{buildroot} %doc README %doc TODO %doc HACKING -%{_sysconfdir}/init/ +%dir %{_sysconfdir}/init/ +/lib/upstart/init/ %config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf %dir /lib/upstart /lib/upstart/halt From 310c5468af465013e26171b24e0bf36db7c5a080 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 15 Mar 2011 16:15:10 +0100 Subject: [PATCH 49/61] upstart-1.0-2.fc16 --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 28e820d..c0db8ef 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 1.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -208,6 +208,9 @@ initctl reload-configuration || : %endif %changelog +* Tue Mar 15 2011 Petr Lautrbach 1.0-2 +- introduce /lib/upstart/init/ as place for jobs defaults + * Thu Mar 03 2011 Petr Lautrbach 1.0-1 - upgrade to 1.0 - https://launchpad.net/upstart/1.x/1.0 From 6daa74388e5c9ec0b52bb04120b834783851f00f Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 17 Mar 2011 18:35:53 +0100 Subject: [PATCH 50/61] remove /lib/upstart/init experiment --- upstart.spec | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/upstart.spec b/upstart.spec index c0db8ef..4740b16 100644 --- a/upstart.spec +++ b/upstart.spec @@ -69,7 +69,7 @@ make install DESTDIR=%{buildroot} mv %{buildroot}/sbin/init %{buildroot}/sbin/upstart rm %{buildroot}/sbin/halt rm %{buildroot}/sbin/poweroff -mkdir -p -m 755 %{buildroot}/lib/upstart/init +mkdir -p -m 755 %{buildroot}/lib/upstart mv %{buildroot}/sbin/reboot %{buildroot}/lib/upstart/reboot mv %{buildroot}/sbin/runlevel %{buildroot}/lib/upstart/runlevel mv %{buildroot}/sbin/shutdown %{buildroot}/lib/upstart/shutdown @@ -93,10 +93,10 @@ rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown, # don't ship default jobs rm -f %{buildroot}/%{_sysconfdir}/init/* -install -m 644 %{SOURCE1} %{buildroot}/lib/upstart/init/ -install -m 644 %{SOURCE3} %{buildroot}/lib/upstart/init/ +install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ +install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init/ for file in initjobs-%{initscripts}/*.conf ; do - install -m 644 $file %{buildroot}/lib/upstart/init/ + install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ done @@ -112,37 +112,6 @@ done %clean rm -rf %{buildroot} -%post -#create symlinks to /lib/upstart/init after instalation -if [ $1 -eq 1 ]; then - cd /lib/upstart/init - for j in *.conf; do - if [ ! -e /etc/init/$j ]; then - ln -sf /lib/upstart/init/$j /etc/init - fi - done -fi - -%postun -#remove broken symlinks from /etc/init -if [ $1 -eq 0 ]; then - for j in $(find -L /etc/init/ -type l); do - if ls -l $j | grep -q '/lib/upstart/init/'; then - rm -f $j - fi - done -fi - -%triggerpostun -- upstart < 1.0-2 -#version before 1.0-2 didn't use symlinks to /lib/upstart/init -cd /lib/upstart/init -for j in *.conf; do - if [ ! -e /etc/init/$j ]; then - ln -sf /lib/upstart/init/$j /etc/init - fi -done -initctl reload-configuration || : - %files -f %{name}.lang %defattr(-,root,root,-) %doc AUTHORS @@ -151,8 +120,7 @@ initctl reload-configuration || : %doc README %doc TODO %doc HACKING -%dir %{_sysconfdir}/init/ -/lib/upstart/init/ +%{_sysconfdir}/init/ %config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf %dir /lib/upstart /lib/upstart/halt From 7538863f6a26638211f92f97ba1fca15c9e6efeb Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 21 Mar 2011 09:45:59 +0100 Subject: [PATCH 51/61] upstart-1.1-1.fc16, enable .override files --- .gitignore | 1 + sources | 2 +- upstart-override.patch | 5145 ++++++++++++++++++++++++++++++++++++++++ upstart.spec | 17 +- 4 files changed, 5158 insertions(+), 7 deletions(-) create mode 100644 upstart-override.patch diff --git a/.gitignore b/.gitignore index 8a23c35..38380bc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ upstart-0.6.6.tar.gz /initjobs-20101206.tar.gz /upstart-0.6.7.tar.gz /upstart-1.0.tar.gz +/upstart-1.1.tar.gz diff --git a/sources b/sources index 3a75af1..cb6545b 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ 53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz -bbcdf7580d5cd35b4b1da44bcb12de9f upstart-1.0.tar.gz +9e9ce9d5e3936e59331f478d8a436e00 upstart-1.1.tar.gz diff --git a/upstart-override.patch b/upstart-override.patch new file mode 100644 index 0000000..7989d57 --- /dev/null +++ b/upstart-override.patch @@ -0,0 +1,5145 @@ +diff --git a/init/conf.c b/init/conf.c +index 89d2cd3..a5a9b85 100644 +--- a/init/conf.c ++++ b/init/conf.c +@@ -49,7 +49,7 @@ + #include "parse_conf.h" + #include "conf.h" + #include "errors.h" +- ++#include "paths.h" + + /* Prototypes for static functions */ + static int conf_source_reload_file (ConfSource *source) +@@ -71,9 +71,19 @@ static int conf_file_visitor (ConfSource *source, + struct stat *statbuf) + __attribute__ ((warn_unused_result)); + +-static int conf_reload_path (ConfSource *source, const char *path) ++static int conf_reload_path (ConfSource *source, const char *path, ++ const char *override_path) ++ __attribute__ ((warn_unused_result)); ++ ++static inline int is_conf_file (const char *path) + __attribute__ ((warn_unused_result)); + ++static inline int is_conf_file_std (const char *path) ++ __attribute__ ((warn_unused_result)); ++ ++static inline int ++is_conf_file_override (const char *path) ++ __attribute__ ((warn_unused_result)); + + /** + * conf_sources: +@@ -86,6 +96,115 @@ NihList *conf_sources = NULL; + + + /** ++ * is_conf_file_std: ++ * @path: path to check. ++ * ++ * Determine if specified path contains a legitimate ++ * configuration file name. ++ * ++ * Returns: TRUE if @path contains a valid configuration file name, ++ * else FALSE. ++ * ++ **/ ++static inline int ++is_conf_file_std (const char *path) ++{ ++ char *ptr = strrchr (path, '.'); ++ ++ if (ptr && IS_CONF_EXT_STD (ptr)) ++ return TRUE; ++ ++ return FALSE; ++} ++ ++/** ++ * is_conf_file_override: ++ * @path: path to check. ++ * ++ * Determine if specified path contains a legitimate ++ * override file name. ++ * ++ * Returns: TRUE if @path contains a valid override file name, ++ * else FALSE. ++ * ++ **/ ++static inline int ++is_conf_file_override (const char *path) ++{ ++ char *ptr = strrchr (path, '.'); ++ ++ if (ptr && IS_CONF_EXT_OVERRIDE (ptr)) ++ return TRUE; ++ ++ return FALSE; ++} ++ ++/** ++ * is_conf_file: ++ * @path: path to check. ++ * ++ * Determine if specified path contains a legitimate ++ * configuration file or override file name. ++ * ++ * Returns: TRUE if @path contains a valid configuration ++ * file or override file name, else FALSE. ++ * ++ **/ ++static inline int ++is_conf_file (const char *path) ++{ ++ char *ptr = strrchr (path, '.'); ++ ++ if (ptr && (ptr > path) && (ptr[-1] != '/') && IS_CONF_EXT (ptr)) ++ return TRUE; ++ ++ return FALSE; ++} ++ ++/** ++ * Convert a configuration file name to an override file name and vice ++ * versa. ++ * ++ * For example, if @path is "foo.conf", this function will return ++ * "foo.override", whereas if @path is "foo.override", it will return ++ * "foo.conf". ++ * ++ * Note that this function should be static, but isn't to allow the ++ * tests to access it. ++ * ++ * @parent: parent of returned path, ++ * @path: path to a configuration file. ++ * ++ * Returns: newly allocated toggled path, or NULL on error. ++ **/ ++char * ++toggle_conf_name (const void *parent, ++ const char *path) ++{ ++ char *new_path; ++ char *ext; ++ char *new_ext; ++ size_t len; ++ ++ ext = strrchr (path, '.'); ++ if (!ext) ++ return NULL; ++ ++ new_ext = IS_CONF_EXT_STD (ext) ++ ? CONF_EXT_OVERRIDE ++ : CONF_EXT_STD; ++ ++ len = strlen (new_ext); ++ ++ new_path = NIH_MUST (nih_strndup (parent, path, (ext - path) + len)); ++ ++ memcpy (new_path + (ext - path), new_ext, len); ++ ++ return new_path; ++} ++ ++ ++/** + * conf_init: + * + * Initialise the conf_sources list. +@@ -233,10 +352,9 @@ conf_reload (void) + NihError *err; + + err = nih_error_get (); +- if (err->number != ENOENT) +- nih_error ("%s: %s: %s", source->path, +- _("Unable to load configuration"), +- err->message); ++ nih_error ("%s: %s: %s", source->path, ++ _("Unable to load configuration"), ++ err->message); + nih_free (err); + } + } +@@ -329,10 +447,16 @@ static int + conf_source_reload_file (ConfSource *source) + { + NihError *err = NULL; ++ nih_local char *override_path = NULL; ++ ++ struct stat statbuf; + + nih_assert (source != NULL); + nih_assert (source->type == CONF_FILE); + ++ /* this function should only be called for standard ++ * configuration files. ++ */ + if (! source->watch) { + nih_local char *dpath = NULL; + char *dname; +@@ -361,7 +485,7 @@ conf_source_reload_file (ConfSource *source) + /* Parse the file itself. If this fails, then we can discard the + * inotify error, since this one will be better. + */ +- if (conf_reload_path (source, source->path) < 0) { ++ if (conf_reload_path (source, source->path, NULL) < 0) { + if (err) + nih_free (err); + +@@ -382,6 +506,26 @@ conf_source_reload_file (ConfSource *source) + nih_free (err); + } + ++ if (! is_conf_file_std (source->path)) ++ return 0; ++ ++ override_path = toggle_conf_name (NULL, source->path); ++ ++ if (stat (override_path, &statbuf) != 0) ++ return 0; ++ ++ nih_debug ("Updating configuration for %s from %s", ++ source->path, override_path); ++ if (conf_reload_path (source, source->path, override_path) < 0) { ++ NihError *err; ++ ++ err = nih_error_get (); ++ nih_error ("%s: %s: %s", override_path, ++ _("Error while reloading configuration file"), ++ err->message); ++ nih_free (err); ++ } ++ + return 0; + } + +@@ -501,19 +645,18 @@ conf_file_filter (ConfSource *source, + * @is_dir: TRUE of @path is a directory. + * + * This is the file filter used for the jobs directory, we only care +- * about paths with the ".conf" extension. Directories that +- * match the nih_file_ignore() function are also ignored. ++ * about paths with particular extensions (see IS_CONF_EXT). ++ * ++ * Directories that match the nih_file_ignore() function are also ignored. + * +- * Returns: FALSE if @path ends in ".conf", or is the original source, +- * TRUE otherwise. ++ * Returns: FALSE if @path ends in ".conf" or ".override", ++ * or is the original source, TRUE otherwise. + **/ + static int + conf_dir_filter (ConfSource *source, + const char *path, + int is_dir) + { +- char *ptr; +- + nih_assert (source != NULL); + nih_assert (path != NULL); + +@@ -523,8 +666,7 @@ conf_dir_filter (ConfSource *source, + if (is_dir) + return nih_file_ignore (NULL, path); + +- ptr = strrchr (path, '.'); +- if (ptr && (ptr > path) && (ptr[-1] != '/') && (! strcmp (ptr, ".conf"))) ++ if (is_conf_file (path)) + return FALSE; + + return TRUE; +@@ -546,29 +688,92 @@ conf_dir_filter (ConfSource *source, + * After checking that it was a regular file that was changed, we reload it; + * we expect this to fail sometimes since the file may be only partially + * written. +- **/ ++ **/ + static void + conf_create_modify_handler (ConfSource *source, + NihWatch *watch, + const char *path, + struct stat *statbuf) + { ++ ConfFile *file = NULL; ++ const char *error_path = path; ++ nih_local char *new_path = NULL; ++ int ret; ++ + nih_assert (source != NULL); + nih_assert (watch != NULL); + nih_assert (path != NULL); + nih_assert (statbuf != NULL); + ++ /* note that symbolic links are ignored */ + if (! S_ISREG (statbuf->st_mode)) + return; + +- if (conf_reload_path (source, path) < 0) { ++ new_path = toggle_conf_name (NULL, path); ++ file = (ConfFile *)nih_hash_lookup (source->files, new_path); ++ ++ if (is_conf_file_override (path)) { ++ if (! file) { ++ /* override file has no corresponding conf file */ ++ nih_debug ("Ignoring orphan override file %s", path); ++ return; ++ } ++ ++ /* reload conf file */ ++ nih_debug ("Loading configuration file %s", new_path); ++ ret = conf_reload_path (source, new_path, NULL); ++ if (ret < 0) { ++ error_path = new_path; ++ goto error; ++ } ++ ++ /* overlay override settings */ ++ nih_debug ("Loading override file %s for %s", path, new_path); ++ ret = conf_reload_path (source, new_path, path); ++ if (ret < 0) { ++ error_path = path; ++ goto error; ++ } ++ } else { ++ nih_debug ("Loading configuration and override files for %s", path); ++ ++ /* load conf file */ ++ nih_debug ("Loading configuration file %s", path); ++ ret = conf_reload_path (source, path, NULL); ++ if (ret < 0) { ++ error_path = path; ++ goto error; ++ } ++ ++ /* ensure we ignore directory changes (which won't have overrides. */ ++ if (is_conf_file_std (path)) { ++ struct stat st; ++ if (stat (new_path, &st) == 0) { ++ /* overlay override settings */ ++ nih_debug ("Loading override file %s for %s", new_path, path); ++ ret = conf_reload_path (source, path, new_path); ++ if (ret < 0) { ++ error_path = new_path; ++ goto error; ++ } ++ } ++ ++ } ++ } ++ ++ return; ++ ++error: ++ { + NihError *err; + + err = nih_error_get (); +- nih_error ("%s: %s: %s", path, +- _("Error while loading configuration file"), +- err->message); ++ nih_error ("%s: %s: %s", error_path, ++ _("Error while loading configuration file"), ++ err->message); + nih_free (err); ++ if (file) ++ nih_unref (file, source); + } + } + +@@ -585,13 +790,14 @@ conf_create_modify_handler (ConfSource *source, + * + * We lookup the file in our hash table, and if we can find it, perform + * the usual deletion of it. +- **/ ++ **/ + static void + conf_delete_handler (ConfSource *source, + NihWatch *watch, + const char *path) + { + ConfFile *file; ++ nih_local char *new_path = NULL; + + nih_assert (source != NULL); + nih_assert (watch != NULL); +@@ -603,7 +809,11 @@ conf_delete_handler (ConfSource *source, + * it's probably a directory or something, so just ignore it. + */ + file = (ConfFile *)nih_hash_lookup (source->files, path); +- if (! file) { ++ /* Note we have to be careful to consider deletion of directories too. ++ * This is handled implicitly by the override check which will return ++ * false if passed a directory in this case. ++ */ ++ if (! file && ! is_conf_file_override (path)) { + if (! strcmp (watch->path, path)) { + nih_warn ("%s: %s", source->path, + _("Configuration directory deleted")); +@@ -614,7 +824,30 @@ conf_delete_handler (ConfSource *source, + return; + } + +- nih_unref (file, source); ++ /* non-override files (and directories) are the simple case, so handle ++ * them and leave. ++ */ ++ if (! is_conf_file_override (path)) { ++ nih_unref (file, source); ++ return; ++ } ++ ++ /* if an override file is deleted for which there is a corresponding ++ * conf file, reload the conf file to remove any modifications ++ * introduced by the override file. ++ */ ++ new_path = toggle_conf_name (NULL, path); ++ file = (ConfFile *)nih_hash_lookup (source->files, new_path); ++ ++ if (file) { ++ nih_debug ("Reloading configuration for %s on deletion of overide (%s)", ++ new_path, path); ++ ++ if ( conf_reload_path (source, new_path, NULL) < 0 ) { ++ nih_warn ("%s: %s", new_path, ++ _("Unable to reload configuration after override deletion")); ++ } ++ } + } + + /** +@@ -637,22 +870,61 @@ conf_file_visitor (ConfSource *source, + const char *path, + struct stat *statbuf) + { ++ ConfFile *file = NULL; ++ nih_local char *new_path = NULL; ++ + nih_assert (source != NULL); + nih_assert (dirname != NULL); + nih_assert (path != NULL); + nih_assert (statbuf != NULL); + ++ /* We assume that CONF_EXT_STD files are visited before ++ * CONF_EXT_OVERRIDE files. Happily, this assumption is currently ++ * valid since CONF_EXT_STD comes before CONF_EXT_OVERRIDE if ordered ++ * alphabetically. ++ * ++ * If this were ever to change (for example if we decided to ++ * rename the CONF_EXT_OVERRIDE files to end in ".abc", say), the logic ++ * in this function would be erroneous since it would never be possible when ++ * visiting an override file (before a conf file) to lookup a conf file ++ * in the hash, since the conf file would not yet have been seen and thus would ++ * not exist in the hash (yet). ++ */ ++ nih_assert (CONF_EXT_STD[1] < CONF_EXT_OVERRIDE[1]); ++ + if (! S_ISREG (statbuf->st_mode)) + return 0; + +- if (conf_reload_path (source, path) < 0) { +- NihError *err; ++ if (is_conf_file_std (path)) { ++ if (conf_reload_path (source, path, NULL) < 0) { ++ NihError *err; + +- err = nih_error_get (); +- nih_error ("%s: %s: %s", path, +- _("Error while loading configuration file"), +- err->message); +- nih_free (err); ++ err = nih_error_get (); ++ nih_error ("%s: %s: %s", path, ++ _("Error while loading configuration file"), ++ err->message); ++ nih_free (err); ++ } ++ return 0; ++ } ++ ++ new_path = toggle_conf_name (NULL, path); ++ file = (ConfFile *)nih_hash_lookup (source->files, new_path); ++ ++ if (file) { ++ /* we're visiting an override file with an associated conf file that ++ * has already been loaded, so just overlay the override file. If ++ * there is no corresponding conf file, we ignore the override file. ++ */ ++ if (conf_reload_path (source, new_path, path) < 0) { ++ NihError *err; ++ ++ err = nih_error_get (); ++ nih_error ("%s: %s: %s", new_path, ++ _("Error while reloading configuration file"), ++ err->message); ++ nih_free (err); ++ } + } + + return 0; +@@ -662,12 +934,15 @@ conf_file_visitor (ConfSource *source, + /** + * conf_reload_path: + * @source: configuration source, +- * @path: path of file to be reloaded. ++ * @path: path of conf file to be reloaded. ++ * @override_path: if TRUE and @path refers to a path associated with @source, ++ * overlay the contents of @path into the existing @source entry for ++ * @path. If FALSE, discard any existing knowledge of @path. + * +- * This function is used to parse the file at @path in the context of the +- * given configuration @source. Necessary ConfFile structures are allocated +- * and attached to @source as appropriate. CONF_FILE sources always have +- * a single ConfFile when the file exists. ++ * This function is used to parse the file at @path (or @override_path) in the ++ * context of the given configuration @source. Necessary ConfFile structures ++ * are allocated and attached to @source as appropriate. CONF_FILE sources ++ * always have a single ConfFile when the file exists. + * + * If the file has been parsed before, then the existing item is deleted and + * freed if the file fails to load, or after the new item has been parsed. +@@ -679,36 +954,43 @@ conf_file_visitor (ConfSource *source, + **/ + static int + conf_reload_path (ConfSource *source, +- const char *path) ++ const char *path, ++ const char *override_path) + { +- ConfFile *file; ++ ConfFile *file = NULL; + nih_local char *buf = NULL; + const char *start, *end; + nih_local char *name = NULL; + size_t len, pos, lineno; + NihError *err = NULL; ++ const char *path_to_load; + + nih_assert (source != NULL); + nih_assert (path != NULL); + +- /* Look up the old file in memory, and then free it. In cases +- * of failure, we discard it anyway, so there's no particular reason ++ path_to_load = ( override_path ? override_path : path); ++ ++ /* If there is no corresponding override file, look up the old ++ * conf file in memory, and then free it. In cases of failure, ++ * we discard it anyway, so there's no particular reason + * to keep it around anymore. + */ + file = (ConfFile *)nih_hash_lookup (source->files, path); +- if (file) ++ if (! override_path && file) + nih_unref (file, source); + + /* Read the file into memory for parsing, if this fails we don't + * bother creating a new ConfFile structure for it and bail out + * now. + */ +- buf = nih_file_read (NULL, path, &len); ++ buf = nih_file_read (NULL, path_to_load, &len); + if (! buf) + return -1; + +- /* Parse the file, storing the item in a new ConfFile structure. */ +- file = NIH_MUST (conf_file_new (source, path)); ++ /* Create a new ConfFile structure (if no override_path was specified) */ ++ file = (ConfFile *)nih_hash_lookup (source->files, path); ++ if (! file) ++ file = NIH_MUST (conf_file_new (source, path)); + + pos = 0; + lineno = 1; +@@ -717,7 +999,14 @@ conf_reload_path (ConfSource *source, + case CONF_FILE: + case CONF_DIR: + /* Simple file of options; usually no item attached to it. */ +- nih_debug ("Loading configuration from %s", path); ++ if (override_path) { ++ nih_debug ("Updating configuration for %s from %s", ++ path, override_path); ++ } else { ++ nih_debug ("Loading configuration from %s %s", ++ (source->type == CONF_DIR ? "directory" : "file"), path); ++ } ++ + if (parse_conf (file, buf, len, &pos, &lineno) < 0) + err = nih_error_get (); + +@@ -735,7 +1024,7 @@ conf_reload_path (ConfSource *source, + start++; + + end = strrchr (start, '.'); +- if (end && (! strcmp (end, ".conf"))) { ++ if (end && IS_CONF_EXT (end)) { + name = NIH_MUST (nih_strndup (NULL, start, end - start)); + } else { + name = NIH_MUST (nih_strdup (NULL, start)); +@@ -744,8 +1033,14 @@ conf_reload_path (ConfSource *source, + /* Create a new job item and parse the buffer to produce + * the job definition. + */ +- nih_debug ("Loading %s from %s", name, path); +- file->job = parse_job (NULL, name, buf, len, &pos, &lineno); ++ if (override_path) { ++ nih_debug ("Updating %s (%s) with %s", ++ name, path, override_path); ++ } else { ++ nih_debug ("Loading %s from %s", name, path); ++ } ++ file->job = parse_job (NULL, file->job, ++ name, buf, len, &pos, &lineno); + if (file->job) { + job_class_consider (file->job); + } else { +@@ -779,7 +1074,7 @@ conf_reload_path (ConfSource *source, + case PARSE_EXPECTED_OPERATOR: + case PARSE_EXPECTED_VARIABLE: + case PARSE_MISMATCHED_PARENS: +- nih_error ("%s:%zi: %s", path, lineno, err->message); ++ nih_error ("%s:%zi: %s", path_to_load, lineno, err->message); + nih_free (err); + err = NULL; + break; +@@ -882,3 +1177,149 @@ conf_select_job (const char *name) + + return NULL; + } ++ ++#ifdef DEBUG ++ ++size_t ++debug_count_list_entries (const NihList *list) ++{ ++ size_t i = 0; ++ NIH_LIST_FOREACH (list, iter) { ++ i++; ++ } ++ return i; ++} ++ ++size_t ++debug_count_hash_entries (const NihHash *hash) ++{ ++ size_t i = 0; ++ NIH_HASH_FOREACH_SAFE (hash, iter) { ++ i++; ++ } ++ return i; ++} ++ ++void ++debug_show_job_class (const JobClass *job) ++{ ++ int i; ++ char **env = (char **)job->env; ++ char **export = (char **)job->export; ++ ++ nih_assert (job); ++ ++ nih_debug ("JobClass %p: name='%s', path='%s', task=%d, " ++ "respawn=%d, console=%x, deleted=%d, debug=%d", ++ job, job->name, job->path, job->task, ++ job->respawn, job->console, job->deleted, job->debug); ++ ++ nih_debug ("\tstart_on=%p, stop_on=%p, emits=%p, process=%p", ++ job->start_on, job->stop_on, job->emits, job->process); ++ ++ nih_debug ("\tauthor='%s', description='%s'", ++ job->author, job->description); ++ ++ if (env && *env) { ++ nih_debug ("\tenv:"); ++ i = 0; ++ while ( *env ) { ++ nih_debug ("\t\tenv[%d]='%s' (len=%u+1)", ++ i, *env, strlen (*env)); ++ env++; ++ ++i; ++ } ++ } else { ++ nih_debug ("\tenv: none."); ++ } ++ ++ ++ if (export && *export) { ++ nih_debug ("\texport:"); ++ i = 0; ++ while ( *export ) { ++ nih_debug ("\t\tenv[%d]='%s' (len=%u+1)", ++ i, *export, strlen (*export)); ++ export++; ++ ++i; ++ } ++ } ++ else { ++ nih_debug ("\texport: none"); ++ } ++} ++ ++void ++debug_show_job_classes (void) ++{ ++ nih_debug ("job_classes:"); ++ ++ NIH_HASH_FOREACH_SAFE (job_classes, iter) { ++ JobClass *job = (JobClass *)iter; ++ debug_show_job_class (job); ++ } ++} ++ ++void ++debug_show_event (const Event *event) ++{ ++ nih_assert (event); ++ ++ nih_debug ("Event %p: name='%s', progress=%x, failed=%d, " ++ "blockers=%d, blocking=%p", ++ event, event->name, event->progress, event->failed, ++ event->blockers, (void *)&event->blocking); ++} ++ ++void ++debug_show_conf_file (const ConfFile *file) ++{ ++ nih_assert (file); ++ ++ nih_debug ("ConfFile %p: path='%s', source=%p, flag=%x, job=%p", ++ file, file->path, file->source, file->flag, file->job); ++ ++ /* Some ConfFile objects won't have any JobClass details, for example, ++ * the ConfFile object associated with "/etc/init.conf". ++ */ ++ if (! file->job) { ++ nih_debug ("ConfFile %p: job: no JobClass object.", file); ++ return; ++ } ++ ++ nih_debug ("ConfFile %p: job:", file); ++ debug_show_job_class (file->job); ++} ++ ++void ++debug_show_conf_source (const ConfSource *source) ++{ ++ nih_assert (source); ++ ++ nih_debug ("ConfSource %p: path='%s', type=%x, flag=%x", ++ source, source->path, source->type, source->flag); ++ ++ nih_debug ("ConfSource %p files (%d):", source, ++ debug_count_hash_entries (source->files)); ++ ++ NIH_HASH_FOREACH (source->files, file_iter) { ++ ConfFile *file = (ConfFile *)file_iter; ++ debug_show_conf_file (file); ++ } ++} ++ ++void ++debug_show_conf_sources (void) ++{ ++ nih_assert (conf_sources); ++ ++ nih_debug ("conf_sources:"); ++ ++ NIH_LIST_FOREACH (conf_sources, iter) { ++ ConfSource *source = (ConfSource *)iter; ++ debug_show_conf_source (source); ++ } ++} ++ ++#endif /* DEBUG */ ++ +diff --git a/init/conf.h b/init/conf.h +index d6915f3..bac02ac 100644 +--- a/init/conf.h ++++ b/init/conf.h +@@ -124,6 +124,46 @@ int conf_file_destroy (ConfFile *file); + + JobClass * conf_select_job (const char *name); + ++char *toggle_conf_name (const void *parent, const char *path) ++ __attribute__ ((warn_unused_result, malloc)); ++ ++#ifdef DEBUG ++ ++/* used for debugging only */ ++ ++size_t ++debug_count_hash_entries (const NihHash *hash); ++ ++size_t ++debug_count_list_entries (const NihList *list) ++ __attribute__ ((unused)); ++ ++void ++debug_show_job_class (const JobClass *job) ++ __attribute__ ((unused)); ++ ++void ++debug_show_job_classes (void) ++ __attribute__ ((unused)); ++ ++void ++debug_show_event (const Event *event) ++ __attribute__ ((unused)); ++ ++void ++debug_show_conf_file(const ConfFile *file) ++ __attribute__ ((unused)); ++ ++void ++debug_show_conf_source(const ConfSource *source) ++ __attribute__ ((unused)); ++ ++void ++debug_show_conf_sources(void) ++ __attribute__ ((unused)); ++ ++#endif ++ + NIH_END_EXTERN + + #endif /* INIT_CONF_H */ +diff --git a/init/man/init.5 b/init/man/init.5 +index 73fff91..56a4d0e 100644 +--- a/init/man/init.5 ++++ b/init/man/init.5 +@@ -1,42 +1,79 @@ +-.TH init 5 2010-12-14 "Upstart" ++.TH init 5 2011-01-12 "Upstart" + .\" + .SH NAME + init \- Upstart init daemon job configuration + .\" + .SH SYNOPSIS +-.B /etc/init ++.B /etc/init/ + .\" + .SH DESCRIPTION + On startup, the Upstart + .BR init (8) +-daemon reads its job configuration from the +-.I /etc/init +-directory, and watches for future changes using ++daemon reads its job configuration from files in the ++.I /etc/init/ ++directory, and watches for future changes to these files using + .BR inotify (7). + +-Files in this directory must end in +-.I .conf +-and may also be present in sub-directories. ++To be considered by Upstart, files in this directory must have a ++recognized suffix and may also be present in sub-directories. There are ++two recognized suffixes: + +-Each file defines a single service or task, with the name taken from its +-relative path within the directory without the extension. For example a +-job defined in ++.IP \(bu 4 ++Files ending in ++.I .conf ++are called configuration files, or simply "conf files" for short. ++These are the primary vehicle for specifying a job. ++.IP \(bu 4 ++Files ending in ++.I .override ++are called override files. If an override file is present, the stanzas ++it contains take precedence over those equivalently named stanzas in the ++corresponding configuration file contents for a particular job. ++The main use for override files is to modify how a job will run without ++having to modify its configuration file directly. See the section ++\fBOverride File Handling\fP below for further details. ++.P ++A job can thus be defined by either: ++.IP \[bu] 2 ++A single configuration file. ++.IP \[bu] ++A single configuration file \fBand\fP a single override file. ++.P ++Unless explicitly stated otherwise, any reference to a jobs ++configuration can refer both to a configuration file or an override ++file. ++ ++Each configuration file defines the template for a single \fIservice\fP ++(long-running process or daemon) or \fItask\fP (short-lived process). ++ ++Note that a configuration file is not itself a job: it is a description ++of an environmenta job could be run in. A job is the runtime embodiment ++of a configuration file. ++ ++The configuration file name as displayed by Upstart and associated ++tooling is taken from its relative path within the directory without the ++extension. For example a configuration file + .I /etc/init/rc-sysinit.conf + is named + .IR rc-sysinit , +-while a job defined in ++while a configuration file + .I /etc/init/net/apache.conf + is named + .IR net/apache . ++Since override files only modify the way a configuration file is ++interpreted, they are not named. + +-These files are plain text and should not be executable. ++Configuration files are plain text and should not be executable. + .\" +-.SS Format ++.SS Configuration File Format + Each line begins with a configuration stanza and continues until either + the end of the line or a line containing a closing stanza. Line breaks + within a stanza are permitted within single or double quotes, or if + preceeded by a blackslash. + ++If a stanza is duplicated, the last occurence will be used. Unrecognized ++stanzas will generate parse errors, which will stop a job from running. ++ + Stanzas and their arguments are delimited by whitespace, which consists + of one or more space or tab characters which are otherwise ignored unless + placed within single or double quotes. +@@ -144,10 +181,10 @@ event is emitted. It is typically used to clean up the environment, + such as removing temporary directories. + + .PP +-All of these processes, including the main process, are optional. Services +-without a main process will appear to be running until they are stopped, +-this is commonly used to define states such as runlevels. It's quite +-permissable to have no main process, but to have ++All of these processes, including the main process, are optional. ++Services without a main process will appear to be running until they are ++stopped: this is commonly used to define states such as runlevels. It ++is permissable to have no main process, but to have + .B pre-start + and + .B post-stop +@@ -249,7 +286,7 @@ The + .B stop on + stanza defines the set of events that will cause the job to be automatically + stopped. It has the same syntax as +-.B start on ++\fBstart on\fP. + + .I VALUE + may additionally expand the value of any variable that came from the +@@ -306,7 +343,8 @@ utility to default to acting on the job the commands are called from. + .B env \fIKEY\fR[=\fIVALUE\fR] + Defines a default environment variable, the value of which may be overriden + by the event or command that starts the job. +-If no value is given, then the value is taken from the ++If \'KEY=VALUE\' is specified, the variable KEY is given the value VALUE. ++If only \'KEY\' is given, then the value is taken from the + .BR init (8) + daemon's own environment. + .\" +@@ -366,7 +404,7 @@ Respawning is subject to a limit, if the job is respawned more than + times in + .I INTERVAL + seconds, it will be considered to be having deeper problems and will +-be stopped. ++be stopped. Default COUNT is 10. Default INTERVAL is 5 seconds. + + This only applies to automatic respawns and not the + .BR restart (8) +@@ -385,7 +423,8 @@ normal exit 0 1 TERM HUP + .SS Instances + By default, only one instance of any job is permitted to exist at one + time. Attempting to start a job when it's already starting or running +-results in an error. ++results in an error. Note that a job is considered to be running if its ++pre-start process is running. + + Multiple instances may be permitted by defining the names of those + instances. If an instance with the same name is not already starting +@@ -561,6 +600,46 @@ value, both of which are integers. The special value + .B unlimited + may be specified for either. + .\" ++.SS Override File Handling ++Override files allow a jobs environment to be changed without modifying ++the jobs configuration file. Rules governing override files: ++ ++.IP \[bu] 2 ++If a job is embodied with only a configuration file, the contents of ++this file define the job. ++.IP \[bu] ++If an override files exists where there is no existing cofiguration ++file, the override file is ignored. ++.IP \[bu] ++If both a configuration file \fBand\fP an override file exist for a job ++and both files are syntactically correct: ++.RS ++.IP \[bu] 2 ++stanzas in the override file will take precedence over stanzas present ++in the corresponding configuration file. ++.IP \[bu] ++stanzas in the override file which are not present in the corresponding ++configuration file will be honoured when the job runs. ++.RE ++.IP \[bu] ++If both a configuration file and an override file exist for a job and ++subsequently the override file is deleted, the configuration file is ++automatically reloaded with the effect that any changes introduced by ++the override file are undone and the configuration file alone now defines ++the job. ++.IP \[bu] ++If both a configuration file and an override file exist for a job and ++subsequently the configuration file is deleted, a new instance of the ++job can no longer be started (since without a corresponding ++configuration file an override file is ignored). ++.IP \[bu] ++If both a configuration file and an override file exist for a job and ++any of the contents of the override file are invalid, the override file ++is ignored and only the contents of the configuration file are ++considered. ++.P ++ ++.\" + .SS Miscellaneous + .TP + .B kill timeout \fIINTERVAL +@@ -568,7 +647,7 @@ Specifies the interval between sending the job's main process the + .I SIGTERM + and + .I SIGKILL +-signals when stopping the running job. ++signals when stopping the running job. Default is 5 seconds. + .\" + .TP + .B expect stop +@@ -609,6 +688,48 @@ Without this stanza + is unable to supervise forking processes and will believe them to have + stopped as soon as they fork on startup. + .\" ++.SH BUGS ++The ++.B and ++and ++.B or ++operators allowed with ++.B start on ++and ++.B stop on ++do not work intuitively: operands to the right of either operator are ++only evaluated once and state information is then discarded. This can ++lead to jobs with complex \fBstart on\fP or \fPstop on\fP conditions ++not behaving as expected \fIwhen restarted\fP. For example, if a job ++encodes the following condition: ++.ti +4 ++.sp 1 ++.nf ++start on A and (B or C) ++.fi ++ ++When 'A' and 'B' become true, the condition is satisfied so the job will ++be run. However, if the job ends and subsequently 'A' and 'C' become true, ++the job will \fInot\fP be re-run even though the condtion is satisfied. ++Avoid using complex conditions with jobs which need to be restarted. ++.\" ++.SH AUTHOR ++Manual page written by Scott James Remnant ++.RB < scott@netsplit.com > ++and James Hunt ++.RB < james.hunt@canonical.com > . ++.\" ++.SH REPORTING BUGS ++Report bugs at ++.RB < https://launchpad.net/upstart/+bugs > ++.\" ++.SH COPYRIGHT ++Copyright \(co 2010 Canonical Ltd. ++.br ++This is free software; see the source for copying conditions. There is NO ++warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++ ++.\" + .SH SEE ALSO + .BR init (8) + .BR sh (1) +diff --git a/init/parse_job.c b/init/parse_job.c +index 4e05454..76d3145 100644 +--- a/init/parse_job.c ++++ b/init/parse_job.c +@@ -263,6 +263,7 @@ static NihConfigStanza stanzas[] = { + /** + * parse_job: + * @parent: parent object for new job, ++ * @update: If not NULL, update the existing specified JobClass, + * @name: name of new job, + * @file: file or string to parse, + * @len: length of @file, +@@ -278,10 +279,12 @@ static NihConfigStanza stanzas[] = { + * of the returned job are freed, the returned job will also be + * freed. + * +- * Returns: new JobClass structure on success, NULL on raised error. ++ * Returns: if @update is NULL, returns new JobClass structure on success, NULL on raised error. ++ * If @update is not NULL, returns @update or NULL on error. + **/ + JobClass * + parse_job (const void *parent, ++ JobClass *update, + const char *name, + const char *file, + size_t len, +@@ -294,13 +297,22 @@ parse_job (const void *parent, + nih_assert (file != NULL); + nih_assert (pos != NULL); + +- class = job_class_new (parent, name); ++ if (update) { ++ class = update; ++ nih_debug ("Reusing JobClass %s (%s)", ++ class->name, class->path); ++ } else { ++ nih_debug ("Creating new JobClass %s", ++ name); ++ class = job_class_new (parent, name); ++ } + if (! class) + nih_return_system_error (NULL); + + if (nih_config_parse_file (file, len, pos, lineno, + stanzas, class) < 0) { +- nih_free (class); ++ if (!update) ++ nih_free (class); + return NULL; + } + +diff --git a/init/parse_job.h b/init/parse_job.h +index f98f70c..65a205f 100644 +--- a/init/parse_job.h ++++ b/init/parse_job.h +@@ -27,8 +27,8 @@ + + NIH_BEGIN_EXTERN + +-JobClass *parse_job (const void *parent, const char *name, +- const char *file, size_t len, ++JobClass *parse_job (const void *parent, JobClass *update, ++ const char *name, const char *file, size_t len, + size_t *pos, size_t *lineno) + __attribute__ ((warn_unused_result, malloc)); + +diff --git a/init/paths.h b/init/paths.h +index d7c6fa4..c7ddec1 100644 +--- a/init/paths.h ++++ b/init/paths.h +@@ -103,5 +103,55 @@ + #define TELINIT SBINDIR "/telinit" + #endif + ++/** ++ * File extension for standard configuration files. ++ **/ ++#define CONF_EXT_STD ".conf" ++ ++/** ++ * File extension for override files. ++ * ++ * Note that override files are not stored in the ConfSource 'files' hash: ++ * all JobClass information from override files is added to the JobClass for ++ * the corresponding (CONF_EXT_STD) object. ++ **/ ++#define CONF_EXT_OVERRIDE ".override" ++ ++/** ++ * Determine if specified path extension representes a standard ++ * configuration file. ++ * ++ * @period: pointer to last period in path to check. ++ * ++ * Returns 1 if specified path extension matches that for a ++ * standard configuration file, else return 0. ++ **/ ++#define IS_CONF_EXT_STD(period) \ ++ (!strcmp (period, CONF_EXT_STD)) ++ ++/** ++ * Determine if specified path extension representes an ++ * override file. ++ * ++ * @period: pointer to last period in path to check. ++ * ++ * Returns 1 if specified path extension matches that for ++ * an override file, else return 0. ++ **/ ++#define IS_CONF_EXT_OVERRIDE(period) \ ++ (!strcmp (period, CONF_EXT_OVERRIDE)) ++ ++/** ++ * Determine if specified filename has a valid configuration ++ * file name extension. ++ * ++ * @period: pointer to last period in filename. ++ * ++ * Returns: TRUE if extension beyond @period is one of the ++ * recognized types, else FALSE. ++ **/ ++#define IS_CONF_EXT(period) \ ++ (IS_CONF_EXT_STD(period) || \ ++ IS_CONF_EXT_OVERRIDE(period)) + + #endif /* INIT_PATHS_H */ +diff --git a/init/tests/test_conf.c b/init/tests/test_conf.c +index 35730b7..9a504de 100644 +--- a/init/tests/test_conf.c ++++ b/init/tests/test_conf.c +@@ -47,6 +47,50 @@ + #include "job.h" + #include "conf.h" + ++/* macro to try and ensure the environment is as pristine as possible ++ * (to avoid follow-on errors caused by not freeing objects in a ++ * previous test, say) ++ */ ++#define TEST_ENSURE_CLEAN_ENV() \ ++{ \ ++ setvbuf(stdout, NULL, _IONBF, 0); \ ++ \ ++ if (job_classes) { \ ++ TEST_HASH_EMPTY (job_classes); \ ++ } \ ++ \ ++ if (conf_sources) { \ ++ TEST_LIST_EMPTY (conf_sources); \ ++ } \ ++ \ ++ if (nih_io_watches) { \ ++ TEST_LIST_EMPTY (nih_io_watches); \ ++ } \ ++ \ ++ if (nih_timers) { \ ++ TEST_LIST_EMPTY (nih_timers); \ ++ } \ ++ \ ++ if (events) { \ ++ TEST_LIST_EMPTY (events); \ ++ } \ ++} ++ ++/* Force an inotify watch update */ ++#define TEST_FORCE_WATCH_UPDATE() \ ++{ \ ++ int nfds = 0; \ ++ fd_set readfds, writefds, exceptfds; \ ++ \ ++ FD_ZERO (&readfds); \ ++ FD_ZERO (&writefds); \ ++ FD_ZERO (&exceptfds); \ ++ \ ++ nih_debug("calling nih_io_select_fds"); \ ++ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); \ ++ nih_debug("calling nih_io_handle_fds"); \ ++ nih_io_handle_fds (&readfds, &writefds, &exceptfds); \ ++} + + void + test_source_new (void) +@@ -2417,40 +2461,70 @@ no_inotify: + } + } + +- + void +-test_source_reload_file (void) ++test_toggle_conf_name (void) + { +- ConfSource *source; +- ConfFile *file, *old_file; +- FILE *f; +- int ret, fd[4096], i = 0, nfds; +- char dirname[PATH_MAX]; +- char tmpname[PATH_MAX], filename[PATH_MAX]; +- fd_set readfds, writefds, exceptfds; +- NihError *err; ++ char override_ext[] = ".override"; ++ char dirname[PATH_MAX]; ++ char filename[PATH_MAX]; ++ JobClass *job; ++ char *f; ++ char *p; + +- TEST_FUNCTION_FEATURE ("conf_source_reload", +- "with configuration file"); +- program_name = "test"; +- nih_log_set_priority (NIH_LOG_FATAL); ++ TEST_FUNCTION_FEATURE ("toggle_conf_name", ++ "changing conf to override"); + + TEST_FILENAME (dirname); +- mkdir (dirname, 0755); +- + strcpy (filename, dirname); + strcat (filename, "/foo.conf"); ++ f = toggle_conf_name (NULL, filename); ++ TEST_NE_P (f, NULL); + +- f = fopen (filename, "w"); +- fprintf (f, "#nothing to test\n"); +- fclose (f); ++ p = strstr (f, ".override"); ++ TEST_NE_P (p, NULL); ++ TEST_EQ_P (p, f+strlen (f) - strlen (override_ext)); ++ nih_free (f); + ++ TEST_FEATURE ("changing override to conf"); + strcpy (filename, dirname); +- strcat (filename, "/bar.conf"); ++ strcat (filename, "/bar.override"); ++ f = toggle_conf_name (NULL, filename); ++ TEST_NE_P (f, NULL); + +- f = fopen (filename, "w"); +- fprintf (f, "#nothing to test\n"); +- fclose (f); ++ p = strstr (f, ".conf"); ++ TEST_NE_P (p, NULL); ++ TEST_EQ_P (p, f+strlen (f) - strlen (".conf")); ++ nih_free (f); ++ ++ /* test parent param */ ++ job = job_class_new (NULL, "foo"); ++ TEST_NE_P (job, NULL); ++ ++ f = toggle_conf_name (job, filename); ++ TEST_NE_P (f, NULL); ++ ++ TEST_EQ (TRUE, nih_alloc_parent (f, job)); ++ ++ nih_free (job); ++} ++ ++void ++test_override (void) ++{ ++ ConfSource *source; ++ ConfFile *file; ++ FILE *f; ++ int ret, fd[4096], i = 0; ++ char dirname[PATH_MAX]; ++ char filename[PATH_MAX], override[PATH_MAX]; ++ JobClass *job; ++ NihError *err; ++ ++ program_name = "test"; ++ nih_log_set_priority (NIH_LOG_FATAL); ++ ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_GROUP ("override files"); + + /* Make sure that we have inotify before performing some tests... */ + if ((fd[0] = inotify_init ()) < 0) { +@@ -2460,207 +2534,1426 @@ test_source_reload_file (void) + close (fd[0]); + + +- /* Check that we can load a file source for the first time. An +- * inotify watch should be established on the parent directory, +- * the descriptor set to be closed-on-exec, but only that single +- * file parsed. ++ /* Explicit test of behaviour prior to introduction of override files. ++ * ++ * conf with no override before watch: ++ * create conf ++ * create watch ++ * ensure conf loaded ++ * update conf ++ * ensure conf updated ++ * delete conf ++ * ensure conf deleted + */ +- TEST_FEATURE ("with new conf file"); ++ TEST_FEATURE ("with pre-override environment (conf with no override before watch)"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create conf */ + strcpy (filename, dirname); + strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); + +- source = conf_source_new (NULL, filename, CONF_FILE); ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); + ret = conf_source_reload (source); +- + TEST_EQ (ret, 0); +- TEST_ALLOC_SIZE (source->watch, sizeof (NihWatch)); +- TEST_EQ_STR (source->watch->path, dirname); +- TEST_EQ_P (source->watch->data, source); +- +- TEST_TRUE (fcntl (source->watch->fd, F_GETFD) & FD_CLOEXEC); +- +- TEST_EQ (source->flag, TRUE); + +- strcpy (filename, dirname); +- strcat (filename, "/foo.conf"); ++ /* ensure conf loaded */ + file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_NE_P (job->start_on, NULL); + +- TEST_ALLOC_SIZE (file, sizeof (ConfFile)); +- TEST_ALLOC_PARENT (file, source); +- TEST_EQ (file->flag, source->flag); +- TEST_EQ_P (file->data, NULL); +- +- nih_free (file); ++ /* update conf */ ++ f = fopen (filename, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fclose (f); + ++ TEST_FORCE_WATCH_UPDATE(); + +- strcpy (filename, dirname); +- strcat (filename, "/bar.conf"); ++ /* ensure conf updated */ + file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (job->start_on, NULL); + +- TEST_EQ_P (file, NULL); ++ /* delete conf */ ++ unlink (filename); ++ ++ TEST_FORCE_WATCH_UPDATE(); + ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ TEST_HASH_EMPTY (job_classes); + TEST_HASH_EMPTY (source->files); + +- nih_free (source); ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure conf deleted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); + +- /* Check that if we create a new file in the directory, alongside +- * the one we are watching, it is ignored. ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ /* Explicit test of behaviour prior to introduction of override files. ++ * ++ * conf with no override after watch: ++ * create watch ++ * create conf ++ * ensure conf loaded ++ * update conf ++ * ensure conf updated ++ * delete conf ++ * ensure conf deleted + */ +- TEST_FEATURE ("with new file alongside conf file"); +- strcpy (filename, dirname); +- strcat (filename, "/foo.conf"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FEATURE ("with pre-override environment (conf with no override after watch)"); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); + +- source = conf_source_new (NULL, filename, CONF_FILE); ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); + ret = conf_source_reload (source); +- + TEST_EQ (ret, 0); + ++ /* create conf */ + strcpy (filename, dirname); +- strcat (filename, "/baz.conf"); +- ++ strcat (filename, "/foo.conf"); + f = fopen (filename, "w"); +- fprintf (f, "#nothing to test\n"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); + fclose (f); + +- nfds = 0; +- FD_ZERO (&readfds); +- FD_ZERO (&writefds); +- FD_ZERO (&exceptfds); +- +- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); +- nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure conf loaded */ + file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); + +- TEST_EQ_P (file, NULL); +- ++ /* update conf */ ++ f = fopen (filename, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fclose (f); + +- /* Check that if we modify a file in the directory, alongside +- * the one we are watching, it is ignored. +- */ +- TEST_FEATURE ("with modification to file alongside conf file"); +- strcpy (filename, dirname); +- strcat (filename, "/bar.conf"); ++ TEST_FORCE_WATCH_UPDATE(); + +- f = fopen (filename, "w"); +- fprintf (f, "#nothing to test\n"); +- fclose (f); ++ /* ensure conf updated */ ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (job->start_on, NULL); + +- nfds = 0; +- FD_ZERO (&readfds); +- FD_ZERO (&writefds); +- FD_ZERO (&exceptfds); ++ /* delete conf */ ++ unlink (filename); + +- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); +- nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure conf deleted */ + file = (ConfFile *)nih_hash_lookup (source->files, filename); +- + TEST_EQ_P (file, NULL); ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); + + +- /* Check that the configuration file we're watching can be modified +- * using the direct writing technique. +- */ +- TEST_FEATURE ("with modification (direct write)"); +- strcpy (filename, dirname); +- strcat (filename, "/foo.conf"); +- +- old_file = (ConfFile *)nih_hash_lookup (source->files, filename); +- TEST_FREE_TAG (old_file); ++ TEST_FEATURE ("ensure lone override ignored before watch"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); + ++ /* create override */ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.override"); + f = fopen (filename, "w"); +- fprintf (f, "#still nothing to test\n"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); + fclose (f); + +- nfds = 0; +- FD_ZERO (&readfds); +- FD_ZERO (&writefds); +- FD_ZERO (&exceptfds); +- +- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); +- nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); + +- TEST_FREE (old_file); ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure no conf object created */ ++ TEST_HASH_EMPTY (source->files); + file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); + +- TEST_ALLOC_SIZE (file, sizeof (ConfFile)); +- TEST_ALLOC_PARENT (file, source); +- TEST_EQ (file->flag, source->flag); +- TEST_EQ_P (file->data, NULL); ++ /* update override */ ++ f = fopen (filename, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "author \"me\"\n"); ++ fclose (f); + +- old_file = file; ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure no conf object created */ ++ TEST_HASH_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); + +- /* Check that the configuration file we're watching can be modified +- * using the write and then rename technique; it should be parsed +- * and the previous file marked for deletion. +- */ +- TEST_FEATURE ("with modification (atomic rename)"); +- strcpy (tmpname, dirname); +- strcat (tmpname, "/.foo.tmp"); ++ /* delete override */ ++ unlink (filename); ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); + +- f = fopen (tmpname, "w"); +- fprintf (f, "#nothing to test\n"); +- fclose (f); + +- strcpy (filename, dirname); +- strcat (filename, "/foo.conf"); ++ TEST_FEATURE ("ensure lone override ignored after watch"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); + +- rename (tmpname, filename); ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); + +- TEST_FREE_TAG (old_file); ++ strcpy (filename, dirname); ++ strcat (filename, "/bar.override"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fclose (f); + +- nfds = 0; +- FD_ZERO (&readfds); +- FD_ZERO (&writefds); +- FD_ZERO (&exceptfds); ++ TEST_FORCE_WATCH_UPDATE(); + +- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); +- nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ /* ensure no conf object created */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "bar"); ++ TEST_EQ_P (job, NULL); + +- TEST_FREE (old_file); ++ /* delete override */ ++ unlink (filename); ++ ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure override still not present */ + file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "bar"); ++ TEST_EQ_P (job, NULL); + +- TEST_ALLOC_SIZE (file, sizeof (ConfFile)); +- TEST_ALLOC_PARENT (file, source); +- TEST_EQ (file->flag, source->flag); +- TEST_EQ_P (file->data, NULL); ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); + +- old_file = file; + ++ TEST_FEATURE ("create conf, watch, then create/modify/delete override"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); + +- /* Check that we can delete the configuration file that we're +- * watching, the metadata for it should be lost. +- */ +- TEST_FEATURE ("with deletion"); ++ /* create conf */ + strcpy (filename, dirname); + strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); + +- unlink (filename); +- +- TEST_FREE_TAG (old_file); +- +- nfds = 0; +- FD_ZERO (&readfds); +- FD_ZERO (&writefds); +- FD_ZERO (&exceptfds); ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); + +- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); +- nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ /* ensure conf loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_P ((job->emits)[1], NULL); ++ TEST_NE_P (job->start_on, NULL); ++ ++ /* create override */ ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fclose (f); + +- TEST_FREE (old_file); ++ TEST_HASH_NOT_EMPTY (source->files); ++ TEST_FORCE_WATCH_UPDATE(); + ++ /* ensure conf updated */ ++ TEST_HASH_NOT_EMPTY (source->files); + file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (job->start_on, NULL); + ++ /* ensure no override in hash */ ++ file = (ConfFile *)nih_hash_lookup (source->files, override); + TEST_EQ_P (file, NULL); + ++ /* modify override */ ++ f = fopen (override, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "emits world\n"); ++ fclose (f); + +- /* Check that the watch allows us to see if the file we want is +- * created using the direct writing technique, and thus parsed. ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf updated */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_STR ((job->emits)[1], "world"); ++ ++ /* delete override */ ++ unlink (override); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf reverted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_NE_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_P ((job->emits)[1], NULL); ++ ++ nih_free (source); ++ unlink (filename); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create watch, conf, then create/modify/delete override"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ /* create conf */ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_P ((job->emits)[1], NULL); ++ TEST_NE_P (job->start_on, NULL); ++ ++ /* create override */ ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fclose (f); ++ ++ TEST_HASH_NOT_EMPTY (source->files); ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf updated */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (job->start_on, NULL); ++ ++ /* ensure no override in hash */ ++ file = (ConfFile *)nih_hash_lookup (source->files, override); ++ TEST_EQ_P (file, NULL); ++ ++ /* modify override */ ++ f = fopen (override, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "emits world\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf updated */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_STR ((job->emits)[1], "world"); ++ ++ /* delete override */ ++ unlink (override); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf reverted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_NE_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_P ((job->emits)[1], NULL); ++ ++ nih_free (source); ++ unlink (filename); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create override, watch, then create/modify/delete conf"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ ++ /* create override */ ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"bar\"\n"); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure no conf object created */ ++ TEST_HASH_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ ++ /* create conf */ ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fprintf (f, "author \"foo\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "bar"); ++ ++ /* modify conf */ ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on wibble\n"); ++ fprintf (f, "emits moo\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf reloaded and updated with override */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "moo"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "bar"); ++ ++ /* delete conf */ ++ unlink (filename); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf object deleted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ TEST_HASH_EMPTY (source->files); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ file = (ConfFile *)nih_hash_lookup (source->files, override); ++ TEST_EQ_P (file, NULL); ++ ++ unlink (override); ++ ++ /* ensure no conf object still */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ TEST_HASH_EMPTY (source->files); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ file = (ConfFile *)nih_hash_lookup (source->files, override); ++ TEST_EQ_P (file, NULL); ++ ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create watch, override, then create/modify/delete conf"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ ++ /* create override */ ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"bar\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure no conf object created */ ++ TEST_HASH_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ ++ /* create conf */ ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fprintf (f, "author \"foo\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "bar"); ++ ++ /* modify conf */ ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on wibble\n"); ++ fprintf (f, "emits moo\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf reloaded and updated with override */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "moo"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "bar"); ++ ++ /* delete conf */ ++ unlink (filename); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf object deleted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ TEST_HASH_EMPTY (source->files); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ file = (ConfFile *)nih_hash_lookup (source->files, override); ++ TEST_EQ_P (file, NULL); ++ ++ unlink (override); ++ ++ /* ensure no conf object still */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ TEST_HASH_EMPTY (source->files); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ file = (ConfFile *)nih_hash_lookup (source->files, override); ++ TEST_EQ_P (file, NULL); ++ ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create override, watch, conf, then modify/delete override"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ ++ /* create override */ ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"bar\"\n"); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure no conf object created */ ++ TEST_HASH_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ ++ /* create conf */ ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fprintf (f, "author \"foo\"\n"); ++ fclose (f); ++ ++ /* FIXME: crashes here */ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "bar"); ++ ++ /* modify override */ ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "author \"meh\"\n"); ++ fprintf (f, "env wibble=wobble\n"); ++ fprintf (f, "manual\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf reloaded and updated with override */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "meh"); ++ TEST_EQ_STR ((job->env)[0], "wibble=wobble"); ++ ++ /* delete override */ ++ unlink (override); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf object reverted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_NE_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "foo"); ++ TEST_EQ_P (job->env, NULL); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ unlink (filename); ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create watch, override, conf, then modify/delete override"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* create override */ ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"bar\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* create conf */ ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "emits hello\n"); ++ fprintf (f, "author \"foo\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "bar"); ++ ++ /* update override */ ++ f = fopen (override, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "author \"me\"\n"); ++ fprintf (f, "env wibble=wobble\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf reloaded and updated with override */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ ++ /* should pick up override, *NOT* conf */ ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "me"); ++ TEST_EQ_STR ((job->env)[0], "wibble=wobble"); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* delete override */ ++ unlink (override); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR (job->author, "foo"); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_NE_P (job->start_on, NULL); ++ TEST_EQ_P (job->env, NULL); ++ ++ unlink (filename); ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create both conf+override files, watch, then modify/delete conf"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create conf */ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "author \"me\"\n"); ++ fprintf (f, "env foo=bar\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); ++ ++ /* create override */ ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"you\"\n"); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_STR (job->author, "you"); ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->env)[0], "foo=bar"); ++ TEST_EQ_P (job->export, NULL); ++ ++ /* modify conf */ ++ f = fopen (filename, "a"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "export foo\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf updated */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_STR ((job->env)[0], "foo=bar"); ++ TEST_NE_P (job->export, NULL); ++ TEST_EQ_STR ((job->export)[0], "foo"); ++ ++ /* delete conf */ ++ unlink (filename); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf object deleted */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_EQ_P (file, NULL); ++ TEST_HASH_EMPTY (source->files); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_EQ_P (job, NULL); ++ file = (ConfFile *)nih_hash_lookup (source->files, override); ++ TEST_EQ_P (file, NULL); ++ ++ unlink (override); ++ nih_free (source); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ TEST_FEATURE ("create both conf+override files, watch, then modify/delete override"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create conf */ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "author \"me\"\n"); ++ fprintf (f, "env foo=bar\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); ++ ++ /* create override */ ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"you\"\n"); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_STR (job->author, "you"); ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->env)[0], "foo=bar"); ++ TEST_EQ_P (job->export, NULL); ++ ++ /* modify override */ ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "description \"hello world\"\n"); ++ fprintf (f, "author \"ubuntu\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf updated */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR (job->author, "ubuntu"); ++ TEST_NE_P (job->description, NULL); ++ TEST_EQ_STR (job->description, "hello world"); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_NE_P (job->start_on, NULL); ++ ++ /* delete override */ ++ unlink (override); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf updated */ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_NE_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->env)[0], "foo=bar"); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_STR (job->author, "me"); ++ TEST_EQ_P (job->description, NULL); ++ ++ nih_free (source); ++ unlink (filename); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ TEST_FEATURE ("create conf, watch, then create invalid override, delete override"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create conf */ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "author \"wibble\"\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_NE_P (job->start_on, NULL); ++ ++ /* create (partially) invalid override (which should be ++ * fully ignored) ++ */ ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "bleaugh!\n"); ++ fprintf (f, "wha...?\n"); ++ fprintf (f, "author \"moo\"\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ unlink (override); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf still loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_NE_P (job->start_on, NULL); ++ TEST_EQ_STR (job->author, "wibble"); ++ ++ nih_free (source); ++ unlink (filename); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ TEST_FEATURE ("ensure override ignored for CONF_FILE"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create empty conf */ ++ strcpy (filename, dirname); ++ strcat (filename, "/init.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_FILE); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ ++ /* We expect conf_source_reload to fail in this situation since ++ * although "init.conf" is a supported config file, it is not ++ * allowed to contain any stanzas, implying that it can only ++ * contain comments. In fact, if the file exists but is zero ++ * size that is currently an error since upstart blindly calls ++ * nih_file_read(), which will fail since there are no bytes to ++ * read. ++ */ ++ TEST_NE (ret, 0); ++ err = nih_error_steal (); ++ TEST_EQ (err->number, EILSEQ); ++ nih_free (err); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf NOT loaded */ ++ TEST_HASH_EMPTY (source->files); ++ ++ /* create override */ ++ strcpy (override, dirname); ++ strcat (override, "/init.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fclose (f); ++ ++ TEST_FORCE_WATCH_UPDATE(); ++ ++ /* ensure conf still NOT loaded */ ++ TEST_HASH_EMPTY (source->files); ++ ++ nih_free (source); ++ unlink (filename); ++ unlink (override); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ /* Consume all available inotify instances so that the following ++ * tests run without inotify. ++ */ ++ for (i = 0; i < 4096; i++) ++ if ((fd[i] = inotify_init ()) < 0) ++ break; ++ ++no_inotify: ++ /* If you don't have inotify, any override file must exist ++ * before the system boots. ++ */ ++ ++ TEST_FEATURE ("both conf+override files with no inotify support"); ++ TEST_ENSURE_CLEAN_ENV (); ++ TEST_FILENAME (dirname); ++ TEST_EQ (mkdir (dirname, 0755), 0); ++ ++ /* create conf */ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ f = fopen (filename, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "start on started\n"); ++ fprintf (f, "author \"me\"\n"); ++ fprintf (f, "env foo=bar\n"); ++ fprintf (f, "emits hello\n"); ++ fclose (f); ++ ++ /* create override */ ++ strcpy (override, dirname); ++ strcat (override, "/foo.override"); ++ f = fopen (override, "w"); ++ TEST_NE_P (f, NULL); ++ fprintf (f, "manual\n"); ++ fprintf (f, "author \"you\"\n"); ++ fclose (f); ++ ++ /* create watch */ ++ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); ++ TEST_NE_P (source, NULL); ++ ret = conf_source_reload (source); ++ TEST_EQ (ret, 0); ++ ++ /* ensure conf loaded */ ++ TEST_HASH_NOT_EMPTY (source->files); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_NE_P (file, NULL); ++ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); ++ TEST_NE_P (job, NULL); ++ TEST_EQ_P (file->job, job); ++ TEST_EQ_STR ((job->emits)[0], "hello"); ++ TEST_EQ_STR (job->author, "you"); ++ TEST_EQ_P (job->start_on, NULL); ++ TEST_EQ_STR ((job->env)[0], "foo=bar"); ++ TEST_EQ_P (job->export, NULL); ++ ++ nih_free (source); ++ unlink (filename); ++ unlink (override); ++ TEST_EQ (rmdir (dirname), 0); ++ ++ ++ nih_log_set_priority (NIH_LOG_MESSAGE); ++ ++ /* Release consumed instances */ ++ for (i = 0; i < 4096; i++) { ++ if (fd[i] < 0) ++ break; ++ ++ close (fd[i]); ++ } ++} ++ ++void ++test_source_reload_file (void) ++{ ++ ConfSource *source; ++ ConfFile *file, *old_file; ++ FILE *f; ++ int ret, fd[4096], i = 0, nfds; ++ char dirname[PATH_MAX]; ++ char tmpname[PATH_MAX], filename[PATH_MAX]; ++ fd_set readfds, writefds, exceptfds; ++ NihError *err; ++ ++ TEST_FUNCTION_FEATURE ("conf_source_reload", ++ "with configuration file"); ++ program_name = "test"; ++ nih_log_set_priority (NIH_LOG_FATAL); ++ ++ TEST_FILENAME (dirname); ++ mkdir (dirname, 0755); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ ++ f = fopen (filename, "w"); ++ fprintf (f, "#nothing to test\n"); ++ fclose (f); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/bar.conf"); ++ ++ f = fopen (filename, "w"); ++ fprintf (f, "#nothing to test\n"); ++ fclose (f); ++ ++ /* Make sure that we have inotify before performing some tests... */ ++ if ((fd[0] = inotify_init ()) < 0) { ++ printf ("SKIP: inotify not available\n"); ++ goto no_inotify; ++ } ++ close (fd[0]); ++ ++ ++ /* Check that we can load a file source for the first time. An ++ * inotify watch should be established on the parent directory, ++ * the descriptor set to be closed-on-exec, but only that single ++ * file parsed. ++ */ ++ TEST_FEATURE ("with new conf file"); ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ ++ source = conf_source_new (NULL, filename, CONF_FILE); ++ ret = conf_source_reload (source); ++ ++ TEST_EQ (ret, 0); ++ TEST_ALLOC_SIZE (source->watch, sizeof (NihWatch)); ++ TEST_EQ_STR (source->watch->path, dirname); ++ TEST_EQ_P (source->watch->data, source); ++ ++ TEST_TRUE (fcntl (source->watch->fd, F_GETFD) & FD_CLOEXEC); ++ ++ TEST_EQ (source->flag, TRUE); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_ALLOC_SIZE (file, sizeof (ConfFile)); ++ TEST_ALLOC_PARENT (file, source); ++ TEST_EQ (file->flag, source->flag); ++ TEST_EQ_P (file->data, NULL); ++ ++ nih_free (file); ++ ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/bar.conf"); ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_EQ_P (file, NULL); ++ ++ TEST_HASH_EMPTY (source->files); ++ ++ nih_free (source); ++ ++ ++ /* Check that if we create a new file in the directory, alongside ++ * the one we are watching, it is ignored. ++ */ ++ TEST_FEATURE ("with new file alongside conf file"); ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ ++ source = conf_source_new (NULL, filename, CONF_FILE); ++ ret = conf_source_reload (source); ++ ++ TEST_EQ (ret, 0); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/baz.conf"); ++ ++ f = fopen (filename, "w"); ++ fprintf (f, "#nothing to test\n"); ++ fclose (f); ++ ++ nfds = 0; ++ FD_ZERO (&readfds); ++ FD_ZERO (&writefds); ++ FD_ZERO (&exceptfds); ++ ++ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); ++ nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_EQ_P (file, NULL); ++ ++ ++ /* Check that if we modify a file in the directory, alongside ++ * the one we are watching, it is ignored. ++ */ ++ TEST_FEATURE ("with modification to file alongside conf file"); ++ strcpy (filename, dirname); ++ strcat (filename, "/bar.conf"); ++ ++ f = fopen (filename, "w"); ++ fprintf (f, "#nothing to test\n"); ++ fclose (f); ++ ++ nfds = 0; ++ FD_ZERO (&readfds); ++ FD_ZERO (&writefds); ++ FD_ZERO (&exceptfds); ++ ++ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); ++ nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_EQ_P (file, NULL); ++ ++ ++ /* Check that the configuration file we're watching can be modified ++ * using the direct writing technique. ++ */ ++ TEST_FEATURE ("with modification (direct write)"); ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ ++ old_file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ TEST_FREE_TAG (old_file); ++ ++ f = fopen (filename, "w"); ++ fprintf (f, "#still nothing to test\n"); ++ fclose (f); ++ ++ nfds = 0; ++ FD_ZERO (&readfds); ++ FD_ZERO (&writefds); ++ FD_ZERO (&exceptfds); ++ ++ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); ++ nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ ++ TEST_FREE (old_file); ++ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_ALLOC_SIZE (file, sizeof (ConfFile)); ++ TEST_ALLOC_PARENT (file, source); ++ TEST_EQ (file->flag, source->flag); ++ TEST_EQ_P (file->data, NULL); ++ ++ old_file = file; ++ ++ ++ /* Check that the configuration file we're watching can be modified ++ * using the write and then rename technique; it should be parsed ++ * and the previous file marked for deletion. ++ */ ++ TEST_FEATURE ("with modification (atomic rename)"); ++ strcpy (tmpname, dirname); ++ strcat (tmpname, "/.foo.tmp"); ++ ++ f = fopen (tmpname, "w"); ++ fprintf (f, "#nothing to test\n"); ++ fclose (f); ++ ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ ++ rename (tmpname, filename); ++ ++ TEST_FREE_TAG (old_file); ++ ++ nfds = 0; ++ FD_ZERO (&readfds); ++ FD_ZERO (&writefds); ++ FD_ZERO (&exceptfds); ++ ++ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); ++ nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ ++ TEST_FREE (old_file); ++ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_ALLOC_SIZE (file, sizeof (ConfFile)); ++ TEST_ALLOC_PARENT (file, source); ++ TEST_EQ (file->flag, source->flag); ++ TEST_EQ_P (file->data, NULL); ++ ++ old_file = file; ++ ++ ++ /* Check that we can delete the configuration file that we're ++ * watching, the metadata for it should be lost. ++ */ ++ TEST_FEATURE ("with deletion"); ++ strcpy (filename, dirname); ++ strcat (filename, "/foo.conf"); ++ ++ unlink (filename); ++ ++ TEST_FREE_TAG (old_file); ++ ++ nfds = 0; ++ FD_ZERO (&readfds); ++ FD_ZERO (&writefds); ++ FD_ZERO (&exceptfds); ++ ++ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); ++ nih_io_handle_fds (&readfds, &writefds, &exceptfds); ++ ++ TEST_FREE (old_file); ++ ++ file = (ConfFile *)nih_hash_lookup (source->files, filename); ++ ++ TEST_EQ_P (file, NULL); ++ ++ ++ /* Check that the watch allows us to see if the file we want is ++ * created using the direct writing technique, and thus parsed. + */ + TEST_FEATURE ("with creation (direct write)"); + strcpy (filename, dirname); +@@ -2969,8 +4262,6 @@ test_source_reload_file (void) + TEST_HASH_EMPTY (source->files); + + nih_free (source); +- +- + /* Consume all available inotify instances so that the following + * tests run without inotify. + */ +@@ -3456,6 +4747,8 @@ main (int argc, + test_source_reload_conf_dir (); + test_source_reload_file (); + test_source_reload (); ++ test_toggle_conf_name (); ++ test_override (); + test_file_destroy (); + test_select_job (); + +diff --git a/init/tests/test_parse_job.c b/init/tests/test_parse_job.c +index 73218f4..07a99c1 100644 +--- a/init/tests/test_parse_job.c ++++ b/init/tests/test_parse_job.c +@@ -64,7 +64,7 @@ test_parse_job (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -110,7 +110,7 @@ test_parse_job (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -131,6 +131,45 @@ test_parse_job (void) + + nih_free (job); + } ++ ++ TEST_FEATURE ("with non-NULL update parameter (override)"); ++ { ++ JobClass *tmp = NULL; ++ ++ strcpy (buf, "start on starting\n"); ++ strcat (buf, "author \"me\"\n"); ++ ++ pos = 0; ++ lineno = 1; ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), ++ &pos, &lineno); ++ ++ TEST_NE_P (job, NULL); ++ TEST_EQ_STR (job->author, "me"); ++ TEST_NE_P (job->start_on, NULL); ++ ++ strcat (buf, "author \"you\"\n"); ++ strcat (buf, "manual\n"); ++ strcat (buf, "description \"my description\"\n"); ++ ++ pos = 0; ++ lineno = 1; ++ tmp = parse_job (NULL, job, "test", buf, strlen (buf), ++ &pos, &lineno); ++ TEST_NE_P (tmp, NULL); ++ ++ /* if passed a job, the same object should be returned. ++ */ ++ TEST_EQ_P (tmp, job); ++ ++ TEST_EQ_STR (tmp->author, "you"); ++ TEST_EQ_P (tmp->start_on, NULL); ++ TEST_NE_P (tmp->description, NULL); ++ ++ TEST_EQ_STR (tmp->description, "my description"); ++ ++ nih_free (job); ++ } + } + + void +@@ -153,7 +192,7 @@ test_stanza_exec (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -190,7 +229,7 @@ test_stanza_exec (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -229,7 +268,7 @@ test_stanza_exec (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -266,7 +305,7 @@ test_stanza_exec (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -299,7 +338,7 @@ test_stanza_script (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -340,7 +379,7 @@ test_stanza_script (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -379,7 +418,7 @@ test_stanza_script (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -416,7 +455,7 @@ test_stanza_script (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -447,7 +486,7 @@ test_stanza_pre_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -484,7 +523,7 @@ test_stanza_pre_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -524,7 +563,7 @@ test_stanza_pre_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -565,7 +604,7 @@ test_stanza_pre_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -604,7 +643,7 @@ test_stanza_pre_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -643,7 +682,7 @@ test_stanza_pre_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -680,7 +719,7 @@ test_stanza_pre_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -699,7 +738,7 @@ test_stanza_pre_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -718,7 +757,7 @@ test_stanza_pre_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -737,7 +776,7 @@ test_stanza_pre_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -768,7 +807,7 @@ test_stanza_post_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -805,7 +844,7 @@ test_stanza_post_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -845,7 +884,7 @@ test_stanza_post_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -886,7 +925,7 @@ test_stanza_post_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -925,7 +964,7 @@ test_stanza_post_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -964,7 +1003,7 @@ test_stanza_post_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1001,7 +1040,7 @@ test_stanza_post_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1020,7 +1059,7 @@ test_stanza_post_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1039,7 +1078,7 @@ test_stanza_post_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1058,7 +1097,7 @@ test_stanza_post_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1089,7 +1128,7 @@ test_stanza_pre_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1126,7 +1165,7 @@ test_stanza_pre_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1166,7 +1205,7 @@ test_stanza_pre_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1207,7 +1246,7 @@ test_stanza_pre_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1246,7 +1285,7 @@ test_stanza_pre_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1285,7 +1324,7 @@ test_stanza_pre_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1322,7 +1361,7 @@ test_stanza_pre_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1341,7 +1380,7 @@ test_stanza_pre_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1360,7 +1399,7 @@ test_stanza_pre_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1379,7 +1418,7 @@ test_stanza_pre_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1410,7 +1449,7 @@ test_stanza_post_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1447,7 +1486,7 @@ test_stanza_post_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1487,7 +1526,7 @@ test_stanza_post_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1528,7 +1567,7 @@ test_stanza_post_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1567,7 +1606,7 @@ test_stanza_post_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1606,7 +1645,7 @@ test_stanza_post_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1643,7 +1682,7 @@ test_stanza_post_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1662,7 +1701,7 @@ test_stanza_post_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1681,7 +1720,7 @@ test_stanza_post_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1700,7 +1739,7 @@ test_stanza_post_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -1731,7 +1770,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1776,7 +1815,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1828,7 +1867,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1879,7 +1918,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -1942,7 +1981,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2012,7 +2051,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2090,7 +2129,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2170,7 +2209,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2249,7 +2288,7 @@ test_stanza_start (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2291,7 +2330,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2310,7 +2349,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2329,7 +2368,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2348,7 +2387,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2367,7 +2406,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2384,7 +2423,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2403,7 +2442,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2422,7 +2461,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2441,7 +2480,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2460,7 +2499,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2479,7 +2518,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2498,7 +2537,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2517,7 +2556,7 @@ test_stanza_start (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -2551,7 +2590,7 @@ test_stanza_manual (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2586,7 +2625,7 @@ test_stanza_manual (void) + TEST_FEATURE ("manual stanza after start on"); + strcpy (buf, "start on wibble\nmanual\n"); + +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + TEST_NE_P (job, NULL); +@@ -2616,7 +2655,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2661,7 +2700,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2713,7 +2752,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2764,7 +2803,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2827,7 +2866,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2897,7 +2936,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -2975,7 +3014,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3055,7 +3094,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3134,7 +3173,7 @@ test_stanza_stop (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3176,7 +3215,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3195,7 +3234,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3214,7 +3253,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3233,7 +3272,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3252,7 +3291,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3269,7 +3308,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3288,7 +3327,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3307,7 +3346,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3326,7 +3365,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3345,7 +3384,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3364,7 +3403,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3383,7 +3422,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3402,7 +3441,7 @@ test_stanza_stop (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3432,7 +3471,7 @@ test_stanza_description (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3465,7 +3504,7 @@ test_stanza_description (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3498,7 +3537,7 @@ test_stanza_description (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3517,7 +3556,7 @@ test_stanza_description (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3547,7 +3586,7 @@ test_stanza_author (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3580,7 +3619,7 @@ test_stanza_author (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3613,7 +3652,7 @@ test_stanza_author (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3632,7 +3671,7 @@ test_stanza_author (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3662,7 +3701,7 @@ test_stanza_version (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3695,7 +3734,7 @@ test_stanza_version (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3728,7 +3767,7 @@ test_stanza_version (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3747,7 +3786,7 @@ test_stanza_version (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3777,7 +3816,7 @@ test_stanza_emits (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3814,7 +3853,7 @@ test_stanza_emits (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3857,7 +3896,7 @@ test_stanza_emits (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3899,7 +3938,7 @@ test_stanza_emits (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -3929,7 +3968,7 @@ test_stanza_expect (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3962,7 +4001,7 @@ test_stanza_expect (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -3995,7 +4034,7 @@ test_stanza_expect (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4028,7 +4067,7 @@ test_stanza_expect (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4061,7 +4100,7 @@ test_stanza_expect (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4093,7 +4132,7 @@ test_stanza_expect (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4112,7 +4151,7 @@ test_stanza_expect (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4131,7 +4170,7 @@ test_stanza_expect (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4159,7 +4198,7 @@ test_stanza_respawn (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4193,7 +4232,7 @@ test_stanza_respawn (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4226,7 +4265,7 @@ test_stanza_respawn (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4260,7 +4299,7 @@ test_stanza_respawn (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4293,7 +4332,7 @@ test_stanza_respawn (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4326,7 +4365,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4345,7 +4384,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4364,7 +4403,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4383,7 +4422,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4402,7 +4441,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4421,7 +4460,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4440,7 +4479,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4459,7 +4498,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4478,7 +4517,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4497,7 +4536,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4516,7 +4555,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4535,7 +4574,7 @@ test_stanza_respawn (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4565,7 +4604,7 @@ test_stanza_task (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4597,7 +4636,7 @@ test_stanza_task (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4629,7 +4668,7 @@ test_stanza_task (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4659,7 +4698,7 @@ test_stanza_instance (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4693,7 +4732,7 @@ test_stanza_instance (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4726,7 +4765,7 @@ test_stanza_instance (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4745,7 +4784,7 @@ test_stanza_instance (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4775,7 +4814,7 @@ test_stanza_kill (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4808,7 +4847,7 @@ test_stanza_kill (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -4840,7 +4879,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4859,7 +4898,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4878,7 +4917,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4897,7 +4936,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4916,7 +4955,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4935,7 +4974,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4954,7 +4993,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -4974,7 +5013,7 @@ test_stanza_kill (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5005,7 +5044,7 @@ test_stanza_normal (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5044,7 +5083,7 @@ test_stanza_normal (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5083,7 +5122,7 @@ test_stanza_normal (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5127,7 +5166,7 @@ test_stanza_normal (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5168,7 +5207,7 @@ test_stanza_normal (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5187,7 +5226,7 @@ test_stanza_normal (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5206,7 +5245,7 @@ test_stanza_normal (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5225,7 +5264,7 @@ test_stanza_normal (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5244,7 +5283,7 @@ test_stanza_normal (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5263,7 +5302,7 @@ test_stanza_normal (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5293,7 +5332,7 @@ test_stanza_console (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5326,7 +5365,7 @@ test_stanza_console (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5359,7 +5398,7 @@ test_stanza_console (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5392,7 +5431,7 @@ test_stanza_console (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5423,7 +5462,7 @@ test_stanza_console (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5442,7 +5481,7 @@ test_stanza_console (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5460,7 +5499,7 @@ test_stanza_console (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5490,7 +5529,7 @@ test_stanza_env (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5528,7 +5567,7 @@ test_stanza_env (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5565,7 +5604,7 @@ test_stanza_env (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5584,7 +5623,7 @@ test_stanza_env (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5614,7 +5653,7 @@ test_stanza_export (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5651,7 +5690,7 @@ test_stanza_export (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5694,7 +5733,7 @@ test_stanza_export (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5736,7 +5775,7 @@ test_stanza_export (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5766,7 +5805,7 @@ test_stanza_umask (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5799,7 +5838,7 @@ test_stanza_umask (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5831,7 +5870,7 @@ test_stanza_umask (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5850,7 +5889,7 @@ test_stanza_umask (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5869,7 +5908,7 @@ test_stanza_umask (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5888,7 +5927,7 @@ test_stanza_umask (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5907,7 +5946,7 @@ test_stanza_umask (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5927,7 +5966,7 @@ test_stanza_umask (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -5957,7 +5996,7 @@ test_stanza_nice (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -5990,7 +6029,7 @@ test_stanza_nice (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6023,7 +6062,7 @@ test_stanza_nice (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6055,7 +6094,7 @@ test_stanza_nice (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6074,7 +6113,7 @@ test_stanza_nice (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6093,7 +6132,7 @@ test_stanza_nice (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6112,7 +6151,7 @@ test_stanza_nice (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6131,7 +6170,7 @@ test_stanza_nice (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6150,7 +6189,7 @@ test_stanza_nice (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6180,7 +6219,7 @@ test_stanza_oom (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6213,7 +6252,7 @@ test_stanza_oom (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6246,7 +6285,7 @@ test_stanza_oom (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6279,7 +6318,7 @@ test_stanza_oom (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6311,7 +6350,7 @@ test_stanza_oom (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6330,7 +6369,7 @@ test_stanza_oom (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6349,7 +6388,7 @@ test_stanza_oom (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6368,7 +6407,7 @@ test_stanza_oom (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6387,7 +6426,7 @@ test_stanza_oom (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6406,7 +6445,7 @@ test_stanza_oom (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -6435,7 +6474,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6469,7 +6508,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6503,7 +6542,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6537,7 +6576,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6571,7 +6610,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6606,7 +6645,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6641,7 +6680,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6675,7 +6714,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6710,7 +6749,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6744,7 +6783,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6778,7 +6817,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6812,7 +6851,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6847,7 +6886,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6881,7 +6920,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6917,7 +6956,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6956,7 +6995,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -6991,7 +7030,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -7026,7 +7065,7 @@ test_stanza_limit (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -7060,7 +7099,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7079,7 +7118,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7098,7 +7137,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7117,7 +7156,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7136,7 +7175,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7155,7 +7194,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7174,7 +7213,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7193,7 +7232,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7212,7 +7251,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7231,7 +7270,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7250,7 +7289,7 @@ test_stanza_limit (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7280,7 +7319,7 @@ test_stanza_chroot (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -7314,7 +7353,7 @@ test_stanza_chroot (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -7347,7 +7386,7 @@ test_stanza_chroot (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7366,7 +7405,7 @@ test_stanza_chroot (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7396,7 +7435,7 @@ test_stanza_chdir (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -7430,7 +7469,7 @@ test_stanza_chdir (void) + TEST_ALLOC_FAIL { + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), + &pos, &lineno); + + if (test_alloc_failed) { +@@ -7463,7 +7502,7 @@ test_stanza_chdir (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + +@@ -7482,7 +7521,7 @@ test_stanza_chdir (void) + + pos = 0; + lineno = 1; +- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); ++ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); + + TEST_EQ_P (job, NULL); + diff --git a/upstart.spec b/upstart.spec index 4740b16..0c8f590 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,14 +1,14 @@ %define initscripts 20101206 Name: upstart -Version: 1.0 -Release: 2%{?dist} +Version: 1.1 +Release: 1%{?dist} Summary: An event-driven init system Group: System Environment/Base License: GPLv2 and LGPLv2+ URL: http://upstart.ubuntu.com -Source0: http://launchpad.net/upstart/1.x/1.0/+download/upstart-%{version}.tar.gz +Source0: http://launchpad.net/upstart/1.x/%{version}/+download/upstart-%{version}.tar.gz Source1: init-system-dbus.conf # These are taken from http://git.fedorahosted.org/git/?p=initscripts.git Source2: initjobs-%{initscripts}.tar.gz @@ -19,8 +19,8 @@ Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) Patch3: upstart-utmp.patch Patch4: upstart-reexec.patch -# send close fd command to shell first (#646894) -Patch6: upstart-close-fd.patch +# allow job override files +Patch7: upstart-override.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 @@ -51,7 +51,7 @@ Drop-in replacement for the System V init tools, provided by Upstart. %patch2 -p1 -b .audit %patch3 -p1 -b .utmp %patch4 -p1 -b .reexec -%patch6 -p1 -b .closefd +%patch7 -p1 -b .override %build autoreconf @@ -176,6 +176,11 @@ rm -rf %{buildroot} %endif %changelog +* Mon Mar 21 2011 Petr Lautrbach 1.1-1 +- upgrade to 1.1 +- remove /lib/upstart/init experiment +- allow job override files + * Tue Mar 15 2011 Petr Lautrbach 1.0-2 - introduce /lib/upstart/init/ as place for jobs defaults From 96848ab1f56418157f8fdc4e13b5ce610ca2b8e4 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 23 Mar 2011 09:38:13 +0100 Subject: [PATCH 52/61] upstart-1.2-1.fc16 --- .gitignore | 1 + sources | 2 +- upstart.spec | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 38380bc..53c36f7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ upstart-0.6.6.tar.gz /upstart-0.6.7.tar.gz /upstart-1.0.tar.gz /upstart-1.1.tar.gz +/upstart-1.2.tar.gz diff --git a/sources b/sources index cb6545b..324aa1a 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ 53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz -9e9ce9d5e3936e59331f478d8a436e00 upstart-1.1.tar.gz +c1b1bab5c1c1ed2595081d8178542b37 upstart-1.2.tar.gz diff --git a/upstart.spec b/upstart.spec index 0c8f590..0c150b5 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,13 +1,13 @@ %define initscripts 20101206 Name: upstart -Version: 1.1 +Version: 1.2 Release: 1%{?dist} Summary: An event-driven init system Group: System Environment/Base License: GPLv2 and LGPLv2+ -URL: http://upstart.ubuntu.com +URL: https://launchpad.net/upstart Source0: http://launchpad.net/upstart/1.x/%{version}/+download/upstart-%{version}.tar.gz Source1: init-system-dbus.conf # These are taken from http://git.fedorahosted.org/git/?p=initscripts.git @@ -176,6 +176,10 @@ rm -rf %{buildroot} %endif %changelog +* Wed Mar 23 2011 Petr Lautrbach 1.2-1 +- upgrade to 1.2 +- update upstream URL + * Mon Mar 21 2011 Petr Lautrbach 1.1-1 - upgrade to 1.1 - remove /lib/upstart/init experiment From 96c0c95752f88795795d068c13b9762b8ab2505c Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 23 Mar 2011 09:53:40 +0100 Subject: [PATCH 53/61] use only spaces in spec file --- upstart.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upstart.spec b/upstart.spec index 0c150b5..ba6b43a 100644 --- a/upstart.spec +++ b/upstart.spec @@ -11,7 +11,7 @@ URL: https://launchpad.net/upstart Source0: http://launchpad.net/upstart/1.x/%{version}/+download/upstart-%{version}.tar.gz Source1: init-system-dbus.conf # These are taken from http://git.fedorahosted.org/git/?p=initscripts.git -Source2: initjobs-%{initscripts}.tar.gz +Source2: initjobs-%{initscripts}.tar.gz # create missing files and directories according to /etc/tmpfiles.d/ Source3: tmpfiles.conf Patch1: upstart-telinit.patch @@ -24,7 +24,7 @@ Patch7: upstart-override.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 -Conflicts: initscripts < 9.12 +Conflicts: initscripts < 9.12 Requires: sysvinit-userspace /etc/rc.d/rc.sysinit Obsoletes: upstart-sysvinit From 8b333c447e03324e8b2d054fcbe67b8a7f0ba085 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 5 May 2011 12:17:01 +0200 Subject: [PATCH 54/61] move binaries to /lib/upstart, add /lib/upstart to default PATH, handle /run in tmpfiles.d --- .gitignore | 1 + fix-selinux-on-run.conf | 8 ++++++ sources | 2 +- tmpfiles.conf | 9 ++++--- upstart-lib-upstart.patch | 13 ++++++++++ upstart.sh | 4 +++ upstart.spec | 53 ++++++++++++++++++++++++++------------- 7 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 fix-selinux-on-run.conf create mode 100644 upstart-lib-upstart.patch create mode 100644 upstart.sh diff --git a/.gitignore b/.gitignore index 53c36f7..5056c71 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ upstart-0.6.6.tar.gz /upstart-1.0.tar.gz /upstart-1.1.tar.gz /upstart-1.2.tar.gz +/initjobs-20110502.tar.gz diff --git a/fix-selinux-on-run.conf b/fix-selinux-on-run.conf new file mode 100644 index 0000000..a09734b --- /dev/null +++ b/fix-selinux-on-run.conf @@ -0,0 +1,8 @@ +# fix selinux context on /run created and mounted by dracut +# original context is tmpfs_t while we need var_run_t and others + +start on starting rcS + +task + +exec /sbin/restorecon -R /run diff --git a/sources b/sources index 324aa1a..0f4c518 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz c1b1bab5c1c1ed2595081d8178542b37 upstart-1.2.tar.gz +dce904a3284fb76fa136c618b9e8a80c initjobs-20110502.tar.gz diff --git a/tmpfiles.conf b/tmpfiles.conf index 2f8d3b8..5b26039 100644 --- a/tmpfiles.conf +++ b/tmpfiles.conf @@ -26,8 +26,11 @@ script # only directories [ -n "$type" ] || continue [ $type = "d" ] || [ $type = "D" ] || continue - # only /var/run and /var/lock - [ $path != ${path#/var/run/} ] || [ $path != ${path#/var/lock/} ] || continue + # only /run /var/run and /var/lock + [ $path != ${path#/run/} ] || + [ $path != ${path#/var/run/} ] || + [ $path != ${path#/var/lock/} ] || + continue if [ ! -d $path ]; then mkdir -p $path || continue SELINUX_RESTORE=1 @@ -38,6 +41,6 @@ script done if [ -n "$SELINUX_STATE" ] && [ -n "$SELINUX_RESTORE" ]; then - /sbin/restorecon -R /var/lock /var/run 2> /dev/null + /sbin/restorecon -R /run /var/run /var/lock 2> /dev/null fi end script diff --git a/upstart-lib-upstart.patch b/upstart-lib-upstart.patch new file mode 100644 index 0000000..bcef9d0 --- /dev/null +++ b/upstart-lib-upstart.patch @@ -0,0 +1,13 @@ +diff --git a/init/paths.h b/init/paths.h +index c7ddec1..1402e9d 100644 +--- a/init/paths.h ++++ b/init/paths.h +@@ -26,7 +26,7 @@ + * This is the default PATH set by the init process itself. + **/ + #ifndef PATH +-#define _PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin" ++#define _PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/lib/upstart:/sbin:/bin" + #ifdef EXTRA_PATH + #define PATH _PATH ":" EXTRA_PATH + #else diff --git a/upstart.sh b/upstart.sh new file mode 100644 index 0000000..ebd143b --- /dev/null +++ b/upstart.sh @@ -0,0 +1,4 @@ +# check if upstart is running +if /lib/upstart/initctl list > /dev/null 2> /dev/null; then + export PATH=/lib/upstart:$PATH +fi diff --git a/upstart.spec b/upstart.spec index ba6b43a..d5321f8 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 1.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -14,6 +14,10 @@ Source1: init-system-dbus.conf Source2: initjobs-%{initscripts}.tar.gz # create missing files and directories according to /etc/tmpfiles.d/ Source3: tmpfiles.conf +# fix selinux context on /run created and mounted by dracut +Source4: fix-selinux-on-run.conf +# add /lib/upstart to shell PATH if upstart is running +Source5: upstart.sh Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) @@ -21,6 +25,8 @@ Patch3: upstart-utmp.patch Patch4: upstart-reexec.patch # allow job override files Patch7: upstart-override.patch +# add /lib/upstart to default PATH set by init process +Patch10: upstart-lib-upstart.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 @@ -52,10 +58,11 @@ Drop-in replacement for the System V init tools, provided by Upstart. %patch3 -p1 -b .utmp %patch4 -p1 -b .reexec %patch7 -p1 -b .override +%patch10 -p1 -b .lib-upstart %build autoreconf -%configure --sbindir=/sbin --libdir=/%{_lib} +%configure --sbindir=/lib/upstart --libdir=/%{_lib} make %{?_smp_mflags} %install @@ -66,14 +73,14 @@ make install DESTDIR=%{buildroot} # installation with systemd. We move the utility binaries into a # subdirectory, so that program_name stays the same and Upstart still # can check argv[0] properly in various places. -mv %{buildroot}/sbin/init %{buildroot}/sbin/upstart -rm %{buildroot}/sbin/halt -rm %{buildroot}/sbin/poweroff -mkdir -p -m 755 %{buildroot}/lib/upstart -mv %{buildroot}/sbin/reboot %{buildroot}/lib/upstart/reboot -mv %{buildroot}/sbin/runlevel %{buildroot}/lib/upstart/runlevel -mv %{buildroot}/sbin/shutdown %{buildroot}/lib/upstart/shutdown -mv %{buildroot}/sbin/telinit %{buildroot}/lib/upstart/telinit +mkdir -p %{buildroot}/sbin/ +ln -sf ../lib/upstart/init %{buildroot}/sbin/upstart +ln -sf ../lib/upstart/initctl %{buildroot}/sbin/initctl +ln -sf ../lib/upstart/start %{buildroot}/sbin/start +ln -sf ../lib/upstart/status %{buildroot}/sbin/status +ln -sf ../lib/upstart/stop %{buildroot}/sbin/stop +ln -sf ../lib/upstart/restart %{buildroot}/sbin/restart +ln -sf ../lib/upstart/reload %{buildroot}/sbin/reload ln -sf reboot %{buildroot}/lib/upstart/poweroff ln -sf reboot %{buildroot}/lib/upstart/halt %if 0 @@ -95,10 +102,14 @@ rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown, rm -f %{buildroot}/%{_sysconfdir}/init/* install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init/ +install -m 644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/init/ for file in initjobs-%{initscripts}/*.conf ; do install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ done +mkdir -p -m 755 %{buildroot}/%{_sysconfdir}/profile.d/ +install -m 644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/profile.d/ + %find_lang %{name} @@ -122,20 +133,28 @@ rm -rf %{buildroot} %doc HACKING %{_sysconfdir}/init/ %config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf -%dir /lib/upstart -/lib/upstart/halt /sbin/upstart /sbin/initctl -/lib/upstart/poweroff -/lib/upstart/reboot -/lib/upstart/runlevel -/lib/upstart/shutdown /sbin/start /sbin/status /sbin/stop /sbin/restart -/lib/upstart/telinit /sbin/reload +%dir /lib/upstart +/lib/upstart/init +/lib/upstart/initctl +/lib/upstart/poweroff +/lib/upstart/reboot +/lib/upstart/runlevel +/lib/upstart/shutdown +/lib/upstart/halt +/lib/upstart/start +/lib/upstart/status +/lib/upstart/stop +/lib/upstart/restart +/lib/upstart/telinit +/lib/upstart/reload +/etc/profile.d/upstart.sh %{_mandir}/man5/init.5.gz %{_mandir}/man5/inittab.5.gz %{_mandir}/man7/control-alt-delete.7.gz From bb1d48a85d1e0b60ed7d3822212194a007b2a2fb Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 5 May 2011 12:17:22 +0200 Subject: [PATCH 55/61] upstart-1.2-2.fc16 --- upstart.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index d5321f8..ca78dba 100644 --- a/upstart.spec +++ b/upstart.spec @@ -1,4 +1,4 @@ -%define initscripts 20101206 +%define initscripts 20110502 Name: upstart Version: 1.2 @@ -195,6 +195,11 @@ rm -rf %{buildroot} %endif %changelog +* Wed May 04 2011 Petr Lautrbach 1.2-2 +- /run - fix selinux context and check for tmpfiles.d +- physically move binaries to /lib/upstart +- add /lib/upstart to default PATH + * Wed Mar 23 2011 Petr Lautrbach 1.2-1 - upgrade to 1.2 - update upstream URL From 8c1aa5b5b13810cffa4210bd48b7036e2c716187 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 11 May 2011 14:07:19 +0200 Subject: [PATCH 56/61] /etc/init.conf, upstart-1.2-3.fc16 --- init.conf | 0 upstart.spec | 8 +++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 init.conf diff --git a/init.conf b/init.conf new file mode 100644 index 0000000..e69de29 diff --git a/upstart.spec b/upstart.spec index ca78dba..5065d4b 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 1.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -18,6 +18,7 @@ Source3: tmpfiles.conf Source4: fix-selinux-on-run.conf # add /lib/upstart to shell PATH if upstart is running Source5: upstart.sh +Source6: init.conf Patch1: upstart-telinit.patch Patch2: upstart-audit-events.patch # set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) @@ -110,6 +111,7 @@ done mkdir -p -m 755 %{buildroot}/%{_sysconfdir}/profile.d/ install -m 644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/profile.d/ +install -m 644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/init.conf %find_lang %{name} @@ -132,6 +134,7 @@ rm -rf %{buildroot} %doc TODO %doc HACKING %{_sysconfdir}/init/ +%config(noreplace) %{_sysconfdir}/init.conf %config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf /sbin/upstart /sbin/initctl @@ -195,6 +198,9 @@ rm -rf %{buildroot} %endif %changelog +* Fri May 13 2011 Petr Lautrbach 1.2-3 +- add /etc/init.conf file + * Wed May 04 2011 Petr Lautrbach 1.2-2 - /run - fix selinux context and check for tmpfiles.d - physically move binaries to /lib/upstart From 47b279bc28c2637d2056cd6df2e55ec10ebaa628 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 26 May 2011 11:09:43 +0200 Subject: [PATCH 57/61] remove Obsoletes: upstart-sysvinit and clean spec file --- upstart.spec | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/upstart.spec b/upstart.spec index 5065d4b..47f743c 100644 --- a/upstart.spec +++ b/upstart.spec @@ -33,25 +33,12 @@ BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 Conflicts: initscripts < 9.12 Requires: sysvinit-userspace /etc/rc.d/rc.sysinit -Obsoletes: upstart-sysvinit %description Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running. -%package sysvinit -Group: System Environment/Base -Summary: Upstart System V init tools -Requires: %{name} = %{version}-%{release} -Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 -Provides: SysVinit = 2.86-24, sysvinit = 2.86-24 -Provides: sysvinit-userspace -Conflicts: systemd-sysvinit - -%description sysvinit -Drop-in replacement for the System V init tools, provided by Upstart. - %prep %setup -q -a 2 %patch1 -p1 -b .u @@ -84,16 +71,6 @@ ln -sf ../lib/upstart/restart %{buildroot}/sbin/restart ln -sf ../lib/upstart/reload %{buildroot}/sbin/reload ln -sf reboot %{buildroot}/lib/upstart/poweroff ln -sf reboot %{buildroot}/lib/upstart/halt -%if 0 -# disabled due the conflicts with systemd -ln -sf upstart %{buildroot}/sbin/init -ln -sf ../lib/upstart/reboot %{buildroot}/sbin/halt -ln -sf ../lib/upstart/reboot %{buildroot}/sbin/poweroff -ln -sf ../lib/upstart/reboot %{buildroot}/sbin/reboot -ln -sf ../lib/upstart/runlevel %{buildroot}/sbin/runlevel -ln -sf ../lib/upstart/shutdown %{buildroot}/sbin/shutdown -ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit -%endif # Rename init.8.gz to upstart.7.gz (#644249) mv %{buildroot}/%{_mandir}/man8/init.8 %{buildroot}/%{_mandir}/man7/upstart.7 # Remove these files due the conflicts with systemd @@ -177,26 +154,6 @@ rm -rf %{buildroot} %{_mandir}/man8/stop.8.gz %{_mandir}/man8/reload.8.gz -%if 0 -# disabled due the conflicts with systemd -%files sysvinit -%defattr(-,root,root,-) -/sbin/halt -/sbin/init -/sbin/poweroff -/sbin/reboot -/sbin/runlevel -/sbin/shutdown -/sbin/telinit -%{_mandir}/man8/halt.8.gz -%{_mandir}/man8/init.8.gz -%{_mandir}/man8/poweroff.8.gz -%{_mandir}/man8/reboot.8.gz -%{_mandir}/man8/runlevel.8.gz -%{_mandir}/man8/shutdown.8.gz -%{_mandir}/man8/telinit.8.gz -%endif - %changelog * Fri May 13 2011 Petr Lautrbach 1.2-3 - add /etc/init.conf file From eb0ab72cba56cd46ae2afd63cbf033bd8571c8e0 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 26 May 2011 11:17:31 +0200 Subject: [PATCH 58/61] upstart-1.2-4.fc16 --- upstart.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 47f743c..0dc0a15 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 1.2 -Release: 3%{?dist} +Release: 4%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -155,6 +155,10 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Wed May 25 2011 Petr Lautrbach 1.2-4 +- drop Obsoletes: upstart-sysvinit (#707507) +- clean upstart-sysvinit stuff from spec file + * Fri May 13 2011 Petr Lautrbach 1.2-3 - add /etc/init.conf file From 9349eae9b164f8d8e954899bf2cfd6d1887d2a01 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 14 Jan 2012 01:37:11 -0600 Subject: [PATCH 59/61] - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index 0dc0a15..e781526 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 1.2 -Release: 4%{?dist} +Release: 5%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -155,6 +155,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Sat Jan 14 2012 Fedora Release Engineering - 1.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + * Wed May 25 2011 Petr Lautrbach 1.2-4 - drop Obsoletes: upstart-sysvinit (#707507) - clean upstart-sysvinit stuff from spec file From 1b0e47b4882b634829f812042bcb7822ea610e53 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 21 Jul 2012 21:00:11 -0500 Subject: [PATCH 60/61] - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild --- upstart.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upstart.spec b/upstart.spec index e781526..ac0d74f 100644 --- a/upstart.spec +++ b/upstart.spec @@ -2,7 +2,7 @@ Name: upstart Version: 1.2 -Release: 5%{?dist} +Release: 6%{?dist} Summary: An event-driven init system Group: System Environment/Base @@ -155,6 +155,9 @@ rm -rf %{buildroot} %{_mandir}/man8/reload.8.gz %changelog +* Sun Jul 22 2012 Fedora Release Engineering - 1.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + * Sat Jan 14 2012 Fedora Release Engineering - 1.2-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild From 5bbe08aad999807ae4b7c5e18472894f715e6497 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 6 Aug 2012 13:27:57 -0400 Subject: [PATCH 61/61] Retire upstart - dead upstream --- dead.package | 1 + fix-selinux-on-run.conf | 8 - init-system-dbus.conf | 6 - init.conf | 0 sources | 2 - tmpfiles.conf | 46 - upstart-audit-events.patch | 271 -- upstart-close-fd.patch | 23 - upstart-lib-upstart.patch | 13 - upstart-override.patch | 5145 ------------------------------- upstart-reexec.patch | 65 - upstart-remove-tests.patch | 213 -- upstart-shutdown-exitcode.patch | 28 - upstart-telinit.patch | 13 - upstart-utmp.patch | 80 - upstart.sh | 4 - upstart.spec | 353 --- 17 files changed, 1 insertion(+), 6270 deletions(-) create mode 100644 dead.package delete mode 100644 fix-selinux-on-run.conf delete mode 100644 init-system-dbus.conf delete mode 100644 init.conf delete mode 100644 sources delete mode 100644 tmpfiles.conf delete mode 100644 upstart-audit-events.patch delete mode 100644 upstart-close-fd.patch delete mode 100644 upstart-lib-upstart.patch delete mode 100644 upstart-override.patch delete mode 100644 upstart-reexec.patch delete mode 100644 upstart-remove-tests.patch delete mode 100644 upstart-shutdown-exitcode.patch delete mode 100644 upstart-telinit.patch delete mode 100644 upstart-utmp.patch delete mode 100644 upstart.sh delete mode 100644 upstart.spec diff --git a/dead.package b/dead.package new file mode 100644 index 0000000..7ceac32 --- /dev/null +++ b/dead.package @@ -0,0 +1 @@ +This package was retired on 2012-08-06 due to no active maintainers for the package. diff --git a/fix-selinux-on-run.conf b/fix-selinux-on-run.conf deleted file mode 100644 index a09734b..0000000 --- a/fix-selinux-on-run.conf +++ /dev/null @@ -1,8 +0,0 @@ -# fix selinux context on /run created and mounted by dracut -# original context is tmpfs_t while we need var_run_t and others - -start on starting rcS - -task - -exec /sbin/restorecon -R /run diff --git a/init-system-dbus.conf b/init-system-dbus.conf deleted file mode 100644 index 0fc6a8a..0000000 --- a/init-system-dbus.conf +++ /dev/null @@ -1,6 +0,0 @@ -# init-system-dbus - tell init process to connect to system dbus server - -start on started messagebus - -task -exec /bin/kill -USR1 1 diff --git a/init.conf b/init.conf deleted file mode 100644 index e69de29..0000000 diff --git a/sources b/sources deleted file mode 100644 index 0f4c518..0000000 --- a/sources +++ /dev/null @@ -1,2 +0,0 @@ -c1b1bab5c1c1ed2595081d8178542b37 upstart-1.2.tar.gz -dce904a3284fb76fa136c618b9e8a80c initjobs-20110502.tar.gz diff --git a/tmpfiles.conf b/tmpfiles.conf deleted file mode 100644 index 5b26039..0000000 --- a/tmpfiles.conf +++ /dev/null @@ -1,46 +0,0 @@ -# tmpfiles - create missing directories in /var/{lock,run} according to -# /etc/tmpfiles.d/ - -start on stopping rcS - -task - -script - [ -d /etc/tmpfiles.d ] || exit 0 - - SELINUX_RESTORE= - - # Check SELinux status - SELINUX_STATE= - if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then - if [ -r "/selinux/enforce" ] ; then - SELINUX_STATE=$(cat "/selinux/enforce") - else - # assume enforcing if you can't read it - SELINUX_STATE=1 - fi - fi - - for i in /etc/tmpfiles.d/*; do - while read type path mode uid gid age; do - # only directories - [ -n "$type" ] || continue - [ $type = "d" ] || [ $type = "D" ] || continue - # only /run /var/run and /var/lock - [ $path != ${path#/run/} ] || - [ $path != ${path#/var/run/} ] || - [ $path != ${path#/var/lock/} ] || - continue - if [ ! -d $path ]; then - mkdir -p $path || continue - SELINUX_RESTORE=1 - chmod $mode $path - chown $uid:$gid $path - fi - done < $i; - done - - if [ -n "$SELINUX_STATE" ] && [ -n "$SELINUX_RESTORE" ]; then - /sbin/restorecon -R /run /var/run /var/lock 2> /dev/null - fi -end script diff --git a/upstart-audit-events.patch b/upstart-audit-events.patch deleted file mode 100644 index f0a2892..0000000 --- a/upstart-audit-events.patch +++ /dev/null @@ -1,271 +0,0 @@ -diff --git a/aclocal.m4 b/aclocal.m4 -index 3d3673e..6e09291 100644 ---- a/aclocal.m4 -+++ b/aclocal.m4 -@@ -1066,6 +1066,7 @@ m4_include([m4/lcmessage.m4]) - m4_include([m4/lib-ld.m4]) - m4_include([m4/lib-link.m4]) - m4_include([m4/lib-prefix.m4]) -+m4_include([m4/libaudit.m4]) - m4_include([m4/libnih.m4]) - m4_include([m4/libtool.m4]) - m4_include([m4/lock.m4]) -diff --git a/config.h.in b/config.h.in -index 8a7d63f..8d000aa 100644 ---- a/config.h.in -+++ b/config.h.in -@@ -118,6 +118,9 @@ - /* Define if your file defines LC_MESSAGES. */ - #undef HAVE_LC_MESSAGES - -+/* linux audit support */ -+#undef HAVE_LIBAUDIT -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_LIMITS_H - -diff --git a/configure.ac b/configure.ac -index 49544e3..1513500 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -40,6 +40,7 @@ AM_PROG_CC_C_O - NIH_C_THREAD - - # Checks for library functions. -+LINUX_AUDIT - - # Other checks - AC_MSG_CHECKING([whether to include sbindir in PATH]) -diff --git a/m4/libaudit.m4 b/m4/libaudit.m4 -new file mode 100644 -index 0000000..6865fb8 ---- /dev/null -+++ b/m4/libaudit.m4 -@@ -0,0 +1,25 @@ -+# libaudit.m4 - Checks for the Linux Audit System support -+# Copyright (c) 2009 Steve Grubb sgrubb@redhat.com -+# -+AC_DEFUN([LINUX_AUDIT], -+[ -+ AC_ARG_WITH(libaudit, -+ [ --with-libaudit=[auto/yes/no] Add Linux audit support [default=auto]],, -+ with_libaudit=auto) -+ -+ # Check for Linux auditing API -+ # -+ # libaudit detection -+ -+ if test x$with_libaudit = xno ; then -+ have_libaudit=no; -+ else -+ # See if we have audit daemon library -+ AC_CHECK_LIB(audit, audit_log_user_message, -+ AUDIT_LDADD=-laudit,) -+ fi -+ AC_SUBST(AUDIT_LDADD) -+ if test x$AUDIT_LDADD != x ; then -+ AC_DEFINE(HAVE_LIBAUDIT,1,[linux audit support]) -+ fi -+]) -diff --git a/util/Makefile.am b/util/Makefile.am -index 0b49c10..9a772d5 100644 ---- a/util/Makefile.am -+++ b/util/Makefile.am -@@ -45,14 +45,17 @@ reboot_SOURCES = \ - utmp.c utmp.h - reboot_LDADD = \ - $(LTLIBINTL) \ -- $(NIH_LIBS) -+ $(NIH_LIBS) \ -+ $(AUDIT_LDADD) -+ - - runlevel_SOURCES = \ - runlevel.c \ - utmp.c utmp.h - runlevel_LDADD = \ - $(LTLIBINTL) \ -- $(NIH_LIBS) -+ $(NIH_LIBS) \ -+ $(AUDIT_LDADD) - - shutdown_SOURCES = \ - shutdown.c \ -@@ -64,7 +67,8 @@ shutdown_LDADD = \ - $(LTLIBINTL) \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - telinit_SOURCES = \ - telinit.c \ -@@ -76,7 +80,8 @@ telinit_LDADD = \ - $(LTLIBINTL) \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - - com_ubuntu_Upstart_OUTPUTS = \ -@@ -201,7 +206,8 @@ test_sysv_LDADD = \ - $(LTLIBINTL) \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - test_telinit_SOURCES = tests/test_telinit.c telinit.c - test_telinit_CFLAGS = $(AM_CFLAGS) -DTEST -@@ -211,7 +217,8 @@ test_telinit_LDADD = \ - com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \ - $(NIH_LIBS) \ - $(NIH_DBUS_LIBS) \ -- $(DBUS_LIBS) -+ $(DBUS_LIBS) \ -+ $(AUDIT_LDADD) - - - .PHONY: tests -diff --git a/util/reboot.c b/util/reboot.c -index 7a9c071..15028eb 100644 ---- a/util/reboot.c -+++ b/util/reboot.c -@@ -36,6 +36,10 @@ - #include - #include - -+#ifdef HAVE_LIBAUDIT -+#include -+#endif -+ - #include "utmp.h" - - -@@ -103,7 +107,6 @@ static int poweroff = FALSE; - **/ - static int exit_only = FALSE; - -- - /** - * options: - * -@@ -127,6 +130,7 @@ static NihOption options[] = { - NIH_OPTION_LAST - }; - -+static void send_audit_event(void); - - int - main (int argc, -@@ -227,6 +231,8 @@ main (int argc, - /* Re-enable Control-Alt-Delete in case it breaks */ - reboot (RB_ENABLE_CAD); - -+ send_audit_event (); -+ - /* Do the syscall */ - switch (mode) { - case REBOOT: -@@ -248,3 +254,21 @@ main (int argc, - - return 0; - } -+ -+/** -+ * send_audit_event -+ * -+ * Send system shutdown audit event -+ **/ -+static void -+send_audit_event (void) -+{ -+#ifdef HAVE_LIBAUDIT -+ int fd = audit_open (); -+ if (fd < 0) -+ return; -+ audit_log_user_message (fd, AUDIT_SYSTEM_SHUTDOWN, "init", -+ NULL, NULL, NULL, 1); -+ close (fd); -+#endif -+} -diff --git a/util/sysv.c b/util/sysv.c -index fbca39f..5476f79 100644 ---- a/util/sysv.c -+++ b/util/sysv.c -@@ -36,6 +36,12 @@ - #include - #include - -+#include -+#ifdef HAVE_LIBAUDIT -+#include -+#include -+#endif -+ - #include "dbus/upstart.h" - - #include "utmp.h" -@@ -54,6 +60,7 @@ - - /* Prototypes for static functions */ - static void error_handler (NihError **err, NihDBusMessage *message); -+static void send_audit_event (int old, int level); - - - /** -@@ -161,6 +168,8 @@ sysv_change_runlevel (int runlevel, - runlevel, prevlevel) < 0) - nih_free (nih_error_get ()); - -+ send_audit_event(prevlevel, runlevel); -+ - /* Make the EmitEvent call, we don't wait for the event to finish - * because sysvinit never did. - */ -@@ -199,3 +208,41 @@ error_handler (NihError ** err, - { - *err = nih_error_steal (); - } -+ -+/** -+ * send_audit_event -+ * @old: current run level -+ * @level: new run level -+ * -+ * Send system runlevel change audit event. If level is 0, then -+ * we consider this to be a reboot event. -+ **/ -+static void -+send_audit_event (int old, int level) -+{ -+#ifdef HAVE_LIBAUDIT -+ int fd = audit_open (); -+ -+ if (fd < 0) -+ return; -+ -+ /* first runlevel change after boot */ -+ if (old == 'N') -+ audit_log_user_message (fd, AUDIT_SYSTEM_BOOT, "init", -+ NULL, NULL, NULL, 1); -+ -+ char buf[64]; -+ -+ snprintf (buf, sizeof (buf), -+ "old-level=%c new-level=%c", old, level); -+ audit_log_user_message (fd, AUDIT_SYSTEM_RUNLEVEL, buf, -+ NULL, NULL, NULL, 1); -+ -+ /* shutdown or reboot */ -+ if (level == '0' || level == '6') -+ audit_log_user_message (fd, AUDIT_SYSTEM_SHUTDOWN, "init", -+ NULL, NULL, NULL, 1); -+ -+ close (fd); -+#endif -+} diff --git a/upstart-close-fd.patch b/upstart-close-fd.patch deleted file mode 100644 index 04391d1..0000000 --- a/upstart-close-fd.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/init/job_process.c b/init/job_process.c -index 8ce2f72..c2c96cb 100644 ---- a/init/job_process.c -+++ b/init/job_process.c -@@ -298,6 +298,7 @@ job_process_run (Job *job, - - /* Feed the script to the child process */ - if (shell) { -+ nih_local char *cmd = NULL; - NihIo *io; - - /* Clean up and close the reading end (we don't need it) */ -@@ -317,6 +318,10 @@ job_process_run (Job *job, - nih_free (err); - } - -+ /* Close leaking fd first */ -+ cmd = NIH_MUST (nih_sprintf (NULL, "<&%d- ;", fds[0])); -+ NIH_ZERO (nih_io_write (io, cmd, strlen (cmd))); -+ - NIH_ZERO (nih_io_write (io, script, strlen (script))); - nih_io_shutdown (io); - } diff --git a/upstart-lib-upstart.patch b/upstart-lib-upstart.patch deleted file mode 100644 index bcef9d0..0000000 --- a/upstart-lib-upstart.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/init/paths.h b/init/paths.h -index c7ddec1..1402e9d 100644 ---- a/init/paths.h -+++ b/init/paths.h -@@ -26,7 +26,7 @@ - * This is the default PATH set by the init process itself. - **/ - #ifndef PATH --#define _PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin" -+#define _PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/lib/upstart:/sbin:/bin" - #ifdef EXTRA_PATH - #define PATH _PATH ":" EXTRA_PATH - #else diff --git a/upstart-override.patch b/upstart-override.patch deleted file mode 100644 index 7989d57..0000000 --- a/upstart-override.patch +++ /dev/null @@ -1,5145 +0,0 @@ -diff --git a/init/conf.c b/init/conf.c -index 89d2cd3..a5a9b85 100644 ---- a/init/conf.c -+++ b/init/conf.c -@@ -49,7 +49,7 @@ - #include "parse_conf.h" - #include "conf.h" - #include "errors.h" -- -+#include "paths.h" - - /* Prototypes for static functions */ - static int conf_source_reload_file (ConfSource *source) -@@ -71,9 +71,19 @@ static int conf_file_visitor (ConfSource *source, - struct stat *statbuf) - __attribute__ ((warn_unused_result)); - --static int conf_reload_path (ConfSource *source, const char *path) -+static int conf_reload_path (ConfSource *source, const char *path, -+ const char *override_path) -+ __attribute__ ((warn_unused_result)); -+ -+static inline int is_conf_file (const char *path) - __attribute__ ((warn_unused_result)); - -+static inline int is_conf_file_std (const char *path) -+ __attribute__ ((warn_unused_result)); -+ -+static inline int -+is_conf_file_override (const char *path) -+ __attribute__ ((warn_unused_result)); - - /** - * conf_sources: -@@ -86,6 +96,115 @@ NihList *conf_sources = NULL; - - - /** -+ * is_conf_file_std: -+ * @path: path to check. -+ * -+ * Determine if specified path contains a legitimate -+ * configuration file name. -+ * -+ * Returns: TRUE if @path contains a valid configuration file name, -+ * else FALSE. -+ * -+ **/ -+static inline int -+is_conf_file_std (const char *path) -+{ -+ char *ptr = strrchr (path, '.'); -+ -+ if (ptr && IS_CONF_EXT_STD (ptr)) -+ return TRUE; -+ -+ return FALSE; -+} -+ -+/** -+ * is_conf_file_override: -+ * @path: path to check. -+ * -+ * Determine if specified path contains a legitimate -+ * override file name. -+ * -+ * Returns: TRUE if @path contains a valid override file name, -+ * else FALSE. -+ * -+ **/ -+static inline int -+is_conf_file_override (const char *path) -+{ -+ char *ptr = strrchr (path, '.'); -+ -+ if (ptr && IS_CONF_EXT_OVERRIDE (ptr)) -+ return TRUE; -+ -+ return FALSE; -+} -+ -+/** -+ * is_conf_file: -+ * @path: path to check. -+ * -+ * Determine if specified path contains a legitimate -+ * configuration file or override file name. -+ * -+ * Returns: TRUE if @path contains a valid configuration -+ * file or override file name, else FALSE. -+ * -+ **/ -+static inline int -+is_conf_file (const char *path) -+{ -+ char *ptr = strrchr (path, '.'); -+ -+ if (ptr && (ptr > path) && (ptr[-1] != '/') && IS_CONF_EXT (ptr)) -+ return TRUE; -+ -+ return FALSE; -+} -+ -+/** -+ * Convert a configuration file name to an override file name and vice -+ * versa. -+ * -+ * For example, if @path is "foo.conf", this function will return -+ * "foo.override", whereas if @path is "foo.override", it will return -+ * "foo.conf". -+ * -+ * Note that this function should be static, but isn't to allow the -+ * tests to access it. -+ * -+ * @parent: parent of returned path, -+ * @path: path to a configuration file. -+ * -+ * Returns: newly allocated toggled path, or NULL on error. -+ **/ -+char * -+toggle_conf_name (const void *parent, -+ const char *path) -+{ -+ char *new_path; -+ char *ext; -+ char *new_ext; -+ size_t len; -+ -+ ext = strrchr (path, '.'); -+ if (!ext) -+ return NULL; -+ -+ new_ext = IS_CONF_EXT_STD (ext) -+ ? CONF_EXT_OVERRIDE -+ : CONF_EXT_STD; -+ -+ len = strlen (new_ext); -+ -+ new_path = NIH_MUST (nih_strndup (parent, path, (ext - path) + len)); -+ -+ memcpy (new_path + (ext - path), new_ext, len); -+ -+ return new_path; -+} -+ -+ -+/** - * conf_init: - * - * Initialise the conf_sources list. -@@ -233,10 +352,9 @@ conf_reload (void) - NihError *err; - - err = nih_error_get (); -- if (err->number != ENOENT) -- nih_error ("%s: %s: %s", source->path, -- _("Unable to load configuration"), -- err->message); -+ nih_error ("%s: %s: %s", source->path, -+ _("Unable to load configuration"), -+ err->message); - nih_free (err); - } - } -@@ -329,10 +447,16 @@ static int - conf_source_reload_file (ConfSource *source) - { - NihError *err = NULL; -+ nih_local char *override_path = NULL; -+ -+ struct stat statbuf; - - nih_assert (source != NULL); - nih_assert (source->type == CONF_FILE); - -+ /* this function should only be called for standard -+ * configuration files. -+ */ - if (! source->watch) { - nih_local char *dpath = NULL; - char *dname; -@@ -361,7 +485,7 @@ conf_source_reload_file (ConfSource *source) - /* Parse the file itself. If this fails, then we can discard the - * inotify error, since this one will be better. - */ -- if (conf_reload_path (source, source->path) < 0) { -+ if (conf_reload_path (source, source->path, NULL) < 0) { - if (err) - nih_free (err); - -@@ -382,6 +506,26 @@ conf_source_reload_file (ConfSource *source) - nih_free (err); - } - -+ if (! is_conf_file_std (source->path)) -+ return 0; -+ -+ override_path = toggle_conf_name (NULL, source->path); -+ -+ if (stat (override_path, &statbuf) != 0) -+ return 0; -+ -+ nih_debug ("Updating configuration for %s from %s", -+ source->path, override_path); -+ if (conf_reload_path (source, source->path, override_path) < 0) { -+ NihError *err; -+ -+ err = nih_error_get (); -+ nih_error ("%s: %s: %s", override_path, -+ _("Error while reloading configuration file"), -+ err->message); -+ nih_free (err); -+ } -+ - return 0; - } - -@@ -501,19 +645,18 @@ conf_file_filter (ConfSource *source, - * @is_dir: TRUE of @path is a directory. - * - * This is the file filter used for the jobs directory, we only care -- * about paths with the ".conf" extension. Directories that -- * match the nih_file_ignore() function are also ignored. -+ * about paths with particular extensions (see IS_CONF_EXT). -+ * -+ * Directories that match the nih_file_ignore() function are also ignored. - * -- * Returns: FALSE if @path ends in ".conf", or is the original source, -- * TRUE otherwise. -+ * Returns: FALSE if @path ends in ".conf" or ".override", -+ * or is the original source, TRUE otherwise. - **/ - static int - conf_dir_filter (ConfSource *source, - const char *path, - int is_dir) - { -- char *ptr; -- - nih_assert (source != NULL); - nih_assert (path != NULL); - -@@ -523,8 +666,7 @@ conf_dir_filter (ConfSource *source, - if (is_dir) - return nih_file_ignore (NULL, path); - -- ptr = strrchr (path, '.'); -- if (ptr && (ptr > path) && (ptr[-1] != '/') && (! strcmp (ptr, ".conf"))) -+ if (is_conf_file (path)) - return FALSE; - - return TRUE; -@@ -546,29 +688,92 @@ conf_dir_filter (ConfSource *source, - * After checking that it was a regular file that was changed, we reload it; - * we expect this to fail sometimes since the file may be only partially - * written. -- **/ -+ **/ - static void - conf_create_modify_handler (ConfSource *source, - NihWatch *watch, - const char *path, - struct stat *statbuf) - { -+ ConfFile *file = NULL; -+ const char *error_path = path; -+ nih_local char *new_path = NULL; -+ int ret; -+ - nih_assert (source != NULL); - nih_assert (watch != NULL); - nih_assert (path != NULL); - nih_assert (statbuf != NULL); - -+ /* note that symbolic links are ignored */ - if (! S_ISREG (statbuf->st_mode)) - return; - -- if (conf_reload_path (source, path) < 0) { -+ new_path = toggle_conf_name (NULL, path); -+ file = (ConfFile *)nih_hash_lookup (source->files, new_path); -+ -+ if (is_conf_file_override (path)) { -+ if (! file) { -+ /* override file has no corresponding conf file */ -+ nih_debug ("Ignoring orphan override file %s", path); -+ return; -+ } -+ -+ /* reload conf file */ -+ nih_debug ("Loading configuration file %s", new_path); -+ ret = conf_reload_path (source, new_path, NULL); -+ if (ret < 0) { -+ error_path = new_path; -+ goto error; -+ } -+ -+ /* overlay override settings */ -+ nih_debug ("Loading override file %s for %s", path, new_path); -+ ret = conf_reload_path (source, new_path, path); -+ if (ret < 0) { -+ error_path = path; -+ goto error; -+ } -+ } else { -+ nih_debug ("Loading configuration and override files for %s", path); -+ -+ /* load conf file */ -+ nih_debug ("Loading configuration file %s", path); -+ ret = conf_reload_path (source, path, NULL); -+ if (ret < 0) { -+ error_path = path; -+ goto error; -+ } -+ -+ /* ensure we ignore directory changes (which won't have overrides. */ -+ if (is_conf_file_std (path)) { -+ struct stat st; -+ if (stat (new_path, &st) == 0) { -+ /* overlay override settings */ -+ nih_debug ("Loading override file %s for %s", new_path, path); -+ ret = conf_reload_path (source, path, new_path); -+ if (ret < 0) { -+ error_path = new_path; -+ goto error; -+ } -+ } -+ -+ } -+ } -+ -+ return; -+ -+error: -+ { - NihError *err; - - err = nih_error_get (); -- nih_error ("%s: %s: %s", path, -- _("Error while loading configuration file"), -- err->message); -+ nih_error ("%s: %s: %s", error_path, -+ _("Error while loading configuration file"), -+ err->message); - nih_free (err); -+ if (file) -+ nih_unref (file, source); - } - } - -@@ -585,13 +790,14 @@ conf_create_modify_handler (ConfSource *source, - * - * We lookup the file in our hash table, and if we can find it, perform - * the usual deletion of it. -- **/ -+ **/ - static void - conf_delete_handler (ConfSource *source, - NihWatch *watch, - const char *path) - { - ConfFile *file; -+ nih_local char *new_path = NULL; - - nih_assert (source != NULL); - nih_assert (watch != NULL); -@@ -603,7 +809,11 @@ conf_delete_handler (ConfSource *source, - * it's probably a directory or something, so just ignore it. - */ - file = (ConfFile *)nih_hash_lookup (source->files, path); -- if (! file) { -+ /* Note we have to be careful to consider deletion of directories too. -+ * This is handled implicitly by the override check which will return -+ * false if passed a directory in this case. -+ */ -+ if (! file && ! is_conf_file_override (path)) { - if (! strcmp (watch->path, path)) { - nih_warn ("%s: %s", source->path, - _("Configuration directory deleted")); -@@ -614,7 +824,30 @@ conf_delete_handler (ConfSource *source, - return; - } - -- nih_unref (file, source); -+ /* non-override files (and directories) are the simple case, so handle -+ * them and leave. -+ */ -+ if (! is_conf_file_override (path)) { -+ nih_unref (file, source); -+ return; -+ } -+ -+ /* if an override file is deleted for which there is a corresponding -+ * conf file, reload the conf file to remove any modifications -+ * introduced by the override file. -+ */ -+ new_path = toggle_conf_name (NULL, path); -+ file = (ConfFile *)nih_hash_lookup (source->files, new_path); -+ -+ if (file) { -+ nih_debug ("Reloading configuration for %s on deletion of overide (%s)", -+ new_path, path); -+ -+ if ( conf_reload_path (source, new_path, NULL) < 0 ) { -+ nih_warn ("%s: %s", new_path, -+ _("Unable to reload configuration after override deletion")); -+ } -+ } - } - - /** -@@ -637,22 +870,61 @@ conf_file_visitor (ConfSource *source, - const char *path, - struct stat *statbuf) - { -+ ConfFile *file = NULL; -+ nih_local char *new_path = NULL; -+ - nih_assert (source != NULL); - nih_assert (dirname != NULL); - nih_assert (path != NULL); - nih_assert (statbuf != NULL); - -+ /* We assume that CONF_EXT_STD files are visited before -+ * CONF_EXT_OVERRIDE files. Happily, this assumption is currently -+ * valid since CONF_EXT_STD comes before CONF_EXT_OVERRIDE if ordered -+ * alphabetically. -+ * -+ * If this were ever to change (for example if we decided to -+ * rename the CONF_EXT_OVERRIDE files to end in ".abc", say), the logic -+ * in this function would be erroneous since it would never be possible when -+ * visiting an override file (before a conf file) to lookup a conf file -+ * in the hash, since the conf file would not yet have been seen and thus would -+ * not exist in the hash (yet). -+ */ -+ nih_assert (CONF_EXT_STD[1] < CONF_EXT_OVERRIDE[1]); -+ - if (! S_ISREG (statbuf->st_mode)) - return 0; - -- if (conf_reload_path (source, path) < 0) { -- NihError *err; -+ if (is_conf_file_std (path)) { -+ if (conf_reload_path (source, path, NULL) < 0) { -+ NihError *err; - -- err = nih_error_get (); -- nih_error ("%s: %s: %s", path, -- _("Error while loading configuration file"), -- err->message); -- nih_free (err); -+ err = nih_error_get (); -+ nih_error ("%s: %s: %s", path, -+ _("Error while loading configuration file"), -+ err->message); -+ nih_free (err); -+ } -+ return 0; -+ } -+ -+ new_path = toggle_conf_name (NULL, path); -+ file = (ConfFile *)nih_hash_lookup (source->files, new_path); -+ -+ if (file) { -+ /* we're visiting an override file with an associated conf file that -+ * has already been loaded, so just overlay the override file. If -+ * there is no corresponding conf file, we ignore the override file. -+ */ -+ if (conf_reload_path (source, new_path, path) < 0) { -+ NihError *err; -+ -+ err = nih_error_get (); -+ nih_error ("%s: %s: %s", new_path, -+ _("Error while reloading configuration file"), -+ err->message); -+ nih_free (err); -+ } - } - - return 0; -@@ -662,12 +934,15 @@ conf_file_visitor (ConfSource *source, - /** - * conf_reload_path: - * @source: configuration source, -- * @path: path of file to be reloaded. -+ * @path: path of conf file to be reloaded. -+ * @override_path: if TRUE and @path refers to a path associated with @source, -+ * overlay the contents of @path into the existing @source entry for -+ * @path. If FALSE, discard any existing knowledge of @path. - * -- * This function is used to parse the file at @path in the context of the -- * given configuration @source. Necessary ConfFile structures are allocated -- * and attached to @source as appropriate. CONF_FILE sources always have -- * a single ConfFile when the file exists. -+ * This function is used to parse the file at @path (or @override_path) in the -+ * context of the given configuration @source. Necessary ConfFile structures -+ * are allocated and attached to @source as appropriate. CONF_FILE sources -+ * always have a single ConfFile when the file exists. - * - * If the file has been parsed before, then the existing item is deleted and - * freed if the file fails to load, or after the new item has been parsed. -@@ -679,36 +954,43 @@ conf_file_visitor (ConfSource *source, - **/ - static int - conf_reload_path (ConfSource *source, -- const char *path) -+ const char *path, -+ const char *override_path) - { -- ConfFile *file; -+ ConfFile *file = NULL; - nih_local char *buf = NULL; - const char *start, *end; - nih_local char *name = NULL; - size_t len, pos, lineno; - NihError *err = NULL; -+ const char *path_to_load; - - nih_assert (source != NULL); - nih_assert (path != NULL); - -- /* Look up the old file in memory, and then free it. In cases -- * of failure, we discard it anyway, so there's no particular reason -+ path_to_load = ( override_path ? override_path : path); -+ -+ /* If there is no corresponding override file, look up the old -+ * conf file in memory, and then free it. In cases of failure, -+ * we discard it anyway, so there's no particular reason - * to keep it around anymore. - */ - file = (ConfFile *)nih_hash_lookup (source->files, path); -- if (file) -+ if (! override_path && file) - nih_unref (file, source); - - /* Read the file into memory for parsing, if this fails we don't - * bother creating a new ConfFile structure for it and bail out - * now. - */ -- buf = nih_file_read (NULL, path, &len); -+ buf = nih_file_read (NULL, path_to_load, &len); - if (! buf) - return -1; - -- /* Parse the file, storing the item in a new ConfFile structure. */ -- file = NIH_MUST (conf_file_new (source, path)); -+ /* Create a new ConfFile structure (if no override_path was specified) */ -+ file = (ConfFile *)nih_hash_lookup (source->files, path); -+ if (! file) -+ file = NIH_MUST (conf_file_new (source, path)); - - pos = 0; - lineno = 1; -@@ -717,7 +999,14 @@ conf_reload_path (ConfSource *source, - case CONF_FILE: - case CONF_DIR: - /* Simple file of options; usually no item attached to it. */ -- nih_debug ("Loading configuration from %s", path); -+ if (override_path) { -+ nih_debug ("Updating configuration for %s from %s", -+ path, override_path); -+ } else { -+ nih_debug ("Loading configuration from %s %s", -+ (source->type == CONF_DIR ? "directory" : "file"), path); -+ } -+ - if (parse_conf (file, buf, len, &pos, &lineno) < 0) - err = nih_error_get (); - -@@ -735,7 +1024,7 @@ conf_reload_path (ConfSource *source, - start++; - - end = strrchr (start, '.'); -- if (end && (! strcmp (end, ".conf"))) { -+ if (end && IS_CONF_EXT (end)) { - name = NIH_MUST (nih_strndup (NULL, start, end - start)); - } else { - name = NIH_MUST (nih_strdup (NULL, start)); -@@ -744,8 +1033,14 @@ conf_reload_path (ConfSource *source, - /* Create a new job item and parse the buffer to produce - * the job definition. - */ -- nih_debug ("Loading %s from %s", name, path); -- file->job = parse_job (NULL, name, buf, len, &pos, &lineno); -+ if (override_path) { -+ nih_debug ("Updating %s (%s) with %s", -+ name, path, override_path); -+ } else { -+ nih_debug ("Loading %s from %s", name, path); -+ } -+ file->job = parse_job (NULL, file->job, -+ name, buf, len, &pos, &lineno); - if (file->job) { - job_class_consider (file->job); - } else { -@@ -779,7 +1074,7 @@ conf_reload_path (ConfSource *source, - case PARSE_EXPECTED_OPERATOR: - case PARSE_EXPECTED_VARIABLE: - case PARSE_MISMATCHED_PARENS: -- nih_error ("%s:%zi: %s", path, lineno, err->message); -+ nih_error ("%s:%zi: %s", path_to_load, lineno, err->message); - nih_free (err); - err = NULL; - break; -@@ -882,3 +1177,149 @@ conf_select_job (const char *name) - - return NULL; - } -+ -+#ifdef DEBUG -+ -+size_t -+debug_count_list_entries (const NihList *list) -+{ -+ size_t i = 0; -+ NIH_LIST_FOREACH (list, iter) { -+ i++; -+ } -+ return i; -+} -+ -+size_t -+debug_count_hash_entries (const NihHash *hash) -+{ -+ size_t i = 0; -+ NIH_HASH_FOREACH_SAFE (hash, iter) { -+ i++; -+ } -+ return i; -+} -+ -+void -+debug_show_job_class (const JobClass *job) -+{ -+ int i; -+ char **env = (char **)job->env; -+ char **export = (char **)job->export; -+ -+ nih_assert (job); -+ -+ nih_debug ("JobClass %p: name='%s', path='%s', task=%d, " -+ "respawn=%d, console=%x, deleted=%d, debug=%d", -+ job, job->name, job->path, job->task, -+ job->respawn, job->console, job->deleted, job->debug); -+ -+ nih_debug ("\tstart_on=%p, stop_on=%p, emits=%p, process=%p", -+ job->start_on, job->stop_on, job->emits, job->process); -+ -+ nih_debug ("\tauthor='%s', description='%s'", -+ job->author, job->description); -+ -+ if (env && *env) { -+ nih_debug ("\tenv:"); -+ i = 0; -+ while ( *env ) { -+ nih_debug ("\t\tenv[%d]='%s' (len=%u+1)", -+ i, *env, strlen (*env)); -+ env++; -+ ++i; -+ } -+ } else { -+ nih_debug ("\tenv: none."); -+ } -+ -+ -+ if (export && *export) { -+ nih_debug ("\texport:"); -+ i = 0; -+ while ( *export ) { -+ nih_debug ("\t\tenv[%d]='%s' (len=%u+1)", -+ i, *export, strlen (*export)); -+ export++; -+ ++i; -+ } -+ } -+ else { -+ nih_debug ("\texport: none"); -+ } -+} -+ -+void -+debug_show_job_classes (void) -+{ -+ nih_debug ("job_classes:"); -+ -+ NIH_HASH_FOREACH_SAFE (job_classes, iter) { -+ JobClass *job = (JobClass *)iter; -+ debug_show_job_class (job); -+ } -+} -+ -+void -+debug_show_event (const Event *event) -+{ -+ nih_assert (event); -+ -+ nih_debug ("Event %p: name='%s', progress=%x, failed=%d, " -+ "blockers=%d, blocking=%p", -+ event, event->name, event->progress, event->failed, -+ event->blockers, (void *)&event->blocking); -+} -+ -+void -+debug_show_conf_file (const ConfFile *file) -+{ -+ nih_assert (file); -+ -+ nih_debug ("ConfFile %p: path='%s', source=%p, flag=%x, job=%p", -+ file, file->path, file->source, file->flag, file->job); -+ -+ /* Some ConfFile objects won't have any JobClass details, for example, -+ * the ConfFile object associated with "/etc/init.conf". -+ */ -+ if (! file->job) { -+ nih_debug ("ConfFile %p: job: no JobClass object.", file); -+ return; -+ } -+ -+ nih_debug ("ConfFile %p: job:", file); -+ debug_show_job_class (file->job); -+} -+ -+void -+debug_show_conf_source (const ConfSource *source) -+{ -+ nih_assert (source); -+ -+ nih_debug ("ConfSource %p: path='%s', type=%x, flag=%x", -+ source, source->path, source->type, source->flag); -+ -+ nih_debug ("ConfSource %p files (%d):", source, -+ debug_count_hash_entries (source->files)); -+ -+ NIH_HASH_FOREACH (source->files, file_iter) { -+ ConfFile *file = (ConfFile *)file_iter; -+ debug_show_conf_file (file); -+ } -+} -+ -+void -+debug_show_conf_sources (void) -+{ -+ nih_assert (conf_sources); -+ -+ nih_debug ("conf_sources:"); -+ -+ NIH_LIST_FOREACH (conf_sources, iter) { -+ ConfSource *source = (ConfSource *)iter; -+ debug_show_conf_source (source); -+ } -+} -+ -+#endif /* DEBUG */ -+ -diff --git a/init/conf.h b/init/conf.h -index d6915f3..bac02ac 100644 ---- a/init/conf.h -+++ b/init/conf.h -@@ -124,6 +124,46 @@ int conf_file_destroy (ConfFile *file); - - JobClass * conf_select_job (const char *name); - -+char *toggle_conf_name (const void *parent, const char *path) -+ __attribute__ ((warn_unused_result, malloc)); -+ -+#ifdef DEBUG -+ -+/* used for debugging only */ -+ -+size_t -+debug_count_hash_entries (const NihHash *hash); -+ -+size_t -+debug_count_list_entries (const NihList *list) -+ __attribute__ ((unused)); -+ -+void -+debug_show_job_class (const JobClass *job) -+ __attribute__ ((unused)); -+ -+void -+debug_show_job_classes (void) -+ __attribute__ ((unused)); -+ -+void -+debug_show_event (const Event *event) -+ __attribute__ ((unused)); -+ -+void -+debug_show_conf_file(const ConfFile *file) -+ __attribute__ ((unused)); -+ -+void -+debug_show_conf_source(const ConfSource *source) -+ __attribute__ ((unused)); -+ -+void -+debug_show_conf_sources(void) -+ __attribute__ ((unused)); -+ -+#endif -+ - NIH_END_EXTERN - - #endif /* INIT_CONF_H */ -diff --git a/init/man/init.5 b/init/man/init.5 -index 73fff91..56a4d0e 100644 ---- a/init/man/init.5 -+++ b/init/man/init.5 -@@ -1,42 +1,79 @@ --.TH init 5 2010-12-14 "Upstart" -+.TH init 5 2011-01-12 "Upstart" - .\" - .SH NAME - init \- Upstart init daemon job configuration - .\" - .SH SYNOPSIS --.B /etc/init -+.B /etc/init/ - .\" - .SH DESCRIPTION - On startup, the Upstart - .BR init (8) --daemon reads its job configuration from the --.I /etc/init --directory, and watches for future changes using -+daemon reads its job configuration from files in the -+.I /etc/init/ -+directory, and watches for future changes to these files using - .BR inotify (7). - --Files in this directory must end in --.I .conf --and may also be present in sub-directories. -+To be considered by Upstart, files in this directory must have a -+recognized suffix and may also be present in sub-directories. There are -+two recognized suffixes: - --Each file defines a single service or task, with the name taken from its --relative path within the directory without the extension. For example a --job defined in -+.IP \(bu 4 -+Files ending in -+.I .conf -+are called configuration files, or simply "conf files" for short. -+These are the primary vehicle for specifying a job. -+.IP \(bu 4 -+Files ending in -+.I .override -+are called override files. If an override file is present, the stanzas -+it contains take precedence over those equivalently named stanzas in the -+corresponding configuration file contents for a particular job. -+The main use for override files is to modify how a job will run without -+having to modify its configuration file directly. See the section -+\fBOverride File Handling\fP below for further details. -+.P -+A job can thus be defined by either: -+.IP \[bu] 2 -+A single configuration file. -+.IP \[bu] -+A single configuration file \fBand\fP a single override file. -+.P -+Unless explicitly stated otherwise, any reference to a jobs -+configuration can refer both to a configuration file or an override -+file. -+ -+Each configuration file defines the template for a single \fIservice\fP -+(long-running process or daemon) or \fItask\fP (short-lived process). -+ -+Note that a configuration file is not itself a job: it is a description -+of an environmenta job could be run in. A job is the runtime embodiment -+of a configuration file. -+ -+The configuration file name as displayed by Upstart and associated -+tooling is taken from its relative path within the directory without the -+extension. For example a configuration file - .I /etc/init/rc-sysinit.conf - is named - .IR rc-sysinit , --while a job defined in -+while a configuration file - .I /etc/init/net/apache.conf - is named - .IR net/apache . -+Since override files only modify the way a configuration file is -+interpreted, they are not named. - --These files are plain text and should not be executable. -+Configuration files are plain text and should not be executable. - .\" --.SS Format -+.SS Configuration File Format - Each line begins with a configuration stanza and continues until either - the end of the line or a line containing a closing stanza. Line breaks - within a stanza are permitted within single or double quotes, or if - preceeded by a blackslash. - -+If a stanza is duplicated, the last occurence will be used. Unrecognized -+stanzas will generate parse errors, which will stop a job from running. -+ - Stanzas and their arguments are delimited by whitespace, which consists - of one or more space or tab characters which are otherwise ignored unless - placed within single or double quotes. -@@ -144,10 +181,10 @@ event is emitted. It is typically used to clean up the environment, - such as removing temporary directories. - - .PP --All of these processes, including the main process, are optional. Services --without a main process will appear to be running until they are stopped, --this is commonly used to define states such as runlevels. It's quite --permissable to have no main process, but to have -+All of these processes, including the main process, are optional. -+Services without a main process will appear to be running until they are -+stopped: this is commonly used to define states such as runlevels. It -+is permissable to have no main process, but to have - .B pre-start - and - .B post-stop -@@ -249,7 +286,7 @@ The - .B stop on - stanza defines the set of events that will cause the job to be automatically - stopped. It has the same syntax as --.B start on -+\fBstart on\fP. - - .I VALUE - may additionally expand the value of any variable that came from the -@@ -306,7 +343,8 @@ utility to default to acting on the job the commands are called from. - .B env \fIKEY\fR[=\fIVALUE\fR] - Defines a default environment variable, the value of which may be overriden - by the event or command that starts the job. --If no value is given, then the value is taken from the -+If \'KEY=VALUE\' is specified, the variable KEY is given the value VALUE. -+If only \'KEY\' is given, then the value is taken from the - .BR init (8) - daemon's own environment. - .\" -@@ -366,7 +404,7 @@ Respawning is subject to a limit, if the job is respawned more than - times in - .I INTERVAL - seconds, it will be considered to be having deeper problems and will --be stopped. -+be stopped. Default COUNT is 10. Default INTERVAL is 5 seconds. - - This only applies to automatic respawns and not the - .BR restart (8) -@@ -385,7 +423,8 @@ normal exit 0 1 TERM HUP - .SS Instances - By default, only one instance of any job is permitted to exist at one - time. Attempting to start a job when it's already starting or running --results in an error. -+results in an error. Note that a job is considered to be running if its -+pre-start process is running. - - Multiple instances may be permitted by defining the names of those - instances. If an instance with the same name is not already starting -@@ -561,6 +600,46 @@ value, both of which are integers. The special value - .B unlimited - may be specified for either. - .\" -+.SS Override File Handling -+Override files allow a jobs environment to be changed without modifying -+the jobs configuration file. Rules governing override files: -+ -+.IP \[bu] 2 -+If a job is embodied with only a configuration file, the contents of -+this file define the job. -+.IP \[bu] -+If an override files exists where there is no existing cofiguration -+file, the override file is ignored. -+.IP \[bu] -+If both a configuration file \fBand\fP an override file exist for a job -+and both files are syntactically correct: -+.RS -+.IP \[bu] 2 -+stanzas in the override file will take precedence over stanzas present -+in the corresponding configuration file. -+.IP \[bu] -+stanzas in the override file which are not present in the corresponding -+configuration file will be honoured when the job runs. -+.RE -+.IP \[bu] -+If both a configuration file and an override file exist for a job and -+subsequently the override file is deleted, the configuration file is -+automatically reloaded with the effect that any changes introduced by -+the override file are undone and the configuration file alone now defines -+the job. -+.IP \[bu] -+If both a configuration file and an override file exist for a job and -+subsequently the configuration file is deleted, a new instance of the -+job can no longer be started (since without a corresponding -+configuration file an override file is ignored). -+.IP \[bu] -+If both a configuration file and an override file exist for a job and -+any of the contents of the override file are invalid, the override file -+is ignored and only the contents of the configuration file are -+considered. -+.P -+ -+.\" - .SS Miscellaneous - .TP - .B kill timeout \fIINTERVAL -@@ -568,7 +647,7 @@ Specifies the interval between sending the job's main process the - .I SIGTERM - and - .I SIGKILL --signals when stopping the running job. -+signals when stopping the running job. Default is 5 seconds. - .\" - .TP - .B expect stop -@@ -609,6 +688,48 @@ Without this stanza - is unable to supervise forking processes and will believe them to have - stopped as soon as they fork on startup. - .\" -+.SH BUGS -+The -+.B and -+and -+.B or -+operators allowed with -+.B start on -+and -+.B stop on -+do not work intuitively: operands to the right of either operator are -+only evaluated once and state information is then discarded. This can -+lead to jobs with complex \fBstart on\fP or \fPstop on\fP conditions -+not behaving as expected \fIwhen restarted\fP. For example, if a job -+encodes the following condition: -+.ti +4 -+.sp 1 -+.nf -+start on A and (B or C) -+.fi -+ -+When 'A' and 'B' become true, the condition is satisfied so the job will -+be run. However, if the job ends and subsequently 'A' and 'C' become true, -+the job will \fInot\fP be re-run even though the condtion is satisfied. -+Avoid using complex conditions with jobs which need to be restarted. -+.\" -+.SH AUTHOR -+Manual page written by Scott James Remnant -+.RB < scott@netsplit.com > -+and James Hunt -+.RB < james.hunt@canonical.com > . -+.\" -+.SH REPORTING BUGS -+Report bugs at -+.RB < https://launchpad.net/upstart/+bugs > -+.\" -+.SH COPYRIGHT -+Copyright \(co 2010 Canonical Ltd. -+.br -+This is free software; see the source for copying conditions. There is NO -+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -+ -+.\" - .SH SEE ALSO - .BR init (8) - .BR sh (1) -diff --git a/init/parse_job.c b/init/parse_job.c -index 4e05454..76d3145 100644 ---- a/init/parse_job.c -+++ b/init/parse_job.c -@@ -263,6 +263,7 @@ static NihConfigStanza stanzas[] = { - /** - * parse_job: - * @parent: parent object for new job, -+ * @update: If not NULL, update the existing specified JobClass, - * @name: name of new job, - * @file: file or string to parse, - * @len: length of @file, -@@ -278,10 +279,12 @@ static NihConfigStanza stanzas[] = { - * of the returned job are freed, the returned job will also be - * freed. - * -- * Returns: new JobClass structure on success, NULL on raised error. -+ * Returns: if @update is NULL, returns new JobClass structure on success, NULL on raised error. -+ * If @update is not NULL, returns @update or NULL on error. - **/ - JobClass * - parse_job (const void *parent, -+ JobClass *update, - const char *name, - const char *file, - size_t len, -@@ -294,13 +297,22 @@ parse_job (const void *parent, - nih_assert (file != NULL); - nih_assert (pos != NULL); - -- class = job_class_new (parent, name); -+ if (update) { -+ class = update; -+ nih_debug ("Reusing JobClass %s (%s)", -+ class->name, class->path); -+ } else { -+ nih_debug ("Creating new JobClass %s", -+ name); -+ class = job_class_new (parent, name); -+ } - if (! class) - nih_return_system_error (NULL); - - if (nih_config_parse_file (file, len, pos, lineno, - stanzas, class) < 0) { -- nih_free (class); -+ if (!update) -+ nih_free (class); - return NULL; - } - -diff --git a/init/parse_job.h b/init/parse_job.h -index f98f70c..65a205f 100644 ---- a/init/parse_job.h -+++ b/init/parse_job.h -@@ -27,8 +27,8 @@ - - NIH_BEGIN_EXTERN - --JobClass *parse_job (const void *parent, const char *name, -- const char *file, size_t len, -+JobClass *parse_job (const void *parent, JobClass *update, -+ const char *name, const char *file, size_t len, - size_t *pos, size_t *lineno) - __attribute__ ((warn_unused_result, malloc)); - -diff --git a/init/paths.h b/init/paths.h -index d7c6fa4..c7ddec1 100644 ---- a/init/paths.h -+++ b/init/paths.h -@@ -103,5 +103,55 @@ - #define TELINIT SBINDIR "/telinit" - #endif - -+/** -+ * File extension for standard configuration files. -+ **/ -+#define CONF_EXT_STD ".conf" -+ -+/** -+ * File extension for override files. -+ * -+ * Note that override files are not stored in the ConfSource 'files' hash: -+ * all JobClass information from override files is added to the JobClass for -+ * the corresponding (CONF_EXT_STD) object. -+ **/ -+#define CONF_EXT_OVERRIDE ".override" -+ -+/** -+ * Determine if specified path extension representes a standard -+ * configuration file. -+ * -+ * @period: pointer to last period in path to check. -+ * -+ * Returns 1 if specified path extension matches that for a -+ * standard configuration file, else return 0. -+ **/ -+#define IS_CONF_EXT_STD(period) \ -+ (!strcmp (period, CONF_EXT_STD)) -+ -+/** -+ * Determine if specified path extension representes an -+ * override file. -+ * -+ * @period: pointer to last period in path to check. -+ * -+ * Returns 1 if specified path extension matches that for -+ * an override file, else return 0. -+ **/ -+#define IS_CONF_EXT_OVERRIDE(period) \ -+ (!strcmp (period, CONF_EXT_OVERRIDE)) -+ -+/** -+ * Determine if specified filename has a valid configuration -+ * file name extension. -+ * -+ * @period: pointer to last period in filename. -+ * -+ * Returns: TRUE if extension beyond @period is one of the -+ * recognized types, else FALSE. -+ **/ -+#define IS_CONF_EXT(period) \ -+ (IS_CONF_EXT_STD(period) || \ -+ IS_CONF_EXT_OVERRIDE(period)) - - #endif /* INIT_PATHS_H */ -diff --git a/init/tests/test_conf.c b/init/tests/test_conf.c -index 35730b7..9a504de 100644 ---- a/init/tests/test_conf.c -+++ b/init/tests/test_conf.c -@@ -47,6 +47,50 @@ - #include "job.h" - #include "conf.h" - -+/* macro to try and ensure the environment is as pristine as possible -+ * (to avoid follow-on errors caused by not freeing objects in a -+ * previous test, say) -+ */ -+#define TEST_ENSURE_CLEAN_ENV() \ -+{ \ -+ setvbuf(stdout, NULL, _IONBF, 0); \ -+ \ -+ if (job_classes) { \ -+ TEST_HASH_EMPTY (job_classes); \ -+ } \ -+ \ -+ if (conf_sources) { \ -+ TEST_LIST_EMPTY (conf_sources); \ -+ } \ -+ \ -+ if (nih_io_watches) { \ -+ TEST_LIST_EMPTY (nih_io_watches); \ -+ } \ -+ \ -+ if (nih_timers) { \ -+ TEST_LIST_EMPTY (nih_timers); \ -+ } \ -+ \ -+ if (events) { \ -+ TEST_LIST_EMPTY (events); \ -+ } \ -+} -+ -+/* Force an inotify watch update */ -+#define TEST_FORCE_WATCH_UPDATE() \ -+{ \ -+ int nfds = 0; \ -+ fd_set readfds, writefds, exceptfds; \ -+ \ -+ FD_ZERO (&readfds); \ -+ FD_ZERO (&writefds); \ -+ FD_ZERO (&exceptfds); \ -+ \ -+ nih_debug("calling nih_io_select_fds"); \ -+ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); \ -+ nih_debug("calling nih_io_handle_fds"); \ -+ nih_io_handle_fds (&readfds, &writefds, &exceptfds); \ -+} - - void - test_source_new (void) -@@ -2417,40 +2461,70 @@ no_inotify: - } - } - -- - void --test_source_reload_file (void) -+test_toggle_conf_name (void) - { -- ConfSource *source; -- ConfFile *file, *old_file; -- FILE *f; -- int ret, fd[4096], i = 0, nfds; -- char dirname[PATH_MAX]; -- char tmpname[PATH_MAX], filename[PATH_MAX]; -- fd_set readfds, writefds, exceptfds; -- NihError *err; -+ char override_ext[] = ".override"; -+ char dirname[PATH_MAX]; -+ char filename[PATH_MAX]; -+ JobClass *job; -+ char *f; -+ char *p; - -- TEST_FUNCTION_FEATURE ("conf_source_reload", -- "with configuration file"); -- program_name = "test"; -- nih_log_set_priority (NIH_LOG_FATAL); -+ TEST_FUNCTION_FEATURE ("toggle_conf_name", -+ "changing conf to override"); - - TEST_FILENAME (dirname); -- mkdir (dirname, 0755); -- - strcpy (filename, dirname); - strcat (filename, "/foo.conf"); -+ f = toggle_conf_name (NULL, filename); -+ TEST_NE_P (f, NULL); - -- f = fopen (filename, "w"); -- fprintf (f, "#nothing to test\n"); -- fclose (f); -+ p = strstr (f, ".override"); -+ TEST_NE_P (p, NULL); -+ TEST_EQ_P (p, f+strlen (f) - strlen (override_ext)); -+ nih_free (f); - -+ TEST_FEATURE ("changing override to conf"); - strcpy (filename, dirname); -- strcat (filename, "/bar.conf"); -+ strcat (filename, "/bar.override"); -+ f = toggle_conf_name (NULL, filename); -+ TEST_NE_P (f, NULL); - -- f = fopen (filename, "w"); -- fprintf (f, "#nothing to test\n"); -- fclose (f); -+ p = strstr (f, ".conf"); -+ TEST_NE_P (p, NULL); -+ TEST_EQ_P (p, f+strlen (f) - strlen (".conf")); -+ nih_free (f); -+ -+ /* test parent param */ -+ job = job_class_new (NULL, "foo"); -+ TEST_NE_P (job, NULL); -+ -+ f = toggle_conf_name (job, filename); -+ TEST_NE_P (f, NULL); -+ -+ TEST_EQ (TRUE, nih_alloc_parent (f, job)); -+ -+ nih_free (job); -+} -+ -+void -+test_override (void) -+{ -+ ConfSource *source; -+ ConfFile *file; -+ FILE *f; -+ int ret, fd[4096], i = 0; -+ char dirname[PATH_MAX]; -+ char filename[PATH_MAX], override[PATH_MAX]; -+ JobClass *job; -+ NihError *err; -+ -+ program_name = "test"; -+ nih_log_set_priority (NIH_LOG_FATAL); -+ -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_GROUP ("override files"); - - /* Make sure that we have inotify before performing some tests... */ - if ((fd[0] = inotify_init ()) < 0) { -@@ -2460,207 +2534,1426 @@ test_source_reload_file (void) - close (fd[0]); - - -- /* Check that we can load a file source for the first time. An -- * inotify watch should be established on the parent directory, -- * the descriptor set to be closed-on-exec, but only that single -- * file parsed. -+ /* Explicit test of behaviour prior to introduction of override files. -+ * -+ * conf with no override before watch: -+ * create conf -+ * create watch -+ * ensure conf loaded -+ * update conf -+ * ensure conf updated -+ * delete conf -+ * ensure conf deleted - */ -- TEST_FEATURE ("with new conf file"); -+ TEST_FEATURE ("with pre-override environment (conf with no override before watch)"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create conf */ - strcpy (filename, dirname); - strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); - -- source = conf_source_new (NULL, filename, CONF_FILE); -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); - ret = conf_source_reload (source); -- - TEST_EQ (ret, 0); -- TEST_ALLOC_SIZE (source->watch, sizeof (NihWatch)); -- TEST_EQ_STR (source->watch->path, dirname); -- TEST_EQ_P (source->watch->data, source); -- -- TEST_TRUE (fcntl (source->watch->fd, F_GETFD) & FD_CLOEXEC); -- -- TEST_EQ (source->flag, TRUE); - -- strcpy (filename, dirname); -- strcat (filename, "/foo.conf"); -+ /* ensure conf loaded */ - file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_NE_P (job->start_on, NULL); - -- TEST_ALLOC_SIZE (file, sizeof (ConfFile)); -- TEST_ALLOC_PARENT (file, source); -- TEST_EQ (file->flag, source->flag); -- TEST_EQ_P (file->data, NULL); -- -- nih_free (file); -+ /* update conf */ -+ f = fopen (filename, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fclose (f); - -+ TEST_FORCE_WATCH_UPDATE(); - -- strcpy (filename, dirname); -- strcat (filename, "/bar.conf"); -+ /* ensure conf updated */ - file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (job->start_on, NULL); - -- TEST_EQ_P (file, NULL); -+ /* delete conf */ -+ unlink (filename); -+ -+ TEST_FORCE_WATCH_UPDATE(); - -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ TEST_HASH_EMPTY (job_classes); - TEST_HASH_EMPTY (source->files); - -- nih_free (source); -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure conf deleted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); - -- /* Check that if we create a new file in the directory, alongside -- * the one we are watching, it is ignored. -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ /* Explicit test of behaviour prior to introduction of override files. -+ * -+ * conf with no override after watch: -+ * create watch -+ * create conf -+ * ensure conf loaded -+ * update conf -+ * ensure conf updated -+ * delete conf -+ * ensure conf deleted - */ -- TEST_FEATURE ("with new file alongside conf file"); -- strcpy (filename, dirname); -- strcat (filename, "/foo.conf"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FEATURE ("with pre-override environment (conf with no override after watch)"); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); - -- source = conf_source_new (NULL, filename, CONF_FILE); -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); - ret = conf_source_reload (source); -- - TEST_EQ (ret, 0); - -+ /* create conf */ - strcpy (filename, dirname); -- strcat (filename, "/baz.conf"); -- -+ strcat (filename, "/foo.conf"); - f = fopen (filename, "w"); -- fprintf (f, "#nothing to test\n"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); - fclose (f); - -- nfds = 0; -- FD_ZERO (&readfds); -- FD_ZERO (&writefds); -- FD_ZERO (&exceptfds); -- -- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -- nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure conf loaded */ - file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); - -- TEST_EQ_P (file, NULL); -- -+ /* update conf */ -+ f = fopen (filename, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fclose (f); - -- /* Check that if we modify a file in the directory, alongside -- * the one we are watching, it is ignored. -- */ -- TEST_FEATURE ("with modification to file alongside conf file"); -- strcpy (filename, dirname); -- strcat (filename, "/bar.conf"); -+ TEST_FORCE_WATCH_UPDATE(); - -- f = fopen (filename, "w"); -- fprintf (f, "#nothing to test\n"); -- fclose (f); -+ /* ensure conf updated */ -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (job->start_on, NULL); - -- nfds = 0; -- FD_ZERO (&readfds); -- FD_ZERO (&writefds); -- FD_ZERO (&exceptfds); -+ /* delete conf */ -+ unlink (filename); - -- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -- nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure conf deleted */ - file = (ConfFile *)nih_hash_lookup (source->files, filename); -- - TEST_EQ_P (file, NULL); -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); - - -- /* Check that the configuration file we're watching can be modified -- * using the direct writing technique. -- */ -- TEST_FEATURE ("with modification (direct write)"); -- strcpy (filename, dirname); -- strcat (filename, "/foo.conf"); -- -- old_file = (ConfFile *)nih_hash_lookup (source->files, filename); -- TEST_FREE_TAG (old_file); -+ TEST_FEATURE ("ensure lone override ignored before watch"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); - -+ /* create override */ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.override"); - f = fopen (filename, "w"); -- fprintf (f, "#still nothing to test\n"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); - fclose (f); - -- nfds = 0; -- FD_ZERO (&readfds); -- FD_ZERO (&writefds); -- FD_ZERO (&exceptfds); -- -- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -- nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); - -- TEST_FREE (old_file); -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure no conf object created */ -+ TEST_HASH_EMPTY (source->files); - file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); - -- TEST_ALLOC_SIZE (file, sizeof (ConfFile)); -- TEST_ALLOC_PARENT (file, source); -- TEST_EQ (file->flag, source->flag); -- TEST_EQ_P (file->data, NULL); -+ /* update override */ -+ f = fopen (filename, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "author \"me\"\n"); -+ fclose (f); - -- old_file = file; -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure no conf object created */ -+ TEST_HASH_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); - -- /* Check that the configuration file we're watching can be modified -- * using the write and then rename technique; it should be parsed -- * and the previous file marked for deletion. -- */ -- TEST_FEATURE ("with modification (atomic rename)"); -- strcpy (tmpname, dirname); -- strcat (tmpname, "/.foo.tmp"); -+ /* delete override */ -+ unlink (filename); -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); - -- f = fopen (tmpname, "w"); -- fprintf (f, "#nothing to test\n"); -- fclose (f); - -- strcpy (filename, dirname); -- strcat (filename, "/foo.conf"); -+ TEST_FEATURE ("ensure lone override ignored after watch"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); - -- rename (tmpname, filename); -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); - -- TEST_FREE_TAG (old_file); -+ strcpy (filename, dirname); -+ strcat (filename, "/bar.override"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fclose (f); - -- nfds = 0; -- FD_ZERO (&readfds); -- FD_ZERO (&writefds); -- FD_ZERO (&exceptfds); -+ TEST_FORCE_WATCH_UPDATE(); - -- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -- nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ /* ensure no conf object created */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "bar"); -+ TEST_EQ_P (job, NULL); - -- TEST_FREE (old_file); -+ /* delete override */ -+ unlink (filename); -+ -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure override still not present */ - file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "bar"); -+ TEST_EQ_P (job, NULL); - -- TEST_ALLOC_SIZE (file, sizeof (ConfFile)); -- TEST_ALLOC_PARENT (file, source); -- TEST_EQ (file->flag, source->flag); -- TEST_EQ_P (file->data, NULL); -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); - -- old_file = file; - -+ TEST_FEATURE ("create conf, watch, then create/modify/delete override"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); - -- /* Check that we can delete the configuration file that we're -- * watching, the metadata for it should be lost. -- */ -- TEST_FEATURE ("with deletion"); -+ /* create conf */ - strcpy (filename, dirname); - strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); - -- unlink (filename); -- -- TEST_FREE_TAG (old_file); -- -- nfds = 0; -- FD_ZERO (&readfds); -- FD_ZERO (&writefds); -- FD_ZERO (&exceptfds); -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); - -- nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -- nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ /* ensure conf loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_P ((job->emits)[1], NULL); -+ TEST_NE_P (job->start_on, NULL); -+ -+ /* create override */ -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fclose (f); - -- TEST_FREE (old_file); -+ TEST_HASH_NOT_EMPTY (source->files); -+ TEST_FORCE_WATCH_UPDATE(); - -+ /* ensure conf updated */ -+ TEST_HASH_NOT_EMPTY (source->files); - file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (job->start_on, NULL); - -+ /* ensure no override in hash */ -+ file = (ConfFile *)nih_hash_lookup (source->files, override); - TEST_EQ_P (file, NULL); - -+ /* modify override */ -+ f = fopen (override, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "emits world\n"); -+ fclose (f); - -- /* Check that the watch allows us to see if the file we want is -- * created using the direct writing technique, and thus parsed. -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf updated */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_STR ((job->emits)[1], "world"); -+ -+ /* delete override */ -+ unlink (override); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf reverted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_NE_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_P ((job->emits)[1], NULL); -+ -+ nih_free (source); -+ unlink (filename); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create watch, conf, then create/modify/delete override"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ /* create conf */ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_P ((job->emits)[1], NULL); -+ TEST_NE_P (job->start_on, NULL); -+ -+ /* create override */ -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fclose (f); -+ -+ TEST_HASH_NOT_EMPTY (source->files); -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf updated */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (job->start_on, NULL); -+ -+ /* ensure no override in hash */ -+ file = (ConfFile *)nih_hash_lookup (source->files, override); -+ TEST_EQ_P (file, NULL); -+ -+ /* modify override */ -+ f = fopen (override, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "emits world\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf updated */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_STR ((job->emits)[1], "world"); -+ -+ /* delete override */ -+ unlink (override); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf reverted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_NE_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_P ((job->emits)[1], NULL); -+ -+ nih_free (source); -+ unlink (filename); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create override, watch, then create/modify/delete conf"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ -+ /* create override */ -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"bar\"\n"); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure no conf object created */ -+ TEST_HASH_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ -+ /* create conf */ -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fprintf (f, "author \"foo\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "bar"); -+ -+ /* modify conf */ -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on wibble\n"); -+ fprintf (f, "emits moo\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf reloaded and updated with override */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "moo"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "bar"); -+ -+ /* delete conf */ -+ unlink (filename); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf object deleted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ TEST_HASH_EMPTY (source->files); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ file = (ConfFile *)nih_hash_lookup (source->files, override); -+ TEST_EQ_P (file, NULL); -+ -+ unlink (override); -+ -+ /* ensure no conf object still */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ TEST_HASH_EMPTY (source->files); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ file = (ConfFile *)nih_hash_lookup (source->files, override); -+ TEST_EQ_P (file, NULL); -+ -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create watch, override, then create/modify/delete conf"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ -+ /* create override */ -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"bar\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure no conf object created */ -+ TEST_HASH_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ -+ /* create conf */ -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fprintf (f, "author \"foo\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "bar"); -+ -+ /* modify conf */ -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on wibble\n"); -+ fprintf (f, "emits moo\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf reloaded and updated with override */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "moo"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "bar"); -+ -+ /* delete conf */ -+ unlink (filename); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf object deleted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ TEST_HASH_EMPTY (source->files); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ file = (ConfFile *)nih_hash_lookup (source->files, override); -+ TEST_EQ_P (file, NULL); -+ -+ unlink (override); -+ -+ /* ensure no conf object still */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ TEST_HASH_EMPTY (source->files); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ file = (ConfFile *)nih_hash_lookup (source->files, override); -+ TEST_EQ_P (file, NULL); -+ -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create override, watch, conf, then modify/delete override"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ -+ /* create override */ -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"bar\"\n"); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure no conf object created */ -+ TEST_HASH_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ -+ /* create conf */ -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fprintf (f, "author \"foo\"\n"); -+ fclose (f); -+ -+ /* FIXME: crashes here */ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "bar"); -+ -+ /* modify override */ -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "author \"meh\"\n"); -+ fprintf (f, "env wibble=wobble\n"); -+ fprintf (f, "manual\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf reloaded and updated with override */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "meh"); -+ TEST_EQ_STR ((job->env)[0], "wibble=wobble"); -+ -+ /* delete override */ -+ unlink (override); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf object reverted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_NE_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "foo"); -+ TEST_EQ_P (job->env, NULL); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ unlink (filename); -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create watch, override, conf, then modify/delete override"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* create override */ -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"bar\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* create conf */ -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "emits hello\n"); -+ fprintf (f, "author \"foo\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "bar"); -+ -+ /* update override */ -+ f = fopen (override, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "author \"me\"\n"); -+ fprintf (f, "env wibble=wobble\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf reloaded and updated with override */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ -+ /* should pick up override, *NOT* conf */ -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "me"); -+ TEST_EQ_STR ((job->env)[0], "wibble=wobble"); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* delete override */ -+ unlink (override); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR (job->author, "foo"); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_NE_P (job->start_on, NULL); -+ TEST_EQ_P (job->env, NULL); -+ -+ unlink (filename); -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create both conf+override files, watch, then modify/delete conf"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create conf */ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "author \"me\"\n"); -+ fprintf (f, "env foo=bar\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); -+ -+ /* create override */ -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"you\"\n"); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_STR (job->author, "you"); -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->env)[0], "foo=bar"); -+ TEST_EQ_P (job->export, NULL); -+ -+ /* modify conf */ -+ f = fopen (filename, "a"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "export foo\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf updated */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_STR ((job->env)[0], "foo=bar"); -+ TEST_NE_P (job->export, NULL); -+ TEST_EQ_STR ((job->export)[0], "foo"); -+ -+ /* delete conf */ -+ unlink (filename); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf object deleted */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_EQ_P (file, NULL); -+ TEST_HASH_EMPTY (source->files); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_EQ_P (job, NULL); -+ file = (ConfFile *)nih_hash_lookup (source->files, override); -+ TEST_EQ_P (file, NULL); -+ -+ unlink (override); -+ nih_free (source); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ TEST_FEATURE ("create both conf+override files, watch, then modify/delete override"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create conf */ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "author \"me\"\n"); -+ fprintf (f, "env foo=bar\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); -+ -+ /* create override */ -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"you\"\n"); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_STR (job->author, "you"); -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->env)[0], "foo=bar"); -+ TEST_EQ_P (job->export, NULL); -+ -+ /* modify override */ -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "description \"hello world\"\n"); -+ fprintf (f, "author \"ubuntu\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf updated */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR (job->author, "ubuntu"); -+ TEST_NE_P (job->description, NULL); -+ TEST_EQ_STR (job->description, "hello world"); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_NE_P (job->start_on, NULL); -+ -+ /* delete override */ -+ unlink (override); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf updated */ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_NE_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->env)[0], "foo=bar"); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_STR (job->author, "me"); -+ TEST_EQ_P (job->description, NULL); -+ -+ nih_free (source); -+ unlink (filename); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ TEST_FEATURE ("create conf, watch, then create invalid override, delete override"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create conf */ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "author \"wibble\"\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_NE_P (job->start_on, NULL); -+ -+ /* create (partially) invalid override (which should be -+ * fully ignored) -+ */ -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "bleaugh!\n"); -+ fprintf (f, "wha...?\n"); -+ fprintf (f, "author \"moo\"\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ unlink (override); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf still loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_NE_P (job->start_on, NULL); -+ TEST_EQ_STR (job->author, "wibble"); -+ -+ nih_free (source); -+ unlink (filename); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ TEST_FEATURE ("ensure override ignored for CONF_FILE"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create empty conf */ -+ strcpy (filename, dirname); -+ strcat (filename, "/init.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_FILE); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ -+ /* We expect conf_source_reload to fail in this situation since -+ * although "init.conf" is a supported config file, it is not -+ * allowed to contain any stanzas, implying that it can only -+ * contain comments. In fact, if the file exists but is zero -+ * size that is currently an error since upstart blindly calls -+ * nih_file_read(), which will fail since there are no bytes to -+ * read. -+ */ -+ TEST_NE (ret, 0); -+ err = nih_error_steal (); -+ TEST_EQ (err->number, EILSEQ); -+ nih_free (err); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf NOT loaded */ -+ TEST_HASH_EMPTY (source->files); -+ -+ /* create override */ -+ strcpy (override, dirname); -+ strcat (override, "/init.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fclose (f); -+ -+ TEST_FORCE_WATCH_UPDATE(); -+ -+ /* ensure conf still NOT loaded */ -+ TEST_HASH_EMPTY (source->files); -+ -+ nih_free (source); -+ unlink (filename); -+ unlink (override); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ /* Consume all available inotify instances so that the following -+ * tests run without inotify. -+ */ -+ for (i = 0; i < 4096; i++) -+ if ((fd[i] = inotify_init ()) < 0) -+ break; -+ -+no_inotify: -+ /* If you don't have inotify, any override file must exist -+ * before the system boots. -+ */ -+ -+ TEST_FEATURE ("both conf+override files with no inotify support"); -+ TEST_ENSURE_CLEAN_ENV (); -+ TEST_FILENAME (dirname); -+ TEST_EQ (mkdir (dirname, 0755), 0); -+ -+ /* create conf */ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ f = fopen (filename, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "start on started\n"); -+ fprintf (f, "author \"me\"\n"); -+ fprintf (f, "env foo=bar\n"); -+ fprintf (f, "emits hello\n"); -+ fclose (f); -+ -+ /* create override */ -+ strcpy (override, dirname); -+ strcat (override, "/foo.override"); -+ f = fopen (override, "w"); -+ TEST_NE_P (f, NULL); -+ fprintf (f, "manual\n"); -+ fprintf (f, "author \"you\"\n"); -+ fclose (f); -+ -+ /* create watch */ -+ source = conf_source_new (NULL, dirname, CONF_JOB_DIR); -+ TEST_NE_P (source, NULL); -+ ret = conf_source_reload (source); -+ TEST_EQ (ret, 0); -+ -+ /* ensure conf loaded */ -+ TEST_HASH_NOT_EMPTY (source->files); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_NE_P (file, NULL); -+ job = (JobClass *)nih_hash_lookup (job_classes, "foo"); -+ TEST_NE_P (job, NULL); -+ TEST_EQ_P (file->job, job); -+ TEST_EQ_STR ((job->emits)[0], "hello"); -+ TEST_EQ_STR (job->author, "you"); -+ TEST_EQ_P (job->start_on, NULL); -+ TEST_EQ_STR ((job->env)[0], "foo=bar"); -+ TEST_EQ_P (job->export, NULL); -+ -+ nih_free (source); -+ unlink (filename); -+ unlink (override); -+ TEST_EQ (rmdir (dirname), 0); -+ -+ -+ nih_log_set_priority (NIH_LOG_MESSAGE); -+ -+ /* Release consumed instances */ -+ for (i = 0; i < 4096; i++) { -+ if (fd[i] < 0) -+ break; -+ -+ close (fd[i]); -+ } -+} -+ -+void -+test_source_reload_file (void) -+{ -+ ConfSource *source; -+ ConfFile *file, *old_file; -+ FILE *f; -+ int ret, fd[4096], i = 0, nfds; -+ char dirname[PATH_MAX]; -+ char tmpname[PATH_MAX], filename[PATH_MAX]; -+ fd_set readfds, writefds, exceptfds; -+ NihError *err; -+ -+ TEST_FUNCTION_FEATURE ("conf_source_reload", -+ "with configuration file"); -+ program_name = "test"; -+ nih_log_set_priority (NIH_LOG_FATAL); -+ -+ TEST_FILENAME (dirname); -+ mkdir (dirname, 0755); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ -+ f = fopen (filename, "w"); -+ fprintf (f, "#nothing to test\n"); -+ fclose (f); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/bar.conf"); -+ -+ f = fopen (filename, "w"); -+ fprintf (f, "#nothing to test\n"); -+ fclose (f); -+ -+ /* Make sure that we have inotify before performing some tests... */ -+ if ((fd[0] = inotify_init ()) < 0) { -+ printf ("SKIP: inotify not available\n"); -+ goto no_inotify; -+ } -+ close (fd[0]); -+ -+ -+ /* Check that we can load a file source for the first time. An -+ * inotify watch should be established on the parent directory, -+ * the descriptor set to be closed-on-exec, but only that single -+ * file parsed. -+ */ -+ TEST_FEATURE ("with new conf file"); -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ -+ source = conf_source_new (NULL, filename, CONF_FILE); -+ ret = conf_source_reload (source); -+ -+ TEST_EQ (ret, 0); -+ TEST_ALLOC_SIZE (source->watch, sizeof (NihWatch)); -+ TEST_EQ_STR (source->watch->path, dirname); -+ TEST_EQ_P (source->watch->data, source); -+ -+ TEST_TRUE (fcntl (source->watch->fd, F_GETFD) & FD_CLOEXEC); -+ -+ TEST_EQ (source->flag, TRUE); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_ALLOC_SIZE (file, sizeof (ConfFile)); -+ TEST_ALLOC_PARENT (file, source); -+ TEST_EQ (file->flag, source->flag); -+ TEST_EQ_P (file->data, NULL); -+ -+ nih_free (file); -+ -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/bar.conf"); -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_EQ_P (file, NULL); -+ -+ TEST_HASH_EMPTY (source->files); -+ -+ nih_free (source); -+ -+ -+ /* Check that if we create a new file in the directory, alongside -+ * the one we are watching, it is ignored. -+ */ -+ TEST_FEATURE ("with new file alongside conf file"); -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ -+ source = conf_source_new (NULL, filename, CONF_FILE); -+ ret = conf_source_reload (source); -+ -+ TEST_EQ (ret, 0); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/baz.conf"); -+ -+ f = fopen (filename, "w"); -+ fprintf (f, "#nothing to test\n"); -+ fclose (f); -+ -+ nfds = 0; -+ FD_ZERO (&readfds); -+ FD_ZERO (&writefds); -+ FD_ZERO (&exceptfds); -+ -+ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -+ nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_EQ_P (file, NULL); -+ -+ -+ /* Check that if we modify a file in the directory, alongside -+ * the one we are watching, it is ignored. -+ */ -+ TEST_FEATURE ("with modification to file alongside conf file"); -+ strcpy (filename, dirname); -+ strcat (filename, "/bar.conf"); -+ -+ f = fopen (filename, "w"); -+ fprintf (f, "#nothing to test\n"); -+ fclose (f); -+ -+ nfds = 0; -+ FD_ZERO (&readfds); -+ FD_ZERO (&writefds); -+ FD_ZERO (&exceptfds); -+ -+ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -+ nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_EQ_P (file, NULL); -+ -+ -+ /* Check that the configuration file we're watching can be modified -+ * using the direct writing technique. -+ */ -+ TEST_FEATURE ("with modification (direct write)"); -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ -+ old_file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ TEST_FREE_TAG (old_file); -+ -+ f = fopen (filename, "w"); -+ fprintf (f, "#still nothing to test\n"); -+ fclose (f); -+ -+ nfds = 0; -+ FD_ZERO (&readfds); -+ FD_ZERO (&writefds); -+ FD_ZERO (&exceptfds); -+ -+ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -+ nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ -+ TEST_FREE (old_file); -+ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_ALLOC_SIZE (file, sizeof (ConfFile)); -+ TEST_ALLOC_PARENT (file, source); -+ TEST_EQ (file->flag, source->flag); -+ TEST_EQ_P (file->data, NULL); -+ -+ old_file = file; -+ -+ -+ /* Check that the configuration file we're watching can be modified -+ * using the write and then rename technique; it should be parsed -+ * and the previous file marked for deletion. -+ */ -+ TEST_FEATURE ("with modification (atomic rename)"); -+ strcpy (tmpname, dirname); -+ strcat (tmpname, "/.foo.tmp"); -+ -+ f = fopen (tmpname, "w"); -+ fprintf (f, "#nothing to test\n"); -+ fclose (f); -+ -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ -+ rename (tmpname, filename); -+ -+ TEST_FREE_TAG (old_file); -+ -+ nfds = 0; -+ FD_ZERO (&readfds); -+ FD_ZERO (&writefds); -+ FD_ZERO (&exceptfds); -+ -+ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -+ nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ -+ TEST_FREE (old_file); -+ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_ALLOC_SIZE (file, sizeof (ConfFile)); -+ TEST_ALLOC_PARENT (file, source); -+ TEST_EQ (file->flag, source->flag); -+ TEST_EQ_P (file->data, NULL); -+ -+ old_file = file; -+ -+ -+ /* Check that we can delete the configuration file that we're -+ * watching, the metadata for it should be lost. -+ */ -+ TEST_FEATURE ("with deletion"); -+ strcpy (filename, dirname); -+ strcat (filename, "/foo.conf"); -+ -+ unlink (filename); -+ -+ TEST_FREE_TAG (old_file); -+ -+ nfds = 0; -+ FD_ZERO (&readfds); -+ FD_ZERO (&writefds); -+ FD_ZERO (&exceptfds); -+ -+ nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds); -+ nih_io_handle_fds (&readfds, &writefds, &exceptfds); -+ -+ TEST_FREE (old_file); -+ -+ file = (ConfFile *)nih_hash_lookup (source->files, filename); -+ -+ TEST_EQ_P (file, NULL); -+ -+ -+ /* Check that the watch allows us to see if the file we want is -+ * created using the direct writing technique, and thus parsed. - */ - TEST_FEATURE ("with creation (direct write)"); - strcpy (filename, dirname); -@@ -2969,8 +4262,6 @@ test_source_reload_file (void) - TEST_HASH_EMPTY (source->files); - - nih_free (source); -- -- - /* Consume all available inotify instances so that the following - * tests run without inotify. - */ -@@ -3456,6 +4747,8 @@ main (int argc, - test_source_reload_conf_dir (); - test_source_reload_file (); - test_source_reload (); -+ test_toggle_conf_name (); -+ test_override (); - test_file_destroy (); - test_select_job (); - -diff --git a/init/tests/test_parse_job.c b/init/tests/test_parse_job.c -index 73218f4..07a99c1 100644 ---- a/init/tests/test_parse_job.c -+++ b/init/tests/test_parse_job.c -@@ -64,7 +64,7 @@ test_parse_job (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -110,7 +110,7 @@ test_parse_job (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -131,6 +131,45 @@ test_parse_job (void) - - nih_free (job); - } -+ -+ TEST_FEATURE ("with non-NULL update parameter (override)"); -+ { -+ JobClass *tmp = NULL; -+ -+ strcpy (buf, "start on starting\n"); -+ strcat (buf, "author \"me\"\n"); -+ -+ pos = 0; -+ lineno = 1; -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), -+ &pos, &lineno); -+ -+ TEST_NE_P (job, NULL); -+ TEST_EQ_STR (job->author, "me"); -+ TEST_NE_P (job->start_on, NULL); -+ -+ strcat (buf, "author \"you\"\n"); -+ strcat (buf, "manual\n"); -+ strcat (buf, "description \"my description\"\n"); -+ -+ pos = 0; -+ lineno = 1; -+ tmp = parse_job (NULL, job, "test", buf, strlen (buf), -+ &pos, &lineno); -+ TEST_NE_P (tmp, NULL); -+ -+ /* if passed a job, the same object should be returned. -+ */ -+ TEST_EQ_P (tmp, job); -+ -+ TEST_EQ_STR (tmp->author, "you"); -+ TEST_EQ_P (tmp->start_on, NULL); -+ TEST_NE_P (tmp->description, NULL); -+ -+ TEST_EQ_STR (tmp->description, "my description"); -+ -+ nih_free (job); -+ } - } - - void -@@ -153,7 +192,7 @@ test_stanza_exec (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -190,7 +229,7 @@ test_stanza_exec (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -229,7 +268,7 @@ test_stanza_exec (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -266,7 +305,7 @@ test_stanza_exec (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -299,7 +338,7 @@ test_stanza_script (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -340,7 +379,7 @@ test_stanza_script (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -379,7 +418,7 @@ test_stanza_script (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -416,7 +455,7 @@ test_stanza_script (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -447,7 +486,7 @@ test_stanza_pre_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -484,7 +523,7 @@ test_stanza_pre_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -524,7 +563,7 @@ test_stanza_pre_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -565,7 +604,7 @@ test_stanza_pre_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -604,7 +643,7 @@ test_stanza_pre_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -643,7 +682,7 @@ test_stanza_pre_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -680,7 +719,7 @@ test_stanza_pre_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -699,7 +738,7 @@ test_stanza_pre_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -718,7 +757,7 @@ test_stanza_pre_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -737,7 +776,7 @@ test_stanza_pre_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -768,7 +807,7 @@ test_stanza_post_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -805,7 +844,7 @@ test_stanza_post_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -845,7 +884,7 @@ test_stanza_post_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -886,7 +925,7 @@ test_stanza_post_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -925,7 +964,7 @@ test_stanza_post_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -964,7 +1003,7 @@ test_stanza_post_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1001,7 +1040,7 @@ test_stanza_post_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1020,7 +1059,7 @@ test_stanza_post_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1039,7 +1078,7 @@ test_stanza_post_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1058,7 +1097,7 @@ test_stanza_post_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1089,7 +1128,7 @@ test_stanza_pre_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1126,7 +1165,7 @@ test_stanza_pre_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1166,7 +1205,7 @@ test_stanza_pre_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1207,7 +1246,7 @@ test_stanza_pre_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1246,7 +1285,7 @@ test_stanza_pre_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1285,7 +1324,7 @@ test_stanza_pre_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1322,7 +1361,7 @@ test_stanza_pre_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1341,7 +1380,7 @@ test_stanza_pre_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1360,7 +1399,7 @@ test_stanza_pre_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1379,7 +1418,7 @@ test_stanza_pre_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1410,7 +1449,7 @@ test_stanza_post_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1447,7 +1486,7 @@ test_stanza_post_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1487,7 +1526,7 @@ test_stanza_post_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1528,7 +1567,7 @@ test_stanza_post_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1567,7 +1606,7 @@ test_stanza_post_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1606,7 +1645,7 @@ test_stanza_post_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1643,7 +1682,7 @@ test_stanza_post_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1662,7 +1701,7 @@ test_stanza_post_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1681,7 +1720,7 @@ test_stanza_post_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1700,7 +1739,7 @@ test_stanza_post_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -1731,7 +1770,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1776,7 +1815,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1828,7 +1867,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1879,7 +1918,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -1942,7 +1981,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2012,7 +2051,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2090,7 +2129,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2170,7 +2209,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2249,7 +2288,7 @@ test_stanza_start (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2291,7 +2330,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2310,7 +2349,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2329,7 +2368,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2348,7 +2387,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2367,7 +2406,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2384,7 +2423,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2403,7 +2442,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2422,7 +2461,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2441,7 +2480,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2460,7 +2499,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2479,7 +2518,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2498,7 +2537,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2517,7 +2556,7 @@ test_stanza_start (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -2551,7 +2590,7 @@ test_stanza_manual (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2586,7 +2625,7 @@ test_stanza_manual (void) - TEST_FEATURE ("manual stanza after start on"); - strcpy (buf, "start on wibble\nmanual\n"); - -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - TEST_NE_P (job, NULL); -@@ -2616,7 +2655,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2661,7 +2700,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2713,7 +2752,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2764,7 +2803,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2827,7 +2866,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2897,7 +2936,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -2975,7 +3014,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3055,7 +3094,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3134,7 +3173,7 @@ test_stanza_stop (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3176,7 +3215,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3195,7 +3234,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3214,7 +3253,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3233,7 +3272,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3252,7 +3291,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3269,7 +3308,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3288,7 +3327,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3307,7 +3346,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3326,7 +3365,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3345,7 +3384,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3364,7 +3403,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3383,7 +3422,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3402,7 +3441,7 @@ test_stanza_stop (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3432,7 +3471,7 @@ test_stanza_description (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3465,7 +3504,7 @@ test_stanza_description (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3498,7 +3537,7 @@ test_stanza_description (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3517,7 +3556,7 @@ test_stanza_description (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3547,7 +3586,7 @@ test_stanza_author (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3580,7 +3619,7 @@ test_stanza_author (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3613,7 +3652,7 @@ test_stanza_author (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3632,7 +3671,7 @@ test_stanza_author (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3662,7 +3701,7 @@ test_stanza_version (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3695,7 +3734,7 @@ test_stanza_version (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3728,7 +3767,7 @@ test_stanza_version (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3747,7 +3786,7 @@ test_stanza_version (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3777,7 +3816,7 @@ test_stanza_emits (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3814,7 +3853,7 @@ test_stanza_emits (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3857,7 +3896,7 @@ test_stanza_emits (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3899,7 +3938,7 @@ test_stanza_emits (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -3929,7 +3968,7 @@ test_stanza_expect (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3962,7 +4001,7 @@ test_stanza_expect (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -3995,7 +4034,7 @@ test_stanza_expect (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4028,7 +4067,7 @@ test_stanza_expect (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4061,7 +4100,7 @@ test_stanza_expect (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4093,7 +4132,7 @@ test_stanza_expect (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4112,7 +4151,7 @@ test_stanza_expect (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4131,7 +4170,7 @@ test_stanza_expect (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4159,7 +4198,7 @@ test_stanza_respawn (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4193,7 +4232,7 @@ test_stanza_respawn (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4226,7 +4265,7 @@ test_stanza_respawn (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4260,7 +4299,7 @@ test_stanza_respawn (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4293,7 +4332,7 @@ test_stanza_respawn (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4326,7 +4365,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4345,7 +4384,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4364,7 +4403,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4383,7 +4422,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4402,7 +4441,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4421,7 +4460,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4440,7 +4479,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4459,7 +4498,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4478,7 +4517,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4497,7 +4536,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4516,7 +4555,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4535,7 +4574,7 @@ test_stanza_respawn (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4565,7 +4604,7 @@ test_stanza_task (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4597,7 +4636,7 @@ test_stanza_task (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4629,7 +4668,7 @@ test_stanza_task (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4659,7 +4698,7 @@ test_stanza_instance (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4693,7 +4732,7 @@ test_stanza_instance (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4726,7 +4765,7 @@ test_stanza_instance (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4745,7 +4784,7 @@ test_stanza_instance (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4775,7 +4814,7 @@ test_stanza_kill (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4808,7 +4847,7 @@ test_stanza_kill (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -4840,7 +4879,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4859,7 +4898,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4878,7 +4917,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4897,7 +4936,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4916,7 +4955,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4935,7 +4974,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4954,7 +4993,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -4974,7 +5013,7 @@ test_stanza_kill (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5005,7 +5044,7 @@ test_stanza_normal (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5044,7 +5083,7 @@ test_stanza_normal (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5083,7 +5122,7 @@ test_stanza_normal (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5127,7 +5166,7 @@ test_stanza_normal (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5168,7 +5207,7 @@ test_stanza_normal (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5187,7 +5226,7 @@ test_stanza_normal (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5206,7 +5245,7 @@ test_stanza_normal (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5225,7 +5264,7 @@ test_stanza_normal (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5244,7 +5283,7 @@ test_stanza_normal (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5263,7 +5302,7 @@ test_stanza_normal (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5293,7 +5332,7 @@ test_stanza_console (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5326,7 +5365,7 @@ test_stanza_console (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5359,7 +5398,7 @@ test_stanza_console (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5392,7 +5431,7 @@ test_stanza_console (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5423,7 +5462,7 @@ test_stanza_console (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5442,7 +5481,7 @@ test_stanza_console (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5460,7 +5499,7 @@ test_stanza_console (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5490,7 +5529,7 @@ test_stanza_env (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5528,7 +5567,7 @@ test_stanza_env (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5565,7 +5604,7 @@ test_stanza_env (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5584,7 +5623,7 @@ test_stanza_env (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5614,7 +5653,7 @@ test_stanza_export (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5651,7 +5690,7 @@ test_stanza_export (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5694,7 +5733,7 @@ test_stanza_export (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5736,7 +5775,7 @@ test_stanza_export (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5766,7 +5805,7 @@ test_stanza_umask (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5799,7 +5838,7 @@ test_stanza_umask (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5831,7 +5870,7 @@ test_stanza_umask (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5850,7 +5889,7 @@ test_stanza_umask (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5869,7 +5908,7 @@ test_stanza_umask (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5888,7 +5927,7 @@ test_stanza_umask (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5907,7 +5946,7 @@ test_stanza_umask (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5927,7 +5966,7 @@ test_stanza_umask (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -5957,7 +5996,7 @@ test_stanza_nice (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -5990,7 +6029,7 @@ test_stanza_nice (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6023,7 +6062,7 @@ test_stanza_nice (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6055,7 +6094,7 @@ test_stanza_nice (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6074,7 +6113,7 @@ test_stanza_nice (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6093,7 +6132,7 @@ test_stanza_nice (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6112,7 +6151,7 @@ test_stanza_nice (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6131,7 +6170,7 @@ test_stanza_nice (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6150,7 +6189,7 @@ test_stanza_nice (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6180,7 +6219,7 @@ test_stanza_oom (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6213,7 +6252,7 @@ test_stanza_oom (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6246,7 +6285,7 @@ test_stanza_oom (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6279,7 +6318,7 @@ test_stanza_oom (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6311,7 +6350,7 @@ test_stanza_oom (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6330,7 +6369,7 @@ test_stanza_oom (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6349,7 +6388,7 @@ test_stanza_oom (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6368,7 +6407,7 @@ test_stanza_oom (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6387,7 +6426,7 @@ test_stanza_oom (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6406,7 +6445,7 @@ test_stanza_oom (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -6435,7 +6474,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6469,7 +6508,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6503,7 +6542,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6537,7 +6576,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6571,7 +6610,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6606,7 +6645,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6641,7 +6680,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6675,7 +6714,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6710,7 +6749,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6744,7 +6783,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6778,7 +6817,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6812,7 +6851,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6847,7 +6886,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6881,7 +6920,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6917,7 +6956,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6956,7 +6995,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -6991,7 +7030,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -7026,7 +7065,7 @@ test_stanza_limit (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -7060,7 +7099,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7079,7 +7118,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7098,7 +7137,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7117,7 +7156,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7136,7 +7175,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7155,7 +7194,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7174,7 +7213,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7193,7 +7232,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7212,7 +7251,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7231,7 +7270,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7250,7 +7289,7 @@ test_stanza_limit (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7280,7 +7319,7 @@ test_stanza_chroot (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -7314,7 +7353,7 @@ test_stanza_chroot (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -7347,7 +7386,7 @@ test_stanza_chroot (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7366,7 +7405,7 @@ test_stanza_chroot (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7396,7 +7435,7 @@ test_stanza_chdir (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -7430,7 +7469,7 @@ test_stanza_chdir (void) - TEST_ALLOC_FAIL { - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), - &pos, &lineno); - - if (test_alloc_failed) { -@@ -7463,7 +7502,7 @@ test_stanza_chdir (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - -@@ -7482,7 +7521,7 @@ test_stanza_chdir (void) - - pos = 0; - lineno = 1; -- job = parse_job (NULL, "test", buf, strlen (buf), &pos, &lineno); -+ job = parse_job (NULL, NULL, "test", buf, strlen (buf), &pos, &lineno); - - TEST_EQ_P (job, NULL); - diff --git a/upstart-reexec.patch b/upstart-reexec.patch deleted file mode 100644 index 324c3a2..0000000 --- a/upstart-reexec.patch +++ /dev/null @@ -1,65 +0,0 @@ -diff -up upstart-0.6.5/init/main.c.foo upstart-0.6.5/init/main.c ---- upstart-0.6.5/init/main.c.foo 2010-04-30 19:38:07.846260462 -0400 -+++ upstart-0.6.5/init/main.c 2010-04-30 21:35:38.690487114 -0400 -@@ -67,6 +67,7 @@ static void kbd_handler (void *data, - static void pwr_handler (void *data, NihSignal *signal); - static void hup_handler (void *data, NihSignal *signal); - static void usr1_handler (void *data, NihSignal *signal); -+static void term_handler (void *data, NihSignal *signal); - #endif /* DEBUG */ - - -@@ -241,6 +242,10 @@ main (int argc, - /* SIGUSR1 instructs us to reconnect to D-Bus */ - nih_signal_set_handler (SIGUSR1, nih_signal_handler); - NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); -+ -+ /* SIGTERM instructs us to re-exec ourselves */ -+ nih_signal_set_handler (SIGTERM, nih_signal_handler); -+ NIH_MUST (nih_signal_add_handler (NULL, SIGTERM, term_handler, NULL)); - #endif /* DEBUG */ - - -@@ -485,4 +490,42 @@ usr1_handler (void *data, - } - } - } -+ -+/** -+ * term_handler: -+ * @data: unused, -+ * @signal: signal that called this handler -+ * -+ * This is called when we recieve the TERM signal, which instructs us -+ * to reexec ourselves. -+ **/ -+static void -+term_handler (void *data, -+ NihSignal *signal) -+{ -+ NihError *err; -+ sigset_t mask, oldmask; -+ -+ nih_assert (argv0 != NULL); -+ nih_assert (signal != NULL); -+ -+ nih_warn (_("Re-executing %s"), argv0); -+ -+ /* Block signals while we work. We're the last signal handler -+ * installed so this should mean that they're all handled now. -+ * -+ * The child must make sure that it unblocks these again when -+ * it's ready. -+ */ -+ sigfillset (&mask); -+ sigprocmask (SIG_BLOCK, &mask, &oldmask); -+ execl (argv0, argv0, "--restart", NULL); -+ nih_error_raise_system (); -+ -+ err = nih_error_get (); -+ nih_error (_("Failed to re-execute %s: %s"), argv0, err->message); -+ nih_free (err); -+ -+ sigprocmask (SIG_SETMASK, &oldmask, NULL); -+} - #endif /* DEBUG */ diff --git a/upstart-remove-tests.patch b/upstart-remove-tests.patch deleted file mode 100644 index 720294a..0000000 --- a/upstart-remove-tests.patch +++ /dev/null @@ -1,213 +0,0 @@ -diff -up upstart-0.6.3/nih-dbus/tests/test_dbus_connection.c.tests upstart-0.6.3/nih-dbus/tests/test_dbus_connection.c ---- upstart-0.6.3/nih-dbus/tests/test_dbus_connection.c.tests 2009-12-14 15:51:25.323430105 +0100 -+++ upstart-0.6.3/nih-dbus/tests/test_dbus_connection.c 2009-12-14 15:51:25.323430105 +0100 -@@ -1521,7 +1521,6 @@ main (int argc, - nih_error_init (); - - test_connect (); -- test_bus (); - test_setup (); - test_server (); - -diff -up upstart-0.6.3/nih/tests/test_child.c.tests upstart-0.6.3/nih/tests/test_child.c ---- upstart-0.6.3/nih/tests/test_child.c.tests 2009-12-14 15:51:25.910710749 +0100 -+++ upstart-0.6.3/nih/tests/test_child.c 2009-12-14 15:51:25.888145178 +0100 -@@ -328,186 +328,6 @@ test_poll (void) - nih_free (watch); - - -- /* Check that a signal raised from a traced child causes the reaper -- * to be called with a traced event and the event in the status -- * field. It should not be removed from the list since the child -- * hasn't gone away. -- */ -- TEST_FEATURE ("with signal from traced child"); -- -- TEST_CHILD (pid) { -- assert0 (ptrace (PTRACE_TRACEME, 0, NULL, NULL)); -- -- raise (SIGSTOP); -- raise (SIGCHLD); -- pause (); -- exit (0); -- } -- -- waitid (P_PID, pid, &siginfo, WSTOPPED); -- -- assert0 (ptrace (PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACESYSGOOD)); -- assert0 (ptrace (PTRACE_CONT, pid, NULL, SIGCONT)); -- -- waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT); -- -- watch = nih_child_add_watch (NULL, pid, NIH_CHILD_TRAPPED, -- my_handler, &watch); -- -- TEST_FREE_TAG (watch); -- -- handler_called = 0; -- last_data = NULL; -- last_pid = 0; -- last_event = -1; -- last_status = 0; -- -- nih_child_poll (); -- -- TEST_TRUE (handler_called); -- TEST_EQ (last_pid, pid); -- TEST_EQ (last_event, NIH_CHILD_TRAPPED); -- TEST_EQ (last_status, SIGCHLD); -- TEST_NOT_FREE (watch); -- -- assert0 (ptrace (PTRACE_DETACH, pid, NULL, 0)); -- -- kill (pid, SIGTERM); -- waitid (P_PID, pid, &siginfo, WEXITED); -- nih_free (watch); -- -- --#if HAVE_VALGRIND_VALGRIND_H -- /* These tests fail when running under valgrind. -- */ -- if (! RUNNING_ON_VALGRIND) { --#endif -- /* Check that when a traced child forks it causes the reaper -- * to be called with a ptrace event and the fork event in the -- * status field. It should not be removed from the list since the -- * child hasn't gone away. -- */ -- TEST_FEATURE ("with fork by traced child"); -- -- TEST_CHILD (pid) { -- assert0 (ptrace (PTRACE_TRACEME, 0, NULL, NULL)); -- -- raise (SIGSTOP); -- -- child = fork (); -- assert (child >= 0); -- -- pause (); -- -- exit (0); -- } -- -- waitid (P_PID, pid, &siginfo, WSTOPPED); -- -- assert0 (ptrace (PTRACE_SETOPTIONS, pid, NULL, -- PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEFORK)); -- assert0 (ptrace (PTRACE_CONT, pid, NULL, SIGCONT)); -- -- /* Wait for ptrace to stop the parent (signalling the fork) */ -- waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT); -- -- /* Will be able to get the child pid now, we have to do it here -- * because we want to wait on it to ensure the test is synchronous; -- * otherwise nih_child_poll() could actually eat the child event -- * before it returns -- normally we'd do this inside the handler, -- * so things would probably work (we iter the handlers for each -- * event, so you can add one). -- */ -- data = 0; -- assert0 (ptrace (PTRACE_GETEVENTMSG, pid, NULL, &data)); -- assert (data != 0); -- child = (pid_t)data; -- -- /* Wait for ptrace to stop the child, otherwise it might not be -- * ready for us to actually detach from. -- */ -- waitid (P_PID, child, &siginfo, WSTOPPED | WNOWAIT); -- -- watch = nih_child_add_watch (NULL, pid, NIH_CHILD_PTRACE, -- my_handler, &watch); -- -- TEST_FREE_TAG (watch); -- -- handler_called = 0; -- last_data = NULL; -- last_pid = 0; -- last_event = -1; -- last_status = 0; -- -- nih_child_poll (); -- -- TEST_TRUE (handler_called); -- TEST_EQ (last_pid, pid); -- TEST_EQ (last_event, NIH_CHILD_PTRACE); -- TEST_EQ (last_status, PTRACE_EVENT_FORK); -- TEST_NOT_FREE (watch); -- -- assert0 (ptrace (PTRACE_DETACH, child, NULL, SIGCONT)); -- kill (child, SIGTERM); -- -- assert0 (ptrace (PTRACE_DETACH, pid, NULL, SIGCONT)); -- kill (pid, SIGTERM); -- waitid (P_PID, pid, &siginfo, WEXITED); -- nih_free (watch); -- -- -- /* Check that when a traced child execs it causes the reaper -- * to be called with a ptrace event and the exec event in the -- * status field. It should not be removed from the list since the -- * child hasn't gone away. -- */ -- TEST_FEATURE ("with exec by traced child"); -- -- TEST_CHILD (pid) { -- assert0 (ptrace (PTRACE_TRACEME, 0, NULL, NULL)); -- -- raise (SIGSTOP); -- -- execl ("/bin/true", "true", NULL); -- exit (255); -- } -- -- waitid (P_PID, pid, &siginfo, WSTOPPED); -- -- assert0 (ptrace (PTRACE_SETOPTIONS, pid, NULL, -- PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC)); -- assert0 (ptrace (PTRACE_CONT, pid, NULL, SIGCONT)); -- -- waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT); -- -- watch = nih_child_add_watch (NULL, pid, NIH_CHILD_PTRACE, -- my_handler, &watch); -- -- TEST_FREE_TAG (watch); -- -- handler_called = 0; -- last_data = NULL; -- last_pid = 0; -- last_event = -1; -- last_status = 0; -- -- nih_child_poll (); -- -- TEST_TRUE (handler_called); -- TEST_EQ (last_pid, pid); -- TEST_EQ (last_event, NIH_CHILD_PTRACE); -- TEST_EQ (last_status, PTRACE_EVENT_EXEC); -- TEST_NOT_FREE (watch); -- -- assert0 (ptrace (PTRACE_DETACH, pid, NULL, SIGCONT)); -- -- waitid (P_PID, pid, &siginfo, WEXITED); -- nih_free (watch); --#if HAVE_VALGRIND_VALGRIND_H -- } --#endif -- -- - /* Check that we can watch for events from any process, which - * shouldn't be freed when the child dies. - */ -diff -up upstart-0.6.3/nih/tests/test_string.c.tests upstart-0.6.3/nih/tests/test_string.c ---- upstart-0.6.3/nih/tests/test_string.c.tests 2009-12-17 12:34:43.357844975 +0100 -+++ upstart-0.6.3/nih/tests/test_string.c 2009-12-17 12:38:41.911484010 +0100 -@@ -1511,8 +1511,6 @@ main (int argc, - test_array_copy (); - test_array_append (); - test_str_wrap (); -- test_str_screen_width (); -- test_str_screen_wrap (); - - return 0; - } diff --git a/upstart-shutdown-exitcode.patch b/upstart-shutdown-exitcode.patch deleted file mode 100644 index 0b70308..0000000 --- a/upstart-shutdown-exitcode.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/util/shutdown.c b/util/shutdown.c -index 0a6d8bf..2ef847a 100644 ---- a/util/shutdown.c -+++ b/util/shutdown.c -@@ -459,6 +459,7 @@ shutdown_now (void) - { - nih_local char **extra_env = NULL; - NihDBusError * dbus_err; -+ int exit_val = 0; - - if (init_halt) { - char *e; -@@ -486,12 +487,14 @@ shutdown_now (void) - * yet rebooted ... so try /dev/initctl - */ - sysvinit_shutdown (); -+ nih_fatal ("Unable to shutdown system"); -+ exit_val = 1; - } - - unlink (ETC_NOLOGIN); - nih_main_unlink_pidfile (); - -- exit (0); -+ exit (exit_val); - } - - /** diff --git a/upstart-telinit.patch b/upstart-telinit.patch deleted file mode 100644 index 3cc2b1e..0000000 --- a/upstart-telinit.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -up upstart-0.6.3/util/telinit.c.foo upstart-0.6.3/util/telinit.c ---- upstart-0.6.3/util/telinit.c.foo 2009-12-03 14:52:58.000000000 -0500 -+++ upstart-0.6.3/util/telinit.c 2009-12-03 14:53:06.000000000 -0500 -@@ -174,9 +174,6 @@ main (int argc, - break; - case 'U': - case 'u': -- ret = kill (1, SIGTERM); -- if (ret < 0) -- nih_error_raise_system (); - break; - default: - nih_assert_not_reached (); diff --git a/upstart-utmp.patch b/upstart-utmp.patch deleted file mode 100644 index ccda548..0000000 --- a/upstart-utmp.patch +++ /dev/null @@ -1,80 +0,0 @@ -diff --git a/init/job_class.c b/init/job_class.c -index eeec83d..00eb13d 100644 ---- a/init/job_class.c -+++ b/init/job_class.c -@@ -219,6 +219,8 @@ job_class_new (const void *parent, - class->chroot = NULL; - class->chdir = NULL; - -+ class->utmp_id = NULL; -+ - class->deleted = FALSE; - class->debug = FALSE; - -diff --git a/init/job_class.h b/init/job_class.h -index d40e750..e5b5190 100644 ---- a/init/job_class.h -+++ b/init/job_class.h -@@ -145,6 +145,7 @@ typedef struct job_class { - struct rlimit *limits[RLIMIT_NLIMITS]; - char *chroot; - char *chdir; -+ char *utmp_id; - - int deleted; - int debug; -diff --git a/init/job_process.c b/init/job_process.c -index 70fa2bf..544f5e3 100644 ---- a/init/job_process.c -+++ b/init/job_process.c -@@ -361,11 +361,13 @@ job_process_spawn (JobClass *class, - char * const *env, - int trace) - { -- sigset_t child_set, orig_set; -- pid_t pid; -- int i, fds[2]; -- char filename[PATH_MAX]; -- FILE *fd; -+ sigset_t child_set, orig_set; -+ pid_t pid; -+ int i, fds[2]; -+ char filename[PATH_MAX]; -+ FILE *fd; -+ struct utmpx utmp; -+ struct timeval tv; - - nih_assert (class != NULL); - -@@ -558,6 +560,20 @@ job_process_spawn (JobClass *class, - } - } - -+ /* Write utmp INIT_PROCESS entry */ -+ if (class->utmp_id) { -+ memset(&utmp, 0, sizeof(struct utmpx)); -+ strncpy(utmp.ut_id, class->utmp_id, sizeof(utmp.ut_id)); -+ utmp.ut_pid = getpid(); -+ utmp.ut_type = INIT_PROCESS; -+ gettimeofday(&tv, NULL); -+ utmp.ut_tv.tv_sec = tv.tv_sec; -+ utmp.ut_tv.tv_usec = tv.tv_usec; -+ setutxent(); -+ pututxline(&utmp); -+ endutxent(); -+ } -+ - /* Execute the process, if we escape from here it failed */ - if (execvp (argv[0], argv) < 0) { - nih_error_raise_system (); -@@ -1176,6 +1192,10 @@ job_process_terminated (Job *job, - memset(utmptr->ut_user, 0, UT_NAMESIZE); - memset(utmptr->ut_host, 0, UT_HOSTSIZE); - utmptr->ut_time = 0; -+ -+ /* Set class utmp_id for next spawn */ -+ job->class->utmp_id = nih_strdup (job->class, utmptr->ut_id); -+ - /* Update existing utmp file. */ - pututxline(utmptr); - diff --git a/upstart.sh b/upstart.sh deleted file mode 100644 index ebd143b..0000000 --- a/upstart.sh +++ /dev/null @@ -1,4 +0,0 @@ -# check if upstart is running -if /lib/upstart/initctl list > /dev/null 2> /dev/null; then - export PATH=/lib/upstart:$PATH -fi diff --git a/upstart.spec b/upstart.spec deleted file mode 100644 index ac0d74f..0000000 --- a/upstart.spec +++ /dev/null @@ -1,353 +0,0 @@ -%define initscripts 20110502 - -Name: upstart -Version: 1.2 -Release: 6%{?dist} -Summary: An event-driven init system - -Group: System Environment/Base -License: GPLv2 and LGPLv2+ -URL: https://launchpad.net/upstart -Source0: http://launchpad.net/upstart/1.x/%{version}/+download/upstart-%{version}.tar.gz -Source1: init-system-dbus.conf -# These are taken from http://git.fedorahosted.org/git/?p=initscripts.git -Source2: initjobs-%{initscripts}.tar.gz -# create missing files and directories according to /etc/tmpfiles.d/ -Source3: tmpfiles.conf -# fix selinux context on /run created and mounted by dracut -Source4: fix-selinux-on-run.conf -# add /lib/upstart to shell PATH if upstart is running -Source5: upstart.sh -Source6: init.conf -Patch1: upstart-telinit.patch -Patch2: upstart-audit-events.patch -# set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) -Patch3: upstart-utmp.patch -Patch4: upstart-reexec.patch -# allow job override files -Patch7: upstart-override.patch -# add /lib/upstart to default PATH set by init process -Patch10: upstart-lib-upstart.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel -BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1 -Conflicts: initscripts < 9.12 -Requires: sysvinit-userspace /etc/rc.d/rc.sysinit - -%description -Upstart is an event-based replacement for the /sbin/init daemon which -handles starting of tasks and services during boot, stopping them -during shutdown and supervising them while the system is running. - -%prep -%setup -q -a 2 -%patch1 -p1 -b .u -%patch2 -p1 -b .audit -%patch3 -p1 -b .utmp -%patch4 -p1 -b .reexec -%patch7 -p1 -b .override -%patch10 -p1 -b .lib-upstart - -%build -autoreconf -%configure --sbindir=/lib/upstart --libdir=/%{_lib} -make %{?_smp_mflags} - -%install -rm -rf %{buildroot} -make install DESTDIR=%{buildroot} - -# Rename common SysV binaries and symlink them to allow parallel -# installation with systemd. We move the utility binaries into a -# subdirectory, so that program_name stays the same and Upstart still -# can check argv[0] properly in various places. -mkdir -p %{buildroot}/sbin/ -ln -sf ../lib/upstart/init %{buildroot}/sbin/upstart -ln -sf ../lib/upstart/initctl %{buildroot}/sbin/initctl -ln -sf ../lib/upstart/start %{buildroot}/sbin/start -ln -sf ../lib/upstart/status %{buildroot}/sbin/status -ln -sf ../lib/upstart/stop %{buildroot}/sbin/stop -ln -sf ../lib/upstart/restart %{buildroot}/sbin/restart -ln -sf ../lib/upstart/reload %{buildroot}/sbin/reload -ln -sf reboot %{buildroot}/lib/upstart/poweroff -ln -sf reboot %{buildroot}/lib/upstart/halt -# Rename init.8.gz to upstart.7.gz (#644249) -mv %{buildroot}/%{_mandir}/man8/init.8 %{buildroot}/%{_mandir}/man7/upstart.7 -# Remove these files due the conflicts with systemd -rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown,telinit}.* - -# don't ship default jobs -rm -f %{buildroot}/%{_sysconfdir}/init/* -install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/ -install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init/ -install -m 644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/init/ -for file in initjobs-%{initscripts}/*.conf ; do - install -m 644 $file %{buildroot}/%{_sysconfdir}/init/ -done - -mkdir -p -m 755 %{buildroot}/%{_sysconfdir}/profile.d/ -install -m 644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/profile.d/ - -install -m 644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/init.conf - -%find_lang %{name} - -%check -#some tests fail in koji while pass in mock and local build -#to run make check use "--with check" -%if %{?_with_check:1}%{!?_with_check:0} - make check -%endif - -%clean -rm -rf %{buildroot} - -%files -f %{name}.lang -%defattr(-,root,root,-) -%doc AUTHORS -%doc COPYING -%doc NEWS -%doc README -%doc TODO -%doc HACKING -%{_sysconfdir}/init/ -%config(noreplace) %{_sysconfdir}/init.conf -%config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf -/sbin/upstart -/sbin/initctl -/sbin/start -/sbin/status -/sbin/stop -/sbin/restart -/sbin/reload -%dir /lib/upstart -/lib/upstart/init -/lib/upstart/initctl -/lib/upstart/poweroff -/lib/upstart/reboot -/lib/upstart/runlevel -/lib/upstart/shutdown -/lib/upstart/halt -/lib/upstart/start -/lib/upstart/status -/lib/upstart/stop -/lib/upstart/restart -/lib/upstart/telinit -/lib/upstart/reload -/etc/profile.d/upstart.sh -%{_mandir}/man5/init.5.gz -%{_mandir}/man5/inittab.5.gz -%{_mandir}/man7/control-alt-delete.7.gz -%{_mandir}/man7/keyboard-request.7.gz -%{_mandir}/man7/power-status-changed.7.gz -%{_mandir}/man7/runlevel.7.gz -%{_mandir}/man7/started.7.gz -%{_mandir}/man7/starting.7.gz -%{_mandir}/man7/startup.7.gz -%{_mandir}/man7/stopped.7.gz -%{_mandir}/man7/stopping.7.gz -%{_mandir}/man7/upstart.7.gz -%{_mandir}/man8/restart.8.gz -%{_mandir}/man8/initctl.8.gz -%{_mandir}/man8/start.8.gz -%{_mandir}/man8/status.8.gz -%{_mandir}/man8/stop.8.gz -%{_mandir}/man8/reload.8.gz - -%changelog -* Sun Jul 22 2012 Fedora Release Engineering - 1.2-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - -* Sat Jan 14 2012 Fedora Release Engineering - 1.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Wed May 25 2011 Petr Lautrbach 1.2-4 -- drop Obsoletes: upstart-sysvinit (#707507) -- clean upstart-sysvinit stuff from spec file - -* Fri May 13 2011 Petr Lautrbach 1.2-3 -- add /etc/init.conf file - -* Wed May 04 2011 Petr Lautrbach 1.2-2 -- /run - fix selinux context and check for tmpfiles.d -- physically move binaries to /lib/upstart -- add /lib/upstart to default PATH - -* Wed Mar 23 2011 Petr Lautrbach 1.2-1 -- upgrade to 1.2 -- update upstream URL - -* Mon Mar 21 2011 Petr Lautrbach 1.1-1 -- upgrade to 1.1 -- remove /lib/upstart/init experiment -- allow job override files - -* Tue Mar 15 2011 Petr Lautrbach 1.0-2 -- introduce /lib/upstart/init/ as place for jobs defaults - -* Thu Mar 03 2011 Petr Lautrbach 1.0-1 -- upgrade to 1.0 - https://launchpad.net/upstart/1.x/1.0 - -* Mon Feb 07 2011 Fedora Release Engineering - 0.6.7-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild - -* Fri Dec 17 2010 Petr Lautrbach 0.6.7-1 -- upgrade to 0.6.7 - -* Mon Dec 06 2010 Petr Lautrbach 0.6.6-4 -- Stop tty and serial also on runlevel 's' - -* Fri Nov 26 2010 Petr Lautrbach 0.6.6-3 -- create missing files and directories according to /etc/init/tmpfiles.conf - -* Tue Nov 16 2010 Bill Nottingham 0.6.6-2 -- require /etc/rc.d/rc.sysinit to pull in new initscripts-legacy package where needed - -* Wed Oct 27 2010 Petr Lautrbach 0.6.6-1 -- upgrade to 0.6.6 -- boot jobs source renamed - -* Tue Oct 26 2010 Petr Lautrbach 0.6.5-14 -- send close fd command to shell first (#646894) - -* Tue Oct 19 2010 Petr Lautrbach 0.6.5-13 -- Rename init(8) to upstart(7) (#644249) - -* Thu Oct 14 2010 Petr Lautrbach 0.6.5-12 -- Disable -sysvinit to avoid conflicts with systemd (#635323) - -* Wed Sep 29 2010 jkeating - 0.6.5-11 -- Rebuilt for gcc bug 634757 - -* Fri Sep 24 2010 Bill Nottingham 0.6.5-10 -- merge in basic boot jobs here (#637099) - -* Tue Sep 21 2010 Petr Lautrbach 0.6.5-9 -- set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568) -- exit shutdown with nonzero exitcode when fails shutdown - -* Fri Sep 17 2010 Bill Nottingham - 0.6.5-8 -- ensure F15 version is newer than F-14 - -* Sat Jul 24 2010 Casey Dahlin - 0.6.5-7 -- Make upgrades work correctly now that -sysvinit is split off - -* Sat Jul 24 2010 Lennart Poettering - 0.6.5-6 -- Split off -sysvinit to make Upstart parallel installable with systemd - -* Tue May 4 2010 Bill Nottingham 0.6.5-5 -- re-add SIGTERM handler so restart on shutdown works, avoiding dirty inodes (#576662) - -* Tue Apr 6 2010 Casey Dahlin 0.6.5-4 -- Reload init after install - -* Wed Feb 24 2010 Petr Lautrbach 0.6.5-3 -- run "make check" only with --with check - -* Fri Feb 19 2010 Casey Dahlin 0.6.5-2 -- be more specific about which libnih we need. - -* Wed Feb 17 2010 Petr Lautrbach 0.6.5-1 -- upgrade to 0.6.5 - -* Fri Jan 29 2010 Petr Lautrbach 0.6.3-7 -- add SIGUSR1 handler and init-system-dbus.conf (#559660) - -* Sun Jan 17 2010 Dennis Gilmore - 0.6.3-6 -- add patch from upstream fixing sparc alignment issues - -* Mon Jan 11 2010 Petr Lautrbach 0.6.3-5 -- License changed to GPLv2 and LGPLv2+ - -* Wed Dec 16 2009 Petr Lautrbach 0.6.3-4 -- audit events patch rebased for 0.6 (#470661) - -* Thu Dec 3 2009 Bill Nottingham 0.6.3-3 -- make 'telinit u' a no-op, temporarily - -* Fri Nov 27 2009 Petr Lautrbach 0.6.3-2 -- Removed tests which fail in koji - -* Fri Nov 20 2009 Casey Dahlin - 0.6.3-1 -- Upgrade to 0.6.3 - -* Fri Aug 21 2009 Tomas Mraz - 0.3.11-3 -- rebuilt with new audit - -* Sun Jul 26 2009 Fedora Release Engineering - 0.3.11-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - -* Mon Jun 22 2009 Petr Lautrbach - 0.3.11-1 -- Update to 0.3.11 - -* Mon Apr 27 2009 Bill Nottingham - 0.3.9-24 -- Apply the audit patch correctly (#470661) - -* Fri Apr 3 2009 Casey Dahlin - 0.3.9-23 -- Add audit events patch from Steve Grubb (Bug #470661) - -* Fri Jan 23 2009 Casey Dahlin - 0.3.9-22 -- Re-add 'telinit u' support along with patch to fix it (#450488). Patch due to - - -* Mon Jan 12 2009 Bill Nottingham - 0.3.9-21 -- Remove 'telinit u' support as it is broken (#450488, ) - -* Fri Apr 25 2008 Bill Nottingham - 0.3.9-19 -- with the merge of event-compat-sysv, move the sysvinit obsoletes/provides here - -* Thu Apr 24 2008 Bill Nottingham - 0.3.9-18 -- fix some man page typos (#444008, ) - -* Wed Apr 09 2008 Casey Dahlin - 0.3.9-17 -- Added list of stock events to events(5) - -* Tue Apr 08 2008 Casey Dahlin - 0.3.9-16 -- Add telinit u support - -* Fri Apr 04 2008 Bill Nottingham - 0.3.9-15 -- Add a events(5) manpage that describes event syntax - -* Thu Apr 03 2008 Casey Dahlin - 0.3.9-14 -- Change bug report email address to fedora-devel-list@redhat.com - -* Thu Mar 14 2008 Bill Nottingham - 0.3.9-13 -- Ignore rpm temporary files of the foo; format -- Make ignores of .rpm{new,orig,save} match only at the end of the name - -* Wed Mar 13 2008 Bill Nottingham - 0.3.9-12 -- forgot about rpmorig too (ugh) - -* Wed Mar 13 2008 Casey Dahlin - 0.3.9-11 -- Make logd a noreplace - -* Wed Mar 13 2008 Casey Dahlin - 0.3.9-10 -- Add patch to ignore .rpm{new,save} files - -* Sun Mar 03 2008 Casey Dahlin - 0.3.9-9 -- Remove automake dependency, build Makefile.in changes into patch - -* Sun Mar 03 2008 Casey Dahlin - 0.3.9-8 -- Run automake after patching - -* Sun Mar 03 2008 Casey Dahlin - 0.3.9-7 -- Added BuildRequires: automake - -* Sun Mar 03 2008 Casey Dahlin - 0.3.9-6 -- Added patch to allow runtime tty changes - -* Fri Feb 15 2008 Casey Dahlin - 0.3.9-5 -- Added patch to imply --force on runlevels 0 and 6 - -* Wed Feb 06 2008 Casey Dahlin - 0.3.9-4 -- Patched for GCC 4.3 - -* Thu Jan 31 2008 Casey Dahlin - 0.3.9-3 -- Added AUTHORS, COPYING, etc. -- Made config --libdir option relative - -* Mon Jan 21 2008 Casey Dahlin - 0.3.9-2 -- Remove libnih and libupstart - -* Sun Jan 13 2008 Casey Dahlin - 0.3.9-1 -- Initial packaging