diff options
author | Pierre Pfister <ppfister@cisco.com> | 2016-11-03 13:14:29 +0000 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2016-11-04 11:22:11 +0000 |
commit | f524f0add51e603118184fcd42f5b8eeafa11462 (patch) | |
tree | 13130270a80ebd6ebb3984f9c68221406e88ac14 /vpp-api-test/scripts | |
parent | 05ab8cbdd410f32766d184ad87e5f66a2d2426fe (diff) |
vppctl: Do not use sudo if already root
When using sudo, environment variable such as the PATH
are overwritten.
This patch just checks if user is already root and does
not use sudo in such situation.
This allows using approaches like:
sudo env PATH=path/to/vpp-binary/:$PATH vppctl
Not really important in production setups, but this is handy
for testing.
Change-Id: I079c104d026ae7d378468380b012279a6e5d765d
Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'vpp-api-test/scripts')
-rwxr-xr-x | vpp-api-test/scripts/vppctl | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/vpp-api-test/scripts/vppctl b/vpp-api-test/scripts/vppctl index 160bdf7ce5e..6dfa3b9b8a5 100755 --- a/vpp-api-test/scripts/vppctl +++ b/vpp-api-test/scripts/vppctl @@ -42,8 +42,12 @@ class Vppctl(Cmd): input_command = input_prefix + line line_remove = '^load_one_plugin:' s = '\n' + command = ['vpp_api_test'] - vpp_process = subprocess.Popen(['sudo', 'vpp_api_test'], + if os.geteuid() != 0: + command = ['sudo', 'vpp_api_test'] + + vpp_process = subprocess.Popen(command, stderr=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE) |