Merge lp:~jamesodhunt/ubuntu/natty/upstart/fix-chroot-sessions into lp:ubuntu/natty/upstart

Proposed by James Hunt
Status: Merged
Merge reported by: Clint Byrum
Merged at revision: not available
Proposed branch: lp:~jamesodhunt/ubuntu/natty/upstart/fix-chroot-sessions
Merge into: lp:ubuntu/natty/upstart
Diff against target: 4753 lines (+842/-700)
38 files modified
ChangeLog (+62/-0)
NEWS (+21/-0)
configure.ac (+1/-1)
debian/changelog (+28/-0)
debian/upstart-job (+14/-4)
init/Makefile.am (+4/-2)
init/conf.c (+18/-12)
init/conf.h (+1/-1)
init/control.c (+5/-1)
init/job.c (+8/-2)
init/job_class.c (+34/-14)
init/job_process.c (+59/-0)
init/job_process.h (+3/-1)
init/main.c (+8/-0)
init/man/init.5 (+0/-38)
init/man/init.8 (+11/-7)
init/parse_job.c (+2/-2)
init/session.c (+21/-8)
init/session.h (+27/-2)
init/tests/test_blocked.c (+4/-6)
init/tests/test_conf.c (+15/-22)
init/tests/test_control.c (+11/-12)
init/tests/test_environ.c (+3/-0)
init/tests/test_event.c (+28/-40)
init/tests/test_event_operator.c (+3/-0)
init/tests/test_job.c (+70/-148)
init/tests/test_job_class.c (+54/-145)
init/tests/test_job_process.c (+34/-59)
init/tests/test_parse_conf.c (+3/-0)
init/tests/test_parse_job.c (+3/-0)
init/tests/test_process.c (+3/-0)
init/tests/test_system.c (+3/-0)
po/upstart.pot (+152/-136)
scripts/init-checkconf.sh (+34/-10)
scripts/man/init-checkconf.8 (+22/-10)
util/initctl.c (+16/-5)
util/man/initctl.8 (+3/-1)
util/tests/test_initctl.c (+54/-11)
To merge this branch: bzr merge lp:~jamesodhunt/ubuntu/natty/upstart/fix-chroot-sessions
Reviewer Review Type Date Requested Status
Clint Byrum (community) Approve
Review via email: mp+58249@code.launchpad.net

Description of the change

* Important fixes for user sessions (currently disabled in Ubuntu) and chroot sessions (which previously could cause an out-of-memory condition).

* Clints fix for bug 707479.

To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

I've been testing this for over a week on two natty machines kept up to date on a daily basis. I've seen no breakage, and this fixes a critical bug. The change to upstart-job is a bit late, and could be removed, but at this point I feel its better having the package as it has been tested by some of us uploaded rather than something with only half the fixes.

