[Title] give platform gdbserver root privilege submit/tizen_2.1/20130510.092923
authorho.namkoong <ho.namkoong@samsung.com>
Fri, 10 May 2013 08:06:41 +0000 (17:06 +0900)
committeryoonki.park <yoonki.park@samsung.com>
Fri, 10 May 2013 09:26:23 +0000 (18:26 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#] 8427
[Problem]
[Cause]
[Solution]
[TestCase]

Change-ID: I0aa18e6c3514f1dc6eabec0c3a02dd4caae6af3a

src/sdktools.c
src/sdktools.h

index 3e7bb29..4c0f457 100644 (file)
@@ -141,8 +141,10 @@ int verify_root_commands(const char *arg1) {
 int verify_app_path(const char* path) {
     char buf[PATH_MAX];
 
-    snprintf(buf, sizeof buf, "^((%s)|(%s))/[a-zA-Z0-9]{%d}/bin/[a-zA-Z0-9_\\-]{1,}(\\.exe)?$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2, APPID_MAX_LENGTH);
-    return regcmp(buf, path);
+    snprintf(buf, sizeof buf, "^((%s)|(%s))/[a-zA-Z0-9]{%d}/bin/[a-zA-Z0-9_\\-]{1,}(\\.exe)?$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2, 10);
+    int reg_cmp = regcmp(buf, path);
+
+    return reg_cmp;
 }
 
 int regcmp(const char* pattern, const char* str) {
@@ -216,7 +218,7 @@ int exec_app_standalone(const char* path) {
             // TODO: check evn setting
         }
         // TODO: i length check
-        if (!strcmp(tokens[i], GDBSERVER_PATH)) { //gdbserver :11 --attach 2332 (cnt=4,)
+        if (!strcmp(tokens[i], GDBSERVER_PATH) || !strcmp(tokens[i], GDBSERVER_PLATFORM_PATH)) { //gdbserver :11 --attach 2332 (cnt=4,)
             char *gdb_attach_arg_pattern = "^:[1-9][0-9]{2,5} \\-\\-attach [1-9][0-9]{2,5}$";
             int argcnt = cnt-i-1;
             if (argcnt == 3 && !strcmp("--attach", tokens[i+2])) {
@@ -241,10 +243,12 @@ int exec_app_standalone(const char* path) {
                     }
                 }
             }
-            if (argcnt >= 2 && verify_app_path(tokens[i+2])) {
-                D("parsing.... debug run as mode\n");
-                if (set_smack_rules_for_gdbserver(tokens[i+2], 0)) {
-                    ret = 1;
+            else if (argcnt >= 2) {
+                if(should_drop_privileges() == 0 || verify_app_path(tokens[i+2])) {
+                    D("parsing.... debug run as mode\n");
+                    if (set_smack_rules_for_gdbserver(tokens[i+2], 0)) {
+                        ret = 1;
+                    }
                 }
             }
             D("finished debug launch mode\n");
@@ -287,19 +291,17 @@ char* clone_gdbserver_label_from_app(const char* app_path) {
     char appid[APPID_MAX_LENGTH+1];
     char *buffer = NULL;
 
+#if 0
     if (!verify_app_path(app_path)) {
         D("not be able to access %s\n", app_path);
         return NULL;
     }
+#endif
 
     int rc = smack_lgetlabel(app_path, &buffer, SMACK_LABEL_ACCESS);
 
     if (rc == 0 && buffer != NULL) {
-        if (strlen(buffer) == APPID_MAX_LENGTH) {
-            strcpy(appid, buffer);
-        } else {
-            strcpy(appid, "_");
-        }
+        strcpy(appid, buffer);
         free(buffer);
     } else {
         strcpy(appid, "_");
index 469cf54..881f122 100644 (file)
@@ -26,10 +26,11 @@ struct arg_permit_rule
 #define APP_INSTALL_PATH_PREFIX1                "/opt/apps"
 #define APP_INSTALL_PATH_PREFIX2                "/opt/usr/apps"
 #define GDBSERVER_PATH                          "/home/developer/sdk_tools/gdbserver/gdbserver"
+#define GDBSERVER_PLATFORM_PATH        "/home/developer/sdk_tools/gdbserver-platform/gdbserver"
 #define SMACK_LEBEL_SUBJECT_PATH                "/proc/self/attr/current"
 #define APP_GROUPS_MAX                          100
 #define APP_GROUP_LIST                          "/usr/share/privilege-control/app_group_list"
-#define APPID_MAX_LENGTH                        10
+#define APPID_MAX_LENGTH                        50
 #define SDBD_LABEL_NAME                          "sdbd"
 #define SDK_HOME_LABEL_NAME                      "sdbd::home"