Merge lp:~jamesodhunt/upstart/upstream-add-session-bus-support into lp:upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1288
Proposed branch: lp:~jamesodhunt/upstart/upstream-add-session-bus-support
Merge into: lp:upstart
Diff against target: 1773 lines (+536/-321)
21 files modified
ChangeLog (+31/-0)
configure.ac (+1/-1)
init/conf.c (+0/-1)
init/control.c (+33/-7)
init/control.h (+15/-1)
init/environ.c (+0/-1)
init/environ.h (+0/-1)
init/job_process.c (+0/-1)
init/job_process.h (+0/-1)
init/main.c (+154/-133)
init/man/init.8 (+6/-2)
init/tests/test_conf.c (+0/-1)
init/tests/test_control.c (+0/-1)
init/tests/test_environ.c (+0/-1)
init/tests/test_job_class.c (+0/-1)
init/tests/test_job_process.c (+0/-1)
po/upstart.pot (+206/-134)
util/initctl.c (+56/-13)
util/man/initctl.8 (+8/-2)
util/reboot.c (+0/-1)
util/tests/test_initctl.c (+26/-17)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/upstream-add-session-bus-support
Reviewer Review Type Date Requested Status
Upstart Developers Pending
Review via email: mp+63345@code.launchpad.net

Description of the change

Add D-Bus session support to initctl.

* Changelog: Updated.
* util/initctl.c:
  - Added "--session" command-line option.
  - dbus_bus_type_setter(): New function used by option parser to
    distinguish system/session D-Bus bus type.
  - system_bus variable now replaced by two others: use_dbus (boolean)
    and dbus_bus_type.
  - upstart_open(): Updated to handle multiple D-Bus bus types.
* util/man/initctl.8: Update for "--session" option.
* util/tests/test_initctl.c: Updated to make use of use_dbus and
  dbus_bus_type rather than system_bus.

Add command-line option to use D-Bus session bus (for testing).

* init/control.c:
  - Added new boolean use_session_bus.
  - Updated comments.
  - control_handle_bus_type(): New function to allow selection of
    session bus via env var "UPSTART_USE_SESSION_BUS".
    Also logs use of session bus if use_session_bus set.
  - control_bus_open(): Now connects to either D-Bus system bus or session bus.
