#include <tzplatform_config.h>
+#define SHELL_COMMAND "/bin/sh"
#define APPCMD_RESULT_BUFSIZE (4096)
typedef struct appcmd_info appcmd_info;
p_info->exitcode = -1;
- const char* path = tzplatform_getenv(TZ_SDK_HOME);
+ const char* path = tzplatform_getenv(TZ_SDK_TOOLS);
if (path != NULL) {
p_info->exitcode = 0;
- snprintf(result_buf, sizeof(result_buf), "\n%s:%s/apps_rw/\n", MESSAGE_PREFIX_APPCMD_RETURN, path);
+ snprintf(result_buf, sizeof(result_buf), "\n%s:%s\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.");
#include <tzplatform_config.h>
#include <pthread.h>
#include <dlfcn.h>
+#include <sys/smack.h>
#include "sysdeps.h"
#include "log.h"
#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>
#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;
#endif
#ifdef SUPPORT_ENCRYPT
-/*
+/*
desc. : 암호화 실패 메시지 전송
parameter : [in] apacket* p : sdbd로 들어온 메시지
[in] atransport *t : 현재 연결에 대한 atransport
//put_apacket(enc_p);
}
-/*
+/*
desc. : 암호화 메시지 핸들링
parameter : [in] apacket* p : sdbd로 들어온 메시지
[in/out] atransport *t : 현재 연결에 대한 atransport
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;
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;
}
}
send_encr_fail(p, t, ENCR_ON_FAIL);
t->encryption = ENCR_OFF;
security_deinit(t->sessionID);
-
+
return -1;
}
} else { // init 실패
}
//put_apacket(enc_p);
return 0;
-
+
}
#endif
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);
"%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);
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
#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);
#include "utils.h"
#include <system_info.h>
#include <tzplatform_config.h>
+#include <sys/smack.h>
#include <vconf.h>
#include <limits.h>
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);
}
#endif /* !SDB_HOST */
+#define SHELL_COMMAND "/bin/sh-user"
#define LOGIN_COMMAND "/bin/login"
#define SUPER_USER "root"
#define LOGIN_CONFIG "/etc/login.defs"
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));