Revert "Modify the SMACK label for SDB shell." 84/103984/1
authorJaewon Lim <jaewon81.lim@samsung.com>
Mon, 12 Dec 2016 04:32:40 +0000 (20:32 -0800)
committerJaewon Lim <jaewon81.lim@samsung.com>
Mon, 12 Dec 2016 04:32:40 +0000 (20:32 -0800)
This reverts commit 046f23e7ea9c15c72de74fc46530c3319bc7622d.

Change-Id: I196d5d4d975e9aec1efd28a39c3f1aaf2a9da6f9

packaging/sdbd.spec
src/default_plugin_appcmd.c
src/sdb.c
src/sdb.h
src/sdktools.h
src/services.c

index 15eb808..bc9408f 100644 (file)
@@ -109,10 +109,6 @@ if ! getent passwd "${TZ_SDK_USER_NAME}" > /dev/null; then
   done
 fi
 
-cp -f /bin/sh /bin/sh-user
-chsmack -a "_" /bin/sh-user
-chsmack -e "User::Shell" /bin/sh-user
-
 %files
 %manifest sdbd.manifest
 %license LICENSE
index 83cecca..4bc158e 100644 (file)
@@ -38,7 +38,6 @@
 
 #include <tzplatform_config.h>
 
-#define SHELL_COMMAND   "/bin/sh"
 #define APPCMD_RESULT_BUFSIZE   (4096)
 
 typedef struct appcmd_info appcmd_info;
