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

Proposed by James Hunt on 2014-07-08
Status: Merged
Merged at revision: 1644
Proposed branch: lp:~jamesodhunt/upstart/bug-1338968
Merge into: lp:upstart
Diff against target: 81 lines (+23/-15)
2 files modified
ChangeLog (+7/-0)
init/job_process.c (+16/-15)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/bug-1338968
Reviewer Review Type Date Requested Status
Upstart Reviewers 2014-07-08 Pending
Review via email: mp+225981@code.launchpad.net
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 2014-07-08 10:02:43 +0000
3+++ ChangeLog 2014-07-08 14:12:55 +0000
4@@ -3,6 +3,13 @@
5 * init/main.c: main():
6 - Only create inotify watches if not restarting or if performing a
7 stateless re-exec (LP: #1338637).
8+ * init/job_process.c:
9+ - job_process_data_serialise():
10+ - Unconditionally toggle CLOEXEC for job_process_fd (LP: #1338968).
11+ - Disregard valid flag when toggling CLOEXEC for script_fd since if
12+ the JobProcessData still exists, we need the fd to persist across
13+ the re-exec.
14+ - job_process_data_deserialise(): As above.
15
16 2014-07-07 James Hunt <james.hunt@ubuntu.com>
17
18
19=== modified file 'init/job_process.c'
20--- init/job_process.c 2014-07-03 08:59:30 +0000
21+++ init/job_process.c 2014-07-08 14:12:55 +0000
22@@ -2707,6 +2707,8 @@
23 if (! process_data)
24 return json;
25
26+ nih_assert (process_data->job_process_fd != -1);
27+
28 /* XXX: Note that Job is not serialised; it's not necessary
29 * since the JobProcessData itself is serialised within its Job
30 * and the job pointer can be reinstated on deserialisation.
31@@ -2720,18 +2722,17 @@
32 if (! state_set_json_string_var_from_obj (json, process_data, script))
33 goto error;
34
35- if (process_data->shell_fd != -1 && process_data->valid) {
36-
37- /* Clear the cloexec flag to ensure the descriptors
38- * remains open across the re-exec.
39- */
40+ /* Clear the cloexec flag to ensure the descriptors
41+ * remains open across the re-exec.
42+ */
43+ if (process_data->shell_fd != -1) {
44 if (state_modify_cloexec (process_data->shell_fd, FALSE) < 0)
45 goto error;
46-
47- if (state_modify_cloexec (process_data->job_process_fd, FALSE) < 0)
48- goto error;
49 }
50
51+ if (state_modify_cloexec (process_data->job_process_fd, FALSE) < 0)
52+ goto error;
53+
54 if (! state_set_json_int_var_from_obj (json, process_data, shell_fd))
55 goto error;
56
57@@ -2797,17 +2798,17 @@
58 if (! state_get_json_int_var_to_obj (json, process_data, valid))
59 goto error;
60
61- if (process_data->shell_fd != -1 && process_data->valid) {
62- /* Reset the cloexec flag to ensure the descriptors
63- * are not leaked to any child processes.
64- */
65+ /* Reset the cloexec flag to ensure the descriptors
66+ * are not leaked to any child processes.
67+ */
68+ if (process_data->shell_fd != -1) {
69 if (state_modify_cloexec (process_data->shell_fd, TRUE) < 0)
70 goto error;
71-
72- if (state_modify_cloexec (process_data->job_process_fd, TRUE) < 0)
73- goto error;
74 }
75
76+ if (state_modify_cloexec (process_data->job_process_fd, TRUE) < 0)
77+ goto error;
78+
79 return process_data;
80
81 error:

Subscribers

People subscribed via source and target branches