From: Pierre Pfister Date: Thu, 3 Nov 2016 13:14:29 +0000 (+0000) Subject: vppctl: Do not use sudo if already root X-Git-Tag: v17.01-rc1~285 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=f524f0add51e603118184fcd42f5b8eeafa11462;p=vpp.git 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 --- 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)