Approved, and uploading to natty for release team approval.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2011-03-24 14:33:36 +0000
+++ ChangeLog 2011-04-19 09:27:29 +0000
@@ -1,3 +1,65 @@
12011-04-15 James Hunt <james.hunt@ubuntu.com>
2
3 * init/conf.c:
4 - conf_source_reload_file(): Added missing error return if override
5 doesn't parse (code path currently unused).
6 - Documentation updates.
7 * init/job.c: job_new(): Fix for nasty OOM scenario when an attempt is made
8 to start a chroot job with same name as running single-instance non-chroot
9 job. Previously, the path for a chrooted Job was set from the (nul) instance
10 name of its parent JobClass. However, since that job instance name already
11 existed outside the chroot and was already D-Bus registered,
12 nih_dbus_object_new() (which allocates storage and is called by
13 job_register()) returned NULL and kept doing so due to being called
14 within NIH_MUST(). This resulted in OOM due to an as-yet unidentified
15 D-Bus bug (possibly a leak in find_subtree_recurse()).
16 * init/session.h: Documentation updates.
17 * util/test_initctl.c: Cleaned up variable names
18 in RUN_COMMAND macro.
19 * init/parse_job.c: Documentation updates.
20
212011-04-06 James Hunt <james.hunt@ubuntu.com>
22
23 * init/conf.c: conf_select_job(): Added Session parameter.
24 * init/control.c: control_get_job_by_name(): Handle multiple jobs with same
25 name (but different session) in job_classes hash.
26 * init/job_class.c:
27 - job_class_remove(): Added Session parameter.
28 - job_class_consider(): Handle multiple jobs with same name
29 (but different session) in job_classes hash.
30 - job_class_reconsider(): Handle multiple jobs with same name
31 (but different session) in job_classes hash.
32 - job_class_remove(): Handle incorrect session.
33 * init/job_process.c: job_process_spawn(): Updated for sessions and
34 chroots.
35 * init/job_process.h: New enums for:
36 - JOB_PROCESS_ERROR_SETUID
37 - JOB_PROCESS_ERROR_SETGID
38 * init/session.c:
39 - session_from_dbus(): Added ability to disable sessions.
40 - Added disable_sessions variable, set via main().
41 * init/session.h: Added tabular comment summarising Session object
42 contents for different environments.
43 * init/Makefile.am: Reverted special-casing for session.c.
44 * init/main.c: Addition of new command-line option "--no-sessions" to
45 disable chroot+user sessions (providing a "traditional" Upstart
46 environment. The primary use for this option is the test suite.
47 * init/man/init.8: Updates for "--no-sessions".
48 * init/tests/test_*.c: Replaced explicit Sessions with NULL
49 session since tests are not yet session-aware (with the exception of
50 test_job_process.c, all main() functions now set the
51 UPSTART_NO_SESSIONS variable to disable sessions).
52 * util/tests/test_initctl.c:
53 - START_UPSTART now specifies "--no-sessions"
54 - test_check_config(): Added test for "--warn".
55 * scripts/init-checkconf.sh: Script now also checks any script
56 sections found unless the new "--noscript" option is specified.
57 Added required "--no-sessions" option to upstart_cmd to ensure Upstart
58 treats clients requests in traditional manner.
59 * scripts/man/init-checkconf.8: Update for "--noscript".
60 * util/initctl.c: Added "--warn" option for check-config command to
61 warn if any events or jobs are not known.
62
12011-03-24 James Hunt <james.hunt@ubuntu.com>632011-03-24 James Hunt <james.hunt@ubuntu.com>
264
3 * init/tests/test_control.c: Added comment.65 * init/tests/test_control.c: Added comment.
466
=== modified file 'NEWS'
--- NEWS 2011-03-24 14:33:36 +0000
+++ NEWS 2011-04-19 09:27:29 +0000
@@ -1,3 +1,24 @@
10.9.6 2011-04-15
2
3 * Fix for nasty OOM scenario when an attempt is made to start
4 a chroot job with same name as running single-instance
5 non-chroot job. Previously, the path for a chrooted Job
6 was set from the (nul) instance name of its parent JobClass.
7 However, since that job instance name already existed
8 outside the chroot and was already D-Bus registered,
9 nih_dbus_object_new() (which allocates storage and is
10 called by job_register()) returned NULL and kept doing so
11 due to being called within NIH_MUST(). This resulted in
12 OOM due to an as-yet unidentified D-Bus bug (possibly a
13 leak in find_subtree_recurse()).
14
150.9.5 2011-04-06
16
17 * Important fixes for user and chroot sessions.
18 * scripts/init-checkconf.sh: Now checks script sections too.
19 * util/initctl.c: Added "--warn" option for check-config command
20 to warn if any events or jobs are not known.
21
10.9.4 2011-03-24220.9.4 2011-03-24
223
3 * scripts/initctl2dot.py: Fix to handle 'emits' glob syntax24 * scripts/initctl2dot.py: Fix to handle 'emits' glob syntax
425
=== modified file 'configure.ac'
--- configure.ac 2011-03-24 14:33:36 +0000
+++ configure.ac 2011-04-19 09:27:29 +0000
@@ -1,7 +1,7 @@
1# Process this file with autoconf to produce a configure script.1# Process this file with autoconf to produce a configure script.
22
3AC_PREREQ(2.61)3AC_PREREQ(2.61)
4AC_INIT([upstart], [0.9.4], [upstart-devel@lists.ubuntu.com])4AC_INIT([upstart], [0.9.6], [upstart-devel@lists.ubuntu.com])
5NIH_COPYRIGHT([[Copyright © 2011 Canonical Ltd.]])5NIH_COPYRIGHT([[Copyright © 2011 Canonical Ltd.]])
6AC_CONFIG_SRCDIR([init/main.c])6AC_CONFIG_SRCDIR([init/main.c])
7AC_CONFIG_MACRO_DIR([m4])7AC_CONFIG_MACRO_DIR([m4])
88
=== modified file 'debian/changelog'
--- debian/changelog 2011-03-24 14:35:14 +0000
+++ debian/changelog 2011-04-19 09:27:29 +0000
@@ -1,3 +1,31 @@
1upstart (0.9.6-1ubuntu1) natty; urgency=low
2
3 * init/man/init.5: Remove mention of user jobs since facility is
4 disabled.
5
6 -- James Hunt <james.hunt@ubuntu.com> Fri, 15 Apr 2011 15:37:57 +0100
7
8upstart (0.9.6-1) natty; urgency=low
9
10 * New upstream release 0.9.6: Important session+chroot fixes.
11
12 -- James Hunt <james.hunt@ubuntu.com> Fri, 15 Apr 2011 15:36:40 +0100
13
14upstart (0.9.5-1ubuntu1) natty; urgency=low
15
16 [ Clint Byrum ]
17 * debian/upstart-job: change behavior to reload job configuration on
18 restart, which more closely matches expected sysvinit script
19 behavior. (LP: #707479)
20
21 -- James Hunt <james.hunt@ubuntu.com> Wed, 06 Apr 2011 17:50:53 +0100
22
23upstart (0.9.5-1) natty; urgency=low
24
25 * New upstream release 0.9.5.
26
27 -- James Hunt <james.hunt@ubuntu.com> Wed, 06 Apr 2011 17:45:38 +0100
28
1upstart (0.9.4-1ubuntu1) natty; urgency=low29upstart (0.9.4-1ubuntu1) natty; urgency=low
230
3 * debian/manpages/upstart-events.7:31 * debian/manpages/upstart-events.7:
432
=== modified file 'debian/upstart-job'
--- debian/upstart-job 2011-01-26 21:52:39 +0000
+++ debian/upstart-job 2011-04-19 09:27:29 +0000
@@ -44,7 +44,7 @@
44 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"44 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
45 $COMMAND "$JOB"45 $COMMAND "$JOB"
46 ;;46 ;;
47start|stop|restart)47start|stop)
48 $ECHO48 $ECHO
49 $ECHO "Since the script you are attempting to invoke has been converted to an"49 $ECHO "Since the script you are attempting to invoke has been converted to an"
50 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"50 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
@@ -55,12 +55,22 @@
55 exit 055 exit 0
56 elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then56 elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
57 exit 057 exit 0
58 elif [ -z "$RUNNING" ] && [ "$COMMAND" = "restart" ]; then
59 start "$JOB"
60 exit 0
61 fi58 fi
62 $COMMAND "$JOB"59 $COMMAND "$JOB"
63 ;;60 ;;
61restart)
62 $ECHO
63 $ECHO "Since the script you are attempting to invoke has been converted to an"
64 $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
65 $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
66 if status "$JOB" 2>/dev/null | grep -q ' start/'; then
67 RUNNING=1
68 fi
69 if [ -n "$RUNNING" ] ; then
70 stop "$JOB"
71 fi
72 start "$JOB"
73 ;;
64reload|force-reload)74reload|force-reload)
65 $ECHO75 $ECHO
66 $ECHO "Since the script you are attempting to invoke has been converted to an"76 $ECHO "Since the script you are attempting to invoke has been converted to an"
6777
=== modified file 'init/Makefile.am'
--- init/Makefile.am 2011-02-24 15:41:04 +0000
+++ init/Makefile.am 2011-04-19 09:27:29 +0000
@@ -273,24 +273,26 @@
273 $(NIH_DBUS_LIBS) \273 $(NIH_DBUS_LIBS) \
274 $(DBUS_LIBS)274 $(DBUS_LIBS)
275275
276test_conf_SOURCES = tests/test_conf.c session.c276test_conf_SOURCES = tests/test_conf.c
277test_conf_CFLAGS = $(AM_CFLAGS) -DTEST277test_conf_CFLAGS = $(AM_CFLAGS) -DTEST
278test_conf_LDADD = \278test_conf_LDADD = \
279 system.o environ.o process.o \279 system.o environ.o process.o \
280 job_class.o job_process.o job.o event.o event_operator.o blocked.o \280 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
281 parse_job.o parse_conf.o conf.o control.o \281 parse_job.o parse_conf.o conf.o control.o \
282 session.o \
282 com.ubuntu.Upstart.o \283 com.ubuntu.Upstart.o \
283 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \284 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
284 $(NIH_LIBS) \285 $(NIH_LIBS) \
285 $(NIH_DBUS_LIBS) \286 $(NIH_DBUS_LIBS) \
286 $(DBUS_LIBS)287 $(DBUS_LIBS)
287288
288test_control_SOURCES = tests/test_control.c session.c289test_control_SOURCES = tests/test_control.c
289test_control_CFLAGS = $(AM_CFLAGS) -DTEST290test_control_CFLAGS = $(AM_CFLAGS) -DTEST
290test_control_LDADD = \291test_control_LDADD = \
291 system.o environ.o process.o \292 system.o environ.o process.o \
292 job_class.o job_process.o job.o event.o event_operator.o blocked.o \293 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
293 parse_job.o parse_conf.o conf.o control.o \294 parse_job.o parse_conf.o conf.o control.o \
295 session.o \
294 com.ubuntu.Upstart.o \296 com.ubuntu.Upstart.o \
295 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \297 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
296 $(NIH_LIBS) \298 $(NIH_LIBS) \
297299
=== modified file 'init/conf.c'
--- init/conf.c 2011-02-23 11:04:27 +0000
+++ init/conf.c 2011-04-19 09:27:29 +0000
@@ -517,13 +517,10 @@
517 nih_debug ("Updating configuration for %s from %s",517 nih_debug ("Updating configuration for %s from %s",
518 source->path, override_path);518 source->path, override_path);
519 if (conf_reload_path (source, source->path, override_path) < 0) {519 if (conf_reload_path (source, source->path, override_path) < 0) {
520 NihError *err;520 if (err)
521 nih_free (err);
521522
522 err = nih_error_get ();523 return -1;
523 nih_error ("%s: %s: %s", override_path,
524 _("Error while reloading configuration file"),
525 err->message);
526 nih_free (err);
527 }524 }
528525
529 return 0;526 return 0;
@@ -935,7 +932,7 @@
935 * conf_reload_path:932 * conf_reload_path:
936 * @source: configuration source,933 * @source: configuration source,
937 * @path: path of conf file to be reloaded.934 * @path: path of conf file to be reloaded.
938 * @override_path: if TRUE and @path refers to a path associated with @source,935 * @override_path: if not NULL and @path refers to a path associated with @source,
939 * overlay the contents of @path into the existing @source entry for936 * overlay the contents of @path into the existing @source entry for
940 * @path. If FALSE, discard any existing knowledge of @path.937 * @path. If FALSE, discard any existing knowledge of @path.
941 *938 *
@@ -946,7 +943,8 @@
946 *943 *
947 * If the file has been parsed before, then the existing item is deleted and944 * If the file has been parsed before, then the existing item is deleted and
948 * freed if the file fails to load, or after the new item has been parsed.945 * freed if the file fails to load, or after the new item has been parsed.
949 * Items are not reused between reloads.946 * Items are only reused between reloads if @override_path is
947 * non-NULL.
950 *948 *
951 * Physical errors are returned, parse errors are not.949 * Physical errors are returned, parse errors are not.
952 *950 *
@@ -968,12 +966,16 @@
968 nih_assert (source != NULL);966 nih_assert (source != NULL);
969 nih_assert (path != NULL);967 nih_assert (path != NULL);
970968
971 path_to_load = ( override_path ? override_path : path);969 path_to_load = (override_path ? override_path : path);
972970
973 /* If there is no corresponding override file, look up the old971 /* If there is no corresponding override file, look up the old
974 * conf file in memory, and then free it. In cases of failure,972 * conf file in memory, and then free it. In cases of failure,
975 * we discard it anyway, so there's no particular reason973 * we discard it anyway, so there's no particular reason
976 * to keep it around anymore.974 * to keep it around anymore.
975 *
976 * Note: if @override_path has been specified, do not
977 * free the file if found, since we want to _update_ the
978 * existing entry.
977 */979 */
978 file = (ConfFile *)nih_hash_lookup (source->files, path);980 file = (ConfFile *)nih_hash_lookup (source->files, path);
979 if (! override_path && file)981 if (! override_path && file)
@@ -987,7 +989,7 @@
987 if (! buf)989 if (! buf)
988 return -1;990 return -1;
989991
990 /* Create a new ConfFile structure (if no override_path was specified) */992 /* Create a new ConfFile structure (if no @override_path specified) */
991 file = (ConfFile *)nih_hash_lookup (source->files, path);993 file = (ConfFile *)nih_hash_lookup (source->files, path);
992 if (! file)994 if (! file)
993 file = NIH_MUST (conf_file_new (source, path));995 file = NIH_MUST (conf_file_new (source, path));
@@ -1144,7 +1146,8 @@
11441146
1145/**1147/**
1146 * conf_select_job:1148 * conf_select_job:
1147 * @name: name of job class to locate.1149 * @name: name of job class to locate,
1150 * @session: session class name belongs to.
1148 *1151 *
1149 * Select the best available class of a job named @name from the registered1152 * Select the best available class of a job named @name from the registered
1150 * configuration sources.1153 * configuration sources.
@@ -1152,7 +1155,7 @@
1152 * Returns: Best available job class or NULL if none available.1155 * Returns: Best available job class or NULL if none available.
1153 **/1156 **/
1154JobClass *1157JobClass *
1155conf_select_job (const char *name)1158conf_select_job (const char *name, const Session *session)
1156{1159{
1157 nih_assert (name != NULL);1160 nih_assert (name != NULL);
11581161
@@ -1164,6 +1167,9 @@
1164 if (source->type != CONF_JOB_DIR)1167 if (source->type != CONF_JOB_DIR)
1165 continue;1168 continue;
11661169
1170 if (source->session != session)
1171 continue;
1172
1167 NIH_HASH_FOREACH (source->files, file_iter) {1173 NIH_HASH_FOREACH (source->files, file_iter) {
1168 ConfFile *file = (ConfFile *)file_iter;1174 ConfFile *file = (ConfFile *)file_iter;
11691175
11701176
=== modified file 'init/conf.h'
--- init/conf.h 2011-02-23 11:04:27 +0000
+++ init/conf.h 2011-04-19 09:27:29 +0000
@@ -125,7 +125,7 @@
125125
126int conf_file_destroy (ConfFile *file);126int conf_file_destroy (ConfFile *file);
127127
128JobClass * conf_select_job (const char *name);128JobClass * conf_select_job (const char *name, const Session *session);
129129
130char *toggle_conf_name (const void *parent, const char *path)130char *toggle_conf_name (const void *parent, const char *path)
131 __attribute__ ((warn_unused_result, malloc));131 __attribute__ ((warn_unused_result, malloc));
132132
=== modified file 'init/control.c'
--- init/control.c 2011-03-10 14:06:37 +0000
+++ init/control.c 2011-04-19 09:27:29 +0000
@@ -417,7 +417,11 @@
417 session = session_from_dbus (NULL, message);417 session = session_from_dbus (NULL, message);
418418
419 /* Lookup the job */419 /* Lookup the job */
420 class = (JobClass *)nih_hash_lookup (job_classes, name);420 class = (JobClass *)nih_hash_search (job_classes, name, NULL);
421
422 while (class && class->session != session) {
423 class = (JobClass *)nih_hash_search (job_classes, name, &class->entry);
424 }
421425
422 if (class && ! session)426 if (class && ! session)
423 class->session = session;427 class->session = session;
424428
=== modified file 'init/job.c'
--- init/job.c 2011-02-23 10:38:33 +0000
+++ init/job.c 2011-04-19 09:27:29 +0000
@@ -100,8 +100,14 @@
100100
101 job->class = class;101 job->class = class;
102102
103 job->path = nih_dbus_path (job, DBUS_PATH_UPSTART, "jobs",103 if (job->class->session && job->class->session->chroot) {
104 class->name, job->name, NULL);104 /* JobClass already contains a valid D-Bus path prefix for the job */
105 job->path = nih_dbus_path (job, class->path, job->name, NULL);
106 } else {
107 job->path = nih_dbus_path (job, DBUS_PATH_UPSTART, "jobs",
108 class->name, job->name, NULL);
109 }
110
105 if (! job->path)111 if (! job->path)
106 goto error;112 goto error;
107113
108114
=== modified file 'init/job_class.c'
--- init/job_class.c 2011-02-23 11:04:27 +0000
+++ init/job_class.c 2011-04-19 09:27:29 +0000
@@ -100,7 +100,7 @@
100100
101/* Prototypes for static functions */101/* Prototypes for static functions */
102static void job_class_add (JobClass *class);102static void job_class_add (JobClass *class);
103static int job_class_remove (JobClass *class);103static int job_class_remove (JobClass *class, const Session *session);
104104
105105
106/**106/**
@@ -280,19 +280,27 @@
280int280int
281job_class_consider (JobClass *class)281job_class_consider (JobClass *class)
282{282{
283 JobClass *registered, *best;283 JobClass *registered = NULL, *best = NULL;
284284
285 nih_assert (class != NULL);285 nih_assert (class != NULL);
286286
287 job_class_init ();287 job_class_init ();
288288
289 best = conf_select_job (class->name);289 best = conf_select_job (class->name, class->session);
290 nih_assert (best != NULL);290 nih_assert (best != NULL);
291291 nih_assert (best->session == class->session);
292 registered = (JobClass *)nih_hash_lookup (job_classes, class->name);292
293 registered = (JobClass *)nih_hash_search (job_classes, class->name, NULL);
294
295 /* If we found an entry, ensure we only consider the appropriate session */
296 while (registered && registered->session != class->session)
297 {
298 registered = (JobClass *)nih_hash_search (job_classes, class->name, &registered->entry);
299 }
300
293 if (registered != best) {301 if (registered != best) {
294 if (registered)302 if (registered)
295 if (! job_class_remove (registered))303 if (! job_class_remove (registered, class->session))
296 return FALSE;304 return FALSE;
297305
298 job_class_add (best);306 job_class_add (best);
@@ -317,18 +325,25 @@
317int325int
318job_class_reconsider (JobClass *class)326job_class_reconsider (JobClass *class)
319{327{
320 JobClass *registered, *best;328 JobClass *registered = NULL, *best = NULL;
321329
322 nih_assert (class != NULL);330 nih_assert (class != NULL);
323331
324 job_class_init ();332 job_class_init ();
325333
326 best = conf_select_job (class->name);334 best = conf_select_job (class->name, class->session);
327335
328 registered = (JobClass *)nih_hash_lookup (job_classes, class->name);336 registered = (JobClass *)nih_hash_search (job_classes, class->name, NULL);
337
338 /* If we found an entry, ensure we only consider the appropriate session */
339 while (registered && registered->session != class->session)
340 {
341 registered = (JobClass *)nih_hash_search (job_classes, class->name, &registered->entry);
342 }
343
329 if (registered == class) {344 if (registered == class) {
330 if (class != best) {345 if (class != best) {
331 if (! job_class_remove (class))346 if (! job_class_remove (class, class->session))
332 return FALSE;347 return FALSE;
333348
334 job_class_add (best);349 job_class_add (best);
@@ -369,19 +384,24 @@
369384
370/**385/**
371 * job_class_remove:386 * job_class_remove:
372 * @class: class to remove.387 * @class: class to remove,
388 * @session: Session of @class.
373 *389 *
374 * Removes @class from the hash table and unregisters it from all current390 * Removes @class from the hash table and unregisters it from all current
375 * D-Bus connections.391 * D-Bus connections.
376 *392 *
377 * Returns: TRUE if class could be unregistered, FALSE if there are393 * Returns: TRUE if class could be unregistered, FALSE if there are
378 * active instances that prevent unregistration.394 * active instances that prevent unregistration, or if @session
395 * does not match the session associated with @class.
379 **/396 **/
380static int397static int
381job_class_remove (JobClass *class)398job_class_remove (JobClass *class, const Session *session)
382{399{
383 nih_assert (class != NULL);400 nih_assert (class != NULL);
384401
402 if (class->session != session)
403 return FALSE;
404
385 control_init ();405 control_init ();
386406
387 /* Return if we have any active instances */407 /* Return if we have any active instances */
388408
=== modified file 'init/job_process.c'
--- init/job_process.c 2011-02-24 15:41:04 +0000
+++ init/job_process.c 2011-04-19 09:27:29 +0000
@@ -40,6 +40,7 @@
40#include <unistd.h>40#include <unistd.h>
41#include <utmp.h>41#include <utmp.h>
42#include <utmpx.h>42#include <utmpx.h>
43#include <pwd.h>
4344
44#include <nih/macros.h>45#include <nih/macros.h>
45#include <nih/alloc.h>46#include <nih/alloc.h>
@@ -503,6 +504,16 @@
503 }504 }
504 }505 }
505506
507 /* Handle changing a chroot session job prior to dealing with
508 * the 'chroot' stanza.
509 */
510 if (class->session && class->session->chroot) {
511 if (chroot (class->session->chroot) < 0) {
512 nih_error_raise_system ();
513 job_process_error_abort (fds[1], JOB_PROCESS_ERROR_CHROOT, 0);
514 }
515 }
516
506 /* Change the root directory, confining path resolution within it;517 /* Change the root directory, confining path resolution within it;
507 * we do this before the working directory call so that is always518 * we do this before the working directory call so that is always
508 * relative to the new root.519 * relative to the new root.
@@ -558,6 +569,54 @@
558 }569 }
559 }570 }
560571
572 /* Handle unprivileged user job by dropping privileges to
573 * their level.
574 */
575 if (class->session && class->session->user) {
576 uid_t uid = class->session->user;
577 struct passwd *pw = NULL;
578
579 /* D-Bus does not expose a public API call to allow
580 * us to query a users primary group.
581 * _dbus_user_info_fill_uid () seems to exist for this
582 * purpose, but is a "secret" API. It is unclear why
583 * D-Bus neglects the gid when it allows the uid
584 * to be queried directly.
585 *
586 * Our only recourse is to disallow user sessions in a
587 * chroot and assume that all other user sessions
588 * originate from the local system. In this way, we can
589 * bypass D-Bus and use getpwuid ().
590 */
591
592 if (class->session->chroot) {
593 /* We cannot determine the group id of the user
594 * session in the chroot via D-Bus, so disallow
595 * all jobs in such an environment.
596 */
597 _nih_error_raise (__FILE__, __LINE__, __FUNCTION__,
598 EPERM, strerror (EPERM));
599 }
600
601 pw = getpwuid (uid);
602
603 if (!pw)
604 nih_return_system_error (-1);
605
606 nih_assert (pw->pw_uid == uid);
607
608 if (uid && setuid (uid) < 0) {
609 nih_error_raise_system ();
610 job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETUID, 0);
611 }
612
613 if (pw->pw_gid && setgid (pw->pw_gid) < 0) {
614 nih_error_raise_system ();
615 job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETGID, 0);
616 }
617 }
618
619
561 /* Execute the process, if we escape from here it failed */620 /* Execute the process, if we escape from here it failed */
562 if (execvp (argv[0], argv) < 0) {621 if (execvp (argv[0], argv) < 0) {
563 nih_error_raise_system ();622 nih_error_raise_system ();
564623
=== modified file 'init/job_process.h'
--- init/job_process.h 2009-07-09 11:01:53 +0000
+++ init/job_process.h 2011-04-19 09:27:29 +0000
@@ -45,7 +45,9 @@
45 JOB_PROCESS_ERROR_CHROOT,45 JOB_PROCESS_ERROR_CHROOT,
46 JOB_PROCESS_ERROR_CHDIR,46 JOB_PROCESS_ERROR_CHDIR,
47 JOB_PROCESS_ERROR_PTRACE,47 JOB_PROCESS_ERROR_PTRACE,
48 JOB_PROCESS_ERROR_EXEC48 JOB_PROCESS_ERROR_EXEC,
49 JOB_PROCESS_ERROR_SETUID,
50 JOB_PROCESS_ERROR_SETGID,
49} JobProcessErrorType;51} JobProcessErrorType;
5052
51/**53/**
5254
=== modified file 'init/main.c'
--- init/main.c 2011-03-10 14:23:57 +0000
+++ init/main.c 2011-04-19 09:27:29 +0000
@@ -117,6 +117,8 @@
117117
118extern int use_session_bus;118extern int use_session_bus;
119119
120extern int disable_sessions;
121
120/**122/**
121 * options:123 * options:
122 *124 *
@@ -132,6 +134,9 @@
132 { 0, "no-startup-event", N_("do not emit any startup event (for testing)"),134 { 0, "no-startup-event", N_("do not emit any startup event (for testing)"),
133 NULL, NULL, &disable_startup_event, NULL },135 NULL, NULL, &disable_startup_event, NULL },
134136
137 { 0, "no-sessions", N_("Disable user and chroot sessions"),
138 NULL, NULL, &disable_sessions, NULL },
139
135 { 0, "restart", NULL, NULL, NULL, &restart, NULL },140 { 0, "restart", NULL, NULL, NULL, &restart, NULL },
136 141
137 { 0, "session", N_("use D-Bus session bus rather than system bus (for testing)"),142 { 0, "session", N_("use D-Bus session bus rather than system bus (for testing)"),
@@ -459,6 +464,9 @@
459 sigprocmask (SIG_SETMASK, &mask, NULL);464 sigprocmask (SIG_SETMASK, &mask, NULL);
460 }465 }
461466
467 if (disable_sessions)
468 nih_debug ("Sessions disabled");
469
462 /* Run through the loop at least once to deal with signals that were470 /* Run through the loop at least once to deal with signals that were
463 * delivered to the previous process while the mask was set or to471 * delivered to the previous process while the mask was set or to
464 * process the startup event we emitted.472 * process the startup event we emitted.
465473
=== modified file 'init/man/init.5'
--- init/man/init.5 2011-03-15 12:15:28 +0000
+++ init/man/init.5 2011-04-19 09:27:29 +0000
@@ -5,8 +5,6 @@
5.\"5.\"
6.SH SYNOPSIS6.SH SYNOPSIS
7.B /etc/init/7.B /etc/init/
8
9.B $HOME/.init/
10.\"8.\"
11.SH DESCRIPTION9.SH DESCRIPTION
12On startup, the Upstart10On startup, the Upstart
@@ -16,11 +14,6 @@
16directory, and watches for future changes to these files using14directory, and watches for future changes to these files using
17.BR inotify (7).15.BR inotify (7).
1816
19If D\-Bus has been configured to allow non\-privileged users to invoke all
20Upstart D\-Bus methods, Upstart is also able to manage User Jobs. See
21.B User Jobs
22for further details.
23
24To be considered by Upstart, files in this directory must have a17To be considered by Upstart, files in this directory must have a
25recognized suffix and may also be present in sub\-directories. There are18recognized suffix and may also be present in sub\-directories. There are
26two recognized suffixes:19two recognized suffixes:
@@ -72,37 +65,6 @@
7265
73Configuration files are plain text and should not be executable.66Configuration files are plain text and should not be executable.
74.\"67.\"
75.SS User Jobs
76
77A User Job is a job configuration file created by a non\-privileged user
78in the
79.B $HOME/.init/
80directory. Job configuration files in this directory have
81the same syntax as system job configuration files.
82
83Any user can create user jobs, but that user can control
84.I only
85jobs they create.
86
87Users are able to manage their jobs using the standard
88.BR initctl (8)
89facility.
90
91Note that a user job configuration file cannot have the same name as a
92system job configuration file.
93
94.\"
95.SS Chroot Support
96
97Upstart is able to manage jobs within a \fBchroot\fP(2). To control jobs
98within the chroot environment, use the standard
99.BR initctl (8)
100facility. Note that it is not necessary to install D\-Bus within the
101chroot (in fact it is not recommended).
102
103Note that User Jobs can be created within a chroot environment.
104
105.\"
106.SS Configuration File Format68.SS Configuration File Format
107Each line begins with a configuration stanza and continues until either69Each line begins with a configuration stanza and continues until either
108the end of the line or a line containing a closing stanza. Line breaks70the end of the line or a line containing a closing stanza. Line breaks
10971
=== modified file 'init/man/init.8'
--- init/man/init.8 2011-03-10 14:23:57 +0000
+++ init/man/init.8 2011-04-19 09:27:29 +0000
@@ -1,4 +1,4 @@
1.TH init 8 2011-03-03 "Upstart"1.TH init 8 2011-04-06 "Upstart"
2.\"2.\"
3.SH NAME3.SH NAME
4init \- Upstart process management daemon4init \- Upstart process management daemon
@@ -68,28 +68,32 @@
68by placing them on the kernel command-line.68by placing them on the kernel command-line.
69.\"69.\"
70.TP70.TP
71.B --confdir \fIdirectory\fP71.B \-\-confdir \fIdirectory\fP
72Read job configuration files from a directory other than72Read job configuration files from a directory other than
73\fI/etc/init\fP.73\fI/etc/init\fP.
74.\"74.\"
75.TP75.TP
76.B --no-startup-event76.B \-\-no\-sessions
77Disable user and chroot sessions.
78.\"
79.TP
80.B \-\-no\-startup\-event
77Suppress emission of the initial startup event. This option should only81Suppress emission of the initial startup event. This option should only
78be used for testing since it will stop the 82be used for testing since it will stop the
79.BR init (8)83.BR init (8)
80daemon from starting \fBany\fP jobs automatically.84daemon from starting \fBany\fP jobs automatically.
81.\"85.\"
82.TP86.TP
83.B --session87.B \-\-session
84Connect to the D-Bus session bus. This should only be used for testing.88Connect to the D-Bus session bus. This should only be used for testing.
85.\"89.\"
86.TP90.TP
87.B --startup-event \fIevent\fP91.B \-\-startup-event \fIevent\fP
88Specify a different initial startup event from the standard92Specify a different initial startup event from the standard
89.BR startup (7) .93.BR startup (7) .
90.\"94.\"
91.TP95.TP
92.B --verbose96.B \-\-verbose
93Outputs verbose messages about job state changes and event emissions to the97Outputs verbose messages about job state changes and event emissions to the
94system console or log, useful for debugging boot.98system console or log, useful for debugging boot.
95.\"99.\"
@@ -123,7 +127,7 @@
123warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.127warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
124.\"128.\"
125.SH SEE ALSO129.SH SEE ALSO
126.BR control-alt-delete (7)130.BR control\-alt\-delete (7)
127.BR init (5)131.BR init (5)
128.BR initctl (8)132.BR initctl (8)
129.BR runlevel (7)133.BR runlevel (7)
130134
=== modified file 'init/parse_job.c'
--- init/parse_job.c 2011-02-24 15:41:04 +0000
+++ init/parse_job.c 2011-04-19 09:27:29 +0000
@@ -280,8 +280,8 @@
280 * of the returned job are freed, the returned job will also be280 * of the returned job are freed, the returned job will also be
281 * freed.281 * freed.
282 *282 *
283 * Returns: if @update is NULL, returns new JobClass structure on success, NULL on raised error.283 * Returns: If @update is NULL, returns new JobClass structure on success, NULL on raised error.
284 * If @update is not NULL, returns @update or NULL on error.284 * If @update is not NULL, returns @update on success, or NULL on error.
285 **/285 **/
286JobClass *286JobClass *
287parse_job (const void *parent,287parse_job (const void *parent,
288288
=== modified file 'init/session.c'
--- init/session.c 2011-02-23 09:35:03 +0000
+++ init/session.c 2011-04-19 09:27:29 +0000
@@ -56,6 +56,14 @@
56 **/56 **/
57NihList *sessions = NULL;57NihList *sessions = NULL;
5858
59/**
60 * disable_sessions:
61 *
62 * If TRUE, disable user and chroot sessions, resulting in a
63 * "traditional" (pre-session support) system.
64 **/
65int disable_sessions = FALSE;
66
5967
60/* Prototypes for static functions */68/* Prototypes for static functions */
61static void session_create_conf_source (Session *sesson);69static void session_create_conf_source (Session *sesson);
@@ -113,22 +121,23 @@
113}121}
114122
115Session *123Session *
116session_from_dbus (const void * parent,124session_from_dbus (const void *parent,
117 NihDBusMessage *message)125 NihDBusMessage *message)
118{126{
119 const char * sender;127 const char *sender;
120 DBusError dbus_error;128 DBusError dbus_error;
121 unsigned long unix_user;129 unsigned long unix_user;
122 unsigned long unix_process_id;130 unsigned long unix_process_id;
123 char root[PATH_MAX];131 char root[PATH_MAX];
124 Session * session;132 Session *session;
125133
126 nih_assert (message != NULL);134 nih_assert (message != NULL);
127135
128#ifdef TEST136 /* Handle explicit command-line request and alternative request
129 /* Return "NULL session" for testing framework. */137 * method (primarily for test framework) to disable session support.
130 return NULL;138 */
131#endif139 if (disable_sessions || getenv ("UPSTART_NO_SESSIONS"))
140 return NULL;
132141
133 session_init ();142 session_init ();
134143
@@ -160,7 +169,7 @@
160 }169 }
161170
162 /* If we retrieved a process id, look up the root path for it;171 /* If we retrieved a process id, look up the root path for it;
163 * if it's just / don't worry so much about it.172 * if it's just '/' don't worry so much about it.
164 */173 */
165 if (unix_process_id) {174 if (unix_process_id) {
166 nih_local char *symlink = NULL;175 nih_local char *symlink = NULL;
@@ -193,15 +202,19 @@
193 if (unix_process_id) {202 if (unix_process_id) {
194 if (! session->chroot)203 if (! session->chroot)
195 continue;204 continue;
205
206 /* ignore sessions relating to other chroots */
196 if (strcmp (session->chroot, root))207 if (strcmp (session->chroot, root))
197 continue;208 continue;
198 }209 }
199210
211 /* ignore sessions relating to other users */
200 if (unix_user != session->user)212 if (unix_user != session->user)
201 continue;213 continue;
202214
203 if (! session->conf_path)215 if (! session->conf_path)
204 session_create_conf_source (session);216 session_create_conf_source (session);
217
205 return session;218 return session;
206 }219 }
207220
208221
=== modified file 'init/session.h'
--- init/session.h 2010-12-10 03:17:53 +0000
+++ init/session.h 2011-04-19 09:27:29 +0000
@@ -35,8 +35,33 @@
35 * @user: uid all jobs are switched to,35 * @user: uid all jobs are switched to,
36 * @conf_path: configuration path.36 * @conf_path: configuration path.
37 *37 *
38 * This structure is used to identify collections of jobs that share either38 * This structure is used to identify collections of jobs
39 * a common @chroot and/or common @user.39 * that share either a common @chroot and/or common @user.
40 *
41 * Summary of Session values for different environments:
42 *
43 * +-------------+---------------------------------------+
44 * | D-Bus | Session |
45 * +------+------+--------+-----+------------------------+
46 * | user | PID | chroot | uid | Object contents |
47 * +------+------+--------+-----+------------------------+
48 * | 0 | >0 | no | 0 | NULL (*1) |
49 * | >0 | "0" | no | >0 | only uid set. |
50 * | 0 | >0 | yes | 0 | chroot + conf_path set |
51 * | >0 | ?? | yes | >0 | XXX: fails (*2) |
52 * +------+------+--------+-----+------------------------+
53 *
54 * Notes:
55 *
56 * (*1) - The "NULL session" represents the "traditional" environment
57 * before sessions were introduced (namely a non-chroot environment
58 * where all job and event operations were handled by uid 0 (root)).
59 *
60 * (*2) - error is:
61 *
62 * initctl: Unable to connect to system bus: Failed to connect to socket
63 * /var/run/dbus/system_bus_socket: No such file or directory
64 *
40 **/65 **/
41typedef struct session {66typedef struct session {
42 NihList entry;67 NihList entry;
4368
=== modified file 'init/tests/test_blocked.c'
--- init/tests/test_blocked.c 2011-02-23 09:35:03 +0000
+++ init/tests/test_blocked.c 2011-04-19 09:27:29 +0000
@@ -38,10 +38,6 @@
38 Job *job;38 Job *job;
39 Event *event;39 Event *event;
40 NihDBusMessage *message = NULL;40 NihDBusMessage *message = NULL;
41 Session *session;
42
43 session = session_new (NULL, NULL, getuid ());
44 TEST_NE_P (session, NULL);
4541
46 TEST_FUNCTION ("blocked_new");42 TEST_FUNCTION ("blocked_new");
4743
@@ -50,7 +46,7 @@
50 * in a list.46 * in a list.
51 */47 */
52 TEST_FEATURE ("with job");48 TEST_FEATURE ("with job");
53 class = job_class_new (NULL, "test", session);49 class = job_class_new (NULL, "test", NULL);
54 job = job_new (class, "");50 job = job_new (class, "");
5551
56 TEST_ALLOC_FAIL {52 TEST_ALLOC_FAIL {
@@ -361,7 +357,6 @@
361 nih_free (blocked);357 nih_free (blocked);
362 TEST_FREE (message);358 TEST_FREE (message);
363 }359 }
364 nih_free (session);
365}360}
366361
367362
@@ -369,6 +364,9 @@
369main (int argc,364main (int argc,
370 char *argv[])365 char *argv[])
371{366{
367 /* run tests in legacy (pre-session support) mode */
368 setenv ("UPSTART_NO_SESSIONS", "1", 1);
369
372 test_new ();370 test_new ();
373371
374 return 0;372 return 0;
375373
=== modified file 'init/tests/test_conf.c'
--- init/tests/test_conf.c 2011-02-23 11:04:27 +0000
+++ init/tests/test_conf.c 2011-04-19 09:27:29 +0000
@@ -4443,22 +4443,18 @@
4443 ConfFile *file;4443 ConfFile *file;
4444 JobClass *job, *other, *ptr;4444 JobClass *job, *other, *ptr;
4445 Job *instance;4445 Job *instance;
4446 Session *session;
44474446
4448 TEST_FUNCTION ("conf_file_destroy");4447 TEST_FUNCTION ("conf_file_destroy");
4449 source = conf_source_new (NULL, "/path", CONF_JOB_DIR);4448 source = conf_source_new (NULL, "/path", CONF_JOB_DIR);
44504449
4451 session = session_new (NULL, NULL, getuid ());
4452 TEST_NE_P (session, NULL);
4453
4454 /* Check that when a ConfFile for a job is freed, the attached4450 /* Check that when a ConfFile for a job is freed, the attached
4455 * job is also freed if it is not the current job.4451 * job is also freed if it is not the current job.
4456 */4452 */
4457 TEST_FEATURE ("with not-current job");4453 TEST_FEATURE ("with not-current job");
4458 file = conf_file_new (source, "/path/to/file");4454 file = conf_file_new (source, "/path/to/file");
4459 job = file->job = job_class_new (NULL, "foo", session);4455 job = file->job = job_class_new (NULL, "foo", NULL);
44604456
4461 other = job_class_new (NULL, "foo", session);4457 other = job_class_new (NULL, "foo", NULL);
4462 nih_hash_add (job_classes, &other->entry);4458 nih_hash_add (job_classes, &other->entry);
44634459
4464 TEST_FREE_TAG (job);4460 TEST_FREE_TAG (job);
@@ -4478,7 +4474,7 @@
4478 */4474 */
4479 TEST_FEATURE ("with stopped job");4475 TEST_FEATURE ("with stopped job");
4480 file = conf_file_new (source, "/path/to/file");4476 file = conf_file_new (source, "/path/to/file");
4481 job = file->job = job_class_new (NULL, "foo", session);4477 job = file->job = job_class_new (NULL, "foo", NULL);
44824478
4483 nih_hash_add (job_classes, &job->entry);4479 nih_hash_add (job_classes, &job->entry);
44844480
@@ -4498,7 +4494,7 @@
4498 */4494 */
4499 TEST_FEATURE ("with running job");4495 TEST_FEATURE ("with running job");
4500 file = conf_file_new (source, "/path/to/file");4496 file = conf_file_new (source, "/path/to/file");
4501 job = file->job = job_class_new (NULL, "foo", session);4497 job = file->job = job_class_new (NULL, "foo", NULL);
45024498
4503 nih_hash_add (job_classes, &job->entry);4499 nih_hash_add (job_classes, &job->entry);
45044500
@@ -4522,7 +4518,6 @@
4522 nih_free (job);4518 nih_free (job);
45234519
4524 nih_free (source);4520 nih_free (source);
4525 nih_free (session);
4526}4521}
45274522
45284523
@@ -4532,10 +4527,6 @@
4532 ConfSource *source1, *source2, *source3;4527 ConfSource *source1, *source2, *source3;
4533 ConfFile *file1, *file2, *file3, *file4, *file5;4528 ConfFile *file1, *file2, *file3, *file4, *file5;
4534 JobClass *class1, *class2, *class3, *class4, *ptr;4529 JobClass *class1, *class2, *class3, *class4, *ptr;
4535 Session *session;
4536
4537 session = session_new (NULL, NULL, getuid ());
4538 TEST_NE_P (session, NULL);
45394530
4540 TEST_FUNCTION ("conf_select_job");4531 TEST_FUNCTION ("conf_select_job");
4541 source1 = conf_source_new (NULL, "/tmp/foo", CONF_DIR);4532 source1 = conf_source_new (NULL, "/tmp/foo", CONF_DIR);
@@ -4543,26 +4534,26 @@
4543 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);4534 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);
45444535
4545 file1 = conf_file_new (source2, "/tmp/bar/frodo");4536 file1 = conf_file_new (source2, "/tmp/bar/frodo");
4546 class1 = file1->job = job_class_new (NULL, "frodo", session);4537 class1 = file1->job = job_class_new (NULL, "frodo", NULL);
45474538
4548 file2 = conf_file_new (source2, "/tmp/bar/bilbo");4539 file2 = conf_file_new (source2, "/tmp/bar/bilbo");
45494540
4550 file3 = conf_file_new (source2, "/tmp/bar/drogo");4541 file3 = conf_file_new (source2, "/tmp/bar/drogo");
4551 class2 = file3->job = job_class_new (NULL, "drogo", session);4542 class2 = file3->job = job_class_new (NULL, "drogo", NULL);
45524543
4553 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);4544 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);
45544545
4555 file4 = conf_file_new (source3, "/tmp/baz/frodo");4546 file4 = conf_file_new (source3, "/tmp/baz/frodo");
4556 class3 = file4->job = job_class_new (NULL, "frodo", session);4547 class3 = file4->job = job_class_new (NULL, "frodo", NULL);
45574548
4558 file5 = conf_file_new (source2, "/tmp/bar/bilbo");4549 file5 = conf_file_new (source2, "/tmp/bar/bilbo");
4559 class4 = file5->job = job_class_new (NULL, "bilbo", session);4550 class4 = file5->job = job_class_new (NULL, "bilbo", NULL);
45604551
45614552
4562 /* Check that a job with only one file is returned.4553 /* Check that a job with only one file is returned.
4563 */4554 */
4564 TEST_FEATURE ("with one file");4555 TEST_FEATURE ("with one file");
4565 ptr = conf_select_job ("drogo");4556 ptr = conf_select_job ("drogo", NULL);
45664557
4567 TEST_EQ_P (ptr, class2);4558 TEST_EQ_P (ptr, class2);
45684559
@@ -4571,7 +4562,7 @@
4571 * returned.4562 * returned.
4572 */4563 */
4573 TEST_FEATURE ("with multiple files");4564 TEST_FEATURE ("with multiple files");
4574 ptr = conf_select_job ("frodo");4565 ptr = conf_select_job ("frodo", NULL);
45754566
4576 TEST_EQ_P (ptr, class1);4567 TEST_EQ_P (ptr, class1);
45774568
@@ -4579,7 +4570,7 @@
4579 /* Check that files with no attached job are ignored.4570 /* Check that files with no attached job are ignored.
4580 */4571 */
4581 TEST_FEATURE ("with file but no attached job");4572 TEST_FEATURE ("with file but no attached job");
4582 ptr = conf_select_job ("bilbo");4573 ptr = conf_select_job ("bilbo", NULL);
45834574
4584 TEST_EQ_P (ptr, class4);4575 TEST_EQ_P (ptr, class4);
45854576
@@ -4587,7 +4578,7 @@
4587 /* Check that when there is no match, NULL is returned.4578 /* Check that when there is no match, NULL is returned.
4588 */4579 */
4589 TEST_FEATURE ("with no match");4580 TEST_FEATURE ("with no match");
4590 ptr = conf_select_job ("meep");4581 ptr = conf_select_job ("meep", NULL);
45914582
4592 TEST_EQ_P (ptr, NULL);4583 TEST_EQ_P (ptr, NULL);
45934584
@@ -4595,7 +4586,6 @@
4595 nih_free (source3);4586 nih_free (source3);
4596 nih_free (source2);4587 nih_free (source2);
4597 nih_free (source1);4588 nih_free (source1);
4598 nih_free (session);
4599}4589}
46004590
46014591
@@ -4603,6 +4593,9 @@
4603main (int argc,4593main (int argc,
4604 char *argv[])4594 char *argv[])
4605{4595{
4596 /* run tests in legacy (pre-session support) mode */
4597 setenv ("UPSTART_NO_SESSIONS", "1", 1);
4598
4606 test_source_new ();4599 test_source_new ();
4607 test_file_new ();4600 test_file_new ();
4608 test_source_reload_job_dir ();4601 test_source_reload_job_dir ();
46094602
=== modified file 'init/tests/test_control.c'
--- init/tests/test_control.c 2011-03-24 13:11:53 +0000
+++ init/tests/test_control.c 2011-04-19 09:27:29 +0000
@@ -154,7 +154,6 @@
154 Job *job1, *job2;154 Job *job1, *job2;
155 pid_t pid;155 pid_t pid;
156 int fd, wait_fd, status;156 int fd, wait_fd, status;
157 Session *session = NULL;
158157
159 TEST_FUNCTION ("control_server_connect");158 TEST_FUNCTION ("control_server_connect");
160 program_name = "test";159 program_name = "test";
@@ -234,10 +233,10 @@
234 * new connection has them automatically registered.233 * new connection has them automatically registered.
235 */234 */
236 TEST_FEATURE ("with existing jobs");235 TEST_FEATURE ("with existing jobs");
237 class1 = job_class_new (NULL, "foo", session);236 class1 = job_class_new (NULL, "foo", NULL);
238 nih_hash_add (job_classes, &class1->entry);237 nih_hash_add (job_classes, &class1->entry);
239238
240 class2 = job_class_new (NULL, "bar", session);239 class2 = job_class_new (NULL, "bar", NULL);
241 job1 = job_new (class2, "test1");240 job1 = job_new (class2, "test1");
242 job2 = job_new (class2, "test2");241 job2 = job_new (class2, "test2");
243 nih_hash_add (job_classes, &class2->entry);242 nih_hash_add (job_classes, &class2->entry);
@@ -439,7 +438,6 @@
439 NihDBusObject *object;438 NihDBusObject *object;
440 pid_t pid;439 pid_t pid;
441 int ret, wait_fd, fd, status;440 int ret, wait_fd, fd, status;
442 Session *session = NULL;
443441
444 TEST_FUNCTION ("control_bus_open");442 TEST_FUNCTION ("control_bus_open");
445 program_name = "test";443 program_name = "test";
@@ -535,10 +533,10 @@
535 refuse_registration = FALSE;533 refuse_registration = FALSE;
536 server_conn = NULL;534 server_conn = NULL;
537535
538 class1 = job_class_new (NULL, "foo", session);536 class1 = job_class_new (NULL, "foo", NULL);
539 nih_hash_add (job_classes, &class1->entry);537 nih_hash_add (job_classes, &class1->entry);
540538
541 class2 = job_class_new (NULL, "bar", session);539 class2 = job_class_new (NULL, "bar", NULL);
542 job1 = job_new (class2, "test1");540 job1 = job_new (class2, "test1");
543 job2 = job_new (class2, "test2");541 job2 = job_new (class2, "test2");
544 nih_hash_add (job_classes, &class2->entry);542 nih_hash_add (job_classes, &class2->entry);
@@ -985,13 +983,12 @@
985 NihError *error;983 NihError *error;
986 NihDBusError *dbus_error;984 NihDBusError *dbus_error;
987 int ret;985 int ret;
988 Session *session = NULL;
989986
990 TEST_FUNCTION ("control_get_job_by_name");987 TEST_FUNCTION ("control_get_job_by_name");
991 nih_error_init ();988 nih_error_init ();
992 job_class_init ();989 job_class_init ();
993990
994 class = job_class_new (NULL, "test", session);991 class = job_class_new (NULL, "test", NULL);
995 nih_hash_add (job_classes, &class->entry);992 nih_hash_add (job_classes, &class->entry);
996993
997994
@@ -1096,7 +1093,6 @@
1096 NihError *error;1093 NihError *error;
1097 char **paths;1094 char **paths;
1098 int ret;1095 int ret;
1099 Session *session = NULL;
11001096
1101 TEST_FUNCTION ("control_get_all_jobs");1097 TEST_FUNCTION ("control_get_all_jobs");
1102 nih_error_init ();1098 nih_error_init ();
@@ -1107,13 +1103,13 @@
1107 * in an array allocated as a child of the message structure.1103 * in an array allocated as a child of the message structure.
1108 */1104 */
1109 TEST_FEATURE ("with registered jobs");1105 TEST_FEATURE ("with registered jobs");
1110 class1 = job_class_new (NULL, "frodo", session);1106 class1 = job_class_new (NULL, "frodo", NULL);
1111 nih_hash_add (job_classes, &class1->entry);1107 nih_hash_add (job_classes, &class1->entry);
11121108
1113 class2 = job_class_new (NULL, "bilbo", session);1109 class2 = job_class_new (NULL, "bilbo", NULL);
1114 nih_hash_add (job_classes, &class2->entry);1110 nih_hash_add (job_classes, &class2->entry);
11151111
1116 class3 = job_class_new (NULL, "sauron", session);1112 class3 = job_class_new (NULL, "sauron", NULL);
1117 nih_hash_add (job_classes, &class3->entry);1113 nih_hash_add (job_classes, &class3->entry);
11181114
1119 TEST_ALLOC_FAIL {1115 TEST_ALLOC_FAIL {
@@ -2223,6 +2219,9 @@
2223main (int argc,2219main (int argc,
2224 char *argv[])2220 char *argv[])
2225{2221{
2222 /* run tests in legacy (pre-session support) mode */
2223 setenv ("UPSTART_NO_SESSIONS", "1", 1);
2224
2226 test_server_open ();2225 test_server_open ();
2227 test_server_connect ();2226 test_server_connect ();
2228 test_server_close ();2227 test_server_close ();
22292228
=== modified file 'init/tests/test_environ.c'
--- init/tests/test_environ.c 2009-06-23 09:29:35 +0000
+++ init/tests/test_environ.c 2011-04-19 09:27:29 +0000
@@ -1692,6 +1692,9 @@
1692main (int argc,1692main (int argc,
1693 char *argv[])1693 char *argv[])
1694{1694{
1695 /* run tests in legacy (pre-session support) mode */
1696 setenv ("UPSTART_NO_SESSIONS", "1", 1);
1697
1695 test_add ();1698 test_add ();
1696 test_append ();1699 test_append ();
1697 test_set ();1700 test_set ();
16981701
=== modified file 'init/tests/test_event.c'
--- init/tests/test_event.c 2011-02-23 09:35:03 +0000
+++ init/tests/test_event.c 2011-04-19 09:27:29 +0000
@@ -222,10 +222,6 @@
222 JobClass *class = NULL;222 JobClass *class = NULL;
223 Job *job;223 Job *job;
224 Event *event = NULL;224 Event *event = NULL;
225 Session *session;
226
227 session = session_new (NULL, NULL, getuid ());
228 TEST_NE_P (session, NULL);
229225
230 /* Check that a pending event in the queue results in jobs being226 /* Check that a pending event in the queue results in jobs being
231 * started and/or stopped and gets moved into the handling state.227 * started and/or stopped and gets moved into the handling state.
@@ -237,7 +233,7 @@
237 TEST_ALLOC_SAFE {233 TEST_ALLOC_SAFE {
238 event = event_new (NULL, "test", NULL);234 event = event_new (NULL, "test", NULL);
239235
240 class = job_class_new (NULL, "test", session);236 class = job_class_new (NULL, "test", NULL);
241 class->task = TRUE;237 class->task = TRUE;
242 class->process[PROCESS_MAIN] = process_new (class->process);238 class->process[PROCESS_MAIN] = process_new (class->process);
243 class->process[PROCESS_MAIN]->command = "echo";239 class->process[PROCESS_MAIN]->command = "echo";
@@ -266,7 +262,6 @@
266 nih_free (class);262 nih_free (class);
267 nih_free (event);263 nih_free (event);
268 }264 }
269 nih_free (session);
270}265}
271266
272void267void
@@ -280,10 +275,6 @@
280 EventOperator *oper;275 EventOperator *oper;
281 Blocked *blocked = NULL, *blocked1 = NULL, *blocked2 = NULL;276 Blocked *blocked = NULL, *blocked1 = NULL, *blocked2 = NULL;
282 char **env1 = NULL, **env2 = NULL;277 char **env1 = NULL, **env2 = NULL;
283 Session *session;
284
285 session = session_new (NULL, NULL, getuid ());
286 TEST_NE_P (session, NULL);
287278
288 TEST_FUNCTION ("event_pending_handle_jobs");279 TEST_FUNCTION ("event_pending_handle_jobs");
289 program_name = "test";280 program_name = "test";
@@ -301,7 +292,7 @@
301292
302 TEST_FREE_TAG (event1);293 TEST_FREE_TAG (event1);
303294
304 class = job_class_new (NULL, "test", session);295 class = job_class_new (NULL, "test", NULL);
305 class->task = TRUE;296 class->task = TRUE;
306297
307 class->start_on = event_operator_new (298 class->start_on = event_operator_new (
@@ -336,7 +327,7 @@
336327
337 TEST_FREE_TAG (event1);328 TEST_FREE_TAG (event1);
338329
339 class = job_class_new (NULL, "test", session);330 class = job_class_new (NULL, "test", NULL);
340 class->task = TRUE;331 class->task = TRUE;
341332
342 class->start_on = event_operator_new (333 class->start_on = event_operator_new (
@@ -395,7 +386,7 @@
395 TEST_FREE_TAG (event1);386 TEST_FREE_TAG (event1);
396 TEST_FREE_TAG (event2);387 TEST_FREE_TAG (event2);
397388
398 class = job_class_new (NULL, "test", session);389 class = job_class_new (NULL, "test", NULL);
399 class->task = TRUE;390 class->task = TRUE;
400391
401 assert (nih_str_array_add (&(class->env), class,392 assert (nih_str_array_add (&(class->env), class,
@@ -511,7 +502,7 @@
511502
512 TEST_FREE_TAG (event2);503 TEST_FREE_TAG (event2);
513504
514 class = job_class_new (NULL, "test", session);505 class = job_class_new (NULL, "test", NULL);
515 class->task = TRUE;506 class->task = TRUE;
516507
517 assert (nih_str_array_add (&(class->env), class,508 assert (nih_str_array_add (&(class->env), class,
@@ -637,7 +628,7 @@
637628
638 TEST_FREE_TAG (event2);629 TEST_FREE_TAG (event2);
639630
640 class = job_class_new (NULL, "test", session);631 class = job_class_new (NULL, "test", NULL);
641 class->task = TRUE;632 class->task = TRUE;
642633
643 assert (nih_str_array_add (&(class->env), class,634 assert (nih_str_array_add (&(class->env), class,
@@ -805,7 +796,7 @@
805796
806 TEST_FREE_TAG (event2);797 TEST_FREE_TAG (event2);
807798
808 class = job_class_new (NULL, "test", session);799 class = job_class_new (NULL, "test", NULL);
809 class->task = TRUE;800 class->task = TRUE;
810801
811 assert (nih_str_array_add (&(class->env), class,802 assert (nih_str_array_add (&(class->env), class,
@@ -930,7 +921,7 @@
930921
931 TEST_FREE_TAG (event1);922 TEST_FREE_TAG (event1);
932923
933 class = job_class_new (NULL, "test", session);924 class = job_class_new (NULL, "test", NULL);
934 class->instance = "$FRODO";925 class->instance = "$FRODO";
935 class->task = TRUE;926 class->task = TRUE;
936927
@@ -1009,7 +1000,7 @@
10091000
1010 TEST_FREE_TAG (event1);1001 TEST_FREE_TAG (event1);
10111002
1012 class = job_class_new (NULL, "test", session);1003 class = job_class_new (NULL, "test", NULL);
1013 class->instance = "$FRODO";1004 class->instance = "$FRODO";
1014 class->task = TRUE;1005 class->task = TRUE;
10151006
@@ -1093,7 +1084,7 @@
10931084
1094 TEST_FREE_TAG (event1);1085 TEST_FREE_TAG (event1);
10951086
1096 class = job_class_new (NULL, "test", session);1087 class = job_class_new (NULL, "test", NULL);
1097 class->instance = "$TIPPLE";1088 class->instance = "$TIPPLE";
1098 class->task = TRUE;1089 class->task = TRUE;
10991090
@@ -1136,7 +1127,7 @@
11361127
1137 TEST_FREE_TAG (event1);1128 TEST_FREE_TAG (event1);
11381129
1139 class = job_class_new (NULL, "test", session);1130 class = job_class_new (NULL, "test", NULL);
1140 class->task = TRUE;1131 class->task = TRUE;
11411132
1142 class->process[PROCESS_POST_STOP] = process_new (class);1133 class->process[PROCESS_POST_STOP] = process_new (class);
@@ -1184,7 +1175,7 @@
11841175
1185 TEST_FREE_TAG (event1);1176 TEST_FREE_TAG (event1);
11861177
1187 class = job_class_new (NULL, "test", session);1178 class = job_class_new (NULL, "test", NULL);
1188 class->task = TRUE;1179 class->task = TRUE;
11891180
1190 class->process[PROCESS_POST_STOP] = process_new (class);1181 class->process[PROCESS_POST_STOP] = process_new (class);
@@ -1259,7 +1250,7 @@
12591250
1260 TEST_FREE_TAG (event1);1251 TEST_FREE_TAG (event1);
12611252
1262 class = job_class_new (NULL, "test", session);1253 class = job_class_new (NULL, "test", NULL);
1263 class->task = TRUE;1254 class->task = TRUE;
12641255
1265 class->process[PROCESS_POST_STOP] = process_new (class);1256 class->process[PROCESS_POST_STOP] = process_new (class);
@@ -1338,7 +1329,7 @@
13381329
1339 TEST_FREE_TAG (event1);1330 TEST_FREE_TAG (event1);
13401331
1341 class = job_class_new (NULL, "test", session);1332 class = job_class_new (NULL, "test", NULL);
1342 class->task = TRUE;1333 class->task = TRUE;
13431334
1344 class->process[PROCESS_POST_STOP] = process_new (class);1335 class->process[PROCESS_POST_STOP] = process_new (class);
@@ -1448,7 +1439,7 @@
14481439
1449 TEST_FREE_TAG (event1);1440 TEST_FREE_TAG (event1);
14501441
1451 class = job_class_new (NULL, "test", session);1442 class = job_class_new (NULL, "test", NULL);
1452 class->task = TRUE;1443 class->task = TRUE;
14531444
1454 class->process[PROCESS_POST_STOP] = process_new (class);1445 class->process[PROCESS_POST_STOP] = process_new (class);
@@ -1536,7 +1527,7 @@
15361527
1537 TEST_FREE_TAG (event1);1528 TEST_FREE_TAG (event1);
15381529
1539 class = job_class_new (NULL, "test", session);1530 class = job_class_new (NULL, "test", NULL);
1540 class->task = TRUE;1531 class->task = TRUE;
15411532
1542 class->process[PROCESS_POST_STOP] = process_new (class);1533 class->process[PROCESS_POST_STOP] = process_new (class);
@@ -1607,7 +1598,6 @@
1607 }1598 }
16081599
1609 fclose (output);1600 fclose (output);
1610 nih_free (session);
1611}1601}
16121602
16131603
@@ -1619,10 +1609,6 @@
1619 Event *event = NULL, *bevent = NULL;1609 Event *event = NULL, *bevent = NULL;
1620 Blocked *blocked = NULL;1610 Blocked *blocked = NULL;
1621 EventOperator *oper;1611 EventOperator *oper;
1622 Session *session;
1623
1624 session = session_new (NULL, NULL, getuid ());
1625 TEST_NE_P (session, NULL);
16261612
1627 TEST_FUNCTION ("event_finished");1613 TEST_FUNCTION ("event_finished");
16281614
@@ -1637,7 +1623,7 @@
16371623
1638 TEST_FREE_TAG (event);1624 TEST_FREE_TAG (event);
16391625
1640 class = job_class_new (NULL, "test", session);1626 class = job_class_new (NULL, "test", NULL);
1641 class->process[PROCESS_MAIN] = process_new (class->process);1627 class->process[PROCESS_MAIN] = process_new (class->process);
1642 class->process[PROCESS_MAIN]->command = "echo";1628 class->process[PROCESS_MAIN]->command = "echo";
16431629
@@ -1671,7 +1657,7 @@
16711657
1672 TEST_FREE_TAG (event);1658 TEST_FREE_TAG (event);
16731659
1674 class = job_class_new (NULL, "test", session);1660 class = job_class_new (NULL, "test", NULL);
1675 class->process[PROCESS_MAIN] = process_new (class->process);1661 class->process[PROCESS_MAIN] = process_new (class->process);
1676 class->process[PROCESS_MAIN]->command = "echo";1662 class->process[PROCESS_MAIN]->command = "echo";
16771663
@@ -1713,7 +1699,7 @@
17131699
1714 TEST_FREE_TAG (event);1700 TEST_FREE_TAG (event);
17151701
1716 class = job_class_new (NULL, "test", session);1702 class = job_class_new (NULL, "test", NULL);
1717 class->process[PROCESS_MAIN] = process_new (class->process);1703 class->process[PROCESS_MAIN] = process_new (class->process);
1718 class->process[PROCESS_MAIN]->command = "echo";1704 class->process[PROCESS_MAIN]->command = "echo";
17191705
@@ -1754,7 +1740,7 @@
17541740
1755 TEST_FREE_TAG (event);1741 TEST_FREE_TAG (event);
17561742
1757 class = job_class_new (NULL, "foo", session);1743 class = job_class_new (NULL, "foo", NULL);
17581744
1759 job = job_new (class, "");1745 job = job_new (class, "");
1760 job->goal = JOB_STOP;1746 job->goal = JOB_STOP;
@@ -1787,7 +1773,7 @@
17871773
1788 TEST_FREE_TAG (event);1774 TEST_FREE_TAG (event);
17891775
1790 class = job_class_new (NULL, "foo", session);1776 class = job_class_new (NULL, "foo", NULL);
17911777
1792 job = job_new (class, "");1778 job = job_new (class, "");
1793 job->goal = JOB_START;1779 job->goal = JOB_START;
@@ -1818,7 +1804,7 @@
18181804
1819 TEST_FREE_TAG (event);1805 TEST_FREE_TAG (event);
18201806
1821 class = job_class_new (NULL, "foo", session);1807 class = job_class_new (NULL, "foo", NULL);
18221808
1823 job = job_new (class, "");1809 job = job_new (class, "");
1824 job->goal = JOB_STOP;1810 job->goal = JOB_STOP;
@@ -1860,7 +1846,7 @@
18601846
1861 TEST_FREE_TAG (event);1847 TEST_FREE_TAG (event);
18621848
1863 class = job_class_new (NULL, "foo", session);1849 class = job_class_new (NULL, "foo", NULL);
18641850
1865 job = job_new (class, "");1851 job = job_new (class, "");
1866 job->goal = JOB_START;1852 job->goal = JOB_START;
@@ -1903,7 +1889,7 @@
19031889
1904 TEST_FREE_TAG (event);1890 TEST_FREE_TAG (event);
19051891
1906 class = job_class_new (NULL, "foo", session);1892 class = job_class_new (NULL, "foo", NULL);
1907 class->process[PROCESS_POST_STOP] = process_new (class);1893 class->process[PROCESS_POST_STOP] = process_new (class);
1908 class->process[PROCESS_POST_STOP]->command = "echo";1894 class->process[PROCESS_POST_STOP]->command = "echo";
19091895
@@ -1948,7 +1934,7 @@
19481934
1949 TEST_FREE_TAG (event);1935 TEST_FREE_TAG (event);
19501936
1951 class = job_class_new (NULL, "foo", session);1937 class = job_class_new (NULL, "foo", NULL);
1952 class->process[PROCESS_PRE_START] = process_new (class);1938 class->process[PROCESS_PRE_START] = process_new (class);
1953 class->process[PROCESS_PRE_START]->command = "echo";1939 class->process[PROCESS_PRE_START]->command = "echo";
19541940
@@ -1981,7 +1967,6 @@
19811967
1982 nih_free (class);1968 nih_free (class);
1983 }1969 }
1984 nih_free (session);
1985}1970}
19861971
19871972
@@ -1989,6 +1974,9 @@
1989main (int argc,1974main (int argc,
1990 char *argv[])1975 char *argv[])
1991{1976{
1977 /* run tests in legacy (pre-session support) mode */
1978 setenv ("UPSTART_NO_SESSIONS", "1", 1);
1979
1992 test_new ();1980 test_new ();
1993 test_block ();1981 test_block ();
1994 test_unblock ();1982 test_unblock ();
19951983
=== modified file 'init/tests/test_event_operator.c'
--- init/tests/test_event_operator.c 2010-02-04 20:08:59 +0000
+++ init/tests/test_event_operator.c 2011-04-19 09:27:29 +0000
@@ -1325,6 +1325,9 @@
1325main (int argc,1325main (int argc,
1326 char *argv[])1326 char *argv[])
1327{1327{
1328 /* run tests in legacy (pre-session support) mode */
1329 setenv ("UPSTART_NO_SESSIONS", "1", 1);
1330
1328 test_operator_new ();1331 test_operator_new ();
1329 test_operator_copy ();1332 test_operator_copy ();
1330 test_operator_destroy ();1333 test_operator_destroy ();
13311334
=== modified file 'init/tests/test_job.c'
--- init/tests/test_job.c 2011-02-23 09:35:03 +0000
+++ init/tests/test_job.c 2011-04-19 09:27:29 +0000
@@ -72,10 +72,6 @@
72 NihDBusObject *object;72 NihDBusObject *object;
73 char *path;73 char *path;
74 int i;74 int i;
75 Session *session;
76
77 session = session_new (NULL, NULL, getuid ());
78 TEST_NE_P (session, NULL);
7975
80 TEST_FUNCTION ("job_new");76 TEST_FUNCTION ("job_new");
81 nih_error_init ();77 nih_error_init ();
@@ -90,7 +86,7 @@
90 * list of the class and have sensible defaults.86 * list of the class and have sensible defaults.
91 */87 */
92 TEST_FEATURE ("with no name");88 TEST_FEATURE ("with no name");
93 class = job_class_new (NULL, "test", session);89 class = job_class_new (NULL, "test", NULL);
94 class->stop_on = event_operator_new (class, EVENT_MATCH, "baz", NULL);90 class->stop_on = event_operator_new (class, EVENT_MATCH, "baz", NULL);
9591
96 TEST_ALLOC_FAIL {92 TEST_ALLOC_FAIL {
@@ -259,7 +255,6 @@
259 event_operator_reset (class->stop_on);255 event_operator_reset (class->stop_on);
260256
261 nih_free (class);257 nih_free (class);
262 nih_free (session);
263}258}
264259
265void260void
@@ -273,10 +268,6 @@
273 Job *job;268 Job *job;
274 NihDBusObject *object;269 NihDBusObject *object;
275 char *path;270 char *path;
276 Session *session;
277
278 session = session_new (NULL, NULL, getuid ());
279 TEST_NE_P (session, NULL);
280271
281 TEST_FUNCTION ("job_register");272 TEST_FUNCTION ("job_register");
282 dbus_error_init (&dbus_error);273 dbus_error_init (&dbus_error);
@@ -293,7 +284,7 @@
293 * using its path, and have a InstanceAdded signal emitted.284 * using its path, and have a InstanceAdded signal emitted.
294 */285 */
295 TEST_FEATURE ("with signal emission");286 TEST_FEATURE ("with signal emission");
296 class = job_class_new (NULL, "test", session);287 class = job_class_new (NULL, "test", NULL);
297 job = job_new (class, "fred");288 job = job_new (class, "fred");
298289
299 assert (dbus_connection_get_object_path_data (conn, job->path,290 assert (dbus_connection_get_object_path_data (conn, job->path,
@@ -333,7 +324,7 @@
333 * is still registered.324 * is still registered.
334 */325 */
335 TEST_FEATURE ("without signal emission");326 TEST_FEATURE ("without signal emission");
336 class = job_class_new (NULL, "test", session);327 class = job_class_new (NULL, "test", NULL);
337 job = job_new (class, "fred");328 job = job_new (class, "fred");
338329
339 assert (dbus_connection_get_object_path_data (conn, job->path,330 assert (dbus_connection_get_object_path_data (conn, job->path,
@@ -367,7 +358,6 @@
367 dbus_message_unref (message);358 dbus_message_unref (message);
368359
369 nih_free (class);360 nih_free (class);
370 nih_free (session);
371361
372 TEST_DBUS_CLOSE (conn);362 TEST_DBUS_CLOSE (conn);
373 TEST_DBUS_CLOSE (client_conn);363 TEST_DBUS_CLOSE (client_conn);
@@ -389,17 +379,13 @@
389 NihListEntry *entry = NULL;379 NihListEntry *entry = NULL;
390 DBusMessage *message;380 DBusMessage *message;
391 char *job_path = NULL, *goal, *state;381 char *job_path = NULL, *goal, *state;
392 Session *session;
393
394 session = session_new (NULL, NULL, getuid ());
395 TEST_NE_P (session, NULL);
396382
397 TEST_FUNCTION ("job_change_goal");383 TEST_FUNCTION ("job_change_goal");
398 event_init ();384 event_init ();
399385
400 program_name = "test";386 program_name = "test";
401387
402 class = job_class_new (NULL, "test", session);388 class = job_class_new (NULL, "test", NULL);
403 class->process[PROCESS_MAIN] = process_new (class);389 class->process[PROCESS_MAIN] = process_new (class);
404 class->process[PROCESS_MAIN]->command = "echo";390 class->process[PROCESS_MAIN]->command = "echo";
405 class->process[PROCESS_PRE_START] = process_new (class);391 class->process[PROCESS_PRE_START] = process_new (class);
@@ -671,7 +657,6 @@
671657
672658
673 nih_free (class);659 nih_free (class);
674 nih_free (session);
675 event_poll ();660 event_poll ();
676}661}
677662
@@ -697,10 +682,6 @@
697 DBusMessage *message;682 DBusMessage *message;
698 char *path, *job_path = NULL, *state;683 char *path, *job_path = NULL, *state;
699 int status;684 int status;
700 Session *session;
701
702 session = session_new (NULL, NULL, getuid ());
703 TEST_NE_P (session, NULL);
704685
705 TEST_FUNCTION ("job_change_state");686 TEST_FUNCTION ("job_change_state");
706 program_name = "test";687 program_name = "test";
@@ -709,7 +690,7 @@
709 TEST_FILENAME (dirname);690 TEST_FILENAME (dirname);
710 mkdir (dirname, 0700);691 mkdir (dirname, 0700);
711692
712 class = job_class_new (NULL, "test", session);693 class = job_class_new (NULL, "test", NULL);
713 class->process[PROCESS_MAIN] = process_new (class);694 class->process[PROCESS_MAIN] = process_new (class);
714 class->process[PROCESS_MAIN]->command = nih_sprintf (695 class->process[PROCESS_MAIN]->command = nih_sprintf (
715 class->process[PROCESS_MAIN], "touch %s/run", dirname);696 class->process[PROCESS_MAIN], "touch %s/run", dirname);
@@ -3754,7 +3735,7 @@
3754 TEST_ALLOC_SAFE {3735 TEST_ALLOC_SAFE {
3755 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);3736 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
3756 file = conf_file_new (source, "/tmp/test");3737 file = conf_file_new (source, "/tmp/test");
3757 file->job = job_class_new (NULL, "test", session);3738 file->job = job_class_new (NULL, "test", NULL);
3758 replacement = file->job;3739 replacement = file->job;
37593740
3760 job = job_new (class, "");3741 job = job_new (class, "");
@@ -3823,7 +3804,7 @@
3823 TEST_ALLOC_SAFE {3804 TEST_ALLOC_SAFE {
3824 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);3805 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
3825 file = conf_file_new (source, "/tmp/test");3806 file = conf_file_new (source, "/tmp/test");
3826 file->job = job_class_new (NULL, "test", session);3807 file->job = job_class_new (NULL, "test", NULL);
3827 replacement = file->job;3808 replacement = file->job;
38283809
3829 job = job_new (class, "");3810 job = job_new (class, "");
@@ -3900,7 +3881,7 @@
3900 TEST_FEATURE ("post-stop to waiting for deleted job");3881 TEST_FEATURE ("post-stop to waiting for deleted job");
3901 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);3882 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
3902 file = conf_file_new (source, "/tmp/test");3883 file = conf_file_new (source, "/tmp/test");
3903 file->job = job_class_new (NULL, "test", session);3884 file->job = job_class_new (NULL, "test", NULL);
3904 replacement = file->job;3885 replacement = file->job;
39053886
3906 class->deleted = TRUE;3887 class->deleted = TRUE;
@@ -3963,7 +3944,6 @@
3963 rmdir (dirname);3944 rmdir (dirname);
39643945
3965 nih_free (cause);3946 nih_free (cause);
3966 nih_free (session);
3967 event_poll ();3947 event_poll ();
3968}3948}
39693949
@@ -3972,13 +3952,9 @@
3972{3952{
3973 JobClass *class;3953 JobClass *class;
3974 Job *job;3954 Job *job;
3975 Session *session;
3976
3977 session = session_new (NULL, NULL, getuid ());
3978 TEST_NE_P (session, NULL);
39793955
3980 TEST_FUNCTION ("job_next_state");3956 TEST_FUNCTION ("job_next_state");
3981 class = job_class_new (NULL, "test", session);3957 class = job_class_new (NULL, "test", NULL);
3982 class->process[PROCESS_MAIN] = process_new (class);3958 class->process[PROCESS_MAIN] = process_new (class);
3983 class->process[PROCESS_MAIN]->command = "echo";3959 class->process[PROCESS_MAIN]->command = "echo";
39843960
@@ -4215,7 +4191,6 @@
42154191
42164192
4217 nih_free (class);4193 nih_free (class);
4218 nih_free (session);
4219}4194}
42204195
42214196
@@ -4226,10 +4201,6 @@
4226 Job *job;4201 Job *job;
4227 Blocked *blocked1, *blocked2;4202 Blocked *blocked1, *blocked2;
4228 Event *event1, *event2;4203 Event *event1, *event2;
4229 Session *session;
4230
4231 session = session_new (NULL, NULL, getuid ());
4232 TEST_NE_P (session, NULL);
42334204
4234 TEST_FUNCTION ("job_failed");4205 TEST_FUNCTION ("job_failed");
42354206
@@ -4238,7 +4209,7 @@
4238 * as failed before freeing the blocking list.4209 * as failed before freeing the blocking list.
4239 */4210 */
4240 TEST_FEATURE ("with no current failure");4211 TEST_FEATURE ("with no current failure");
4241 class = job_class_new (NULL, "test", session);4212 class = job_class_new (NULL, "test", NULL);
4242 job = job_new (class, "");4213 job = job_new (class, "");
42434214
4244 event1 = event_new (NULL, "foo", NULL);4215 event1 = event_new (NULL, "foo", NULL);
@@ -4279,7 +4250,7 @@
4279 * since these were added after the first failure.4250 * since these were added after the first failure.
4280 */4251 */
4281 TEST_FEATURE ("with previous failure");4252 TEST_FEATURE ("with previous failure");
4282 class = job_class_new (NULL, "test", session);4253 class = job_class_new (NULL, "test", NULL);
4283 job = job_new (class, "");4254 job = job_new (class, "");
4284 job->failed = TRUE;4255 job->failed = TRUE;
4285 job->failed_process = PROCESS_PRE_START;4256 job->failed_process = PROCESS_PRE_START;
@@ -4316,7 +4287,6 @@
4316 TEST_FALSE (event2->failed);4287 TEST_FALSE (event2->failed);
43174288
4318 nih_free (class);4289 nih_free (class);
4319 nih_free (session);
43204290
4321 event_poll ();4291 event_poll ();
4322}4292}
@@ -4328,10 +4298,6 @@
4328 Job *job;4298 Job *job;
4329 Blocked *blocked1, *blocked2;4299 Blocked *blocked1, *blocked2;
4330 Event *event1, *event2;4300 Event *event1, *event2;
4331 Session *session;
4332
4333 session = session_new (NULL, NULL, getuid ());
4334 TEST_NE_P (session, NULL);
43354301
4336 TEST_FUNCTION ("job_finished");4302 TEST_FUNCTION ("job_finished");
43374303
@@ -4339,7 +4305,7 @@
4339 * is unblocked and the list itself is then freed.4305 * is unblocked and the list itself is then freed.
4340 */4306 */
4341 TEST_FEATURE ("with blocked events");4307 TEST_FEATURE ("with blocked events");
4342 class = job_class_new (NULL, "test", session);4308 class = job_class_new (NULL, "test", NULL);
4343 job = job_new (class, "");4309 job = job_new (class, "");
43444310
4345 event1 = event_new (NULL, "foo", NULL);4311 event1 = event_new (NULL, "foo", NULL);
@@ -4375,7 +4341,7 @@
4375 * unblocked and marked as failed.4341 * unblocked and marked as failed.
4376 */4342 */
4377 TEST_FEATURE ("with blocked events and failure");4343 TEST_FEATURE ("with blocked events and failure");
4378 class = job_class_new (NULL, "test", session);4344 class = job_class_new (NULL, "test", NULL);
4379 job = job_new (class, "");4345 job = job_new (class, "");
43804346
4381 event1 = event_new (NULL, "foo", NULL);4347 event1 = event_new (NULL, "foo", NULL);
@@ -4411,7 +4377,7 @@
4411 * still works (and just does nothing).4377 * still works (and just does nothing).
4412 */4378 */
4413 TEST_FEATURE ("without blocked events");4379 TEST_FEATURE ("without blocked events");
4414 class = job_class_new (NULL, "test", session);4380 class = job_class_new (NULL, "test", NULL);
4415 job = job_new (class, "");4381 job = job_new (class, "");
44164382
4417 job_finished (job, TRUE);4383 job_finished (job, TRUE);
@@ -4419,7 +4385,6 @@
4419 TEST_LIST_EMPTY (&job->blocking);4385 TEST_LIST_EMPTY (&job->blocking);
44204386
4421 nih_free (class);4387 nih_free (class);
4422 nih_free (session);
44234388
4424 event_poll ();4389 event_poll ();
4425}4390}
@@ -4432,10 +4397,6 @@
4432 Job *job;4397 Job *job;
4433 Event *event;4398 Event *event;
4434 Blocked *blocked;4399 Blocked *blocked;
4435 Session *session;
4436
4437 session = session_new (NULL, NULL, getuid ());
4438 TEST_NE_P (session, NULL);
44394400
4440 TEST_FUNCTION ("job_emit_event");4401 TEST_FUNCTION ("job_emit_event");
44414402
@@ -4443,7 +4404,7 @@
4443 * event event emitted with the job name set.4404 * event event emitted with the job name set.
4444 */4405 */
4445 TEST_FEATURE ("with singleton in starting state");4406 TEST_FEATURE ("with singleton in starting state");
4446 class = job_class_new (NULL, "test", session);4407 class = job_class_new (NULL, "test", NULL);
44474408
4448 job = job_new (class, "");4409 job = job_new (class, "");
4449 job->goal = JOB_START;4410 job->goal = JOB_START;
@@ -4482,7 +4443,7 @@
4482 * instance name set.4443 * instance name set.
4483 */4444 */
4484 TEST_FEATURE ("with instance in starting state");4445 TEST_FEATURE ("with instance in starting state");
4485 class = job_class_new (NULL, "test", session);4446 class = job_class_new (NULL, "test", NULL);
4486 class->instance = "$FOO";4447 class->instance = "$FOO";
44874448
4488 job = job_new (class, "foo");4449 job = job_new (class, "foo");
@@ -4522,7 +4483,7 @@
4522 * event emitted with the job name set.4483 * event emitted with the job name set.
4523 */4484 */
4524 TEST_FEATURE ("with singleton in running state");4485 TEST_FEATURE ("with singleton in running state");
4525 class = job_class_new (NULL, "test", session);4486 class = job_class_new (NULL, "test", NULL);
45264487
4527 job = job_new (class, "");4488 job = job_new (class, "");
4528 job->goal = JOB_START;4489 job->goal = JOB_START;
@@ -4552,7 +4513,7 @@
4552 * instance name set.4513 * instance name set.
4553 */4514 */
4554 TEST_FEATURE ("with instance in running state");4515 TEST_FEATURE ("with instance in running state");
4555 class = job_class_new (NULL, "test", session);4516 class = job_class_new (NULL, "test", NULL);
4556 class->instance = "$FOO";4517 class->instance = "$FOO";
45574518
4558 job = job_new (class, "foo");4519 job = job_new (class, "foo");
@@ -4584,7 +4545,7 @@
4584 * result as "ok"4545 * result as "ok"
4585 */4546 */
4586 TEST_FEATURE ("with non-failed singleton in stopping state");4547 TEST_FEATURE ("with non-failed singleton in stopping state");
4587 class = job_class_new (NULL, "test", session);4548 class = job_class_new (NULL, "test", NULL);
45884549
4589 job = job_new (class, "");4550 job = job_new (class, "");
4590 job->goal = JOB_STOP;4551 job->goal = JOB_STOP;
@@ -4624,7 +4585,7 @@
4624 * also has the instance name set before the result information.4585 * also has the instance name set before the result information.
4625 */4586 */
4626 TEST_FEATURE ("with non-failed instance in stopping state");4587 TEST_FEATURE ("with non-failed instance in stopping state");
4627 class = job_class_new (NULL, "test", session);4588 class = job_class_new (NULL, "test", NULL);
4628 class->instance = "$FOO";4589 class->instance = "$FOO";
46294590
4630 job = job_new (class, "foo");4591 job = job_new (class, "foo");
@@ -4667,7 +4628,7 @@
4667 * exit status members set.4628 * exit status members set.
4668 */4629 */
4669 TEST_FEATURE ("with failed singleton in stopping state");4630 TEST_FEATURE ("with failed singleton in stopping state");
4670 class = job_class_new (NULL, "test", session);4631 class = job_class_new (NULL, "test", NULL);
46714632
4672 job = job_new (class, "");4633 job = job_new (class, "");
4673 job->goal = JOB_STOP;4634 job->goal = JOB_STOP;
@@ -4713,7 +4674,7 @@
4713 * set before the result information.4674 * set before the result information.
4714 */4675 */
4715 TEST_FEATURE ("with failed instance in stopping state");4676 TEST_FEATURE ("with failed instance in stopping state");
4716 class = job_class_new (NULL, "test", session);4677 class = job_class_new (NULL, "test", NULL);
4717 class->instance = "$FOO";4678 class->instance = "$FOO";
47184679
4719 job = job_new (class, "foo");4680 job = job_new (class, "foo");
@@ -4761,7 +4722,7 @@
4761 * members set.4722 * members set.
4762 */4723 */
4763 TEST_FEATURE ("with killed singleton in stopping state");4724 TEST_FEATURE ("with killed singleton in stopping state");
4764 class = job_class_new (NULL, "test", session);4725 class = job_class_new (NULL, "test", NULL);
47654726
4766 job = job_new (class, "");4727 job = job_new (class, "");
4767 job->goal = JOB_STOP;4728 job->goal = JOB_STOP;
@@ -4807,7 +4768,7 @@
4807 * result information.4768 * result information.
4808 */4769 */
4809 TEST_FEATURE ("with killed instance in stopping state");4770 TEST_FEATURE ("with killed instance in stopping state");
4810 class = job_class_new (NULL, "test", session);4771 class = job_class_new (NULL, "test", NULL);
4811 class->instance = "$FOO";4772 class->instance = "$FOO";
48124773
4813 job = job_new (class, "foo");4774 job = job_new (class, "foo");
@@ -4855,7 +4816,7 @@
4855 * signal members set.4816 * signal members set.
4856 */4817 */
4857 TEST_FEATURE ("with unknown killed singleton in stopping state");4818 TEST_FEATURE ("with unknown killed singleton in stopping state");
4858 class = job_class_new (NULL, "test", session);4819 class = job_class_new (NULL, "test", NULL);
48594820
4860 job = job_new (class, "");4821 job = job_new (class, "");
4861 job->goal = JOB_STOP;4822 job->goal = JOB_STOP;
@@ -4901,7 +4862,7 @@
4901 * the result information.4862 * the result information.
4902 */4863 */
4903 TEST_FEATURE ("with unknown killed instance in stopping state");4864 TEST_FEATURE ("with unknown killed instance in stopping state");
4904 class = job_class_new (NULL, "test", session);4865 class = job_class_new (NULL, "test", NULL);
4905 class->instance = "$FOO";4866 class->instance = "$FOO";
49064867
4907 job = job_new (class, "foo");4868 job = job_new (class, "foo");
@@ -4948,7 +4909,7 @@
4948 * the job name set, the result as failed, and just the process set.4909 * the job name set, the result as failed, and just the process set.
4949 */4910 */
4950 TEST_FEATURE ("with unstarted singleton in stopping state");4911 TEST_FEATURE ("with unstarted singleton in stopping state");
4951 class = job_class_new (NULL, "test", session);4912 class = job_class_new (NULL, "test", NULL);
49524913
4953 job = job_new (class, "");4914 job = job_new (class, "");
4954 job->goal = JOB_STOP;4915 job->goal = JOB_STOP;
@@ -4993,7 +4954,7 @@
4993 * the result information.4954 * the result information.
4994 */4955 */
4995 TEST_FEATURE ("with unstarted instance in stopping state");4956 TEST_FEATURE ("with unstarted instance in stopping state");
4996 class = job_class_new (NULL, "test", session);4957 class = job_class_new (NULL, "test", NULL);
4997 class->instance = "$FOO";4958 class->instance = "$FOO";
49984959
4999 job = job_new (class, "foo");4960 job = job_new (class, "foo");
@@ -5039,7 +5000,7 @@
5039 * the result as failed and the process set to respawn.5000 * the result as failed and the process set to respawn.
5040 */5001 */
5041 TEST_FEATURE ("with failed respawn singleton in stopping state");5002 TEST_FEATURE ("with failed respawn singleton in stopping state");
5042 class = job_class_new (NULL, "test", session);5003 class = job_class_new (NULL, "test", NULL);
50435004
5044 job = job_new (class, "");5005 job = job_new (class, "");
5045 job->goal = JOB_STOP;5006 job->goal = JOB_STOP;
@@ -5084,7 +5045,7 @@
5084 * information.5045 * information.
5085 */5046 */
5086 TEST_FEATURE ("with failed respawn instance in stopping state");5047 TEST_FEATURE ("with failed respawn instance in stopping state");
5087 class = job_class_new (NULL, "test", session);5048 class = job_class_new (NULL, "test", NULL);
5088 class->instance = "$FOO";5049 class->instance = "$FOO";
50895050
5090 job = job_new (class, "foo");5051 job = job_new (class, "foo");
@@ -5130,7 +5091,7 @@
5130 * result as "ok"5091 * result as "ok"
5131 */5092 */
5132 TEST_FEATURE ("with non-failed singleton in stopped state");5093 TEST_FEATURE ("with non-failed singleton in stopped state");
5133 class = job_class_new (NULL, "test", session);5094 class = job_class_new (NULL, "test", NULL);
51345095
5135 job = job_new (class, "");5096 job = job_new (class, "");
5136 job->goal = JOB_STOP;5097 job->goal = JOB_STOP;
@@ -5161,7 +5122,7 @@
5161 * also has the instance name set before the result information.5122 * also has the instance name set before the result information.
5162 */5123 */
5163 TEST_FEATURE ("with non-failed instance in waiting state");5124 TEST_FEATURE ("with non-failed instance in waiting state");
5164 class = job_class_new (NULL, "test", session);5125 class = job_class_new (NULL, "test", NULL);
5165 class->instance = "$FOO";5126 class->instance = "$FOO";
51665127
5167 job = job_new (class, "foo");5128 job = job_new (class, "foo");
@@ -5195,7 +5156,7 @@
5195 * exit status members set.5156 * exit status members set.
5196 */5157 */
5197 TEST_FEATURE ("with failed singleton in waiting state");5158 TEST_FEATURE ("with failed singleton in waiting state");
5198 class = job_class_new (NULL, "test", session);5159 class = job_class_new (NULL, "test", NULL);
51995160
5200 job = job_new (class, "");5161 job = job_new (class, "");
5201 job->goal = JOB_STOP;5162 job->goal = JOB_STOP;
@@ -5232,7 +5193,7 @@
5232 * set before the result information.5193 * set before the result information.
5233 */5194 */
5234 TEST_FEATURE ("with failed instance in waiting state");5195 TEST_FEATURE ("with failed instance in waiting state");
5235 class = job_class_new (NULL, "test", session);5196 class = job_class_new (NULL, "test", NULL);
5236 class->instance = "$FOO";5197 class->instance = "$FOO";
52375198
5238 job = job_new (class, "foo");5199 job = job_new (class, "foo");
@@ -5271,7 +5232,7 @@
5271 * members set.5232 * members set.
5272 */5233 */
5273 TEST_FEATURE ("with killed singleton in waiting state");5234 TEST_FEATURE ("with killed singleton in waiting state");
5274 class = job_class_new (NULL, "test", session);5235 class = job_class_new (NULL, "test", NULL);
52755236
5276 job = job_new (class, "");5237 job = job_new (class, "");
5277 job->goal = JOB_STOP;5238 job->goal = JOB_STOP;
@@ -5308,7 +5269,7 @@
5308 * result information.5269 * result information.
5309 */5270 */
5310 TEST_FEATURE ("with killed instance in waiting state");5271 TEST_FEATURE ("with killed instance in waiting state");
5311 class = job_class_new (NULL, "test", session);5272 class = job_class_new (NULL, "test", NULL);
5312 class->instance = "$FOO";5273 class->instance = "$FOO";
53135274
5314 job = job_new (class, "foo");5275 job = job_new (class, "foo");
@@ -5347,7 +5308,7 @@
5347 * signal members set.5308 * signal members set.
5348 */5309 */
5349 TEST_FEATURE ("with unknown killed singleton in waiting state");5310 TEST_FEATURE ("with unknown killed singleton in waiting state");
5350 class = job_class_new (NULL, "test", session);5311 class = job_class_new (NULL, "test", NULL);
53515312
5352 job = job_new (class, "");5313 job = job_new (class, "");
5353 job->goal = JOB_STOP;5314 job->goal = JOB_STOP;
@@ -5384,7 +5345,7 @@
5384 * the result information.5345 * the result information.
5385 */5346 */
5386 TEST_FEATURE ("with unknown killed instance in waiting state");5347 TEST_FEATURE ("with unknown killed instance in waiting state");
5387 class = job_class_new (NULL, "test", session);5348 class = job_class_new (NULL, "test", NULL);
5388 class->instance = "$FOO";5349 class->instance = "$FOO";
53895350
5390 job = job_new (class, "foo");5351 job = job_new (class, "foo");
@@ -5422,7 +5383,7 @@
5422 * the job name set, the result as failed, and just the process set.5383 * the job name set, the result as failed, and just the process set.
5423 */5384 */
5424 TEST_FEATURE ("with unstarted singleton in waiting state");5385 TEST_FEATURE ("with unstarted singleton in waiting state");
5425 class = job_class_new (NULL, "test", session);5386 class = job_class_new (NULL, "test", NULL);
54265387
5427 job = job_new (class, "");5388 job = job_new (class, "");
5428 job->goal = JOB_STOP;5389 job->goal = JOB_STOP;
@@ -5458,7 +5419,7 @@
5458 * the result information.5419 * the result information.
5459 */5420 */
5460 TEST_FEATURE ("with unstarted instance in waiting state");5421 TEST_FEATURE ("with unstarted instance in waiting state");
5461 class = job_class_new (NULL, "test", session);5422 class = job_class_new (NULL, "test", NULL);
5462 class->instance = "$FOO";5423 class->instance = "$FOO";
54635424
5464 job = job_new (class, "foo");5425 job = job_new (class, "foo");
@@ -5495,7 +5456,7 @@
5495 * the result as failed and the process set to respawn.5456 * the result as failed and the process set to respawn.
5496 */5457 */
5497 TEST_FEATURE ("with failed respawn singleton in waiting state");5458 TEST_FEATURE ("with failed respawn singleton in waiting state");
5498 class = job_class_new (NULL, "test", session);5459 class = job_class_new (NULL, "test", NULL);
54995460
5500 job = job_new (class, "");5461 job = job_new (class, "");
5501 job->goal = JOB_STOP;5462 job->goal = JOB_STOP;
@@ -5531,7 +5492,7 @@
5531 * information.5492 * information.
5532 */5493 */
5533 TEST_FEATURE ("with failed respawn instance in waiting state");5494 TEST_FEATURE ("with failed respawn instance in waiting state");
5534 class = job_class_new (NULL, "test", session);5495 class = job_class_new (NULL, "test", NULL);
5535 class->instance = "$FOO";5496 class->instance = "$FOO";
55365497
5537 job = job_new (class, "foo");5498 job = job_new (class, "foo");
@@ -5561,7 +5522,6 @@
5561 }5522 }
55625523
5563 nih_free (class);5524 nih_free (class);
5564 nih_free (session);
5565}5525}
55665526
55675527
@@ -5572,16 +5532,12 @@
5572 Job *job;5532 Job *job;
5573 const char *ret;5533 const char *ret;
5574 char *name;5534 char *name;
5575 Session *session;
5576
5577 session = session_new (NULL, NULL, getuid ());
5578 TEST_NE_P (session, NULL);
55795535
5580 TEST_FUNCTION ("job_name");5536 TEST_FUNCTION ("job_name");
55815537
5582 /* Check that the name of a non-instance job is returned. */5538 /* Check that the name of a non-instance job is returned. */
5583 TEST_FEATURE ("with non-instance job");5539 TEST_FEATURE ("with non-instance job");
5584 class = job_class_new (NULL, "test", session);5540 class = job_class_new (NULL, "test", NULL);
5585 job = job_new (class, "");5541 job = job_new (class, "");
55865542
5587 TEST_ALLOC_FAIL {5543 TEST_ALLOC_FAIL {
@@ -5595,7 +5551,7 @@
55955551
5596 /* Check that the name of an instance job is returned. */5552 /* Check that the name of an instance job is returned. */
5597 TEST_FEATURE ("with instance job");5553 TEST_FEATURE ("with instance job");
5598 class = job_class_new (NULL, "test", session);5554 class = job_class_new (NULL, "test", NULL);
5599 class->instance = "$FOO";5555 class->instance = "$FOO";
5600 job = job_new (class, "foo");5556 job = job_new (class, "foo");
56015557
@@ -5612,7 +5568,7 @@
5612 * value.5568 * value.
5613 */5569 */
5614 TEST_FEATURE ("with multiple calls");5570 TEST_FEATURE ("with multiple calls");
5615 class = job_class_new (NULL, "test", session);5571 class = job_class_new (NULL, "test", NULL);
5616 job = job_new (class, "");5572 job = job_new (class, "");
56175573
5618 ret = job_name (job);5574 ret = job_name (job);
@@ -5625,7 +5581,6 @@
5625 TEST_FREE (name);5581 TEST_FREE (name);
56265582
5627 nih_free (class);5583 nih_free (class);
5628 nih_free (session);
5629}5584}
56305585
56315586
@@ -5883,11 +5838,6 @@
5883 int ret;5838 int ret;
5884 NihError *error;5839 NihError *error;
5885 NihDBusError *dbus_error;5840 NihDBusError *dbus_error;
5886 Session *session;
5887
5888 session = session_new (NULL, NULL, getuid ());
5889 TEST_NE_P (session, NULL);
5890
58915841
5892 TEST_FUNCTION ("job_start");5842 TEST_FUNCTION ("job_start");
5893 nih_error_init ();5843 nih_error_init ();
@@ -5904,8 +5854,9 @@
5904 * the reply will be sent to the sender.5854 * the reply will be sent to the sender.
5905 */5855 */
5906 TEST_FEATURE ("with stopping job");5856 TEST_FEATURE ("with stopping job");
5907 class = job_class_new (NULL, "test", session);5857 class = job_class_new (NULL, "test", NULL);
5908 job = job_new (class, "");5858 job = job_new (class, "");
5859 TEST_NE_P (job, NULL);
59095860
5910 job->goal = JOB_STOP;5861 job->goal = JOB_STOP;
5911 job->state = JOB_STOPPING;5862 job->state = JOB_STOPPING;
@@ -5990,7 +5941,7 @@
5990 * and no blocking entry created.5941 * and no blocking entry created.
5991 */5942 */
5992 TEST_FEATURE ("with no wait");5943 TEST_FEATURE ("with no wait");
5993 class = job_class_new (NULL, "test", session);5944 class = job_class_new (NULL, "test", NULL);
5994 job = job_new (class, "");5945 job = job_new (class, "");
59955946
5996 job->goal = JOB_STOP;5947 job->goal = JOB_STOP;
@@ -6060,7 +6011,7 @@
6060 * a D-Bus error is raised immediately.6011 * a D-Bus error is raised immediately.
6061 */6012 */
6062 TEST_FEATURE ("with starting job");6013 TEST_FEATURE ("with starting job");
6063 class = job_class_new (NULL, "test", session);6014 class = job_class_new (NULL, "test", NULL);
6064 job = job_new (class, "");6015 job = job_new (class, "");
60656016
6066 job->goal = JOB_START;6017 job->goal = JOB_START;
@@ -6107,7 +6058,6 @@
6107 TEST_EQ (job->state, JOB_STARTING);6058 TEST_EQ (job->state, JOB_STARTING);
61086059
6109 nih_free (class);6060 nih_free (class);
6110 nih_free (session);
61116061
6112 TEST_DBUS_CLOSE (conn);6062 TEST_DBUS_CLOSE (conn);
6113 TEST_DBUS_CLOSE (client_conn);6063 TEST_DBUS_CLOSE (client_conn);
@@ -6132,10 +6082,6 @@
6132 int ret;6082 int ret;
6133 NihError *error;6083 NihError *error;
6134 NihDBusError *dbus_error;6084 NihDBusError *dbus_error;
6135 Session *session;
6136
6137 session = session_new (NULL, NULL, getuid ());
6138 TEST_NE_P (session, NULL);
61396085
6140 TEST_FUNCTION ("job_stop");6086 TEST_FUNCTION ("job_stop");
6141 nih_error_init ();6087 nih_error_init ();
@@ -6152,7 +6098,7 @@
6152 * the reply will be sent to the sender and the instance deleted.6098 * the reply will be sent to the sender and the instance deleted.
6153 */6099 */
6154 TEST_FEATURE ("with running job");6100 TEST_FEATURE ("with running job");
6155 class = job_class_new (NULL, "test", session);6101 class = job_class_new (NULL, "test", NULL);
6156 job = job_new (class, "");6102 job = job_new (class, "");
61576103
6158 job->goal = JOB_START;6104 job->goal = JOB_START;
@@ -6231,7 +6177,7 @@
6231 * no blocking entry created.6177 * no blocking entry created.
6232 */6178 */
6233 TEST_FEATURE ("with no wait");6179 TEST_FEATURE ("with no wait");
6234 class = job_class_new (NULL, "test", session);6180 class = job_class_new (NULL, "test", NULL);
6235 job = job_new (class, "");6181 job = job_new (class, "");
62366182
6237 job->goal = JOB_START;6183 job->goal = JOB_START;
@@ -6297,7 +6243,7 @@
6297 * a D-Bus error is raised immediately.6243 * a D-Bus error is raised immediately.
6298 */6244 */
6299 TEST_FEATURE ("with stopping job");6245 TEST_FEATURE ("with stopping job");
6300 class = job_class_new (NULL, "test", session);6246 class = job_class_new (NULL, "test", NULL);
6301 job = job_new (class, "");6247 job = job_new (class, "");
63026248
6303 job->goal = JOB_STOP;6249 job->goal = JOB_STOP;
@@ -6344,8 +6290,6 @@
6344 TEST_EQ (job->state, JOB_STOPPING);6290 TEST_EQ (job->state, JOB_STOPPING);
63456291
6346 nih_free (class);6292 nih_free (class);
6347 nih_free (session);
6348
63496293
6350 TEST_DBUS_CLOSE (conn);6294 TEST_DBUS_CLOSE (conn);
6351 TEST_DBUS_CLOSE (client_conn);6295 TEST_DBUS_CLOSE (client_conn);
@@ -6370,10 +6314,6 @@
6370 int ret;6314 int ret;
6371 NihError *error;6315 NihError *error;
6372 NihDBusError *dbus_error;6316 NihDBusError *dbus_error;
6373 Session *session;
6374
6375 session = session_new (NULL, NULL, getuid ());
6376 TEST_NE_P (session, NULL);
63776317
6378 TEST_FUNCTION ("job_restart");6318 TEST_FUNCTION ("job_restart");
6379 nih_error_init ();6319 nih_error_init ();
@@ -6390,7 +6330,7 @@
6390 * it back through to running, the reply will be sent to the sender.6330 * it back through to running, the reply will be sent to the sender.
6391 */6331 */
6392 TEST_FEATURE ("with running job");6332 TEST_FEATURE ("with running job");
6393 class = job_class_new (NULL, "test", session);6333 class = job_class_new (NULL, "test", NULL);
6394 job = job_new (class, "");6334 job = job_new (class, "");
63956335
6396 job->goal = JOB_START;6336 job->goal = JOB_START;
@@ -6479,7 +6419,7 @@
6479 * and no blocking entry created.6419 * and no blocking entry created.
6480 */6420 */
6481 TEST_FEATURE ("with no wait");6421 TEST_FEATURE ("with no wait");
6482 class = job_class_new (NULL, "test", session);6422 class = job_class_new (NULL, "test", NULL);
6483 job = job_new (class, "");6423 job = job_new (class, "");
64846424
6485 job->goal = JOB_START;6425 job->goal = JOB_START;
@@ -6552,7 +6492,7 @@
6552 * a D-Bus error is raised immediately.6492 * a D-Bus error is raised immediately.
6553 */6493 */
6554 TEST_FEATURE ("with stopping job");6494 TEST_FEATURE ("with stopping job");
6555 class = job_class_new (NULL, "test", session);6495 class = job_class_new (NULL, "test", NULL);
6556 job = job_new (class, "");6496 job = job_new (class, "");
65576497
6558 job->goal = JOB_STOP;6498 job->goal = JOB_STOP;
@@ -6599,7 +6539,6 @@
6599 TEST_EQ (job->state, JOB_STOPPING);6539 TEST_EQ (job->state, JOB_STOPPING);
66006540
6601 nih_free (class);6541 nih_free (class);
6602 nih_free (session);
66036542
6604 TEST_DBUS_CLOSE (conn);6543 TEST_DBUS_CLOSE (conn);
6605 TEST_DBUS_CLOSE (client_conn);6544 TEST_DBUS_CLOSE (client_conn);
@@ -6620,10 +6559,6 @@
6620 NihError *error;6559 NihError *error;
6621 char *name;6560 char *name;
6622 int ret;6561 int ret;
6623 Session *session;
6624
6625 session = session_new (NULL, NULL, getuid ());
6626 TEST_NE_P (session, NULL);
66276562
6628 TEST_FUNCTION ("job_get_name");6563 TEST_FUNCTION ("job_get_name");
6629 nih_error_init ();6564 nih_error_init ();
@@ -6635,7 +6570,7 @@
6635 TEST_FEATURE ("with instance name");6570 TEST_FEATURE ("with instance name");
6636 TEST_ALLOC_FAIL {6571 TEST_ALLOC_FAIL {
6637 TEST_ALLOC_SAFE {6572 TEST_ALLOC_SAFE {
6638 class = job_class_new (NULL, "test", session);6573 class = job_class_new (NULL, "test", NULL);
6639 job = job_new (class, "instance name");6574 job = job_new (class, "instance name");
66406575
6641 message = nih_new (NULL, NihDBusMessage);6576 message = nih_new (NULL, NihDBusMessage);
@@ -6675,7 +6610,7 @@
6675 TEST_FEATURE ("with no instance name");6610 TEST_FEATURE ("with no instance name");
6676 TEST_ALLOC_FAIL {6611 TEST_ALLOC_FAIL {
6677 TEST_ALLOC_SAFE {6612 TEST_ALLOC_SAFE {
6678 class = job_class_new (NULL, "test", session);6613 class = job_class_new (NULL, "test", NULL);
6679 job = job_new (class, "");6614 job = job_new (class, "");
66806615
6681 message = nih_new (NULL, NihDBusMessage);6616 message = nih_new (NULL, NihDBusMessage);
@@ -6707,7 +6642,6 @@
6707 nih_free (message);6642 nih_free (message);
6708 nih_free (class);6643 nih_free (class);
6709 }6644 }
6710 nih_free (session);
6711}6645}
67126646
6713void6647void
@@ -6719,10 +6653,6 @@
6719 NihError *error;6653 NihError *error;
6720 char *goal;6654 char *goal;
6721 int ret;6655 int ret;
6722 Session *session;
6723
6724 session = session_new (NULL, NULL, getuid ());
6725 TEST_NE_P (session, NULL);
67266656
6727 /* Check that the goal of the instance is returned a newly allocated6657 /* Check that the goal of the instance is returned a newly allocated
6728 * string, as a child of the message.6658 * string, as a child of the message.
@@ -6733,7 +6663,7 @@
67336663
6734 TEST_ALLOC_FAIL {6664 TEST_ALLOC_FAIL {
6735 TEST_ALLOC_SAFE {6665 TEST_ALLOC_SAFE {
6736 class = job_class_new (NULL, "test", session);6666 class = job_class_new (NULL, "test", NULL);
6737 job = job_new (class, "");6667 job = job_new (class, "");
6738 job->goal = JOB_START;6668 job->goal = JOB_START;
67396669
@@ -6766,7 +6696,6 @@
6766 nih_free (message);6696 nih_free (message);
6767 nih_free (class);6697 nih_free (class);
6768 }6698 }
6769 nih_free (session);
6770}6699}
67716700
6772void6701void
@@ -6778,10 +6707,6 @@
6778 NihError *error;6707 NihError *error;
6779 char *state;6708 char *state;
6780 int ret;6709 int ret;
6781 Session *session;
6782
6783 session = session_new (NULL, NULL, getuid ());
6784 TEST_NE_P (session, NULL);
67856710
6786 /* Check that the state of the instance is returned a newly allocated6711 /* Check that the state of the instance is returned a newly allocated
6787 * string, as a child of the message.6712 * string, as a child of the message.
@@ -6792,7 +6717,7 @@
67926717
6793 TEST_ALLOC_FAIL {6718 TEST_ALLOC_FAIL {
6794 TEST_ALLOC_SAFE {6719 TEST_ALLOC_SAFE {
6795 class = job_class_new (NULL, "test", session);6720 class = job_class_new (NULL, "test", NULL);
6796 job = job_new (class, "");6721 job = job_new (class, "");
6797 job->goal = JOB_START;6722 job->goal = JOB_START;
6798 job->state = JOB_RUNNING;6723 job->state = JOB_RUNNING;
@@ -6826,7 +6751,6 @@
6826 nih_free (message);6751 nih_free (message);
6827 nih_free (class);6752 nih_free (class);
6828 }6753 }
6829 nih_free (session);
6830}6754}
68316755
68326756
@@ -6839,10 +6763,6 @@
6839 JobProcessesElement **processes;6763 JobProcessesElement **processes;
6840 NihError * error;6764 NihError * error;
6841 int ret;6765 int ret;
6842 Session *session;
6843
6844 session = session_new (NULL, NULL, getuid ());
6845 TEST_NE_P (session, NULL);
68466766
6847 TEST_FUNCTION ("job_get_processes");6767 TEST_FUNCTION ("job_get_processes");
6848 nih_error_init ();6768 nih_error_init ();
@@ -6855,7 +6775,7 @@
6855 TEST_FEATURE ("with no processes");6775 TEST_FEATURE ("with no processes");
6856 TEST_ALLOC_FAIL {6776 TEST_ALLOC_FAIL {
6857 TEST_ALLOC_SAFE {6777 TEST_ALLOC_SAFE {
6858 class = job_class_new (NULL, "test", session);6778 class = job_class_new (NULL, "test", NULL);
6859 job = job_new (class, "");6779 job = job_new (class, "");
6860 job->goal = JOB_START;6780 job->goal = JOB_START;
6861 job->state = JOB_STARTING;6781 job->state = JOB_STARTING;
@@ -6899,7 +6819,7 @@
6899 TEST_FEATURE ("with pre-start process");6819 TEST_FEATURE ("with pre-start process");
6900 TEST_ALLOC_FAIL {6820 TEST_ALLOC_FAIL {
6901 TEST_ALLOC_SAFE {6821 TEST_ALLOC_SAFE {
6902 class = job_class_new (NULL, "test", session);6822 class = job_class_new (NULL, "test", NULL);
6903 class->process[PROCESS_PRE_START] = process_new (class);6823 class->process[PROCESS_PRE_START] = process_new (class);
6904 class->process[PROCESS_PRE_START]->command = "echo";6824 class->process[PROCESS_PRE_START]->command = "echo";
69056825
@@ -6954,7 +6874,7 @@
6954 TEST_FEATURE ("with post-start process and no main process");6874 TEST_FEATURE ("with post-start process and no main process");
6955 TEST_ALLOC_FAIL {6875 TEST_ALLOC_FAIL {
6956 TEST_ALLOC_SAFE {6876 TEST_ALLOC_SAFE {
6957 class = job_class_new (NULL, "test", session);6877 class = job_class_new (NULL, "test", NULL);
6958 class->process[PROCESS_POST_START] = process_new (class);6878 class->process[PROCESS_POST_START] = process_new (class);
6959 class->process[PROCESS_POST_START]->command = "echo";6879 class->process[PROCESS_POST_START]->command = "echo";
69606880
@@ -7008,7 +6928,7 @@
7008 TEST_FEATURE ("with main process");6928 TEST_FEATURE ("with main process");
7009 TEST_ALLOC_FAIL {6929 TEST_ALLOC_FAIL {
7010 TEST_ALLOC_SAFE {6930 TEST_ALLOC_SAFE {
7011 class = job_class_new (NULL, "test", session);6931 class = job_class_new (NULL, "test", NULL);
7012 class->process[PROCESS_MAIN] = process_new (class);6932 class->process[PROCESS_MAIN] = process_new (class);
7013 class->process[PROCESS_MAIN]->command = "echo";6933 class->process[PROCESS_MAIN]->command = "echo";
70146934
@@ -7063,7 +6983,7 @@
7063 TEST_FEATURE ("with main process and post-start process");6983 TEST_FEATURE ("with main process and post-start process");
7064 TEST_ALLOC_FAIL {6984 TEST_ALLOC_FAIL {
7065 TEST_ALLOC_SAFE {6985 TEST_ALLOC_SAFE {
7066 class = job_class_new (NULL, "test", session);6986 class = job_class_new (NULL, "test", NULL);
7067 class->process[PROCESS_POST_START] = process_new (class);6987 class->process[PROCESS_POST_START] = process_new (class);
7068 class->process[PROCESS_POST_START]->command = "echo";6988 class->process[PROCESS_POST_START]->command = "echo";
7069 class->process[PROCESS_MAIN] = process_new (class);6989 class->process[PROCESS_MAIN] = process_new (class);
@@ -7127,7 +7047,7 @@
7127 TEST_FEATURE ("with main process and pre-stop process");7047 TEST_FEATURE ("with main process and pre-stop process");
7128 TEST_ALLOC_FAIL {7048 TEST_ALLOC_FAIL {
7129 TEST_ALLOC_SAFE {7049 TEST_ALLOC_SAFE {
7130 class = job_class_new (NULL, "test", session);7050 class = job_class_new (NULL, "test", NULL);
7131 class->process[PROCESS_MAIN] = process_new (class);7051 class->process[PROCESS_MAIN] = process_new (class);
7132 class->process[PROCESS_MAIN]->command = "echo";7052 class->process[PROCESS_MAIN]->command = "echo";
7133 class->process[PROCESS_PRE_STOP] = process_new (class);7053 class->process[PROCESS_PRE_STOP] = process_new (class);
@@ -7191,7 +7111,7 @@
7191 TEST_FEATURE ("with pre-stop process and no main process");7111 TEST_FEATURE ("with pre-stop process and no main process");
7192 TEST_ALLOC_FAIL {7112 TEST_ALLOC_FAIL {
7193 TEST_ALLOC_SAFE {7113 TEST_ALLOC_SAFE {
7194 class = job_class_new (NULL, "test", session);7114 class = job_class_new (NULL, "test", NULL);
7195 class->process[PROCESS_PRE_STOP] = process_new (class);7115 class->process[PROCESS_PRE_STOP] = process_new (class);
7196 class->process[PROCESS_PRE_STOP]->command = "echo";7116 class->process[PROCESS_PRE_STOP]->command = "echo";
71977117
@@ -7245,7 +7165,7 @@
7245 TEST_FEATURE ("with post-stop process");7165 TEST_FEATURE ("with post-stop process");
7246 TEST_ALLOC_FAIL {7166 TEST_ALLOC_FAIL {
7247 TEST_ALLOC_SAFE {7167 TEST_ALLOC_SAFE {
7248 class = job_class_new (NULL, "test", session);7168 class = job_class_new (NULL, "test", NULL);
7249 class->process[PROCESS_POST_STOP] = process_new (class);7169 class->process[PROCESS_POST_STOP] = process_new (class);
7250 class->process[PROCESS_POST_STOP]->command = "echo";7170 class->process[PROCESS_POST_STOP]->command = "echo";
72517171
@@ -7291,7 +7211,6 @@
7291 nih_free (message);7211 nih_free (message);
7292 nih_free (class);7212 nih_free (class);
7293 }7213 }
7294 nih_free (session);
7295}7214}
72967215
72977216
@@ -7299,6 +7218,9 @@
7299main (int argc,7218main (int argc,
7300 char *argv[])7219 char *argv[])
7301{7220{
7221 /* run tests in legacy (pre-session support) mode */
7222 setenv ("UPSTART_NO_SESSIONS", "1", 1);
7223
7302 test_new ();7224 test_new ();
7303 test_register ();7225 test_register ();
7304 test_change_goal ();7226 test_change_goal ();
73057227
=== modified file 'init/tests/test_job_class.c'
--- init/tests/test_job_class.c 2011-02-23 13:50:30 +0000
+++ init/tests/test_job_class.c 2011-04-19 09:27:29 +0000
@@ -160,10 +160,6 @@
160 Job *job;160 Job *job;
161 char *path;161 char *path;
162 int ret;162 int ret;
163 Session *session;
164
165 session = session_new (NULL, NULL, getuid ());
166 TEST_NE_P (session, NULL);
167163
168 TEST_FUNCTION ("job_class_consider");164 TEST_FUNCTION ("job_class_consider");
169 dbus_error_init (&dbus_error);165 dbus_error_init (&dbus_error);
@@ -181,15 +177,15 @@
181 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);177 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);
182178
183 file1 = conf_file_new (source2, "/tmp/bar/frodo");179 file1 = conf_file_new (source2, "/tmp/bar/frodo");
184 class1 = file1->job = job_class_new (NULL, "frodo", session);180 class1 = file1->job = job_class_new (NULL, "frodo", NULL);
185181
186 file2 = conf_file_new (source2, "/tmp/bar/bilbo");182 file2 = conf_file_new (source2, "/tmp/bar/bilbo");
187 class2 = file2->job = job_class_new (NULL, "bilbo", session);183 class2 = file2->job = job_class_new (NULL, "bilbo", NULL);
188184
189 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);185 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);
190186
191 file3 = conf_file_new (source3, "/tmp/baz/frodo");187 file3 = conf_file_new (source3, "/tmp/baz/frodo");
192 class3 = file3->job = job_class_new (NULL, "frodo", session);188 class3 = file3->job = job_class_new (NULL, "frodo", NULL);
193189
194190
195 control_init ();191 control_init ();
@@ -382,7 +378,7 @@
382 * becomes the hash table member.378 * becomes the hash table member.
383 */379 */
384 TEST_FEATURE ("with replacable registered class and not best class");380 TEST_FEATURE ("with replacable registered class and not best class");
385 class4 = job_class_new (NULL, "frodo", session);381 class4 = job_class_new (NULL, "frodo", NULL);
386 nih_hash_add (job_classes, &class4->entry);382 nih_hash_add (job_classes, &class4->entry);
387 job_class_register (class4, conn, FALSE);383 job_class_register (class4, conn, FALSE);
388384
@@ -440,7 +436,6 @@
440436
441437
442 nih_free (entry);438 nih_free (entry);
443 nih_free (session);
444439
445 TEST_DBUS_CLOSE (conn);440 TEST_DBUS_CLOSE (conn);
446 TEST_DBUS_CLOSE (client_conn);441 TEST_DBUS_CLOSE (client_conn);
@@ -464,10 +459,6 @@
464 Job *job;459 Job *job;
465 char *path;460 char *path;
466 int ret;461 int ret;
467 Session *session;
468
469 session = session_new (NULL, NULL, getuid ());
470 TEST_NE_P (session, NULL);
471462
472 TEST_FUNCTION ("job_class_reconsider");463 TEST_FUNCTION ("job_class_reconsider");
473 dbus_error_init (&dbus_error);464 dbus_error_init (&dbus_error);
@@ -485,15 +476,15 @@
485 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);476 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);
486477
487 file1 = conf_file_new (source2, "/tmp/bar/frodo");478 file1 = conf_file_new (source2, "/tmp/bar/frodo");
488 class1 = file1->job = job_class_new (NULL, "frodo", session);479 class1 = file1->job = job_class_new (NULL, "frodo", NULL);
489480
490 file2 = conf_file_new (source2, "/tmp/bar/bilbo");481 file2 = conf_file_new (source2, "/tmp/bar/bilbo");
491 class2 = file2->job = job_class_new (NULL, "bilbo", session);482 class2 = file2->job = job_class_new (NULL, "bilbo", NULL);
492483
493 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);484 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);
494485
495 file3 = conf_file_new (source3, "/tmp/baz/frodo");486 file3 = conf_file_new (source3, "/tmp/baz/frodo");
496 class3 = file3->job = job_class_new (NULL, "frodo", session);487 class3 = file3->job = job_class_new (NULL, "frodo", NULL);
497488
498489
499 control_init ();490 control_init ();
@@ -726,7 +717,7 @@
726 nih_free (source2);717 nih_free (source2);
727 nih_free (source1);718 nih_free (source1);
728719
729 class4 = job_class_new (NULL, "frodo", session);720 class4 = job_class_new (NULL, "frodo", NULL);
730 nih_hash_add (job_classes, &class4->entry);721 nih_hash_add (job_classes, &class4->entry);
731 job_class_register (class4, conn, FALSE);722 job_class_register (class4, conn, FALSE);
732723
@@ -759,7 +750,6 @@
759750
760751
761 nih_free (entry);752 nih_free (entry);
762 nih_free (session);
763753
764 TEST_DBUS_CLOSE (conn);754 TEST_DBUS_CLOSE (conn);
765 TEST_DBUS_CLOSE (client_conn);755 TEST_DBUS_CLOSE (client_conn);
@@ -779,10 +769,6 @@
779 JobClass *class;769 JobClass *class;
780 NihDBusObject *object;770 NihDBusObject *object;
781 char *path;771 char *path;
782 Session *session;
783
784 session = session_new (NULL, NULL, getuid ());
785 TEST_NE_P (session, NULL);
786772
787 TEST_FUNCTION ("job_class_register");773 TEST_FUNCTION ("job_class_register");
788 dbus_error_init (&dbus_error);774 dbus_error_init (&dbus_error);
@@ -800,7 +786,7 @@
800 * announce it.786 * announce it.
801 */787 */
802 TEST_FEATURE ("with signal emission");788 TEST_FEATURE ("with signal emission");
803 class = job_class_new (NULL, "test", session);789 class = job_class_new (NULL, "test", NULL);
804790
805 assert (dbus_connection_get_object_path_data (conn, class->path,791 assert (dbus_connection_get_object_path_data (conn, class->path,
806 (void **)&object));792 (void **)&object));
@@ -837,7 +823,7 @@
837 * by emitting a signal immediately afterwards.823 * by emitting a signal immediately afterwards.
838 */824 */
839 TEST_FEATURE ("without signal emission");825 TEST_FEATURE ("without signal emission");
840 class = job_class_new (NULL, "test", session);826 class = job_class_new (NULL, "test", NULL);
841827
842 assert (dbus_connection_get_object_path_data (conn, class->path,828 assert (dbus_connection_get_object_path_data (conn, class->path,
843 (void **)&object));829 (void **)&object));
@@ -870,7 +856,6 @@
870 dbus_message_unref (message);856 dbus_message_unref (message);
871857
872 nih_free (class);858 nih_free (class);
873 nih_free (session);
874859
875 TEST_DBUS_CLOSE (conn);860 TEST_DBUS_CLOSE (conn);
876 TEST_DBUS_CLOSE (client_conn);861 TEST_DBUS_CLOSE (client_conn);
@@ -889,10 +874,6 @@
889 JobClass *class;874 JobClass *class;
890 NihDBusObject *object;875 NihDBusObject *object;
891 char *path;876 char *path;
892 Session *session;
893
894 session = session_new (NULL, NULL, getuid ());
895 TEST_NE_P (session, NULL);
896877
897 /* Check that we can unregister an object for a job class from878 /* Check that we can unregister an object for a job class from
898 * the bus and that the JobRemoved signal is emitted as a result.879 * the bus and that the JobRemoved signal is emitted as a result.
@@ -910,7 +891,7 @@
910 assert (! dbus_error_is_set (&dbus_error));891 assert (! dbus_error_is_set (&dbus_error));
911892
912893
913 class = job_class_new (NULL, "test", session);894 class = job_class_new (NULL, "test", NULL);
914895
915 assert (dbus_connection_get_object_path_data (conn, class->path,896 assert (dbus_connection_get_object_path_data (conn, class->path,
916 (void **)&object));897 (void **)&object));
@@ -945,7 +926,6 @@
945 dbus_message_unref (message);926 dbus_message_unref (message);
946927
947 nih_free (class);928 nih_free (class);
948 nih_free (session);
949929
950 TEST_DBUS_CLOSE (conn);930 TEST_DBUS_CLOSE (conn);
951 TEST_DBUS_CLOSE (client_conn);931 TEST_DBUS_CLOSE (client_conn);
@@ -961,10 +941,6 @@
961 JobClass *class;941 JobClass *class;
962 char **env;942 char **env;
963 size_t len;943 size_t len;
964 Session *session;
965
966 session = session_new (NULL, NULL, getuid ());
967 TEST_NE_P (session, NULL);
968944
969 TEST_FUNCTION ("job_class_environment");945 TEST_FUNCTION ("job_class_environment");
970946
@@ -972,7 +948,7 @@
972 * just have the built-ins in the returned environment.948 * just have the built-ins in the returned environment.
973 */949 */
974 TEST_FEATURE ("with no configured environment");950 TEST_FEATURE ("with no configured environment");
975 class = job_class_new (NULL, "test", session);951 class = job_class_new (NULL, "test", NULL);
976952
977 TEST_ALLOC_FAIL {953 TEST_ALLOC_FAIL {
978 env = job_class_environment (NULL, class, &len);954 env = job_class_environment (NULL, class, &len);
@@ -1002,7 +978,7 @@
1002 * will have those appended to the environment as well as the builtins.978 * will have those appended to the environment as well as the builtins.
1003 */979 */
1004 TEST_FEATURE ("with configured environment");980 TEST_FEATURE ("with configured environment");
1005 class = job_class_new (NULL, "test", session);981 class = job_class_new (NULL, "test", NULL);
1006982
1007 class->env = nih_str_array_new (class);983 class->env = nih_str_array_new (class);
1008 assert (nih_str_array_add (&(class->env), class, NULL, "FOO=BAR"));984 assert (nih_str_array_add (&(class->env), class, NULL, "FOO=BAR"));
@@ -1039,7 +1015,7 @@
1039 /* Check that configured environment override built-ins.1015 /* Check that configured environment override built-ins.
1040 */1016 */
1041 TEST_FEATURE ("with configuration overriding built-ins");1017 TEST_FEATURE ("with configuration overriding built-ins");
1042 class = job_class_new (NULL, "test", session);1018 class = job_class_new (NULL, "test", NULL);
10431019
1044 class->env = nih_str_array_new (class);1020 class->env = nih_str_array_new (class);
1045 assert (nih_str_array_add (&(class->env), class, NULL, "FOO=BAR"));1021 assert (nih_str_array_add (&(class->env), class, NULL, "FOO=BAR"));
@@ -1072,7 +1048,6 @@
1072 }1048 }
10731049
1074 nih_free (class);1050 nih_free (class);
1075 nih_free (session);
1076}1051}
10771052
10781053
@@ -1087,11 +1062,6 @@
1087 int ret;1062 int ret;
1088 NihError *error;1063 NihError *error;
1089 NihDBusError *dbus_error;1064 NihDBusError *dbus_error;
1090 Session *session;
1091
1092 session = session_new (NULL, NULL, getuid ());
1093 TEST_NE_P (session, NULL);
1094
10951065
1096 TEST_FUNCTION ("job_class_get_instance");1066 TEST_FUNCTION ("job_class_get_instance");
1097 nih_error_init ();1067 nih_error_init ();
@@ -1103,7 +1073,7 @@
1103 TEST_FEATURE ("with running job");1073 TEST_FEATURE ("with running job");
1104 TEST_ALLOC_FAIL {1074 TEST_ALLOC_FAIL {
1105 TEST_ALLOC_SAFE {1075 TEST_ALLOC_SAFE {
1106 class = job_class_new (NULL, "test", session);1076 class = job_class_new (NULL, "test", NULL);
1107 job = job_new (class, "");1077 job = job_new (class, "");
11081078
1109 message = nih_new (NULL, NihDBusMessage);1079 message = nih_new (NULL, NihDBusMessage);
@@ -1140,7 +1110,7 @@
1140 /* Check that if there's no such instance, a D-Bus error is raised.1110 /* Check that if there's no such instance, a D-Bus error is raised.
1141 */1111 */
1142 TEST_FEATURE ("with unknown job");1112 TEST_FEATURE ("with unknown job");
1143 class = job_class_new (NULL, "test", session);1113 class = job_class_new (NULL, "test", NULL);
11441114
1145 message = nih_new (NULL, NihDBusMessage);1115 message = nih_new (NULL, NihDBusMessage);
1146 message->connection = NULL;1116 message->connection = NULL;
@@ -1171,7 +1141,7 @@
1171 TEST_FEATURE ("with environment");1141 TEST_FEATURE ("with environment");
1172 TEST_ALLOC_FAIL {1142 TEST_ALLOC_FAIL {
1173 TEST_ALLOC_SAFE {1143 TEST_ALLOC_SAFE {
1174 class = job_class_new (NULL, "test", session);1144 class = job_class_new (NULL, "test", NULL);
1175 class->instance = "$FOO";1145 class->instance = "$FOO";
11761146
1177 job = job_new (class, "wibble");1147 job = job_new (class, "wibble");
@@ -1215,7 +1185,7 @@
1215 * is returned.1185 * is returned.
1216 */1186 */
1217 TEST_FEATURE ("with invalid environment");1187 TEST_FEATURE ("with invalid environment");
1218 class = job_class_new (NULL, "test", session);1188 class = job_class_new (NULL, "test", NULL);
1219 class->instance = "$FOO";1189 class->instance = "$FOO";
12201190
1221 job = job_new (class, "wibble");1191 job = job_new (class, "wibble");
@@ -1242,7 +1212,6 @@
12421212
1243 nih_free (message);1213 nih_free (message);
1244 nih_free (class);1214 nih_free (class);
1245 nih_free (session);
1246}1215}
12471216
1248void1217void
@@ -1255,15 +1224,11 @@
1255 NihError *error;1224 NihError *error;
1256 NihDBusError *dbus_error;1225 NihDBusError *dbus_error;
1257 int ret;1226 int ret;
1258 Session *session;
1259
1260 session = session_new (NULL, NULL, getuid ());
1261 TEST_NE_P (session, NULL);
12621227
1263 TEST_FUNCTION ("job_class_get_instance_by_name");1228 TEST_FUNCTION ("job_class_get_instance_by_name");
1264 nih_error_init ();1229 nih_error_init ();
12651230
1266 class = job_class_new (NULL, "test", session);1231 class = job_class_new (NULL, "test", NULL);
12671232
12681233
1269 /* Check that when given a known instance name, the path to that1234 /* Check that when given a known instance name, the path to that
@@ -1377,7 +1342,6 @@
13771342
13781343
1379 nih_free (class);1344 nih_free (class);
1380 nih_free (session);
1381}1345}
13821346
1383void1347void
@@ -1389,16 +1353,12 @@
1389 NihError *error;1353 NihError *error;
1390 char **paths;1354 char **paths;
1391 int ret;1355 int ret;
1392 Session *session;
1393
1394 session = session_new (NULL, NULL, getuid ());
1395 TEST_NE_P (session, NULL);
13961356
1397 TEST_FUNCTION ("job_class_get_all_instances");1357 TEST_FUNCTION ("job_class_get_all_instances");
1398 nih_error_init ();1358 nih_error_init ();
1399 job_class_init ();1359 job_class_init ();
14001360
1401 class = job_class_new (NULL, "test", session);1361 class = job_class_new (NULL, "test", NULL);
14021362
14031363
1404 /* Check that paths for each of the active instances are returned1364 /* Check that paths for each of the active instances are returned
@@ -1496,7 +1456,6 @@
1496 }1456 }
14971457
1498 nih_free (class);1458 nih_free (class);
1499 nih_free (session);
1500}1459}
15011460
15021461
@@ -1516,10 +1475,6 @@
1516 int ret;1475 int ret;
1517 NihError *error;1476 NihError *error;
1518 NihDBusError *dbus_error;1477 NihDBusError *dbus_error;
1519 Session *session;
1520
1521 session = session_new (NULL, NULL, getuid ());
1522 TEST_NE_P (session, NULL);
15231478
1524 TEST_FUNCTION ("job_class_start");1479 TEST_FUNCTION ("job_class_start");
1525 nih_error_init ();1480 nih_error_init ();
@@ -1536,7 +1491,7 @@
1536 * the reply will be sent to the sender.1491 * the reply will be sent to the sender.
1537 */1492 */
1538 TEST_FEATURE ("with new job");1493 TEST_FEATURE ("with new job");
1539 class = job_class_new (NULL, "test", session);1494 class = job_class_new (NULL, "test", NULL);
15401495
1541 method = dbus_message_new_method_call (1496 method = dbus_message_new_method_call (
1542 dbus_bus_get_unique_name (conn),1497 dbus_bus_get_unique_name (conn),
@@ -1627,7 +1582,7 @@
1627 * immediately and the job not blocked.1582 * immediately and the job not blocked.
1628 */1583 */
1629 TEST_FEATURE ("with no wait");1584 TEST_FEATURE ("with no wait");
1630 class = job_class_new (NULL, "test", session);1585 class = job_class_new (NULL, "test", NULL);
16311586
1632 method = dbus_message_new_method_call (1587 method = dbus_message_new_method_call (
1633 dbus_bus_get_unique_name (conn),1588 dbus_bus_get_unique_name (conn),
@@ -1707,7 +1662,7 @@
1707 * it through to running, the reply will be sent to the sender.1662 * it through to running, the reply will be sent to the sender.
1708 */1663 */
1709 TEST_FEATURE ("with stopping job");1664 TEST_FEATURE ("with stopping job");
1710 class = job_class_new (NULL, "test", session);1665 class = job_class_new (NULL, "test", NULL);
1711 job = job_new (class, "");1666 job = job_new (class, "");
17121667
1713 job->goal = JOB_STOP;1668 job->goal = JOB_STOP;
@@ -1808,7 +1763,7 @@
1808 * a D-Bus error is raised immediately.1763 * a D-Bus error is raised immediately.
1809 */1764 */
1810 TEST_FEATURE ("with starting job");1765 TEST_FEATURE ("with starting job");
1811 class = job_class_new (NULL, "test", session);1766 class = job_class_new (NULL, "test", NULL);
1812 job = job_new (class, "");1767 job = job_new (class, "");
18131768
1814 job->goal = JOB_START;1769 job->goal = JOB_START;
@@ -1864,7 +1819,7 @@
1864 * when it's starting.1819 * when it's starting.
1865 */1820 */
1866 TEST_FEATURE ("with environment");1821 TEST_FEATURE ("with environment");
1867 class = job_class_new (NULL, "test", session);1822 class = job_class_new (NULL, "test", NULL);
1868 class->instance = "$FOO";1823 class->instance = "$FOO";
18691824
1870 method = dbus_message_new_method_call (1825 method = dbus_message_new_method_call (
@@ -1965,7 +1920,7 @@
1965 * is returned.1920 * is returned.
1966 */1921 */
1967 TEST_FEATURE ("with invalid environment");1922 TEST_FEATURE ("with invalid environment");
1968 class = job_class_new (NULL, "test", session);1923 class = job_class_new (NULL, "test", NULL);
19691924
1970 method = dbus_message_new_method_call (1925 method = dbus_message_new_method_call (
1971 dbus_bus_get_unique_name (conn),1926 dbus_bus_get_unique_name (conn),
@@ -2010,8 +1965,6 @@
2010 TEST_HASH_EMPTY (class->instances);1965 TEST_HASH_EMPTY (class->instances);
20111966
2012 nih_free (class);1967 nih_free (class);
2013 nih_free (session);
2014
20151968
2016 TEST_DBUS_CLOSE (conn);1969 TEST_DBUS_CLOSE (conn);
2017 TEST_DBUS_CLOSE (client_conn);1970 TEST_DBUS_CLOSE (client_conn);
@@ -2037,11 +1990,6 @@
2037 int ret;1990 int ret;
2038 NihError *error;1991 NihError *error;
2039 NihDBusError *dbus_error;1992 NihDBusError *dbus_error;
2040 Session *session;
2041
2042 session = session_new (NULL, NULL, getuid ());
2043 TEST_NE_P (session, NULL);
2044
20451993
2046 TEST_FUNCTION ("job_class_stop");1994 TEST_FUNCTION ("job_class_stop");
2047 nih_error_init ();1995 nih_error_init ();
@@ -2058,7 +2006,7 @@
2058 * will be sent to the sender.2006 * will be sent to the sender.
2059 */2007 */
2060 TEST_FEATURE ("with running job");2008 TEST_FEATURE ("with running job");
2061 class = job_class_new (NULL, "test", session);2009 class = job_class_new (NULL, "test", NULL);
2062 job = job_new (class, "");2010 job = job_new (class, "");
20632011
2064 job->goal = JOB_START;2012 job->goal = JOB_START;
@@ -2141,7 +2089,7 @@
2141 * and no blocking entry created.2089 * and no blocking entry created.
2142 */2090 */
2143 TEST_FEATURE ("with no wait");2091 TEST_FEATURE ("with no wait");
2144 class = job_class_new (NULL, "test", session);2092 class = job_class_new (NULL, "test", NULL);
2145 job = job_new (class, "");2093 job = job_new (class, "");
21462094
2147 job->goal = JOB_START;2095 job->goal = JOB_START;
@@ -2211,7 +2159,7 @@
2211 * a D-Bus error is raised immediately.2159 * a D-Bus error is raised immediately.
2212 */2160 */
2213 TEST_FEATURE ("with stopping job");2161 TEST_FEATURE ("with stopping job");
2214 class = job_class_new (NULL, "test", session);2162 class = job_class_new (NULL, "test", NULL);
2215 job = job_new (class, "");2163 job = job_new (class, "");
22162164
2217 job->goal = JOB_STOP;2165 job->goal = JOB_STOP;
@@ -2266,7 +2214,7 @@
2266 * immediately.2214 * immediately.
2267 */2215 */
2268 TEST_FEATURE ("with unknown job");2216 TEST_FEATURE ("with unknown job");
2269 class = job_class_new (NULL, "test", session);2217 class = job_class_new (NULL, "test", NULL);
22702218
2271 method = dbus_message_new_method_call (2219 method = dbus_message_new_method_call (
2272 dbus_bus_get_unique_name (conn),2220 dbus_bus_get_unique_name (conn),
@@ -2315,7 +2263,7 @@
2315 * for the pre-stop script.2263 * for the pre-stop script.
2316 */2264 */
2317 TEST_FEATURE ("with environment");2265 TEST_FEATURE ("with environment");
2318 class = job_class_new (NULL, "test", session);2266 class = job_class_new (NULL, "test", NULL);
2319 class->instance = "$FOO";2267 class->instance = "$FOO";
23202268
2321 job = job_new (class, "wibble");2269 job = job_new (class, "wibble");
@@ -2404,7 +2352,7 @@
2404 * is returned.2352 * is returned.
2405 */2353 */
2406 TEST_FEATURE ("with invalid environment");2354 TEST_FEATURE ("with invalid environment");
2407 class = job_class_new (NULL, "test", session);2355 class = job_class_new (NULL, "test", NULL);
2408 job = job_new (class, "");2356 job = job_new (class, "");
24092357
2410 job->goal = JOB_START;2358 job->goal = JOB_START;
@@ -2451,7 +2399,6 @@
2451 nih_free (dbus_error);2399 nih_free (dbus_error);
24522400
2453 nih_free (class);2401 nih_free (class);
2454 nih_free (session);
24552402
2456 TEST_DBUS_CLOSE (conn);2403 TEST_DBUS_CLOSE (conn);
2457 TEST_DBUS_CLOSE (client_conn);2404 TEST_DBUS_CLOSE (client_conn);
@@ -2478,11 +2425,6 @@
2478 int ret;2425 int ret;
2479 NihError *error;2426 NihError *error;
2480 NihDBusError *dbus_error;2427 NihDBusError *dbus_error;
2481 Session *session;
2482
2483 session = session_new (NULL, NULL, getuid ());
2484 TEST_NE_P (session, NULL);
2485
24862428
2487 TEST_FUNCTION ("job_class_restart");2429 TEST_FUNCTION ("job_class_restart");
2488 nih_error_init ();2430 nih_error_init ();
@@ -2499,7 +2441,7 @@
2499 * through to waiting, the reply will be sent to the sender.2441 * through to waiting, the reply will be sent to the sender.
2500 */2442 */
2501 TEST_FEATURE ("with running job");2443 TEST_FEATURE ("with running job");
2502 class = job_class_new (NULL, "test", session);2444 class = job_class_new (NULL, "test", NULL);
2503 job = job_new (class, "");2445 job = job_new (class, "");
25042446
2505 job->goal = JOB_START;2447 job->goal = JOB_START;
@@ -2596,7 +2538,7 @@
2596 * entry created.2538 * entry created.
2597 */2539 */
2598 TEST_FEATURE ("with no wait");2540 TEST_FEATURE ("with no wait");
2599 class = job_class_new (NULL, "test", session);2541 class = job_class_new (NULL, "test", NULL);
2600 job = job_new (class, "");2542 job = job_new (class, "");
26012543
2602 job->goal = JOB_START;2544 job->goal = JOB_START;
@@ -2677,7 +2619,7 @@
2677 * a D-Bus error is raised immediately.2619 * a D-Bus error is raised immediately.
2678 */2620 */
2679 TEST_FEATURE ("with stopping job");2621 TEST_FEATURE ("with stopping job");
2680 class = job_class_new (NULL, "test", session);2622 class = job_class_new (NULL, "test", NULL);
2681 job = job_new (class, "");2623 job = job_new (class, "");
26822624
2683 job->goal = JOB_STOP;2625 job->goal = JOB_STOP;
@@ -2732,7 +2674,7 @@
2732 * immediately.2674 * immediately.
2733 */2675 */
2734 TEST_FEATURE ("with unknown job");2676 TEST_FEATURE ("with unknown job");
2735 class = job_class_new (NULL, "test", session);2677 class = job_class_new (NULL, "test", NULL);
27362678
2737 method = dbus_message_new_method_call (2679 method = dbus_message_new_method_call (
2738 dbus_bus_get_unique_name (conn),2680 dbus_bus_get_unique_name (conn),
@@ -2781,7 +2723,7 @@
2781 * when it's starting again.2723 * when it's starting again.
2782 */2724 */
2783 TEST_FEATURE ("with environment");2725 TEST_FEATURE ("with environment");
2784 class = job_class_new (NULL, "test", session);2726 class = job_class_new (NULL, "test", NULL);
2785 class->instance = "$FOO";2727 class->instance = "$FOO";
27862728
2787 job = job_new (class, "wibble");2729 job = job_new (class, "wibble");
@@ -2894,7 +2836,7 @@
2894 * is returned.2836 * is returned.
2895 */2837 */
2896 TEST_FEATURE ("with invalid environment");2838 TEST_FEATURE ("with invalid environment");
2897 class = job_class_new (NULL, "test", session);2839 class = job_class_new (NULL, "test", NULL);
2898 job = job_new (class, "");2840 job = job_new (class, "");
28992841
2900 job->goal = JOB_START;2842 job->goal = JOB_START;
@@ -2941,7 +2883,6 @@
2941 nih_free (dbus_error);2883 nih_free (dbus_error);
29422884
2943 nih_free (class);2885 nih_free (class);
2944 nih_free (session);
29452886
2946 TEST_DBUS_CLOSE (conn);2887 TEST_DBUS_CLOSE (conn);
2947 TEST_DBUS_CLOSE (client_conn);2888 TEST_DBUS_CLOSE (client_conn);
@@ -2961,10 +2902,6 @@
2961 NihError *error;2902 NihError *error;
2962 char *name;2903 char *name;
2963 int ret;2904 int ret;
2964 Session *session;
2965
2966 session = session_new (NULL, NULL, getuid ());
2967 TEST_NE_P (session, NULL);
29682905
2969 /* Check that the name of the job class is returned from the2906 /* Check that the name of the job class is returned from the
2970 * property, as a child of the message.2907 * property, as a child of the message.
@@ -2975,7 +2912,7 @@
29752912
2976 TEST_ALLOC_FAIL {2913 TEST_ALLOC_FAIL {
2977 TEST_ALLOC_SAFE {2914 TEST_ALLOC_SAFE {
2978 class = job_class_new (NULL, "test", session);2915 class = job_class_new (NULL, "test", NULL);
29792916
2980 message = nih_new (NULL, NihDBusMessage);2917 message = nih_new (NULL, NihDBusMessage);
2981 message->connection = NULL;2918 message->connection = NULL;
@@ -3006,7 +2943,6 @@
3006 nih_free (message);2943 nih_free (message);
3007 nih_free (class);2944 nih_free (class);
3008 }2945 }
3009 nih_free (session);
3010}2946}
30112947
3012void2948void
@@ -3017,10 +2953,6 @@
3017 NihError *error;2953 NihError *error;
3018 char *description;2954 char *description;
3019 int ret;2955 int ret;
3020 Session *session;
3021
3022 session = session_new (NULL, NULL, getuid ());
3023 TEST_NE_P (session, NULL);
30242956
3025 TEST_FUNCTION ("job_class_get_description");2957 TEST_FUNCTION ("job_class_get_description");
3026 nih_error_init ();2958 nih_error_init ();
@@ -3032,7 +2964,7 @@
3032 TEST_FEATURE ("with description");2964 TEST_FEATURE ("with description");
3033 TEST_ALLOC_FAIL {2965 TEST_ALLOC_FAIL {
3034 TEST_ALLOC_SAFE {2966 TEST_ALLOC_SAFE {
3035 class = job_class_new (NULL, "test", session);2967 class = job_class_new (NULL, "test", NULL);
3036 class->description = nih_strdup (class, "a test job");2968 class->description = nih_strdup (class, "a test job");
30372969
3038 message = nih_new (NULL, NihDBusMessage);2970 message = nih_new (NULL, NihDBusMessage);
@@ -3072,7 +3004,7 @@
3072 TEST_FEATURE ("with no description");3004 TEST_FEATURE ("with no description");
3073 TEST_ALLOC_FAIL {3005 TEST_ALLOC_FAIL {
3074 TEST_ALLOC_SAFE {3006 TEST_ALLOC_SAFE {
3075 class = job_class_new (NULL, "test", session);3007 class = job_class_new (NULL, "test", NULL);
30763008
3077 message = nih_new (NULL, NihDBusMessage);3009 message = nih_new (NULL, NihDBusMessage);
3078 message->connection = NULL;3010 message->connection = NULL;
@@ -3103,7 +3035,6 @@
3103 nih_free (message);3035 nih_free (message);
3104 nih_free (class);3036 nih_free (class);
3105 }3037 }
3106 nih_free (session);
3107}3038}
31083039
3109void3040void
@@ -3114,10 +3045,6 @@
3114 NihError *error;3045 NihError *error;
3115 char *author;3046 char *author;
3116 int ret;3047 int ret;
3117 Session *session;
3118
3119 session = session_new (NULL, NULL, getuid ());
3120 TEST_NE_P (session, NULL);
31213048
3122 TEST_FUNCTION ("job_class_get_author");3049 TEST_FUNCTION ("job_class_get_author");
3123 nih_error_init ();3050 nih_error_init ();
@@ -3129,7 +3056,7 @@
3129 TEST_FEATURE ("with author");3056 TEST_FEATURE ("with author");
3130 TEST_ALLOC_FAIL {3057 TEST_ALLOC_FAIL {
3131 TEST_ALLOC_SAFE {3058 TEST_ALLOC_SAFE {
3132 class = job_class_new (NULL, "test", session);3059 class = job_class_new (NULL, "test", NULL);
3133 class->author = nih_strdup (class, "a test job");3060 class->author = nih_strdup (class, "a test job");
31343061
3135 message = nih_new (NULL, NihDBusMessage);3062 message = nih_new (NULL, NihDBusMessage);
@@ -3169,7 +3096,7 @@
3169 TEST_FEATURE ("with no author");3096 TEST_FEATURE ("with no author");
3170 TEST_ALLOC_FAIL {3097 TEST_ALLOC_FAIL {
3171 TEST_ALLOC_SAFE {3098 TEST_ALLOC_SAFE {
3172 class = job_class_new (NULL, "test", session);3099 class = job_class_new (NULL, "test", NULL);
31733100
3174 message = nih_new (NULL, NihDBusMessage);3101 message = nih_new (NULL, NihDBusMessage);
3175 message->connection = NULL;3102 message->connection = NULL;
@@ -3200,7 +3127,6 @@
3200 nih_free (message);3127 nih_free (message);
3201 nih_free (class);3128 nih_free (class);
3202 }3129 }
3203 nih_free (session);
3204}3130}
32053131
3206void3132void
@@ -3211,10 +3137,6 @@
3211 NihError *error;3137 NihError *error;
3212 char *version;3138 char *version;
3213 int ret;3139 int ret;
3214 Session *session;
3215
3216 session = session_new (NULL, NULL, getuid ());
3217 TEST_NE_P (session, NULL);
32183140
3219 TEST_FUNCTION ("job_class_get_version");3141 TEST_FUNCTION ("job_class_get_version");
3220 nih_error_init ();3142 nih_error_init ();
@@ -3226,7 +3148,7 @@
3226 TEST_FEATURE ("with version");3148 TEST_FEATURE ("with version");
3227 TEST_ALLOC_FAIL {3149 TEST_ALLOC_FAIL {
3228 TEST_ALLOC_SAFE {3150 TEST_ALLOC_SAFE {
3229 class = job_class_new (NULL, "test", session);3151 class = job_class_new (NULL, "test", NULL);
3230 class->version = nih_strdup (class, "a test job");3152 class->version = nih_strdup (class, "a test job");
32313153
3232 message = nih_new (NULL, NihDBusMessage);3154 message = nih_new (NULL, NihDBusMessage);
@@ -3266,7 +3188,7 @@
3266 TEST_FEATURE ("with no version");3188 TEST_FEATURE ("with no version");
3267 TEST_ALLOC_FAIL {3189 TEST_ALLOC_FAIL {
3268 TEST_ALLOC_SAFE {3190 TEST_ALLOC_SAFE {
3269 class = job_class_new (NULL, "test", session);3191 class = job_class_new (NULL, "test", NULL);
32703192
3271 message = nih_new (NULL, NihDBusMessage);3193 message = nih_new (NULL, NihDBusMessage);
3272 message->connection = NULL;3194 message->connection = NULL;
@@ -3297,7 +3219,6 @@
3297 nih_free (message);3219 nih_free (message);
3298 nih_free (class);3220 nih_free (class);
3299 }3221 }
3300 nih_free (session);
3301}3222}
33023223
3303void3224void
@@ -3310,10 +3231,6 @@
3310 NihError *error;3231 NihError *error;
3311 char ***start_on;3232 char ***start_on;
3312 int ret;3233 int ret;
3313 Session *session;
3314
3315 session = session_new (NULL, NULL, getuid ());
3316 TEST_NE_P (session, NULL);
33173234
3318 TEST_FUNCTION ("job_class_get_start_on");3235 TEST_FUNCTION ("job_class_get_start_on");
33193236
@@ -3326,7 +3243,7 @@
33263243
3327 TEST_ALLOC_FAIL {3244 TEST_ALLOC_FAIL {
3328 TEST_ALLOC_SAFE {3245 TEST_ALLOC_SAFE {
3329 class = job_class_new (NULL, "test", session);3246 class = job_class_new (NULL, "test", NULL);
33303247
3331 class->start_on = event_operator_new (3248 class->start_on = event_operator_new (
3332 class, EVENT_OR, NULL, NULL);3249 class, EVENT_OR, NULL, NULL);
@@ -3421,7 +3338,7 @@
34213338
3422 TEST_ALLOC_FAIL {3339 TEST_ALLOC_FAIL {
3423 TEST_ALLOC_SAFE {3340 TEST_ALLOC_SAFE {
3424 class = job_class_new (NULL, "test", session);3341 class = job_class_new (NULL, "test", NULL);
34253342
3426 message = nih_new (NULL, NihDBusMessage);3343 message = nih_new (NULL, NihDBusMessage);
3427 message->connection = NULL;3344 message->connection = NULL;
@@ -3453,7 +3370,6 @@
3453 nih_free (message);3370 nih_free (message);
3454 nih_free (class);3371 nih_free (class);
3455 }3372 }
3456 nih_free (session);
3457}3373}
34583374
3459void3375void
@@ -3466,10 +3382,6 @@
3466 NihError *error;3382 NihError *error;
3467 char ***stop_on;3383 char ***stop_on;
3468 int ret;3384 int ret;
3469 Session *session;
3470
3471 session = session_new (NULL, NULL, getuid ());
3472 TEST_NE_P (session, NULL);
34733385
3474 TEST_FUNCTION ("job_class_get_stop_on");3386 TEST_FUNCTION ("job_class_get_stop_on");
34753387
@@ -3482,7 +3394,7 @@
34823394
3483 TEST_ALLOC_FAIL {3395 TEST_ALLOC_FAIL {
3484 TEST_ALLOC_SAFE {3396 TEST_ALLOC_SAFE {
3485 class = job_class_new (NULL, "test", session);3397 class = job_class_new (NULL, "test", NULL);
34863398
3487 class->stop_on = event_operator_new (3399 class->stop_on = event_operator_new (
3488 class, EVENT_OR, NULL, NULL);3400 class, EVENT_OR, NULL, NULL);
@@ -3577,7 +3489,7 @@
35773489
3578 TEST_ALLOC_FAIL {3490 TEST_ALLOC_FAIL {
3579 TEST_ALLOC_SAFE {3491 TEST_ALLOC_SAFE {
3580 class = job_class_new (NULL, "test", session);3492 class = job_class_new (NULL, "test", NULL);
35813493
3582 message = nih_new (NULL, NihDBusMessage);3494 message = nih_new (NULL, NihDBusMessage);
3583 message->connection = NULL;3495 message->connection = NULL;
@@ -3609,7 +3521,6 @@
3609 nih_free (message);3521 nih_free (message);
3610 nih_free (class);3522 nih_free (class);
3611 }3523 }
3612 nih_free (session);
3613}3524}
36143525
3615void3526void
@@ -3620,10 +3531,6 @@
3620 NihError *error;3531 NihError *error;
3621 char **emits;3532 char **emits;
3622 int ret;3533 int ret;
3623 Session *session;
3624
3625 session = session_new (NULL, NULL, getuid ());
3626 TEST_NE_P (session, NULL);
36273534
3628 TEST_FUNCTION ("job_class_get_emits");3535 TEST_FUNCTION ("job_class_get_emits");
36293536
@@ -3637,7 +3544,7 @@
36373544
3638 TEST_ALLOC_FAIL {3545 TEST_ALLOC_FAIL {
3639 TEST_ALLOC_SAFE {3546 TEST_ALLOC_SAFE {
3640 class = job_class_new (NULL, "test", session);3547 class = job_class_new (NULL, "test", NULL);
3641 class->emits = nih_str_array_new (class);3548 class->emits = nih_str_array_new (class);
36423549
3643 NIH_MUST (nih_str_array_add (&class->emits, class, NULL, "foo"));3550 NIH_MUST (nih_str_array_add (&class->emits, class, NULL, "foo"));
@@ -3689,7 +3596,7 @@
36893596
3690 TEST_ALLOC_FAIL {3597 TEST_ALLOC_FAIL {
3691 TEST_ALLOC_SAFE {3598 TEST_ALLOC_SAFE {
3692 class = job_class_new (NULL, "test", session);3599 class = job_class_new (NULL, "test", NULL);
36933600
3694 message = nih_new (NULL, NihDBusMessage);3601 message = nih_new (NULL, NihDBusMessage);
3695 message->connection = NULL;3602 message->connection = NULL;
@@ -3721,7 +3628,6 @@
3721 nih_free (message);3628 nih_free (message);
3722 nih_free (class);3629 nih_free (class);
3723 }3630 }
3724 nih_free (session);
3725}3631}
37263632
37273633
@@ -3729,6 +3635,9 @@
3729main (int argc,3635main (int argc,
3730 char *argv[])3636 char *argv[])
3731{3637{
3638 /* run tests in legacy (pre-session support) mode */
3639 setenv ("UPSTART_NO_SESSIONS", "1", 1);
3640
3732 test_new ();3641 test_new ();
3733 test_consider ();3642 test_consider ();
3734 test_reconsider ();3643 test_reconsider ();
37353644
=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c 2011-02-24 15:41:04 +0000
+++ init/tests/test_job_process.c 2011-04-19 09:27:29 +0000
@@ -131,10 +131,6 @@
131 char filename[PATH_MAX], buf[80];131 char filename[PATH_MAX], buf[80];
132 int ret = -1, status, first;132 int ret = -1, status, first;
133 siginfo_t info;133 siginfo_t info;
134 Session *session;
135
136 session = session_new (NULL, NULL, getuid ());
137 TEST_NE_P (session, NULL);
138134
139 TEST_FUNCTION ("job_process_run");135 TEST_FUNCTION ("job_process_run");
140 job_class_init ();136 job_class_init ();
@@ -151,7 +147,7 @@
151 TEST_FEATURE ("with simple command");147 TEST_FEATURE ("with simple command");
152 TEST_ALLOC_FAIL {148 TEST_ALLOC_FAIL {
153 TEST_ALLOC_SAFE {149 TEST_ALLOC_SAFE {
154 class = job_class_new (NULL, "test", session);150 class = job_class_new (NULL, "test", NULL);
155 class->process[PROCESS_MAIN] = process_new (class);151 class->process[PROCESS_MAIN] = process_new (class);
156 class->process[PROCESS_MAIN]->command = nih_sprintf (152 class->process[PROCESS_MAIN]->command = nih_sprintf (
157 class->process[PROCESS_MAIN],153 class->process[PROCESS_MAIN],
@@ -183,7 +179,7 @@
183 TEST_FEATURE ("with shell command");179 TEST_FEATURE ("with shell command");
184 TEST_ALLOC_FAIL {180 TEST_ALLOC_FAIL {
185 TEST_ALLOC_SAFE {181 TEST_ALLOC_SAFE {
186 class = job_class_new (NULL, "test", session);182 class = job_class_new (NULL, "test", NULL);
187 class->process[PROCESS_MAIN] = process_new (class);183 class->process[PROCESS_MAIN] = process_new (class);
188 class->process[PROCESS_MAIN]->command = nih_sprintf (184 class->process[PROCESS_MAIN]->command = nih_sprintf (
189 class->process[PROCESS_MAIN],185 class->process[PROCESS_MAIN],
@@ -220,7 +216,7 @@
220 TEST_FEATURE ("with small script");216 TEST_FEATURE ("with small script");
221 TEST_ALLOC_FAIL {217 TEST_ALLOC_FAIL {
222 TEST_ALLOC_SAFE {218 TEST_ALLOC_SAFE {
223 class = job_class_new (NULL, "test", session);219 class = job_class_new (NULL, "test", NULL);
224 class->process[PROCESS_MAIN] = process_new (class);220 class->process[PROCESS_MAIN] = process_new (class);
225 class->process[PROCESS_MAIN]->script = TRUE;221 class->process[PROCESS_MAIN]->script = TRUE;
226 class->process[PROCESS_MAIN]->command = nih_sprintf (222 class->process[PROCESS_MAIN]->command = nih_sprintf (
@@ -257,7 +253,7 @@
257 TEST_FEATURE ("with small script and trailing newlines");253 TEST_FEATURE ("with small script and trailing newlines");
258 TEST_ALLOC_FAIL {254 TEST_ALLOC_FAIL {
259 TEST_ALLOC_SAFE {255 TEST_ALLOC_SAFE {
260 class = job_class_new (NULL, "test", session);256 class = job_class_new (NULL, "test", NULL);
261 class->process[PROCESS_MAIN] = process_new (class);257 class->process[PROCESS_MAIN] = process_new (class);
262 class->process[PROCESS_MAIN]->script = TRUE;258 class->process[PROCESS_MAIN]->script = TRUE;
263 class->process[PROCESS_MAIN]->command = nih_sprintf (259 class->process[PROCESS_MAIN]->command = nih_sprintf (
@@ -294,7 +290,7 @@
294 TEST_FEATURE ("with script that will fail");290 TEST_FEATURE ("with script that will fail");
295 TEST_ALLOC_FAIL {291 TEST_ALLOC_FAIL {
296 TEST_ALLOC_SAFE {292 TEST_ALLOC_SAFE {
297 class = job_class_new (NULL, "test", session);293 class = job_class_new (NULL, "test", NULL);
298 class->process[PROCESS_MAIN] = process_new (class);294 class->process[PROCESS_MAIN] = process_new (class);
299 class->process[PROCESS_MAIN]->script = TRUE;295 class->process[PROCESS_MAIN]->script = TRUE;
300 class->process[PROCESS_MAIN]->command = nih_sprintf (296 class->process[PROCESS_MAIN]->command = nih_sprintf (
@@ -331,7 +327,7 @@
331 TEST_FEATURE ("with environment of unnamed instance");327 TEST_FEATURE ("with environment of unnamed instance");
332 TEST_ALLOC_FAIL {328 TEST_ALLOC_FAIL {
333 TEST_ALLOC_SAFE {329 TEST_ALLOC_SAFE {
334 class = job_class_new (NULL, "test", session);330 class = job_class_new (NULL, "test", NULL);
335 class->process[PROCESS_MAIN] = process_new (class);331 class->process[PROCESS_MAIN] = process_new (class);
336 class->process[PROCESS_MAIN]->command = nih_sprintf (332 class->process[PROCESS_MAIN]->command = nih_sprintf (
337 class->process[PROCESS_MAIN],333 class->process[PROCESS_MAIN],
@@ -380,7 +376,7 @@
380 TEST_FEATURE ("with environment of named instance");376 TEST_FEATURE ("with environment of named instance");
381 TEST_ALLOC_FAIL {377 TEST_ALLOC_FAIL {
382 TEST_ALLOC_SAFE {378 TEST_ALLOC_SAFE {
383 class = job_class_new (NULL, "test", session);379 class = job_class_new (NULL, "test", NULL);
384 class->process[PROCESS_MAIN] = process_new (class);380 class->process[PROCESS_MAIN] = process_new (class);
385 class->process[PROCESS_MAIN]->command = nih_sprintf (381 class->process[PROCESS_MAIN]->command = nih_sprintf (
386 class->process[PROCESS_MAIN],382 class->process[PROCESS_MAIN],
@@ -430,7 +426,7 @@
430 TEST_FEATURE ("with environment for pre-stop");426 TEST_FEATURE ("with environment for pre-stop");
431 TEST_ALLOC_FAIL {427 TEST_ALLOC_FAIL {
432 TEST_ALLOC_SAFE {428 TEST_ALLOC_SAFE {
433 class = job_class_new (NULL, "test", session);429 class = job_class_new (NULL, "test", NULL);
434 class->process[PROCESS_PRE_STOP] = process_new (class);430 class->process[PROCESS_PRE_STOP] = process_new (class);
435 class->process[PROCESS_PRE_STOP]->command = nih_sprintf (431 class->process[PROCESS_PRE_STOP]->command = nih_sprintf (
436 class->process[PROCESS_PRE_STOP],432 class->process[PROCESS_PRE_STOP],
@@ -481,7 +477,7 @@
481 TEST_FEATURE ("with environment for post-stop");477 TEST_FEATURE ("with environment for post-stop");
482 TEST_ALLOC_FAIL {478 TEST_ALLOC_FAIL {
483 TEST_ALLOC_SAFE {479 TEST_ALLOC_SAFE {
484 class = job_class_new (NULL, "test", session);480 class = job_class_new (NULL, "test", NULL);
485 class->process[PROCESS_POST_STOP] = process_new (class);481 class->process[PROCESS_POST_STOP] = process_new (class);
486 class->process[PROCESS_POST_STOP]->command = nih_sprintf (482 class->process[PROCESS_POST_STOP]->command = nih_sprintf (
487 class->process[PROCESS_POST_STOP],483 class->process[PROCESS_POST_STOP],
@@ -532,7 +528,7 @@
532 TEST_FEATURE ("with long script");528 TEST_FEATURE ("with long script");
533 TEST_ALLOC_FAIL {529 TEST_ALLOC_FAIL {
534 TEST_ALLOC_SAFE {530 TEST_ALLOC_SAFE {
535 class = job_class_new (NULL, "test", session);531 class = job_class_new (NULL, "test", NULL);
536 class->process[PROCESS_MAIN] = process_new (class);532 class->process[PROCESS_MAIN] = process_new (class);
537 class->process[PROCESS_MAIN]->script = TRUE;533 class->process[PROCESS_MAIN]->script = TRUE;
538 class->process[PROCESS_MAIN]->command = nih_alloc (534 class->process[PROCESS_MAIN]->command = nih_alloc (
@@ -597,7 +593,7 @@
597 TEST_FEATURE ("with non-daemon job");593 TEST_FEATURE ("with non-daemon job");
598 TEST_ALLOC_FAIL {594 TEST_ALLOC_FAIL {
599 TEST_ALLOC_SAFE {595 TEST_ALLOC_SAFE {
600 class = job_class_new (NULL, "test", session);596 class = job_class_new (NULL, "test", NULL);
601 class->process[PROCESS_MAIN] = process_new (class);597 class->process[PROCESS_MAIN] = process_new (class);
602 class->process[PROCESS_MAIN]->command = "true";598 class->process[PROCESS_MAIN]->command = "true";
603599
@@ -633,7 +629,7 @@
633 TEST_FEATURE ("with script for daemon job");629 TEST_FEATURE ("with script for daemon job");
634 TEST_ALLOC_FAIL {630 TEST_ALLOC_FAIL {
635 TEST_ALLOC_SAFE {631 TEST_ALLOC_SAFE {
636 class = job_class_new (NULL, "test", session);632 class = job_class_new (NULL, "test", NULL);
637 class->process[PROCESS_PRE_START] = process_new (class);633 class->process[PROCESS_PRE_START] = process_new (class);
638 class->process[PROCESS_PRE_START]->command = "true";634 class->process[PROCESS_PRE_START]->command = "true";
639635
@@ -670,7 +666,7 @@
670 TEST_FEATURE ("with daemon job");666 TEST_FEATURE ("with daemon job");
671 TEST_ALLOC_FAIL {667 TEST_ALLOC_FAIL {
672 TEST_ALLOC_SAFE {668 TEST_ALLOC_SAFE {
673 class = job_class_new (NULL, "test", session);669 class = job_class_new (NULL, "test", NULL);
674 class->expect = EXPECT_DAEMON;670 class->expect = EXPECT_DAEMON;
675 class->process[PROCESS_MAIN] = process_new (class);671 class->process[PROCESS_MAIN] = process_new (class);
676 class->process[PROCESS_MAIN]->command = "true";672 class->process[PROCESS_MAIN]->command = "true";
@@ -717,7 +713,7 @@
717 TEST_FEATURE ("with forking job");713 TEST_FEATURE ("with forking job");
718 TEST_ALLOC_FAIL {714 TEST_ALLOC_FAIL {
719 TEST_ALLOC_SAFE {715 TEST_ALLOC_SAFE {
720 class = job_class_new (NULL, "test", session);716 class = job_class_new (NULL, "test", NULL);
721 class->expect = EXPECT_FORK;717 class->expect = EXPECT_FORK;
722 class->process[PROCESS_MAIN] = process_new (class);718 class->process[PROCESS_MAIN] = process_new (class);
723 class->process[PROCESS_MAIN]->command = "true";719 class->process[PROCESS_MAIN]->command = "true";
@@ -766,7 +762,7 @@
766762
767 TEST_ALLOC_FAIL {763 TEST_ALLOC_FAIL {
768 TEST_ALLOC_SAFE {764 TEST_ALLOC_SAFE {
769 class = job_class_new (NULL, "test", session);765 class = job_class_new (NULL, "test", NULL);
770 class->process[PROCESS_MAIN] = process_new (class);766 class->process[PROCESS_MAIN] = process_new (class);
771 class->process[PROCESS_MAIN]->command = filename;767 class->process[PROCESS_MAIN]->command = filename;
772768
@@ -791,7 +787,6 @@
791787
792 nih_free (class);788 nih_free (class);
793 }789 }
794 nih_free (session);
795}790}
796791
797792
@@ -808,10 +803,6 @@
808 NihError *err;803 NihError *err;
809 JobProcessError *perr;804 JobProcessError *perr;
810 int status;805 int status;
811 Session *session;
812
813 session = session_new (NULL, NULL, getuid ());
814 TEST_NE_P (session, NULL);
815806
816 TEST_FUNCTION ("job_process_spawn");807 TEST_FUNCTION ("job_process_spawn");
817 TEST_FILENAME (filename);808 TEST_FILENAME (filename);
@@ -828,7 +819,7 @@
828 TEST_FEATURE ("with simple job");819 TEST_FEATURE ("with simple job");
829 sprintf (function, "%d", TEST_PIDS);820 sprintf (function, "%d", TEST_PIDS);
830821
831 class = job_class_new (NULL, "test", session);822 class = job_class_new (NULL, "test", NULL);
832823
833 pid = job_process_spawn (class, args, NULL, FALSE);824 pid = job_process_spawn (class, args, NULL, FALSE);
834 TEST_GT (pid, 0);825 TEST_GT (pid, 0);
@@ -865,7 +856,7 @@
865 TEST_FEATURE ("with no console");856 TEST_FEATURE ("with no console");
866 sprintf (function, "%d", TEST_CONSOLE);857 sprintf (function, "%d", TEST_CONSOLE);
867858
868 class = job_class_new (NULL, "test", session);859 class = job_class_new (NULL, "test", NULL);
869 class->console = CONSOLE_NONE;860 class->console = CONSOLE_NONE;
870861
871 pid = job_process_spawn (class, args, NULL, FALSE);862 pid = job_process_spawn (class, args, NULL, FALSE);
@@ -891,7 +882,7 @@
891 TEST_FEATURE ("with working directory");882 TEST_FEATURE ("with working directory");
892 sprintf (function, "%d", TEST_PWD);883 sprintf (function, "%d", TEST_PWD);
893884
894 class = job_class_new (NULL, "test", session);885 class = job_class_new (NULL, "test", NULL);
895 class->chdir = "/tmp";886 class->chdir = "/tmp";
896887
897 pid = job_process_spawn (class, args, NULL, FALSE);888 pid = job_process_spawn (class, args, NULL, FALSE);
@@ -920,7 +911,7 @@
920 env[1] = "FOO=bar";911 env[1] = "FOO=bar";
921 env[2] = NULL;912 env[2] = NULL;
922913
923 class = job_class_new (NULL, "test", session);914 class = job_class_new (NULL, "test", NULL);
924915
925 pid = job_process_spawn (class, args, env, FALSE);916 pid = job_process_spawn (class, args, env, FALSE);
926 TEST_GT (pid, 0);917 TEST_GT (pid, 0);
@@ -945,7 +936,7 @@
945 TEST_FEATURE ("with non-daemon job");936 TEST_FEATURE ("with non-daemon job");
946 sprintf (function, "%d", TEST_SIMPLE);937 sprintf (function, "%d", TEST_SIMPLE);
947938
948 class = job_class_new (NULL, "test", session);939 class = job_class_new (NULL, "test", NULL);
949940
950 pid = job_process_spawn (class, args, NULL, FALSE);941 pid = job_process_spawn (class, args, NULL, FALSE);
951 TEST_GT (pid, 0);942 TEST_GT (pid, 0);
@@ -965,7 +956,7 @@
965 TEST_FEATURE ("with daemon job");956 TEST_FEATURE ("with daemon job");
966 sprintf (function, "%d", TEST_SIMPLE);957 sprintf (function, "%d", TEST_SIMPLE);
967958
968 class = job_class_new (NULL, "test", session);959 class = job_class_new (NULL, "test", NULL);
969960
970 pid = job_process_spawn (class, args, NULL, TRUE);961 pid = job_process_spawn (class, args, NULL, TRUE);
971 TEST_GT (pid, 0);962 TEST_GT (pid, 0);
@@ -994,7 +985,7 @@
994 args[1] = filename;985 args[1] = filename;
995 args[2] = NULL;986 args[2] = NULL;
996987
997 class = job_class_new (NULL, "test", session);988 class = job_class_new (NULL, "test", NULL);
998989
999 pid = job_process_spawn (class, args, NULL, FALSE);990 pid = job_process_spawn (class, args, NULL, FALSE);
1000 TEST_LT (pid, 0);991 TEST_LT (pid, 0);
@@ -1013,7 +1004,7 @@
1013 */1004 */
1014 TEST_FEATURE ("with debug enabled");1005 TEST_FEATURE ("with debug enabled");
10151006
1016 class = job_class_new (NULL, "test", session);1007 class = job_class_new (NULL, "test", NULL);
1017 class->debug = TRUE;1008 class->debug = TRUE;
10181009
1019 sprintf (function, "%s", "/bin/true");1010 sprintf (function, "%s", "/bin/true");
@@ -1042,7 +1033,6 @@
1042 TEST_EQ (WEXITSTATUS (status), 0);1033 TEST_EQ (WEXITSTATUS (status), 0);
10431034
1044 nih_free (class);1035 nih_free (class);
1045 nih_free (session);
1046}1036}
10471037
10481038
@@ -1055,16 +1045,12 @@
1055 struct timespec now;1045 struct timespec now;
1056 pid_t pid;1046 pid_t pid;
1057 int status;1047 int status;
1058 Session *session;
1059
1060 session = session_new (NULL, NULL, getuid ());
1061 TEST_NE_P (session, NULL);
10621048
1063 TEST_FUNCTION ("job_process_kill");1049 TEST_FUNCTION ("job_process_kill");
1064 nih_timer_init ();1050 nih_timer_init ();
1065 event_init ();1051 event_init ();
10661052
1067 class = job_class_new (NULL, "test", session);1053 class = job_class_new (NULL, "test", NULL);
1068 class->kill_timeout = 1000;1054 class->kill_timeout = 1000;
10691055
1070 class->process[PROCESS_MAIN] = process_new (class);1056 class->process[PROCESS_MAIN] = process_new (class);
@@ -1191,7 +1177,6 @@
1191 }1177 }
11921178
1193 nih_free (class);1179 nih_free (class);
1194 nih_free (session);
1195}1180}
11961181
11971182
@@ -1212,10 +1197,6 @@
1212 siginfo_t info;1197 siginfo_t info;
1213 unsigned long data;1198 unsigned long data;
1214 struct timespec now;1199 struct timespec now;
1215 Session *session;
1216
1217 session = session_new (NULL, NULL, getuid ());
1218 TEST_NE_P (session, NULL);
12191200
1220 TEST_FUNCTION ("job_process_handler");1201 TEST_FUNCTION ("job_process_handler");
1221 program_name = "test";1202 program_name = "test";
@@ -1223,7 +1204,7 @@
12231204
1224 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);1205 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
1225 file = conf_file_new (source, "/tmp/test");1206 file = conf_file_new (source, "/tmp/test");
1226 file->job = class = job_class_new (NULL, "test", session);1207 file->job = class = job_class_new (NULL, "test", NULL);
1227 class->process[PROCESS_MAIN] = process_new (class);1208 class->process[PROCESS_MAIN] = process_new (class);
1228 class->process[PROCESS_MAIN]->command = "echo";1209 class->process[PROCESS_MAIN]->command = "echo";
12291210
@@ -4387,7 +4368,6 @@
4387 nih_free (source);4368 nih_free (source);
43884369
4389 nih_free (event);4370 nih_free (event);
4390 nih_free (session);
4391 event_poll ();4371 event_poll ();
4392}4372}
43934373
@@ -4398,26 +4378,22 @@
4398 JobClass *class1, *class2, *class3;4378 JobClass *class1, *class2, *class3;
4399 Job *job1, *job2, *job3, *job4, *job5, *ptr;4379 Job *job1, *job2, *job3, *job4, *job5, *ptr;
4400 ProcessType process;4380 ProcessType process;
4401 Session *session;
4402
4403 session = session_new (NULL, NULL, getuid ());
4404 TEST_NE_P (session, NULL);
44054381
4406 TEST_FUNCTION ("job_process_find");4382 TEST_FUNCTION ("job_process_find");
4407 class1 = job_class_new (NULL, "foo", session);4383 class1 = job_class_new (NULL, "foo", NULL);
4408 class1->process[PROCESS_MAIN] = process_new (class1);4384 class1->process[PROCESS_MAIN] = process_new (class1);
4409 class1->process[PROCESS_POST_START] = process_new (class1);4385 class1->process[PROCESS_POST_START] = process_new (class1);
4410 class1->instance = "$FOO";4386 class1->instance = "$FOO";
4411 nih_hash_add (job_classes, &class1->entry);4387 nih_hash_add (job_classes, &class1->entry);
44124388
4413 class2 = job_class_new (NULL, "bar", session);4389 class2 = job_class_new (NULL, "bar", NULL);
4414 class2->process[PROCESS_PRE_START] = process_new (class2);4390 class2->process[PROCESS_PRE_START] = process_new (class2);
4415 class2->process[PROCESS_MAIN] = process_new (class2);4391 class2->process[PROCESS_MAIN] = process_new (class2);
4416 class2->process[PROCESS_PRE_STOP] = process_new (class2);4392 class2->process[PROCESS_PRE_STOP] = process_new (class2);
4417 class2->instance = "$FOO";4393 class2->instance = "$FOO";
4418 nih_hash_add (job_classes, &class2->entry);4394 nih_hash_add (job_classes, &class2->entry);
44194395
4420 class3 = job_class_new (NULL, "baz", session);4396 class3 = job_class_new (NULL, "baz", NULL);
4421 class3->process[PROCESS_POST_STOP] = process_new (class3);4397 class3->process[PROCESS_POST_STOP] = process_new (class3);
4422 nih_hash_add (job_classes, &class3->entry);4398 nih_hash_add (job_classes, &class3->entry);
44234399
@@ -4521,7 +4497,6 @@
4521 nih_free (class1);4497 nih_free (class1);
4522 nih_free (class2);4498 nih_free (class2);
4523 nih_free (class3);4499 nih_free (class3);
4524 nih_free (session);
4525 ptr = job_process_find (20, NULL);4500 ptr = job_process_find (20, NULL);
45264501
4527 TEST_EQ_P (ptr, NULL);4502 TEST_EQ_P (ptr, NULL);
@@ -4539,15 +4514,11 @@
4539 char utmpname[PATH_MAX];4514 char utmpname[PATH_MAX];
4540 struct utmpx utmp, *utmptr;4515 struct utmpx utmp, *utmptr;
4541 struct timeval tv;4516 struct timeval tv;
4542 Session *session;
4543
4544 session = session_new (NULL, NULL, getuid ());
4545 TEST_NE_P (session, NULL);
45464517
4547 TEST_FUNCTION ("job_process_handler");4518 TEST_FUNCTION ("job_process_handler");
4548 program_name = "test";4519 program_name = "test";
45494520
4550 class = job_class_new (NULL, "test", session);4521 class = job_class_new (NULL, "test", NULL);
4551 class->process[PROCESS_MAIN] = process_new (class);4522 class->process[PROCESS_MAIN] = process_new (class);
4552 class->process[PROCESS_MAIN]->command = "echo";4523 class->process[PROCESS_MAIN]->command = "echo";
45534524
@@ -4765,7 +4736,6 @@
47654736
4766 nih_free (job);4737 nih_free (job);
4767 }4738 }
4768 nih_free (session);
4769}4739}
47704740
47714741
@@ -4773,6 +4743,11 @@
4773main (int argc,4743main (int argc,
4774 char *argv[])4744 char *argv[])
4775{4745{
4746 /* Note we do not set the UPSTART_NO_SESSIONS variable since this
4747 * would cause these tests to fail (as they scrutinize the job
4748 * environment).
4749 */
4750
4776 /* We re-exec this binary to test various children features. To4751 /* We re-exec this binary to test various children features. To
4777 * do that, we need to know the full path to the program.4752 * do that, we need to know the full path to the program.
4778 */4753 */
47794754
=== modified file 'init/tests/test_parse_conf.c'
--- init/tests/test_parse_conf.c 2009-06-23 09:29:35 +0000
+++ init/tests/test_parse_conf.c 2011-04-19 09:27:29 +0000
@@ -77,6 +77,9 @@
77main (int argc,77main (int argc,
78 char *argv[])78 char *argv[])
79{79{
80 /* run tests in legacy (pre-session support) mode */
81 setenv ("UPSTART_NO_SESSIONS", "1", 1);
82
80 test_parse_conf ();83 test_parse_conf ();
8184
82 return 0;85 return 0;
8386
=== modified file 'init/tests/test_parse_job.c'
--- init/tests/test_parse_job.c 2011-02-23 11:04:27 +0000
+++ init/tests/test_parse_job.c 2011-04-19 09:27:29 +0000
@@ -7536,6 +7536,9 @@
7536main (int argc,7536main (int argc,
7537 char *argv[])7537 char *argv[])
7538{7538{
7539 /* run tests in legacy (pre-session support) mode */
7540 setenv ("UPSTART_NO_SESSIONS", "1", 1);
7541
7539 test_parse_job ();7542 test_parse_job ();
75407543
7541 test_stanza_instance ();7544 test_stanza_instance ();
75427545
=== modified file 'init/tests/test_process.c'
--- init/tests/test_process.c 2009-06-23 09:29:35 +0000
+++ init/tests/test_process.c 2011-04-19 09:27:29 +0000
@@ -157,6 +157,9 @@
157main (int argc,157main (int argc,
158 char *argv[])158 char *argv[])
159{159{
160 /* run tests in legacy (pre-session support) mode */
161 setenv ("UPSTART_NO_SESSIONS", "1", 1);
162
160 test_new ();163 test_new ();
161164
162 test_name ();165 test_name ();
163166
=== modified file 'init/tests/test_system.c'
--- init/tests/test_system.c 2009-06-23 09:29:35 +0000
+++ init/tests/test_system.c 2011-04-19 09:27:29 +0000
@@ -133,6 +133,9 @@
133main (int argc,133main (int argc,
134 char *argv[])134 char *argv[])
135{135{
136 /* run tests in legacy (pre-session support) mode */
137 setenv ("UPSTART_NO_SESSIONS", "1", 1);
138
136 test_kill ();139 test_kill ();
137140
138 return 0;141 return 0;
139142
=== modified file 'po/upstart.pot'
--- po/upstart.pot 2011-03-24 13:11:53 +0000
+++ po/upstart.pot 2011-04-19 09:27:29 +0000
@@ -6,9 +6,9 @@
6#, fuzzy6#, fuzzy
7msgid ""7msgid ""
8msgstr ""8msgstr ""
9"Project-Id-Version: upstart 0.9.4\n"9"Project-Id-Version: upstart 0.9.5\n"
10"Report-Msgid-Bugs-To: new@bugs.launchpad.net\n"10"Report-Msgid-Bugs-To: new@bugs.launchpad.net\n"
11"POT-Creation-Date: 2011-03-24 11:26+0000\n"11"POT-Creation-Date: 2011-04-15 12:11+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -35,26 +35,26 @@
35msgid "Unable to watch configuration file"35msgid "Unable to watch configuration file"
36msgstr ""36msgstr ""
3737
38#: init/conf.c:524 init/conf.c:92438#: init/conf.c:598
39msgid "Error while reloading configuration file"
40msgstr ""
41
42#: init/conf.c:601
43msgid "Unable to watch configuration directory"39msgid "Unable to watch configuration directory"
44msgstr ""40msgstr ""
4541
46#: init/conf.c:772 init/conf.c:90442#: init/conf.c:769 init/conf.c:901
47msgid "Error while loading configuration file"43msgid "Error while loading configuration file"
48msgstr ""44msgstr ""
4945
50#: init/conf.c:81946#: init/conf.c:816
51msgid "Configuration directory deleted"47msgid "Configuration directory deleted"
52msgstr ""48msgstr ""
5349
54#: init/conf.c:84850#: init/conf.c:845
55msgid "Unable to reload configuration after override deletion"51msgid "Unable to reload configuration after override deletion"
56msgstr ""52msgstr ""
5753
54#: init/conf.c:921
55msgid "Error while reloading configuration file"
56msgstr ""
57
58#: init/control.c:16558#: init/control.c:165
59msgid "Connection from private client"59msgid "Connection from private client"
60msgstr ""60msgstr ""
@@ -63,25 +63,25 @@
63msgid "Disconnected from system bus"63msgid "Disconnected from system bus"
64msgstr ""64msgstr ""
6565
66#: init/control.c:370 init/main.c:54966#: init/control.c:370 init/main.c:557
67msgid "Reloading configuration"67msgid "Reloading configuration"
68msgstr ""68msgstr ""
6969
70#: init/control.c:412 init/control.c:56170#: init/control.c:412 init/control.c:565
71msgid "Name may not be empty string"71msgid "Name may not be empty string"
72msgstr ""72msgstr ""
7373
74#: init/control.c:43874#: init/control.c:442
75#, c-format75#, c-format
76msgid "Unknown job: %s"76msgid "Unknown job: %s"
77msgstr ""77msgstr ""
7878
79#: init/control.c:569 init/job_class.c:559 init/job_class.c:75879#: init/control.c:573 init/job_class.c:579 init/job_class.c:778
80#: init/job_class.c:888 init/job_class.c:102380#: init/job_class.c:908 init/job_class.c:1043
81msgid "Env must be KEY=VALUE pairs"81msgid "Env must be KEY=VALUE pairs"
82msgstr ""82msgstr ""
8383
84#: init/control.c:73884#: init/control.c:742
85msgid "The log priority given was not recognised"85msgid "The log priority given was not recognised"
86msgstr ""86msgstr ""
8787
@@ -99,337 +99,341 @@
99msgid "Event failed"99msgid "Event failed"
100msgstr ""100msgstr ""
101101
102#: init/job.c:227102#: init/job.c:233
103#, c-format103#, c-format
104msgid "%s goal changed from %s to %s"104msgid "%s goal changed from %s to %s"
105msgstr ""105msgstr ""
106106
107#: init/job.c:298107#: init/job.c:304
108#, c-format108#, c-format
109msgid "%s state changed from %s to %s"109msgid "%s state changed from %s to %s"
110msgstr ""110msgstr ""
111111
112#: init/job.c:717 init/job.c:755112#: init/job.c:723 init/job.c:761
113msgid "Job failed to start"113msgid "Job failed to start"
114msgstr ""114msgstr ""
115115
116#: init/job.c:730 init/job.c:766116#: init/job.c:736 init/job.c:772
117msgid "Job failed while stopping"117msgid "Job failed while stopping"
118msgstr ""118msgstr ""
119119
120#: init/job.c:742 init/job.c:777120#: init/job.c:748 init/job.c:783
121msgid "Job failed to restart"121msgid "Job failed to restart"
122msgstr ""122msgstr ""
123123
124#: init/job.c:971124#: init/job.c:977
125msgid "stop"125msgid "stop"
126msgstr ""126msgstr ""
127127
128#: init/job.c:973128#: init/job.c:979
129msgid "start"129msgid "start"
130msgstr ""130msgstr ""
131131
132#: init/job.c:975132#: init/job.c:981
133msgid "respawn"133msgid "respawn"
134msgstr ""134msgstr ""
135135
136#: init/job.c:1020136#: init/job.c:1026
137msgid "waiting"137msgid "waiting"
138msgstr ""138msgstr ""
139139
140#: init/job.c:1022140#: init/job.c:1028
141msgid "starting"141msgid "starting"
142msgstr ""142msgstr ""
143143
144#: init/job.c:1024 init/process.c:80144#: init/job.c:1030 init/process.c:80
145msgid "pre-start"145msgid "pre-start"
146msgstr ""146msgstr ""
147147
148#: init/job.c:1026148#: init/job.c:1032
149msgid "spawned"149msgid "spawned"
150msgstr ""150msgstr ""
151151
152#: init/job.c:1028 init/process.c:82152#: init/job.c:1034 init/process.c:82
153msgid "post-start"153msgid "post-start"
154msgstr ""154msgstr ""
155155
156#: init/job.c:1030156#: init/job.c:1036
157msgid "running"157msgid "running"
158msgstr ""158msgstr ""
159159
160#: init/job.c:1032 init/process.c:84160#: init/job.c:1038 init/process.c:84
161msgid "pre-stop"161msgid "pre-stop"
162msgstr ""162msgstr ""
163163
164#: init/job.c:1034164#: init/job.c:1040
165msgid "stopping"165msgid "stopping"
166msgstr ""166msgstr ""
167167
168#: init/job.c:1036168#: init/job.c:1042
169msgid "killed"169msgid "killed"
170msgstr ""170msgstr ""
171171
172#: init/job.c:1038 init/process.c:86172#: init/job.c:1044 init/process.c:86
173msgid "post-stop"173msgid "post-stop"
174msgstr ""174msgstr ""
175175
176#: init/job.c:1121 init/job.c:1196 init/job.c:1272 init/job_class.c:750176#: init/job.c:1127 init/job.c:1202 init/job.c:1278 init/job_class.c:770
177#: init/job_class.c:880 init/job_class.c:1015177#: init/job_class.c:900 init/job_class.c:1035
178#, c-format178#, c-format
179msgid "You do not have permission to modify job: %s"179msgid "You do not have permission to modify job: %s"
180msgstr ""180msgstr ""
181181
182#: init/job.c:1129 init/job_class.c:804182#: init/job.c:1135 init/job_class.c:824
183#, c-format183#, c-format
184msgid "Job is already running: %s"184msgid "Job is already running: %s"
185msgstr ""185msgstr ""
186186
187#: init/job.c:1204 init/job.c:1280 init/job_class.c:934 init/job_class.c:1068187#: init/job.c:1210 init/job.c:1286 init/job_class.c:954 init/job_class.c:1088
188#, c-format188#, c-format
189msgid "Job has already been stopped: %s"189msgid "Job has already been stopped: %s"
190msgstr ""190msgstr ""
191191
192#: init/job_class.c:596 init/job_class.c:641 init/job_class.c:926192#: init/job_class.c:616 init/job_class.c:661 init/job_class.c:946
193#: init/job_class.c:1060193#: init/job_class.c:1080
194#, c-format194#, c-format
195msgid "Unknown instance: %s"195msgid "Unknown instance: %s"
196msgstr ""196msgstr ""
197197
198#: init/job_process.c:278198#: init/job_process.c:279
199#, c-format199#, c-format
200msgid "Failed to spawn %s %s process: %s"200msgid "Failed to spawn %s %s process: %s"
201msgstr ""201msgstr ""
202202
203#: init/job_process.c:284203#: init/job_process.c:285
204msgid "Temporary process spawn error"204msgid "Temporary process spawn error"
205msgstr ""205msgstr ""
206206
207#: init/job_process.c:291207#: init/job_process.c:292
208#, c-format208#, c-format
209msgid "%s %s process (%d)"209msgid "%s %s process (%d)"
210msgstr ""210msgstr ""
211211
212#: init/job_process.c:391212#: init/job_process.c:392
213#, c-format213#, c-format
214msgid "Pausing %s (%d) [pre-exec] for debug"214msgid "Pausing %s (%d) [pre-exec] for debug"
215msgstr ""215msgstr ""
216216
217#: init/job_process.c:445217#: init/job_process.c:446
218#, c-format218#, c-format
219msgid "Failed to open system console: %s"219msgid "Failed to open system console: %s"
220msgstr ""220msgstr ""
221221
222#: init/job_process.c:661222#: init/job_process.c:720
223#, c-format223#, c-format
224msgid "unable to open console: %s"224msgid "unable to open console: %s"
225msgstr ""225msgstr ""
226226
227#: init/job_process.c:716227#: init/job_process.c:775
228#, c-format228#, c-format
229msgid "unable to set \"%s\" resource limit: %s"229msgid "unable to set \"%s\" resource limit: %s"
230msgstr ""230msgstr ""
231231
232#: init/job_process.c:721232#: init/job_process.c:780
233#, c-format233#, c-format
234msgid "unable to set priority: %s"234msgid "unable to set priority: %s"
235msgstr ""235msgstr ""
236236
237#: init/job_process.c:726237#: init/job_process.c:785
238#, c-format238#, c-format
239msgid "unable to set oom adjustment: %s"239msgid "unable to set oom adjustment: %s"
240msgstr ""240msgstr ""
241241
242#: init/job_process.c:731242#: init/job_process.c:790
243#, c-format243#, c-format
244msgid "unable to change root directory: %s"244msgid "unable to change root directory: %s"
245msgstr ""245msgstr ""
246246
247#: init/job_process.c:736247#: init/job_process.c:795
248#, c-format248#, c-format
249msgid "unable to change working directory: %s"249msgid "unable to change working directory: %s"
250msgstr ""250msgstr ""
251251
252#: init/job_process.c:741252#: init/job_process.c:800
253#, c-format253#, c-format
254msgid "unable to set trace: %s"254msgid "unable to set trace: %s"
255msgstr ""255msgstr ""
256256
257#: init/job_process.c:746257#: init/job_process.c:805
258#, c-format258#, c-format
259msgid "unable to execute: %s"259msgid "unable to execute: %s"
260msgstr ""260msgstr ""
261261
262#: init/job_process.c:777262#: init/job_process.c:836
263#, c-format263#, c-format
264msgid "Sending TERM signal to %s %s process (%d)"264msgid "Sending TERM signal to %s %s process (%d)"
265msgstr ""265msgstr ""
266266
267#: init/job_process.c:785267#: init/job_process.c:844
268#, c-format268#, c-format
269msgid "Failed to send TERM signal to %s %s process (%d): %s"269msgid "Failed to send TERM signal to %s %s process (%d): %s"
270msgstr ""270msgstr ""
271271
272#: init/job_process.c:825272#: init/job_process.c:884
273#, c-format273#, c-format
274msgid "Sending KILL signal to %s %s process (%d)"274msgid "Sending KILL signal to %s %s process (%d)"
275msgstr ""275msgstr ""
276276
277#: init/job_process.c:833277#: init/job_process.c:892
278#, c-format278#, c-format
279msgid "Failed to send KILL signal to %s %s process (%d): %s"279msgid "Failed to send KILL signal to %s %s process (%d): %s"
280msgstr ""280msgstr ""
281281
282#: init/job_process.c:882282#: init/job_process.c:941
283#, c-format283#, c-format
284msgid "%s %s process (%d) terminated with status %d"284msgid "%s %s process (%d) terminated with status %d"
285msgstr ""285msgstr ""
286286
287#: init/job_process.c:887287#: init/job_process.c:946
288#, c-format288#, c-format
289msgid "%s %s process (%d) exited normally"289msgid "%s %s process (%d) exited normally"
290msgstr ""290msgstr ""
291291
292#: init/job_process.c:902292#: init/job_process.c:961
293#, c-format293#, c-format
294msgid "%s %s process (%d) killed by %s signal"294msgid "%s %s process (%d) killed by %s signal"
295msgstr ""295msgstr ""
296296
297#: init/job_process.c:906297#: init/job_process.c:965
298#, c-format298#, c-format
299msgid "%s %s process (%d) killed by signal %d"299msgid "%s %s process (%d) killed by signal %d"
300msgstr ""300msgstr ""
301301
302#: init/job_process.c:920302#: init/job_process.c:979
303#, c-format303#, c-format
304msgid "%s %s process (%d) stopped by %s signal"304msgid "%s %s process (%d) stopped by %s signal"
305msgstr ""305msgstr ""
306306
307#: init/job_process.c:924307#: init/job_process.c:983
308#, c-format308#, c-format
309msgid "%s %s process (%d) stopped by signal %d"309msgid "%s %s process (%d) stopped by signal %d"
310msgstr ""310msgstr ""
311311
312#: init/job_process.c:938312#: init/job_process.c:997
313#, c-format313#, c-format
314msgid "%s %s process (%d) continued by %s signal"314msgid "%s %s process (%d) continued by %s signal"
315msgstr ""315msgstr ""
316316
317#: init/job_process.c:942317#: init/job_process.c:1001
318#, c-format318#, c-format
319msgid "%s %s process (%d) continued by signal %d"319msgid "%s %s process (%d) continued by signal %d"
320msgstr ""320msgstr ""
321321
322#: init/job_process.c:1077322#: init/job_process.c:1136
323#, c-format323#, c-format
324msgid "%s respawning too fast, stopped"324msgid "%s respawning too fast, stopped"
325msgstr ""325msgstr ""
326326
327#: init/job_process.c:1083327#: init/job_process.c:1142
328#, c-format328#, c-format
329msgid "%s %s process ended, respawning"329msgid "%s %s process ended, respawning"
330msgstr ""330msgstr ""
331331
332#: init/job_process.c:1323332#: init/job_process.c:1382
333#, c-format333#, c-format
334msgid "Failed to set ptrace options for %s %s process (%d): %s"334msgid "Failed to set ptrace options for %s %s process (%d): %s"
335msgstr ""335msgstr ""
336336
337#: init/job_process.c:1336 init/job_process.c:1531337#: init/job_process.c:1395 init/job_process.c:1590
338#, c-format338#, c-format
339msgid "Failed to continue traced %s %s process (%d): %s"339msgid "Failed to continue traced %s %s process (%d): %s"
340msgstr ""340msgstr ""
341341
342#: init/job_process.c:1376 init/job_process.c:1467 init/job_process.c:1522342#: init/job_process.c:1435 init/job_process.c:1526 init/job_process.c:1581
343#, c-format343#, c-format
344msgid "Failed to detach traced %s %s process (%d): %s"344msgid "Failed to detach traced %s %s process (%d): %s"
345msgstr ""345msgstr ""
346346
347#: init/job_process.c:1416347#: init/job_process.c:1475
348#, c-format348#, c-format
349msgid "Failed to deliver signal to traced %s %s process (%d): %s"349msgid "Failed to deliver signal to traced %s %s process (%d): %s"
350msgstr ""350msgstr ""
351351
352#: init/job_process.c:1451352#: init/job_process.c:1510
353#, c-format353#, c-format
354msgid "Failed to obtain child process id for %s %s process (%d): %s"354msgid "Failed to obtain child process id for %s %s process (%d): %s"
355msgstr ""355msgstr ""
356356
357#: init/job_process.c:1458357#: init/job_process.c:1517
358#, c-format358#, c-format
359msgid "%s %s process (%d) became new process (%d)"359msgid "%s %s process (%d) became new process (%d)"
360msgstr ""360msgstr ""
361361
362#: init/job_process.c:1517362#: init/job_process.c:1576
363#, c-format363#, c-format
364msgid "%s %s process (%d) executable changed"364msgid "%s %s process (%d) executable changed"
365msgstr ""365msgstr ""
366366
367#: init/main.c:122367#: init/main.c:124
368msgid "specify alternative directory to load configuration files from"368msgid "specify alternative directory to load configuration files from"
369msgstr ""369msgstr ""
370370
371#: init/main.c:125371#: init/main.c:127
372msgid "specify an alternative initial event (for testing)"372msgid "specify an alternative initial event (for testing)"
373msgstr ""373msgstr ""
374374
375#: init/main.c:128375#: init/main.c:130
376msgid "do not emit any startup event (for testing)"376msgid "do not emit any startup event (for testing)"
377msgstr ""377msgstr ""
378378
379#: init/main.c:133379#: init/main.c:133
380msgid "Disable user and chroot sessions"
381msgstr ""
382
383#: init/main.c:138
380msgid "use D-Bus session bus rather than system bus (for testing)"384msgid "use D-Bus session bus rather than system bus (for testing)"
381msgstr ""385msgstr ""
382386
383#: init/main.c:153387#: init/main.c:158
384msgid "Process management daemon."388msgid "Process management daemon."
385msgstr ""389msgstr ""
386390
387#: init/main.c:155391#: init/main.c:160
388msgid ""392msgid ""
389"This daemon is normally executed by the kernel and given process id 1 to "393"This daemon is normally executed by the kernel and given process id 1 to "
390"denote its special status. When executed by a user process, it will "394"denote its special status. When executed by a user process, it will "
391"actually run /sbin/telinit."395"actually run /sbin/telinit."
392msgstr ""396msgstr ""
393397
394#: init/main.c:171 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148398#: init/main.c:176 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148
395msgid "Need to be root"399msgid "Need to be root"
396msgstr ""400msgstr ""
397401
398#: init/main.c:180402#: init/main.c:185
399msgid "Not being executed as init"403msgid "Not being executed as init"
400msgstr ""404msgstr ""
401405
402#: init/main.c:230 init/main.c:459406#: init/main.c:235 init/main.c:467
403msgid "Unable to set root directory"407msgid "Unable to set root directory"
404msgstr ""408msgstr ""
405409
406#: init/main.c:241410#: init/main.c:246
407msgid "Unable to mount /proc filesystem"411msgid "Unable to mount /proc filesystem"
408msgstr ""412msgstr ""
409413
410#: init/main.c:250414#: init/main.c:255
411msgid "Unable to mount /sys filesystem"415msgid "Unable to mount /sys filesystem"
412msgstr ""416msgstr ""
413417
414#: init/main.c:346418#: init/main.c:351
415msgid "Unable to listen for private connections"419msgid "Unable to listen for private connections"
416msgstr ""420msgstr ""
417421
418#: init/main.c:476422#: init/main.c:484
419#, c-format423#, c-format
420msgid "Caught %s, core dumped"424msgid "Caught %s, core dumped"
421msgstr ""425msgstr ""
422426
423#: init/main.c:480427#: init/main.c:488
424#, c-format428#, c-format
425msgid "Caught %s, unable to dump core"429msgid "Caught %s, unable to dump core"
426msgstr ""430msgstr ""
427431
428#: init/main.c:566432#: init/main.c:574
429msgid "Reconnecting to system bus"433msgid "Reconnecting to system bus"
430msgstr ""434msgstr ""
431435
432#: init/main.c:572436#: init/main.c:580
433msgid "Unable to connect to the system bus"437msgid "Unable to connect to the system bus"
434msgstr ""438msgstr ""
435439
@@ -437,98 +441,110 @@
437msgid "main"441msgid "main"
438msgstr ""442msgstr ""
439443
440#: util/initctl.c:310444#: util/initctl.c:318
441msgid "Unable to connect to system bus"445msgid "Unable to connect to system bus"
442msgstr ""446msgstr ""
443447
444#: util/initctl.c:311448#: util/initctl.c:319
445msgid "Unable to connect to session bus"449msgid "Unable to connect to session bus"
446msgstr ""450msgstr ""
447451
448#: util/initctl.c:320452#: util/initctl.c:328
449#, c-format453#, c-format
450msgid "%s: --dest given without --system\n"454msgid "%s: --dest given without --system\n"
451msgstr ""455msgstr ""
452456
453#: util/initctl.c:328457#: util/initctl.c:336
454msgid "Unable to connect to Upstart"458msgid "Unable to connect to Upstart"
455msgstr ""459msgstr ""
456460
457#: util/initctl.c:514 util/initctl.c:649 util/initctl.c:777 util/initctl.c:912461#: util/initctl.c:522 util/initctl.c:657 util/initctl.c:785 util/initctl.c:920
458#: util/initctl.c:1017462#: util/initctl.c:1025
459#, c-format463#, c-format
460msgid "%s: missing job name\n"464msgid "%s: missing job name\n"
461msgstr ""465msgstr ""
462466
463#: util/initctl.c:963467#: util/initctl.c:971
464msgid "Not running"468msgid "Not running"
465msgstr ""469msgstr ""
466470
467#: util/initctl.c:1319471#: util/initctl.c:1327
468#, c-format472#, c-format
469msgid "%s: missing event name\n"473msgid "%s: missing event name\n"
470msgstr ""474msgstr ""
471475
472#: util/initctl.c:1517476#: util/initctl.c:1525
473msgid "Invalid job class"477msgid "Invalid job class"
474msgstr ""478msgstr ""
475479
476#: util/initctl.c:2218480#: util/initctl.c:2122
481msgid "unknown event"
482msgstr ""
483
484#: util/initctl.c:2126
485msgid "unknown job"
486msgstr ""
487
488#: util/initctl.c:2227
477msgid "use D-Bus session bus to connect to init daemon (for testing)"489msgid "use D-Bus session bus to connect to init daemon (for testing)"
478msgstr ""490msgstr ""
479491
480#: util/initctl.c:2220492#: util/initctl.c:2229
481msgid "use D-Bus system bus to connect to init daemon"493msgid "use D-Bus system bus to connect to init daemon"
482msgstr ""494msgstr ""
483495
484#: util/initctl.c:2222496#: util/initctl.c:2231
485msgid "destination well-known name on D-Bus bus"497msgid "destination well-known name on D-Bus bus"
486msgstr ""498msgstr ""
487499
488#: util/initctl.c:2235500#: util/initctl.c:2244
489msgid "do not wait for job to start before exiting"501msgid "do not wait for job to start before exiting"
490msgstr ""502msgstr ""
491503
492#: util/initctl.c:2247504#: util/initctl.c:2256
493msgid "do not wait for job to stop before exiting"505msgid "do not wait for job to stop before exiting"
494msgstr ""506msgstr ""
495507
496#: util/initctl.c:2259508#: util/initctl.c:2268
497msgid "do not wait for job to restart before exiting"509msgid "do not wait for job to restart before exiting"
498msgstr ""510msgstr ""
499511
500#: util/initctl.c:2298512#: util/initctl.c:2307
501msgid "do not wait for event to finish before exiting"513msgid "do not wait for event to finish before exiting"
502msgstr ""514msgstr ""
503515
504#: util/initctl.c:2339516#: util/initctl.c:2348
505msgid ""517msgid ""
506"enumerate list of events and jobs causing job created from job config to "518"enumerate list of events and jobs causing job created from job config to "
507"start/stop"519"start/stop"
508msgstr ""520msgstr ""
509521
510#: util/initctl.c:2352522#: util/initctl.c:2361
511msgid "ignore specified list of events (comma-separated)"523msgid "ignore specified list of events (comma-separated)"
512msgstr ""524msgstr ""
513525
514#: util/initctl.c:2361526#: util/initctl.c:2363
527msgid "Generate warning for any unreachable events/jobs"
528msgstr ""
529
530#: util/initctl.c:2372
515msgid "Job"531msgid "Job"
516msgstr ""532msgstr ""
517533
518#: util/initctl.c:2368534#: util/initctl.c:2379
519msgid "Event"535msgid "Event"
520msgstr ""536msgstr ""
521537
522#: util/initctl.c:2376 util/initctl.c:2388 util/initctl.c:2399538#: util/initctl.c:2387 util/initctl.c:2399 util/initctl.c:2410
523#: util/initctl.c:2410 util/initctl.c:2417539#: util/initctl.c:2421 util/initctl.c:2428
524msgid "JOB [KEY=VALUE]..."540msgid "JOB [KEY=VALUE]..."
525msgstr ""541msgstr ""
526542
527#: util/initctl.c:2377543#: util/initctl.c:2388
528msgid "Start job."544msgid "Start job."
529msgstr ""545msgstr ""
530546
531#: util/initctl.c:2378547#: util/initctl.c:2389
532msgid ""548msgid ""
533"JOB is the name of the job that is to be started, this may be followed by "549"JOB is the name of the job that is to be started, this may be followed by "
534"zero or more environment variables to be defined in the new job.\n"550"zero or more environment variables to be defined in the new job.\n"
@@ -538,11 +554,11 @@
538"an existing instance is already running."554"an existing instance is already running."
539msgstr ""555msgstr ""
540556
541#: util/initctl.c:2389557#: util/initctl.c:2400
542msgid "Stop job."558msgid "Stop job."
543msgstr ""559msgstr ""
544560
545#: util/initctl.c:2390561#: util/initctl.c:2401
546msgid ""562msgid ""
547"JOB is the name of the job that is to be stopped, this may be followed by "563"JOB is the name of the job that is to be stopped, this may be followed by "
548"zero or more environment variables to be passed to the job's pre-stop and "564"zero or more environment variables to be passed to the job's pre-stop and "
@@ -552,11 +568,11 @@
552"decide which of multiple instances will be stopped."568"decide which of multiple instances will be stopped."
553msgstr ""569msgstr ""
554570
555#: util/initctl.c:2400571#: util/initctl.c:2411
556msgid "Restart job."572msgid "Restart job."
557msgstr ""573msgstr ""
558574
559#: util/initctl.c:2401575#: util/initctl.c:2412
560msgid ""576msgid ""
561"JOB is the name of the job that is to be restarted, this may be followed by "577"JOB is the name of the job that is to be restarted, this may be followed by "
562"zero or more environment variables to be defined in the job after "578"zero or more environment variables to be defined in the job after "
@@ -566,66 +582,66 @@
566"decide which of multiple instances will be restarted."582"decide which of multiple instances will be restarted."
567msgstr ""583msgstr ""
568584
569#: util/initctl.c:2411585#: util/initctl.c:2422
570msgid "Send HUP signal to job."586msgid "Send HUP signal to job."
571msgstr ""587msgstr ""
572588
573#: util/initctl.c:2412589#: util/initctl.c:2423
574msgid ""590msgid ""
575"JOB is the name of the job that is to be sent the signal, this may be "591"JOB is the name of the job that is to be sent the signal, this may be "
576"followed by zero or more environment variables to distinguish between job "592"followed by zero or more environment variables to distinguish between job "
577"instances.\n"593"instances.\n"
578msgstr ""594msgstr ""
579595
580#: util/initctl.c:2418596#: util/initctl.c:2429
581msgid "Query status of job."597msgid "Query status of job."
582msgstr ""598msgstr ""
583599
584#: util/initctl.c:2419600#: util/initctl.c:2430
585msgid ""601msgid ""
586"JOB is the name of the job that is to be queried, this may be followed by "602"JOB is the name of the job that is to be queried, this may be followed by "
587"zero or more environment variables to distguish between job instances.\n"603"zero or more environment variables to distguish between job instances.\n"
588msgstr ""604msgstr ""
589605
590#: util/initctl.c:2425606#: util/initctl.c:2436
591msgid "List known jobs."607msgid "List known jobs."
592msgstr ""608msgstr ""
593609
594#: util/initctl.c:2426610#: util/initctl.c:2437
595msgid "The known jobs and their current status will be output."611msgid "The known jobs and their current status will be output."
596msgstr ""612msgstr ""
597613
598#: util/initctl.c:2429614#: util/initctl.c:2440
599msgid "EVENT [KEY=VALUE]..."615msgid "EVENT [KEY=VALUE]..."
600msgstr ""616msgstr ""
601617
602#: util/initctl.c:2430618#: util/initctl.c:2441
603msgid "Emit an event."619msgid "Emit an event."
604msgstr ""620msgstr ""
605621
606#: util/initctl.c:2431622#: util/initctl.c:2442
607msgid ""623msgid ""
608"EVENT is the name of an event the init daemon should emit, this may be "624"EVENT is the name of an event the init daemon should emit, this may be "
609"followed by zero or more environment variables to be included in the event.\n"625"followed by zero or more environment variables to be included in the event.\n"
610msgstr ""626msgstr ""
611627
612#: util/initctl.c:2437628#: util/initctl.c:2448
613msgid "Reload the configuration of the init daemon."629msgid "Reload the configuration of the init daemon."
614msgstr ""630msgstr ""
615631
616#: util/initctl.c:2441632#: util/initctl.c:2452
617msgid "Request the version of the init daemon."633msgid "Request the version of the init daemon."
618msgstr ""634msgstr ""
619635
620#: util/initctl.c:2444636#: util/initctl.c:2455
621msgid "[PRIORITY]"637msgid "[PRIORITY]"
622msgstr ""638msgstr ""
623639
624#: util/initctl.c:2445640#: util/initctl.c:2456
625msgid "Change the minimum priority of log messages from the init daemon"641msgid "Change the minimum priority of log messages from the init daemon"
626msgstr ""642msgstr ""
627643
628#: util/initctl.c:2447644#: util/initctl.c:2458
629msgid ""645msgid ""
630"PRIORITY may be one of:\n"646"PRIORITY may be one of:\n"
631" `debug' (messages useful for debugging upstart are logged, equivalent to --"647" `debug' (messages useful for debugging upstart are logged, equivalent to --"
@@ -642,25 +658,25 @@
642"Without arguments, this outputs the current log priority."658"Without arguments, this outputs the current log priority."
643msgstr ""659msgstr ""
644660
645#: util/initctl.c:2464 util/initctl.c:2470661#: util/initctl.c:2475 util/initctl.c:2481
646msgid "[CONF]"662msgid "[CONF]"
647msgstr ""663msgstr ""
648664
649#: util/initctl.c:2465665#: util/initctl.c:2476
650msgid "Show emits, start on and stop on details for job configurations."666msgid "Show emits, start on and stop on details for job configurations."
651msgstr ""667msgstr ""
652668
653#: util/initctl.c:2466669#: util/initctl.c:2477
654msgid ""670msgid ""
655"If CONF specified, show configuration details for single job configuration, "671"If CONF specified, show configuration details for single job configuration, "
656"else show details for all jobs configurations.\n"672"else show details for all jobs configurations.\n"
657msgstr ""673msgstr ""
658674
659#: util/initctl.c:2471675#: util/initctl.c:2482
660msgid "Check for unreachable jobs/event conditions."676msgid "Check for unreachable jobs/event conditions."
661msgstr ""677msgstr ""
662678
663#: util/initctl.c:2472679#: util/initctl.c:2483
664msgid ""680msgid ""
665"List all jobs and events which cannot be satisfied by currently available "681"List all jobs and events which cannot be satisfied by currently available "
666"job configuration files"682"job configuration files"
667683
=== modified file 'scripts/init-checkconf.sh'
--- scripts/init-checkconf.sh 2011-03-10 14:06:37 +0000
+++ scripts/init-checkconf.sh 2011-04-19 09:27:29 +0000
@@ -1,7 +1,11 @@
1#!/bin/bash1#!/bin/bash
2#---------------------------------------------------------------------2#---------------------------------------------------------------------
3# Script to determine if specified config file is valid or not3# Script to determine if specified config file is valid or not.
4# (whether upstart can parse it successfully).4# By default, two checks are performed:
5#
6# - Ensure Upstart can parse overall file successfully
7# - Ensure all script sections are parseable by shell
8#
5#---------------------------------------------------------------------9#---------------------------------------------------------------------
6#10#
7# Copyright (C) 2011 Canonical Ltd.11# Copyright (C) 2011 Canonical Ltd.
@@ -29,6 +33,7 @@
29debug_enabled=n33debug_enabled=n
30file_valid=n34file_valid=n
31running=n35running=n
36check_scripts=y
3237
33cleanup()38cleanup()
34{39{
@@ -55,6 +60,7 @@
55 --file=<file> (no default).60 --file=<file> (no default).
56 -i <path>, : Specify path to initctl binary61 -i <path>, : Specify path to initctl binary
57 --initctl-path=<path> (default=$initctl_path).62 --initctl-path=<path> (default=$initctl_path).
63 -s, --noscript : Do not check script sections.
58 -x <path> : Specify path to init daemon binary64 -x <path> : Specify path to init daemon binary
59 --upstart-path=<path> (default=$upstart_path).65 --upstart-path=<path> (default=$upstart_path).
60 -h, --help : Show this help.66 -h, --help : Show this help.
@@ -85,8 +91,8 @@
85args=$(getopt \91args=$(getopt \
86 -n "$script_name" \92 -n "$script_name" \
87 -a \93 -a \
88 --options="df:hi:x:" \94 --options="df:hi:sx:" \
89 --longoptions="debug file: help initctl-path: upstart-path:" \95 --longoptions="debug file: help initctl-path: noscript upstart-path:" \
90 -- "$@")96 -- "$@")
9197
92eval set -- "$args"98eval set -- "$args"
@@ -115,6 +121,10 @@
115 shift121 shift
116 ;;122 ;;
117123
124 -s|--noscript)
125 check_scripts=n
126 ;;
127
118 -x|--upstart-path)128 -x|--upstart-path)
119 upstart_path="$2"129 upstart_path="$2"
120 shift130 shift
@@ -165,7 +175,7 @@
165debug "upstart_out=$upstart_out"175debug "upstart_out=$upstart_out"
166176
167upstart_cmd=$(printf \177upstart_cmd=$(printf \
168 "%s --session --no-startup-event --verbose --confdir %s" \178 "%s --session --no-sessions --no-startup-event --verbose --confdir %s" \
169 "$upstart_path" \179 "$upstart_path" \
170 "$confdir")180 "$confdir")
171debug "upstart_cmd=$upstart_cmd"181debug "upstart_cmd=$upstart_cmd"
@@ -177,7 +187,7 @@
177# We handle this ourselves in cleanup().187# We handle this ourselves in cleanup().
178disown 188disown
179189
180# wait for upstart to initialize190# wait for Upstart to initialize
181for i in $(seq 1 5)191for i in $(seq 1 5)
182do192do
183 debug "Waiting for Upstart to reply over D-Bus (attempt $i)"193 debug "Waiting for Upstart to reply over D-Bus (attempt $i)"
@@ -193,9 +203,23 @@
193 sleep 1203 sleep 1
194done204done
195205
196[ $running = n ] && die "failed to start upstart"206[ $running = n ] && die "failed to ask Upstart to check conf file"
197207
198debug "upstart ($upstart_cmd) running with PID $upstart_pid"208debug "Secondary Upstart ($upstart_cmd) running with PID $upstart_pid"
209
210if [ "$check_scripts" = y ]
211then
212 for section in pre-start post-start script pre-stop post-stop
213 do
214 if egrep -q "\<${section}\>" "$file"
215 then
216 cmd='sed -n "/^ *${section}/,/^ *end script/p" $file | /bin/sh -n 2>&1'
217 errors=$(eval "$cmd")
218 [ $? -ne 0 ] && \
219 die "$(printf "File $file: shell syntax invalid in $section section:\n${errors}")"
220 fi
221 done
222fi
199223
200if "$initctl_path" --session status "$job" >/dev/null 2>&1224if "$initctl_path" --session status "$job" >/dev/null 2>&1
201then225then
@@ -205,4 +229,4 @@
205fi229fi
206230
207errors=$(grep "$job" "$upstart_out"|sed "s,${confdir}/,,g")231errors=$(grep "$job" "$upstart_out"|sed "s,${confdir}/,,g")
208error "File $file: syntax invalid ($errors)"232die "$(printf "File $file: syntax invalid:\n${errors}")"
209233
=== modified file 'scripts/man/init-checkconf.8'
--- scripts/man/init-checkconf.8 2011-03-07 15:02:20 +0000
+++ scripts/man/init-checkconf.8 2011-04-19 09:27:29 +0000
@@ -1,39 +1,49 @@
1.TH init-checkconf 8 2011-03-07 "Upstart"1.TH init\-checkconf 8 2011-04-06 "Upstart"
2.\"2.\"
3.SH NAME3.SH NAME
4init-checkconf \- manual page for init-checkconf4init\-checkconf \- manual page for init-checkconf
5.\"5.\"
6.SH SYNOPSIS6.SH SYNOPSIS
7.B init-checkconf7.B init\-checkconf
8.RI [ OPTIONS ] " file "8.RI [ OPTIONS ] " file "
99
10.B init-checkconf10.B init\-checkconf
11.RI [ OPTIONS ] " " "-f" " file "11.RI [ OPTIONS ] " " "\-f" " file "
12.\"12.\"
13.SH DESCRIPTION13.SH DESCRIPTION
14Determine if specified Upstart14Determine if specified Upstart
15.BR init (8)15.BR init (8)
16job configuration file is valid.16job configuration file is valid.
17.P
18By default, two checks are performed:
19.IP \(bu 4
20Ensure Upstart can parse overall file successfully
21.IP \(bu 4
22Ensure all script sections are parseable by shell
23.P
17.\"24.\"
18.SH OPTIONS25.SH OPTIONS
19.TP26.TP
20.B -d27.BR \-d " , " \-\-debug
21Show some debug output.28Show some debug output.
22.TP29.TP
23.B -f \fIfile\fP30.BR \-f " \fIfile\fP" " , " \-\-file=\fIfile\fP
24Specify job configuration file to check.31Specify job configuration file to check.
25.TP32.TP
26.B -i \fIpath\fP33.BR \-i " \fIpath\fP" " , " \-\-initctl\-path=\fIpath\fP
27Specify path to34Specify path to
28.BR initctl (8)35.BR initctl (8)
29binary.36binary.
30.TP37.TP
31.B -x \fIpath\fP38.BR \-s " , " \-\-noscript
39Do not check script sections.
40.TP
41.BR \-x " \fIpath\fP" " , " \-\-upstart\-path=\fIpath\fP
32Specify path to42Specify path to
33.BR init (8)43.BR init (8)
34binary.44binary.
35.TP45.TP
36.B -h46.BR \-h " , " \-\-help
37Display usage statement.47Display usage statement.
38.\"48.\"
39.SH AUTHOR49.SH AUTHOR
@@ -51,4 +61,6 @@
51warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.61warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
52.\"62.\"
53.SH SEE ALSO63.SH SEE ALSO
64.BR sh (1)
65.BR init (5)
54.BR init (8)66.BR init (8)
5567
=== modified file 'util/initctl.c'
--- util/initctl.c 2011-03-15 12:15:28 +0000
+++ util/initctl.c 2011-04-19 09:27:29 +0000
@@ -194,6 +194,14 @@
194int check_config_mode = FALSE;194int check_config_mode = FALSE;
195195
196/**196/**
197 * check_config_warn:
198 *
199 * If TRUE, check-config will generate a warning for *any* unreachable
200 * events/jobs.
201 **/
202int check_config_warn = FALSE;
203
204/**
197 * check_config_data:205 * check_config_data:
198 *206 *
199 * Used to record details of all known jobs and events.207 * Used to record details of all known jobs and events.
@@ -1959,7 +1967,7 @@
1959 * this node based on children1967 * this node based on children
1960 * and type of operator.1968 * and type of operator.
1961 */1969 */
1962 if (IS_OP_AND (expr))1970 if (IS_OP_AND (expr) || check_config_warn)
1963 node->value = first->value && second->value;1971 node->value = first->value && second->value;
1964 else1972 else
1965 node->value = first->value || second->value;1973 node->value = first->value || second->value;
@@ -2110,12 +2118,13 @@
2110 const char *job = expr->job_in_error;2118 const char *job = expr->job_in_error;
21112119
2112 if (event)2120 if (event)
2113 nih_message (" %s: unknown event %s", condition, event);2121 nih_message (" %s: %s %s", condition,
2122 _("unknown event"), event);
21142123
2115 if (job)2124 if (job)
2116 nih_message (" %s: unknown job %s", condition, job);2125 nih_message (" %s: %s %s", condition,
2126 _("unknown job"), job);
2117 }2127 }
2118
2119}2128}
21202129
21212130
@@ -2349,8 +2358,10 @@
2349 * Command-line options accepted for the check-config command.2358 * Command-line options accepted for the check-config command.
2350 **/2359 **/
2351NihOption check_config_options[] = {2360NihOption check_config_options[] = {
2352 { 0, "ignore-events", N_("ignore specified list of events (comma-separated)"),2361 { 'i', "ignore-events", N_("ignore specified list of events (comma-separated)"),
2353 NULL, "EVENT_LIST", NULL, ignored_events_setter },2362 NULL, "EVENT_LIST", NULL, ignored_events_setter },
2363 { 'w', "warn", N_("Generate warning for any unreachable events/jobs"),
2364 NULL, NULL, &check_config_warn, NULL },
2354 NIH_OPTION_LAST2365 NIH_OPTION_LAST
2355};2366};
2356/**2367/**
23572368
=== modified file 'util/man/initctl.8'
--- util/man/initctl.8 2011-03-10 14:06:37 +0000
+++ util/man/initctl.8 2011-04-19 09:27:29 +0000
@@ -494,7 +494,7 @@
494494
495.B OPTIONS495.B OPTIONS
496.RS496.RS
497.IP "\fB\-\-ignore\-events\fP \fI[EVENTS]\fP"497.IP "\fB-i\fP \fI[EVENTS]\fP, \fB\-\-ignore\-events\fP \fI[EVENTS]\fP"
498498
499If specified, the argument should be a list of comma\-separated events to499If specified, the argument should be a list of comma\-separated events to
500ignore when checking the job configuration files.500ignore when checking the job configuration files.
@@ -504,6 +504,8 @@
504504
505Note that internal events (such as \fBstartup\fP(7) and505Note that internal events (such as \fBstartup\fP(7) and
506\fBstarting\fP(7)) are automatically ignored.506\fBstarting\fP(7)) are automatically ignored.
507.IP "\fB-w\fP, \fB\-\-warn\fP"
508If specified, treat \fIany\fP unknown jobs and events as errors.
507509
508.\"510.\"
509.SH AUTHOR511.SH AUTHOR
510512
=== modified file 'util/tests/test_initctl.c'
--- util/tests/test_initctl.c 2011-03-15 11:32:15 +0000
+++ util/tests/test_initctl.c 2011-04-19 09:27:29 +0000
@@ -49,6 +49,7 @@
49/* remember we run from the 'util' directory */49/* remember we run from the 'util' directory */
50#define UPSTART_BINARY "../init/init"50#define UPSTART_BINARY "../init/init"
51#define INITCTL_BINARY "./initctl --session"51#define INITCTL_BINARY "./initctl --session"
52
52#define BUFFER_SIZE 102453#define BUFFER_SIZE 1024
5354
54/**55/**
@@ -74,7 +75,9 @@
74 \75 \
75 if (pid == 0) \76 if (pid == 0) \
76 execlp (UPSTART_BINARY, UPSTART_BINARY, \77 execlp (UPSTART_BINARY, UPSTART_BINARY, \
77 "--session", "--no-startup-event", \78 "--session", \
79 "--no-startup-event", \
80 "--no-sessions", \
78 NULL); \81 NULL); \
79 \82 \
80 while (attempts) { \83 while (attempts) { \
@@ -138,11 +141,11 @@
138 * @len: size_t pointer which will be set to length of @result.141 * @len: size_t pointer which will be set to length of @result.
139 *142 *
140 * Run a command and return its standard output. It is the callers143 * Run a command and return its standard output. It is the callers
141 * responsibility to free @result.144 * responsibility to free @result. Errors from running @cmd are fatal.
142 **/145 **/
143#define RUN_COMMAND(parent, cmd, result, len) \146#define RUN_COMMAND(parent, cmd, result, len) \
144{ \147{ \
145 FILE *initctl; \148 FILE *f; \
146 char buffer[BUFFER_SIZE]; \149 char buffer[BUFFER_SIZE]; \
147 char **ret; \150 char **ret; \
148 \151 \
@@ -152,20 +155,20 @@
152 TEST_NE_P (*result, NULL); \155 TEST_NE_P (*result, NULL); \
153 *(len) = 0; \156 *(len) = 0; \
154 \157 \
155 initctl = popen (cmd, "r"); \158 f = popen (cmd, "r"); \
156 TEST_NE_P (initctl, NULL); \159 TEST_NE_P (f, NULL); \
157 \160 \
158 while (fgets (buffer, BUFFER_SIZE, initctl)) { \161 while (fgets (buffer, BUFFER_SIZE, f)) { \
159 size_t l = strlen(buffer)-1; \162 size_t l = strlen (buffer)-1; \
160 \163 \
161 if ( buffer[l] == '\n') \164 if ( buffer[l] == '\n') \
162 buffer[l] = '\0'; \165 buffer[l] = '\0'; \
163 ret = nih_str_array_add (result, parent, len, \166 ret = nih_str_array_add (result, parent, len, \
164 buffer); \167 buffer); \
165 TEST_NE_P (ret, NULL); \168 TEST_NE_P (ret, NULL); \
166 } \169 } \
167 \170 \
168 TEST_NE (pclose(initctl), -1); \171 TEST_NE ( pclose (f), -1); \
169}172}
170173
171/**174/**
@@ -10946,7 +10949,6 @@
10946 "author \"foo\"\n"10949 "author \"foo\"\n"
10947 "description \"wibble\"");10950 "description \"wibble\"");
1094810951
10949
10950 cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);10952 cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
10951 TEST_NE_P (cmd, NULL);10953 TEST_NE_P (cmd, NULL);
10952 RUN_COMMAND (NULL, cmd, &output, &lines);10954 RUN_COMMAND (NULL, cmd, &output, &lines);
@@ -11790,6 +11792,47 @@
1179011792
11791 /*******************************************************************/11793 /*******************************************************************/
1179211794
11795 TEST_FEATURE (
11796 "satisfiable complex start on, satisfiable complex stop on with warnings");
11797
11798 CREATE_FILE (dirname, "plymouth.conf",
11799 "start on (starting mountall\n"
11800 " or (hello\n"
11801 " and (stopped gdm\n"
11802 " or (stopped kdm\n"
11803 " or (stopped xdm\n"
11804 " or stopped lxdm)))))\n"
11805 "stop on (stopping portmap\n"
11806 " or (wibble or starting beano))\n");
11807
11808 CREATE_FILE (dirname, "mountall.conf", "exec true\n");
11809 CREATE_FILE (dirname, "portmap.conf",
11810 "exec true\n"
11811 "emits hello");
11812 CREATE_FILE (dirname, "lxdm.conf", "exec true");
11813 CREATE_FILE (dirname, "wibble.conf", "emits wibble");
11814 CREATE_FILE (dirname, "beano.conf", "exec true");
11815
11816 cmd = nih_sprintf (NULL, "%s check-config --warn 2>&1",
11817 INITCTL_BINARY);
11818 TEST_NE_P (cmd, NULL);
11819 RUN_COMMAND (NULL, cmd, &output, &lines);
11820
11821 TEST_EQ_STR (output[0], "plymouth");
11822 TEST_EQ_STR (output[1], " start on: unknown job xdm");
11823 TEST_EQ_STR (output[2], " start on: unknown job kdm");
11824 TEST_EQ_STR (output[3], " start on: unknown job gdm");
11825 TEST_EQ (lines, 4);
11826
11827 DELETE_FILE (dirname, "plymouth.conf");
11828 DELETE_FILE (dirname, "mountall.conf");
11829 DELETE_FILE (dirname, "portmap.conf");
11830 DELETE_FILE (dirname, "lxdm.conf");
11831 DELETE_FILE (dirname, "beano.conf");
11832 DELETE_FILE (dirname, "wibble.conf");
11833
11834 /*******************************************************************/
11835
11793 STOP_UPSTART (upstart_pid);11836 STOP_UPSTART (upstart_pid);
11794 TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0);11837 TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0);
11795}11838}

Subscribers

People subscribed via source and target branches

to all changes: