Merge lp:~stgraber/upstart/upstart-inherit-env-no-override into lp:upstart

Proposed by Stéphane Graber
Status: Merged
Merged at revision: 1432
Proposed branch: lp:~stgraber/upstart/upstart-inherit-env-no-override
Merge into: lp:upstart
Diff against target: 23 lines (+4/-5)
1 file modified
init/job_process.c (+4/-5)
To merge this branch: bzr merge lp:~stgraber/upstart/upstart-inherit-env-no-override
Reviewer Review Type Date Requested Status
James Hunt Approve
Review via email: mp+148362@code.launchpad.net

Description of the change

When preparing the test PPA for user session, I noticed that I had a problem
with the new environment inheriting feature.

In my test case, I had DBUS_SESSION_BUS_ADDRESS set in the parent environment,
so upstart with --inherit-env stored that value.
I then used initctl set-env to set it to another value, but this would never be
propagated to the new jobs.

The reason for this is because the inherited environment was appended after any
other environment variables and so would effectively override the "right"
variable as was defined through initctl.

This change simply changes the logic to always apply the inherited environment
first, then have any other environment variables override it.

NOTE: This change is already part of my current PPA packages.

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

LGTM. Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'init/job_process.c'
2--- init/job_process.c 2013-02-11 08:50:24 +0000
3+++ init/job_process.c 2013-02-14 02:58:20 +0000
4@@ -271,15 +271,14 @@
5 * so that initctl can have clever behaviour when called within them.
6 */
7 envc = 0;
8- if (job->env) {
9- env = NIH_MUST (nih_str_array_copy (NULL, &envc, job->env));
10- } else {
11- env = NIH_MUST (nih_str_array_new (NULL));
12- }
13+ env = NIH_MUST (nih_str_array_new (NULL));
14
15 if (user_mode && inherit_env)
16 NIH_MUST(environ_append (&env, NULL, &envc, TRUE, environ));
17
18+ if (job->env)
19+ NIH_MUST(environ_append (&env, NULL, &envc, TRUE, job->env));
20+
21 if (job->stop_env
22 && ((process == PROCESS_PRE_STOP)
23 || (process == PROCESS_POST_STOP)))

Subscribers

People subscribed via source and target branches