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
1=== modified file 'ChangeLog'
2--- ChangeLog 2011-03-24 14:33:36 +0000
3+++ ChangeLog 2011-04-19 09:27:29 +0000
4@@ -1,3 +1,65 @@
5+2011-04-15 James Hunt <james.hunt@ubuntu.com>
6+
7+ * init/conf.c:
8+ - conf_source_reload_file(): Added missing error return if override
9+ doesn't parse (code path currently unused).
10+ - Documentation updates.
11+ * init/job.c: job_new(): Fix for nasty OOM scenario when an attempt is made
12+ to start a chroot job with same name as running single-instance non-chroot
13+ job. Previously, the path for a chrooted Job was set from the (nul) instance
14+ name of its parent JobClass. However, since that job instance name already
15+ existed outside the chroot and was already D-Bus registered,
16+ nih_dbus_object_new() (which allocates storage and is called by
17+ job_register()) returned NULL and kept doing so due to being called
18+ within NIH_MUST(). This resulted in OOM due to an as-yet unidentified
19+ D-Bus bug (possibly a leak in find_subtree_recurse()).
20+ * init/session.h: Documentation updates.
21+ * util/test_initctl.c: Cleaned up variable names
22+ in RUN_COMMAND macro.
23+ * init/parse_job.c: Documentation updates.
24+
25+2011-04-06 James Hunt <james.hunt@ubuntu.com>
26+
27+ * init/conf.c: conf_select_job(): Added Session parameter.
28+ * init/control.c: control_get_job_by_name(): Handle multiple jobs with same
29+ name (but different session) in job_classes hash.
30+ * init/job_class.c:
31+ - job_class_remove(): Added Session parameter.
32+ - job_class_consider(): Handle multiple jobs with same name
33+ (but different session) in job_classes hash.
34+ - job_class_reconsider(): Handle multiple jobs with same name
35+ (but different session) in job_classes hash.
36+ - job_class_remove(): Handle incorrect session.
37+ * init/job_process.c: job_process_spawn(): Updated for sessions and
38+ chroots.
39+ * init/job_process.h: New enums for:
40+ - JOB_PROCESS_ERROR_SETUID
41+ - JOB_PROCESS_ERROR_SETGID
42+ * init/session.c:
43+ - session_from_dbus(): Added ability to disable sessions.
44+ - Added disable_sessions variable, set via main().
45+ * init/session.h: Added tabular comment summarising Session object
46+ contents for different environments.
47+ * init/Makefile.am: Reverted special-casing for session.c.
48+ * init/main.c: Addition of new command-line option "--no-sessions" to
49+ disable chroot+user sessions (providing a "traditional" Upstart
50+ environment. The primary use for this option is the test suite.
51+ * init/man/init.8: Updates for "--no-sessions".
52+ * init/tests/test_*.c: Replaced explicit Sessions with NULL
53+ session since tests are not yet session-aware (with the exception of
54+ test_job_process.c, all main() functions now set the
55+ UPSTART_NO_SESSIONS variable to disable sessions).
56+ * util/tests/test_initctl.c:
57+ - START_UPSTART now specifies "--no-sessions"
58+ - test_check_config(): Added test for "--warn".
59+ * scripts/init-checkconf.sh: Script now also checks any script
60+ sections found unless the new "--noscript" option is specified.
61+ Added required "--no-sessions" option to upstart_cmd to ensure Upstart
62+ treats clients requests in traditional manner.
63+ * scripts/man/init-checkconf.8: Update for "--noscript".
64+ * util/initctl.c: Added "--warn" option for check-config command to
65+ warn if any events or jobs are not known.
66+
67 2011-03-24 James Hunt <james.hunt@ubuntu.com>
68
69 * init/tests/test_control.c: Added comment.
70
71=== modified file 'NEWS'
72--- NEWS 2011-03-24 14:33:36 +0000
73+++ NEWS 2011-04-19 09:27:29 +0000
74@@ -1,3 +1,24 @@
75+0.9.6 2011-04-15
76+
77+ * Fix for nasty OOM scenario when an attempt is made to start
78+ a chroot job with same name as running single-instance
79+ non-chroot job. Previously, the path for a chrooted Job
80+ was set from the (nul) instance name of its parent JobClass.
81+ However, since that job instance name already existed
82+ outside the chroot and was already D-Bus registered,
83+ nih_dbus_object_new() (which allocates storage and is
84+ called by job_register()) returned NULL and kept doing so
85+ due to being called within NIH_MUST(). This resulted in
86+ OOM due to an as-yet unidentified D-Bus bug (possibly a
87+ leak in find_subtree_recurse()).
88+
89+0.9.5 2011-04-06
90+
91+ * Important fixes for user and chroot sessions.
92+ * scripts/init-checkconf.sh: Now checks script sections too.
93+ * util/initctl.c: Added "--warn" option for check-config command
94+ to warn if any events or jobs are not known.
95+
96 0.9.4 2011-03-24
97
98 * scripts/initctl2dot.py: Fix to handle 'emits' glob syntax
99
100=== modified file 'configure.ac'
101--- configure.ac 2011-03-24 14:33:36 +0000
102+++ configure.ac 2011-04-19 09:27:29 +0000
103@@ -1,7 +1,7 @@
104 # Process this file with autoconf to produce a configure script.
105
106 AC_PREREQ(2.61)
107-AC_INIT([upstart], [0.9.4], [upstart-devel@lists.ubuntu.com])
108+AC_INIT([upstart], [0.9.6], [upstart-devel@lists.ubuntu.com])
109 NIH_COPYRIGHT([[Copyright © 2011 Canonical Ltd.]])
110 AC_CONFIG_SRCDIR([init/main.c])
111 AC_CONFIG_MACRO_DIR([m4])
112
113=== modified file 'debian/changelog'
114--- debian/changelog 2011-03-24 14:35:14 +0000
115+++ debian/changelog 2011-04-19 09:27:29 +0000
116@@ -1,3 +1,31 @@
117+upstart (0.9.6-1ubuntu1) natty; urgency=low
118+
119+ * init/man/init.5: Remove mention of user jobs since facility is
120+ disabled.
121+
122+ -- James Hunt <james.hunt@ubuntu.com> Fri, 15 Apr 2011 15:37:57 +0100
123+
124+upstart (0.9.6-1) natty; urgency=low
125+
126+ * New upstream release 0.9.6: Important session+chroot fixes.
127+
128+ -- James Hunt <james.hunt@ubuntu.com> Fri, 15 Apr 2011 15:36:40 +0100
129+
130+upstart (0.9.5-1ubuntu1) natty; urgency=low
131+
132+ [ Clint Byrum ]
133+ * debian/upstart-job: change behavior to reload job configuration on
134+ restart, which more closely matches expected sysvinit script
135+ behavior. (LP: #707479)
136+
137+ -- James Hunt <james.hunt@ubuntu.com> Wed, 06 Apr 2011 17:50:53 +0100
138+
139+upstart (0.9.5-1) natty; urgency=low
140+
141+ * New upstream release 0.9.5.
142+
143+ -- James Hunt <james.hunt@ubuntu.com> Wed, 06 Apr 2011 17:45:38 +0100
144+
145 upstart (0.9.4-1ubuntu1) natty; urgency=low
146
147 * debian/manpages/upstart-events.7:
148
149=== modified file 'debian/upstart-job'
150--- debian/upstart-job 2011-01-26 21:52:39 +0000
151+++ debian/upstart-job 2011-04-19 09:27:29 +0000
152@@ -44,7 +44,7 @@
153 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
154 $COMMAND "$JOB"
155 ;;
156-start|stop|restart)
157+start|stop)
158 $ECHO
159 $ECHO "Since the script you are attempting to invoke has been converted to an"
160 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
161@@ -55,12 +55,22 @@
162 exit 0
163 elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
164 exit 0
165- elif [ -z "$RUNNING" ] && [ "$COMMAND" = "restart" ]; then
166- start "$JOB"
167- exit 0
168 fi
169 $COMMAND "$JOB"
170 ;;
171+restart)
172+ $ECHO
173+ $ECHO "Since the script you are attempting to invoke has been converted to an"
174+ $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
175+ $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
176+ if status "$JOB" 2>/dev/null | grep -q ' start/'; then
177+ RUNNING=1
178+ fi
179+ if [ -n "$RUNNING" ] ; then
180+ stop "$JOB"
181+ fi
182+ start "$JOB"
183+ ;;
184 reload|force-reload)
185 $ECHO
186 $ECHO "Since the script you are attempting to invoke has been converted to an"
187
188=== modified file 'init/Makefile.am'
189--- init/Makefile.am 2011-02-24 15:41:04 +0000
190+++ init/Makefile.am 2011-04-19 09:27:29 +0000
191@@ -273,24 +273,26 @@
192 $(NIH_DBUS_LIBS) \
193 $(DBUS_LIBS)
194
195-test_conf_SOURCES = tests/test_conf.c session.c
196+test_conf_SOURCES = tests/test_conf.c
197 test_conf_CFLAGS = $(AM_CFLAGS) -DTEST
198 test_conf_LDADD = \
199 system.o environ.o process.o \
200 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
201 parse_job.o parse_conf.o conf.o control.o \
202+ session.o \
203 com.ubuntu.Upstart.o \
204 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
205 $(NIH_LIBS) \
206 $(NIH_DBUS_LIBS) \
207 $(DBUS_LIBS)
208
209-test_control_SOURCES = tests/test_control.c session.c
210+test_control_SOURCES = tests/test_control.c
211 test_control_CFLAGS = $(AM_CFLAGS) -DTEST
212 test_control_LDADD = \
213 system.o environ.o process.o \
214 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
215 parse_job.o parse_conf.o conf.o control.o \
216+ session.o \
217 com.ubuntu.Upstart.o \
218 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
219 $(NIH_LIBS) \
220
221=== modified file 'init/conf.c'
222--- init/conf.c 2011-02-23 11:04:27 +0000
223+++ init/conf.c 2011-04-19 09:27:29 +0000
224@@ -517,13 +517,10 @@
225 nih_debug ("Updating configuration for %s from %s",
226 source->path, override_path);
227 if (conf_reload_path (source, source->path, override_path) < 0) {
228- NihError *err;
229+ if (err)
230+ nih_free (err);
231
232- err = nih_error_get ();
233- nih_error ("%s: %s: %s", override_path,
234- _("Error while reloading configuration file"),
235- err->message);
236- nih_free (err);
237+ return -1;
238 }
239
240 return 0;
241@@ -935,7 +932,7 @@
242 * conf_reload_path:
243 * @source: configuration source,
244 * @path: path of conf file to be reloaded.
245- * @override_path: if TRUE and @path refers to a path associated with @source,
246+ * @override_path: if not NULL and @path refers to a path associated with @source,
247 * overlay the contents of @path into the existing @source entry for
248 * @path. If FALSE, discard any existing knowledge of @path.
249 *
250@@ -946,7 +943,8 @@
251 *
252 * If the file has been parsed before, then the existing item is deleted and
253 * freed if the file fails to load, or after the new item has been parsed.
254- * Items are not reused between reloads.
255+ * Items are only reused between reloads if @override_path is
256+ * non-NULL.
257 *
258 * Physical errors are returned, parse errors are not.
259 *
260@@ -968,12 +966,16 @@
261 nih_assert (source != NULL);
262 nih_assert (path != NULL);
263
264- path_to_load = ( override_path ? override_path : path);
265+ path_to_load = (override_path ? override_path : path);
266
267 /* If there is no corresponding override file, look up the old
268 * conf file in memory, and then free it. In cases of failure,
269 * we discard it anyway, so there's no particular reason
270 * to keep it around anymore.
271+ *
272+ * Note: if @override_path has been specified, do not
273+ * free the file if found, since we want to _update_ the
274+ * existing entry.
275 */
276 file = (ConfFile *)nih_hash_lookup (source->files, path);
277 if (! override_path && file)
278@@ -987,7 +989,7 @@
279 if (! buf)
280 return -1;
281
282- /* Create a new ConfFile structure (if no override_path was specified) */
283+ /* Create a new ConfFile structure (if no @override_path specified) */
284 file = (ConfFile *)nih_hash_lookup (source->files, path);
285 if (! file)
286 file = NIH_MUST (conf_file_new (source, path));
287@@ -1144,7 +1146,8 @@
288
289 /**
290 * conf_select_job:
291- * @name: name of job class to locate.
292+ * @name: name of job class to locate,
293+ * @session: session class name belongs to.
294 *
295 * Select the best available class of a job named @name from the registered
296 * configuration sources.
297@@ -1152,7 +1155,7 @@
298 * Returns: Best available job class or NULL if none available.
299 **/
300 JobClass *
301-conf_select_job (const char *name)
302+conf_select_job (const char *name, const Session *session)
303 {
304 nih_assert (name != NULL);
305
306@@ -1164,6 +1167,9 @@
307 if (source->type != CONF_JOB_DIR)
308 continue;
309
310+ if (source->session != session)
311+ continue;
312+
313 NIH_HASH_FOREACH (source->files, file_iter) {
314 ConfFile *file = (ConfFile *)file_iter;
315
316
317=== modified file 'init/conf.h'
318--- init/conf.h 2011-02-23 11:04:27 +0000
319+++ init/conf.h 2011-04-19 09:27:29 +0000
320@@ -125,7 +125,7 @@
321
322 int conf_file_destroy (ConfFile *file);
323
324-JobClass * conf_select_job (const char *name);
325+JobClass * conf_select_job (const char *name, const Session *session);
326
327 char *toggle_conf_name (const void *parent, const char *path)
328 __attribute__ ((warn_unused_result, malloc));
329
330=== modified file 'init/control.c'
331--- init/control.c 2011-03-10 14:06:37 +0000
332+++ init/control.c 2011-04-19 09:27:29 +0000
333@@ -417,7 +417,11 @@
334 session = session_from_dbus (NULL, message);
335
336 /* Lookup the job */
337- class = (JobClass *)nih_hash_lookup (job_classes, name);
338+ class = (JobClass *)nih_hash_search (job_classes, name, NULL);
339+
340+ while (class && class->session != session) {
341+ class = (JobClass *)nih_hash_search (job_classes, name, &class->entry);
342+ }
343
344 if (class && ! session)
345 class->session = session;
346
347=== modified file 'init/job.c'
348--- init/job.c 2011-02-23 10:38:33 +0000
349+++ init/job.c 2011-04-19 09:27:29 +0000
350@@ -100,8 +100,14 @@
351
352 job->class = class;
353
354- job->path = nih_dbus_path (job, DBUS_PATH_UPSTART, "jobs",
355- class->name, job->name, NULL);
356+ if (job->class->session && job->class->session->chroot) {
357+ /* JobClass already contains a valid D-Bus path prefix for the job */
358+ job->path = nih_dbus_path (job, class->path, job->name, NULL);
359+ } else {
360+ job->path = nih_dbus_path (job, DBUS_PATH_UPSTART, "jobs",
361+ class->name, job->name, NULL);
362+ }
363+
364 if (! job->path)
365 goto error;
366
367
368=== modified file 'init/job_class.c'
369--- init/job_class.c 2011-02-23 11:04:27 +0000
370+++ init/job_class.c 2011-04-19 09:27:29 +0000
371@@ -100,7 +100,7 @@
372
373 /* Prototypes for static functions */
374 static void job_class_add (JobClass *class);
375-static int job_class_remove (JobClass *class);
376+static int job_class_remove (JobClass *class, const Session *session);
377
378
379 /**
380@@ -280,19 +280,27 @@
381 int
382 job_class_consider (JobClass *class)
383 {
384- JobClass *registered, *best;
385+ JobClass *registered = NULL, *best = NULL;
386
387 nih_assert (class != NULL);
388
389 job_class_init ();
390
391- best = conf_select_job (class->name);
392+ best = conf_select_job (class->name, class->session);
393 nih_assert (best != NULL);
394-
395- registered = (JobClass *)nih_hash_lookup (job_classes, class->name);
396+ nih_assert (best->session == class->session);
397+
398+ registered = (JobClass *)nih_hash_search (job_classes, class->name, NULL);
399+
400+ /* If we found an entry, ensure we only consider the appropriate session */
401+ while (registered && registered->session != class->session)
402+ {
403+ registered = (JobClass *)nih_hash_search (job_classes, class->name, &registered->entry);
404+ }
405+
406 if (registered != best) {
407 if (registered)
408- if (! job_class_remove (registered))
409+ if (! job_class_remove (registered, class->session))
410 return FALSE;
411
412 job_class_add (best);
413@@ -317,18 +325,25 @@
414 int
415 job_class_reconsider (JobClass *class)
416 {
417- JobClass *registered, *best;
418+ JobClass *registered = NULL, *best = NULL;
419
420 nih_assert (class != NULL);
421
422 job_class_init ();
423
424- best = conf_select_job (class->name);
425-
426- registered = (JobClass *)nih_hash_lookup (job_classes, class->name);
427+ best = conf_select_job (class->name, class->session);
428+
429+ registered = (JobClass *)nih_hash_search (job_classes, class->name, NULL);
430+
431+ /* If we found an entry, ensure we only consider the appropriate session */
432+ while (registered && registered->session != class->session)
433+ {
434+ registered = (JobClass *)nih_hash_search (job_classes, class->name, &registered->entry);
435+ }
436+
437 if (registered == class) {
438 if (class != best) {
439- if (! job_class_remove (class))
440+ if (! job_class_remove (class, class->session))
441 return FALSE;
442
443 job_class_add (best);
444@@ -369,19 +384,24 @@
445
446 /**
447 * job_class_remove:
448- * @class: class to remove.
449+ * @class: class to remove,
450+ * @session: Session of @class.
451 *
452 * Removes @class from the hash table and unregisters it from all current
453 * D-Bus connections.
454 *
455 * Returns: TRUE if class could be unregistered, FALSE if there are
456- * active instances that prevent unregistration.
457+ * active instances that prevent unregistration, or if @session
458+ * does not match the session associated with @class.
459 **/
460 static int
461-job_class_remove (JobClass *class)
462+job_class_remove (JobClass *class, const Session *session)
463 {
464 nih_assert (class != NULL);
465
466+ if (class->session != session)
467+ return FALSE;
468+
469 control_init ();
470
471 /* Return if we have any active instances */
472
473=== modified file 'init/job_process.c'
474--- init/job_process.c 2011-02-24 15:41:04 +0000
475+++ init/job_process.c 2011-04-19 09:27:29 +0000
476@@ -40,6 +40,7 @@
477 #include <unistd.h>
478 #include <utmp.h>
479 #include <utmpx.h>
480+#include <pwd.h>
481
482 #include <nih/macros.h>
483 #include <nih/alloc.h>
484@@ -503,6 +504,16 @@
485 }
486 }
487
488+ /* Handle changing a chroot session job prior to dealing with
489+ * the 'chroot' stanza.
490+ */
491+ if (class->session && class->session->chroot) {
492+ if (chroot (class->session->chroot) < 0) {
493+ nih_error_raise_system ();
494+ job_process_error_abort (fds[1], JOB_PROCESS_ERROR_CHROOT, 0);
495+ }
496+ }
497+
498 /* Change the root directory, confining path resolution within it;
499 * we do this before the working directory call so that is always
500 * relative to the new root.
501@@ -558,6 +569,54 @@
502 }
503 }
504
505+ /* Handle unprivileged user job by dropping privileges to
506+ * their level.
507+ */
508+ if (class->session && class->session->user) {
509+ uid_t uid = class->session->user;
510+ struct passwd *pw = NULL;
511+
512+ /* D-Bus does not expose a public API call to allow
513+ * us to query a users primary group.
514+ * _dbus_user_info_fill_uid () seems to exist for this
515+ * purpose, but is a "secret" API. It is unclear why
516+ * D-Bus neglects the gid when it allows the uid
517+ * to be queried directly.
518+ *
519+ * Our only recourse is to disallow user sessions in a
520+ * chroot and assume that all other user sessions
521+ * originate from the local system. In this way, we can
522+ * bypass D-Bus and use getpwuid ().
523+ */
524+
525+ if (class->session->chroot) {
526+ /* We cannot determine the group id of the user
527+ * session in the chroot via D-Bus, so disallow
528+ * all jobs in such an environment.
529+ */
530+ _nih_error_raise (__FILE__, __LINE__, __FUNCTION__,
531+ EPERM, strerror (EPERM));
532+ }
533+
534+ pw = getpwuid (uid);
535+
536+ if (!pw)
537+ nih_return_system_error (-1);
538+
539+ nih_assert (pw->pw_uid == uid);
540+
541+ if (uid && setuid (uid) < 0) {
542+ nih_error_raise_system ();
543+ job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETUID, 0);
544+ }
545+
546+ if (pw->pw_gid && setgid (pw->pw_gid) < 0) {
547+ nih_error_raise_system ();
548+ job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETGID, 0);
549+ }
550+ }
551+
552+
553 /* Execute the process, if we escape from here it failed */
554 if (execvp (argv[0], argv) < 0) {
555 nih_error_raise_system ();
556
557=== modified file 'init/job_process.h'
558--- init/job_process.h 2009-07-09 11:01:53 +0000
559+++ init/job_process.h 2011-04-19 09:27:29 +0000
560@@ -45,7 +45,9 @@
561 JOB_PROCESS_ERROR_CHROOT,
562 JOB_PROCESS_ERROR_CHDIR,
563 JOB_PROCESS_ERROR_PTRACE,
564- JOB_PROCESS_ERROR_EXEC
565+ JOB_PROCESS_ERROR_EXEC,
566+ JOB_PROCESS_ERROR_SETUID,
567+ JOB_PROCESS_ERROR_SETGID,
568 } JobProcessErrorType;
569
570 /**
571
572=== modified file 'init/main.c'
573--- init/main.c 2011-03-10 14:23:57 +0000
574+++ init/main.c 2011-04-19 09:27:29 +0000
575@@ -117,6 +117,8 @@
576
577 extern int use_session_bus;
578
579+extern int disable_sessions;
580+
581 /**
582 * options:
583 *
584@@ -132,6 +134,9 @@
585 { 0, "no-startup-event", N_("do not emit any startup event (for testing)"),
586 NULL, NULL, &disable_startup_event, NULL },
587
588+ { 0, "no-sessions", N_("Disable user and chroot sessions"),
589+ NULL, NULL, &disable_sessions, NULL },
590+
591 { 0, "restart", NULL, NULL, NULL, &restart, NULL },
592
593 { 0, "session", N_("use D-Bus session bus rather than system bus (for testing)"),
594@@ -459,6 +464,9 @@
595 sigprocmask (SIG_SETMASK, &mask, NULL);
596 }
597
598+ if (disable_sessions)
599+ nih_debug ("Sessions disabled");
600+
601 /* Run through the loop at least once to deal with signals that were
602 * delivered to the previous process while the mask was set or to
603 * process the startup event we emitted.
604
605=== modified file 'init/man/init.5'
606--- init/man/init.5 2011-03-15 12:15:28 +0000
607+++ init/man/init.5 2011-04-19 09:27:29 +0000
608@@ -5,8 +5,6 @@
609 .\"
610 .SH SYNOPSIS
611 .B /etc/init/
612-
613-.B $HOME/.init/
614 .\"
615 .SH DESCRIPTION
616 On startup, the Upstart
617@@ -16,11 +14,6 @@
618 directory, and watches for future changes to these files using
619 .BR inotify (7).
620
621-If D\-Bus has been configured to allow non\-privileged users to invoke all
622-Upstart D\-Bus methods, Upstart is also able to manage User Jobs. See
623-.B User Jobs
624-for further details.
625-
626 To be considered by Upstart, files in this directory must have a
627 recognized suffix and may also be present in sub\-directories. There are
628 two recognized suffixes:
629@@ -72,37 +65,6 @@
630
631 Configuration files are plain text and should not be executable.
632 .\"
633-.SS User Jobs
634-
635-A User Job is a job configuration file created by a non\-privileged user
636-in the
637-.B $HOME/.init/
638-directory. Job configuration files in this directory have
639-the same syntax as system job configuration files.
640-
641-Any user can create user jobs, but that user can control
642-.I only
643-jobs they create.
644-
645-Users are able to manage their jobs using the standard
646-.BR initctl (8)
647-facility.
648-
649-Note that a user job configuration file cannot have the same name as a
650-system job configuration file.
651-
652-.\"
653-.SS Chroot Support
654-
655-Upstart is able to manage jobs within a \fBchroot\fP(2). To control jobs
656-within the chroot environment, use the standard
657-.BR initctl (8)
658-facility. Note that it is not necessary to install D\-Bus within the
659-chroot (in fact it is not recommended).
660-
661-Note that User Jobs can be created within a chroot environment.
662-
663-.\"
664 .SS Configuration File Format
665 Each line begins with a configuration stanza and continues until either
666 the end of the line or a line containing a closing stanza. Line breaks
667
668=== modified file 'init/man/init.8'
669--- init/man/init.8 2011-03-10 14:23:57 +0000
670+++ init/man/init.8 2011-04-19 09:27:29 +0000
671@@ -1,4 +1,4 @@
672-.TH init 8 2011-03-03 "Upstart"
673+.TH init 8 2011-04-06 "Upstart"
674 .\"
675 .SH NAME
676 init \- Upstart process management daemon
677@@ -68,28 +68,32 @@
678 by placing them on the kernel command-line.
679 .\"
680 .TP
681-.B --confdir \fIdirectory\fP
682+.B \-\-confdir \fIdirectory\fP
683 Read job configuration files from a directory other than
684 \fI/etc/init\fP.
685 .\"
686 .TP
687-.B --no-startup-event
688+.B \-\-no\-sessions
689+Disable user and chroot sessions.
690+.\"
691+.TP
692+.B \-\-no\-startup\-event
693 Suppress emission of the initial startup event. This option should only
694 be used for testing since it will stop the
695 .BR init (8)
696 daemon from starting \fBany\fP jobs automatically.
697 .\"
698 .TP
699-.B --session
700+.B \-\-session
701 Connect to the D-Bus session bus. This should only be used for testing.
702 .\"
703 .TP
704-.B --startup-event \fIevent\fP
705+.B \-\-startup-event \fIevent\fP
706 Specify a different initial startup event from the standard
707 .BR startup (7) .
708 .\"
709 .TP
710-.B --verbose
711+.B \-\-verbose
712 Outputs verbose messages about job state changes and event emissions to the
713 system console or log, useful for debugging boot.
714 .\"
715@@ -123,7 +127,7 @@
716 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
717 .\"
718 .SH SEE ALSO
719-.BR control-alt-delete (7)
720+.BR control\-alt\-delete (7)
721 .BR init (5)
722 .BR initctl (8)
723 .BR runlevel (7)
724
725=== modified file 'init/parse_job.c'
726--- init/parse_job.c 2011-02-24 15:41:04 +0000
727+++ init/parse_job.c 2011-04-19 09:27:29 +0000
728@@ -280,8 +280,8 @@
729 * of the returned job are freed, the returned job will also be
730 * freed.
731 *
732- * Returns: if @update is NULL, returns new JobClass structure on success, NULL on raised error.
733- * If @update is not NULL, returns @update or NULL on error.
734+ * Returns: If @update is NULL, returns new JobClass structure on success, NULL on raised error.
735+ * If @update is not NULL, returns @update on success, or NULL on error.
736 **/
737 JobClass *
738 parse_job (const void *parent,
739
740=== modified file 'init/session.c'
741--- init/session.c 2011-02-23 09:35:03 +0000
742+++ init/session.c 2011-04-19 09:27:29 +0000
743@@ -56,6 +56,14 @@
744 **/
745 NihList *sessions = NULL;
746
747+/**
748+ * disable_sessions:
749+ *
750+ * If TRUE, disable user and chroot sessions, resulting in a
751+ * "traditional" (pre-session support) system.
752+ **/
753+int disable_sessions = FALSE;
754+
755
756 /* Prototypes for static functions */
757 static void session_create_conf_source (Session *sesson);
758@@ -113,22 +121,23 @@
759 }
760
761 Session *
762-session_from_dbus (const void * parent,
763+session_from_dbus (const void *parent,
764 NihDBusMessage *message)
765 {
766- const char * sender;
767+ const char *sender;
768 DBusError dbus_error;
769 unsigned long unix_user;
770 unsigned long unix_process_id;
771 char root[PATH_MAX];
772- Session * session;
773+ Session *session;
774
775 nih_assert (message != NULL);
776
777-#ifdef TEST
778- /* Return "NULL session" for testing framework. */
779- return NULL;
780-#endif
781+ /* Handle explicit command-line request and alternative request
782+ * method (primarily for test framework) to disable session support.
783+ */
784+ if (disable_sessions || getenv ("UPSTART_NO_SESSIONS"))
785+ return NULL;
786
787 session_init ();
788
789@@ -160,7 +169,7 @@
790 }
791
792 /* If we retrieved a process id, look up the root path for it;
793- * if it's just / don't worry so much about it.
794+ * if it's just '/' don't worry so much about it.
795 */
796 if (unix_process_id) {
797 nih_local char *symlink = NULL;
798@@ -193,15 +202,19 @@
799 if (unix_process_id) {
800 if (! session->chroot)
801 continue;
802+
803+ /* ignore sessions relating to other chroots */
804 if (strcmp (session->chroot, root))
805 continue;
806 }
807
808+ /* ignore sessions relating to other users */
809 if (unix_user != session->user)
810 continue;
811
812 if (! session->conf_path)
813 session_create_conf_source (session);
814+
815 return session;
816 }
817
818
819=== modified file 'init/session.h'
820--- init/session.h 2010-12-10 03:17:53 +0000
821+++ init/session.h 2011-04-19 09:27:29 +0000
822@@ -35,8 +35,33 @@
823 * @user: uid all jobs are switched to,
824 * @conf_path: configuration path.
825 *
826- * This structure is used to identify collections of jobs that share either
827- * a common @chroot and/or common @user.
828+ * This structure is used to identify collections of jobs
829+ * that share either a common @chroot and/or common @user.
830+ *
831+ * Summary of Session values for different environments:
832+ *
833+ * +-------------+---------------------------------------+
834+ * | D-Bus | Session |
835+ * +------+------+--------+-----+------------------------+
836+ * | user | PID | chroot | uid | Object contents |
837+ * +------+------+--------+-----+------------------------+
838+ * | 0 | >0 | no | 0 | NULL (*1) |
839+ * | >0 | "0" | no | >0 | only uid set. |
840+ * | 0 | >0 | yes | 0 | chroot + conf_path set |
841+ * | >0 | ?? | yes | >0 | XXX: fails (*2) |
842+ * +------+------+--------+-----+------------------------+
843+ *
844+ * Notes:
845+ *
846+ * (*1) - The "NULL session" represents the "traditional" environment
847+ * before sessions were introduced (namely a non-chroot environment
848+ * where all job and event operations were handled by uid 0 (root)).
849+ *
850+ * (*2) - error is:
851+ *
852+ * initctl: Unable to connect to system bus: Failed to connect to socket
853+ * /var/run/dbus/system_bus_socket: No such file or directory
854+ *
855 **/
856 typedef struct session {
857 NihList entry;
858
859=== modified file 'init/tests/test_blocked.c'
860--- init/tests/test_blocked.c 2011-02-23 09:35:03 +0000
861+++ init/tests/test_blocked.c 2011-04-19 09:27:29 +0000
862@@ -38,10 +38,6 @@
863 Job *job;
864 Event *event;
865 NihDBusMessage *message = NULL;
866- Session *session;
867-
868- session = session_new (NULL, NULL, getuid ());
869- TEST_NE_P (session, NULL);
870
871 TEST_FUNCTION ("blocked_new");
872
873@@ -50,7 +46,7 @@
874 * in a list.
875 */
876 TEST_FEATURE ("with job");
877- class = job_class_new (NULL, "test", session);
878+ class = job_class_new (NULL, "test", NULL);
879 job = job_new (class, "");
880
881 TEST_ALLOC_FAIL {
882@@ -361,7 +357,6 @@
883 nih_free (blocked);
884 TEST_FREE (message);
885 }
886- nih_free (session);
887 }
888
889
890@@ -369,6 +364,9 @@
891 main (int argc,
892 char *argv[])
893 {
894+ /* run tests in legacy (pre-session support) mode */
895+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
896+
897 test_new ();
898
899 return 0;
900
901=== modified file 'init/tests/test_conf.c'
902--- init/tests/test_conf.c 2011-02-23 11:04:27 +0000
903+++ init/tests/test_conf.c 2011-04-19 09:27:29 +0000
904@@ -4443,22 +4443,18 @@
905 ConfFile *file;
906 JobClass *job, *other, *ptr;
907 Job *instance;
908- Session *session;
909
910 TEST_FUNCTION ("conf_file_destroy");
911 source = conf_source_new (NULL, "/path", CONF_JOB_DIR);
912
913- session = session_new (NULL, NULL, getuid ());
914- TEST_NE_P (session, NULL);
915-
916 /* Check that when a ConfFile for a job is freed, the attached
917 * job is also freed if it is not the current job.
918 */
919 TEST_FEATURE ("with not-current job");
920 file = conf_file_new (source, "/path/to/file");
921- job = file->job = job_class_new (NULL, "foo", session);
922+ job = file->job = job_class_new (NULL, "foo", NULL);
923
924- other = job_class_new (NULL, "foo", session);
925+ other = job_class_new (NULL, "foo", NULL);
926 nih_hash_add (job_classes, &other->entry);
927
928 TEST_FREE_TAG (job);
929@@ -4478,7 +4474,7 @@
930 */
931 TEST_FEATURE ("with stopped job");
932 file = conf_file_new (source, "/path/to/file");
933- job = file->job = job_class_new (NULL, "foo", session);
934+ job = file->job = job_class_new (NULL, "foo", NULL);
935
936 nih_hash_add (job_classes, &job->entry);
937
938@@ -4498,7 +4494,7 @@
939 */
940 TEST_FEATURE ("with running job");
941 file = conf_file_new (source, "/path/to/file");
942- job = file->job = job_class_new (NULL, "foo", session);
943+ job = file->job = job_class_new (NULL, "foo", NULL);
944
945 nih_hash_add (job_classes, &job->entry);
946
947@@ -4522,7 +4518,6 @@
948 nih_free (job);
949
950 nih_free (source);
951- nih_free (session);
952 }
953
954
955@@ -4532,10 +4527,6 @@
956 ConfSource *source1, *source2, *source3;
957 ConfFile *file1, *file2, *file3, *file4, *file5;
958 JobClass *class1, *class2, *class3, *class4, *ptr;
959- Session *session;
960-
961- session = session_new (NULL, NULL, getuid ());
962- TEST_NE_P (session, NULL);
963
964 TEST_FUNCTION ("conf_select_job");
965 source1 = conf_source_new (NULL, "/tmp/foo", CONF_DIR);
966@@ -4543,26 +4534,26 @@
967 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);
968
969 file1 = conf_file_new (source2, "/tmp/bar/frodo");
970- class1 = file1->job = job_class_new (NULL, "frodo", session);
971+ class1 = file1->job = job_class_new (NULL, "frodo", NULL);
972
973 file2 = conf_file_new (source2, "/tmp/bar/bilbo");
974
975 file3 = conf_file_new (source2, "/tmp/bar/drogo");
976- class2 = file3->job = job_class_new (NULL, "drogo", session);
977+ class2 = file3->job = job_class_new (NULL, "drogo", NULL);
978
979 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);
980
981 file4 = conf_file_new (source3, "/tmp/baz/frodo");
982- class3 = file4->job = job_class_new (NULL, "frodo", session);
983+ class3 = file4->job = job_class_new (NULL, "frodo", NULL);
984
985 file5 = conf_file_new (source2, "/tmp/bar/bilbo");
986- class4 = file5->job = job_class_new (NULL, "bilbo", session);
987+ class4 = file5->job = job_class_new (NULL, "bilbo", NULL);
988
989
990 /* Check that a job with only one file is returned.
991 */
992 TEST_FEATURE ("with one file");
993- ptr = conf_select_job ("drogo");
994+ ptr = conf_select_job ("drogo", NULL);
995
996 TEST_EQ_P (ptr, class2);
997
998@@ -4571,7 +4562,7 @@
999 * returned.
1000 */
1001 TEST_FEATURE ("with multiple files");
1002- ptr = conf_select_job ("frodo");
1003+ ptr = conf_select_job ("frodo", NULL);
1004
1005 TEST_EQ_P (ptr, class1);
1006
1007@@ -4579,7 +4570,7 @@
1008 /* Check that files with no attached job are ignored.
1009 */
1010 TEST_FEATURE ("with file but no attached job");
1011- ptr = conf_select_job ("bilbo");
1012+ ptr = conf_select_job ("bilbo", NULL);
1013
1014 TEST_EQ_P (ptr, class4);
1015
1016@@ -4587,7 +4578,7 @@
1017 /* Check that when there is no match, NULL is returned.
1018 */
1019 TEST_FEATURE ("with no match");
1020- ptr = conf_select_job ("meep");
1021+ ptr = conf_select_job ("meep", NULL);
1022
1023 TEST_EQ_P (ptr, NULL);
1024
1025@@ -4595,7 +4586,6 @@
1026 nih_free (source3);
1027 nih_free (source2);
1028 nih_free (source1);
1029- nih_free (session);
1030 }
1031
1032
1033@@ -4603,6 +4593,9 @@
1034 main (int argc,
1035 char *argv[])
1036 {
1037+ /* run tests in legacy (pre-session support) mode */
1038+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
1039+
1040 test_source_new ();
1041 test_file_new ();
1042 test_source_reload_job_dir ();
1043
1044=== modified file 'init/tests/test_control.c'
1045--- init/tests/test_control.c 2011-03-24 13:11:53 +0000
1046+++ init/tests/test_control.c 2011-04-19 09:27:29 +0000
1047@@ -154,7 +154,6 @@
1048 Job *job1, *job2;
1049 pid_t pid;
1050 int fd, wait_fd, status;
1051- Session *session = NULL;
1052
1053 TEST_FUNCTION ("control_server_connect");
1054 program_name = "test";
1055@@ -234,10 +233,10 @@
1056 * new connection has them automatically registered.
1057 */
1058 TEST_FEATURE ("with existing jobs");
1059- class1 = job_class_new (NULL, "foo", session);
1060+ class1 = job_class_new (NULL, "foo", NULL);
1061 nih_hash_add (job_classes, &class1->entry);
1062
1063- class2 = job_class_new (NULL, "bar", session);
1064+ class2 = job_class_new (NULL, "bar", NULL);
1065 job1 = job_new (class2, "test1");
1066 job2 = job_new (class2, "test2");
1067 nih_hash_add (job_classes, &class2->entry);
1068@@ -439,7 +438,6 @@
1069 NihDBusObject *object;
1070 pid_t pid;
1071 int ret, wait_fd, fd, status;
1072- Session *session = NULL;
1073
1074 TEST_FUNCTION ("control_bus_open");
1075 program_name = "test";
1076@@ -535,10 +533,10 @@
1077 refuse_registration = FALSE;
1078 server_conn = NULL;
1079
1080- class1 = job_class_new (NULL, "foo", session);
1081+ class1 = job_class_new (NULL, "foo", NULL);
1082 nih_hash_add (job_classes, &class1->entry);
1083
1084- class2 = job_class_new (NULL, "bar", session);
1085+ class2 = job_class_new (NULL, "bar", NULL);
1086 job1 = job_new (class2, "test1");
1087 job2 = job_new (class2, "test2");
1088 nih_hash_add (job_classes, &class2->entry);
1089@@ -985,13 +983,12 @@
1090 NihError *error;
1091 NihDBusError *dbus_error;
1092 int ret;
1093- Session *session = NULL;
1094
1095 TEST_FUNCTION ("control_get_job_by_name");
1096 nih_error_init ();
1097 job_class_init ();
1098
1099- class = job_class_new (NULL, "test", session);
1100+ class = job_class_new (NULL, "test", NULL);
1101 nih_hash_add (job_classes, &class->entry);
1102
1103
1104@@ -1096,7 +1093,6 @@
1105 NihError *error;
1106 char **paths;
1107 int ret;
1108- Session *session = NULL;
1109
1110 TEST_FUNCTION ("control_get_all_jobs");
1111 nih_error_init ();
1112@@ -1107,13 +1103,13 @@
1113 * in an array allocated as a child of the message structure.
1114 */
1115 TEST_FEATURE ("with registered jobs");
1116- class1 = job_class_new (NULL, "frodo", session);
1117+ class1 = job_class_new (NULL, "frodo", NULL);
1118 nih_hash_add (job_classes, &class1->entry);
1119
1120- class2 = job_class_new (NULL, "bilbo", session);
1121+ class2 = job_class_new (NULL, "bilbo", NULL);
1122 nih_hash_add (job_classes, &class2->entry);
1123
1124- class3 = job_class_new (NULL, "sauron", session);
1125+ class3 = job_class_new (NULL, "sauron", NULL);
1126 nih_hash_add (job_classes, &class3->entry);
1127
1128 TEST_ALLOC_FAIL {
1129@@ -2223,6 +2219,9 @@
1130 main (int argc,
1131 char *argv[])
1132 {
1133+ /* run tests in legacy (pre-session support) mode */
1134+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
1135+
1136 test_server_open ();
1137 test_server_connect ();
1138 test_server_close ();
1139
1140=== modified file 'init/tests/test_environ.c'
1141--- init/tests/test_environ.c 2009-06-23 09:29:35 +0000
1142+++ init/tests/test_environ.c 2011-04-19 09:27:29 +0000
1143@@ -1692,6 +1692,9 @@
1144 main (int argc,
1145 char *argv[])
1146 {
1147+ /* run tests in legacy (pre-session support) mode */
1148+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
1149+
1150 test_add ();
1151 test_append ();
1152 test_set ();
1153
1154=== modified file 'init/tests/test_event.c'
1155--- init/tests/test_event.c 2011-02-23 09:35:03 +0000
1156+++ init/tests/test_event.c 2011-04-19 09:27:29 +0000
1157@@ -222,10 +222,6 @@
1158 JobClass *class = NULL;
1159 Job *job;
1160 Event *event = NULL;
1161- Session *session;
1162-
1163- session = session_new (NULL, NULL, getuid ());
1164- TEST_NE_P (session, NULL);
1165
1166 /* Check that a pending event in the queue results in jobs being
1167 * started and/or stopped and gets moved into the handling state.
1168@@ -237,7 +233,7 @@
1169 TEST_ALLOC_SAFE {
1170 event = event_new (NULL, "test", NULL);
1171
1172- class = job_class_new (NULL, "test", session);
1173+ class = job_class_new (NULL, "test", NULL);
1174 class->task = TRUE;
1175 class->process[PROCESS_MAIN] = process_new (class->process);
1176 class->process[PROCESS_MAIN]->command = "echo";
1177@@ -266,7 +262,6 @@
1178 nih_free (class);
1179 nih_free (event);
1180 }
1181- nih_free (session);
1182 }
1183
1184 void
1185@@ -280,10 +275,6 @@
1186 EventOperator *oper;
1187 Blocked *blocked = NULL, *blocked1 = NULL, *blocked2 = NULL;
1188 char **env1 = NULL, **env2 = NULL;
1189- Session *session;
1190-
1191- session = session_new (NULL, NULL, getuid ());
1192- TEST_NE_P (session, NULL);
1193
1194 TEST_FUNCTION ("event_pending_handle_jobs");
1195 program_name = "test";
1196@@ -301,7 +292,7 @@
1197
1198 TEST_FREE_TAG (event1);
1199
1200- class = job_class_new (NULL, "test", session);
1201+ class = job_class_new (NULL, "test", NULL);
1202 class->task = TRUE;
1203
1204 class->start_on = event_operator_new (
1205@@ -336,7 +327,7 @@
1206
1207 TEST_FREE_TAG (event1);
1208
1209- class = job_class_new (NULL, "test", session);
1210+ class = job_class_new (NULL, "test", NULL);
1211 class->task = TRUE;
1212
1213 class->start_on = event_operator_new (
1214@@ -395,7 +386,7 @@
1215 TEST_FREE_TAG (event1);
1216 TEST_FREE_TAG (event2);
1217
1218- class = job_class_new (NULL, "test", session);
1219+ class = job_class_new (NULL, "test", NULL);
1220 class->task = TRUE;
1221
1222 assert (nih_str_array_add (&(class->env), class,
1223@@ -511,7 +502,7 @@
1224
1225 TEST_FREE_TAG (event2);
1226
1227- class = job_class_new (NULL, "test", session);
1228+ class = job_class_new (NULL, "test", NULL);
1229 class->task = TRUE;
1230
1231 assert (nih_str_array_add (&(class->env), class,
1232@@ -637,7 +628,7 @@
1233
1234 TEST_FREE_TAG (event2);
1235
1236- class = job_class_new (NULL, "test", session);
1237+ class = job_class_new (NULL, "test", NULL);
1238 class->task = TRUE;
1239
1240 assert (nih_str_array_add (&(class->env), class,
1241@@ -805,7 +796,7 @@
1242
1243 TEST_FREE_TAG (event2);
1244
1245- class = job_class_new (NULL, "test", session);
1246+ class = job_class_new (NULL, "test", NULL);
1247 class->task = TRUE;
1248
1249 assert (nih_str_array_add (&(class->env), class,
1250@@ -930,7 +921,7 @@
1251
1252 TEST_FREE_TAG (event1);
1253
1254- class = job_class_new (NULL, "test", session);
1255+ class = job_class_new (NULL, "test", NULL);
1256 class->instance = "$FRODO";
1257 class->task = TRUE;
1258
1259@@ -1009,7 +1000,7 @@
1260
1261 TEST_FREE_TAG (event1);
1262
1263- class = job_class_new (NULL, "test", session);
1264+ class = job_class_new (NULL, "test", NULL);
1265 class->instance = "$FRODO";
1266 class->task = TRUE;
1267
1268@@ -1093,7 +1084,7 @@
1269
1270 TEST_FREE_TAG (event1);
1271
1272- class = job_class_new (NULL, "test", session);
1273+ class = job_class_new (NULL, "test", NULL);
1274 class->instance = "$TIPPLE";
1275 class->task = TRUE;
1276
1277@@ -1136,7 +1127,7 @@
1278
1279 TEST_FREE_TAG (event1);
1280
1281- class = job_class_new (NULL, "test", session);
1282+ class = job_class_new (NULL, "test", NULL);
1283 class->task = TRUE;
1284
1285 class->process[PROCESS_POST_STOP] = process_new (class);
1286@@ -1184,7 +1175,7 @@
1287
1288 TEST_FREE_TAG (event1);
1289
1290- class = job_class_new (NULL, "test", session);
1291+ class = job_class_new (NULL, "test", NULL);
1292 class->task = TRUE;
1293
1294 class->process[PROCESS_POST_STOP] = process_new (class);
1295@@ -1259,7 +1250,7 @@
1296
1297 TEST_FREE_TAG (event1);
1298
1299- class = job_class_new (NULL, "test", session);
1300+ class = job_class_new (NULL, "test", NULL);
1301 class->task = TRUE;
1302
1303 class->process[PROCESS_POST_STOP] = process_new (class);
1304@@ -1338,7 +1329,7 @@
1305
1306 TEST_FREE_TAG (event1);
1307
1308- class = job_class_new (NULL, "test", session);
1309+ class = job_class_new (NULL, "test", NULL);
1310 class->task = TRUE;
1311
1312 class->process[PROCESS_POST_STOP] = process_new (class);
1313@@ -1448,7 +1439,7 @@
1314
1315 TEST_FREE_TAG (event1);
1316
1317- class = job_class_new (NULL, "test", session);
1318+ class = job_class_new (NULL, "test", NULL);
1319 class->task = TRUE;
1320
1321 class->process[PROCESS_POST_STOP] = process_new (class);
1322@@ -1536,7 +1527,7 @@
1323
1324 TEST_FREE_TAG (event1);
1325
1326- class = job_class_new (NULL, "test", session);
1327+ class = job_class_new (NULL, "test", NULL);
1328 class->task = TRUE;
1329
1330 class->process[PROCESS_POST_STOP] = process_new (class);
1331@@ -1607,7 +1598,6 @@
1332 }
1333
1334 fclose (output);
1335- nih_free (session);
1336 }
1337
1338
1339@@ -1619,10 +1609,6 @@
1340 Event *event = NULL, *bevent = NULL;
1341 Blocked *blocked = NULL;
1342 EventOperator *oper;
1343- Session *session;
1344-
1345- session = session_new (NULL, NULL, getuid ());
1346- TEST_NE_P (session, NULL);
1347
1348 TEST_FUNCTION ("event_finished");
1349
1350@@ -1637,7 +1623,7 @@
1351
1352 TEST_FREE_TAG (event);
1353
1354- class = job_class_new (NULL, "test", session);
1355+ class = job_class_new (NULL, "test", NULL);
1356 class->process[PROCESS_MAIN] = process_new (class->process);
1357 class->process[PROCESS_MAIN]->command = "echo";
1358
1359@@ -1671,7 +1657,7 @@
1360
1361 TEST_FREE_TAG (event);
1362
1363- class = job_class_new (NULL, "test", session);
1364+ class = job_class_new (NULL, "test", NULL);
1365 class->process[PROCESS_MAIN] = process_new (class->process);
1366 class->process[PROCESS_MAIN]->command = "echo";
1367
1368@@ -1713,7 +1699,7 @@
1369
1370 TEST_FREE_TAG (event);
1371
1372- class = job_class_new (NULL, "test", session);
1373+ class = job_class_new (NULL, "test", NULL);
1374 class->process[PROCESS_MAIN] = process_new (class->process);
1375 class->process[PROCESS_MAIN]->command = "echo";
1376
1377@@ -1754,7 +1740,7 @@
1378
1379 TEST_FREE_TAG (event);
1380
1381- class = job_class_new (NULL, "foo", session);
1382+ class = job_class_new (NULL, "foo", NULL);
1383
1384 job = job_new (class, "");
1385 job->goal = JOB_STOP;
1386@@ -1787,7 +1773,7 @@
1387
1388 TEST_FREE_TAG (event);
1389
1390- class = job_class_new (NULL, "foo", session);
1391+ class = job_class_new (NULL, "foo", NULL);
1392
1393 job = job_new (class, "");
1394 job->goal = JOB_START;
1395@@ -1818,7 +1804,7 @@
1396
1397 TEST_FREE_TAG (event);
1398
1399- class = job_class_new (NULL, "foo", session);
1400+ class = job_class_new (NULL, "foo", NULL);
1401
1402 job = job_new (class, "");
1403 job->goal = JOB_STOP;
1404@@ -1860,7 +1846,7 @@
1405
1406 TEST_FREE_TAG (event);
1407
1408- class = job_class_new (NULL, "foo", session);
1409+ class = job_class_new (NULL, "foo", NULL);
1410
1411 job = job_new (class, "");
1412 job->goal = JOB_START;
1413@@ -1903,7 +1889,7 @@
1414
1415 TEST_FREE_TAG (event);
1416
1417- class = job_class_new (NULL, "foo", session);
1418+ class = job_class_new (NULL, "foo", NULL);
1419 class->process[PROCESS_POST_STOP] = process_new (class);
1420 class->process[PROCESS_POST_STOP]->command = "echo";
1421
1422@@ -1948,7 +1934,7 @@
1423
1424 TEST_FREE_TAG (event);
1425
1426- class = job_class_new (NULL, "foo", session);
1427+ class = job_class_new (NULL, "foo", NULL);
1428 class->process[PROCESS_PRE_START] = process_new (class);
1429 class->process[PROCESS_PRE_START]->command = "echo";
1430
1431@@ -1981,7 +1967,6 @@
1432
1433 nih_free (class);
1434 }
1435- nih_free (session);
1436 }
1437
1438
1439@@ -1989,6 +1974,9 @@
1440 main (int argc,
1441 char *argv[])
1442 {
1443+ /* run tests in legacy (pre-session support) mode */
1444+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
1445+
1446 test_new ();
1447 test_block ();
1448 test_unblock ();
1449
1450=== modified file 'init/tests/test_event_operator.c'
1451--- init/tests/test_event_operator.c 2010-02-04 20:08:59 +0000
1452+++ init/tests/test_event_operator.c 2011-04-19 09:27:29 +0000
1453@@ -1325,6 +1325,9 @@
1454 main (int argc,
1455 char *argv[])
1456 {
1457+ /* run tests in legacy (pre-session support) mode */
1458+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
1459+
1460 test_operator_new ();
1461 test_operator_copy ();
1462 test_operator_destroy ();
1463
1464=== modified file 'init/tests/test_job.c'
1465--- init/tests/test_job.c 2011-02-23 09:35:03 +0000
1466+++ init/tests/test_job.c 2011-04-19 09:27:29 +0000
1467@@ -72,10 +72,6 @@
1468 NihDBusObject *object;
1469 char *path;
1470 int i;
1471- Session *session;
1472-
1473- session = session_new (NULL, NULL, getuid ());
1474- TEST_NE_P (session, NULL);
1475
1476 TEST_FUNCTION ("job_new");
1477 nih_error_init ();
1478@@ -90,7 +86,7 @@
1479 * list of the class and have sensible defaults.
1480 */
1481 TEST_FEATURE ("with no name");
1482- class = job_class_new (NULL, "test", session);
1483+ class = job_class_new (NULL, "test", NULL);
1484 class->stop_on = event_operator_new (class, EVENT_MATCH, "baz", NULL);
1485
1486 TEST_ALLOC_FAIL {
1487@@ -259,7 +255,6 @@
1488 event_operator_reset (class->stop_on);
1489
1490 nih_free (class);
1491- nih_free (session);
1492 }
1493
1494 void
1495@@ -273,10 +268,6 @@
1496 Job *job;
1497 NihDBusObject *object;
1498 char *path;
1499- Session *session;
1500-
1501- session = session_new (NULL, NULL, getuid ());
1502- TEST_NE_P (session, NULL);
1503
1504 TEST_FUNCTION ("job_register");
1505 dbus_error_init (&dbus_error);
1506@@ -293,7 +284,7 @@
1507 * using its path, and have a InstanceAdded signal emitted.
1508 */
1509 TEST_FEATURE ("with signal emission");
1510- class = job_class_new (NULL, "test", session);
1511+ class = job_class_new (NULL, "test", NULL);
1512 job = job_new (class, "fred");
1513
1514 assert (dbus_connection_get_object_path_data (conn, job->path,
1515@@ -333,7 +324,7 @@
1516 * is still registered.
1517 */
1518 TEST_FEATURE ("without signal emission");
1519- class = job_class_new (NULL, "test", session);
1520+ class = job_class_new (NULL, "test", NULL);
1521 job = job_new (class, "fred");
1522
1523 assert (dbus_connection_get_object_path_data (conn, job->path,
1524@@ -367,7 +358,6 @@
1525 dbus_message_unref (message);
1526
1527 nih_free (class);
1528- nih_free (session);
1529
1530 TEST_DBUS_CLOSE (conn);
1531 TEST_DBUS_CLOSE (client_conn);
1532@@ -389,17 +379,13 @@
1533 NihListEntry *entry = NULL;
1534 DBusMessage *message;
1535 char *job_path = NULL, *goal, *state;
1536- Session *session;
1537-
1538- session = session_new (NULL, NULL, getuid ());
1539- TEST_NE_P (session, NULL);
1540
1541 TEST_FUNCTION ("job_change_goal");
1542 event_init ();
1543
1544 program_name = "test";
1545
1546- class = job_class_new (NULL, "test", session);
1547+ class = job_class_new (NULL, "test", NULL);
1548 class->process[PROCESS_MAIN] = process_new (class);
1549 class->process[PROCESS_MAIN]->command = "echo";
1550 class->process[PROCESS_PRE_START] = process_new (class);
1551@@ -671,7 +657,6 @@
1552
1553
1554 nih_free (class);
1555- nih_free (session);
1556 event_poll ();
1557 }
1558
1559@@ -697,10 +682,6 @@
1560 DBusMessage *message;
1561 char *path, *job_path = NULL, *state;
1562 int status;
1563- Session *session;
1564-
1565- session = session_new (NULL, NULL, getuid ());
1566- TEST_NE_P (session, NULL);
1567
1568 TEST_FUNCTION ("job_change_state");
1569 program_name = "test";
1570@@ -709,7 +690,7 @@
1571 TEST_FILENAME (dirname);
1572 mkdir (dirname, 0700);
1573
1574- class = job_class_new (NULL, "test", session);
1575+ class = job_class_new (NULL, "test", NULL);
1576 class->process[PROCESS_MAIN] = process_new (class);
1577 class->process[PROCESS_MAIN]->command = nih_sprintf (
1578 class->process[PROCESS_MAIN], "touch %s/run", dirname);
1579@@ -3754,7 +3735,7 @@
1580 TEST_ALLOC_SAFE {
1581 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
1582 file = conf_file_new (source, "/tmp/test");
1583- file->job = job_class_new (NULL, "test", session);
1584+ file->job = job_class_new (NULL, "test", NULL);
1585 replacement = file->job;
1586
1587 job = job_new (class, "");
1588@@ -3823,7 +3804,7 @@
1589 TEST_ALLOC_SAFE {
1590 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
1591 file = conf_file_new (source, "/tmp/test");
1592- file->job = job_class_new (NULL, "test", session);
1593+ file->job = job_class_new (NULL, "test", NULL);
1594 replacement = file->job;
1595
1596 job = job_new (class, "");
1597@@ -3900,7 +3881,7 @@
1598 TEST_FEATURE ("post-stop to waiting for deleted job");
1599 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
1600 file = conf_file_new (source, "/tmp/test");
1601- file->job = job_class_new (NULL, "test", session);
1602+ file->job = job_class_new (NULL, "test", NULL);
1603 replacement = file->job;
1604
1605 class->deleted = TRUE;
1606@@ -3963,7 +3944,6 @@
1607 rmdir (dirname);
1608
1609 nih_free (cause);
1610- nih_free (session);
1611 event_poll ();
1612 }
1613
1614@@ -3972,13 +3952,9 @@
1615 {
1616 JobClass *class;
1617 Job *job;
1618- Session *session;
1619-
1620- session = session_new (NULL, NULL, getuid ());
1621- TEST_NE_P (session, NULL);
1622
1623 TEST_FUNCTION ("job_next_state");
1624- class = job_class_new (NULL, "test", session);
1625+ class = job_class_new (NULL, "test", NULL);
1626 class->process[PROCESS_MAIN] = process_new (class);
1627 class->process[PROCESS_MAIN]->command = "echo";
1628
1629@@ -4215,7 +4191,6 @@
1630
1631
1632 nih_free (class);
1633- nih_free (session);
1634 }
1635
1636
1637@@ -4226,10 +4201,6 @@
1638 Job *job;
1639 Blocked *blocked1, *blocked2;
1640 Event *event1, *event2;
1641- Session *session;
1642-
1643- session = session_new (NULL, NULL, getuid ());
1644- TEST_NE_P (session, NULL);
1645
1646 TEST_FUNCTION ("job_failed");
1647
1648@@ -4238,7 +4209,7 @@
1649 * as failed before freeing the blocking list.
1650 */
1651 TEST_FEATURE ("with no current failure");
1652- class = job_class_new (NULL, "test", session);
1653+ class = job_class_new (NULL, "test", NULL);
1654 job = job_new (class, "");
1655
1656 event1 = event_new (NULL, "foo", NULL);
1657@@ -4279,7 +4250,7 @@
1658 * since these were added after the first failure.
1659 */
1660 TEST_FEATURE ("with previous failure");
1661- class = job_class_new (NULL, "test", session);
1662+ class = job_class_new (NULL, "test", NULL);
1663 job = job_new (class, "");
1664 job->failed = TRUE;
1665 job->failed_process = PROCESS_PRE_START;
1666@@ -4316,7 +4287,6 @@
1667 TEST_FALSE (event2->failed);
1668
1669 nih_free (class);
1670- nih_free (session);
1671
1672 event_poll ();
1673 }
1674@@ -4328,10 +4298,6 @@
1675 Job *job;
1676 Blocked *blocked1, *blocked2;
1677 Event *event1, *event2;
1678- Session *session;
1679-
1680- session = session_new (NULL, NULL, getuid ());
1681- TEST_NE_P (session, NULL);
1682
1683 TEST_FUNCTION ("job_finished");
1684
1685@@ -4339,7 +4305,7 @@
1686 * is unblocked and the list itself is then freed.
1687 */
1688 TEST_FEATURE ("with blocked events");
1689- class = job_class_new (NULL, "test", session);
1690+ class = job_class_new (NULL, "test", NULL);
1691 job = job_new (class, "");
1692
1693 event1 = event_new (NULL, "foo", NULL);
1694@@ -4375,7 +4341,7 @@
1695 * unblocked and marked as failed.
1696 */
1697 TEST_FEATURE ("with blocked events and failure");
1698- class = job_class_new (NULL, "test", session);
1699+ class = job_class_new (NULL, "test", NULL);
1700 job = job_new (class, "");
1701
1702 event1 = event_new (NULL, "foo", NULL);
1703@@ -4411,7 +4377,7 @@
1704 * still works (and just does nothing).
1705 */
1706 TEST_FEATURE ("without blocked events");
1707- class = job_class_new (NULL, "test", session);
1708+ class = job_class_new (NULL, "test", NULL);
1709 job = job_new (class, "");
1710
1711 job_finished (job, TRUE);
1712@@ -4419,7 +4385,6 @@
1713 TEST_LIST_EMPTY (&job->blocking);
1714
1715 nih_free (class);
1716- nih_free (session);
1717
1718 event_poll ();
1719 }
1720@@ -4432,10 +4397,6 @@
1721 Job *job;
1722 Event *event;
1723 Blocked *blocked;
1724- Session *session;
1725-
1726- session = session_new (NULL, NULL, getuid ());
1727- TEST_NE_P (session, NULL);
1728
1729 TEST_FUNCTION ("job_emit_event");
1730
1731@@ -4443,7 +4404,7 @@
1732 * event event emitted with the job name set.
1733 */
1734 TEST_FEATURE ("with singleton in starting state");
1735- class = job_class_new (NULL, "test", session);
1736+ class = job_class_new (NULL, "test", NULL);
1737
1738 job = job_new (class, "");
1739 job->goal = JOB_START;
1740@@ -4482,7 +4443,7 @@
1741 * instance name set.
1742 */
1743 TEST_FEATURE ("with instance in starting state");
1744- class = job_class_new (NULL, "test", session);
1745+ class = job_class_new (NULL, "test", NULL);
1746 class->instance = "$FOO";
1747
1748 job = job_new (class, "foo");
1749@@ -4522,7 +4483,7 @@
1750 * event emitted with the job name set.
1751 */
1752 TEST_FEATURE ("with singleton in running state");
1753- class = job_class_new (NULL, "test", session);
1754+ class = job_class_new (NULL, "test", NULL);
1755
1756 job = job_new (class, "");
1757 job->goal = JOB_START;
1758@@ -4552,7 +4513,7 @@
1759 * instance name set.
1760 */
1761 TEST_FEATURE ("with instance in running state");
1762- class = job_class_new (NULL, "test", session);
1763+ class = job_class_new (NULL, "test", NULL);
1764 class->instance = "$FOO";
1765
1766 job = job_new (class, "foo");
1767@@ -4584,7 +4545,7 @@
1768 * result as "ok"
1769 */
1770 TEST_FEATURE ("with non-failed singleton in stopping state");
1771- class = job_class_new (NULL, "test", session);
1772+ class = job_class_new (NULL, "test", NULL);
1773
1774 job = job_new (class, "");
1775 job->goal = JOB_STOP;
1776@@ -4624,7 +4585,7 @@
1777 * also has the instance name set before the result information.
1778 */
1779 TEST_FEATURE ("with non-failed instance in stopping state");
1780- class = job_class_new (NULL, "test", session);
1781+ class = job_class_new (NULL, "test", NULL);
1782 class->instance = "$FOO";
1783
1784 job = job_new (class, "foo");
1785@@ -4667,7 +4628,7 @@
1786 * exit status members set.
1787 */
1788 TEST_FEATURE ("with failed singleton in stopping state");
1789- class = job_class_new (NULL, "test", session);
1790+ class = job_class_new (NULL, "test", NULL);
1791
1792 job = job_new (class, "");
1793 job->goal = JOB_STOP;
1794@@ -4713,7 +4674,7 @@
1795 * set before the result information.
1796 */
1797 TEST_FEATURE ("with failed instance in stopping state");
1798- class = job_class_new (NULL, "test", session);
1799+ class = job_class_new (NULL, "test", NULL);
1800 class->instance = "$FOO";
1801
1802 job = job_new (class, "foo");
1803@@ -4761,7 +4722,7 @@
1804 * members set.
1805 */
1806 TEST_FEATURE ("with killed singleton in stopping state");
1807- class = job_class_new (NULL, "test", session);
1808+ class = job_class_new (NULL, "test", NULL);
1809
1810 job = job_new (class, "");
1811 job->goal = JOB_STOP;
1812@@ -4807,7 +4768,7 @@
1813 * result information.
1814 */
1815 TEST_FEATURE ("with killed instance in stopping state");
1816- class = job_class_new (NULL, "test", session);
1817+ class = job_class_new (NULL, "test", NULL);
1818 class->instance = "$FOO";
1819
1820 job = job_new (class, "foo");
1821@@ -4855,7 +4816,7 @@
1822 * signal members set.
1823 */
1824 TEST_FEATURE ("with unknown killed singleton in stopping state");
1825- class = job_class_new (NULL, "test", session);
1826+ class = job_class_new (NULL, "test", NULL);
1827
1828 job = job_new (class, "");
1829 job->goal = JOB_STOP;
1830@@ -4901,7 +4862,7 @@
1831 * the result information.
1832 */
1833 TEST_FEATURE ("with unknown killed instance in stopping state");
1834- class = job_class_new (NULL, "test", session);
1835+ class = job_class_new (NULL, "test", NULL);
1836 class->instance = "$FOO";
1837
1838 job = job_new (class, "foo");
1839@@ -4948,7 +4909,7 @@
1840 * the job name set, the result as failed, and just the process set.
1841 */
1842 TEST_FEATURE ("with unstarted singleton in stopping state");
1843- class = job_class_new (NULL, "test", session);
1844+ class = job_class_new (NULL, "test", NULL);
1845
1846 job = job_new (class, "");
1847 job->goal = JOB_STOP;
1848@@ -4993,7 +4954,7 @@
1849 * the result information.
1850 */
1851 TEST_FEATURE ("with unstarted instance in stopping state");
1852- class = job_class_new (NULL, "test", session);
1853+ class = job_class_new (NULL, "test", NULL);
1854 class->instance = "$FOO";
1855
1856 job = job_new (class, "foo");
1857@@ -5039,7 +5000,7 @@
1858 * the result as failed and the process set to respawn.
1859 */
1860 TEST_FEATURE ("with failed respawn singleton in stopping state");
1861- class = job_class_new (NULL, "test", session);
1862+ class = job_class_new (NULL, "test", NULL);
1863
1864 job = job_new (class, "");
1865 job->goal = JOB_STOP;
1866@@ -5084,7 +5045,7 @@
1867 * information.
1868 */
1869 TEST_FEATURE ("with failed respawn instance in stopping state");
1870- class = job_class_new (NULL, "test", session);
1871+ class = job_class_new (NULL, "test", NULL);
1872 class->instance = "$FOO";
1873
1874 job = job_new (class, "foo");
1875@@ -5130,7 +5091,7 @@
1876 * result as "ok"
1877 */
1878 TEST_FEATURE ("with non-failed singleton in stopped state");
1879- class = job_class_new (NULL, "test", session);
1880+ class = job_class_new (NULL, "test", NULL);
1881
1882 job = job_new (class, "");
1883 job->goal = JOB_STOP;
1884@@ -5161,7 +5122,7 @@
1885 * also has the instance name set before the result information.
1886 */
1887 TEST_FEATURE ("with non-failed instance in waiting state");
1888- class = job_class_new (NULL, "test", session);
1889+ class = job_class_new (NULL, "test", NULL);
1890 class->instance = "$FOO";
1891
1892 job = job_new (class, "foo");
1893@@ -5195,7 +5156,7 @@
1894 * exit status members set.
1895 */
1896 TEST_FEATURE ("with failed singleton in waiting state");
1897- class = job_class_new (NULL, "test", session);
1898+ class = job_class_new (NULL, "test", NULL);
1899
1900 job = job_new (class, "");
1901 job->goal = JOB_STOP;
1902@@ -5232,7 +5193,7 @@
1903 * set before the result information.
1904 */
1905 TEST_FEATURE ("with failed instance in waiting state");
1906- class = job_class_new (NULL, "test", session);
1907+ class = job_class_new (NULL, "test", NULL);
1908 class->instance = "$FOO";
1909
1910 job = job_new (class, "foo");
1911@@ -5271,7 +5232,7 @@
1912 * members set.
1913 */
1914 TEST_FEATURE ("with killed singleton in waiting state");
1915- class = job_class_new (NULL, "test", session);
1916+ class = job_class_new (NULL, "test", NULL);
1917
1918 job = job_new (class, "");
1919 job->goal = JOB_STOP;
1920@@ -5308,7 +5269,7 @@
1921 * result information.
1922 */
1923 TEST_FEATURE ("with killed instance in waiting state");
1924- class = job_class_new (NULL, "test", session);
1925+ class = job_class_new (NULL, "test", NULL);
1926 class->instance = "$FOO";
1927
1928 job = job_new (class, "foo");
1929@@ -5347,7 +5308,7 @@
1930 * signal members set.
1931 */
1932 TEST_FEATURE ("with unknown killed singleton in waiting state");
1933- class = job_class_new (NULL, "test", session);
1934+ class = job_class_new (NULL, "test", NULL);
1935
1936 job = job_new (class, "");
1937 job->goal = JOB_STOP;
1938@@ -5384,7 +5345,7 @@
1939 * the result information.
1940 */
1941 TEST_FEATURE ("with unknown killed instance in waiting state");
1942- class = job_class_new (NULL, "test", session);
1943+ class = job_class_new (NULL, "test", NULL);
1944 class->instance = "$FOO";
1945
1946 job = job_new (class, "foo");
1947@@ -5422,7 +5383,7 @@
1948 * the job name set, the result as failed, and just the process set.
1949 */
1950 TEST_FEATURE ("with unstarted singleton in waiting state");
1951- class = job_class_new (NULL, "test", session);
1952+ class = job_class_new (NULL, "test", NULL);
1953
1954 job = job_new (class, "");
1955 job->goal = JOB_STOP;
1956@@ -5458,7 +5419,7 @@
1957 * the result information.
1958 */
1959 TEST_FEATURE ("with unstarted instance in waiting state");
1960- class = job_class_new (NULL, "test", session);
1961+ class = job_class_new (NULL, "test", NULL);
1962 class->instance = "$FOO";
1963
1964 job = job_new (class, "foo");
1965@@ -5495,7 +5456,7 @@
1966 * the result as failed and the process set to respawn.
1967 */
1968 TEST_FEATURE ("with failed respawn singleton in waiting state");
1969- class = job_class_new (NULL, "test", session);
1970+ class = job_class_new (NULL, "test", NULL);
1971
1972 job = job_new (class, "");
1973 job->goal = JOB_STOP;
1974@@ -5531,7 +5492,7 @@
1975 * information.
1976 */
1977 TEST_FEATURE ("with failed respawn instance in waiting state");
1978- class = job_class_new (NULL, "test", session);
1979+ class = job_class_new (NULL, "test", NULL);
1980 class->instance = "$FOO";
1981
1982 job = job_new (class, "foo");
1983@@ -5561,7 +5522,6 @@
1984 }
1985
1986 nih_free (class);
1987- nih_free (session);
1988 }
1989
1990
1991@@ -5572,16 +5532,12 @@
1992 Job *job;
1993 const char *ret;
1994 char *name;
1995- Session *session;
1996-
1997- session = session_new (NULL, NULL, getuid ());
1998- TEST_NE_P (session, NULL);
1999
2000 TEST_FUNCTION ("job_name");
2001
2002 /* Check that the name of a non-instance job is returned. */
2003 TEST_FEATURE ("with non-instance job");
2004- class = job_class_new (NULL, "test", session);
2005+ class = job_class_new (NULL, "test", NULL);
2006 job = job_new (class, "");
2007
2008 TEST_ALLOC_FAIL {
2009@@ -5595,7 +5551,7 @@
2010
2011 /* Check that the name of an instance job is returned. */
2012 TEST_FEATURE ("with instance job");
2013- class = job_class_new (NULL, "test", session);
2014+ class = job_class_new (NULL, "test", NULL);
2015 class->instance = "$FOO";
2016 job = job_new (class, "foo");
2017
2018@@ -5612,7 +5568,7 @@
2019 * value.
2020 */
2021 TEST_FEATURE ("with multiple calls");
2022- class = job_class_new (NULL, "test", session);
2023+ class = job_class_new (NULL, "test", NULL);
2024 job = job_new (class, "");
2025
2026 ret = job_name (job);
2027@@ -5625,7 +5581,6 @@
2028 TEST_FREE (name);
2029
2030 nih_free (class);
2031- nih_free (session);
2032 }
2033
2034
2035@@ -5883,11 +5838,6 @@
2036 int ret;
2037 NihError *error;
2038 NihDBusError *dbus_error;
2039- Session *session;
2040-
2041- session = session_new (NULL, NULL, getuid ());
2042- TEST_NE_P (session, NULL);
2043-
2044
2045 TEST_FUNCTION ("job_start");
2046 nih_error_init ();
2047@@ -5904,8 +5854,9 @@
2048 * the reply will be sent to the sender.
2049 */
2050 TEST_FEATURE ("with stopping job");
2051- class = job_class_new (NULL, "test", session);
2052+ class = job_class_new (NULL, "test", NULL);
2053 job = job_new (class, "");
2054+ TEST_NE_P (job, NULL);
2055
2056 job->goal = JOB_STOP;
2057 job->state = JOB_STOPPING;
2058@@ -5990,7 +5941,7 @@
2059 * and no blocking entry created.
2060 */
2061 TEST_FEATURE ("with no wait");
2062- class = job_class_new (NULL, "test", session);
2063+ class = job_class_new (NULL, "test", NULL);
2064 job = job_new (class, "");
2065
2066 job->goal = JOB_STOP;
2067@@ -6060,7 +6011,7 @@
2068 * a D-Bus error is raised immediately.
2069 */
2070 TEST_FEATURE ("with starting job");
2071- class = job_class_new (NULL, "test", session);
2072+ class = job_class_new (NULL, "test", NULL);
2073 job = job_new (class, "");
2074
2075 job->goal = JOB_START;
2076@@ -6107,7 +6058,6 @@
2077 TEST_EQ (job->state, JOB_STARTING);
2078
2079 nih_free (class);
2080- nih_free (session);
2081
2082 TEST_DBUS_CLOSE (conn);
2083 TEST_DBUS_CLOSE (client_conn);
2084@@ -6132,10 +6082,6 @@
2085 int ret;
2086 NihError *error;
2087 NihDBusError *dbus_error;
2088- Session *session;
2089-
2090- session = session_new (NULL, NULL, getuid ());
2091- TEST_NE_P (session, NULL);
2092
2093 TEST_FUNCTION ("job_stop");
2094 nih_error_init ();
2095@@ -6152,7 +6098,7 @@
2096 * the reply will be sent to the sender and the instance deleted.
2097 */
2098 TEST_FEATURE ("with running job");
2099- class = job_class_new (NULL, "test", session);
2100+ class = job_class_new (NULL, "test", NULL);
2101 job = job_new (class, "");
2102
2103 job->goal = JOB_START;
2104@@ -6231,7 +6177,7 @@
2105 * no blocking entry created.
2106 */
2107 TEST_FEATURE ("with no wait");
2108- class = job_class_new (NULL, "test", session);
2109+ class = job_class_new (NULL, "test", NULL);
2110 job = job_new (class, "");
2111
2112 job->goal = JOB_START;
2113@@ -6297,7 +6243,7 @@
2114 * a D-Bus error is raised immediately.
2115 */
2116 TEST_FEATURE ("with stopping job");
2117- class = job_class_new (NULL, "test", session);
2118+ class = job_class_new (NULL, "test", NULL);
2119 job = job_new (class, "");
2120
2121 job->goal = JOB_STOP;
2122@@ -6344,8 +6290,6 @@
2123 TEST_EQ (job->state, JOB_STOPPING);
2124
2125 nih_free (class);
2126- nih_free (session);
2127-
2128
2129 TEST_DBUS_CLOSE (conn);
2130 TEST_DBUS_CLOSE (client_conn);
2131@@ -6370,10 +6314,6 @@
2132 int ret;
2133 NihError *error;
2134 NihDBusError *dbus_error;
2135- Session *session;
2136-
2137- session = session_new (NULL, NULL, getuid ());
2138- TEST_NE_P (session, NULL);
2139
2140 TEST_FUNCTION ("job_restart");
2141 nih_error_init ();
2142@@ -6390,7 +6330,7 @@
2143 * it back through to running, the reply will be sent to the sender.
2144 */
2145 TEST_FEATURE ("with running job");
2146- class = job_class_new (NULL, "test", session);
2147+ class = job_class_new (NULL, "test", NULL);
2148 job = job_new (class, "");
2149
2150 job->goal = JOB_START;
2151@@ -6479,7 +6419,7 @@
2152 * and no blocking entry created.
2153 */
2154 TEST_FEATURE ("with no wait");
2155- class = job_class_new (NULL, "test", session);
2156+ class = job_class_new (NULL, "test", NULL);
2157 job = job_new (class, "");
2158
2159 job->goal = JOB_START;
2160@@ -6552,7 +6492,7 @@
2161 * a D-Bus error is raised immediately.
2162 */
2163 TEST_FEATURE ("with stopping job");
2164- class = job_class_new (NULL, "test", session);
2165+ class = job_class_new (NULL, "test", NULL);
2166 job = job_new (class, "");
2167
2168 job->goal = JOB_STOP;
2169@@ -6599,7 +6539,6 @@
2170 TEST_EQ (job->state, JOB_STOPPING);
2171
2172 nih_free (class);
2173- nih_free (session);
2174
2175 TEST_DBUS_CLOSE (conn);
2176 TEST_DBUS_CLOSE (client_conn);
2177@@ -6620,10 +6559,6 @@
2178 NihError *error;
2179 char *name;
2180 int ret;
2181- Session *session;
2182-
2183- session = session_new (NULL, NULL, getuid ());
2184- TEST_NE_P (session, NULL);
2185
2186 TEST_FUNCTION ("job_get_name");
2187 nih_error_init ();
2188@@ -6635,7 +6570,7 @@
2189 TEST_FEATURE ("with instance name");
2190 TEST_ALLOC_FAIL {
2191 TEST_ALLOC_SAFE {
2192- class = job_class_new (NULL, "test", session);
2193+ class = job_class_new (NULL, "test", NULL);
2194 job = job_new (class, "instance name");
2195
2196 message = nih_new (NULL, NihDBusMessage);
2197@@ -6675,7 +6610,7 @@
2198 TEST_FEATURE ("with no instance name");
2199 TEST_ALLOC_FAIL {
2200 TEST_ALLOC_SAFE {
2201- class = job_class_new (NULL, "test", session);
2202+ class = job_class_new (NULL, "test", NULL);
2203 job = job_new (class, "");
2204
2205 message = nih_new (NULL, NihDBusMessage);
2206@@ -6707,7 +6642,6 @@
2207 nih_free (message);
2208 nih_free (class);
2209 }
2210- nih_free (session);
2211 }
2212
2213 void
2214@@ -6719,10 +6653,6 @@
2215 NihError *error;
2216 char *goal;
2217 int ret;
2218- Session *session;
2219-
2220- session = session_new (NULL, NULL, getuid ());
2221- TEST_NE_P (session, NULL);
2222
2223 /* Check that the goal of the instance is returned a newly allocated
2224 * string, as a child of the message.
2225@@ -6733,7 +6663,7 @@
2226
2227 TEST_ALLOC_FAIL {
2228 TEST_ALLOC_SAFE {
2229- class = job_class_new (NULL, "test", session);
2230+ class = job_class_new (NULL, "test", NULL);
2231 job = job_new (class, "");
2232 job->goal = JOB_START;
2233
2234@@ -6766,7 +6696,6 @@
2235 nih_free (message);
2236 nih_free (class);
2237 }
2238- nih_free (session);
2239 }
2240
2241 void
2242@@ -6778,10 +6707,6 @@
2243 NihError *error;
2244 char *state;
2245 int ret;
2246- Session *session;
2247-
2248- session = session_new (NULL, NULL, getuid ());
2249- TEST_NE_P (session, NULL);
2250
2251 /* Check that the state of the instance is returned a newly allocated
2252 * string, as a child of the message.
2253@@ -6792,7 +6717,7 @@
2254
2255 TEST_ALLOC_FAIL {
2256 TEST_ALLOC_SAFE {
2257- class = job_class_new (NULL, "test", session);
2258+ class = job_class_new (NULL, "test", NULL);
2259 job = job_new (class, "");
2260 job->goal = JOB_START;
2261 job->state = JOB_RUNNING;
2262@@ -6826,7 +6751,6 @@
2263 nih_free (message);
2264 nih_free (class);
2265 }
2266- nih_free (session);
2267 }
2268
2269
2270@@ -6839,10 +6763,6 @@
2271 JobProcessesElement **processes;
2272 NihError * error;
2273 int ret;
2274- Session *session;
2275-
2276- session = session_new (NULL, NULL, getuid ());
2277- TEST_NE_P (session, NULL);
2278
2279 TEST_FUNCTION ("job_get_processes");
2280 nih_error_init ();
2281@@ -6855,7 +6775,7 @@
2282 TEST_FEATURE ("with no processes");
2283 TEST_ALLOC_FAIL {
2284 TEST_ALLOC_SAFE {
2285- class = job_class_new (NULL, "test", session);
2286+ class = job_class_new (NULL, "test", NULL);
2287 job = job_new (class, "");
2288 job->goal = JOB_START;
2289 job->state = JOB_STARTING;
2290@@ -6899,7 +6819,7 @@
2291 TEST_FEATURE ("with pre-start process");
2292 TEST_ALLOC_FAIL {
2293 TEST_ALLOC_SAFE {
2294- class = job_class_new (NULL, "test", session);
2295+ class = job_class_new (NULL, "test", NULL);
2296 class->process[PROCESS_PRE_START] = process_new (class);
2297 class->process[PROCESS_PRE_START]->command = "echo";
2298
2299@@ -6954,7 +6874,7 @@
2300 TEST_FEATURE ("with post-start process and no main process");
2301 TEST_ALLOC_FAIL {
2302 TEST_ALLOC_SAFE {
2303- class = job_class_new (NULL, "test", session);
2304+ class = job_class_new (NULL, "test", NULL);
2305 class->process[PROCESS_POST_START] = process_new (class);
2306 class->process[PROCESS_POST_START]->command = "echo";
2307
2308@@ -7008,7 +6928,7 @@
2309 TEST_FEATURE ("with main process");
2310 TEST_ALLOC_FAIL {
2311 TEST_ALLOC_SAFE {
2312- class = job_class_new (NULL, "test", session);
2313+ class = job_class_new (NULL, "test", NULL);
2314 class->process[PROCESS_MAIN] = process_new (class);
2315 class->process[PROCESS_MAIN]->command = "echo";
2316
2317@@ -7063,7 +6983,7 @@
2318 TEST_FEATURE ("with main process and post-start process");
2319 TEST_ALLOC_FAIL {
2320 TEST_ALLOC_SAFE {
2321- class = job_class_new (NULL, "test", session);
2322+ class = job_class_new (NULL, "test", NULL);
2323 class->process[PROCESS_POST_START] = process_new (class);
2324 class->process[PROCESS_POST_START]->command = "echo";
2325 class->process[PROCESS_MAIN] = process_new (class);
2326@@ -7127,7 +7047,7 @@
2327 TEST_FEATURE ("with main process and pre-stop process");
2328 TEST_ALLOC_FAIL {
2329 TEST_ALLOC_SAFE {
2330- class = job_class_new (NULL, "test", session);
2331+ class = job_class_new (NULL, "test", NULL);
2332 class->process[PROCESS_MAIN] = process_new (class);
2333 class->process[PROCESS_MAIN]->command = "echo";
2334 class->process[PROCESS_PRE_STOP] = process_new (class);
2335@@ -7191,7 +7111,7 @@
2336 TEST_FEATURE ("with pre-stop process and no main process");
2337 TEST_ALLOC_FAIL {
2338 TEST_ALLOC_SAFE {
2339- class = job_class_new (NULL, "test", session);
2340+ class = job_class_new (NULL, "test", NULL);
2341 class->process[PROCESS_PRE_STOP] = process_new (class);
2342 class->process[PROCESS_PRE_STOP]->command = "echo";
2343
2344@@ -7245,7 +7165,7 @@
2345 TEST_FEATURE ("with post-stop process");
2346 TEST_ALLOC_FAIL {
2347 TEST_ALLOC_SAFE {
2348- class = job_class_new (NULL, "test", session);
2349+ class = job_class_new (NULL, "test", NULL);
2350 class->process[PROCESS_POST_STOP] = process_new (class);
2351 class->process[PROCESS_POST_STOP]->command = "echo";
2352
2353@@ -7291,7 +7211,6 @@
2354 nih_free (message);
2355 nih_free (class);
2356 }
2357- nih_free (session);
2358 }
2359
2360
2361@@ -7299,6 +7218,9 @@
2362 main (int argc,
2363 char *argv[])
2364 {
2365+ /* run tests in legacy (pre-session support) mode */
2366+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
2367+
2368 test_new ();
2369 test_register ();
2370 test_change_goal ();
2371
2372=== modified file 'init/tests/test_job_class.c'
2373--- init/tests/test_job_class.c 2011-02-23 13:50:30 +0000
2374+++ init/tests/test_job_class.c 2011-04-19 09:27:29 +0000
2375@@ -160,10 +160,6 @@
2376 Job *job;
2377 char *path;
2378 int ret;
2379- Session *session;
2380-
2381- session = session_new (NULL, NULL, getuid ());
2382- TEST_NE_P (session, NULL);
2383
2384 TEST_FUNCTION ("job_class_consider");
2385 dbus_error_init (&dbus_error);
2386@@ -181,15 +177,15 @@
2387 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);
2388
2389 file1 = conf_file_new (source2, "/tmp/bar/frodo");
2390- class1 = file1->job = job_class_new (NULL, "frodo", session);
2391+ class1 = file1->job = job_class_new (NULL, "frodo", NULL);
2392
2393 file2 = conf_file_new (source2, "/tmp/bar/bilbo");
2394- class2 = file2->job = job_class_new (NULL, "bilbo", session);
2395+ class2 = file2->job = job_class_new (NULL, "bilbo", NULL);
2396
2397 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);
2398
2399 file3 = conf_file_new (source3, "/tmp/baz/frodo");
2400- class3 = file3->job = job_class_new (NULL, "frodo", session);
2401+ class3 = file3->job = job_class_new (NULL, "frodo", NULL);
2402
2403
2404 control_init ();
2405@@ -382,7 +378,7 @@
2406 * becomes the hash table member.
2407 */
2408 TEST_FEATURE ("with replacable registered class and not best class");
2409- class4 = job_class_new (NULL, "frodo", session);
2410+ class4 = job_class_new (NULL, "frodo", NULL);
2411 nih_hash_add (job_classes, &class4->entry);
2412 job_class_register (class4, conn, FALSE);
2413
2414@@ -440,7 +436,6 @@
2415
2416
2417 nih_free (entry);
2418- nih_free (session);
2419
2420 TEST_DBUS_CLOSE (conn);
2421 TEST_DBUS_CLOSE (client_conn);
2422@@ -464,10 +459,6 @@
2423 Job *job;
2424 char *path;
2425 int ret;
2426- Session *session;
2427-
2428- session = session_new (NULL, NULL, getuid ());
2429- TEST_NE_P (session, NULL);
2430
2431 TEST_FUNCTION ("job_class_reconsider");
2432 dbus_error_init (&dbus_error);
2433@@ -485,15 +476,15 @@
2434 source2 = conf_source_new (NULL, "/tmp/bar", CONF_JOB_DIR);
2435
2436 file1 = conf_file_new (source2, "/tmp/bar/frodo");
2437- class1 = file1->job = job_class_new (NULL, "frodo", session);
2438+ class1 = file1->job = job_class_new (NULL, "frodo", NULL);
2439
2440 file2 = conf_file_new (source2, "/tmp/bar/bilbo");
2441- class2 = file2->job = job_class_new (NULL, "bilbo", session);
2442+ class2 = file2->job = job_class_new (NULL, "bilbo", NULL);
2443
2444 source3 = conf_source_new (NULL, "/tmp/baz", CONF_JOB_DIR);
2445
2446 file3 = conf_file_new (source3, "/tmp/baz/frodo");
2447- class3 = file3->job = job_class_new (NULL, "frodo", session);
2448+ class3 = file3->job = job_class_new (NULL, "frodo", NULL);
2449
2450
2451 control_init ();
2452@@ -726,7 +717,7 @@
2453 nih_free (source2);
2454 nih_free (source1);
2455
2456- class4 = job_class_new (NULL, "frodo", session);
2457+ class4 = job_class_new (NULL, "frodo", NULL);
2458 nih_hash_add (job_classes, &class4->entry);
2459 job_class_register (class4, conn, FALSE);
2460
2461@@ -759,7 +750,6 @@
2462
2463
2464 nih_free (entry);
2465- nih_free (session);
2466
2467 TEST_DBUS_CLOSE (conn);
2468 TEST_DBUS_CLOSE (client_conn);
2469@@ -779,10 +769,6 @@
2470 JobClass *class;
2471 NihDBusObject *object;
2472 char *path;
2473- Session *session;
2474-
2475- session = session_new (NULL, NULL, getuid ());
2476- TEST_NE_P (session, NULL);
2477
2478 TEST_FUNCTION ("job_class_register");
2479 dbus_error_init (&dbus_error);
2480@@ -800,7 +786,7 @@
2481 * announce it.
2482 */
2483 TEST_FEATURE ("with signal emission");
2484- class = job_class_new (NULL, "test", session);
2485+ class = job_class_new (NULL, "test", NULL);
2486
2487 assert (dbus_connection_get_object_path_data (conn, class->path,
2488 (void **)&object));
2489@@ -837,7 +823,7 @@
2490 * by emitting a signal immediately afterwards.
2491 */
2492 TEST_FEATURE ("without signal emission");
2493- class = job_class_new (NULL, "test", session);
2494+ class = job_class_new (NULL, "test", NULL);
2495
2496 assert (dbus_connection_get_object_path_data (conn, class->path,
2497 (void **)&object));
2498@@ -870,7 +856,6 @@
2499 dbus_message_unref (message);
2500
2501 nih_free (class);
2502- nih_free (session);
2503
2504 TEST_DBUS_CLOSE (conn);
2505 TEST_DBUS_CLOSE (client_conn);
2506@@ -889,10 +874,6 @@
2507 JobClass *class;
2508 NihDBusObject *object;
2509 char *path;
2510- Session *session;
2511-
2512- session = session_new (NULL, NULL, getuid ());
2513- TEST_NE_P (session, NULL);
2514
2515 /* Check that we can unregister an object for a job class from
2516 * the bus and that the JobRemoved signal is emitted as a result.
2517@@ -910,7 +891,7 @@
2518 assert (! dbus_error_is_set (&dbus_error));
2519
2520
2521- class = job_class_new (NULL, "test", session);
2522+ class = job_class_new (NULL, "test", NULL);
2523
2524 assert (dbus_connection_get_object_path_data (conn, class->path,
2525 (void **)&object));
2526@@ -945,7 +926,6 @@
2527 dbus_message_unref (message);
2528
2529 nih_free (class);
2530- nih_free (session);
2531
2532 TEST_DBUS_CLOSE (conn);
2533 TEST_DBUS_CLOSE (client_conn);
2534@@ -961,10 +941,6 @@
2535 JobClass *class;
2536 char **env;
2537 size_t len;
2538- Session *session;
2539-
2540- session = session_new (NULL, NULL, getuid ());
2541- TEST_NE_P (session, NULL);
2542
2543 TEST_FUNCTION ("job_class_environment");
2544
2545@@ -972,7 +948,7 @@
2546 * just have the built-ins in the returned environment.
2547 */
2548 TEST_FEATURE ("with no configured environment");
2549- class = job_class_new (NULL, "test", session);
2550+ class = job_class_new (NULL, "test", NULL);
2551
2552 TEST_ALLOC_FAIL {
2553 env = job_class_environment (NULL, class, &len);
2554@@ -1002,7 +978,7 @@
2555 * will have those appended to the environment as well as the builtins.
2556 */
2557 TEST_FEATURE ("with configured environment");
2558- class = job_class_new (NULL, "test", session);
2559+ class = job_class_new (NULL, "test", NULL);
2560
2561 class->env = nih_str_array_new (class);
2562 assert (nih_str_array_add (&(class->env), class, NULL, "FOO=BAR"));
2563@@ -1039,7 +1015,7 @@
2564 /* Check that configured environment override built-ins.
2565 */
2566 TEST_FEATURE ("with configuration overriding built-ins");
2567- class = job_class_new (NULL, "test", session);
2568+ class = job_class_new (NULL, "test", NULL);
2569
2570 class->env = nih_str_array_new (class);
2571 assert (nih_str_array_add (&(class->env), class, NULL, "FOO=BAR"));
2572@@ -1072,7 +1048,6 @@
2573 }
2574
2575 nih_free (class);
2576- nih_free (session);
2577 }
2578
2579
2580@@ -1087,11 +1062,6 @@
2581 int ret;
2582 NihError *error;
2583 NihDBusError *dbus_error;
2584- Session *session;
2585-
2586- session = session_new (NULL, NULL, getuid ());
2587- TEST_NE_P (session, NULL);
2588-
2589
2590 TEST_FUNCTION ("job_class_get_instance");
2591 nih_error_init ();
2592@@ -1103,7 +1073,7 @@
2593 TEST_FEATURE ("with running job");
2594 TEST_ALLOC_FAIL {
2595 TEST_ALLOC_SAFE {
2596- class = job_class_new (NULL, "test", session);
2597+ class = job_class_new (NULL, "test", NULL);
2598 job = job_new (class, "");
2599
2600 message = nih_new (NULL, NihDBusMessage);
2601@@ -1140,7 +1110,7 @@
2602 /* Check that if there's no such instance, a D-Bus error is raised.
2603 */
2604 TEST_FEATURE ("with unknown job");
2605- class = job_class_new (NULL, "test", session);
2606+ class = job_class_new (NULL, "test", NULL);
2607
2608 message = nih_new (NULL, NihDBusMessage);
2609 message->connection = NULL;
2610@@ -1171,7 +1141,7 @@
2611 TEST_FEATURE ("with environment");
2612 TEST_ALLOC_FAIL {
2613 TEST_ALLOC_SAFE {
2614- class = job_class_new (NULL, "test", session);
2615+ class = job_class_new (NULL, "test", NULL);
2616 class->instance = "$FOO";
2617
2618 job = job_new (class, "wibble");
2619@@ -1215,7 +1185,7 @@
2620 * is returned.
2621 */
2622 TEST_FEATURE ("with invalid environment");
2623- class = job_class_new (NULL, "test", session);
2624+ class = job_class_new (NULL, "test", NULL);
2625 class->instance = "$FOO";
2626
2627 job = job_new (class, "wibble");
2628@@ -1242,7 +1212,6 @@
2629
2630 nih_free (message);
2631 nih_free (class);
2632- nih_free (session);
2633 }
2634
2635 void
2636@@ -1255,15 +1224,11 @@
2637 NihError *error;
2638 NihDBusError *dbus_error;
2639 int ret;
2640- Session *session;
2641-
2642- session = session_new (NULL, NULL, getuid ());
2643- TEST_NE_P (session, NULL);
2644
2645 TEST_FUNCTION ("job_class_get_instance_by_name");
2646 nih_error_init ();
2647
2648- class = job_class_new (NULL, "test", session);
2649+ class = job_class_new (NULL, "test", NULL);
2650
2651
2652 /* Check that when given a known instance name, the path to that
2653@@ -1377,7 +1342,6 @@
2654
2655
2656 nih_free (class);
2657- nih_free (session);
2658 }
2659
2660 void
2661@@ -1389,16 +1353,12 @@
2662 NihError *error;
2663 char **paths;
2664 int ret;
2665- Session *session;
2666-
2667- session = session_new (NULL, NULL, getuid ());
2668- TEST_NE_P (session, NULL);
2669
2670 TEST_FUNCTION ("job_class_get_all_instances");
2671 nih_error_init ();
2672 job_class_init ();
2673
2674- class = job_class_new (NULL, "test", session);
2675+ class = job_class_new (NULL, "test", NULL);
2676
2677
2678 /* Check that paths for each of the active instances are returned
2679@@ -1496,7 +1456,6 @@
2680 }
2681
2682 nih_free (class);
2683- nih_free (session);
2684 }
2685
2686
2687@@ -1516,10 +1475,6 @@
2688 int ret;
2689 NihError *error;
2690 NihDBusError *dbus_error;
2691- Session *session;
2692-
2693- session = session_new (NULL, NULL, getuid ());
2694- TEST_NE_P (session, NULL);
2695
2696 TEST_FUNCTION ("job_class_start");
2697 nih_error_init ();
2698@@ -1536,7 +1491,7 @@
2699 * the reply will be sent to the sender.
2700 */
2701 TEST_FEATURE ("with new job");
2702- class = job_class_new (NULL, "test", session);
2703+ class = job_class_new (NULL, "test", NULL);
2704
2705 method = dbus_message_new_method_call (
2706 dbus_bus_get_unique_name (conn),
2707@@ -1627,7 +1582,7 @@
2708 * immediately and the job not blocked.
2709 */
2710 TEST_FEATURE ("with no wait");
2711- class = job_class_new (NULL, "test", session);
2712+ class = job_class_new (NULL, "test", NULL);
2713
2714 method = dbus_message_new_method_call (
2715 dbus_bus_get_unique_name (conn),
2716@@ -1707,7 +1662,7 @@
2717 * it through to running, the reply will be sent to the sender.
2718 */
2719 TEST_FEATURE ("with stopping job");
2720- class = job_class_new (NULL, "test", session);
2721+ class = job_class_new (NULL, "test", NULL);
2722 job = job_new (class, "");
2723
2724 job->goal = JOB_STOP;
2725@@ -1808,7 +1763,7 @@
2726 * a D-Bus error is raised immediately.
2727 */
2728 TEST_FEATURE ("with starting job");
2729- class = job_class_new (NULL, "test", session);
2730+ class = job_class_new (NULL, "test", NULL);
2731 job = job_new (class, "");
2732
2733 job->goal = JOB_START;
2734@@ -1864,7 +1819,7 @@
2735 * when it's starting.
2736 */
2737 TEST_FEATURE ("with environment");
2738- class = job_class_new (NULL, "test", session);
2739+ class = job_class_new (NULL, "test", NULL);
2740 class->instance = "$FOO";
2741
2742 method = dbus_message_new_method_call (
2743@@ -1965,7 +1920,7 @@
2744 * is returned.
2745 */
2746 TEST_FEATURE ("with invalid environment");
2747- class = job_class_new (NULL, "test", session);
2748+ class = job_class_new (NULL, "test", NULL);
2749
2750 method = dbus_message_new_method_call (
2751 dbus_bus_get_unique_name (conn),
2752@@ -2010,8 +1965,6 @@
2753 TEST_HASH_EMPTY (class->instances);
2754
2755 nih_free (class);
2756- nih_free (session);
2757-
2758
2759 TEST_DBUS_CLOSE (conn);
2760 TEST_DBUS_CLOSE (client_conn);
2761@@ -2037,11 +1990,6 @@
2762 int ret;
2763 NihError *error;
2764 NihDBusError *dbus_error;
2765- Session *session;
2766-
2767- session = session_new (NULL, NULL, getuid ());
2768- TEST_NE_P (session, NULL);
2769-
2770
2771 TEST_FUNCTION ("job_class_stop");
2772 nih_error_init ();
2773@@ -2058,7 +2006,7 @@
2774 * will be sent to the sender.
2775 */
2776 TEST_FEATURE ("with running job");
2777- class = job_class_new (NULL, "test", session);
2778+ class = job_class_new (NULL, "test", NULL);
2779 job = job_new (class, "");
2780
2781 job->goal = JOB_START;
2782@@ -2141,7 +2089,7 @@
2783 * and no blocking entry created.
2784 */
2785 TEST_FEATURE ("with no wait");
2786- class = job_class_new (NULL, "test", session);
2787+ class = job_class_new (NULL, "test", NULL);
2788 job = job_new (class, "");
2789
2790 job->goal = JOB_START;
2791@@ -2211,7 +2159,7 @@
2792 * a D-Bus error is raised immediately.
2793 */
2794 TEST_FEATURE ("with stopping job");
2795- class = job_class_new (NULL, "test", session);
2796+ class = job_class_new (NULL, "test", NULL);
2797 job = job_new (class, "");
2798
2799 job->goal = JOB_STOP;
2800@@ -2266,7 +2214,7 @@
2801 * immediately.
2802 */
2803 TEST_FEATURE ("with unknown job");
2804- class = job_class_new (NULL, "test", session);
2805+ class = job_class_new (NULL, "test", NULL);
2806
2807 method = dbus_message_new_method_call (
2808 dbus_bus_get_unique_name (conn),
2809@@ -2315,7 +2263,7 @@
2810 * for the pre-stop script.
2811 */
2812 TEST_FEATURE ("with environment");
2813- class = job_class_new (NULL, "test", session);
2814+ class = job_class_new (NULL, "test", NULL);
2815 class->instance = "$FOO";
2816
2817 job = job_new (class, "wibble");
2818@@ -2404,7 +2352,7 @@
2819 * is returned.
2820 */
2821 TEST_FEATURE ("with invalid environment");
2822- class = job_class_new (NULL, "test", session);
2823+ class = job_class_new (NULL, "test", NULL);
2824 job = job_new (class, "");
2825
2826 job->goal = JOB_START;
2827@@ -2451,7 +2399,6 @@
2828 nih_free (dbus_error);
2829
2830 nih_free (class);
2831- nih_free (session);
2832
2833 TEST_DBUS_CLOSE (conn);
2834 TEST_DBUS_CLOSE (client_conn);
2835@@ -2478,11 +2425,6 @@
2836 int ret;
2837 NihError *error;
2838 NihDBusError *dbus_error;
2839- Session *session;
2840-
2841- session = session_new (NULL, NULL, getuid ());
2842- TEST_NE_P (session, NULL);
2843-
2844
2845 TEST_FUNCTION ("job_class_restart");
2846 nih_error_init ();
2847@@ -2499,7 +2441,7 @@
2848 * through to waiting, the reply will be sent to the sender.
2849 */
2850 TEST_FEATURE ("with running job");
2851- class = job_class_new (NULL, "test", session);
2852+ class = job_class_new (NULL, "test", NULL);
2853 job = job_new (class, "");
2854
2855 job->goal = JOB_START;
2856@@ -2596,7 +2538,7 @@
2857 * entry created.
2858 */
2859 TEST_FEATURE ("with no wait");
2860- class = job_class_new (NULL, "test", session);
2861+ class = job_class_new (NULL, "test", NULL);
2862 job = job_new (class, "");
2863
2864 job->goal = JOB_START;
2865@@ -2677,7 +2619,7 @@
2866 * a D-Bus error is raised immediately.
2867 */
2868 TEST_FEATURE ("with stopping job");
2869- class = job_class_new (NULL, "test", session);
2870+ class = job_class_new (NULL, "test", NULL);
2871 job = job_new (class, "");
2872
2873 job->goal = JOB_STOP;
2874@@ -2732,7 +2674,7 @@
2875 * immediately.
2876 */
2877 TEST_FEATURE ("with unknown job");
2878- class = job_class_new (NULL, "test", session);
2879+ class = job_class_new (NULL, "test", NULL);
2880
2881 method = dbus_message_new_method_call (
2882 dbus_bus_get_unique_name (conn),
2883@@ -2781,7 +2723,7 @@
2884 * when it's starting again.
2885 */
2886 TEST_FEATURE ("with environment");
2887- class = job_class_new (NULL, "test", session);
2888+ class = job_class_new (NULL, "test", NULL);
2889 class->instance = "$FOO";
2890
2891 job = job_new (class, "wibble");
2892@@ -2894,7 +2836,7 @@
2893 * is returned.
2894 */
2895 TEST_FEATURE ("with invalid environment");
2896- class = job_class_new (NULL, "test", session);
2897+ class = job_class_new (NULL, "test", NULL);
2898 job = job_new (class, "");
2899
2900 job->goal = JOB_START;
2901@@ -2941,7 +2883,6 @@
2902 nih_free (dbus_error);
2903
2904 nih_free (class);
2905- nih_free (session);
2906
2907 TEST_DBUS_CLOSE (conn);
2908 TEST_DBUS_CLOSE (client_conn);
2909@@ -2961,10 +2902,6 @@
2910 NihError *error;
2911 char *name;
2912 int ret;
2913- Session *session;
2914-
2915- session = session_new (NULL, NULL, getuid ());
2916- TEST_NE_P (session, NULL);
2917
2918 /* Check that the name of the job class is returned from the
2919 * property, as a child of the message.
2920@@ -2975,7 +2912,7 @@
2921
2922 TEST_ALLOC_FAIL {
2923 TEST_ALLOC_SAFE {
2924- class = job_class_new (NULL, "test", session);
2925+ class = job_class_new (NULL, "test", NULL);
2926
2927 message = nih_new (NULL, NihDBusMessage);
2928 message->connection = NULL;
2929@@ -3006,7 +2943,6 @@
2930 nih_free (message);
2931 nih_free (class);
2932 }
2933- nih_free (session);
2934 }
2935
2936 void
2937@@ -3017,10 +2953,6 @@
2938 NihError *error;
2939 char *description;
2940 int ret;
2941- Session *session;
2942-
2943- session = session_new (NULL, NULL, getuid ());
2944- TEST_NE_P (session, NULL);
2945
2946 TEST_FUNCTION ("job_class_get_description");
2947 nih_error_init ();
2948@@ -3032,7 +2964,7 @@
2949 TEST_FEATURE ("with description");
2950 TEST_ALLOC_FAIL {
2951 TEST_ALLOC_SAFE {
2952- class = job_class_new (NULL, "test", session);
2953+ class = job_class_new (NULL, "test", NULL);
2954 class->description = nih_strdup (class, "a test job");
2955
2956 message = nih_new (NULL, NihDBusMessage);
2957@@ -3072,7 +3004,7 @@
2958 TEST_FEATURE ("with no description");
2959 TEST_ALLOC_FAIL {
2960 TEST_ALLOC_SAFE {
2961- class = job_class_new (NULL, "test", session);
2962+ class = job_class_new (NULL, "test", NULL);
2963
2964 message = nih_new (NULL, NihDBusMessage);
2965 message->connection = NULL;
2966@@ -3103,7 +3035,6 @@
2967 nih_free (message);
2968 nih_free (class);
2969 }
2970- nih_free (session);
2971 }
2972
2973 void
2974@@ -3114,10 +3045,6 @@
2975 NihError *error;
2976 char *author;
2977 int ret;
2978- Session *session;
2979-
2980- session = session_new (NULL, NULL, getuid ());
2981- TEST_NE_P (session, NULL);
2982
2983 TEST_FUNCTION ("job_class_get_author");
2984 nih_error_init ();
2985@@ -3129,7 +3056,7 @@
2986 TEST_FEATURE ("with author");
2987 TEST_ALLOC_FAIL {
2988 TEST_ALLOC_SAFE {
2989- class = job_class_new (NULL, "test", session);
2990+ class = job_class_new (NULL, "test", NULL);
2991 class->author = nih_strdup (class, "a test job");
2992
2993 message = nih_new (NULL, NihDBusMessage);
2994@@ -3169,7 +3096,7 @@
2995 TEST_FEATURE ("with no author");
2996 TEST_ALLOC_FAIL {
2997 TEST_ALLOC_SAFE {
2998- class = job_class_new (NULL, "test", session);
2999+ class = job_class_new (NULL, "test", NULL);
3000
3001 message = nih_new (NULL, NihDBusMessage);
3002 message->connection = NULL;
3003@@ -3200,7 +3127,6 @@
3004 nih_free (message);
3005 nih_free (class);
3006 }
3007- nih_free (session);
3008 }
3009
3010 void
3011@@ -3211,10 +3137,6 @@
3012 NihError *error;
3013 char *version;
3014 int ret;
3015- Session *session;
3016-
3017- session = session_new (NULL, NULL, getuid ());
3018- TEST_NE_P (session, NULL);
3019
3020 TEST_FUNCTION ("job_class_get_version");
3021 nih_error_init ();
3022@@ -3226,7 +3148,7 @@
3023 TEST_FEATURE ("with version");
3024 TEST_ALLOC_FAIL {
3025 TEST_ALLOC_SAFE {
3026- class = job_class_new (NULL, "test", session);
3027+ class = job_class_new (NULL, "test", NULL);
3028 class->version = nih_strdup (class, "a test job");
3029
3030 message = nih_new (NULL, NihDBusMessage);
3031@@ -3266,7 +3188,7 @@
3032 TEST_FEATURE ("with no version");
3033 TEST_ALLOC_FAIL {
3034 TEST_ALLOC_SAFE {
3035- class = job_class_new (NULL, "test", session);
3036+ class = job_class_new (NULL, "test", NULL);
3037
3038 message = nih_new (NULL, NihDBusMessage);
3039 message->connection = NULL;
3040@@ -3297,7 +3219,6 @@
3041 nih_free (message);
3042 nih_free (class);
3043 }
3044- nih_free (session);
3045 }
3046
3047 void
3048@@ -3310,10 +3231,6 @@
3049 NihError *error;
3050 char ***start_on;
3051 int ret;
3052- Session *session;
3053-
3054- session = session_new (NULL, NULL, getuid ());
3055- TEST_NE_P (session, NULL);
3056
3057 TEST_FUNCTION ("job_class_get_start_on");
3058
3059@@ -3326,7 +3243,7 @@
3060
3061 TEST_ALLOC_FAIL {
3062 TEST_ALLOC_SAFE {
3063- class = job_class_new (NULL, "test", session);
3064+ class = job_class_new (NULL, "test", NULL);
3065
3066 class->start_on = event_operator_new (
3067 class, EVENT_OR, NULL, NULL);
3068@@ -3421,7 +3338,7 @@
3069
3070 TEST_ALLOC_FAIL {
3071 TEST_ALLOC_SAFE {
3072- class = job_class_new (NULL, "test", session);
3073+ class = job_class_new (NULL, "test", NULL);
3074
3075 message = nih_new (NULL, NihDBusMessage);
3076 message->connection = NULL;
3077@@ -3453,7 +3370,6 @@
3078 nih_free (message);
3079 nih_free (class);
3080 }
3081- nih_free (session);
3082 }
3083
3084 void
3085@@ -3466,10 +3382,6 @@
3086 NihError *error;
3087 char ***stop_on;
3088 int ret;
3089- Session *session;
3090-
3091- session = session_new (NULL, NULL, getuid ());
3092- TEST_NE_P (session, NULL);
3093
3094 TEST_FUNCTION ("job_class_get_stop_on");
3095
3096@@ -3482,7 +3394,7 @@
3097
3098 TEST_ALLOC_FAIL {
3099 TEST_ALLOC_SAFE {
3100- class = job_class_new (NULL, "test", session);
3101+ class = job_class_new (NULL, "test", NULL);
3102
3103 class->stop_on = event_operator_new (
3104 class, EVENT_OR, NULL, NULL);
3105@@ -3577,7 +3489,7 @@
3106
3107 TEST_ALLOC_FAIL {
3108 TEST_ALLOC_SAFE {
3109- class = job_class_new (NULL, "test", session);
3110+ class = job_class_new (NULL, "test", NULL);
3111
3112 message = nih_new (NULL, NihDBusMessage);
3113 message->connection = NULL;
3114@@ -3609,7 +3521,6 @@
3115 nih_free (message);
3116 nih_free (class);
3117 }
3118- nih_free (session);
3119 }
3120
3121 void
3122@@ -3620,10 +3531,6 @@
3123 NihError *error;
3124 char **emits;
3125 int ret;
3126- Session *session;
3127-
3128- session = session_new (NULL, NULL, getuid ());
3129- TEST_NE_P (session, NULL);
3130
3131 TEST_FUNCTION ("job_class_get_emits");
3132
3133@@ -3637,7 +3544,7 @@
3134
3135 TEST_ALLOC_FAIL {
3136 TEST_ALLOC_SAFE {
3137- class = job_class_new (NULL, "test", session);
3138+ class = job_class_new (NULL, "test", NULL);
3139 class->emits = nih_str_array_new (class);
3140
3141 NIH_MUST (nih_str_array_add (&class->emits, class, NULL, "foo"));
3142@@ -3689,7 +3596,7 @@
3143
3144 TEST_ALLOC_FAIL {
3145 TEST_ALLOC_SAFE {
3146- class = job_class_new (NULL, "test", session);
3147+ class = job_class_new (NULL, "test", NULL);
3148
3149 message = nih_new (NULL, NihDBusMessage);
3150 message->connection = NULL;
3151@@ -3721,7 +3628,6 @@
3152 nih_free (message);
3153 nih_free (class);
3154 }
3155- nih_free (session);
3156 }
3157
3158
3159@@ -3729,6 +3635,9 @@
3160 main (int argc,
3161 char *argv[])
3162 {
3163+ /* run tests in legacy (pre-session support) mode */
3164+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
3165+
3166 test_new ();
3167 test_consider ();
3168 test_reconsider ();
3169
3170=== modified file 'init/tests/test_job_process.c'
3171--- init/tests/test_job_process.c 2011-02-24 15:41:04 +0000
3172+++ init/tests/test_job_process.c 2011-04-19 09:27:29 +0000
3173@@ -131,10 +131,6 @@
3174 char filename[PATH_MAX], buf[80];
3175 int ret = -1, status, first;
3176 siginfo_t info;
3177- Session *session;
3178-
3179- session = session_new (NULL, NULL, getuid ());
3180- TEST_NE_P (session, NULL);
3181
3182 TEST_FUNCTION ("job_process_run");
3183 job_class_init ();
3184@@ -151,7 +147,7 @@
3185 TEST_FEATURE ("with simple command");
3186 TEST_ALLOC_FAIL {
3187 TEST_ALLOC_SAFE {
3188- class = job_class_new (NULL, "test", session);
3189+ class = job_class_new (NULL, "test", NULL);
3190 class->process[PROCESS_MAIN] = process_new (class);
3191 class->process[PROCESS_MAIN]->command = nih_sprintf (
3192 class->process[PROCESS_MAIN],
3193@@ -183,7 +179,7 @@
3194 TEST_FEATURE ("with shell command");
3195 TEST_ALLOC_FAIL {
3196 TEST_ALLOC_SAFE {
3197- class = job_class_new (NULL, "test", session);
3198+ class = job_class_new (NULL, "test", NULL);
3199 class->process[PROCESS_MAIN] = process_new (class);
3200 class->process[PROCESS_MAIN]->command = nih_sprintf (
3201 class->process[PROCESS_MAIN],
3202@@ -220,7 +216,7 @@
3203 TEST_FEATURE ("with small script");
3204 TEST_ALLOC_FAIL {
3205 TEST_ALLOC_SAFE {
3206- class = job_class_new (NULL, "test", session);
3207+ class = job_class_new (NULL, "test", NULL);
3208 class->process[PROCESS_MAIN] = process_new (class);
3209 class->process[PROCESS_MAIN]->script = TRUE;
3210 class->process[PROCESS_MAIN]->command = nih_sprintf (
3211@@ -257,7 +253,7 @@
3212 TEST_FEATURE ("with small script and trailing newlines");
3213 TEST_ALLOC_FAIL {
3214 TEST_ALLOC_SAFE {
3215- class = job_class_new (NULL, "test", session);
3216+ class = job_class_new (NULL, "test", NULL);
3217 class->process[PROCESS_MAIN] = process_new (class);
3218 class->process[PROCESS_MAIN]->script = TRUE;
3219 class->process[PROCESS_MAIN]->command = nih_sprintf (
3220@@ -294,7 +290,7 @@
3221 TEST_FEATURE ("with script that will fail");
3222 TEST_ALLOC_FAIL {
3223 TEST_ALLOC_SAFE {
3224- class = job_class_new (NULL, "test", session);
3225+ class = job_class_new (NULL, "test", NULL);
3226 class->process[PROCESS_MAIN] = process_new (class);
3227 class->process[PROCESS_MAIN]->script = TRUE;
3228 class->process[PROCESS_MAIN]->command = nih_sprintf (
3229@@ -331,7 +327,7 @@
3230 TEST_FEATURE ("with environment of unnamed instance");
3231 TEST_ALLOC_FAIL {
3232 TEST_ALLOC_SAFE {
3233- class = job_class_new (NULL, "test", session);
3234+ class = job_class_new (NULL, "test", NULL);
3235 class->process[PROCESS_MAIN] = process_new (class);
3236 class->process[PROCESS_MAIN]->command = nih_sprintf (
3237 class->process[PROCESS_MAIN],
3238@@ -380,7 +376,7 @@
3239 TEST_FEATURE ("with environment of named instance");
3240 TEST_ALLOC_FAIL {
3241 TEST_ALLOC_SAFE {
3242- class = job_class_new (NULL, "test", session);
3243+ class = job_class_new (NULL, "test", NULL);
3244 class->process[PROCESS_MAIN] = process_new (class);
3245 class->process[PROCESS_MAIN]->command = nih_sprintf (
3246 class->process[PROCESS_MAIN],
3247@@ -430,7 +426,7 @@
3248 TEST_FEATURE ("with environment for pre-stop");
3249 TEST_ALLOC_FAIL {
3250 TEST_ALLOC_SAFE {
3251- class = job_class_new (NULL, "test", session);
3252+ class = job_class_new (NULL, "test", NULL);
3253 class->process[PROCESS_PRE_STOP] = process_new (class);
3254 class->process[PROCESS_PRE_STOP]->command = nih_sprintf (
3255 class->process[PROCESS_PRE_STOP],
3256@@ -481,7 +477,7 @@
3257 TEST_FEATURE ("with environment for post-stop");
3258 TEST_ALLOC_FAIL {
3259 TEST_ALLOC_SAFE {
3260- class = job_class_new (NULL, "test", session);
3261+ class = job_class_new (NULL, "test", NULL);
3262 class->process[PROCESS_POST_STOP] = process_new (class);
3263 class->process[PROCESS_POST_STOP]->command = nih_sprintf (
3264 class->process[PROCESS_POST_STOP],
3265@@ -532,7 +528,7 @@
3266 TEST_FEATURE ("with long script");
3267 TEST_ALLOC_FAIL {
3268 TEST_ALLOC_SAFE {
3269- class = job_class_new (NULL, "test", session);
3270+ class = job_class_new (NULL, "test", NULL);
3271 class->process[PROCESS_MAIN] = process_new (class);
3272 class->process[PROCESS_MAIN]->script = TRUE;
3273 class->process[PROCESS_MAIN]->command = nih_alloc (
3274@@ -597,7 +593,7 @@
3275 TEST_FEATURE ("with non-daemon job");
3276 TEST_ALLOC_FAIL {
3277 TEST_ALLOC_SAFE {
3278- class = job_class_new (NULL, "test", session);
3279+ class = job_class_new (NULL, "test", NULL);
3280 class->process[PROCESS_MAIN] = process_new (class);
3281 class->process[PROCESS_MAIN]->command = "true";
3282
3283@@ -633,7 +629,7 @@
3284 TEST_FEATURE ("with script for daemon job");
3285 TEST_ALLOC_FAIL {
3286 TEST_ALLOC_SAFE {
3287- class = job_class_new (NULL, "test", session);
3288+ class = job_class_new (NULL, "test", NULL);
3289 class->process[PROCESS_PRE_START] = process_new (class);
3290 class->process[PROCESS_PRE_START]->command = "true";
3291
3292@@ -670,7 +666,7 @@
3293 TEST_FEATURE ("with daemon job");
3294 TEST_ALLOC_FAIL {
3295 TEST_ALLOC_SAFE {
3296- class = job_class_new (NULL, "test", session);
3297+ class = job_class_new (NULL, "test", NULL);
3298 class->expect = EXPECT_DAEMON;
3299 class->process[PROCESS_MAIN] = process_new (class);
3300 class->process[PROCESS_MAIN]->command = "true";
3301@@ -717,7 +713,7 @@
3302 TEST_FEATURE ("with forking job");
3303 TEST_ALLOC_FAIL {
3304 TEST_ALLOC_SAFE {
3305- class = job_class_new (NULL, "test", session);
3306+ class = job_class_new (NULL, "test", NULL);
3307 class->expect = EXPECT_FORK;
3308 class->process[PROCESS_MAIN] = process_new (class);
3309 class->process[PROCESS_MAIN]->command = "true";
3310@@ -766,7 +762,7 @@
3311
3312 TEST_ALLOC_FAIL {
3313 TEST_ALLOC_SAFE {
3314- class = job_class_new (NULL, "test", session);
3315+ class = job_class_new (NULL, "test", NULL);
3316 class->process[PROCESS_MAIN] = process_new (class);
3317 class->process[PROCESS_MAIN]->command = filename;
3318
3319@@ -791,7 +787,6 @@
3320
3321 nih_free (class);
3322 }
3323- nih_free (session);
3324 }
3325
3326
3327@@ -808,10 +803,6 @@
3328 NihError *err;
3329 JobProcessError *perr;
3330 int status;
3331- Session *session;
3332-
3333- session = session_new (NULL, NULL, getuid ());
3334- TEST_NE_P (session, NULL);
3335
3336 TEST_FUNCTION ("job_process_spawn");
3337 TEST_FILENAME (filename);
3338@@ -828,7 +819,7 @@
3339 TEST_FEATURE ("with simple job");
3340 sprintf (function, "%d", TEST_PIDS);
3341
3342- class = job_class_new (NULL, "test", session);
3343+ class = job_class_new (NULL, "test", NULL);
3344
3345 pid = job_process_spawn (class, args, NULL, FALSE);
3346 TEST_GT (pid, 0);
3347@@ -865,7 +856,7 @@
3348 TEST_FEATURE ("with no console");
3349 sprintf (function, "%d", TEST_CONSOLE);
3350
3351- class = job_class_new (NULL, "test", session);
3352+ class = job_class_new (NULL, "test", NULL);
3353 class->console = CONSOLE_NONE;
3354
3355 pid = job_process_spawn (class, args, NULL, FALSE);
3356@@ -891,7 +882,7 @@
3357 TEST_FEATURE ("with working directory");
3358 sprintf (function, "%d", TEST_PWD);
3359
3360- class = job_class_new (NULL, "test", session);
3361+ class = job_class_new (NULL, "test", NULL);
3362 class->chdir = "/tmp";
3363
3364 pid = job_process_spawn (class, args, NULL, FALSE);
3365@@ -920,7 +911,7 @@
3366 env[1] = "FOO=bar";
3367 env[2] = NULL;
3368
3369- class = job_class_new (NULL, "test", session);
3370+ class = job_class_new (NULL, "test", NULL);
3371
3372 pid = job_process_spawn (class, args, env, FALSE);
3373 TEST_GT (pid, 0);
3374@@ -945,7 +936,7 @@
3375 TEST_FEATURE ("with non-daemon job");
3376 sprintf (function, "%d", TEST_SIMPLE);
3377
3378- class = job_class_new (NULL, "test", session);
3379+ class = job_class_new (NULL, "test", NULL);
3380
3381 pid = job_process_spawn (class, args, NULL, FALSE);
3382 TEST_GT (pid, 0);
3383@@ -965,7 +956,7 @@
3384 TEST_FEATURE ("with daemon job");
3385 sprintf (function, "%d", TEST_SIMPLE);
3386
3387- class = job_class_new (NULL, "test", session);
3388+ class = job_class_new (NULL, "test", NULL);
3389
3390 pid = job_process_spawn (class, args, NULL, TRUE);
3391 TEST_GT (pid, 0);
3392@@ -994,7 +985,7 @@
3393 args[1] = filename;
3394 args[2] = NULL;
3395
3396- class = job_class_new (NULL, "test", session);
3397+ class = job_class_new (NULL, "test", NULL);
3398
3399 pid = job_process_spawn (class, args, NULL, FALSE);
3400 TEST_LT (pid, 0);
3401@@ -1013,7 +1004,7 @@
3402 */
3403 TEST_FEATURE ("with debug enabled");
3404
3405- class = job_class_new (NULL, "test", session);
3406+ class = job_class_new (NULL, "test", NULL);
3407 class->debug = TRUE;
3408
3409 sprintf (function, "%s", "/bin/true");
3410@@ -1042,7 +1033,6 @@
3411 TEST_EQ (WEXITSTATUS (status), 0);
3412
3413 nih_free (class);
3414- nih_free (session);
3415 }
3416
3417
3418@@ -1055,16 +1045,12 @@
3419 struct timespec now;
3420 pid_t pid;
3421 int status;
3422- Session *session;
3423-
3424- session = session_new (NULL, NULL, getuid ());
3425- TEST_NE_P (session, NULL);
3426
3427 TEST_FUNCTION ("job_process_kill");
3428 nih_timer_init ();
3429 event_init ();
3430
3431- class = job_class_new (NULL, "test", session);
3432+ class = job_class_new (NULL, "test", NULL);
3433 class->kill_timeout = 1000;
3434
3435 class->process[PROCESS_MAIN] = process_new (class);
3436@@ -1191,7 +1177,6 @@
3437 }
3438
3439 nih_free (class);
3440- nih_free (session);
3441 }
3442
3443
3444@@ -1212,10 +1197,6 @@
3445 siginfo_t info;
3446 unsigned long data;
3447 struct timespec now;
3448- Session *session;
3449-
3450- session = session_new (NULL, NULL, getuid ());
3451- TEST_NE_P (session, NULL);
3452
3453 TEST_FUNCTION ("job_process_handler");
3454 program_name = "test";
3455@@ -1223,7 +1204,7 @@
3456
3457 source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
3458 file = conf_file_new (source, "/tmp/test");
3459- file->job = class = job_class_new (NULL, "test", session);
3460+ file->job = class = job_class_new (NULL, "test", NULL);
3461 class->process[PROCESS_MAIN] = process_new (class);
3462 class->process[PROCESS_MAIN]->command = "echo";
3463
3464@@ -4387,7 +4368,6 @@
3465 nih_free (source);
3466
3467 nih_free (event);
3468- nih_free (session);
3469 event_poll ();
3470 }
3471
3472@@ -4398,26 +4378,22 @@
3473 JobClass *class1, *class2, *class3;
3474 Job *job1, *job2, *job3, *job4, *job5, *ptr;
3475 ProcessType process;
3476- Session *session;
3477-
3478- session = session_new (NULL, NULL, getuid ());
3479- TEST_NE_P (session, NULL);
3480
3481 TEST_FUNCTION ("job_process_find");
3482- class1 = job_class_new (NULL, "foo", session);
3483+ class1 = job_class_new (NULL, "foo", NULL);
3484 class1->process[PROCESS_MAIN] = process_new (class1);
3485 class1->process[PROCESS_POST_START] = process_new (class1);
3486 class1->instance = "$FOO";
3487 nih_hash_add (job_classes, &class1->entry);
3488
3489- class2 = job_class_new (NULL, "bar", session);
3490+ class2 = job_class_new (NULL, "bar", NULL);
3491 class2->process[PROCESS_PRE_START] = process_new (class2);
3492 class2->process[PROCESS_MAIN] = process_new (class2);
3493 class2->process[PROCESS_PRE_STOP] = process_new (class2);
3494 class2->instance = "$FOO";
3495 nih_hash_add (job_classes, &class2->entry);
3496
3497- class3 = job_class_new (NULL, "baz", session);
3498+ class3 = job_class_new (NULL, "baz", NULL);
3499 class3->process[PROCESS_POST_STOP] = process_new (class3);
3500 nih_hash_add (job_classes, &class3->entry);
3501
3502@@ -4521,7 +4497,6 @@
3503 nih_free (class1);
3504 nih_free (class2);
3505 nih_free (class3);
3506- nih_free (session);
3507 ptr = job_process_find (20, NULL);
3508
3509 TEST_EQ_P (ptr, NULL);
3510@@ -4539,15 +4514,11 @@
3511 char utmpname[PATH_MAX];
3512 struct utmpx utmp, *utmptr;
3513 struct timeval tv;
3514- Session *session;
3515-
3516- session = session_new (NULL, NULL, getuid ());
3517- TEST_NE_P (session, NULL);
3518
3519 TEST_FUNCTION ("job_process_handler");
3520 program_name = "test";
3521
3522- class = job_class_new (NULL, "test", session);
3523+ class = job_class_new (NULL, "test", NULL);
3524 class->process[PROCESS_MAIN] = process_new (class);
3525 class->process[PROCESS_MAIN]->command = "echo";
3526
3527@@ -4765,7 +4736,6 @@
3528
3529 nih_free (job);
3530 }
3531- nih_free (session);
3532 }
3533
3534
3535@@ -4773,6 +4743,11 @@
3536 main (int argc,
3537 char *argv[])
3538 {
3539+ /* Note we do not set the UPSTART_NO_SESSIONS variable since this
3540+ * would cause these tests to fail (as they scrutinize the job
3541+ * environment).
3542+ */
3543+
3544 /* We re-exec this binary to test various children features. To
3545 * do that, we need to know the full path to the program.
3546 */
3547
3548=== modified file 'init/tests/test_parse_conf.c'
3549--- init/tests/test_parse_conf.c 2009-06-23 09:29:35 +0000
3550+++ init/tests/test_parse_conf.c 2011-04-19 09:27:29 +0000
3551@@ -77,6 +77,9 @@
3552 main (int argc,
3553 char *argv[])
3554 {
3555+ /* run tests in legacy (pre-session support) mode */
3556+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
3557+
3558 test_parse_conf ();
3559
3560 return 0;
3561
3562=== modified file 'init/tests/test_parse_job.c'
3563--- init/tests/test_parse_job.c 2011-02-23 11:04:27 +0000
3564+++ init/tests/test_parse_job.c 2011-04-19 09:27:29 +0000
3565@@ -7536,6 +7536,9 @@
3566 main (int argc,
3567 char *argv[])
3568 {
3569+ /* run tests in legacy (pre-session support) mode */
3570+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
3571+
3572 test_parse_job ();
3573
3574 test_stanza_instance ();
3575
3576=== modified file 'init/tests/test_process.c'
3577--- init/tests/test_process.c 2009-06-23 09:29:35 +0000
3578+++ init/tests/test_process.c 2011-04-19 09:27:29 +0000
3579@@ -157,6 +157,9 @@
3580 main (int argc,
3581 char *argv[])
3582 {
3583+ /* run tests in legacy (pre-session support) mode */
3584+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
3585+
3586 test_new ();
3587
3588 test_name ();
3589
3590=== modified file 'init/tests/test_system.c'
3591--- init/tests/test_system.c 2009-06-23 09:29:35 +0000
3592+++ init/tests/test_system.c 2011-04-19 09:27:29 +0000
3593@@ -133,6 +133,9 @@
3594 main (int argc,
3595 char *argv[])
3596 {
3597+ /* run tests in legacy (pre-session support) mode */
3598+ setenv ("UPSTART_NO_SESSIONS", "1", 1);
3599+
3600 test_kill ();
3601
3602 return 0;
3603
3604=== modified file 'po/upstart.pot'
3605--- po/upstart.pot 2011-03-24 13:11:53 +0000
3606+++ po/upstart.pot 2011-04-19 09:27:29 +0000
3607@@ -6,9 +6,9 @@
3608 #, fuzzy
3609 msgid ""
3610 msgstr ""
3611-"Project-Id-Version: upstart 0.9.4\n"
3612+"Project-Id-Version: upstart 0.9.5\n"
3613 "Report-Msgid-Bugs-To: new@bugs.launchpad.net\n"
3614-"POT-Creation-Date: 2011-03-24 11:26+0000\n"
3615+"POT-Creation-Date: 2011-04-15 12:11+0100\n"
3616 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
3617 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
3618 "Language-Team: LANGUAGE <LL@li.org>\n"
3619@@ -35,26 +35,26 @@
3620 msgid "Unable to watch configuration file"
3621 msgstr ""
3622
3623-#: init/conf.c:524 init/conf.c:924
3624-msgid "Error while reloading configuration file"
3625-msgstr ""
3626-
3627-#: init/conf.c:601
3628+#: init/conf.c:598
3629 msgid "Unable to watch configuration directory"
3630 msgstr ""
3631
3632-#: init/conf.c:772 init/conf.c:904
3633+#: init/conf.c:769 init/conf.c:901
3634 msgid "Error while loading configuration file"
3635 msgstr ""
3636
3637-#: init/conf.c:819
3638+#: init/conf.c:816
3639 msgid "Configuration directory deleted"
3640 msgstr ""
3641
3642-#: init/conf.c:848
3643+#: init/conf.c:845
3644 msgid "Unable to reload configuration after override deletion"
3645 msgstr ""
3646
3647+#: init/conf.c:921
3648+msgid "Error while reloading configuration file"
3649+msgstr ""
3650+
3651 #: init/control.c:165
3652 msgid "Connection from private client"
3653 msgstr ""
3654@@ -63,25 +63,25 @@
3655 msgid "Disconnected from system bus"
3656 msgstr ""
3657
3658-#: init/control.c:370 init/main.c:549
3659+#: init/control.c:370 init/main.c:557
3660 msgid "Reloading configuration"
3661 msgstr ""
3662
3663-#: init/control.c:412 init/control.c:561
3664+#: init/control.c:412 init/control.c:565
3665 msgid "Name may not be empty string"
3666 msgstr ""
3667
3668-#: init/control.c:438
3669+#: init/control.c:442
3670 #, c-format
3671 msgid "Unknown job: %s"
3672 msgstr ""
3673
3674-#: init/control.c:569 init/job_class.c:559 init/job_class.c:758
3675-#: init/job_class.c:888 init/job_class.c:1023
3676+#: init/control.c:573 init/job_class.c:579 init/job_class.c:778
3677+#: init/job_class.c:908 init/job_class.c:1043
3678 msgid "Env must be KEY=VALUE pairs"
3679 msgstr ""
3680
3681-#: init/control.c:738
3682+#: init/control.c:742
3683 msgid "The log priority given was not recognised"
3684 msgstr ""
3685
3686@@ -99,337 +99,341 @@
3687 msgid "Event failed"
3688 msgstr ""
3689
3690-#: init/job.c:227
3691+#: init/job.c:233
3692 #, c-format
3693 msgid "%s goal changed from %s to %s"
3694 msgstr ""
3695
3696-#: init/job.c:298
3697+#: init/job.c:304
3698 #, c-format
3699 msgid "%s state changed from %s to %s"
3700 msgstr ""
3701
3702-#: init/job.c:717 init/job.c:755
3703+#: init/job.c:723 init/job.c:761
3704 msgid "Job failed to start"
3705 msgstr ""
3706
3707-#: init/job.c:730 init/job.c:766
3708+#: init/job.c:736 init/job.c:772
3709 msgid "Job failed while stopping"
3710 msgstr ""
3711
3712-#: init/job.c:742 init/job.c:777
3713+#: init/job.c:748 init/job.c:783
3714 msgid "Job failed to restart"
3715 msgstr ""
3716
3717-#: init/job.c:971
3718+#: init/job.c:977
3719 msgid "stop"
3720 msgstr ""
3721
3722-#: init/job.c:973
3723+#: init/job.c:979
3724 msgid "start"
3725 msgstr ""
3726
3727-#: init/job.c:975
3728+#: init/job.c:981
3729 msgid "respawn"
3730 msgstr ""
3731
3732-#: init/job.c:1020
3733+#: init/job.c:1026
3734 msgid "waiting"
3735 msgstr ""
3736
3737-#: init/job.c:1022
3738+#: init/job.c:1028
3739 msgid "starting"
3740 msgstr ""
3741
3742-#: init/job.c:1024 init/process.c:80
3743+#: init/job.c:1030 init/process.c:80
3744 msgid "pre-start"
3745 msgstr ""
3746
3747-#: init/job.c:1026
3748+#: init/job.c:1032
3749 msgid "spawned"
3750 msgstr ""
3751
3752-#: init/job.c:1028 init/process.c:82
3753+#: init/job.c:1034 init/process.c:82
3754 msgid "post-start"
3755 msgstr ""
3756
3757-#: init/job.c:1030
3758+#: init/job.c:1036
3759 msgid "running"
3760 msgstr ""
3761
3762-#: init/job.c:1032 init/process.c:84
3763+#: init/job.c:1038 init/process.c:84
3764 msgid "pre-stop"
3765 msgstr ""
3766
3767-#: init/job.c:1034
3768+#: init/job.c:1040
3769 msgid "stopping"
3770 msgstr ""
3771
3772-#: init/job.c:1036
3773+#: init/job.c:1042
3774 msgid "killed"
3775 msgstr ""
3776
3777-#: init/job.c:1038 init/process.c:86
3778+#: init/job.c:1044 init/process.c:86
3779 msgid "post-stop"
3780 msgstr ""
3781
3782-#: init/job.c:1121 init/job.c:1196 init/job.c:1272 init/job_class.c:750
3783-#: init/job_class.c:880 init/job_class.c:1015
3784+#: init/job.c:1127 init/job.c:1202 init/job.c:1278 init/job_class.c:770
3785+#: init/job_class.c:900 init/job_class.c:1035
3786 #, c-format
3787 msgid "You do not have permission to modify job: %s"
3788 msgstr ""
3789
3790-#: init/job.c:1129 init/job_class.c:804
3791+#: init/job.c:1135 init/job_class.c:824
3792 #, c-format
3793 msgid "Job is already running: %s"
3794 msgstr ""
3795
3796-#: init/job.c:1204 init/job.c:1280 init/job_class.c:934 init/job_class.c:1068
3797+#: init/job.c:1210 init/job.c:1286 init/job_class.c:954 init/job_class.c:1088
3798 #, c-format
3799 msgid "Job has already been stopped: %s"
3800 msgstr ""
3801
3802-#: init/job_class.c:596 init/job_class.c:641 init/job_class.c:926
3803-#: init/job_class.c:1060
3804+#: init/job_class.c:616 init/job_class.c:661 init/job_class.c:946
3805+#: init/job_class.c:1080
3806 #, c-format
3807 msgid "Unknown instance: %s"
3808 msgstr ""
3809
3810-#: init/job_process.c:278
3811+#: init/job_process.c:279
3812 #, c-format
3813 msgid "Failed to spawn %s %s process: %s"
3814 msgstr ""
3815
3816-#: init/job_process.c:284
3817+#: init/job_process.c:285
3818 msgid "Temporary process spawn error"
3819 msgstr ""
3820
3821-#: init/job_process.c:291
3822+#: init/job_process.c:292
3823 #, c-format
3824 msgid "%s %s process (%d)"
3825 msgstr ""
3826
3827-#: init/job_process.c:391
3828+#: init/job_process.c:392
3829 #, c-format
3830 msgid "Pausing %s (%d) [pre-exec] for debug"
3831 msgstr ""
3832
3833-#: init/job_process.c:445
3834+#: init/job_process.c:446
3835 #, c-format
3836 msgid "Failed to open system console: %s"
3837 msgstr ""
3838
3839-#: init/job_process.c:661
3840+#: init/job_process.c:720
3841 #, c-format
3842 msgid "unable to open console: %s"
3843 msgstr ""
3844
3845-#: init/job_process.c:716
3846+#: init/job_process.c:775
3847 #, c-format
3848 msgid "unable to set \"%s\" resource limit: %s"
3849 msgstr ""
3850
3851-#: init/job_process.c:721
3852+#: init/job_process.c:780
3853 #, c-format
3854 msgid "unable to set priority: %s"
3855 msgstr ""
3856
3857-#: init/job_process.c:726
3858+#: init/job_process.c:785
3859 #, c-format
3860 msgid "unable to set oom adjustment: %s"
3861 msgstr ""
3862
3863-#: init/job_process.c:731
3864+#: init/job_process.c:790
3865 #, c-format
3866 msgid "unable to change root directory: %s"
3867 msgstr ""
3868
3869-#: init/job_process.c:736
3870+#: init/job_process.c:795
3871 #, c-format
3872 msgid "unable to change working directory: %s"
3873 msgstr ""
3874
3875-#: init/job_process.c:741
3876+#: init/job_process.c:800
3877 #, c-format
3878 msgid "unable to set trace: %s"
3879 msgstr ""
3880
3881-#: init/job_process.c:746
3882+#: init/job_process.c:805
3883 #, c-format
3884 msgid "unable to execute: %s"
3885 msgstr ""
3886
3887-#: init/job_process.c:777
3888+#: init/job_process.c:836
3889 #, c-format
3890 msgid "Sending TERM signal to %s %s process (%d)"
3891 msgstr ""
3892
3893-#: init/job_process.c:785
3894+#: init/job_process.c:844
3895 #, c-format
3896 msgid "Failed to send TERM signal to %s %s process (%d): %s"
3897 msgstr ""
3898
3899-#: init/job_process.c:825
3900+#: init/job_process.c:884
3901 #, c-format
3902 msgid "Sending KILL signal to %s %s process (%d)"
3903 msgstr ""
3904
3905-#: init/job_process.c:833
3906+#: init/job_process.c:892
3907 #, c-format
3908 msgid "Failed to send KILL signal to %s %s process (%d): %s"
3909 msgstr ""
3910
3911-#: init/job_process.c:882
3912+#: init/job_process.c:941
3913 #, c-format
3914 msgid "%s %s process (%d) terminated with status %d"
3915 msgstr ""
3916
3917-#: init/job_process.c:887
3918+#: init/job_process.c:946
3919 #, c-format
3920 msgid "%s %s process (%d) exited normally"
3921 msgstr ""
3922
3923-#: init/job_process.c:902
3924+#: init/job_process.c:961
3925 #, c-format
3926 msgid "%s %s process (%d) killed by %s signal"
3927 msgstr ""
3928
3929-#: init/job_process.c:906
3930+#: init/job_process.c:965
3931 #, c-format
3932 msgid "%s %s process (%d) killed by signal %d"
3933 msgstr ""
3934
3935-#: init/job_process.c:920
3936+#: init/job_process.c:979
3937 #, c-format
3938 msgid "%s %s process (%d) stopped by %s signal"
3939 msgstr ""
3940
3941-#: init/job_process.c:924
3942+#: init/job_process.c:983
3943 #, c-format
3944 msgid "%s %s process (%d) stopped by signal %d"
3945 msgstr ""
3946
3947-#: init/job_process.c:938
3948+#: init/job_process.c:997
3949 #, c-format
3950 msgid "%s %s process (%d) continued by %s signal"
3951 msgstr ""
3952
3953-#: init/job_process.c:942
3954+#: init/job_process.c:1001
3955 #, c-format
3956 msgid "%s %s process (%d) continued by signal %d"
3957 msgstr ""
3958
3959-#: init/job_process.c:1077
3960+#: init/job_process.c:1136
3961 #, c-format
3962 msgid "%s respawning too fast, stopped"
3963 msgstr ""
3964
3965-#: init/job_process.c:1083
3966+#: init/job_process.c:1142
3967 #, c-format
3968 msgid "%s %s process ended, respawning"
3969 msgstr ""
3970
3971-#: init/job_process.c:1323
3972+#: init/job_process.c:1382
3973 #, c-format
3974 msgid "Failed to set ptrace options for %s %s process (%d): %s"
3975 msgstr ""
3976
3977-#: init/job_process.c:1336 init/job_process.c:1531
3978+#: init/job_process.c:1395 init/job_process.c:1590
3979 #, c-format
3980 msgid "Failed to continue traced %s %s process (%d): %s"
3981 msgstr ""
3982
3983-#: init/job_process.c:1376 init/job_process.c:1467 init/job_process.c:1522
3984+#: init/job_process.c:1435 init/job_process.c:1526 init/job_process.c:1581
3985 #, c-format
3986 msgid "Failed to detach traced %s %s process (%d): %s"
3987 msgstr ""
3988
3989-#: init/job_process.c:1416
3990+#: init/job_process.c:1475
3991 #, c-format
3992 msgid "Failed to deliver signal to traced %s %s process (%d): %s"
3993 msgstr ""
3994
3995-#: init/job_process.c:1451
3996+#: init/job_process.c:1510
3997 #, c-format
3998 msgid "Failed to obtain child process id for %s %s process (%d): %s"
3999 msgstr ""
4000
4001-#: init/job_process.c:1458
4002+#: init/job_process.c:1517
4003 #, c-format
4004 msgid "%s %s process (%d) became new process (%d)"
4005 msgstr ""
4006
4007-#: init/job_process.c:1517
4008+#: init/job_process.c:1576
4009 #, c-format
4010 msgid "%s %s process (%d) executable changed"
4011 msgstr ""
4012
4013-#: init/main.c:122
4014+#: init/main.c:124
4015 msgid "specify alternative directory to load configuration files from"
4016 msgstr ""
4017
4018-#: init/main.c:125
4019+#: init/main.c:127
4020 msgid "specify an alternative initial event (for testing)"
4021 msgstr ""
4022
4023-#: init/main.c:128
4024+#: init/main.c:130
4025 msgid "do not emit any startup event (for testing)"
4026 msgstr ""
4027
4028 #: init/main.c:133
4029+msgid "Disable user and chroot sessions"
4030+msgstr ""
4031+
4032+#: init/main.c:138
4033 msgid "use D-Bus session bus rather than system bus (for testing)"
4034 msgstr ""
4035
4036-#: init/main.c:153
4037+#: init/main.c:158
4038 msgid "Process management daemon."
4039 msgstr ""
4040
4041-#: init/main.c:155
4042+#: init/main.c:160
4043 msgid ""
4044 "This daemon is normally executed by the kernel and given process id 1 to "
4045 "denote its special status. When executed by a user process, it will "
4046 "actually run /sbin/telinit."
4047 msgstr ""
4048
4049-#: init/main.c:171 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148
4050+#: init/main.c:176 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148
4051 msgid "Need to be root"
4052 msgstr ""
4053
4054-#: init/main.c:180
4055+#: init/main.c:185
4056 msgid "Not being executed as init"
4057 msgstr ""
4058
4059-#: init/main.c:230 init/main.c:459
4060+#: init/main.c:235 init/main.c:467
4061 msgid "Unable to set root directory"
4062 msgstr ""
4063
4064-#: init/main.c:241
4065+#: init/main.c:246
4066 msgid "Unable to mount /proc filesystem"
4067 msgstr ""
4068
4069-#: init/main.c:250
4070+#: init/main.c:255
4071 msgid "Unable to mount /sys filesystem"
4072 msgstr ""
4073
4074-#: init/main.c:346
4075+#: init/main.c:351
4076 msgid "Unable to listen for private connections"
4077 msgstr ""
4078
4079-#: init/main.c:476
4080+#: init/main.c:484
4081 #, c-format
4082 msgid "Caught %s, core dumped"
4083 msgstr ""
4084
4085-#: init/main.c:480
4086+#: init/main.c:488
4087 #, c-format
4088 msgid "Caught %s, unable to dump core"
4089 msgstr ""
4090
4091-#: init/main.c:566
4092+#: init/main.c:574
4093 msgid "Reconnecting to system bus"
4094 msgstr ""
4095
4096-#: init/main.c:572
4097+#: init/main.c:580
4098 msgid "Unable to connect to the system bus"
4099 msgstr ""
4100
4101@@ -437,98 +441,110 @@
4102 msgid "main"
4103 msgstr ""
4104
4105-#: util/initctl.c:310
4106+#: util/initctl.c:318
4107 msgid "Unable to connect to system bus"
4108 msgstr ""
4109
4110-#: util/initctl.c:311
4111+#: util/initctl.c:319
4112 msgid "Unable to connect to session bus"
4113 msgstr ""
4114
4115-#: util/initctl.c:320
4116+#: util/initctl.c:328
4117 #, c-format
4118 msgid "%s: --dest given without --system\n"
4119 msgstr ""
4120
4121-#: util/initctl.c:328
4122+#: util/initctl.c:336
4123 msgid "Unable to connect to Upstart"
4124 msgstr ""
4125
4126-#: util/initctl.c:514 util/initctl.c:649 util/initctl.c:777 util/initctl.c:912
4127-#: util/initctl.c:1017
4128+#: util/initctl.c:522 util/initctl.c:657 util/initctl.c:785 util/initctl.c:920
4129+#: util/initctl.c:1025
4130 #, c-format
4131 msgid "%s: missing job name\n"
4132 msgstr ""
4133
4134-#: util/initctl.c:963
4135+#: util/initctl.c:971
4136 msgid "Not running"
4137 msgstr ""
4138
4139-#: util/initctl.c:1319
4140+#: util/initctl.c:1327
4141 #, c-format
4142 msgid "%s: missing event name\n"
4143 msgstr ""
4144
4145-#: util/initctl.c:1517
4146+#: util/initctl.c:1525
4147 msgid "Invalid job class"
4148 msgstr ""
4149
4150-#: util/initctl.c:2218
4151+#: util/initctl.c:2122
4152+msgid "unknown event"
4153+msgstr ""
4154+
4155+#: util/initctl.c:2126
4156+msgid "unknown job"
4157+msgstr ""
4158+
4159+#: util/initctl.c:2227
4160 msgid "use D-Bus session bus to connect to init daemon (for testing)"
4161 msgstr ""
4162
4163-#: util/initctl.c:2220
4164+#: util/initctl.c:2229
4165 msgid "use D-Bus system bus to connect to init daemon"
4166 msgstr ""
4167
4168-#: util/initctl.c:2222
4169+#: util/initctl.c:2231
4170 msgid "destination well-known name on D-Bus bus"
4171 msgstr ""
4172
4173-#: util/initctl.c:2235
4174+#: util/initctl.c:2244
4175 msgid "do not wait for job to start before exiting"
4176 msgstr ""
4177
4178-#: util/initctl.c:2247
4179+#: util/initctl.c:2256
4180 msgid "do not wait for job to stop before exiting"
4181 msgstr ""
4182
4183-#: util/initctl.c:2259
4184+#: util/initctl.c:2268
4185 msgid "do not wait for job to restart before exiting"
4186 msgstr ""
4187
4188-#: util/initctl.c:2298
4189+#: util/initctl.c:2307
4190 msgid "do not wait for event to finish before exiting"
4191 msgstr ""
4192
4193-#: util/initctl.c:2339
4194+#: util/initctl.c:2348
4195 msgid ""
4196 "enumerate list of events and jobs causing job created from job config to "
4197 "start/stop"
4198 msgstr ""
4199
4200-#: util/initctl.c:2352
4201+#: util/initctl.c:2361
4202 msgid "ignore specified list of events (comma-separated)"
4203 msgstr ""
4204
4205-#: util/initctl.c:2361
4206+#: util/initctl.c:2363
4207+msgid "Generate warning for any unreachable events/jobs"
4208+msgstr ""
4209+
4210+#: util/initctl.c:2372
4211 msgid "Job"
4212 msgstr ""
4213
4214-#: util/initctl.c:2368
4215+#: util/initctl.c:2379
4216 msgid "Event"
4217 msgstr ""
4218
4219-#: util/initctl.c:2376 util/initctl.c:2388 util/initctl.c:2399
4220-#: util/initctl.c:2410 util/initctl.c:2417
4221+#: util/initctl.c:2387 util/initctl.c:2399 util/initctl.c:2410
4222+#: util/initctl.c:2421 util/initctl.c:2428
4223 msgid "JOB [KEY=VALUE]..."
4224 msgstr ""
4225
4226-#: util/initctl.c:2377
4227+#: util/initctl.c:2388
4228 msgid "Start job."
4229 msgstr ""
4230
4231-#: util/initctl.c:2378
4232+#: util/initctl.c:2389
4233 msgid ""
4234 "JOB is the name of the job that is to be started, this may be followed by "
4235 "zero or more environment variables to be defined in the new job.\n"
4236@@ -538,11 +554,11 @@
4237 "an existing instance is already running."
4238 msgstr ""
4239
4240-#: util/initctl.c:2389
4241+#: util/initctl.c:2400
4242 msgid "Stop job."
4243 msgstr ""
4244
4245-#: util/initctl.c:2390
4246+#: util/initctl.c:2401
4247 msgid ""
4248 "JOB is the name of the job that is to be stopped, this may be followed by "
4249 "zero or more environment variables to be passed to the job's pre-stop and "
4250@@ -552,11 +568,11 @@
4251 "decide which of multiple instances will be stopped."
4252 msgstr ""
4253
4254-#: util/initctl.c:2400
4255+#: util/initctl.c:2411
4256 msgid "Restart job."
4257 msgstr ""
4258
4259-#: util/initctl.c:2401
4260+#: util/initctl.c:2412
4261 msgid ""
4262 "JOB is the name of the job that is to be restarted, this may be followed by "
4263 "zero or more environment variables to be defined in the job after "
4264@@ -566,66 +582,66 @@
4265 "decide which of multiple instances will be restarted."
4266 msgstr ""
4267
4268-#: util/initctl.c:2411
4269+#: util/initctl.c:2422
4270 msgid "Send HUP signal to job."
4271 msgstr ""
4272
4273-#: util/initctl.c:2412
4274+#: util/initctl.c:2423
4275 msgid ""
4276 "JOB is the name of the job that is to be sent the signal, this may be "
4277 "followed by zero or more environment variables to distinguish between job "
4278 "instances.\n"
4279 msgstr ""
4280
4281-#: util/initctl.c:2418
4282+#: util/initctl.c:2429
4283 msgid "Query status of job."
4284 msgstr ""
4285
4286-#: util/initctl.c:2419
4287+#: util/initctl.c:2430
4288 msgid ""
4289 "JOB is the name of the job that is to be queried, this may be followed by "
4290 "zero or more environment variables to distguish between job instances.\n"
4291 msgstr ""
4292
4293-#: util/initctl.c:2425
4294+#: util/initctl.c:2436
4295 msgid "List known jobs."
4296 msgstr ""
4297
4298-#: util/initctl.c:2426
4299+#: util/initctl.c:2437
4300 msgid "The known jobs and their current status will be output."
4301 msgstr ""
4302
4303-#: util/initctl.c:2429
4304+#: util/initctl.c:2440
4305 msgid "EVENT [KEY=VALUE]..."
4306 msgstr ""
4307
4308-#: util/initctl.c:2430
4309+#: util/initctl.c:2441
4310 msgid "Emit an event."
4311 msgstr ""
4312
4313-#: util/initctl.c:2431
4314+#: util/initctl.c:2442
4315 msgid ""
4316 "EVENT is the name of an event the init daemon should emit, this may be "
4317 "followed by zero or more environment variables to be included in the event.\n"
4318 msgstr ""
4319
4320-#: util/initctl.c:2437
4321+#: util/initctl.c:2448
4322 msgid "Reload the configuration of the init daemon."
4323 msgstr ""
4324
4325-#: util/initctl.c:2441
4326+#: util/initctl.c:2452
4327 msgid "Request the version of the init daemon."
4328 msgstr ""
4329
4330-#: util/initctl.c:2444
4331+#: util/initctl.c:2455
4332 msgid "[PRIORITY]"
4333 msgstr ""
4334
4335-#: util/initctl.c:2445
4336+#: util/initctl.c:2456
4337 msgid "Change the minimum priority of log messages from the init daemon"
4338 msgstr ""
4339
4340-#: util/initctl.c:2447
4341+#: util/initctl.c:2458
4342 msgid ""
4343 "PRIORITY may be one of:\n"
4344 " `debug' (messages useful for debugging upstart are logged, equivalent to --"
4345@@ -642,25 +658,25 @@
4346 "Without arguments, this outputs the current log priority."
4347 msgstr ""
4348
4349-#: util/initctl.c:2464 util/initctl.c:2470
4350+#: util/initctl.c:2475 util/initctl.c:2481
4351 msgid "[CONF]"
4352 msgstr ""
4353
4354-#: util/initctl.c:2465
4355+#: util/initctl.c:2476
4356 msgid "Show emits, start on and stop on details for job configurations."
4357 msgstr ""
4358
4359-#: util/initctl.c:2466
4360+#: util/initctl.c:2477
4361 msgid ""
4362 "If CONF specified, show configuration details for single job configuration, "
4363 "else show details for all jobs configurations.\n"
4364 msgstr ""
4365
4366-#: util/initctl.c:2471
4367+#: util/initctl.c:2482
4368 msgid "Check for unreachable jobs/event conditions."
4369 msgstr ""
4370
4371-#: util/initctl.c:2472
4372+#: util/initctl.c:2483
4373 msgid ""
4374 "List all jobs and events which cannot be satisfied by currently available "
4375 "job configuration files"
4376
4377=== modified file 'scripts/init-checkconf.sh'
4378--- scripts/init-checkconf.sh 2011-03-10 14:06:37 +0000
4379+++ scripts/init-checkconf.sh 2011-04-19 09:27:29 +0000
4380@@ -1,7 +1,11 @@
4381 #!/bin/bash
4382 #---------------------------------------------------------------------
4383-# Script to determine if specified config file is valid or not
4384-# (whether upstart can parse it successfully).
4385+# Script to determine if specified config file is valid or not.
4386+# By default, two checks are performed:
4387+#
4388+# - Ensure Upstart can parse overall file successfully
4389+# - Ensure all script sections are parseable by shell
4390+#
4391 #---------------------------------------------------------------------
4392 #
4393 # Copyright (C) 2011 Canonical Ltd.
4394@@ -29,6 +33,7 @@
4395 debug_enabled=n
4396 file_valid=n
4397 running=n
4398+check_scripts=y
4399
4400 cleanup()
4401 {
4402@@ -55,6 +60,7 @@
4403 --file=<file> (no default).
4404 -i <path>, : Specify path to initctl binary
4405 --initctl-path=<path> (default=$initctl_path).
4406+ -s, --noscript : Do not check script sections.
4407 -x <path> : Specify path to init daemon binary
4408 --upstart-path=<path> (default=$upstart_path).
4409 -h, --help : Show this help.
4410@@ -85,8 +91,8 @@
4411 args=$(getopt \
4412 -n "$script_name" \
4413 -a \
4414- --options="df:hi:x:" \
4415- --longoptions="debug file: help initctl-path: upstart-path:" \
4416+ --options="df:hi:sx:" \
4417+ --longoptions="debug file: help initctl-path: noscript upstart-path:" \
4418 -- "$@")
4419
4420 eval set -- "$args"
4421@@ -115,6 +121,10 @@
4422 shift
4423 ;;
4424
4425+ -s|--noscript)
4426+ check_scripts=n
4427+ ;;
4428+
4429 -x|--upstart-path)
4430 upstart_path="$2"
4431 shift
4432@@ -165,7 +175,7 @@
4433 debug "upstart_out=$upstart_out"
4434
4435 upstart_cmd=$(printf \
4436- "%s --session --no-startup-event --verbose --confdir %s" \
4437+ "%s --session --no-sessions --no-startup-event --verbose --confdir %s" \
4438 "$upstart_path" \
4439 "$confdir")
4440 debug "upstart_cmd=$upstart_cmd"
4441@@ -177,7 +187,7 @@
4442 # We handle this ourselves in cleanup().
4443 disown
4444
4445-# wait for upstart to initialize
4446+# wait for Upstart to initialize
4447 for i in $(seq 1 5)
4448 do
4449 debug "Waiting for Upstart to reply over D-Bus (attempt $i)"
4450@@ -193,9 +203,23 @@
4451 sleep 1
4452 done
4453
4454-[ $running = n ] && die "failed to start upstart"
4455-
4456-debug "upstart ($upstart_cmd) running with PID $upstart_pid"
4457+[ $running = n ] && die "failed to ask Upstart to check conf file"
4458+
4459+debug "Secondary Upstart ($upstart_cmd) running with PID $upstart_pid"
4460+
4461+if [ "$check_scripts" = y ]
4462+then
4463+ for section in pre-start post-start script pre-stop post-stop
4464+ do
4465+ if egrep -q "\<${section}\>" "$file"
4466+ then
4467+ cmd='sed -n "/^ *${section}/,/^ *end script/p" $file | /bin/sh -n 2>&1'
4468+ errors=$(eval "$cmd")
4469+ [ $? -ne 0 ] && \
4470+ die "$(printf "File $file: shell syntax invalid in $section section:\n${errors}")"
4471+ fi
4472+ done
4473+fi
4474
4475 if "$initctl_path" --session status "$job" >/dev/null 2>&1
4476 then
4477@@ -205,4 +229,4 @@
4478 fi
4479
4480 errors=$(grep "$job" "$upstart_out"|sed "s,${confdir}/,,g")
4481-error "File $file: syntax invalid ($errors)"
4482+die "$(printf "File $file: syntax invalid:\n${errors}")"
4483
4484=== modified file 'scripts/man/init-checkconf.8'
4485--- scripts/man/init-checkconf.8 2011-03-07 15:02:20 +0000
4486+++ scripts/man/init-checkconf.8 2011-04-19 09:27:29 +0000
4487@@ -1,39 +1,49 @@
4488-.TH init-checkconf 8 2011-03-07 "Upstart"
4489+.TH init\-checkconf 8 2011-04-06 "Upstart"
4490 .\"
4491 .SH NAME
4492-init-checkconf \- manual page for init-checkconf
4493+init\-checkconf \- manual page for init-checkconf
4494 .\"
4495 .SH SYNOPSIS
4496-.B init-checkconf
4497+.B init\-checkconf
4498 .RI [ OPTIONS ] " file "
4499
4500-.B init-checkconf
4501-.RI [ OPTIONS ] " " "-f" " file "
4502+.B init\-checkconf
4503+.RI [ OPTIONS ] " " "\-f" " file "
4504 .\"
4505 .SH DESCRIPTION
4506 Determine if specified Upstart
4507 .BR init (8)
4508 job configuration file is valid.
4509+.P
4510+By default, two checks are performed:
4511+.IP \(bu 4
4512+Ensure Upstart can parse overall file successfully
4513+.IP \(bu 4
4514+Ensure all script sections are parseable by shell
4515+.P
4516 .\"
4517 .SH OPTIONS
4518 .TP
4519-.B -d
4520+.BR \-d " , " \-\-debug
4521 Show some debug output.
4522 .TP
4523-.B -f \fIfile\fP
4524+.BR \-f " \fIfile\fP" " , " \-\-file=\fIfile\fP
4525 Specify job configuration file to check.
4526 .TP
4527-.B -i \fIpath\fP
4528+.BR \-i " \fIpath\fP" " , " \-\-initctl\-path=\fIpath\fP
4529 Specify path to
4530 .BR initctl (8)
4531 binary.
4532 .TP
4533-.B -x \fIpath\fP
4534+.BR \-s " , " \-\-noscript
4535+Do not check script sections.
4536+.TP
4537+.BR \-x " \fIpath\fP" " , " \-\-upstart\-path=\fIpath\fP
4538 Specify path to
4539 .BR init (8)
4540 binary.
4541 .TP
4542-.B -h
4543+.BR \-h " , " \-\-help
4544 Display usage statement.
4545 .\"
4546 .SH AUTHOR
4547@@ -51,4 +61,6 @@
4548 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4549 .\"
4550 .SH SEE ALSO
4551+.BR sh (1)
4552+.BR init (5)
4553 .BR init (8)
4554
4555=== modified file 'util/initctl.c'
4556--- util/initctl.c 2011-03-15 12:15:28 +0000
4557+++ util/initctl.c 2011-04-19 09:27:29 +0000
4558@@ -194,6 +194,14 @@
4559 int check_config_mode = FALSE;
4560
4561 /**
4562+ * check_config_warn:
4563+ *
4564+ * If TRUE, check-config will generate a warning for *any* unreachable
4565+ * events/jobs.
4566+ **/
4567+int check_config_warn = FALSE;
4568+
4569+/**
4570 * check_config_data:
4571 *
4572 * Used to record details of all known jobs and events.
4573@@ -1959,7 +1967,7 @@
4574 * this node based on children
4575 * and type of operator.
4576 */
4577- if (IS_OP_AND (expr))
4578+ if (IS_OP_AND (expr) || check_config_warn)
4579 node->value = first->value && second->value;
4580 else
4581 node->value = first->value || second->value;
4582@@ -2110,12 +2118,13 @@
4583 const char *job = expr->job_in_error;
4584
4585 if (event)
4586- nih_message (" %s: unknown event %s", condition, event);
4587+ nih_message (" %s: %s %s", condition,
4588+ _("unknown event"), event);
4589
4590 if (job)
4591- nih_message (" %s: unknown job %s", condition, job);
4592+ nih_message (" %s: %s %s", condition,
4593+ _("unknown job"), job);
4594 }
4595-
4596 }
4597
4598
4599@@ -2349,8 +2358,10 @@
4600 * Command-line options accepted for the check-config command.
4601 **/
4602 NihOption check_config_options[] = {
4603- { 0, "ignore-events", N_("ignore specified list of events (comma-separated)"),
4604+ { 'i', "ignore-events", N_("ignore specified list of events (comma-separated)"),
4605 NULL, "EVENT_LIST", NULL, ignored_events_setter },
4606+ { 'w', "warn", N_("Generate warning for any unreachable events/jobs"),
4607+ NULL, NULL, &check_config_warn, NULL },
4608 NIH_OPTION_LAST
4609 };
4610 /**
4611
4612=== modified file 'util/man/initctl.8'
4613--- util/man/initctl.8 2011-03-10 14:06:37 +0000
4614+++ util/man/initctl.8 2011-04-19 09:27:29 +0000
4615@@ -494,7 +494,7 @@
4616
4617 .B OPTIONS
4618 .RS
4619-.IP "\fB\-\-ignore\-events\fP \fI[EVENTS]\fP"
4620+.IP "\fB-i\fP \fI[EVENTS]\fP, \fB\-\-ignore\-events\fP \fI[EVENTS]\fP"
4621
4622 If specified, the argument should be a list of comma\-separated events to
4623 ignore when checking the job configuration files.
4624@@ -504,6 +504,8 @@
4625
4626 Note that internal events (such as \fBstartup\fP(7) and
4627 \fBstarting\fP(7)) are automatically ignored.
4628+.IP "\fB-w\fP, \fB\-\-warn\fP"
4629+If specified, treat \fIany\fP unknown jobs and events as errors.
4630
4631 .\"
4632 .SH AUTHOR
4633
4634=== modified file 'util/tests/test_initctl.c'
4635--- util/tests/test_initctl.c 2011-03-15 11:32:15 +0000
4636+++ util/tests/test_initctl.c 2011-04-19 09:27:29 +0000
4637@@ -49,6 +49,7 @@
4638 /* remember we run from the 'util' directory */
4639 #define UPSTART_BINARY "../init/init"
4640 #define INITCTL_BINARY "./initctl --session"
4641+
4642 #define BUFFER_SIZE 1024
4643
4644 /**
4645@@ -74,7 +75,9 @@
4646 \
4647 if (pid == 0) \
4648 execlp (UPSTART_BINARY, UPSTART_BINARY, \
4649- "--session", "--no-startup-event", \
4650+ "--session", \
4651+ "--no-startup-event", \
4652+ "--no-sessions", \
4653 NULL); \
4654 \
4655 while (attempts) { \
4656@@ -138,11 +141,11 @@
4657 * @len: size_t pointer which will be set to length of @result.
4658 *
4659 * Run a command and return its standard output. It is the callers
4660- * responsibility to free @result.
4661+ * responsibility to free @result. Errors from running @cmd are fatal.
4662 **/
4663 #define RUN_COMMAND(parent, cmd, result, len) \
4664 { \
4665- FILE *initctl; \
4666+ FILE *f; \
4667 char buffer[BUFFER_SIZE]; \
4668 char **ret; \
4669 \
4670@@ -152,20 +155,20 @@
4671 TEST_NE_P (*result, NULL); \
4672 *(len) = 0; \
4673 \
4674- initctl = popen (cmd, "r"); \
4675- TEST_NE_P (initctl, NULL); \
4676+ f = popen (cmd, "r"); \
4677+ TEST_NE_P (f, NULL); \
4678 \
4679- while (fgets (buffer, BUFFER_SIZE, initctl)) { \
4680- size_t l = strlen(buffer)-1; \
4681+ while (fgets (buffer, BUFFER_SIZE, f)) { \
4682+ size_t l = strlen (buffer)-1; \
4683 \
4684 if ( buffer[l] == '\n') \
4685 buffer[l] = '\0'; \
4686 ret = nih_str_array_add (result, parent, len, \
4687- buffer); \
4688+ buffer); \
4689 TEST_NE_P (ret, NULL); \
4690 } \
4691- \
4692- TEST_NE (pclose(initctl), -1); \
4693+ \
4694+ TEST_NE ( pclose (f), -1); \
4695 }
4696
4697 /**
4698@@ -10946,7 +10949,6 @@
4699 "author \"foo\"\n"
4700 "description \"wibble\"");
4701
4702-
4703 cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
4704 TEST_NE_P (cmd, NULL);
4705 RUN_COMMAND (NULL, cmd, &output, &lines);
4706@@ -11790,6 +11792,47 @@
4707
4708 /*******************************************************************/
4709
4710+ TEST_FEATURE (
4711+ "satisfiable complex start on, satisfiable complex stop on with warnings");
4712+
4713+ CREATE_FILE (dirname, "plymouth.conf",
4714+ "start on (starting mountall\n"
4715+ " or (hello\n"
4716+ " and (stopped gdm\n"
4717+ " or (stopped kdm\n"
4718+ " or (stopped xdm\n"
4719+ " or stopped lxdm)))))\n"
4720+ "stop on (stopping portmap\n"
4721+ " or (wibble or starting beano))\n");
4722+
4723+ CREATE_FILE (dirname, "mountall.conf", "exec true\n");
4724+ CREATE_FILE (dirname, "portmap.conf",
4725+ "exec true\n"
4726+ "emits hello");
4727+ CREATE_FILE (dirname, "lxdm.conf", "exec true");
4728+ CREATE_FILE (dirname, "wibble.conf", "emits wibble");
4729+ CREATE_FILE (dirname, "beano.conf", "exec true");
4730+
4731+ cmd = nih_sprintf (NULL, "%s check-config --warn 2>&1",
4732+ INITCTL_BINARY);
4733+ TEST_NE_P (cmd, NULL);
4734+ RUN_COMMAND (NULL, cmd, &output, &lines);
4735+
4736+ TEST_EQ_STR (output[0], "plymouth");
4737+ TEST_EQ_STR (output[1], " start on: unknown job xdm");
4738+ TEST_EQ_STR (output[2], " start on: unknown job kdm");
4739+ TEST_EQ_STR (output[3], " start on: unknown job gdm");
4740+ TEST_EQ (lines, 4);
4741+
4742+ DELETE_FILE (dirname, "plymouth.conf");
4743+ DELETE_FILE (dirname, "mountall.conf");
4744+ DELETE_FILE (dirname, "portmap.conf");
4745+ DELETE_FILE (dirname, "lxdm.conf");
4746+ DELETE_FILE (dirname, "beano.conf");
4747+ DELETE_FILE (dirname, "wibble.conf");
4748+
4749+ /*******************************************************************/
4750+
4751 STOP_UPSTART (upstart_pid);
4752 TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0);
4753 }

Subscribers

People subscribed via source and target branches

to all changes: