Modify the method for determining whether put the debug option(-G).
authorKim Gunsoo <gunsoo83.kim@samsung.com>
Fri, 12 Feb 2016 06:22:55 +0000 (15:22 +0900)
committerKim Gunsoo <gunsoo83.kim@samsung.com>
Fri, 12 Feb 2016 07:52:27 +0000 (16:52 +0900)
- Only put the debug option(-G) when SDBD is not performing as root.

Change-Id: I5ee76bf758f43f81e3d6ba68a6eb442e2f3fb33c
Signed-off-by: Kim Gunsoo <gunsoo83.kim@samsung.com>
src/command_function.c
src/commandline.c
src/commandline.h

index 6fb7c4565d7524f2c9643072a066af90f50ba6ce..d0697cf3bad029ecb31426f32e7d95d4afd0d3d1 100644 (file)
@@ -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";
index abe6ee7dea5018dc51feb9b1898aea30db01f99f..2df8c34d02d0e3e61ebf76b4fa6adcb14a37d2e6 100755 (executable)
@@ -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;
index 6f62268956f0b99309d133202771f057c8033299..0bcfeb076263f14307d2bfdee2560e193ff97d7f 100644 (file)
@@ -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_ */