#if !SDB_HOST
#include <linux/prctl.h>
#define SDB_PIDPATH "/tmp/.sdbd.pid"
-#else
-#include "usb_vendors.h"
#endif
#include <system_info.h>
#include <vconf.h>
if (access(SDB_PIDPATH, F_OK) == 0)
sdb_unlink(SDB_PIDPATH);
#endif
- char * const cmd1_args[] = {"/usr/bin/killall", "/usr/bin/debug_launchpad_preloading_preinitializing_daemon", NULL};
- spawn("/usr/bin/killall", cmd1_args);
- sdb_sleep_ms(1000);
}
static const char *sdb_device_banner = "device";
exit(-1);
}
+static int is_enable_sdbd_log()
+{
+ return (!strncmp(g_capabilities.log_enable, SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED)));
+}
+
int sdb_trace_mask;
/* read a comma/space/colum/semi-column separated list of tags
{ NULL, 0 }
};
- if (p == NULL)
+ if (p == NULL) {
+ if (is_enable_sdbd_log())
+ p = "all";
+ else
return;
+ }
/* use a comma/column/semi-colum/space separated list */
while (*p) {
// Verify pointer p
int result = access((const char *) p, F_OK);
if ((result == -1) && (errno == EFAULT)) {
- D("Invalid apacket = [0x%x]", p);
- fatal("Invalid apacket = [0x%x]", p);
+ fatal("Invalid apacket = [0x%p]", p);
}
asocket *s;
}
#if !SDB_HOST
+
void start_device_log(void)
{
int fd;
- char path[PATH_MAX];
+ char path[PATH_MAX] = {0, };
+ char path_folder[PATH_MAX] = {0, };
+ char path_file[PATH_MAX] = {0, };
struct tm now;
time_t t;
// char value[PROPERTY_VALUE_MAX];
- const char* p = getenv("SDB_TRACE");
+ const char* p_trace = getenv("SDB_TRACE");
+ const char* p_path = getenv("SDBD_LOG_PATH");
// read the trace mask from persistent property persist.sdb.trace_mask
// give up if the property is not set or cannot be parsed
#if 0 /* tizen specific */
return;
#endif
- if (p == NULL) {
+ if ((p_trace == NULL ) && !is_enable_sdbd_log()) {
return;
}
+
+ if (p_path)
+ snprintf(path_folder, sizeof(path_folder), "%s", p_path);
+ else if (g_capabilities.log_path[0] != '\0')
+ snprintf(path_folder, sizeof(path_folder), "%s", g_capabilities.log_path);
+ else
+ return;
+
tzset();
time(&t);
localtime_r(&t, &now);
- strftime(path, sizeof(path),
- "/tmp/sdbd-%Y-%m-%d-%H-%M-%S.txt",
- &now);
- fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+
+ strftime(path_file, sizeof(path_file),
+ "sdbd-%Y-%m-%d-%H-%M-%S.txt",
+ &now);
+
+ snprintf(path, sizeof(path), "%s/%s", path_folder, path_file);
+
+ fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0) {
return;
}
int daemonize(void) {
- // set file creation mask to 0
- umask(0);
-
switch (fork()) {
case -1:
return -1;
default:
_exit(0);
}
+
+ // 2016-08-25 : modified umask to 022 from 000 because of security reason
+ // there is a problem that the file created by sdb shell command could be written by 'others'
+ umask(SDBD_UMASK);
+
#ifdef SDB_PIDPATH
FILE *f = fopen(SDB_PIDPATH, "w");
return 0;
}
-static void execute_required_process() {
- char * const cmd_args[] = {"/usr/bin/debug_launchpad_preloading_preinitializing_daemon",NULL};
-
- spawn("/usr/bin/debug_launchpad_preloading_preinitializing_daemon", cmd_args);
-}
-
/* default plugin proc */
static int get_plugin_capability(const char* in_buf, sdbd_plugin_param out) {
int ret = SDBD_PLUGIN_RET_NOT_SUPPORT;
} else {
snprintf(out.data, out.len, "%s", SDBD_CAP_RET_DISABLED);
}
+ ret = SDBD_PLUGIN_RET_SUCCESS;
+ } else if (SDBD_CMP_CAP(in_buf, CANLAUNCH)) {
+ snprintf(out.data, out.len, "%s", UNKNOWN);
+ ret = SDBD_PLUGIN_RET_SUCCESS;
} else if (SDBD_CMP_CAP(in_buf, PLUGIN_VER)) {
snprintf(out.data, out.len, "%s", UNKNOWN);
ret = SDBD_PLUGIN_RET_SUCCESS;
} else if (SDBD_CMP_CAP(in_buf, PRODUCT_VER)) {
snprintf(out.data, out.len, "%s", UNKNOWN);
ret = SDBD_PLUGIN_RET_SUCCESS;
+ } else if (SDBD_CMP_CAP(in_buf, LOG_ENABLE)) {
+ snprintf(out.data, out.len, "%s", SDBD_CAP_RET_DISABLED);
+ ret = SDBD_PLUGIN_RET_SUCCESS;
+ } else if (SDBD_CMP_CAP(in_buf, LOG_PATH)) {
+ snprintf(out.data, out.len, "%s", "/tmp");
+ ret = SDBD_PLUGIN_RET_SUCCESS;
}
return ret;
return ret;
}
+static int get_shell_env(const char* in_buf, sdbd_plugin_param out) {
+ snprintf(out.data, out.len, "%s", "");
+ return SDBD_PLUGIN_RET_SUCCESS;
+}
+
int default_cmd_proc(const char* cmd,
const char* in_buf, sdbd_plugin_param out) {
int ret = SDBD_PLUGIN_RET_NOT_SUPPORT;
ret = verify_sdbd_launch(in_buf, out);
} else if (SDBD_CMP_CMD(cmd, VERIFY_ROOTCMD)) {
ret = verify_root_cmd(in_buf, out);
+ } else if (SDBD_CMP_CMD(cmd, SHELL_ENVVAR)) {
+ ret = get_shell_env(in_buf, out);
} else {
D("Not supported command : %s\n", cmd);
ret = SDBD_PLUGIN_RET_NOT_SUPPORT;
}
}
- execute_required_process();
-
if (is_emulator()) {
register_bootdone_cb();
}
}
+ // Target name of the launch possible
+ if(!request_plugin_cmd(SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_CANLAUNCH,
+ g_capabilities.can_launch,
+ sizeof(g_capabilities.can_launch))) {
+ D("failed to request. (%s:%s) \n", SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_CANLAUNCH);
+ snprintf(g_capabilities.can_launch, sizeof(g_capabilities.can_launch),
+ "%s", UNKNOWN);
+ }
+
+
// Platform version
ret = system_info_get_platform_string("http://tizen.org/feature/platform.version", &value);
if (ret != SYSTEM_INFO_ERROR_NONE) {
snprintf(g_capabilities.sdbd_plugin_version, sizeof(g_capabilities.sdbd_plugin_version),
"%s", UNKNOWN);
}
+
+
+ // sdbd log enable
+ if(!request_plugin_cmd(SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_ENABLE,
+ g_capabilities.log_enable,
+ sizeof(g_capabilities.log_enable))) {
+ D("failed to request. (%s:%s) \n", SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_ENABLE);
+ snprintf(g_capabilities.log_enable, sizeof(g_capabilities.log_enable),
+ "%s", DISABLED);
+ }
+
+ // sdbd log path
+ if(!request_plugin_cmd(SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_PATH,
+ g_capabilities.log_path,
+ sizeof(g_capabilities.log_path))) {
+ D("failed to request. (%s:%s) \n", SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_PATH);
+ snprintf(g_capabilities.log_path, sizeof(g_capabilities.log_path),
+ "%s", UNKNOWN);
+ }
+
+
+ // Capability version
+ snprintf(g_capabilities.sdbd_cap_version, sizeof(g_capabilities.sdbd_cap_version),
+ "%d.%d", SDBD_CAP_VERSION_MAJOR, SDBD_CAP_VERSION_MINOR);
}
static int is_support_usbproto()
load_sdbd_plugin();
init_capabilities();
+ sdb_trace_init();
+ start_device_log();
+
init_drop_privileges();
init_sdk_requirements();
if (!request_plugin_verification(SDBD_CMD_VERIFY_LAUNCH, NULL)) {
D("sdbd should be launched in develop mode.\n");
return -1;
}
-
- umask(000);
#endif
atexit(sdb_cleanup);
#if SDB_HOST
HOST = 1;
- usb_vendors_init();
usb_init();
local_init(DEFAULT_SDB_LOCAL_TRANSPORT_PORT);
int main(int argc, char **argv)
{
- sdb_trace_init(); /* tizen specific */
#if SDB_HOST
sdb_sysdeps_init();
sdb_trace_init();
fatal("daemonize() failed: errno:%d", errno);
#endif
- start_device_log();
D("Handling main()\n");
//sdbd will never die on emulator!