diff options
author | ho.namkoong <ho.namkoong@samsung.com> | 2013-05-10 17:06:41 +0900 |
---|---|---|
committer | yoonki.park <yoonki.park@samsung.com> | 2013-05-10 18:26:23 +0900 |
commit | 0fe5bcebe022bc2af541228be5e4b321dac252d4 (patch) | |
tree | 8e40cb22192215638489a3e7817663cdfadadecb | |
parent | da192b1fe01291030ffda93136701893e2dc3bdd (diff) | |
download | sdbd-0fe5bcebe022bc2af541228be5e4b321dac252d4.tar.gz sdbd-0fe5bcebe022bc2af541228be5e4b321dac252d4.tar.bz2 sdbd-0fe5bcebe022bc2af541228be5e4b321dac252d4.zip |
[Title] give platform gdbserver root privilege
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#] 8427
[Problem]
[Cause]
[Solution]
[TestCase]
Change-ID: I0aa18e6c3514f1dc6eabec0c3a02dd4caae6af3a
-rw-r--r-- | src/sdktools.c | 26 | ||||
-rw-r--r-- | src/sdktools.h | 3 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/sdktools.c b/src/sdktools.c index 3e7bb29..4c0f457 100644 --- a/src/sdktools.c +++ b/src/sdktools.c @@ -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, "_"); diff --git a/src/sdktools.h b/src/sdktools.h index 469cf54..881f122 100644 --- a/src/sdktools.h +++ b/src/sdktools.h @@ -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" |