Merge lp:~elopio/snappy/sudo_path into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Merge reported by: Leo Arias
Merged at revision: not available
Proposed branch: lp:~elopio/snappy/sudo_path
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 23 lines (+11/-0)
1 file modified
_integration-tests/reboot-wrapper (+11/-0)
To merge this branch: bzr merge lp:~elopio/snappy/sudo_path
Reviewer Review Type Date Requested Status
Sergio Schvezov Needs Information
Federico Gimenez continuous-integration Pending
Review via email: mp+269252@code.launchpad.net

Commit message

Added a sudo wrapper that preserves the user path.

To post a comment you must log in.
lp:~elopio/snappy/sudo_path updated
642. By Leo Arias

Make the file writable.

643. By Leo Arias

Fixed the path.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Have you tried something like
Maybe expand PATH using os.ExpandEnv
cmd := exec.Command("/bin/sh", "-c", "sudo env PATH=$PATH ...")

review: Needs Information
Revision history for this message
Leo Arias (elopio) wrote :

That works. The problem with that approach is that we would have to do the same for every sudo call.
We could write a helper called ExecSudoCommand, if you prefer that.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Oh, I'll leave it to your preference, we used to have run_with and run in phablet-test-run, made it easy to get it at a first glance.

I you prefer this, you have my ack to self approve though ;-)

Revision history for this message
Leo Arias (elopio) wrote :

I hate both ways. mvo found this, so maybe he'll have a preference.

Revision history for this message
Leo Arias (elopio) wrote :
Revision history for this message
Leo Arias (elopio) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '_integration-tests/reboot-wrapper'
--- _integration-tests/reboot-wrapper 2015-07-08 08:41:35 +0000
+++ _integration-tests/reboot-wrapper 2015-08-26 18:43:10 +0000
@@ -21,8 +21,19 @@
21TEST=$121TEST=$1
22NEEDS_REBOOT=/tmp/needs-reboot22NEEDS_REBOOT=/tmp/needs-reboot
2323
24# We export the tests bin path so the snappy binary that might be compiled from
25# the branch is found.
24export PATH=$(pwd)/_integration-tests/bin:$PATH26export PATH=$(pwd)/_integration-tests/bin:$PATH
2527
28# XXX sudo does not preserve the user PATH. A nicer way to solve this would be
29# to use an alias, but go exec.Command sets the full binary path.
30cat > $(pwd)/_integration-tests/bin/sudo <<EOF
31#!/bin/bash
32/usr/bin/sudo env PATH=$PATH "\$@"
33EOF
34
35chmod +x $(pwd)/_integration-tests/bin/sudo
36
26# shift to remove the test binary name (first argument) and be able to pass the rest37# shift to remove the test binary name (first argument) and be able to pass the rest
27# of them to it38# of them to it
28shift39shift

Subscribers

People subscribed via source and target branches