James Hunt has proposed merging lp:~jamesodhunt/upstart/init--inherit-env into 
lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~jamesodhunt/upstart/init--inherit-env/+merge/147421

Add ability for jobs supervised by a Session Init to inherit the init 
enviromnent to simplify Session handling.
-- 
https://code.launchpad.net/~jamesodhunt/upstart/init--inherit-env/+merge/147421
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~jamesodhunt/upstart/init--inherit-env into lp:upstart.
=== modified file 'ChangeLog'
--- ChangeLog	2013-02-02 16:09:52 +0000
+++ ChangeLog	2013-02-08 16:59:23 +0000
@@ -1,3 +1,10 @@
+2013-02-08  James Hunt  <[email protected]>
+
+	* init/job_process.c: job_process_run(): Copy parent environment if
+	  inherit_env in operation for a Session Init.
+	* init/main.c: Added 'inherit-env' command-line option.
+	* init/man/init.8: Documented --inherit-env.
+
 2013-02-02  James Hunt  <[email protected]>
 
 	* util/initctl.c: Remove ability to specify explicitly job and/or job

=== modified file 'init/job_process.c'
--- init/job_process.c	2013-01-25 09:08:09 +0000
+++ init/job_process.c	2013-02-08 16:59:23 +0000
@@ -128,7 +128,8 @@
 static void job_process_trace_fork      (Job *job, ProcessType process);
 static void job_process_trace_exec      (Job *job, ProcessType process);
 
-extern int          user_mode;
+extern int           user_mode;
+extern int           inherit_env;
 extern char         *control_server_address;
 
 /**
@@ -269,6 +270,9 @@
 		env = NIH_MUST (nih_str_array_new (NULL));
 	}
 
+	if (user_mode && inherit_env)
+		NIH_MUST(environ_append (&env, NULL, &envc, TRUE, environ));
+
 	if (job->stop_env
 	    && ((process == PROCESS_PRE_STOP)
 		|| (process == PROCESS_POST_STOP)))

=== modified file 'init/main.c'
--- init/main.c	2013-01-31 17:23:55 +0000
+++ init/main.c	2013-02-08 16:59:23 +0000
@@ -120,6 +120,13 @@
  **/
 static int disable_startup_event = FALSE;
 
+/**
+ * inherit_env:
+ *
+ * If TRUE, copy inits environment to that provided to jobs.
+ **/
+int inherit_env = FALSE;
+
 extern int          user_mode;
 extern int          disable_sessions;
 extern int          disable_job_logging;
@@ -140,6 +147,9 @@
 	{ 0, "default-console", N_("default value for console stanza"),
 		NULL, "VALUE", NULL, console_type_setter },
 
+	{ 0, "inherit-env", N_("jobs will inherit environment of init"),
+		NULL, NULL, &inherit_env ,NULL },
+
 	{ 0, "logdir", N_("specify alternative directory to store job output logs in"),
 		NULL, "DIR", &log_dir, NULL },
 

=== modified file 'init/man/init.8'
--- init/man/init.8	2013-01-18 15:26:17 +0000
+++ init/man/init.8	2013-02-08 16:59:23 +0000
@@ -81,6 +81,11 @@
 .BR console "."
 .\"
 .TP
+.B \-\-inherit\-env
+Make jobs inherit the initial environment. Impotent when running as
+process id 1.
+.\"
+.TP
 .B \-\-logdir \fIdirectory\fP
 Write job output log files to a directory other than
 \fI/var/log/upstart\fP (system mode) or \fI$XDG_CACHE_HOME/upstart\fP

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to