@@ -642,10 +641,10 @@ static void run_appcmd_appinstallpath(appcmd_info* p_info) {
 
     p_info->exitcode = -1;
 
-    const char* path = tzplatform_getenv(TZ_SDK_TOOLS);
+    const char* path = tzplatform_getenv(TZ_SDK_HOME);
     if (path != NULL) {
         p_info->exitcode = 0;
-        snprintf(result_buf, sizeof(result_buf), "\n%s:%s\n", MESSAGE_PREFIX_APPCMD_RETURN, path);
+        snprintf(result_buf, sizeof(result_buf), "\n%s:%s/apps_rw/\n", MESSAGE_PREFIX_APPCMD_RETURN, path);
         writex(p_info->fd, result_buf, strlen(result_buf));
     } else {
         D("failed to get application install path from tzplatform_getenv.");
index 2be2345..ac7f573 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -31,7 +31,6 @@
 #include <tzplatform_config.h>
 #include <pthread.h>
 #include <dlfcn.h>
-#include <sys/smack.h>
 
 #include "sysdeps.h"
 #include "log.h"
@@ -59,7 +58,6 @@
 
 #define PROC_CMDLINE_PATH "/proc/cmdline"
 #define USB_SERIAL_PATH "/sys/class/usb_mode/usb0/iSerial"
-#define APPID2PID_PATH  "/usr/bin/appid2pid"
 
 #include <sys/ioctl.h>
 #include <net/if.h>
@@ -127,29 +125,6 @@ int is_emulator(void) {
 #endif
 }
 
-int is_appid2pid_supported(void) {
-
-    if (access(APPID2PID_PATH, F_OK) == 0) {
-        /* It is necessary to confirm that it is possible
-         * to run "appid2pid" in the sdk user/group privileges. */
-        struct stat st;
-        if (stat(APPID2PID_PATH, &st) == 0) {
-            D("appid2pid uid=%d, gid=%d, mode=0x%x.\n", st.st_uid, st.st_gid, st.st_mode);
-            if ( (st.st_uid == STATIC_SDK_USER_ID && st.st_mode & S_IXUSR)
-                || (st.st_gid == STATIC_SDK_GROUP_ID && st.st_mode & S_IXGRP)
-                || (st.st_mode & S_IXOTH) ) {
-                D("appid2pid is supported.\n");
-                return 1;
-            }
-        }
-    } else {
-        D("failed to access appid2pid file: %d\n", errno);
-    }
-
-    D("appid2pid is NOT supported.\n");
-    return 0;
-}
-
 int is_container_enabled(void) {
     bool value;
     int ret;
@@ -398,7 +373,7 @@ void print_packet(const char *label, apacket *p)
 #endif
 
 #ifdef SUPPORT_ENCRYPT
-/*
+/* 
 desc. : 암호화 실패 메시지 전송
 parameter : [in] apacket* p : sdbd로 들어온 메시지
                        [in] atransport *t : 현재 연결에 대한 atransport
@@ -414,7 +389,7 @@ void send_encr_fail(apacket* p, atransport *t, unsigned failed_value){
        //put_apacket(enc_p);
 }
 
-/*
+/* 
 desc. : 암호화 메시지 핸들링
 parameter : [in] apacket* p : sdbd로 들어온 메시지
                        [in/out] atransport *t : 현재 연결에 대한 atransport
@@ -428,12 +403,12 @@ int handle_encr_packet(apacket* p, atransport *t){
 
        if(p->msg.arg0 == ENCR_SET_ON_REQ){ // hello 메시지인 경우
                t->sessionID = sessionID;
-               if((retVal = security_init(t->sessionID, NULL)) == 1){ // 암호화 handshaking을 위한 init
+               if((retVal = security_init(t->sessionID, NULL)) == 1){ // 암호화 handshaking을 위한 init                  
                        if(security_parse_server_hello(t->sessionID, p) == 1){ // hello 메시지 파싱
                                D("security_parse_server_hello success\n");
                 enc_p = get_apacket();
                                if(security_gen_client_hello(t->sessionID, enc_p) == 1){ // hello 메시지 생성
-                                       D("security_gen_client_hello success\n");
+                                       D("security_gen_client_hello success\n");                               
                                        enc_p->msg.command = A_ENCR;
                                        enc_p->msg.arg0 = ENCR_SET_ON_REQ;
                                        enc_p->msg.arg1 = p->msg.arg1;
@@ -444,7 +419,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                                        D("security_gen_client_hello error\n");
                                        send_encr_fail(p, t, ENCR_ON_FAIL); // 암호화 on 실패 메시지 전송
                                        t->encryption = ENCR_OFF; // 암호화 모드는 off
-                                       security_deinit(t->sessionID);
+                                       security_deinit(t->sessionID);                          
                                        return -1;
                                }
                        }
@@ -453,7 +428,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                                send_encr_fail(p, t, ENCR_ON_FAIL);
                                t->encryption = ENCR_OFF;
                                security_deinit(t->sessionID);
-
+                               
                                return -1;
                        }
                } else { // init 실패
@@ -536,7 +511,7 @@ int handle_encr_packet(apacket* p, atransport *t){
        }
        //put_apacket(enc_p);
        return 0;
-
+       
 }
 #endif
 
@@ -1253,10 +1228,6 @@ void start_device_log(void)
         return;
     }
 
-    if (smack_setlabel(path, SDK_SHELL_LABEL_NAME, SMACK_LABEL_ACCESS) == -1) {
-        D("unable to set sdk shell smack label %s due to (errno:%d)\n", SDK_SHELL_LABEL_NAME, errno);
-    }
-
     // redirect stdout and stderr to the log file
     dup2(fd, 1);
     dup2(fd, 2);
@@ -2021,17 +1992,6 @@ static void init_capabilities(void) {
                        "%s", UNKNOWN);
     }
 
-    // appid2pid support
-    ret = is_appid2pid_supported();
-    snprintf(g_capabilities.appid2pid_support, sizeof(g_capabilities.appid2pid_support),
-                "%s", ret == 1 ? ENABLED : DISABLED);
-
-
-    // pkgcmd debug mode support
-    snprintf(g_capabilities.pkgcmd_debugmode, sizeof(g_capabilities.pkgcmd_debugmode),
-                "%s", ENABLED);
-
-
     // Capability version
     snprintf(g_capabilities.sdbd_cap_version, sizeof(g_capabilities.sdbd_cap_version),
                 "%d.%d", SDBD_CAP_VERSION_MAJOR, SDBD_CAP_VERSION_MINOR);
index 052d49d..348a7eb 100644 (file)
--- a/src/sdb.h
+++ b/src/sdb.h
@@ -275,8 +275,6 @@ typedef struct platform_capabilities
     char sockproto_support[CAPBUF_ITEMSIZE];    // enabled or disabled
     char appcmd_support[CAPBUF_ITEMSIZE];       // enabled or disabled
     char encryption_support[CAPBUF_ITEMSIZE];   // enabled or disabled
-    char appid2pid_support[CAPBUF_ITEMSIZE];    // enabled or disabled
-    char pkgcmd_debugmode[CAPBUF_ITEMSIZE];     // enabled or disabled
 
     char log_enable[CAPBUF_ITEMSIZE];           // enabled or disabled
     char log_path[CAPBUF_LL_ITEMSIZE];          // path of sdbd log
@@ -544,6 +542,7 @@ int read_line(const int fd, char* ptr, const size_t maxlen);
 
 #define USB_FUNCFS_SDB_PATH "/dev/usbgadget/sdb"
 #define USB_NODE_FILE "/dev/samsung_sdb"
+#define SHELL_COMMAND "/bin/sh"
 int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * const envp[]);
 void get_env(char *key, char **env);
 
index e73bfec..9027970 100644 (file)
@@ -37,7 +37,6 @@ struct arg_permit_rule
 #define APPID_MAX_LENGTH                        50
 #define SDBD_LABEL_NAME                         "sdbd"
 #define SDK_HOME_LABEL_NAME                     "sdbd::home"
-#define SDK_SHELL_LABEL_NAME                    "User::Shell"
 
 int verify_root_commands(const char *arg1);
 int verify_app_path(const char* path);
index 76c28d1..d2d1500 100644 (file)
@@ -44,7 +44,6 @@
 #include "utils.h"
 #include <system_info.h>
 #include <tzplatform_config.h>
-#include <sys/smack.h>
 
 #include <vconf.h>
 #include <limits.h>
@@ -462,12 +461,6 @@ int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * c
         return -1;
     }
 
-    if (smack_setlabel(devname, SDK_SHELL_LABEL_NAME, SMACK_LABEL_ACCESS) == -1) {
-        D("unable to set sdk shell smack label %s due to (errno:%d)\n", SDK_SHELL_LABEL_NAME, errno);
-        sdb_close(ptm);
-        return -1;
-    }
-
     *pid = fork();
     if(*pid < 0) {
         D("- fork failed: errno:%d -\n", errno);
@@ -528,7 +521,6 @@ int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * c
 }
 #endif  /* !SDB_HOST */
 
-#define SHELL_COMMAND "/bin/sh-user"
 #define LOGIN_COMMAND "/bin/login"
 #define SUPER_USER    "root"
 #define LOGIN_CONFIG  "/etc/login.defs"
@@ -1020,14 +1012,6 @@ static void get_capability(int fd, void *cookie) {
     offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE,
             "appcmd_support", g_capabilities.appcmd_support);
 
-    // appid2pid support
-    offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE,
-                                "appid2pid_support", g_capabilities.appid2pid_support);
-
-    // pkgcmd debug mode support
-    offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE,
-                                "pkgcmd_debugmode", g_capabilities.pkgcmd_debugmode);
-
     offset++; // for '\0' character
 
     writex(fd, &offset, sizeof(uint16_t));