From: Kim Gunsoo Date: Fri, 12 Feb 2016 06:22:55 +0000 (+0900) Subject: Modify the method for determining whether put the debug option(-G). X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bddb6eb2f9ddf0dcb727f6919775bde95d4b500f;p=sdk%2Ftools%2Fsdb.git Modify the method for determining whether put the debug option(-G). - Only put the debug option(-G) when SDBD is not performing as root. Change-Id: I5ee76bf758f43f81e3d6ba68a6eb442e2f3fb33c Signed-off-by: Kim Gunsoo --- diff --git a/src/command_function.c b/src/command_function.c index 6fb7c45..d0697cf 100644 --- a/src/command_function.c +++ b/src/command_function.c @@ -635,29 +635,24 @@ int forkserver(int argc, char** argv) { } static int is_support_debug_option(void){ - int is_support = 0; - char buf[512] = {}; - - const char* SHELL_GET_PROFILE_VER_CMD ="shell:/usr/bin/profile_command getversion"; - int fd = sdb_connect(SHELL_GET_PROFILE_VER_CMD); + char full_cmd[16] = {0,}; + char cap_buffer[CAPBUF_SIZE] = {0,}; + uint16_t len = 0; + int ret = -1; - if(fd < 0) { - // default : not support -G option. - return 0; - } - if (read_line(fd, buf, sizeof(buf)) > 0) { - int major = 0; - int minor = 0; - if (sscanf(buf, "%d.%d", &major, &minor) == 2) { - // major version number at least 4 - if (major >= 4) { - is_support = 1; - } + snprintf(full_cmd, sizeof(full_cmd), "capability:"); + int fd = sdb_connect(full_cmd); + if (fd >= 0) { + readx(fd, &len, sizeof(uint16_t)); + if (len > CAPBUF_SIZE-1) { + len = CAPBUF_SIZE-1; } - } + readx(fd, cap_buffer, len); + sdb_close(fd); - sdb_close(fd); - return is_support; + ret = match_capability_key_value(cap_buffer, "sdbd_rootperm", "disabled"); + } + return ret; } static int is_support_whitespace_pkgname(void){ @@ -725,7 +720,7 @@ int install(int argc, char **argv) { const char* SHELL_INSTALL_CMD = NULL; char full_cmd[PATH_MAX]; - if (is_support_debug_option()) { + if (is_support_debug_option() == 1) { SHELL_INSTALL_CMD ="shell:/usr/bin/pkgcmd -i -t %s -p \"%s\" -q -G"; } else { SHELL_INSTALL_CMD ="shell:/usr/bin/pkgcmd -i -t %s -p \"%s\" -q"; diff --git a/src/commandline.c b/src/commandline.c index abe6ee7..2df8c34 100755 --- a/src/commandline.c +++ b/src/commandline.c @@ -413,7 +413,7 @@ static void sync_winsz() { } } -static int match_capability_key_value(char* cap, char* key, char* value) { +int match_capability_key_value(char* cap, char* key, char* value) { char *p_str = NULL; int offset = 0; char *k = NULL; diff --git a/src/commandline.h b/src/commandline.h index 6f62268..0bcfeb0 100644 --- a/src/commandline.h +++ b/src/commandline.h @@ -54,5 +54,6 @@ int interactive_shell(); int get_server_port(); int get_platform_version(); int __sdb_command(const char* cmd); +int match_capability_key_value(char* cap, char* key, char* value); #endif /* COMMANDLINE_H_ */