[Title] give platform gdbserver root privilege submit/tizen_2.1/20130419.134235
authorho.namkoong <ho.namkoong@samsung.com>
Wed, 17 Apr 2013 12:15:58 +0000 (21:15 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Fri, 19 Apr 2013 13:34:43 +0000 (22:34 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#] 8427
[Problem]
[Cause]
[Solution]
[TestCase]

packaging/sdbd.spec
src/sdktools.c
src/sdktools.h

index 2c65498..94ee1bc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       sdbd
 Summary:    SDB daemon
-Version:    2.1.1
+Version:    2.1.2
 Release:    0
 Group:      TO_BE/FILLED_IN
 License:    TO BE FILLED IN
@@ -32,6 +32,8 @@ rm -rf %{buildroot}
 %endif
 
 %changelog
+* Wed Apr 04 2013 Ho Namkoong <ho.namkoong@samsung.com>
+ - supports platform gdbserver
 * Mon Dec 02 2012 Yoonki Park <yoonki.park@samsung.com>
  - supports cs report service using inotify
 * Mon Dec 02 2012 Yoonki Park <yoonki.park@samsung.com>
index b04c1fd..b5f71b8 100644 (file)
@@ -139,10 +139,12 @@ 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, 10);
+    int reg_cmp = 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, APPID_MAX_LENGTH);
-    return 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");
@@ -284,19 +288,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 34f2ecb..5c58298 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
 
 int verify_commands(const char *arg1);
 int verify_root_commands(const char *arg1);