environment not preserved when user: is specified in a job

Bug #897889 reported by Daniel Manrique
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Daniel Manrique

Bug Description

If the user: parameter is specified in a job description, environment variables are not preserved for this job.

For instance, if a FOO environment variable is defined, this job will echo foo's value (the job is incomplete, it's just for illustrative purposes):

command: echo $FOO

but this job will not echo anything:
command: echo $FOO

This happens because the backend is spawned using sudo, which in ubuntu has "Defaults env_reset" to sanitize the environment while spawning a process. To test this, create /tmp/echo_env.sh with mode 755:

echo $FOO

then compare these invocations:

$ FOO=bar /tmp/echo_env.sh
$ FOO=bar sudo /tmp/echo_env.sh

$ FOO=bar sudo -E /tmp/echo_env.sh

the -E parameter to sudo means "preserve environment". It's a possible workaround for this problem but sudo's documentation should be reviewed to ensure this will still work for most use cases.

Related branches

Daniel Manrique (roadmr)
Changed in checkbox:
status: New → Triaged
importance: Undecided → High
milestone: none → 0.13.1
Changed in checkbox:
status: Triaged → Fix Committed
assignee: nobody → Daniel Manrique (roadmr)
Marc Tardif (cr3)
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers