Merge authors:
  James Hunt (jamesodhunt)
Related merge proposals:
  https://code.launchpad.net/~jamesodhunt/upstart/bug-1338968/+merge/225981
  proposed by: James Hunt (jamesodhunt)
------------------------------------------------------------
revno: 1644 [merge]
fixes bug: https://launchpad.net/bugs/1338968
committer: Dimitri John Ledkov <dimitri.led...@canonical.com>
branch nick: trunk
timestamp: Wed 2014-07-09 13:04:25 +0100
message:
  Merge lp:~jamesodhunt/upstart/bug-1338968
modified:
  ChangeLog
  init/job_process.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'ChangeLog'
--- ChangeLog	2014-07-08 10:02:43 +0000
+++ ChangeLog	2014-07-08 14:11:53 +0000
@@ -3,6 +3,13 @@
 	* init/main.c: main():
 	  - Only create inotify watches if not restarting or if performing a
 	    stateless re-exec (LP: #1338637).
+	* init/job_process.c:
+	  - job_process_data_serialise():
+	    - Unconditionally toggle CLOEXEC for job_process_fd (LP: #1338968).
+	    - Disregard valid flag when toggling CLOEXEC for script_fd since if
+	      the JobProcessData still exists, we need the fd to persist across
+	      the re-exec.
+	  - job_process_data_deserialise(): As above.
 
 2014-07-07  James Hunt  <james.h...@ubuntu.com>
 

=== modified file 'init/job_process.c'
--- init/job_process.c	2014-07-03 08:59:30 +0000
+++ init/job_process.c	2014-07-08 14:11:53 +0000
@@ -2707,6 +2707,8 @@
 	if (! process_data)
 		return json;
 
+	nih_assert (process_data->job_process_fd != -1);
+
 	/* XXX: Note that Job is not serialised; it's not necessary
 	 * since the JobProcessData itself is serialised within its Job
 	 * and the job pointer can be reinstated on deserialisation.
@@ -2720,18 +2722,17 @@
 	if (! state_set_json_string_var_from_obj (json, process_data, script))
 		goto error;
 
-	if (process_data->shell_fd != -1 && process_data->valid) {
-
-		/* Clear the cloexec flag to ensure the descriptors
-		 * remains open across the re-exec.
-		 */
+	/* Clear the cloexec flag to ensure the descriptors
+	 * remains open across the re-exec.
+	 */
+	if (process_data->shell_fd != -1) {
 		if (state_modify_cloexec (process_data->shell_fd, FALSE) < 0)
 			goto error;
-
-		if (state_modify_cloexec (process_data->job_process_fd, FALSE) < 0)
-			goto error;
 	}
 
+	if (state_modify_cloexec (process_data->job_process_fd, FALSE) < 0)
+		goto error;
+
 	if (! state_set_json_int_var_from_obj (json, process_data, shell_fd))
 		goto error;
 
@@ -2797,17 +2798,17 @@
 	if (! state_get_json_int_var_to_obj (json, process_data, valid))
 		goto error;
 
-	if (process_data->shell_fd != -1 && process_data->valid) {
-		/* Reset the cloexec flag to ensure the descriptors
-		 * are not leaked to any child processes.
-		 */
+	/* Reset the cloexec flag to ensure the descriptors
+	 * are not leaked to any child processes.
+	 */
+	if (process_data->shell_fd != -1) {
 		if (state_modify_cloexec (process_data->shell_fd, TRUE) < 0)
 			goto error;
-
-		if (state_modify_cloexec (process_data->job_process_fd, TRUE) < 0)
-			goto error;
 	}
 
+	if (state_modify_cloexec (process_data->job_process_fd, TRUE) < 0)
+		goto error;
+
 	return process_data;
 
 error:

-- 
upstart-devel mailing list
upstart-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to