environment not preserved when user: is specified in a job

Bug #897889 reported by Daniel Manrique
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox
Fix Released
High
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):

plugin:shell
command: echo $FOO

but this job will not echo anything:
plugin:shell
user:root
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
bar
$ FOO=bar sudo /tmp/echo_env.sh

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

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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.