From f524f0add51e603118184fcd42f5b8eeafa11462 Mon Sep 17 00:00:00 2001 From: Pierre Pfister Date: Thu, 3 Nov 2016 13:14:29 +0000 Subject: [PATCH] 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 --- vpp-api-test/scripts/vppctl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- 2.16.6