Merge lp:~jamesodhunt/upstart/bug-1197225 into lp:upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1499
Proposed branch: lp:~jamesodhunt/upstart/bug-1197225
Merge into: lp:upstart
Diff against target: 95 lines (+35/-20)
4 files modified
ChangeLog (+9/-0)
extra/upstart-dbus-bridge.c (+2/-1)
extra/upstart-event-bridge.c (+2/-1)
extra/upstart-file-bridge.c (+22/-18)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/bug-1197225
Reviewer Review Type Date Requested Status
Upstart Reviewers Pending
Review via email: mp+172762@code.launchpad.net

Description of the change

Fix for bug 1197225, which also affected 2 of the other bridges.

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 2013-06-28 13:21:34 +0000
3+++ ChangeLog 2013-07-03 08:29:30 +0000
4@@ -1,3 +1,12 @@
5+2013-07-03 James Hunt <james.hunt@ubuntu.com>
6+
7+ * extra/upstart-dbus-bridge.c: main(): Check nih_str_split() return.
8+ * extra/upstart-event-bridge.c: main(): Check nih_str_split() return.
9+ * extra/upstart-file-bridge.c: main():
10+ - Check nih_str_split() return.
11+ - Only attempt to extract PID from UPSTART_SESSION
12+ in user mode (LP: #1197225).
13+
14 2013-06-28 James Hunt <james.hunt@ubuntu.com>
15
16 * NEWS: Release 1.9
17
18=== modified file 'extra/upstart-dbus-bridge.c'
19--- extra/upstart-dbus-bridge.c 2013-06-26 09:15:41 +0000
20+++ extra/upstart-dbus-bridge.c 2013-07-03 08:29:30 +0000
21@@ -297,7 +297,8 @@
22 if (user_mode) {
23 /* Extract PID from UPSTART_SESSION */
24 user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
25- for (int i = 0; user_session_path[i] != NULL; i++)
26+
27+ for (int i = 0; user_session_path && user_session_path[i]; i++)
28 path_element = user_session_path[i];
29
30 if (! path_element) {
31
32=== modified file 'extra/upstart-event-bridge.c'
33--- extra/upstart-event-bridge.c 2013-01-23 19:18:43 +0000
34+++ extra/upstart-event-bridge.c 2013-07-03 08:29:30 +0000
35@@ -209,7 +209,8 @@
36
37 /* Extract PID from UPSTART_SESSION */
38 user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
39- for (int i = 0; user_session_path[i] != NULL; i++)
40+
41+ for (int i = 0; user_session_path && user_session_path[i]; i++)
42 path_element = user_session_path[i];
43
44 if (! path_element) {
45
46=== modified file 'extra/upstart-file-bridge.c'
47--- extra/upstart-file-bridge.c 2013-03-28 16:55:36 +0000
48+++ extra/upstart-file-bridge.c 2013-07-03 08:29:30 +0000
49@@ -547,24 +547,28 @@
50 * the Upstart instance (last part of the DBus path) in the filename.
51 */
52
53- /* Extract PID from UPSTART_SESSION */
54- user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
55- for (int i = 0; user_session_path[i] != NULL; i++)
56- path_element = user_session_path[i];
57-
58- if (! path_element) {
59- nih_fatal (_("Invalid value for UPSTART_SESSION"));
60- exit (1);
61- }
62-
63- pidfile_path = getenv ("XDG_RUNTIME_DIR");
64- if (! pidfile_path)
65- pidfile_path = getenv ("HOME");
66-
67- if (pidfile_path) {
68- NIH_MUST (nih_strcat_sprintf (&pidfile, NULL, "%s/upstart-file-bridge.%s.pid",
69- pidfile_path, path_element));
70- nih_main_set_pidfile (pidfile);
71+ if (user) {
72+
73+ /* Extract PID from UPSTART_SESSION */
74+ user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
75+
76+ for (int i = 0; user_session_path && user_session_path[i]; i++)
77+ path_element = user_session_path[i];
78+
79+ if (! path_element) {
80+ nih_fatal (_("Invalid value for UPSTART_SESSION"));
81+ exit (1);
82+ }
83+
84+ pidfile_path = getenv ("XDG_RUNTIME_DIR");
85+ if (! pidfile_path)
86+ pidfile_path = getenv ("HOME");
87+
88+ if (pidfile_path) {
89+ NIH_MUST (nih_strcat_sprintf (&pidfile, NULL, "%s/upstart-file-bridge.%s.pid",
90+ pidfile_path, path_element));
91+ nih_main_set_pidfile (pidfile);
92+ }
93 }
94
95 if (nih_main_daemonise () < 0) {

Subscribers

People subscribed via source and target branches