tlm-client: make tlm-client utility running as normal user privilege. 04/38804/1 sandbox/scwoo/devel tizen_3.0.2015.q2_common tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/common/20150513.083747 accepted/tizen/mobile/20150513.111829 accepted/tizen/tv/20150513.105611 accepted/tizen/wearable/20150513.110513 submit/tizen/20150513.044607 submit/tizen_common/20151015.190624 submit/tizen_common/20151019.135620 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release
authorSangjung Woo <sangjung.woo@samsung.com>
Wed, 29 Apr 2015 01:46:58 +0000 (10:46 +0900)
committerSangjung Woo <sangjung.woo@samsung.com>
Wed, 29 Apr 2015 01:46:58 +0000 (10:46 +0900)
This patch makes to run tlm-client utility as normal user instead of
ROOT privilege. That functionality is necessary to test for switching
users as application privilege. What if launching tlm daemon itself,
ROOT privilege is still necessary.

Change-Id: I705a7a92c090bf53106cd0d1ef1762d633884f50
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
src/utils/tlm-client.c

index 3380d58..8c3a883 100644 (file)
@@ -84,6 +84,11 @@ _setup_daemon ()
 
     const gchar *bin_path = TLM_BIN_DIR;
 
+    if (geteuid() != 0) {
+        WARN("ROOT privilege users can launch tlm daemon");
+        return FALSE;
+    }
+
 #ifdef ENABLE_DEBUG
     const gchar *env_val = g_getenv("TLM_BIN_DIR");
     if (env_val)
@@ -392,15 +397,11 @@ int main (int argc, char *argv[])
         return EXIT_FAILURE;
     }
 
-    if (geteuid() != 0) {
-        WARN("test-client can only be run with ROOT privileges");
+    if (run_tlm_daemon && !_setup_daemon()) {
         _free_tlm_user (user);
         return EXIT_FAILURE;
     }
 
-    if (run_tlm_daemon)
-        _setup_daemon ();
-
     if (is_user_login_op) {
         _handle_user_login (user);
     } else if (is_user_logout_op) {