Get user id without forking a shell. 07/12107/1
authorPeter Barabas <peter.barabas@ericsson.com>
Thu, 10 Mar 2016 12:14:53 +0000 (13:14 +0100)
committerJonas Bjurel <jonas.bjurel@ericsson.com>
Sat, 9 Apr 2016 17:58:14 +0000 (17:58 +0000)
Change-Id: I6789b81186b7ede124a838a5b6668ba8326e0c0b
Signed-off-by: Peter Barabas <peter.barabas@ericsson.com>
(cherry picked from commit befc84a9d28663a45510c71119980e1cf5b6eeca)

deploy/common.py

index cc418b5..787a21a 100644 (file)
@@ -133,8 +133,8 @@ def commafy(comma_separated_list):
 
 
 def check_if_root():
-    r = exec_cmd('whoami')
-    if r != 'root':
+    uid = os.getuid()
+    if uid != 0:
         err('You need be root to run this application')