* init/control.h: New define for USE_SESSION_BUS_ENV.
* init/main.c: Addition of "--session" command-line option.
* init/man/init.8: Update for new "--session" command-line option.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2011-05-12 20:42:28 +0000
3+++ ChangeLog 2011-06-03 09:21:18 +0000
4@@ -1,3 +1,34 @@
5+2011-06-01 James Hunt <james.hunt@ubuntu.com>
6+
7+ Add D-Bus session support to initctl.
8+
9+ * util/initctl.c:
10+ - Added "--session" command-line option.
11+ - dbus_bus_type_setter(): New function used by option parser to
12+ distinguish system/session D-Bus bus type.
13+ - system_bus variable now replaced by two others: use_dbus (boolean)
14+ and dbus_bus_type.
15+ - upstart_open(): Updated to handle multiple D-Bus bus types.
16+ * util/man/initctl.8: Update for "--session" option.
17+ * util/tests/test_initctl.c: Updated to make use of use_dbus and
18+ dbus_bus_type rather than system_bus.
19+
20+2011-05-31 James Hunt <james.hunt@ubuntu.com>
21+
22+ Add command-line option to use D-Bus session bus (for testing).
23+
24+ * init/control.c:
25+ - Added new boolean use_session_bus.
26+ - Updated comments.
27+ - control_handle_bus_type(): New function to allow selection of
28+ session bus via env var "UPSTART_USE_SESSION_BUS".
29+ Also logs use of session bus if use_session_bus set.
30+ - control_bus_open(): Now connects to either D-Bus system bus or session bus.
31+ * init/control.h: New define for USE_SESSION_BUS_ENV.
32+ * init/main.c: Addition of "--session" command-line option.
33+ * init/man/init.8: Update for new "--session" command-line option.
34+ * Corrected copyright notices.
35+
36 2011-05-12 Marc - A. Dahlhaus <mad@wol.de>
37
38 * init/job_class.h (JobClass): Add kill signal member
39
40=== modified file 'configure.ac'
41--- configure.ac 2011-03-22 17:53:17 +0000
42+++ configure.ac 2011-06-03 09:21:18 +0000
43@@ -2,7 +2,7 @@
44
45 AC_PREREQ(2.61)
46 AC_INIT([upstart], [1.3], [upstart-devel@lists.ubuntu.com])
47-NIH_COPYRIGHT([[Copyright © 2011 Scott James Remnant, Google Inc., Canonical Ltd.]])
48+NIH_COPYRIGHT([[Copyright © 2011 Scott James Remnant, Canonical Ltd.]])
49 AC_CONFIG_SRCDIR([init/main.c])
50 AC_CONFIG_MACRO_DIR([m4])
51
52
53=== modified file 'init/conf.c'
54--- init/conf.c 2011-03-15 18:44:09 +0000
55+++ init/conf.c 2011-06-03 09:21:18 +0000
56@@ -2,7 +2,6 @@
57 *
58 * conf.c - configuration management
59 *
60- * Copyright © 2011 Google Inc.
61 * Copyright © 2009 Canonical Ltd.
62 * Author: Scott James Remnant <scott@netsplit.com>.
63 *
64
65=== modified file 'init/control.c'
66--- init/control.c 2009-07-11 11:47:12 +0000
67+++ init/control.c 2011-06-03 09:21:18 +0000
68@@ -2,7 +2,7 @@
69 *
70 * control.c - D-Bus connections, objects and methods
71 *
72- * Copyright © 2009 Canonical Ltd.
73+ * Copyright © 2009-2011 Canonical Ltd.
74 * Author: Scott James Remnant <scott@netsplit.com>.
75 *
76 * This program is free software; you can redistribute it and/or modify
77@@ -54,12 +54,19 @@
78
79 #include "com.ubuntu.Upstart.h"
80
81-
82 /* Prototypes for static functions */
83 static int control_server_connect (DBusServer *server, DBusConnection *conn);
84 static void control_disconnected (DBusConnection *conn);
85 static void control_register_all (DBusConnection *conn);
86
87+/**
88+ * use_session_bus:
89+ *
90+ * If TRUE, connect to the D-Bus sessio bus rather than the system bus.
91+ *
92+ * Used for testing.
93+ **/
94+int use_session_bus = FALSE;
95
96 /**
97 * control_server_address:
98@@ -78,7 +85,7 @@
99 /**
100 * control_bus:
101 *
102- * Open connection to D-Bus system bus. The connection may be opened with
103+ * Open connection to a D-Bus bus. The connection may be opened with
104 * control_bus_open() and if lost will become NULL.
105 **/
106 DBusConnection *control_bus = NULL;
107@@ -86,7 +93,7 @@
108 /**
109 * control_conns:
110 *
111- * Open control connections, including the connection to the D-Bus system
112+ * Open control connections, including the connection to a D-Bus
113 * bus and any private client connections.
114 **/
115 NihList *control_conns = NULL;
116@@ -190,8 +197,9 @@
117 /**
118 * control_bus_open:
119 *
120- * Open a connection to the D-Bus system bus and store it in the control_bus
121- * global. The connection is handled automatically in the main loop.
122+ * Open a connection to the appropriate D-Bus bus and store it in the
123+ * control_bus global. The connection is handled automatically
124+ * in the main loop.
125 *
126 * Returns: zero on success, negative value on raised error.
127 **/
128@@ -207,10 +215,13 @@
129
130 control_init ();
131
132+ control_handle_bus_type ();
133+
134 /* Connect to the D-Bus System Bus and hook everything up into
135 * our own main loop automatically.
136 */
137- conn = nih_dbus_bus (DBUS_BUS_SYSTEM, control_disconnected);
138+ conn = nih_dbus_bus (use_session_bus ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM,
139+ control_disconnected);
140 if (! conn)
141 return -1;
142
143@@ -669,3 +680,18 @@
144
145 return 0;
146 }
147+
148+/**
149+ * control_handle_bus_type:
150+ *
151+ * Determine D-Bus bus type to connect to.
152+ **/
153+void
154+control_handle_bus_type (void)
155+{
156+ if (getenv (USE_SESSION_BUS_ENV))
157+ use_session_bus = TRUE;
158+
159+ if (use_session_bus)
160+ nih_debug ("Using session bus");
161+}
162
163=== modified file 'init/control.h'
164--- init/control.h 2009-07-09 08:36:52 +0000
165+++ init/control.h 2011-06-03 09:21:18 +0000
166@@ -1,6 +1,6 @@
167 /* upstart
168 *
169- * Copyright © 2009 Canonical Ltd.
170+ * Copyright © 2009-2011 Canonical Ltd.
171 * Author: Scott James Remnant <scott@netsplit.com>.
172 *
173 * This program is free software; you can redistribute it and/or modify
174@@ -27,6 +27,18 @@
175 #include <nih-dbus/dbus_connection.h>
176 #include <nih-dbus/dbus_message.h>
177
178+/**
179+ * USE_SESSION_BUS_ENV:
180+ *
181+ * If this environment variable is set to any value, connect to
182+ * D-Bus session bus rather than the system bus.
183+ *
184+ * Used for testing.
185+ **/
186+#ifndef USE_SESSION_BUS_ENV
187+#define USE_SESSION_BUS_ENV "UPSTART_USE_SESSION_BUS"
188+#endif
189+
190
191 NIH_BEGIN_EXTERN
192
193@@ -72,6 +84,8 @@
194 const char *log_priority)
195 __attribute__ ((warn_unused_result));
196
197+void control_handle_bus_type (void);
198+
199 NIH_END_EXTERN
200
201 #endif /* INIT_CONTROL_H */
202
203=== modified file 'init/environ.c'
204--- init/environ.c 2011-03-16 22:42:48 +0000
205+++ init/environ.c 2011-06-03 09:21:18 +0000
206@@ -2,7 +2,6 @@
207 *
208 * environ.c - environment table utilities
209 *
210- * Copyright © 2011 Google Inc.
211 * Copyright © 2009 Canonical Ltd.
212 * Author: Scott James Remnant <scott@netsplit.com>.
213 *
214
215=== modified file 'init/environ.h'
216--- init/environ.h 2011-03-16 22:42:48 +0000
217+++ init/environ.h 2011-06-03 09:21:18 +0000
218@@ -1,6 +1,5 @@
219 /* upstart
220 *
221- * Copyright © 2011 Google Inc.
222 * Copyright © 2009 Canonical Ltd.
223 * Author: Scott James Remnant <scott@netsplit.com>.
224 *
225
226=== modified file 'init/job_process.c'
227--- init/job_process.c 2011-05-12 20:42:28 +0000
228+++ init/job_process.c 2011-06-03 09:21:18 +0000
229@@ -2,7 +2,6 @@
230 *
231 * job_process.c - job process handling
232 *
233- * Copyright © 2011 Google Inc.
234 * Copyright © 2011 Canonical Ltd.
235 * Author: Scott James Remnant <scott@netsplit.com>.
236 *
237
238=== modified file 'init/job_process.h'
239--- init/job_process.h 2011-05-12 19:21:16 +0000
240+++ init/job_process.h 2011-06-03 09:21:18 +0000
241@@ -1,6 +1,5 @@
242 /* upstart
243 *
244- * Copyright © 2011 Google Inc.
245 * Copyright © 2009 Canonical Ltd.
246 * Author: Scott James Remnant <scott@netsplit.com>.
247 *
248
249=== modified file 'init/main.c'
250--- init/main.c 2011-03-16 22:54:56 +0000
251+++ init/main.c 2011-06-03 09:21:18 +0000
252@@ -1,7 +1,6 @@
253 /* upstart
254 *
255- * Copyright © 2011 Google Inc.
256- * Copyright © 2010 Canonical Ltd.
257+ * Copyright © 2009-2011 Canonical Ltd.
258 * Author: Scott James Remnant <scott@netsplit.com>.
259 *
260 * This program is free software; you can redistribute it and/or modify
261@@ -88,6 +87,7 @@
262 **/
263 static int restart = FALSE;
264
265+extern int use_session_bus;
266
267 /**
268 * options:
269@@ -97,6 +97,9 @@
270 static NihOption options[] = {
271 { 0, "restart", NULL, NULL, NULL, &restart, NULL },
272
273+ { 0, "session", N_("use D-Bus session bus rather than system bus (for testing)"),
274+ NULL, NULL, &use_session_bus, NULL },
275+
276 /* Ignore invalid options */
277 { '-', "--", NULL, NULL, NULL, NULL, NULL },
278
279@@ -124,94 +127,104 @@
280 if (! args)
281 exit (1);
282
283+ control_handle_bus_type ();
284+
285 #ifndef DEBUG
286- /* Check we're root */
287- if (getuid ()) {
288- nih_fatal (_("Need to be root"));
289- exit (1);
290- }
291-
292- /* Check we're process #1 */
293- if (getpid () > 1) {
294- execv (TELINIT, argv);
295- /* Ignore failure, probably just that telinit doesn't exist */
296-
297- nih_fatal (_("Not being executed as init"));
298- exit (1);
299- }
300-
301- /* Clear our arguments from the command-line, so that we show up in
302- * ps or top output as /sbin/init, with no extra flags.
303- *
304- * This is a very Linux-specific trick; by deleting the NULL
305- * terminator at the end of the last argument, we fool the kernel
306- * into believing we used a setproctitle()-a-like to extend the
307- * argument space into the environment space, and thus make it use
308- * strlen() instead of its own assumed length. In fact, we've done
309- * the exact opposite, and shrunk the command line length to just that
310- * of whatever is in argv[0].
311- *
312- * If we don't do this, and just write \0 over the rest of argv, for
313- * example; the command-line length still includes those \0s, and ps
314- * will show whitespace in their place.
315- */
316- if (argc > 1) {
317- char *arg_end;
318-
319- arg_end = argv[argc-1] + strlen (argv[argc-1]);
320- *arg_end = ' ';
321- }
322-
323-
324- /* Become the leader of a new session and process group, shedding
325- * any controlling tty (which we shouldn't have had anyway - but
326- * you never know what initramfs did).
327- */
328- setsid ();
329-
330- /* Set the standard file descriptors to the ordinary console device,
331- * resetting it to sane defaults unless we're inheriting from another
332- * init process which we know left it in a sane state.
333- */
334- if (system_setup_console (CONSOLE_OUTPUT, (! restart)) < 0)
335- nih_free (nih_error_get ());
336-
337- /* Set the PATH environment variable */
338- setenv ("PATH", PATH, TRUE);
339-
340- /* Switch to the root directory in case we were started from some
341- * strange place, or worse, some directory in the initramfs that's
342- * going to go away soon.
343- */
344- if (chdir ("/"))
345- nih_warn ("%s: %s", _("Unable to set root directory"),
346- strerror (errno));
347-
348- /* Mount the /proc and /sys filesystems, which are pretty much
349- * essential for any Linux system; not to mention used by
350- * ourselves.
351- */
352- if (system_mount ("proc", "/proc") < 0) {
353- NihError *err;
354-
355- err = nih_error_get ();
356- nih_warn ("%s: %s", _("Unable to mount /proc filesystem"),
357- err->message);
358- nih_free (err);
359- }
360-
361- if (system_mount ("sysfs", "/sys") < 0) {
362- NihError *err;
363-
364- err = nih_error_get ();
365- nih_warn ("%s: %s", _("Unable to mount /sys filesystem"),
366- err->message);
367- nih_free (err);
368- }
369+ if (use_session_bus == FALSE) {
370+
371+ /* Check we're root */
372+ if (getuid ()) {
373+ nih_fatal (_("Need to be root"));
374+ exit (1);
375+ }
376+
377+ /* Check we're process #1 */
378+ if (getpid () > 1) {
379+ execv (TELINIT, argv);
380+ /* Ignore failure, probably just that telinit doesn't exist */
381+
382+ nih_fatal (_("Not being executed as init"));
383+ exit (1);
384+ }
385+
386+ /* Clear our arguments from the command-line, so that we show up in
387+ * ps or top output as /sbin/init, with no extra flags.
388+ *
389+ * This is a very Linux-specific trick; by deleting the NULL
390+ * terminator at the end of the last argument, we fool the kernel
391+ * into believing we used a setproctitle()-a-like to extend the
392+ * argument space into the environment space, and thus make it use
393+ * strlen() instead of its own assumed length. In fact, we've done
394+ * the exact opposite, and shrunk the command line length to just that
395+ * of whatever is in argv[0].
396+ *
397+ * If we don't do this, and just write \0 over the rest of argv, for
398+ * example; the command-line length still includes those \0s, and ps
399+ * will show whitespace in their place.
400+ */
401+ if (argc > 1) {
402+ char *arg_end;
403+
404+ arg_end = argv[argc-1] + strlen (argv[argc-1]);
405+ *arg_end = ' ';
406+ }
407+
408+
409+ /* Become the leader of a new session and process group, shedding
410+ * any controlling tty (which we shouldn't have had anyway - but
411+ * you never know what initramfs did).
412+ */
413+ setsid ();
414+
415+ /* Set the standard file descriptors to the ordinary console device,
416+ * resetting it to sane defaults unless we're inheriting from another
417+ * init process which we know left it in a sane state.
418+ */
419+ if (system_setup_console (CONSOLE_OUTPUT, (! restart)) < 0)
420+ nih_free (nih_error_get ());
421+
422+ /* Set the PATH environment variable */
423+ setenv ("PATH", PATH, TRUE);
424+
425+ /* Switch to the root directory in case we were started from some
426+ * strange place, or worse, some directory in the initramfs that's
427+ * going to go away soon.
428+ */
429+ if (chdir ("/"))
430+ nih_warn ("%s: %s", _("Unable to set root directory"),
431+ strerror (errno));
432+
433+ /* Mount the /proc and /sys filesystems, which are pretty much
434+ * essential for any Linux system; not to mention used by
435+ * ourselves.
436+ */
437+ if (system_mount ("proc", "/proc") < 0) {
438+ NihError *err;
439+
440+ err = nih_error_get ();
441+ nih_warn ("%s: %s", _("Unable to mount /proc filesystem"),
442+ err->message);
443+ nih_free (err);
444+ }
445+
446+ if (system_mount ("sysfs", "/sys") < 0) {
447+ NihError *err;
448+
449+ err = nih_error_get ();
450+ nih_warn ("%s: %s", _("Unable to mount /sys filesystem"),
451+ err->message);
452+ nih_free (err);
453+ }
454+ } else {
455+ nih_log_set_priority (NIH_LOG_DEBUG);
456+ nih_debug ("Running with UID %d as PID %d (PPID %d)",
457+ (int)getuid (), (int)getpid (), (int)getppid ());
458+ }
459+
460 #else /* DEBUG */
461 nih_log_set_priority (NIH_LOG_DEBUG);
462- nih_debug ("Running as PID %d (PPID %d)",
463- (int)getpid (), (int)getppid ());
464+ nih_debug ("Running with UID %d as PID %d (PPID %d)",
465+ (int)getuid (), (int)getpid (), (int)getppid ());
466 #endif /* DEBUG */
467
468
469@@ -223,11 +236,13 @@
470 nih_signal_reset ();
471
472 #ifndef DEBUG
473- /* Catch fatal errors immediately rather than waiting for a new
474- * iteration through the main loop.
475- */
476- nih_signal_set_handler (SIGSEGV, crash_handler);
477- nih_signal_set_handler (SIGABRT, crash_handler);
478+ if (use_session_bus == FALSE) {
479+ /* Catch fatal errors immediately rather than waiting for a new
480+ * iteration through the main loop.
481+ */
482+ nih_signal_set_handler (SIGSEGV, crash_handler);
483+ nih_signal_set_handler (SIGABRT, crash_handler);
484+ }
485 #endif /* DEBUG */
486
487 /* Don't ignore SIGCHLD or SIGALRM, but don't respond to them
488@@ -238,33 +253,35 @@
489 nih_signal_set_handler (SIGALRM, nih_signal_handler);
490
491 #ifndef DEBUG
492- /* Ask the kernel to send us SIGINT when control-alt-delete is
493- * pressed; generate an event with the same name.
494- */
495- reboot (RB_DISABLE_CAD);
496- nih_signal_set_handler (SIGINT, nih_signal_handler);
497- NIH_MUST (nih_signal_add_handler (NULL, SIGINT, cad_handler, NULL));
498-
499- /* Ask the kernel to send us SIGWINCH when alt-uparrow is pressed;
500- * generate a keyboard-request event.
501- */
502- if (ioctl (0, KDSIGACCEPT, SIGWINCH) == 0) {
503- nih_signal_set_handler (SIGWINCH, nih_signal_handler);
504- NIH_MUST (nih_signal_add_handler (NULL, SIGWINCH,
505- kbd_handler, NULL));
506+ if (use_session_bus == FALSE) {
507+ /* Ask the kernel to send us SIGINT when control-alt-delete is
508+ * pressed; generate an event with the same name.
509+ */
510+ reboot (RB_DISABLE_CAD);
511+ nih_signal_set_handler (SIGINT, nih_signal_handler);
512+ NIH_MUST (nih_signal_add_handler (NULL, SIGINT, cad_handler, NULL));
513+
514+ /* Ask the kernel to send us SIGWINCH when alt-uparrow is pressed;
515+ * generate a keyboard-request event.
516+ */
517+ if (ioctl (0, KDSIGACCEPT, SIGWINCH) == 0) {
518+ nih_signal_set_handler (SIGWINCH, nih_signal_handler);
519+ NIH_MUST (nih_signal_add_handler (NULL, SIGWINCH,
520+ kbd_handler, NULL));
521+ }
522+
523+ /* powstatd sends us SIGPWR when it changes /etc/powerstatus */
524+ nih_signal_set_handler (SIGPWR, nih_signal_handler);
525+ NIH_MUST (nih_signal_add_handler (NULL, SIGPWR, pwr_handler, NULL));
526+
527+ /* SIGHUP instructs us to re-load our configuration */
528+ nih_signal_set_handler (SIGHUP, nih_signal_handler);
529+ NIH_MUST (nih_signal_add_handler (NULL, SIGHUP, hup_handler, NULL));
530+
531+ /* SIGUSR1 instructs us to reconnect to D-Bus */
532+ nih_signal_set_handler (SIGUSR1, nih_signal_handler);
533+ NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL));
534 }
535-
536- /* powstatd sends us SIGPWR when it changes /etc/powerstatus */
537- nih_signal_set_handler (SIGPWR, nih_signal_handler);
538- NIH_MUST (nih_signal_add_handler (NULL, SIGPWR, pwr_handler, NULL));
539-
540- /* SIGHUP instructs us to re-load our configuration */
541- nih_signal_set_handler (SIGHUP, nih_signal_handler);
542- NIH_MUST (nih_signal_add_handler (NULL, SIGHUP, hup_handler, NULL));
543-
544- /* SIGUSR1 instructs us to reconnect to D-Bus */
545- nih_signal_set_handler (SIGUSR1, nih_signal_handler);
546- NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL));
547 #endif /* DEBUG */
548
549
550@@ -284,20 +301,22 @@
551 conf_reload ();
552
553 /* Create a listening server for private connections. */
554- while (control_server_open () < 0) {
555- NihError *err;
556+ if (use_session_bus == FALSE) {
557+ while (control_server_open () < 0) {
558+ NihError *err;
559
560- err = nih_error_get ();
561- if (err->number != ENOMEM) {
562- nih_warn ("%s: %s", _("Unable to listen for private connections"),
563- err->message);
564+ err = nih_error_get ();
565+ if (err->number != ENOMEM) {
566+ nih_warn ("%s: %s", _("Unable to listen for private connections"),
567+ err->message);
568+ nih_free (err);
569+ break;
570+ }
571 nih_free (err);
572- break;
573 }
574- nih_free (err);
575 }
576
577- /* Open connection to the system bus; we normally expect this to
578+ /* Open connection to the appropriate D-Bus bus; we normally expect this to
579 * fail and will try again later - don't let ENOMEM stop us though.
580 */
581 while (control_bus_open () < 0) {
582@@ -313,13 +332,15 @@
583 }
584
585 #ifndef DEBUG
586- /* Now that the startup is complete, send all further logging output
587- * to kmsg instead of to the console.
588- */
589- if (system_setup_console (CONSOLE_NONE, FALSE) < 0)
590- nih_free (nih_error_get ());
591+ if (use_session_bus == FALSE) {
592+ /* Now that the startup is complete, send all further logging output
593+ * to kmsg instead of to the console.
594+ */
595+ if (system_setup_console (CONSOLE_NONE, FALSE) < 0)
596+ nih_free (nih_error_get ());
597
598- nih_log_set_logger (logger_kmsg);
599+ nih_log_set_logger (logger_kmsg);
600+ }
601 #endif /* DEBUG */
602
603
604
605=== modified file 'init/man/init.8'
606--- init/man/init.8 2010-02-04 19:26:17 +0000
607+++ init/man/init.8 2011-06-03 09:21:18 +0000
608@@ -1,4 +1,4 @@
609-.TH init 8 2010-02-04 "Upstart"
610+.TH init 8 2011-05-31 "Upstart"
611 .\"
612 .SH NAME
613 init \- Upstart process management daemon
614@@ -64,6 +64,10 @@
615 by placing them on the kernel command-line.
616 .\"
617 .TP
618+.B \-\-session
619+Connect to the D\-Bus session bus. This should only be used for testing.
620+.\"
621+.TP
622 .B --verbose
623 Outputs verbose messages about job state changes and event emissions to the
624 system console or log, useful for debugging boot.
625@@ -90,7 +94,7 @@
626 .RB < https://launchpad.net/upstart/+bugs >
627 .\"
628 .SH COPYRIGHT
629-Copyright \(co 2010 Canonical Ltd.
630+Copyright \(co 2009-2011 Canonical Ltd.
631 .br
632 This is free software; see the source for copying conditions. There is NO
633 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
634
635=== modified file 'init/tests/test_conf.c'
636--- init/tests/test_conf.c 2011-02-17 23:38:17 +0000
637+++ init/tests/test_conf.c 2011-06-03 09:21:18 +0000
638@@ -2,7 +2,6 @@
639 *
640 * test_conf.c - test suite for init/conf.c
641 *
642- * Copyright © 2011 Google Inc.
643 * Copyright © 2009 Canonical Ltd.
644 * Author: Scott James Remnant <scott@netsplit.com>.
645 *
646
647=== modified file 'init/tests/test_control.c'
648--- init/tests/test_control.c 2011-03-16 22:42:48 +0000
649+++ init/tests/test_control.c 2011-06-03 09:21:18 +0000
650@@ -2,7 +2,6 @@
651 *
652 * test_dbus.c - test suite for init/dbus.c
653 *
654- * Copyright © 2011 Google Inc.
655 * Copyright © 2010 Canonical Ltd.
656 * Author: Scott James Remnant <scott@netsplit.com>.
657 *
658
659=== modified file 'init/tests/test_environ.c'
660--- init/tests/test_environ.c 2011-03-16 22:42:48 +0000
661+++ init/tests/test_environ.c 2011-06-03 09:21:18 +0000
662@@ -2,7 +2,6 @@
663 *
664 * test_environ.c - test suite for init/environ.c
665 *
666- * Copyright © 2011 Google Inc.
667 * Copyright © 2009 Canonical Ltd.
668 * Author: Scott James Remnant <scott@netsplit.com>.
669 *
670
671=== modified file 'init/tests/test_job_class.c'
672--- init/tests/test_job_class.c 2011-05-12 20:42:28 +0000
673+++ init/tests/test_job_class.c 2011-06-03 09:21:18 +0000
674@@ -2,7 +2,6 @@
675 *
676 * test_job_class.c - test suite for init/job_class.c
677 *
678- * Copyright © 2011 Google Inc.
679 * Copyright © 2010 Canonical Ltd.
680 * Author: Scott James Remnant <scott@netsplit.com>.
681 *
682
683=== modified file 'init/tests/test_job_process.c'
684--- init/tests/test_job_process.c 2011-05-12 19:21:16 +0000
685+++ init/tests/test_job_process.c 2011-06-03 09:21:18 +0000
686@@ -2,7 +2,6 @@
687 *
688 * test_job_process.c - test suite for init/job_process.c
689 *
690- * Copyright © 2011 Google Inc.
691 * Copyright © 2011 Canonical Ltd.
692 * Author: Scott James Remnant <scott@netsplit.com>.
693 *
694
695=== modified file 'po/upstart.pot'
696--- po/upstart.pot 2011-03-22 17:52:25 +0000
697+++ po/upstart.pot 2011-06-03 09:21:18 +0000
698@@ -6,76 +6,141 @@
699 #, fuzzy
700 msgid ""
701 msgstr ""
702-"Project-Id-Version: upstart 1.2\n"
703+"Project-Id-Version: upstart 1.3\n"
704 "Report-Msgid-Bugs-To: new@bugs.launchpad.net\n"
705-"POT-Creation-Date: 2011-03-22 10:52-0700\n"
706+"POT-Creation-Date: 2011-05-31 17:52+0100\n"
707 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
708 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
709 "Language-Team: LANGUAGE <LL@li.org>\n"
710+"Language: \n"
711 "MIME-Version: 1.0\n"
712 "Content-Type: text/plain; charset=CHARSET\n"
713 "Content-Transfer-Encoding: 8bit\n"
714
715-#: init/conf.c:238
716+#: init/conf.c:237
717 msgid "Unable to load configuration"
718 msgstr ""
719
720-#: init/conf.c:271
721+#: init/conf.c:270
722 #, c-format
723 msgid "Loading configuration from %s"
724 msgstr ""
725
726-#: init/conf.c:308
727+#: init/conf.c:307
728 #, c-format
729 msgid "Handling deletion of %s"
730 msgstr ""
731
732-#: init/conf.c:379
733+#: init/conf.c:378
734 msgid "Unable to watch configuration file"
735 msgstr ""
736
737-#: init/conf.c:457
738+#: init/conf.c:456
739 msgid "Unable to watch configuration directory"
740 msgstr ""
741
742-#: init/conf.c:569 init/conf.c:653
743+#: init/conf.c:568 init/conf.c:652
744 msgid "Error while loading configuration file"
745 msgstr ""
746
747-#: init/conf.c:609
748+#: init/conf.c:608
749 msgid "Configuration directory deleted"
750 msgstr ""
751
752-#: init/control.c:155
753+#: init/control.c:162
754 msgid "Connection from private client"
755 msgstr ""
756
757-#: init/control.c:290
758+#: init/control.c:301
759 msgid "Disconnected from system bus"
760 msgstr ""
761
762-#: init/control.c:356 init/main.c:546
763+#: init/control.c:367 init/main.c:567
764 msgid "Reloading configuration"
765 msgstr ""
766
767-#: init/control.c:396 init/control.c:507
768+#: init/control.c:407 init/control.c:518
769 msgid "Name may not be empty string"
770 msgstr ""
771
772-#: init/control.c:405
773+#: init/control.c:416
774 #, c-format
775 msgid "Unknown job: %s"
776 msgstr ""
777
778-#: init/control.c:514 init/job_class.c:522 init/job_class.c:710
779-#: init/job_class.c:829 init/job_class.c:953
780+#: init/control.c:525 init/job_class.c:524 init/job_class.c:712
781+#: init/job_class.c:831 init/job_class.c:955
782 msgid "Env must be KEY=VALUE pairs"
783 msgstr ""
784
785-#: init/control.c:666
786+#: init/control.c:677
787 msgid "The log priority given was not recognised"
788 msgstr ""
789
790+#: init/errors.h:58
791+msgid "Illegal parameter"
792+msgstr ""
793+
794+#: init/errors.h:59
795+msgid "Unknown parameter"
796+msgstr ""
797+
798+#: init/errors.h:60 init/errors.h:71
799+msgid "Expected operator"
800+msgstr ""
801+
802+#: init/errors.h:61
803+msgid "Mismatched braces"
804+msgstr ""
805+
806+#: init/errors.h:62
807+msgid "Illegal interval, expected number of seconds"
808+msgstr ""
809+
810+#: init/errors.h:63
811+msgid "Illegal exit status, expected integer"
812+msgstr ""
813+
814+#: init/errors.h:64
815+msgid "Illegal signal status, expected integer"
816+msgstr ""
817+
818+#: init/errors.h:65
819+msgid "Illegal file creation mask, expected octal integer"
820+msgstr ""
821+
822+#: init/errors.h:66
823+msgid "Illegal nice value, expected -20 to 19"
824+msgstr ""
825+
826+#: init/errors.h:67
827+msgid "Illegal oom adjustment, expected -16 to 15 or 'never'"
828+msgstr ""
829+
830+#: init/errors.h:68
831+msgid "Illegal oom score adjustment, expected -999 to 1000 or 'never'"
832+msgstr ""
833+
834+#: init/errors.h:69
835+msgid "Illegal limit, expected 'unlimited' or integer"
836+msgstr ""
837+
838+#: init/errors.h:70
839+msgid "Expected event"
840+msgstr ""
841+
842+#: init/errors.h:72
843+msgid "Expected variable name before value"
844+msgstr ""
845+
846+#: init/errors.h:73
847+msgid "Mismatched parentheses"
848+msgstr ""
849+
850+#: init/errors.h:74
851+msgid "Name already taken"
852+msgstr ""
853+
854 #: init/event.c:273
855 #, c-format
856 msgid "Handling %s event"
857@@ -164,241 +229,240 @@
858 msgid "post-stop"
859 msgstr ""
860
861-#: init/job.c:1113 init/job_class.c:756
862+#: init/job.c:1113 init/job_class.c:758
863 #, c-format
864 msgid "Job is already running: %s"
865 msgstr ""
866
867-#: init/job.c:1177 init/job.c:1242 init/job_class.c:875 init/job_class.c:998
868+#: init/job.c:1177 init/job.c:1242 init/job_class.c:877 init/job_class.c:1000
869 #, c-format
870 msgid "Job has already been stopped: %s"
871 msgstr ""
872
873-#: init/job_class.c:559 init/job_class.c:604 init/job_class.c:867
874-#: init/job_class.c:990
875+#: init/job_class.c:561 init/job_class.c:606 init/job_class.c:869
876+#: init/job_class.c:992
877 #, c-format
878 msgid "Unknown instance: %s"
879 msgstr ""
880
881-#: init/job_process.c:279
882+#: init/job_process.c:276
883 #, c-format
884 msgid "Failed to spawn %s %s process: %s"
885 msgstr ""
886
887-#: init/job_process.c:285
888+#: init/job_process.c:282
889 msgid "Temporary process spawn error"
890 msgstr ""
891
892-#: init/job_process.c:292
893+#: init/job_process.c:289
894 #, c-format
895 msgid "%s %s process (%d)"
896 msgstr ""
897
898-#: init/job_process.c:399
899+#: init/job_process.c:402
900 #, c-format
901 msgid "Pausing %s (%d) [pre-exec] for debug"
902 msgstr ""
903
904-#: init/job_process.c:453
905+#: init/job_process.c:472
906 #, c-format
907 msgid "Failed to open system console: %s"
908 msgstr ""
909
910-#: init/job_process.c:669
911+#: init/job_process.c:696
912+#, c-format
913+msgid "unable to move script fd: %s"
914+msgstr ""
915+
916+#: init/job_process.c:701
917 #, c-format
918 msgid "unable to open console: %s"
919 msgstr ""
920
921-#: init/job_process.c:724
922+#: init/job_process.c:756
923 #, c-format
924 msgid "unable to set \"%s\" resource limit: %s"
925 msgstr ""
926
927-#: init/job_process.c:729
928+#: init/job_process.c:761
929 #, c-format
930 msgid "unable to set priority: %s"
931 msgstr ""
932
933-#: init/job_process.c:734
934+#: init/job_process.c:766
935 #, c-format
936 msgid "unable to set oom adjustment: %s"
937 msgstr ""
938
939-#: init/job_process.c:739
940+#: init/job_process.c:771
941 #, c-format
942 msgid "unable to change root directory: %s"
943 msgstr ""
944
945-#: init/job_process.c:744
946+#: init/job_process.c:776
947 #, c-format
948 msgid "unable to change working directory: %s"
949 msgstr ""
950
951-#: init/job_process.c:749
952+#: init/job_process.c:781
953 #, c-format
954 msgid "unable to set trace: %s"
955 msgstr ""
956
957-#: init/job_process.c:754
958+#: init/job_process.c:786
959 #, c-format
960 msgid "unable to execute: %s"
961 msgstr ""
962
963-#: init/job_process.c:785
964-#, c-format
965-msgid "Sending TERM signal to %s %s process (%d)"
966-msgstr ""
967-
968-#: init/job_process.c:793
969-#, c-format
970-msgid "Failed to send TERM signal to %s %s process (%d): %s"
971-msgstr ""
972-
973-#: init/job_process.c:833
974-#, c-format
975-msgid "Sending KILL signal to %s %s process (%d)"
976-msgstr ""
977-
978-#: init/job_process.c:841
979-#, c-format
980-msgid "Failed to send KILL signal to %s %s process (%d): %s"
981-msgstr ""
982-
983-#: init/job_process.c:901
984+#: init/job_process.c:817 init/job_process.c:867
985+#, c-format
986+msgid "Sending %s signal to %s %s process (%d)"
987+msgstr ""
988+
989+#: init/job_process.c:826 init/job_process.c:876
990+#, c-format
991+msgid "Failed to send %s signal to %s %s process (%d): %s"
992+msgstr ""
993+
994+#: init/job_process.c:937
995 #, c-format
996 msgid "%s %s process (%d) terminated with status %d"
997 msgstr ""
998
999-#: init/job_process.c:906
1000+#: init/job_process.c:942
1001 #, c-format
1002 msgid "%s %s process (%d) exited normally"
1003 msgstr ""
1004
1005-#: init/job_process.c:921
1006+#: init/job_process.c:957
1007 #, c-format
1008 msgid "%s %s process (%d) killed by %s signal"
1009 msgstr ""
1010
1011-#: init/job_process.c:925
1012+#: init/job_process.c:961
1013 #, c-format
1014 msgid "%s %s process (%d) killed by signal %d"
1015 msgstr ""
1016
1017-#: init/job_process.c:939
1018+#: init/job_process.c:975
1019 #, c-format
1020 msgid "%s %s process (%d) stopped by %s signal"
1021 msgstr ""
1022
1023-#: init/job_process.c:943
1024+#: init/job_process.c:979
1025 #, c-format
1026 msgid "%s %s process (%d) stopped by signal %d"
1027 msgstr ""
1028
1029-#: init/job_process.c:957
1030+#: init/job_process.c:993
1031 #, c-format
1032 msgid "%s %s process (%d) continued by %s signal"
1033 msgstr ""
1034
1035-#: init/job_process.c:961
1036+#: init/job_process.c:997
1037 #, c-format
1038 msgid "%s %s process (%d) continued by signal %d"
1039 msgstr ""
1040
1041-#: init/job_process.c:1096
1042+#: init/job_process.c:1132
1043 #, c-format
1044 msgid "%s respawning too fast, stopped"
1045 msgstr ""
1046
1047-#: init/job_process.c:1102
1048+#: init/job_process.c:1138
1049 #, c-format
1050 msgid "%s %s process ended, respawning"
1051 msgstr ""
1052
1053-#: init/job_process.c:1342
1054+#: init/job_process.c:1378
1055 #, c-format
1056 msgid "Failed to set ptrace options for %s %s process (%d): %s"
1057 msgstr ""
1058
1059-#: init/job_process.c:1355 init/job_process.c:1550
1060+#: init/job_process.c:1391 init/job_process.c:1586
1061 #, c-format
1062 msgid "Failed to continue traced %s %s process (%d): %s"
1063 msgstr ""
1064
1065-#: init/job_process.c:1395 init/job_process.c:1486 init/job_process.c:1541
1066+#: init/job_process.c:1431 init/job_process.c:1522 init/job_process.c:1577
1067 #, c-format
1068 msgid "Failed to detach traced %s %s process (%d): %s"
1069 msgstr ""
1070
1071-#: init/job_process.c:1435
1072+#: init/job_process.c:1471
1073 #, c-format
1074 msgid "Failed to deliver signal to traced %s %s process (%d): %s"
1075 msgstr ""
1076
1077-#: init/job_process.c:1470
1078+#: init/job_process.c:1506
1079 #, c-format
1080 msgid "Failed to obtain child process id for %s %s process (%d): %s"
1081 msgstr ""
1082
1083-#: init/job_process.c:1477
1084+#: init/job_process.c:1513
1085 #, c-format
1086 msgid "%s %s process (%d) became new process (%d)"
1087 msgstr ""
1088
1089-#: init/job_process.c:1536
1090+#: init/job_process.c:1572
1091 #, c-format
1092 msgid "%s %s process (%d) executable changed"
1093 msgstr ""
1094
1095-#: init/main.c:117
1096+#: init/main.c:100
1097+msgid "use D-Bus session bus rather than system bus (for testing)"
1098+msgstr ""
1099+
1100+#: init/main.c:120
1101 msgid "Process management daemon."
1102 msgstr ""
1103
1104-#: init/main.c:119
1105+#: init/main.c:122
1106 msgid ""
1107 "This daemon is normally executed by the kernel and given process id 1 to "
1108 "denote its special status. When executed by a user process, it will "
1109 "actually run /sbin/telinit."
1110 msgstr ""
1111
1112-#: init/main.c:130 util/reboot.c:167 util/shutdown.c:363 util/telinit.c:148
1113+#: init/main.c:137 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148
1114 msgid "Need to be root"
1115 msgstr ""
1116
1117-#: init/main.c:139
1118+#: init/main.c:146
1119 msgid "Not being executed as init"
1120 msgstr ""
1121
1122-#: init/main.c:187 init/main.c:456
1123+#: init/main.c:194 init/main.c:477
1124 msgid "Unable to set root directory"
1125 msgstr ""
1126
1127-#: init/main.c:198
1128+#: init/main.c:205
1129 msgid "Unable to mount /proc filesystem"
1130 msgstr ""
1131
1132-#: init/main.c:207
1133+#: init/main.c:214
1134 msgid "Unable to mount /sys filesystem"
1135 msgstr ""
1136
1137-#: init/main.c:292
1138+#: init/main.c:310
1139 msgid "Unable to listen for private connections"
1140 msgstr ""
1141
1142-#: init/main.c:473
1143+#: init/main.c:494
1144 #, c-format
1145 msgid "Caught %s, core dumped"
1146 msgstr ""
1147
1148-#: init/main.c:477
1149+#: init/main.c:498
1150 #, c-format
1151 msgid "Caught %s, unable to dump core"
1152 msgstr ""
1153
1154-#: init/main.c:563
1155+#: init/main.c:584
1156 msgid "Reconnecting to system bus"
1157 msgstr ""
1158
1159-#: init/main.c:569
1160+#: init/main.c:590
1161 msgid "Unable to connect to the system bus"
1162 msgstr ""
1163
1164@@ -406,76 +470,84 @@
1165 msgid "main"
1166 msgstr ""
1167
1168-#: util/initctl.c:145
1169+#: util/initctl.c:185
1170 msgid "Unable to connect to system bus"
1171 msgstr ""
1172
1173-#: util/initctl.c:154
1174+#: util/initctl.c:186
1175+msgid "Unable to connect to session bus"
1176+msgstr ""
1177+
1178+#: util/initctl.c:195
1179 #, c-format
1180 msgid "%s: --dest given without --system\n"
1181 msgstr ""
1182
1183-#: util/initctl.c:162
1184+#: util/initctl.c:203
1185 msgid "Unable to connect to Upstart"
1186 msgstr ""
1187
1188-#: util/initctl.c:348 util/initctl.c:483 util/initctl.c:611 util/initctl.c:745
1189-#: util/initctl.c:850
1190+#: util/initctl.c:389 util/initctl.c:524 util/initctl.c:652 util/initctl.c:786
1191+#: util/initctl.c:891
1192 #, c-format
1193 msgid "%s: missing job name\n"
1194 msgstr ""
1195
1196-#: util/initctl.c:796
1197+#: util/initctl.c:837
1198 msgid "Not running"
1199 msgstr ""
1200
1201-#: util/initctl.c:1065
1202+#: util/initctl.c:1106
1203 #, c-format
1204 msgid "%s: missing event name\n"
1205 msgstr ""
1206
1207-#: util/initctl.c:1261
1208+#: util/initctl.c:1302
1209+msgid "use D-Bus session bus to connect to init daemon (for testing)"
1210+msgstr ""
1211+
1212+#: util/initctl.c:1304
1213 msgid "use D-Bus system bus to connect to init daemon"
1214 msgstr ""
1215
1216-#: util/initctl.c:1263
1217-msgid "destination well-known name on system bus"
1218+#: util/initctl.c:1306
1219+msgid "destination well-known name on D-Bus bus"
1220 msgstr ""
1221
1222-#: util/initctl.c:1276
1223+#: util/initctl.c:1319
1224 msgid "do not wait for job to start before exiting"
1225 msgstr ""
1226
1227-#: util/initctl.c:1288
1228+#: util/initctl.c:1331
1229 msgid "do not wait for job to stop before exiting"
1230 msgstr ""
1231
1232-#: util/initctl.c:1300
1233+#: util/initctl.c:1343
1234 msgid "do not wait for job to restart before exiting"
1235 msgstr ""
1236
1237-#: util/initctl.c:1339
1238+#: util/initctl.c:1382
1239 msgid "do not wait for event to finish before exiting"
1240 msgstr ""
1241
1242-#: util/initctl.c:1378
1243+#: util/initctl.c:1421
1244 msgid "Job"
1245 msgstr ""
1246
1247-#: util/initctl.c:1385
1248+#: util/initctl.c:1428
1249 msgid "Event"
1250 msgstr ""
1251
1252-#: util/initctl.c:1393 util/initctl.c:1405 util/initctl.c:1416
1253-#: util/initctl.c:1427 util/initctl.c:1434
1254+#: util/initctl.c:1436 util/initctl.c:1448 util/initctl.c:1459
1255+#: util/initctl.c:1470 util/initctl.c:1477
1256 msgid "JOB [KEY=VALUE]..."
1257 msgstr ""
1258
1259-#: util/initctl.c:1394
1260+#: util/initctl.c:1437
1261 msgid "Start job."
1262 msgstr ""
1263
1264-#: util/initctl.c:1395
1265+#: util/initctl.c:1438
1266 msgid ""
1267 "JOB is the name of the job that is to be started, this may be followed by "
1268 "zero or more environment variables to be defined in the new job.\n"
1269@@ -485,11 +557,11 @@
1270 "an existing instance is already running."
1271 msgstr ""
1272
1273-#: util/initctl.c:1406
1274+#: util/initctl.c:1449
1275 msgid "Stop job."
1276 msgstr ""
1277
1278-#: util/initctl.c:1407
1279+#: util/initctl.c:1450
1280 msgid ""
1281 "JOB is the name of the job that is to be stopped, this may be followed by "
1282 "zero or more environment variables to be passed to the job's pre-stop and "
1283@@ -499,11 +571,11 @@
1284 "decide which of multiple instances will be stopped."
1285 msgstr ""
1286
1287-#: util/initctl.c:1417
1288+#: util/initctl.c:1460
1289 msgid "Restart job."
1290 msgstr ""
1291
1292-#: util/initctl.c:1418
1293+#: util/initctl.c:1461
1294 msgid ""
1295 "JOB is the name of the job that is to be restarted, this may be followed by "
1296 "zero or more environment variables to be defined in the job after "
1297@@ -513,66 +585,66 @@
1298 "decide which of multiple instances will be restarted."
1299 msgstr ""
1300
1301-#: util/initctl.c:1428
1302+#: util/initctl.c:1471
1303 msgid "Send HUP signal to job."
1304 msgstr ""
1305
1306-#: util/initctl.c:1429
1307+#: util/initctl.c:1472
1308 msgid ""
1309 "JOB is the name of the job that is to be sent the signal, this may be "
1310 "followed by zero or more environment variables to distinguish between job "
1311 "instances.\n"
1312 msgstr ""
1313
1314-#: util/initctl.c:1435
1315+#: util/initctl.c:1478
1316 msgid "Query status of job."
1317 msgstr ""
1318
1319-#: util/initctl.c:1436
1320+#: util/initctl.c:1479
1321 msgid ""
1322 "JOB is the name of the job that is to be queried, this may be followed by "
1323 "zero or more environment variables to distguish between job instances.\n"
1324 msgstr ""
1325
1326-#: util/initctl.c:1442
1327+#: util/initctl.c:1485
1328 msgid "List known jobs."
1329 msgstr ""
1330
1331-#: util/initctl.c:1443
1332+#: util/initctl.c:1486
1333 msgid "The known jobs and their current status will be output."
1334 msgstr ""
1335
1336-#: util/initctl.c:1446
1337+#: util/initctl.c:1489
1338 msgid "EVENT [KEY=VALUE]..."
1339 msgstr ""
1340
1341-#: util/initctl.c:1447
1342+#: util/initctl.c:1490
1343 msgid "Emit an event."
1344 msgstr ""
1345
1346-#: util/initctl.c:1448
1347+#: util/initctl.c:1491
1348 msgid ""
1349 "EVENT is the name of an event the init daemon should emit, this may be "
1350 "followed by zero or more environment variables to be included in the event.\n"
1351 msgstr ""
1352
1353-#: util/initctl.c:1454
1354+#: util/initctl.c:1497
1355 msgid "Reload the configuration of the init daemon."
1356 msgstr ""
1357
1358-#: util/initctl.c:1458
1359+#: util/initctl.c:1501
1360 msgid "Request the version of the init daemon."
1361 msgstr ""
1362
1363-#: util/initctl.c:1461
1364+#: util/initctl.c:1504
1365 msgid "[PRIORITY]"
1366 msgstr ""
1367
1368-#: util/initctl.c:1462
1369+#: util/initctl.c:1505
1370 msgid "Change the minimum priority of log messages from the init daemon"
1371 msgstr ""
1372
1373-#: util/initctl.c:1464
1374+#: util/initctl.c:1507
1375 msgid ""
1376 "PRIORITY may be one of:\n"
1377 " `debug' (messages useful for debugging upstart are logged, equivalent to --"
1378@@ -589,59 +661,59 @@
1379 "Without arguments, this outputs the current log priority."
1380 msgstr ""
1381
1382-#: util/reboot.c:114
1383+#: util/reboot.c:113
1384 msgid "don't sync before reboot or halt"
1385 msgstr ""
1386
1387-#: util/reboot.c:116
1388+#: util/reboot.c:115
1389 msgid "force reboot or halt, don't call shutdown(8)"
1390 msgstr ""
1391
1392-#: util/reboot.c:118
1393+#: util/reboot.c:117
1394 msgid "switch off the power when called as halt"
1395 msgstr ""
1396
1397-#: util/reboot.c:120
1398+#: util/reboot.c:119
1399 msgid "don't actually reboot or halt, just write wtmp record"
1400 msgstr ""
1401
1402-#: util/reboot.c:145
1403+#: util/reboot.c:144
1404 msgid "Halt the system."
1405 msgstr ""
1406
1407-#: util/reboot.c:148
1408+#: util/reboot.c:147
1409 msgid "Power off the system."
1410 msgstr ""
1411
1412-#: util/reboot.c:151
1413+#: util/reboot.c:150
1414 msgid "Reboot the system."
1415 msgstr ""
1416
1417-#: util/reboot.c:155
1418+#: util/reboot.c:154
1419 msgid ""
1420 "This command is intended to instruct the kernel to reboot or halt the "
1421 "system; when run without the -f option, or when in a system runlevel other "
1422 "than 0 or 6, it will actually execute /sbin/shutdown.\n"
1423 msgstr ""
1424
1425-#: util/reboot.c:211
1426+#: util/reboot.c:210
1427 msgid "Calling shutdown"
1428 msgstr ""
1429
1430-#: util/reboot.c:214
1431+#: util/reboot.c:213
1432 #, c-format
1433 msgid "Unable to execute shutdown: %s"
1434 msgstr ""
1435
1436-#: util/reboot.c:235
1437+#: util/reboot.c:234
1438 msgid "Rebooting"
1439 msgstr ""
1440
1441-#: util/reboot.c:239
1442+#: util/reboot.c:238
1443 msgid "Halting"
1444 msgstr ""
1445
1446-#: util/reboot.c:243
1447+#: util/reboot.c:242
1448 msgid "Powering off"
1449 msgstr ""
1450
1451
1452=== modified file 'util/initctl.c'
1453--- util/initctl.c 2010-02-04 19:08:07 +0000
1454+++ util/initctl.c 2011-06-03 09:21:18 +0000
1455@@ -63,6 +63,11 @@
1456 static void reply_handler (int *ret, NihDBusMessage *message);
1457 static void error_handler (void *data, NihDBusMessage *message);
1458
1459+#ifndef TEST
1460+
1461+static int dbus_bus_type_setter (NihOption *option, const char *arg);
1462+
1463+#endif
1464
1465 /* Prototypes for option and command functions */
1466 int start_action (NihCommand *command, char * const *args);
1467@@ -78,12 +83,21 @@
1468
1469
1470 /**
1471- * system_bus:
1472- *
1473- * Whether to connect to the init daemon on the D-Bus system bus or
1474- * privately.
1475- **/
1476-int system_bus = -1;
1477+ * use_dbus:
1478+ *
1479+ * If 1, connect using a D-Bus bus.
1480+ * If 0, connect using private connection.
1481+ * If -1, determine appropriate connection based on UID.
1482+ */
1483+int use_dbus = -1;
1484+
1485+/**
1486+ * dbus_bus_type:
1487+ *
1488+ * D-Bus bus to connect to (DBUS_BUS_SYSTEM or DBUS_BUS_SESSION), or -1
1489+ * to have an appropriate bus selected.
1490+ */
1491+int dbus_bus_type = -1;
1492
1493 /**
1494 * dest_name:
1495@@ -107,6 +121,28 @@
1496 **/
1497 int no_wait = FALSE;
1498
1499+/**
1500+ * NihOption setter function to handle selection of appropriate D-Bus
1501+ * bus.
1502+ *
1503+ * Always returns 1 denoting success.
1504+ **/
1505+int
1506+dbus_bus_type_setter (NihOption *option, const char *arg)
1507+{
1508+ nih_assert (option);
1509+
1510+ if (! strcmp (option->long_option, "system")) {
1511+ use_dbus = TRUE;
1512+ dbus_bus_type = DBUS_BUS_SYSTEM;
1513+ }
1514+ else if (! strcmp (option->long_option, "session")) {
1515+ use_dbus = TRUE;
1516+ dbus_bus_type = DBUS_BUS_SESSION;
1517+ }
1518+
1519+ return 1;
1520+}
1521
1522 /**
1523 * upstart_open:
1524@@ -132,17 +168,22 @@
1525 DBusConnection *connection;
1526 NihDBusProxy * upstart;
1527
1528- if (system_bus < 0)
1529- system_bus = getuid () ? TRUE : FALSE;
1530+ if (use_dbus < 0)
1531+ use_dbus = getuid () ? TRUE : FALSE;
1532+ if (use_dbus >= 0 && dbus_bus_type < 0)
1533+ dbus_bus_type = DBUS_BUS_SYSTEM;
1534
1535 dbus_error_init (&dbus_error);
1536- if (system_bus) {
1537+ if (use_dbus) {
1538 if (! dest_name)
1539 dest_name = DBUS_SERVICE_UPSTART;
1540
1541- connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
1542+ connection = dbus_bus_get (dbus_bus_type, &dbus_error);
1543 if (! connection) {
1544- nih_error ("%s: %s", _("Unable to connect to system bus"),
1545+ nih_error ("%s: %s",
1546+ dbus_bus_type == DBUS_BUS_SYSTEM
1547+ ? _("Unable to connect to system bus")
1548+ : _("Unable to connect to session bus"),
1549 dbus_error.message);
1550 dbus_error_free (&dbus_error);
1551 return NULL;
1552@@ -1258,9 +1299,11 @@
1553 * Command-line options accepted for all arguments.
1554 **/
1555 static NihOption options[] = {
1556+ { 0, "session", N_("use D-Bus session bus to connect to init daemon (for testing)"),
1557+ NULL, NULL, NULL, dbus_bus_type_setter },
1558 { 0, "system", N_("use D-Bus system bus to connect to init daemon"),
1559- NULL, NULL, &system_bus, NULL },
1560- { 0, "dest", N_("destination well-known name on system bus"),
1561+ NULL, NULL, NULL, dbus_bus_type_setter },
1562+ { 0, "dest", N_("destination well-known name on D-Bus bus"),
1563 NULL, "NAME", &dest_name, NULL },
1564
1565 NIH_OPTION_LAST
1566
1567=== modified file 'util/man/initctl.8'
1568--- util/man/initctl.8 2010-02-04 19:08:07 +0000
1569+++ util/man/initctl.8 2011-06-03 09:21:18 +0000
1570@@ -1,4 +1,4 @@
1571-.TH initctl 8 2010-02-04 "Upstart"
1572+.TH initctl 8 2011-06-01 "Upstart"
1573 .\"
1574 .SH NAME
1575 initctl \- init daemon control tool
1576@@ -33,6 +33,12 @@
1577 .\"
1578 .SH OPTIONS
1579 .TP
1580+.B --session
1581+Connect to
1582+.BR init (8)
1583+daemon using the D-Bus session bus (for testing purposes only).
1584+.\"
1585+.TP
1586 .B --system
1587 Communication with the
1588 .BR init (8)
1589@@ -348,7 +354,7 @@
1590 .RB < https://launchpad.net/upstart/+bugs >
1591 .\"
1592 .SH COPYRIGHT
1593-Copyright \(co 2010 Canonical Ltd.
1594+Copyright \(co 2010-2011 Canonical Ltd.
1595 .br
1596 This is free software; see the source for copying conditions. There is NO
1597 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1598
1599=== modified file 'util/reboot.c'
1600--- util/reboot.c 2011-03-16 22:18:22 +0000
1601+++ util/reboot.c 2011-06-03 09:21:18 +0000
1602@@ -1,6 +1,5 @@
1603 /* upstart
1604 *
1605- * Copyright © 2011 Google Inc.
1606 * Copyright © 2010 Canonical Ltd.
1607 * Author: Scott James Remnant <scott@netsplit.com>.
1608 *
1609
1610=== modified file 'util/tests/test_initctl.c'
1611--- util/tests/test_initctl.c 2010-02-04 20:43:33 +0000
1612+++ util/tests/test_initctl.c 2011-06-03 09:21:18 +0000
1613@@ -44,7 +44,8 @@
1614 #include "dbus/upstart.h"
1615
1616
1617-extern int system_bus;
1618+extern int use_dbus;
1619+extern int dbus_bus_type;
1620 extern char *dest_name;
1621 extern const char *dest_address;
1622 extern int no_wait;
1623@@ -103,7 +104,7 @@
1624 */
1625 TEST_FEATURE ("with private connection");
1626 TEST_ALLOC_FAIL {
1627- system_bus = FALSE;
1628+ use_dbus = FALSE;
1629 dest_name = NULL;
1630 dest_address = "unix:abstract=/com/ubuntu/upstart/test";
1631
1632@@ -179,7 +180,8 @@
1633 */
1634 TEST_FEATURE ("with system bus connection");
1635 TEST_ALLOC_FAIL {
1636- system_bus = TRUE;
1637+ use_dbus = TRUE;
1638+ dbus_bus_type = DBUS_BUS_SYSTEM;
1639 dest_name = NULL;
1640 dest_address = DBUS_ADDRESS_UPSTART;
1641
1642@@ -240,7 +242,8 @@
1643 */
1644 TEST_FEATURE ("with system bus connection and different name");
1645 TEST_ALLOC_FAIL {
1646- system_bus = TRUE;
1647+ use_dbus = TRUE;
1648+ dbus_bus_type = DBUS_BUS_SYSTEM;
1649 dest_name = "com.ubuntu.UpstartTest";
1650 dest_address = DBUS_ADDRESS_UPSTART;
1651
1652@@ -302,7 +305,7 @@
1653 */
1654 TEST_FEATURE ("with non-listening private connection");
1655 TEST_ALLOC_FAIL {
1656- system_bus = FALSE;
1657+ use_dbus = FALSE;
1658 dest_name = NULL;
1659 dest_address = "unix:abstract=/com/ubuntu/upstart/test";
1660
1661@@ -328,7 +331,8 @@
1662 */
1663 TEST_FEATURE ("with non-listening system bus");
1664 TEST_ALLOC_FAIL {
1665- system_bus = TRUE;
1666+ use_dbus = TRUE;
1667+ dbus_bus_type = DBUS_BUS_SYSTEM;
1668 dest_name = NULL;
1669 dest_address = DBUS_ADDRESS_UPSTART;
1670
1671@@ -360,7 +364,7 @@
1672 */
1673 TEST_FEATURE ("with --dest but without --system");
1674 TEST_ALLOC_FAIL {
1675- system_bus = FALSE;
1676+ use_dbus = FALSE;
1677 dest_name = "com.ubuntu.Upstart";
1678 dest_address = DBUS_ADDRESS_UPSTART;
1679
1680@@ -3229,7 +3233,8 @@
1681 "NameAcquired"));
1682 dbus_message_unref (method_call);
1683
1684- system_bus = TRUE;
1685+ use_dbus = TRUE;
1686+ dbus_bus_type = DBUS_BUS_SYSTEM;
1687 dest_name = DBUS_SERVICE_UPSTART;
1688 dest_address = DBUS_ADDRESS_UPSTART;
1689
1690@@ -4999,7 +5004,8 @@
1691 "NameAcquired"));
1692 dbus_message_unref (method_call);
1693
1694- system_bus = TRUE;
1695+ use_dbus = TRUE;
1696+ dbus_bus_type = DBUS_BUS_SYSTEM;
1697 dest_name = DBUS_SERVICE_UPSTART;
1698 dest_address = DBUS_ADDRESS_UPSTART;
1699
1700@@ -6584,7 +6590,8 @@
1701 "NameAcquired"));
1702 dbus_message_unref (method_call);
1703
1704- system_bus = TRUE;
1705+ use_dbus = TRUE;
1706+ dbus_bus_type = DBUS_BUS_SYSTEM;
1707 dest_name = DBUS_SERVICE_UPSTART;
1708 dest_address = DBUS_ADDRESS_UPSTART;
1709
1710@@ -8357,7 +8364,8 @@
1711 "NameAcquired"));
1712 dbus_message_unref (method_call);
1713
1714- system_bus = TRUE;
1715+ use_dbus = TRUE;
1716+ dbus_bus_type = DBUS_BUS_SYSTEM;
1717 dest_name = DBUS_SERVICE_UPSTART;
1718 dest_address = DBUS_ADDRESS_UPSTART;
1719
1720@@ -9239,7 +9247,8 @@
1721 "NameAcquired"));
1722 dbus_message_unref (method_call);
1723
1724- system_bus = TRUE;
1725+ use_dbus = TRUE;
1726+ dbus_bus_type = DBUS_BUS_SYSTEM;
1727 dest_name = DBUS_SERVICE_UPSTART;
1728 dest_address = DBUS_ADDRESS_UPSTART;
1729
1730@@ -10769,7 +10778,7 @@
1731 "NameAcquired"));
1732 dbus_message_unref (method_call);
1733
1734- system_bus = TRUE;
1735+ dbus_bus_type = DBUS_BUS_SYSTEM;
1736 dest_name = DBUS_SERVICE_UPSTART;
1737 dest_address = DBUS_ADDRESS_UPSTART;
1738
1739@@ -12060,7 +12069,7 @@
1740 "NameAcquired"));
1741 dbus_message_unref (method_call);
1742
1743- system_bus = TRUE;
1744+ dbus_bus_type = DBUS_BUS_SYSTEM;
1745 dest_name = DBUS_SERVICE_UPSTART;
1746 dest_address = DBUS_ADDRESS_UPSTART;
1747
1748@@ -12494,7 +12503,7 @@
1749 "NameAcquired"));
1750 dbus_message_unref (method_call);
1751
1752- system_bus = TRUE;
1753+ dbus_bus_type = DBUS_BUS_SYSTEM;
1754 dest_name = DBUS_SERVICE_UPSTART;
1755 dest_address = DBUS_ADDRESS_UPSTART;
1756
1757@@ -12684,7 +12693,7 @@
1758 "NameAcquired"));
1759 dbus_message_unref (method_call);
1760
1761- system_bus = TRUE;
1762+ dbus_bus_type = DBUS_BUS_SYSTEM;
1763 dest_name = DBUS_SERVICE_UPSTART;
1764 dest_address = DBUS_ADDRESS_UPSTART;
1765
1766@@ -12904,7 +12913,7 @@
1767 "NameAcquired"));
1768 dbus_message_unref (method_call);
1769
1770- system_bus = TRUE;
1771+ dbus_bus_type = DBUS_BUS_SYSTEM;
1772 dest_name = DBUS_SERVICE_UPSTART;
1773 dest_address = DBUS_ADDRESS_UPSTART;
1774

Subscribers

People subscribed via source and target branches