Merge lp:~jamesodhunt/upstart/upstream-configurable-confdir into lp:upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1286
Proposed branch: lp:~jamesodhunt/upstart/upstream-configurable-confdir
Merge into: lp:upstart
Diff against target: 1353 lines (+464/-254)
19 files modified
ChangeLog (+26/-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 (+198/-134)
init/man/init.8 (+11/-2)
init/paths.h (+16/-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 (+164/-96)
util/reboot.c (+0/-1)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/upstream-configurable-confdir
Reviewer Review Type Date Requested Status
Upstart Developers Pending
Review via email: mp+63344@code.launchpad.net

Description of the change

  Add option to allow alternate location for job config files.

  * init/main.c:
    - Added "--confdir <dir>" command-line option.
    - handle_confdir(): New function to select alternate confdir using env
      var "UPSTART_CONFDIR" or command-line option (for testing).
  * init/paths.h: Added define for CONFDIR_ENV.
  * init/man/init.8: Update for "--confdir".
  * Changelog: Updated.

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

Note: This is a pre-requisite for the visualisation feature.

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:09:24 +0000
4@@ -1,3 +1,29 @@
5+2011-05-31 James Hunt <james.hunt@ubuntu.com>
6+
7+ Add command-line option to use D-Bus session bus (for testing).
8+
9+ * init/control.c:
10+ - Added new boolean use_session_bus.
11+ - Updated comments.
12+ - control_handle_bus_type(): New function to allow selection of
13+ session bus via env var "UPSTART_USE_SESSION_BUS".
14+ Also logs use of session bus if use_session_bus set.
15+ - control_bus_open(): Now connects to either D-Bus system bus or session bus.
16+ * init/control.h: New define for USE_SESSION_BUS_ENV.
17+ * init/main.c: Addition of "--session" command-line option.
18+ * init/man/init.8: Update for new "--session" command-line option.
19+
20+ * Corrected copyright notices.
21+
22+ Add option to allow alternate location for job config files.
23+
24+ * init/main.c:
25+ - Added "--confdir <dir>" command-line option.
26+ - handle_confdir(): New function to select alternate confdir using env
27+ var "UPSTART_CONFDIR" or command-line option (for testing).
28+ * init/paths.h: Added define for CONFDIR_ENV.
29+ * init/man/init.8: Update for new "--confdir" command-line option.
30+
31 2011-05-12 Marc - A. Dahlhaus <mad@wol.de>
32
33 * init/job_class.h (JobClass): Add kill signal member
34
35=== modified file 'configure.ac'
36--- configure.ac 2011-03-22 17:53:17 +0000
37+++ configure.ac 2011-06-03 09:09:24 +0000
38@@ -2,7 +2,7 @@
39
40 AC_PREREQ(2.61)
41 AC_INIT([upstart], [1.3], [upstart-devel@lists.ubuntu.com])
42-NIH_COPYRIGHT([[Copyright © 2011 Scott James Remnant, Google Inc., Canonical Ltd.]])
43+NIH_COPYRIGHT([[Copyright © 2011 Scott James Remnant, Canonical Ltd.]])
44 AC_CONFIG_SRCDIR([init/main.c])
45 AC_CONFIG_MACRO_DIR([m4])
46
47
48=== modified file 'init/conf.c'
49--- init/conf.c 2011-03-15 18:44:09 +0000
50+++ init/conf.c 2011-06-03 09:09:24 +0000
51@@ -2,7 +2,6 @@
52 *
53 * conf.c - configuration management
54 *
55- * Copyright © 2011 Google Inc.
56 * Copyright © 2009 Canonical Ltd.
57 * Author: Scott James Remnant <scott@netsplit.com>.
58 *
59
60=== modified file 'init/control.c'
61--- init/control.c 2009-07-11 11:47:12 +0000
62+++ init/control.c 2011-06-03 09:09:24 +0000
63@@ -2,7 +2,7 @@
64 *
65 * control.c - D-Bus connections, objects and methods
66 *
67- * Copyright © 2009 Canonical Ltd.
68+ * Copyright © 2009-2011 Canonical Ltd.
69 * Author: Scott James Remnant <scott@netsplit.com>.
70 *
71 * This program is free software; you can redistribute it and/or modify
72@@ -54,12 +54,19 @@
73
74 #include "com.ubuntu.Upstart.h"
75
76-
77 /* Prototypes for static functions */
78 static int control_server_connect (DBusServer *server, DBusConnection *conn);
79 static void control_disconnected (DBusConnection *conn);
80 static void control_register_all (DBusConnection *conn);
81
82+/**
83+ * use_session_bus:
84+ *
85+ * If TRUE, connect to the D-Bus sessio bus rather than the system bus.
86+ *
87+ * Used for testing.
88+ **/
89+int use_session_bus = FALSE;
90
91 /**
92 * control_server_address:
93@@ -78,7 +85,7 @@
94 /**
95 * control_bus:
96 *
97- * Open connection to D-Bus system bus. The connection may be opened with
98+ * Open connection to a D-Bus bus. The connection may be opened with
99 * control_bus_open() and if lost will become NULL.
100 **/
101 DBusConnection *control_bus = NULL;
102@@ -86,7 +93,7 @@
103 /**
104 * control_conns:
105 *
106- * Open control connections, including the connection to the D-Bus system
107+ * Open control connections, including the connection to a D-Bus
108 * bus and any private client connections.
109 **/
110 NihList *control_conns = NULL;
111@@ -190,8 +197,9 @@
112 /**
113 * control_bus_open:
114 *
115- * Open a connection to the D-Bus system bus and store it in the control_bus
116- * global. The connection is handled automatically in the main loop.
117+ * Open a connection to the appropriate D-Bus bus and store it in the
118+ * control_bus global. The connection is handled automatically
119+ * in the main loop.
120 *
121 * Returns: zero on success, negative value on raised error.
122 **/
123@@ -207,10 +215,13 @@
124
125 control_init ();
126
127+ control_handle_bus_type ();
128+
129 /* Connect to the D-Bus System Bus and hook everything up into
130 * our own main loop automatically.
131 */
132- conn = nih_dbus_bus (DBUS_BUS_SYSTEM, control_disconnected);
133+ conn = nih_dbus_bus (use_session_bus ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM,
134+ control_disconnected);
135 if (! conn)
136 return -1;
137
138@@ -669,3 +680,18 @@
139
140 return 0;
141 }
142+
143+/**
144+ * control_handle_bus_type:
145+ *
146+ * Determine D-Bus bus type to connect to.
147+ **/
148+void
149+control_handle_bus_type (void)
150+{
151+ if (getenv (USE_SESSION_BUS_ENV))
152+ use_session_bus = TRUE;
153+
154+ if (use_session_bus)
155+ nih_debug ("Using session bus");
156+}
157
158=== modified file 'init/control.h'
159--- init/control.h 2009-07-09 08:36:52 +0000
160+++ init/control.h 2011-06-03 09:09:24 +0000
161@@ -1,6 +1,6 @@
162 /* upstart
163 *
164- * Copyright © 2009 Canonical Ltd.
165+ * Copyright © 2009-2011 Canonical Ltd.
166 * Author: Scott James Remnant <scott@netsplit.com>.
167 *
168 * This program is free software; you can redistribute it and/or modify
169@@ -27,6 +27,18 @@
170 #include <nih-dbus/dbus_connection.h>
171 #include <nih-dbus/dbus_message.h>
172
173+/**
174+ * USE_SESSION_BUS_ENV:
175+ *
176+ * If this environment variable is set to any value, connect to
177+ * D-Bus session bus rather than the system bus.
178+ *
179+ * Used for testing.
180+ **/
181+#ifndef USE_SESSION_BUS_ENV
182+#define USE_SESSION_BUS_ENV "UPSTART_USE_SESSION_BUS"
183+#endif
184+
185
186 NIH_BEGIN_EXTERN
187
188@@ -72,6 +84,8 @@
189 const char *log_priority)
190 __attribute__ ((warn_unused_result));
191
192+void control_handle_bus_type (void);
193+
194 NIH_END_EXTERN
195
196 #endif /* INIT_CONTROL_H */
197
198=== modified file 'init/environ.c'
199--- init/environ.c 2011-03-16 22:42:48 +0000
200+++ init/environ.c 2011-06-03 09:09:24 +0000
201@@ -2,7 +2,6 @@
202 *
203 * environ.c - environment table utilities
204 *
205- * Copyright © 2011 Google Inc.
206 * Copyright © 2009 Canonical Ltd.
207 * Author: Scott James Remnant <scott@netsplit.com>.
208 *
209
210=== modified file 'init/environ.h'
211--- init/environ.h 2011-03-16 22:42:48 +0000
212+++ init/environ.h 2011-06-03 09:09:24 +0000
213@@ -1,6 +1,5 @@
214 /* upstart
215 *
216- * Copyright © 2011 Google Inc.
217 * Copyright © 2009 Canonical Ltd.
218 * Author: Scott James Remnant <scott@netsplit.com>.
219 *
220
221=== modified file 'init/job_process.c'
222--- init/job_process.c 2011-05-12 20:42:28 +0000
223+++ init/job_process.c 2011-06-03 09:09:24 +0000
224@@ -2,7 +2,6 @@
225 *
226 * job_process.c - job process handling
227 *
228- * Copyright © 2011 Google Inc.
229 * Copyright © 2011 Canonical Ltd.
230 * Author: Scott James Remnant <scott@netsplit.com>.
231 *
232
233=== modified file 'init/job_process.h'
234--- init/job_process.h 2011-05-12 19:21:16 +0000
235+++ init/job_process.h 2011-06-03 09:09:24 +0000
236@@ -1,6 +1,5 @@
237 /* upstart
238 *
239- * Copyright © 2011 Google Inc.
240 * Copyright © 2009 Canonical Ltd.
241 * Author: Scott James Remnant <scott@netsplit.com>.
242 *
243
244=== modified file 'init/main.c'
245--- init/main.c 2011-03-16 22:54:56 +0000
246+++ init/main.c 2011-06-03 09:09:24 +0000
247@@ -1,7 +1,6 @@
248 /* upstart
249 *
250- * Copyright © 2011 Google Inc.
251- * Copyright © 2010 Canonical Ltd.
252+ * Copyright © 2009-2011 Canonical Ltd.
253 * Author: Scott James Remnant <scott@netsplit.com>.
254 *
255 * This program is free software; you can redistribute it and/or modify
256@@ -71,6 +70,8 @@
257 static void usr1_handler (void *data, NihSignal *signal);
258 #endif /* DEBUG */
259
260+static void handle_confdir (void);
261+
262
263 /**
264 * argv0:
265@@ -90,13 +91,29 @@
266
267
268 /**
269+ * conf_dir:
270+ *
271+ * Full path to job configuration file directory.
272+ *
273+ **/
274+static char *conf_dir = NULL;
275+
276+extern int use_session_bus;
277+
278+/**
279 * options:
280 *
281 * Command-line options we accept.
282 **/
283 static NihOption options[] = {
284+ { 0, "confdir", N_("specify alternative directory to load configuration files from"),
285+ NULL, "DIR", &conf_dir, NULL },
286+
287 { 0, "restart", NULL, NULL, NULL, &restart, NULL },
288
289+ { 0, "session", N_("use D-Bus session bus rather than system bus (for testing)"),
290+ NULL, NULL, &use_session_bus, NULL },
291+
292 /* Ignore invalid options */
293 { '-', "--", NULL, NULL, NULL, NULL, NULL },
294
295@@ -124,94 +141,105 @@
296 if (! args)
297 exit (1);
298
299+ handle_confdir ();
300+ control_handle_bus_type ();
301+
302 #ifndef DEBUG
303- /* Check we're root */
304- if (getuid ()) {
305- nih_fatal (_("Need to be root"));
306- exit (1);
307- }
308-
309- /* Check we're process #1 */
310- if (getpid () > 1) {
311- execv (TELINIT, argv);
312- /* Ignore failure, probably just that telinit doesn't exist */
313-
314- nih_fatal (_("Not being executed as init"));
315- exit (1);
316- }
317-
318- /* Clear our arguments from the command-line, so that we show up in
319- * ps or top output as /sbin/init, with no extra flags.
320- *
321- * This is a very Linux-specific trick; by deleting the NULL
322- * terminator at the end of the last argument, we fool the kernel
323- * into believing we used a setproctitle()-a-like to extend the
324- * argument space into the environment space, and thus make it use
325- * strlen() instead of its own assumed length. In fact, we've done
326- * the exact opposite, and shrunk the command line length to just that
327- * of whatever is in argv[0].
328- *
329- * If we don't do this, and just write \0 over the rest of argv, for
330- * example; the command-line length still includes those \0s, and ps
331- * will show whitespace in their place.
332- */
333- if (argc > 1) {
334- char *arg_end;
335-
336- arg_end = argv[argc-1] + strlen (argv[argc-1]);
337- *arg_end = ' ';
338- }
339-
340-
341- /* Become the leader of a new session and process group, shedding
342- * any controlling tty (which we shouldn't have had anyway - but
343- * you never know what initramfs did).
344- */
345- setsid ();
346-
347- /* Set the standard file descriptors to the ordinary console device,
348- * resetting it to sane defaults unless we're inheriting from another
349- * init process which we know left it in a sane state.
350- */
351- if (system_setup_console (CONSOLE_OUTPUT, (! restart)) < 0)
352- nih_free (nih_error_get ());
353-
354- /* Set the PATH environment variable */
355- setenv ("PATH", PATH, TRUE);
356-
357- /* Switch to the root directory in case we were started from some
358- * strange place, or worse, some directory in the initramfs that's
359- * going to go away soon.
360- */
361- if (chdir ("/"))
362- nih_warn ("%s: %s", _("Unable to set root directory"),
363- strerror (errno));
364-
365- /* Mount the /proc and /sys filesystems, which are pretty much
366- * essential for any Linux system; not to mention used by
367- * ourselves.
368- */
369- if (system_mount ("proc", "/proc") < 0) {
370- NihError *err;
371-
372- err = nih_error_get ();
373- nih_warn ("%s: %s", _("Unable to mount /proc filesystem"),
374- err->message);
375- nih_free (err);
376- }
377-
378- if (system_mount ("sysfs", "/sys") < 0) {
379- NihError *err;
380-
381- err = nih_error_get ();
382- nih_warn ("%s: %s", _("Unable to mount /sys filesystem"),
383- err->message);
384- nih_free (err);
385- }
386+ if (use_session_bus == FALSE) {
387+
388+ /* Check we're root */
389+ if (getuid ()) {
390+ nih_fatal (_("Need to be root"));
391+ exit (1);
392+ }
393+
394+ /* Check we're process #1 */
395+ if (getpid () > 1) {
396+ execv (TELINIT, argv);
397+ /* Ignore failure, probably just that telinit doesn't exist */
398+
399+ nih_fatal (_("Not being executed as init"));
400+ exit (1);
401+ }
402+
403+ /* Clear our arguments from the command-line, so that we show up in
404+ * ps or top output as /sbin/init, with no extra flags.
405+ *
406+ * This is a very Linux-specific trick; by deleting the NULL
407+ * terminator at the end of the last argument, we fool the kernel
408+ * into believing we used a setproctitle()-a-like to extend the
409+ * argument space into the environment space, and thus make it use
410+ * strlen() instead of its own assumed length. In fact, we've done
411+ * the exact opposite, and shrunk the command line length to just that
412+ * of whatever is in argv[0].
413+ *
414+ * If we don't do this, and just write \0 over the rest of argv, for
415+ * example; the command-line length still includes those \0s, and ps
416+ * will show whitespace in their place.
417+ */
418+ if (argc > 1) {
419+ char *arg_end;
420+
421+ arg_end = argv[argc-1] + strlen (argv[argc-1]);
422+ *arg_end = ' ';
423+ }
424+
425+
426+ /* Become the leader of a new session and process group, shedding
427+ * any controlling tty (which we shouldn't have had anyway - but
428+ * you never know what initramfs did).
429+ */
430+ setsid ();
431+
432+ /* Set the standard file descriptors to the ordinary console device,
433+ * resetting it to sane defaults unless we're inheriting from another
434+ * init process which we know left it in a sane state.
435+ */
436+ if (system_setup_console (CONSOLE_OUTPUT, (! restart)) < 0)
437+ nih_free (nih_error_get ());
438+
439+ /* Set the PATH environment variable */
440+ setenv ("PATH", PATH, TRUE);
441+
442+ /* Switch to the root directory in case we were started from some
443+ * strange place, or worse, some directory in the initramfs that's
444+ * going to go away soon.
445+ */
446+ if (chdir ("/"))
447+ nih_warn ("%s: %s", _("Unable to set root directory"),
448+ strerror (errno));
449+
450+ /* Mount the /proc and /sys filesystems, which are pretty much
451+ * essential for any Linux system; not to mention used by
452+ * ourselves.
453+ */
454+ if (system_mount ("proc", "/proc") < 0) {
455+ NihError *err;
456+
457+ err = nih_error_get ();
458+ nih_warn ("%s: %s", _("Unable to mount /proc filesystem"),
459+ err->message);
460+ nih_free (err);
461+ }
462+
463+ if (system_mount ("sysfs", "/sys") < 0) {
464+ NihError *err;
465+
466+ err = nih_error_get ();
467+ nih_warn ("%s: %s", _("Unable to mount /sys filesystem"),
468+ err->message);
469+ nih_free (err);
470+ }
471+ } else {
472+ nih_log_set_priority (NIH_LOG_DEBUG);
473+ nih_debug ("Running with UID %d as PID %d (PPID %d)",
474+ (int)getuid (), (int)getpid (), (int)getppid ());
475+ }
476+
477 #else /* DEBUG */
478 nih_log_set_priority (NIH_LOG_DEBUG);
479- nih_debug ("Running as PID %d (PPID %d)",
480- (int)getpid (), (int)getppid ());
481+ nih_debug ("Running with UID %d as PID %d (PPID %d)",
482+ (int)getuid (), (int)getpid (), (int)getppid ());
483 #endif /* DEBUG */
484
485
486@@ -223,11 +251,13 @@
487 nih_signal_reset ();
488
489 #ifndef DEBUG
490- /* Catch fatal errors immediately rather than waiting for a new
491- * iteration through the main loop.
492- */
493- nih_signal_set_handler (SIGSEGV, crash_handler);
494- nih_signal_set_handler (SIGABRT, crash_handler);
495+ if (use_session_bus == FALSE) {
496+ /* Catch fatal errors immediately rather than waiting for a new
497+ * iteration through the main loop.
498+ */
499+ nih_signal_set_handler (SIGSEGV, crash_handler);
500+ nih_signal_set_handler (SIGABRT, crash_handler);
501+ }
502 #endif /* DEBUG */
503
504 /* Don't ignore SIGCHLD or SIGALRM, but don't respond to them
505@@ -238,33 +268,35 @@
506 nih_signal_set_handler (SIGALRM, nih_signal_handler);
507
508 #ifndef DEBUG
509- /* Ask the kernel to send us SIGINT when control-alt-delete is
510- * pressed; generate an event with the same name.
511- */
512- reboot (RB_DISABLE_CAD);
513- nih_signal_set_handler (SIGINT, nih_signal_handler);
514- NIH_MUST (nih_signal_add_handler (NULL, SIGINT, cad_handler, NULL));
515-
516- /* Ask the kernel to send us SIGWINCH when alt-uparrow is pressed;
517- * generate a keyboard-request event.
518- */
519- if (ioctl (0, KDSIGACCEPT, SIGWINCH) == 0) {
520- nih_signal_set_handler (SIGWINCH, nih_signal_handler);
521- NIH_MUST (nih_signal_add_handler (NULL, SIGWINCH,
522- kbd_handler, NULL));
523+ if (use_session_bus == FALSE) {
524+ /* Ask the kernel to send us SIGINT when control-alt-delete is
525+ * pressed; generate an event with the same name.
526+ */
527+ reboot (RB_DISABLE_CAD);
528+ nih_signal_set_handler (SIGINT, nih_signal_handler);
529+ NIH_MUST (nih_signal_add_handler (NULL, SIGINT, cad_handler, NULL));
530+
531+ /* Ask the kernel to send us SIGWINCH when alt-uparrow is pressed;
532+ * generate a keyboard-request event.
533+ */
534+ if (ioctl (0, KDSIGACCEPT, SIGWINCH) == 0) {
535+ nih_signal_set_handler (SIGWINCH, nih_signal_handler);
536+ NIH_MUST (nih_signal_add_handler (NULL, SIGWINCH,
537+ kbd_handler, NULL));
538+ }
539+
540+ /* powstatd sends us SIGPWR when it changes /etc/powerstatus */
541+ nih_signal_set_handler (SIGPWR, nih_signal_handler);
542+ NIH_MUST (nih_signal_add_handler (NULL, SIGPWR, pwr_handler, NULL));
543+
544+ /* SIGHUP instructs us to re-load our configuration */
545+ nih_signal_set_handler (SIGHUP, nih_signal_handler);
546+ NIH_MUST (nih_signal_add_handler (NULL, SIGHUP, hup_handler, NULL));
547+
548+ /* SIGUSR1 instructs us to reconnect to D-Bus */
549+ nih_signal_set_handler (SIGUSR1, nih_signal_handler);
550+ NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL));
551 }
552-
553- /* powstatd sends us SIGPWR when it changes /etc/powerstatus */
554- nih_signal_set_handler (SIGPWR, nih_signal_handler);
555- NIH_MUST (nih_signal_add_handler (NULL, SIGPWR, pwr_handler, NULL));
556-
557- /* SIGHUP instructs us to re-load our configuration */
558- nih_signal_set_handler (SIGHUP, nih_signal_handler);
559- NIH_MUST (nih_signal_add_handler (NULL, SIGHUP, hup_handler, NULL));
560-
561- /* SIGUSR1 instructs us to reconnect to D-Bus */
562- nih_signal_set_handler (SIGUSR1, nih_signal_handler);
563- NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL));
564 #endif /* DEBUG */
565
566
567@@ -279,25 +311,27 @@
568
569 /* Read configuration */
570 NIH_MUST (conf_source_new (NULL, CONFFILE, CONF_FILE));
571- NIH_MUST (conf_source_new (NULL, CONFDIR, CONF_JOB_DIR));
572+ NIH_MUST (conf_source_new (NULL, conf_dir, CONF_JOB_DIR));
573
574 conf_reload ();
575
576 /* Create a listening server for private connections. */
577- while (control_server_open () < 0) {
578- NihError *err;
579+ if (use_session_bus == FALSE) {
580+ while (control_server_open () < 0) {
581+ NihError *err;
582
583- err = nih_error_get ();
584- if (err->number != ENOMEM) {
585- nih_warn ("%s: %s", _("Unable to listen for private connections"),
586- err->message);
587+ err = nih_error_get ();
588+ if (err->number != ENOMEM) {
589+ nih_warn ("%s: %s", _("Unable to listen for private connections"),
590+ err->message);
591+ nih_free (err);
592+ break;
593+ }
594 nih_free (err);
595- break;
596 }
597- nih_free (err);
598 }
599
600- /* Open connection to the system bus; we normally expect this to
601+ /* Open connection to the appropriate D-Bus bus; we normally expect this to
602 * fail and will try again later - don't let ENOMEM stop us though.
603 */
604 while (control_bus_open () < 0) {
605@@ -313,13 +347,15 @@
606 }
607
608 #ifndef DEBUG
609- /* Now that the startup is complete, send all further logging output
610- * to kmsg instead of to the console.
611- */
612- if (system_setup_console (CONSOLE_NONE, FALSE) < 0)
613- nih_free (nih_error_get ());
614+ if (use_session_bus == FALSE) {
615+ /* Now that the startup is complete, send all further logging output
616+ * to kmsg instead of to the console.
617+ */
618+ if (system_setup_console (CONSOLE_NONE, FALSE) < 0)
619+ nih_free (nih_error_get ());
620
621- nih_log_set_logger (logger_kmsg);
622+ nih_log_set_logger (logger_kmsg);
623+ }
624 #endif /* DEBUG */
625
626
627@@ -573,3 +609,31 @@
628 }
629 }
630 #endif /* DEBUG */
631+
632+/**
633+ * handle_confdir:
634+ *
635+ * Determine where system configuration files should be loaded from.
636+ **/
637+static void
638+handle_confdir (void)
639+{
640+ char *dir;
641+
642+ /* user has already specified directory on command-line */
643+ if (conf_dir)
644+ goto out;
645+
646+ conf_dir = CONFDIR;
647+
648+ dir = getenv (CONFDIR_ENV);
649+ if (! dir)
650+ return;
651+
652+ conf_dir = dir;
653+
654+out:
655+ nih_debug ("Using alternate configuration directory %s",
656+ conf_dir);
657+}
658+
659
660=== modified file 'init/man/init.8'
661--- init/man/init.8 2010-02-04 19:26:17 +0000
662+++ init/man/init.8 2011-06-03 09:09:24 +0000
663@@ -1,4 +1,4 @@
664-.TH init 8 2010-02-04 "Upstart"
665+.TH init 8 2011-05-31 "Upstart"
666 .\"
667 .SH NAME
668 init \- Upstart process management daemon
669@@ -64,6 +64,15 @@
670 by placing them on the kernel command-line.
671 .\"
672 .TP
673+.B \-\-confdir \fIdirectory\fP
674+Read job configuration files from a directory other than
675+\fI/etc/init\fP.
676+.\"
677+.TP
678+.B \-\-session
679+Connect to the D\-Bus session bus. This should only be used for testing.
680+.\"
681+.TP
682 .B --verbose
683 Outputs verbose messages about job state changes and event emissions to the
684 system console or log, useful for debugging boot.
685@@ -90,7 +99,7 @@
686 .RB < https://launchpad.net/upstart/+bugs >
687 .\"
688 .SH COPYRIGHT
689-Copyright \(co 2010 Canonical Ltd.
690+Copyright \(co 2009-2011 Canonical Ltd.
691 .br
692 This is free software; see the source for copying conditions. There is NO
693 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
694
695=== modified file 'init/paths.h'
696--- init/paths.h 2010-02-26 15:27:14 +0000
697+++ init/paths.h 2011-06-03 09:09:24 +0000
698@@ -1,6 +1,6 @@
699 /* upstart
700 *
701- * Copyright © 2010 Canonical Ltd.
702+ * Copyright © 2010-2011 Canonical Ltd.
703 * Author: Scott James Remnant <scott@netsplit.com>.
704 *
705 * This program is free software; you can redistribute it and/or modify
706@@ -67,7 +67,7 @@
707 /**
708 * CONFDIR:
709 *
710- * Top-level directory of the system configuration files.
711+ * Default top-level directory of the system configuration files.
712 **/
713 #ifndef CONFDIR
714 #define CONFDIR "/etc/init"
715@@ -75,6 +75,20 @@
716
717
718 /**
719+ * CONFDIR_ENV:
720+ *
721+ * If this environment variable is set, read configuration files
722+ * from the location specified, rather than CONFDIR.
723+ *
724+ * Value is expected to be the full path to an alternative job
725+ * configuration directory.
726+ **/
727+#ifndef CONFDIR_ENV
728+#define CONFDIR_ENV "UPSTART_CONFDIR"
729+#endif
730+
731+
732+/**
733 * SHELL:
734 *
735 * This is the shell binary used whenever we need special processing for
736
737=== modified file 'init/tests/test_conf.c'
738--- init/tests/test_conf.c 2011-02-17 23:38:17 +0000
739+++ init/tests/test_conf.c 2011-06-03 09:09:24 +0000
740@@ -2,7 +2,6 @@
741 *
742 * test_conf.c - test suite for init/conf.c
743 *
744- * Copyright © 2011 Google Inc.
745 * Copyright © 2009 Canonical Ltd.
746 * Author: Scott James Remnant <scott@netsplit.com>.
747 *
748
749=== modified file 'init/tests/test_control.c'
750--- init/tests/test_control.c 2011-03-16 22:42:48 +0000
751+++ init/tests/test_control.c 2011-06-03 09:09:24 +0000
752@@ -2,7 +2,6 @@
753 *
754 * test_dbus.c - test suite for init/dbus.c
755 *
756- * Copyright © 2011 Google Inc.
757 * Copyright © 2010 Canonical Ltd.
758 * Author: Scott James Remnant <scott@netsplit.com>.
759 *
760
761=== modified file 'init/tests/test_environ.c'
762--- init/tests/test_environ.c 2011-03-16 22:42:48 +0000
763+++ init/tests/test_environ.c 2011-06-03 09:09:24 +0000
764@@ -2,7 +2,6 @@
765 *
766 * test_environ.c - test suite for init/environ.c
767 *
768- * Copyright © 2011 Google Inc.
769 * Copyright © 2009 Canonical Ltd.
770 * Author: Scott James Remnant <scott@netsplit.com>.
771 *
772
773=== modified file 'init/tests/test_job_class.c'
774--- init/tests/test_job_class.c 2011-05-12 20:42:28 +0000
775+++ init/tests/test_job_class.c 2011-06-03 09:09:24 +0000
776@@ -2,7 +2,6 @@
777 *
778 * test_job_class.c - test suite for init/job_class.c
779 *
780- * Copyright © 2011 Google Inc.
781 * Copyright © 2010 Canonical Ltd.
782 * Author: Scott James Remnant <scott@netsplit.com>.
783 *
784
785=== modified file 'init/tests/test_job_process.c'
786--- init/tests/test_job_process.c 2011-05-12 19:21:16 +0000
787+++ init/tests/test_job_process.c 2011-06-03 09:09:24 +0000
788@@ -2,7 +2,6 @@
789 *
790 * test_job_process.c - test suite for init/job_process.c
791 *
792- * Copyright © 2011 Google Inc.
793 * Copyright © 2011 Canonical Ltd.
794 * Author: Scott James Remnant <scott@netsplit.com>.
795 *
796
797=== modified file 'po/upstart.pot'
798--- po/upstart.pot 2011-03-22 17:52:25 +0000
799+++ po/upstart.pot 2011-06-03 09:09:24 +0000
800@@ -6,76 +6,141 @@
801 #, fuzzy
802 msgid ""
803 msgstr ""
804-"Project-Id-Version: upstart 1.2\n"
805+"Project-Id-Version: upstart 1.3\n"
806 "Report-Msgid-Bugs-To: new@bugs.launchpad.net\n"
807-"POT-Creation-Date: 2011-03-22 10:52-0700\n"
808+"POT-Creation-Date: 2011-05-31 16:18+0100\n"
809 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
810 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
811 "Language-Team: LANGUAGE <LL@li.org>\n"
812+"Language: \n"
813 "MIME-Version: 1.0\n"
814 "Content-Type: text/plain; charset=CHARSET\n"
815 "Content-Transfer-Encoding: 8bit\n"
816
817-#: init/conf.c:238
818+#: init/conf.c:237
819 msgid "Unable to load configuration"
820 msgstr ""
821
822-#: init/conf.c:271
823+#: init/conf.c:270
824 #, c-format
825 msgid "Loading configuration from %s"
826 msgstr ""
827
828-#: init/conf.c:308
829+#: init/conf.c:307
830 #, c-format
831 msgid "Handling deletion of %s"
832 msgstr ""
833
834-#: init/conf.c:379
835+#: init/conf.c:378
836 msgid "Unable to watch configuration file"
837 msgstr ""
838
839-#: init/conf.c:457
840+#: init/conf.c:456
841 msgid "Unable to watch configuration directory"
842 msgstr ""
843
844-#: init/conf.c:569 init/conf.c:653
845+#: init/conf.c:568 init/conf.c:652
846 msgid "Error while loading configuration file"
847 msgstr ""
848
849-#: init/conf.c:609
850+#: init/conf.c:608
851 msgid "Configuration directory deleted"
852 msgstr ""
853
854-#: init/control.c:155
855+#: init/control.c:162
856 msgid "Connection from private client"
857 msgstr ""
858
859-#: init/control.c:290
860+#: init/control.c:301
861 msgid "Disconnected from system bus"
862 msgstr ""
863
864-#: init/control.c:356 init/main.c:546
865+#: init/control.c:367 init/main.c:582
866 msgid "Reloading configuration"
867 msgstr ""
868
869-#: init/control.c:396 init/control.c:507
870+#: init/control.c:407 init/control.c:518
871 msgid "Name may not be empty string"
872 msgstr ""
873
874-#: init/control.c:405
875+#: init/control.c:416
876 #, c-format
877 msgid "Unknown job: %s"
878 msgstr ""
879
880-#: init/control.c:514 init/job_class.c:522 init/job_class.c:710
881-#: init/job_class.c:829 init/job_class.c:953
882+#: init/control.c:525 init/job_class.c:524 init/job_class.c:712
883+#: init/job_class.c:831 init/job_class.c:955
884 msgid "Env must be KEY=VALUE pairs"
885 msgstr ""
886
887-#: init/control.c:666
888+#: init/control.c:677
889 msgid "The log priority given was not recognised"
890 msgstr ""
891
892+#: init/errors.h:58
893+msgid "Illegal parameter"
894+msgstr ""
895+
896+#: init/errors.h:59
897+msgid "Unknown parameter"
898+msgstr ""
899+
900+#: init/errors.h:60 init/errors.h:71
901+msgid "Expected operator"
902+msgstr ""
903+
904+#: init/errors.h:61
905+msgid "Mismatched braces"
906+msgstr ""
907+
908+#: init/errors.h:62
909+msgid "Illegal interval, expected number of seconds"
910+msgstr ""
911+
912+#: init/errors.h:63
913+msgid "Illegal exit status, expected integer"
914+msgstr ""
915+
916+#: init/errors.h:64
917+msgid "Illegal signal status, expected integer"
918+msgstr ""
919+
920+#: init/errors.h:65
921+msgid "Illegal file creation mask, expected octal integer"
922+msgstr ""
923+
924+#: init/errors.h:66
925+msgid "Illegal nice value, expected -20 to 19"
926+msgstr ""
927+
928+#: init/errors.h:67
929+msgid "Illegal oom adjustment, expected -16 to 15 or 'never'"
930+msgstr ""
931+
932+#: init/errors.h:68
933+msgid "Illegal oom score adjustment, expected -999 to 1000 or 'never'"
934+msgstr ""
935+
936+#: init/errors.h:69
937+msgid "Illegal limit, expected 'unlimited' or integer"
938+msgstr ""
939+
940+#: init/errors.h:70
941+msgid "Expected event"
942+msgstr ""
943+
944+#: init/errors.h:72
945+msgid "Expected variable name before value"
946+msgstr ""
947+
948+#: init/errors.h:73
949+msgid "Mismatched parentheses"
950+msgstr ""
951+
952+#: init/errors.h:74
953+msgid "Name already taken"
954+msgstr ""
955+
956 #: init/event.c:273
957 #, c-format
958 msgid "Handling %s event"
959@@ -164,241 +229,244 @@
960 msgid "post-stop"
961 msgstr ""
962
963-#: init/job.c:1113 init/job_class.c:756
964+#: init/job.c:1113 init/job_class.c:758
965 #, c-format
966 msgid "Job is already running: %s"
967 msgstr ""
968
969-#: init/job.c:1177 init/job.c:1242 init/job_class.c:875 init/job_class.c:998
970+#: init/job.c:1177 init/job.c:1242 init/job_class.c:877 init/job_class.c:1000
971 #, c-format
972 msgid "Job has already been stopped: %s"
973 msgstr ""
974
975-#: init/job_class.c:559 init/job_class.c:604 init/job_class.c:867
976-#: init/job_class.c:990
977+#: init/job_class.c:561 init/job_class.c:606 init/job_class.c:869
978+#: init/job_class.c:992
979 #, c-format
980 msgid "Unknown instance: %s"
981 msgstr ""
982
983-#: init/job_process.c:279
984+#: init/job_process.c:276
985 #, c-format
986 msgid "Failed to spawn %s %s process: %s"
987 msgstr ""
988
989-#: init/job_process.c:285
990+#: init/job_process.c:282
991 msgid "Temporary process spawn error"
992 msgstr ""
993
994-#: init/job_process.c:292
995+#: init/job_process.c:289
996 #, c-format
997 msgid "%s %s process (%d)"
998 msgstr ""
999
1000-#: init/job_process.c:399
1001+#: init/job_process.c:402
1002 #, c-format
1003 msgid "Pausing %s (%d) [pre-exec] for debug"
1004 msgstr ""
1005
1006-#: init/job_process.c:453
1007+#: init/job_process.c:472
1008 #, c-format
1009 msgid "Failed to open system console: %s"
1010 msgstr ""
1011
1012-#: init/job_process.c:669
1013+#: init/job_process.c:696
1014+#, c-format
1015+msgid "unable to move script fd: %s"
1016+msgstr ""
1017+
1018+#: init/job_process.c:701
1019 #, c-format
1020 msgid "unable to open console: %s"
1021 msgstr ""
1022
1023-#: init/job_process.c:724
1024+#: init/job_process.c:756
1025 #, c-format
1026 msgid "unable to set \"%s\" resource limit: %s"
1027 msgstr ""
1028
1029-#: init/job_process.c:729
1030+#: init/job_process.c:761
1031 #, c-format
1032 msgid "unable to set priority: %s"
1033 msgstr ""
1034
1035-#: init/job_process.c:734
1036+#: init/job_process.c:766
1037 #, c-format
1038 msgid "unable to set oom adjustment: %s"
1039 msgstr ""
1040
1041-#: init/job_process.c:739
1042+#: init/job_process.c:771
1043 #, c-format
1044 msgid "unable to change root directory: %s"
1045 msgstr ""
1046
1047-#: init/job_process.c:744
1048+#: init/job_process.c:776
1049 #, c-format
1050 msgid "unable to change working directory: %s"
1051 msgstr ""
1052
1053-#: init/job_process.c:749
1054+#: init/job_process.c:781
1055 #, c-format
1056 msgid "unable to set trace: %s"
1057 msgstr ""
1058
1059-#: init/job_process.c:754
1060+#: init/job_process.c:786
1061 #, c-format
1062 msgid "unable to execute: %s"
1063 msgstr ""
1064
1065-#: init/job_process.c:785
1066-#, c-format
1067-msgid "Sending TERM signal to %s %s process (%d)"
1068-msgstr ""
1069-
1070-#: init/job_process.c:793
1071-#, c-format
1072-msgid "Failed to send TERM signal to %s %s process (%d): %s"
1073-msgstr ""
1074-
1075-#: init/job_process.c:833
1076-#, c-format
1077-msgid "Sending KILL signal to %s %s process (%d)"
1078-msgstr ""
1079-
1080-#: init/job_process.c:841
1081-#, c-format
1082-msgid "Failed to send KILL signal to %s %s process (%d): %s"
1083-msgstr ""
1084-
1085-#: init/job_process.c:901
1086+#: init/job_process.c:817 init/job_process.c:867
1087+#, c-format
1088+msgid "Sending %s signal to %s %s process (%d)"
1089+msgstr ""
1090+
1091+#: init/job_process.c:826 init/job_process.c:876
1092+#, c-format
1093+msgid "Failed to send %s signal to %s %s process (%d): %s"
1094+msgstr ""
1095+
1096+#: init/job_process.c:937
1097 #, c-format
1098 msgid "%s %s process (%d) terminated with status %d"
1099 msgstr ""
1100
1101-#: init/job_process.c:906
1102+#: init/job_process.c:942
1103 #, c-format
1104 msgid "%s %s process (%d) exited normally"
1105 msgstr ""
1106
1107-#: init/job_process.c:921
1108+#: init/job_process.c:957
1109 #, c-format
1110 msgid "%s %s process (%d) killed by %s signal"
1111 msgstr ""
1112
1113-#: init/job_process.c:925
1114+#: init/job_process.c:961
1115 #, c-format
1116 msgid "%s %s process (%d) killed by signal %d"
1117 msgstr ""
1118
1119-#: init/job_process.c:939
1120+#: init/job_process.c:975
1121 #, c-format
1122 msgid "%s %s process (%d) stopped by %s signal"
1123 msgstr ""
1124
1125-#: init/job_process.c:943
1126+#: init/job_process.c:979
1127 #, c-format
1128 msgid "%s %s process (%d) stopped by signal %d"
1129 msgstr ""
1130
1131-#: init/job_process.c:957
1132+#: init/job_process.c:993
1133 #, c-format
1134 msgid "%s %s process (%d) continued by %s signal"
1135 msgstr ""
1136
1137-#: init/job_process.c:961
1138+#: init/job_process.c:997
1139 #, c-format
1140 msgid "%s %s process (%d) continued by signal %d"
1141 msgstr ""
1142
1143-#: init/job_process.c:1096
1144+#: init/job_process.c:1132
1145 #, c-format
1146 msgid "%s respawning too fast, stopped"
1147 msgstr ""
1148
1149-#: init/job_process.c:1102
1150+#: init/job_process.c:1138
1151 #, c-format
1152 msgid "%s %s process ended, respawning"
1153 msgstr ""
1154
1155-#: init/job_process.c:1342
1156+#: init/job_process.c:1378
1157 #, c-format
1158 msgid "Failed to set ptrace options for %s %s process (%d): %s"
1159 msgstr ""
1160
1161-#: init/job_process.c:1355 init/job_process.c:1550
1162+#: init/job_process.c:1391 init/job_process.c:1586
1163 #, c-format
1164 msgid "Failed to continue traced %s %s process (%d): %s"
1165 msgstr ""
1166
1167-#: init/job_process.c:1395 init/job_process.c:1486 init/job_process.c:1541
1168+#: init/job_process.c:1431 init/job_process.c:1522 init/job_process.c:1577
1169 #, c-format
1170 msgid "Failed to detach traced %s %s process (%d): %s"
1171 msgstr ""
1172
1173-#: init/job_process.c:1435
1174+#: init/job_process.c:1471
1175 #, c-format
1176 msgid "Failed to deliver signal to traced %s %s process (%d): %s"
1177 msgstr ""
1178
1179-#: init/job_process.c:1470
1180+#: init/job_process.c:1506
1181 #, c-format
1182 msgid "Failed to obtain child process id for %s %s process (%d): %s"
1183 msgstr ""
1184
1185-#: init/job_process.c:1477
1186+#: init/job_process.c:1513
1187 #, c-format
1188 msgid "%s %s process (%d) became new process (%d)"
1189 msgstr ""
1190
1191-#: init/job_process.c:1536
1192+#: init/job_process.c:1572
1193 #, c-format
1194 msgid "%s %s process (%d) executable changed"
1195 msgstr ""
1196
1197-#: init/main.c:117
1198+#: init/main.c:109
1199+msgid "specify alternative directory to load configuration files from"
1200+msgstr ""
1201+
1202+#: init/main.c:114
1203+msgid "use D-Bus session bus rather than system bus (for testing)"
1204+msgstr ""
1205+
1206+#: init/main.c:134
1207 msgid "Process management daemon."
1208 msgstr ""
1209
1210-#: init/main.c:119
1211+#: init/main.c:136
1212 msgid ""
1213 "This daemon is normally executed by the kernel and given process id 1 to "
1214 "denote its special status. When executed by a user process, it will "
1215 "actually run /sbin/telinit."
1216 msgstr ""
1217
1218-#: init/main.c:130 util/reboot.c:167 util/shutdown.c:363 util/telinit.c:148
1219+#: init/main.c:152 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148
1220 msgid "Need to be root"
1221 msgstr ""
1222
1223-#: init/main.c:139
1224+#: init/main.c:161
1225 msgid "Not being executed as init"
1226 msgstr ""
1227
1228-#: init/main.c:187 init/main.c:456
1229+#: init/main.c:209 init/main.c:492
1230 msgid "Unable to set root directory"
1231 msgstr ""
1232
1233-#: init/main.c:198
1234+#: init/main.c:220
1235 msgid "Unable to mount /proc filesystem"
1236 msgstr ""
1237
1238-#: init/main.c:207
1239+#: init/main.c:229
1240 msgid "Unable to mount /sys filesystem"
1241 msgstr ""
1242
1243-#: init/main.c:292
1244+#: init/main.c:325
1245 msgid "Unable to listen for private connections"
1246 msgstr ""
1247
1248-#: init/main.c:473
1249+#: init/main.c:509
1250 #, c-format
1251 msgid "Caught %s, core dumped"
1252 msgstr ""
1253
1254-#: init/main.c:477
1255+#: init/main.c:513
1256 #, c-format
1257 msgid "Caught %s, unable to dump core"
1258 msgstr ""
1259
1260-#: init/main.c:563
1261+#: init/main.c:599
1262 msgid "Reconnecting to system bus"
1263 msgstr ""
1264
1265-#: init/main.c:569
1266+#: init/main.c:605
1267 msgid "Unable to connect to the system bus"
1268 msgstr ""
1269
1270@@ -589,59 +657,59 @@
1271 "Without arguments, this outputs the current log priority."
1272 msgstr ""
1273
1274-#: util/reboot.c:114
1275+#: util/reboot.c:113
1276 msgid "don't sync before reboot or halt"
1277 msgstr ""
1278
1279-#: util/reboot.c:116
1280+#: util/reboot.c:115
1281 msgid "force reboot or halt, don't call shutdown(8)"
1282 msgstr ""
1283
1284-#: util/reboot.c:118
1285+#: util/reboot.c:117
1286 msgid "switch off the power when called as halt"
1287 msgstr ""
1288
1289-#: util/reboot.c:120
1290+#: util/reboot.c:119
1291 msgid "don't actually reboot or halt, just write wtmp record"
1292 msgstr ""
1293
1294-#: util/reboot.c:145
1295+#: util/reboot.c:144
1296 msgid "Halt the system."
1297 msgstr ""
1298
1299-#: util/reboot.c:148
1300+#: util/reboot.c:147
1301 msgid "Power off the system."
1302 msgstr ""
1303
1304-#: util/reboot.c:151
1305+#: util/reboot.c:150
1306 msgid "Reboot the system."
1307 msgstr ""
1308
1309-#: util/reboot.c:155
1310+#: util/reboot.c:154
1311 msgid ""
1312 "This command is intended to instruct the kernel to reboot or halt the "
1313 "system; when run without the -f option, or when in a system runlevel other "
1314 "than 0 or 6, it will actually execute /sbin/shutdown.\n"
1315 msgstr ""
1316
1317-#: util/reboot.c:211
1318+#: util/reboot.c:210
1319 msgid "Calling shutdown"
1320 msgstr ""
1321
1322-#: util/reboot.c:214
1323+#: util/reboot.c:213
1324 #, c-format
1325 msgid "Unable to execute shutdown: %s"
1326 msgstr ""
1327
1328-#: util/reboot.c:235
1329+#: util/reboot.c:234
1330 msgid "Rebooting"
1331 msgstr ""
1332
1333-#: util/reboot.c:239
1334+#: util/reboot.c:238
1335 msgid "Halting"
1336 msgstr ""
1337
1338-#: util/reboot.c:243
1339+#: util/reboot.c:242
1340 msgid "Powering off"
1341 msgstr ""
1342
1343
1344=== modified file 'util/reboot.c'
1345--- util/reboot.c 2011-03-16 22:18:22 +0000
1346+++ util/reboot.c 2011-06-03 09:09:24 +0000
1347@@ -1,6 +1,5 @@
1348 /* upstart
1349 *
1350- * Copyright © 2011 Google Inc.
1351 * Copyright © 2010 Canonical Ltd.
1352 * Author: Scott James Remnant <scott@netsplit.com>.
1353 *

Subscribers

People subscribed via source and target branches