From b3894c7aa4e819c5cde88c7d389fb8300af6fdb1 Mon Sep 17 00:00:00 2001 From: Sangjin Kim Date: Tue, 27 Dec 2016 04:51:21 -0800 Subject: [PATCH] Revert "Revert "Revert "Modify the SMACK label for SDB shell.""" This reverts commit cb4d1bb8af186a59661e4e35bdb13fecdc1a0163. Change-Id: I0e22b3fe0cb56f38cc562182bef7a65de998a59f --- packaging/sdbd.spec | 4 ---- src/default_plugin_appcmd.c | 5 ++--- src/sdb.c | 54 ++++++--------------------------------------- src/sdb.h | 3 +-- src/sdktools.h | 1 - src/services.c | 16 -------------- 6 files changed, 10 insertions(+), 73 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 15eb808..bc9408f 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -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 diff --git a/src/default_plugin_appcmd.c b/src/default_plugin_appcmd.c index c929cf2..07a41d1 100644 --- a/src/default_plugin_appcmd.c +++ b/src/default_plugin_appcmd.c @@ -38,7 +38,6 @@ #include -#define SHELL_COMMAND "/bin/sh" #define APPCMD_RESULT_BUFSIZE (4096) typedef struct appcmd_info appcmd_info; @@ -651,10 +650,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."); diff --git a/src/sdb.c b/src/sdb.c index 4a1ca97..a07a881 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -31,7 +31,6 @@ #include #include #include -#include #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 #include @@ -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 @@ -1261,10 +1236,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); @@ -2029,17 +2000,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); diff --git a/src/sdb.h b/src/sdb.h index b339f26..226da64 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -279,8 +279,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 @@ -549,6 +547,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); diff --git a/src/sdktools.h b/src/sdktools.h index e73bfec..9027970 100644 --- a/src/sdktools.h +++ b/src/sdktools.h @@ -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); diff --git a/src/services.c b/src/services.c index 2b52bc8..b0f2e08 100644 --- a/src/services.c +++ b/src/services.c @@ -44,7 +44,6 @@ #include "utils.h" #include #include -#include #include #include @@ -409,12 +408,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); @@ -475,7 +468,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" @@ -967,14 +959,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)); -- 2.7.4