From 0b202ec3594d65668ab0d1c5b1f2af87b257eb90 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Wed, 30 Mar 2016 12:39:50 +0900 Subject: [PATCH 01/16] Removed libprivilege-control dependency Change-Id: I6db42995d134e555ef93a024c7e0377e5977520c Signed-off-by: shingil.kang --- packaging/sdbd.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index aaba56d..db9e680 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -23,7 +23,6 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) -Requires(post): libprivilege-control Requires: dbus %description -- 2.7.4 From 467ef95149819b0fe41c766ed165b1f7e6091c99 Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Mon, 4 Apr 2016 14:36:24 +0900 Subject: [PATCH 02/16] Add the sdk_toolpath member to sdbd capability. - The sdk_toolpath member includes a path that tool of the SDK is saved. Change-Id: Ie022bed562ea0485d263593c060041a6f4fcea14 Signed-off-by: Kim Gunsoo --- src/sdb.c | 11 +++++++++-- src/sdb.h | 3 +++ src/services.c | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index 1686af2..0fa0672 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -67,8 +67,6 @@ SDB_MUTEX_DEFINE( D_lock ); #endif int HOST = 0; -#define HOME_DEV_PATH tzplatform_getenv(TZ_SDK_HOME) -#define DEV_NAME tzplatform_getenv(TZ_SDK_USER_NAME) uid_t g_sdk_user_id; gid_t g_sdk_group_id; char* g_sdk_home_dir = NULL; @@ -1933,6 +1931,15 @@ static void init_capabilities(void) { snprintf(g_capabilities.syncwinsz_support, sizeof(g_capabilities.syncwinsz_support), "%s", ENABLED); + // SDK Tool path + if (SDK_TOOL_PATH == NULL) { + D("fail to get SDK tool path.\n"); + snprintf(g_capabilities.sdk_toolpath, sizeof(g_capabilities.sdk_toolpath), + "%s", UNKNOWN); + } else { + snprintf(g_capabilities.sdk_toolpath, sizeof(g_capabilities.sdk_toolpath), + "%s", SDK_TOOL_PATH); + } // Profile name ret = system_info_get_platform_string("http://tizen.org/feature/profile", &value); diff --git a/src/sdb.h b/src/sdb.h index 750e9a6..074d165 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -245,6 +245,7 @@ typedef struct platform_info { #define CPUARCH_X86 "x86" #define CAPBUF_SIZE 4096 #define CAPBUF_ITEMSIZE 32 +#define CAPBUF_L_ITEMSIZE 256 typedef struct platform_capabilities { char secure_protocol[CAPBUF_ITEMSIZE]; // enabled or disabled @@ -260,6 +261,7 @@ typedef struct platform_capabilities char cpu_arch[CAPBUF_ITEMSIZE]; // cpu architecture (ex. x86) char profile_name[CAPBUF_ITEMSIZE]; // profile name (ex. mobile) char vendor_name[CAPBUF_ITEMSIZE]; // vendor name (ex. Tizen) + char sdk_toolpath[CAPBUF_L_ITEMSIZE]; // sdk tool path char platform_version[CAPBUF_ITEMSIZE]; // platform version (ex. 2.3.0) char product_version[CAPBUF_ITEMSIZE]; // product version (ex. 1.0) @@ -388,6 +390,7 @@ int booting_done; // 0: platform booting is in progess 1: platform booting is do #define SID_INPUT 1004 #define SDK_USER_NAME tzplatform_getenv(TZ_SDK_USER_NAME) +#define SDK_TOOL_PATH tzplatform_getenv(TZ_SDK_TOOLS) extern uid_t g_sdk_user_id; extern gid_t g_sdk_group_id; extern char* g_sdk_home_dir; diff --git a/src/services.c b/src/services.c index 78cd4aa..9607462 100644 --- a/src/services.c +++ b/src/services.c @@ -885,6 +885,10 @@ static void get_capability(int fd, void *cookie) { offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE, "cpu_arch", g_capabilities.cpu_arch); + // SDK Tool path + offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE, + "sdk_toolpath", g_capabilities.sdk_toolpath); + // Profile name offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE, "profile_name", g_capabilities.profile_name); -- 2.7.4 From 0795f20e22524c34b5a8fad5e920cd7010a60f9b Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Wed, 6 Apr 2016 08:40:21 +0900 Subject: [PATCH 03/16] Add the check routine for multi-user support. - The multi-user support information is obtained from tizen-platform-config. Change-Id: I3ce38d8a0d9070d9a93784918acf7a0746a1094c Signed-off-by: Kim Gunsoo --- src/sdb.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index 0fa0672..57cbcb0 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1922,10 +1922,17 @@ static void init_capabilities(void) { // Multi-User support - // TODO: get this information from platform. - snprintf(g_capabilities.multiuser_support, sizeof(g_capabilities.multiuser_support), - "%s", DISABLED); - + // XXX: There is no clear way to determine whether multi-user support. + // Since TZ_SYS_DEFAULT_USER is set to "owner" for multi-user support, + // guess whether multiuser support through that information. + const char* sys_default_user = tzplatform_getenv(TZ_SYS_DEFAULT_USER); + if (sys_default_user != NULL && !strcmp(sys_default_user, "owner")) { + snprintf(g_capabilities.multiuser_support, sizeof(g_capabilities.multiuser_support), + "%s", ENABLED); + } else { + snprintf(g_capabilities.multiuser_support, sizeof(g_capabilities.multiuser_support), + "%s", DISABLED); + } // Window size synchronization support snprintf(g_capabilities.syncwinsz_support, sizeof(g_capabilities.syncwinsz_support), -- 2.7.4 From 77d9bf3de8868f7ac7653c3ba713e25558a1b582 Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Thu, 7 Apr 2016 13:10:16 +0900 Subject: [PATCH 04/16] MISC: package version up(3.0.7) - Add the check routine for multi-user support. - Add the sdk_toolpath member to sdbd capability. Change-Id: I7121f8c2c487934e30fbcd3ddddc2092c49742d5 Signed-off-by: Kim Gunsoo --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index db9e680..c9e22bf 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.6 +Version: 3.0.7 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 5ebfb9fc5cb97861083cbdc9c553488708b3bd6c Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Wed, 6 Apr 2016 15:21:49 +0900 Subject: [PATCH 05/16] Add permission of the log group to sdbd service. - To obtain permission to run the dlogutil, the log group permissions has been granted to sdbd service. Change-Id: I739a3ab5dfb0b118939e2f809b32fee7d10fee04 Signed-off-by: Kim Gunsoo --- packaging/sdbd.spec | 2 +- src/sdb.c | 99 +++++++++++++++++++++++++++++++++++++---------------- src/sdb.h | 6 ---- 3 files changed, 71 insertions(+), 36 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index c9e22bf..4b562e1 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.7 +Version: 3.0.8 Release: 0 License: Apache-2.0 Summary: SDB daemon diff --git a/src/sdb.c b/src/sdb.c index 57cbcb0..ac5f2ad 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -71,6 +71,15 @@ uid_t g_sdk_user_id; gid_t g_sdk_group_id; char* g_sdk_home_dir = NULL; char* g_sdk_home_dir_env = NULL; + +struct group_info +{ + const char *name; + gid_t gid; +}; +struct group_info g_default_groups[] = { {"log", -1}, {NULL, -1}}; +#define SDB_DEFAULT_GROUPS_CNT ((sizeof(g_default_groups)/sizeof(g_default_groups[0]))-1) + int is_init_sdk_userinfo = 0; #if !SDB_HOST @@ -1397,50 +1406,46 @@ void register_bootdone_cb() { } static int sdbd_set_groups() { - gid_t *groups = NULL; + gid_t *group_ids = NULL; int ngroups = 0; - int default_ngroups = 0; int i, j = 0; int group_match = 0; int added_group_cnt = 0; - gid_t default_groups[] = { SID_DEVELOPER, SID_APP_LOGGING, SID_SYS_LOGGING, SID_INPUT }; - - default_ngroups = sizeof(default_groups) / sizeof(default_groups[0]); getgrouplist(SDK_USER_NAME, g_sdk_group_id, NULL, &ngroups); D("group list : ngroups = %d\n", ngroups); - groups = malloc((ngroups + default_ngroups) * sizeof(gid_t)); - if (groups == NULL) { - D("failed to allocate groups(%d)\n", (ngroups + default_ngroups) * sizeof(gid_t)); + group_ids = malloc((ngroups + SDB_DEFAULT_GROUPS_CNT) * sizeof(gid_t)); + if (group_ids == NULL) { + D("failed to allocate group_ids(%d)\n", (ngroups + SDB_DEFAULT_GROUPS_CNT) * sizeof(gid_t)); return -1; } - if (getgrouplist(SDK_USER_NAME, g_sdk_group_id, groups, &ngroups) == -1) { + if (getgrouplist(SDK_USER_NAME, g_sdk_group_id, group_ids, &ngroups) == -1) { D("failed to getgrouplist(), ngroups = %d\n", ngroups); - free(groups); + free(group_ids); return -1; } - for (i = 0; i < default_ngroups; i++) { + for (i = 0; g_default_groups[i].name != NULL; i++) { for (j = 0; j < ngroups; j++) { - if (groups[j] == default_groups[i]) { + if (group_ids[j] == g_default_groups[i].gid) { group_match = 1; break; } } if (group_match == 0) { - groups[ngroups + added_group_cnt] = default_groups[i]; + group_ids[ngroups + added_group_cnt] = g_default_groups[i].gid; added_group_cnt ++; } group_match = 0; } - if (setgroups(ngroups+added_group_cnt, groups) != 0) { + if (setgroups(ngroups+added_group_cnt, group_ids) != 0) { D("failed to setgroups().\n"); - free(groups); + free(group_ids); return -1; } - free(groups); + free(group_ids); return 0; } @@ -1456,7 +1461,6 @@ static int sdbd_get_user_pwd(const char* user_name, struct passwd* pwd, char* bu errno = ret; D("failed to getpwuid_r\n"); } - free(buf); return -1; } @@ -1471,11 +1475,7 @@ int set_sdk_user_privileges() { if (sdbd_set_groups() < 0) { D("set groups failed (errno: %d)\n", errno); - - // set default group list - gid_t default_groups[] = { SID_DEVELOPER, SID_APP_LOGGING, SID_SYS_LOGGING, SID_INPUT }; - int default_ngroups = sizeof(default_groups) / sizeof(default_groups[0]); - setgroups(default_ngroups, default_groups); + return -1; } if (setgid(g_sdk_group_id) != 0) { @@ -1718,6 +1718,45 @@ static void load_sdbd_plugin() { D("using sdbd plugin interface.(%s)\n", SDBD_PLUGIN_PATH); } +static long get_passwd_bufsize() { + long bufsize = 0; + + bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); + if(bufsize < 0) { + bufsize = (16*1024); + } + + return bufsize; +} + +static int init_sdb_default_groups() { + struct passwd pwd; + char *buf = NULL; + long bufsize = 0; + int i = 0; + + bufsize = get_passwd_bufsize(); + buf = malloc(bufsize); + if (buf == NULL) { + D("failed to allocate passwd buf(%ld)\n", bufsize); + return -1; + } + + for (i = 0; g_default_groups[i].name != NULL; i++) { + memset(buf, 0, bufsize); + if (sdbd_get_user_pwd(g_default_groups[i].name, &pwd, buf, bufsize) == 0) { + g_default_groups[i].gid = pwd.pw_gid; + } else { + D("get user passwd info.(errno: %d)\n", errno); + free(buf); + return -1; + } + } + + free(buf); + return 0; +} + static int init_sdk_userinfo() { struct passwd pwd; char *buf = NULL; @@ -1727,14 +1766,10 @@ static int init_sdk_userinfo() { return 0; } - bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); - if(bufsize < 0) { - bufsize = (16*1024); - } - + bufsize = get_passwd_bufsize(); buf = malloc(bufsize); if (buf == NULL) { - D("failed to allocate passwd buf(%d)\n", bufsize); + D("failed to allocate passwd buf(%ld)\n", bufsize); return -1; } @@ -1751,6 +1786,13 @@ static int init_sdk_userinfo() { free(buf); + if (init_sdb_default_groups() < 0) { + D("failed to initialize default groups.\n"); + free(g_sdk_home_dir); + g_sdk_home_dir = NULL; + return -1; + } + int env_size = strlen("HOME=") + strlen(g_sdk_home_dir) + 1; g_sdk_home_dir_env = malloc(env_size); if(g_sdk_home_dir_env == 0) { @@ -1920,7 +1962,6 @@ static void init_capabilities(void) { snprintf(g_capabilities.zone_support, sizeof(g_capabilities.zone_support), "%s", ret == 1 ? ENABLED : DISABLED); - // Multi-User support // XXX: There is no clear way to determine whether multi-user support. // Since TZ_SYS_DEFAULT_USER is set to "owner" for multi-user support, diff --git a/src/sdb.h b/src/sdb.h index 074d165..21056b6 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -382,12 +382,6 @@ int booting_done; // 0: platform booting is in progess 1: platform booting is do // This is the users and groups config for the platform #define SID_ROOT 0 /* traditional unix root user */ -#define SID_TTY 5 /* group for /dev/ptmx */ -#define SID_APP tzplatform_getuid(TZ_USER_NAME) /* application */ -#define SID_DEVELOPER tzplatform_getuid(TZ_SDK_USER_NAME) /* developer with SDK */ -#define SID_APP_LOGGING 6509 -#define SID_SYS_LOGGING 6527 -#define SID_INPUT 1004 #define SDK_USER_NAME tzplatform_getenv(TZ_SDK_USER_NAME) #define SDK_TOOL_PATH tzplatform_getenv(TZ_SDK_TOOLS) -- 2.7.4 From f71e433440041a74a3e72903dcd3e4478d310300 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Mon, 11 Apr 2016 13:33:49 +0900 Subject: [PATCH 06/16] Fixed sdk_launch script - Supported multi user feature Change-Id: I2c092c8ad4f332571353f12f91f50638416dc3f6 Signed-off-by: shingil.kang --- packaging/sdbd.spec | 2 +- script/sdk_launch | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 4b562e1..0a7d9aa 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.8 +Version: 3.0.9 Release: 0 License: Apache-2.0 Summary: SDB daemon diff --git a/script/sdk_launch b/script/sdk_launch index 6206e59..b914363 100755 --- a/script/sdk_launch +++ b/script/sdk_launch @@ -132,7 +132,7 @@ then if [ "" != "$attach_id" ] #debug attach then - cmd="/usr/bin/launch_debug $launch_app_arg1 __AUL_SDK__ ATTACH __DLP_ATTACH_ARG__ --attach,:$port,$attach_id" + cmd="/usr/bin/launch_debug $launch_app_arg1 __AUL_SDK__ ATTACH __DLP_GDBSERVER_PATH__ ${SDK_TOOLS_PATH}/gdbserver/gdbserver __DLP_ATTACH_ARG__ --attach,:$port,$attach_id" #debug else if [ "" != "$result_mode" ] @@ -141,7 +141,7 @@ then else result_mode="DEBUG" fi - cmd="/usr/bin/launch_app $launch_app_arg1 __AUL_SDK__ $result_mode __DLP_DEBUG_ARG__ :$port $launch_app_mode $args" + cmd="/usr/bin/app_launcher -s $launch_app_arg1 __AUL_SDK__ $result_mode __DLP_DEBUG_ARG__ :$port $launch_app_mode $args __DLP_GDBSERVER_PATH__ ${SDK_TOOLS_PATH}/gdbserver/gdbserver" # cmd="$COV_TEST_PREFIX ${TZ_SDK_TOOLS}/gdbserver/gdbserver :$port ${TZ_SYS_RW_APP}/$pkgid/bin/$exe" fi else -- 2.7.4 From 2f4a9d9c1670bbe26286b8cf69169cbb7041e9db Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Mon, 18 Apr 2016 18:17:05 +0900 Subject: [PATCH 07/16] Fixed build warnings. Change-Id: I1063d7ae01b6b28699cd90d82f9fe88c1737a34a Signed-off-by: shingil.kang --- packaging/sdbd.spec | 2 +- src/file_sync_service.c | 55 ++++++++++++++++++++------------ src/sdb.c | 17 ++++++---- src/sdb.h | 8 ++--- src/sdktools.c | 4 +-- src/sdktools.h | 2 +- src/services.c | 14 ++++---- src/transport.c | 14 +++----- src/transport_local.c | 85 ++----------------------------------------------- src/usb_funcfs_client.c | 4 +-- src/usb_libusb.c | 2 +- src/usb_linux.c | 2 +- src/usb_linux_client.c | 2 +- src/utils.c | 4 +-- src/utils.h | 2 +- 15 files changed, 74 insertions(+), 143 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 0a7d9aa..a05aff7 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.9 +Version: 3.0.10 Release: 0 License: Apache-2.0 Summary: SDB daemon diff --git a/src/file_sync_service.c b/src/file_sync_service.c index 0e97ab4..d142ff1 100644 --- a/src/file_sync_service.c +++ b/src/file_sync_service.c @@ -39,13 +39,10 @@ #define SYNC_TIMEOUT 15 -#define APP_INSTALL_PATH_PREFIX1 tzplatform_getenv(TZ_SYS_RW_APP) -#define APP_INSTALL_PATH_PREFIX2 tzplatform_mkpath(TZ_SDK_HOME, "apps_rw") - struct sync_permit_rule { const char *name; - const char *regx; + char *regx; int mode; // 0:push, 1: pull, 2: push&push }; @@ -63,9 +60,19 @@ struct sync_permit_rule sdk_sync_permit_rule[] = { void init_sdk_sync_permit_rule_regx(void) { - asprintf(&sdk_sync_permit_rule[0].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); - asprintf(&sdk_sync_permit_rule[1].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/+(.)*\\.gcda$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); - asprintf(&sdk_sync_permit_rule[2].regx, "^(/tmp/da/)*+[a-zA-Z0-9_\\-\\.]{1,50}\\.png$"); + int ret; + ret = asprintf(&sdk_sync_permit_rule[0].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); + if(ret < 0) { + D("failed to run asprintf for unittest\n"); + } + ret = asprintf(&sdk_sync_permit_rule[1].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/+(.)*\\.gcda$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); + if (ret < 0) { + D("failed to run asprintf for codecoverage\n"); + } + ret = asprintf(&sdk_sync_permit_rule[2].regx, "^(/tmp/da/)*+[a-zA-Z0-9_\\-\\.]{1,50}\\.png$"); + if (ret < 0) { + D("failed to run asprintf for da\n"); + } } static void set_syncfile_smack_label(char *src) { @@ -285,11 +292,12 @@ static int fail_message(int s, const char *reason) static int fail_errno(int s) { - char buf[512]; + char* ret_str; + char buf[512]; - strerror_r(s, buf, sizeof(buf)); + ret_str = strerror_r(s, buf, sizeof(buf)); - return fail_message(s, buf); + return fail_message(s, (const char*)ret_str); } // FIXME: should get the following paths with api later but, do it for simple and not having dependency on other packages @@ -310,16 +318,16 @@ static void sync_mediadb(char *path) { } if (strstr(path, MEDIA_CONTENTS_PATH1) != NULL) { - char *arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH1, NULL}; - spawn(CMD_MEDIADB_UPDATE, arg_list); + const char * const arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH1, NULL}; + spawn(CMD_MEDIADB_UPDATE, (char * const*)arg_list); D("media db update done to %s\n", MEDIA_CONTENTS_PATH1); } else if (strstr(path, MEDIA_CONTENTS_PATH2) != NULL) { - char *arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH2, NULL}; - spawn(CMD_MEDIADB_UPDATE, arg_list); + const char * const arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH2, NULL}; + spawn(CMD_MEDIADB_UPDATE, (char * const*)arg_list); D("media db update done to %s\n", MEDIA_CONTENTS_PATH2); } else if (strstr(path, MEDIA_CONTENTS_PATH3) != NULL) { - char *arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH3, NULL}; - spawn(CMD_MEDIADB_UPDATE, arg_list); + const char * const arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH3, NULL}; + spawn(CMD_MEDIADB_UPDATE, (char * const*)arg_list); D("media db update done to %s\n", MEDIA_CONTENTS_PATH3); } return; @@ -475,7 +483,10 @@ static int do_send(int s, int noti_fd, char *path, char *buffer) { char *tmp; mode_t mode; - int is_link, ret; + int ret; +#ifdef HAVE_SYMLINKS + int is_link; +#endif // Check the capability for file push support. if(!is_support_push()) { @@ -488,9 +499,7 @@ static int do_send(int s, int noti_fd, char *path, char *buffer) *tmp = 0; errno = 0; mode = strtoul(tmp + 1, NULL, 0); -#ifndef HAVE_SYMLINKS - is_link = 0; -#else +#ifdef HAVE_SYMLINKS is_link = S_ISLNK(mode); #endif // extracts file permission from stat.mode. (ex 100644 & 0777 = 644); @@ -499,11 +508,15 @@ static int do_send(int s, int noti_fd, char *path, char *buffer) } if(!tmp || errno) { mode = 0644; // set default permission value in most of unix system. +#ifdef HAVE_SYMLINKS is_link = 0; +#endif } if (is_pkg_file_path(path)) { mode = 0644; +#ifdef HAVE_SYMLINKS is_link = 0; +#endif } // sdb does not allow to check that file exists or not. After deleting old file and creating new file again unconditionally. @@ -601,7 +614,7 @@ static int verify_sync_rule(const char* path) { } } regfree(®ex); - for (i = 0; i <= 3; i++){ + for (i=0; sdk_sync_permit_rule[i].regx != NULL; i++){ free(sdk_sync_permit_rule[i].regx); } return 0; diff --git a/src/sdb.c b/src/sdb.c index ac5f2ad..61b5bc4 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -92,7 +92,7 @@ static int is_support_sockproto(); void (*usb_init)() = NULL; void (*usb_cleanup)() = NULL; int (*usb_write)(usb_handle *h, const void *data, int len) = NULL; -int (*usb_read)(usb_handle *h, void *data, int len) = NULL; +int (*usb_read)(usb_handle *h, void *data, size_t len) = NULL; int (*usb_close)(usb_handle *h) = NULL; void (*usb_kick)(usb_handle *h) = NULL; @@ -128,7 +128,7 @@ void handle_sig_term(int sig) { if (access(SDB_PIDPATH, F_OK) == 0) sdb_unlink(SDB_PIDPATH); #endif - char *cmd1_args[] = {"/usr/bin/killall", "/usr/bin/debug_launchpad_preloading_preinitializing_daemon", NULL}; + 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); } @@ -1361,14 +1361,17 @@ static void *bootdone_cb(void *x) { char rule[MAX_LOCAL_BUFSZ]; GMainLoop *mainloop; +/* g_type_init() is deprecated for glib version 2.35.0 or greater, */ +#if !GLIB_CHECK_VERSION(2,35,0) g_type_init(); +#endif dbus_error_init(&error); bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); if (!bus) { D("Failed to connect to the D-BUS daemon: %s", error.message); dbus_error_free(&error); - return -1; + return NULL; } dbus_connection_setup_with_g_main(bus, NULL); @@ -1379,12 +1382,12 @@ static void *bootdone_cb(void *x) { if (dbus_error_is_set(&error)) { D("Fail to rule set: %s", error.message); dbus_error_free(&error); - return -1; + return NULL; } if (dbus_connection_add_filter(bus, __sdbd_dbus_signal_filter, NULL, NULL) == FALSE) - return -1; + return NULL; D("booting signal initialized\n"); mainloop = g_main_loop_new(NULL, FALSE); @@ -1392,7 +1395,7 @@ static void *bootdone_cb(void *x) { D("dbus loop exited"); - return 0; + return NULL; } void register_bootdone_cb() { @@ -1499,7 +1502,7 @@ int set_sdk_user_privileges() { } static void execute_required_process() { - char *cmd_args[] = {"/usr/bin/debug_launchpad_preloading_preinitializing_daemon",NULL}; + char * const cmd_args[] = {"/usr/bin/debug_launchpad_preloading_preinitializing_daemon",NULL}; spawn("/usr/bin/debug_launchpad_preloading_preinitializing_daemon", cmd_args); } diff --git a/src/sdb.h b/src/sdb.h index 21056b6..dd0fe23 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -521,7 +521,7 @@ int local_connect_arbitrary_ports(int console_port, int sdb_port, const char *d void usb_init(); void usb_cleanup(); int usb_write(usb_handle *h, const void *data, int len); -int usb_read(usb_handle *h, void *data, int len); +int usb_read(usb_handle *h, void *data, size_t len); int usb_close(usb_handle *h); void usb_kick(usb_handle *h); #else @@ -529,7 +529,7 @@ void usb_kick(usb_handle *h); extern void (*usb_init)(); extern void (*usb_cleanup)(); extern int (*usb_write)(usb_handle *h, const void *data, int len); -extern int (*usb_read)(usb_handle *h, void *data, int len); +extern int (*usb_read)(usb_handle *h, void *data, size_t len); extern int (*usb_close)(usb_handle *h); extern void (*usb_kick)(usb_handle *h); @@ -537,7 +537,7 @@ extern void (*usb_kick)(usb_handle *h); void ffs_usb_init(); void ffs_usb_cleanup(); int ffs_usb_write(usb_handle *h, const void *data, int len); -int ffs_usb_read(usb_handle *h, void *data, int len); +int ffs_usb_read(usb_handle *h, void *data, size_t len); int ffs_usb_close(usb_handle *h); void ffs_usb_kick(usb_handle *h); @@ -545,7 +545,7 @@ void ffs_usb_kick(usb_handle *h); void linux_usb_init(); void linux_usb_cleanup(); int linux_usb_write(usb_handle *h, const void *data, int len); -int linux_usb_read(usb_handle *h, void *data, unsigned len); +int linux_usb_read(usb_handle *h, void *data, size_t len); int linux_usb_close(usb_handle *h); void linux_usb_kick(usb_handle *h); diff --git a/src/sdktools.c b/src/sdktools.c index f24bccc..7780101 100644 --- a/src/sdktools.c +++ b/src/sdktools.c @@ -32,10 +32,10 @@ struct sudo_command root_commands[] = { } }, /* end */ - { NULL, NULL, NULL } + { NULL, NULL, {NULL} } }; -static struct command_suffix +struct command_suffix { const char *name; // comments for human const char *suffix; //pattern diff --git a/src/sdktools.h b/src/sdktools.h index 50b68de..9027970 100644 --- a/src/sdktools.h +++ b/src/sdktools.h @@ -26,7 +26,7 @@ struct arg_permit_rule #define SDK_LAUNCH_PATH "/usr/sbin/sdk_launch" #define APP_INSTALL_PATH_PREFIX1 tzplatform_getenv(TZ_SYS_RW_APP) -#define APP_INSTALL_PATH_PREFIX2 tzplatform_getenv(TZ_USER_APP) +#define APP_INSTALL_PATH_PREFIX2 tzplatform_mkpath(TZ_SDK_HOME, "apps_rw") #define DEV_INSTALL_PATH_PREFIX tzplatform_getenv(TZ_SDK_TOOLS) #define GDBSERVER_PATH tzplatform_mkpath(TZ_SDK_TOOLS,"gdbserver/gdbserver") #define GDBSERVER_PLATFORM_PATH tzplatform_mkpath(TZ_SDK_TOOLS,"gdbserver-platform/gdbserver") diff --git a/src/services.c b/src/services.c index 9607462..dc19c14 100644 --- a/src/services.c +++ b/src/services.c @@ -387,7 +387,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) #if !SDB_HOST -static void redirect_and_exec(int pts, const char *cmd, const char *argv[], const char *envp[]) +static void redirect_and_exec(int pts, const char *cmd, char * const argv[], char * const envp[]) { dup2(pts, 0); dup2(pts, 1); @@ -398,7 +398,7 @@ static void redirect_and_exec(int pts, const char *cmd, const char *argv[], cons execve(cmd, argv, envp); } -static int create_subprocess(const char *cmd, pid_t *pid, const char *argv[], const char *envp[]) +static int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * const envp[]) { char devname[64]; int ptm; @@ -517,7 +517,6 @@ static void get_env(char *key, char **env) { FILE *fp; char buf[1024]; - int i; char *s, *e, *value; fp = fopen (LOGIN_CONFIG, "r"); @@ -641,7 +640,7 @@ static int create_subproc_thread(const char *name, int lines, int columns) }; args[2] = new_cmd; - ret_fd = create_subprocess(SHELL_COMMAND, &pid, args, envp); + ret_fd = create_subprocess(SHELL_COMMAND, &pid, (char * const*)args, (char * const*)envp); free(new_cmd); } else { // in case of shell interactively // Check the capability for interactive shell support. @@ -650,12 +649,12 @@ static int create_subproc_thread(const char *name, int lines, int columns) return -1; } - char *args[] = { + char * const args[] = { SHELL_COMMAND, "-", NULL, }; - ret_fd = create_subprocess(SHELL_COMMAND, &pid, args, envp); + ret_fd = create_subprocess(SHELL_COMMAND, &pid, (char * const*)args, (char * const*)envp); #if 0 // FIXME: should call login command instead of /bin/sh if (should_drop_privileges()) { char *args[] = { @@ -950,7 +949,6 @@ static void sync_windowsize(int fd, void *cookie) { const unsigned COMMAND_TIMEOUT = 10000; void get_boot(int fd, void *cookie) { char buf[2] = { 0, }; - char *mode = (char*) cookie; int time = 0; int interval = 1000; while (time < COMMAND_TIMEOUT) { @@ -1076,7 +1074,7 @@ int service_to_fd(const char *name) } } else if(!strncmp(name, "shellconf:", 10)){ if(!strncmp(name+10, "syncwinsz:", 10)){ - ret = create_service_thread(sync_windowsize, name+20); + ret = create_service_thread(sync_windowsize, (void *)name+20); } } diff --git a/src/transport.c b/src/transport.c index c4b64d7..a697eee 100644 --- a/src/transport.c +++ b/src/transport.c @@ -524,7 +524,7 @@ static int transport_read_action(int fd, struct tmsg* m) { char *p = (char*)m; - int len = sizeof(*m); + size_t len = sizeof(*m); int r; while(len > 0) { @@ -546,7 +546,7 @@ static int transport_write_action(int fd, struct tmsg* m) { char *p = (char*)m; - int len = sizeof(*m); + size_t len = sizeof(*m); int r; while(len > 0) { @@ -745,7 +745,6 @@ atransport *acquire_one_transport(int state, transport_type ttype, const char* s { atransport *t; atransport *result = NULL; - int ambiguous = 0; if (error_out) *error_out = "device not found"; @@ -769,7 +768,6 @@ atransport *acquire_one_transport(int state, transport_type ttype, const char* s if (result) { if (error_out) *error_out = "more than one device"; - ambiguous = 1; result = NULL; break; } @@ -778,7 +776,6 @@ atransport *acquire_one_transport(int state, transport_type ttype, const char* s if (result) { if (error_out) *error_out = "more than one emulator"; - ambiguous = 1; result = NULL; break; } @@ -787,7 +784,6 @@ atransport *acquire_one_transport(int state, transport_type ttype, const char* s if (result) { if (error_out) *error_out = "more than one device and emulator"; - ambiguous = 1; result = NULL; break; } @@ -1058,9 +1054,9 @@ int readx(int fd, void *ptr, size_t len) char *p = ptr; int r; #if SDB_TRACE - int len0 = len; + size_t len0 = len; #endif - D("readx: fd=%d wanted=%d\n", fd, (int)len); + D("readx: fd=%d wanted=%d\n", fd, len); while(len > 0) { r = sdb_read(fd, p, len); if(r > 0) { @@ -1091,7 +1087,7 @@ int writex(int fd, const void *ptr, size_t len) int r; #if SDB_TRACE - D("writex: fd=%d len=%d: ", fd, (int)len); + D("writex: fd=%d len=%d: ", fd, len); dump_hex( ptr, len ); #endif while(len > 0) { diff --git a/src/transport_local.c b/src/transport_local.c index 1daa143..527e1f5 100644 --- a/src/transport_local.c +++ b/src/transport_local.c @@ -415,85 +415,6 @@ static const char _ok_resp[] = "ok"; #endif // !SDB_HOST #endif -/*! - * static int send_msg_to_host_from_guest(const char *hostname, int host_port, char *request, int sock_type) - * @brief Sends \c request to host using specified protocol - * - * @param hostname Hostname -- could be domain name or IP - * @param host_port Host port - * @param request Message to be sent to host - * @param protocol IP protocol to be used: IPPROTO_TCP or IPPROTO_UDP - * - * @returns 0 on success, -1 otherwise - * - * @note SOCK_STREAM will be used for IPPROTO_TCP as socket type - * and SOCK_DGRAM for IPPROTO_UDP - */ -static int send_msg_to_host_from_guest(const char *hostname, int host_port, char *request, int protocol) { - int sock = -1; - int PORT_SIZE = 32; - char port[PORT_SIZE]; /* string decimal representation for getaddrinfo */ - struct addrinfo hints = {0}; - struct addrinfo *addresses, *curr_addr; - int getaddr_ret; - const char *protocol_name = "unknown"; /* for debug message */ - - switch(protocol) { - case IPPROTO_TCP: - protocol_name = "tcp"; - hints.ai_socktype = SOCK_STREAM; - break; - case IPPROTO_UDP: - protocol_name = "udp"; - hints.ai_socktype = SOCK_DGRAM; - break; - default: - D("unsupported protocol: %d", protocol); - return -1; - } - - D("try to send notification to host(%s:%d) using %s:[%s]\n", hostname, host_port, protocol_name, request); - - hints.ai_family = AF_INET; - - snprintf(port, PORT_SIZE, "%d", host_port); - getaddr_ret = getaddrinfo(hostname, port, &hints, &addresses); - - if (getaddr_ret != 0) { - D("could not resolve %s\n", hostname); - return -1; - } - - for(curr_addr = addresses; curr_addr != NULL; curr_addr = curr_addr->ai_next) { - sock = socket(curr_addr->ai_family, curr_addr->ai_socktype, curr_addr->ai_protocol); - if (sock == -1) - continue; - - if (connect(sock, curr_addr->ai_addr, curr_addr->ai_addrlen) != -1) - break; /* Success */ - - sdb_close(sock); - } - - if(curr_addr == NULL) { /* No address succeeded */ - freeaddrinfo(addresses); - D("could not connect to server\n"); - return -1; - } - - freeaddrinfo(addresses); - - if (sdb_write(sock, request, strlen(request)) < 0) { - D("could not send notification request to host\n"); - sdb_close(sock); - return -1; - } - sdb_close(sock); - D("sent notification request to host\n"); - - return 0; -} - int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen, int nsec) { int flags, n, error; @@ -588,7 +509,7 @@ static int send_msg_to_localhost_from_guest(const char *host_ip, int local_port, } // send the "emulator" request to sdbserver -static void notify_sdbd_startup_thread() { +static void* notify_sdbd_startup_thread(void* ptr) { char buffer[512]; char request[512]; @@ -605,11 +526,11 @@ static void notify_sdbd_startup_thread() { int time = 0; //int try_limit_time = -1; // try_limit_time < 0 if unlimited if (sensors_port < 0 || emulator_port < 0 || r < 0) { - return; + return NULL; } if (get_emulator_hostip(host_ip, sizeof host_ip) == -1) { D("failed to get emulator host ip\n"); - return; + return NULL; } // XXX: Known issue - log collision while (1) { diff --git a/src/usb_funcfs_client.c b/src/usb_funcfs_client.c index ef28284..75d90aa 100644 --- a/src/usb_funcfs_client.c +++ b/src/usb_funcfs_client.c @@ -297,7 +297,7 @@ static int read_control(struct usb_handle *usb) /* Read events from control endpoint Fortunately, FunctionFS guarantees reading of full event (or nothing), so we're not bothered with ret < sizeof(read_event) */ - ret = sdb_read(usb->control, &read_event, sizeof(read_event)); + ret = sdb_read(usb->control, (void *)&read_event, sizeof(read_event)); if (ret < 0) { /* EAGAIN support will be useful, when non-blocking ep0 reads are supported in FunctionFS */ @@ -548,7 +548,7 @@ int ffs_usb_write(usb_handle *h, const void *data, int len) * * @returns 0 on success and -1 on failure (errno is set) */ -int ffs_usb_read(usb_handle *h, void *data, int len) +int ffs_usb_read(usb_handle *h, void *data, size_t len) { int n; diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 8d12ea7..fc3596f 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -171,7 +171,7 @@ usb_write(struct usb_handle *uh, const void *_data, int len) } int -usb_read(struct usb_handle *uh, void *_data, int len) +usb_read(struct usb_handle *uh, void *_data, size_t len) { unsigned char *data = (unsigned char*) _data; int n; diff --git a/src/usb_linux.c b/src/usb_linux.c index d7e8399..95f2ee9 100644 --- a/src/usb_linux.c +++ b/src/usb_linux.c @@ -454,7 +454,7 @@ int usb_write(usb_handle *h, const void *_data, int len) return 0; } -int usb_read(usb_handle *h, void *_data, int len) +int usb_read(usb_handle *h, void *_data, size_t len) { unsigned char *data = (unsigned char*) _data; int n; diff --git a/src/usb_linux_client.c b/src/usb_linux_client.c index d2af0c4..ec8c159 100644 --- a/src/usb_linux_client.c +++ b/src/usb_linux_client.c @@ -94,7 +94,7 @@ int linux_usb_write(usb_handle *h, const void *data, int len) return 0; } -int linux_usb_read(usb_handle *h, void *data, unsigned len) +int linux_usb_read(usb_handle *h, void *data, size_t len) { int n; diff --git a/src/utils.c b/src/utils.c index ae7d51d..acf8c5a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -151,7 +151,7 @@ char *str_trim(char *str) { return str; } -int spawn(char* program, char** arg_list) +int spawn(const char* program, char* const arg_list[]) { pid_t pid; int ret; @@ -167,7 +167,7 @@ int spawn(char* program, char** arg_list) // init takes the process, and the process is not able to be zombie exit(0); } - execvp (program, arg_list); + execvp(program, arg_list); fprintf(stderr, "failed to spawn: never reach here!:%s\n", program); exit(0); } diff --git a/src/utils.h b/src/utils.h index 11a63c8..ce17442 100644 --- a/src/utils.h +++ b/src/utils.h @@ -72,7 +72,7 @@ char *str_trim(char* string); * spawn a process and returns the process id of the new spawned process. * it is working as async. */ -int spawn(char* program, char** arg_list); +int spawn(const char* program, char * const arg_list[]); char** str_split(char* a_str, const char a_delim); -- 2.7.4 From 7c2595d0822b22221af68a47be06e5691fbedf20 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Tue, 26 Apr 2016 20:57:37 +0900 Subject: [PATCH 08/16] Fixed a bug where sdbd shows incorrect error message Change-Id: I1107e20525547327f7f97431c581c647aa6570d9 Signed-off-by: shingil.kang --- src/file_sync_service.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/file_sync_service.c b/src/file_sync_service.c index d142ff1..5fc6642 100644 --- a/src/file_sync_service.c +++ b/src/file_sync_service.c @@ -276,12 +276,13 @@ done: static int fail_message(int s, const char *reason) { syncmsg msg; - int len = strlen(reason); + size_t len = strlen(reason); D("sync: failure: %s\n", reason); msg.data.id = ID_FAIL; msg.data.size = htoll(len); + if(writex(s, &msg.data, sizeof(msg.data)) || writex(s, reason, len)) { return -1; @@ -290,14 +291,14 @@ static int fail_message(int s, const char *reason) } } -static int fail_errno(int s) +static int fail_errno(int fd, int err_no) { char* ret_str; - char buf[512]; + char buf[512] = {0, }; - ret_str = strerror_r(s, buf, sizeof(buf)); + ret_str = strerror_r(err_no, buf, sizeof(buf)); - return fail_message(s, (const char*)ret_str); + return fail_message(fd, (const char*)ret_str); } // FIXME: should get the following paths with api later but, do it for simple and not having dependency on other packages @@ -348,7 +349,7 @@ static int handle_send_file(int s, int noti_fd, char *path, mode_t mode, char *b fd = sdb_open_mode(path, O_WRONLY, mode); } if(fd < 0) { - if(fail_errno(s)) + if(fail_errno(s, errno)) return -1; fd = -1; } @@ -385,7 +386,7 @@ static int handle_send_file(int s, int noti_fd, char *path, mode_t mode, char *b sdb_unlink(path); fd = -1; errno = saved_errno; - if(fail_errno(s)) return -1; + if(fail_errno(s, errno)) return -1; } } @@ -446,7 +447,7 @@ static int handle_send_link(int s, int noti_fd, char *path, char *buffer) ret = symlink(buffer, path); } if(ret) { - fail_errno(s); + fail_errno(s, errno); return -1; } @@ -556,7 +557,7 @@ static int do_recv(int s, const char *path, char *buffer) fd = sdb_open(path, O_RDONLY); if(fd < 0) { - if(fail_errno(s)) return -1; + if(fail_errno(s, errno)) return -1; return 0; } @@ -566,7 +567,7 @@ static int do_recv(int s, const char *path, char *buffer) if(r <= 0) { if(r == 0) break; if(errno == EINTR) continue; - r = fail_errno(s); + r = fail_errno(s, errno); sdb_close(fd); return r; } -- 2.7.4 From 7d6427a05082be14e01e0620d2955300e392925a Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Wed, 27 Apr 2016 14:51:55 +0900 Subject: [PATCH 09/16] Modify the sdk groups routine for sdb shell/sync service. - Add the groups for sdbd shell/sync default group. ("priv_externalstorage", "priv_externalstorage_appdata", "priv_mediastorage") - Modify the sdk group init routine that receives group infomation from platform. Change-Id: I7273df2e05f65a62953e7e4f6003e3bc928aaae4 Signed-off-by: Kim Gunsoo --- src/sdb.c | 115 ++++++++++++++++++++++++++++++++++++++++---------------------- src/sdb.h | 3 ++ 2 files changed, 77 insertions(+), 41 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index 61b5bc4..793d8ec 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -77,7 +77,13 @@ struct group_info const char *name; gid_t gid; }; -struct group_info g_default_groups[] = { {"log", -1}, {NULL, -1}}; +struct group_info g_default_groups[] = { + {"priv_externalstorage", -1}, + {"priv_externalstorage_appdata", -1}, + {"priv_mediastorage", -1}, + {"log", -1}, + {NULL, -1} +}; #define SDB_DEFAULT_GROUPS_CNT ((sizeof(g_default_groups)/sizeof(g_default_groups[0]))-1) int is_init_sdk_userinfo = 0; @@ -1435,7 +1441,7 @@ static int sdbd_set_groups() { break; } } - if (group_match == 0) { + if (group_match == 0 && g_default_groups[i].gid != -1) { group_ids[ngroups + added_group_cnt] = g_default_groups[i].gid; added_group_cnt ++; } @@ -1462,7 +1468,25 @@ static int sdbd_get_user_pwd(const char* user_name, struct passwd* pwd, char* bu D("Not found passwd : username(%s)\n", user_name); } else { errno = ret; - D("failed to getpwuid_r\n"); + D("failed to getpwnam_r\n"); + } + return -1; + } + + return 0; +} + +static int sdbd_get_group(const char* group_name, struct group* grp, char* buf, size_t bufsize) { + struct group *result = NULL; + int ret = 0; + + ret = getgrnam_r(group_name, grp, buf, bufsize, &result); + if (result == NULL) { + if (ret == 0) { + D("Not found group : groupname(%s)\n", group_name); + } else { + errno = ret; + D("failed to getgrnam_r\n"); } return -1; } @@ -1478,26 +1502,25 @@ int set_sdk_user_privileges() { if (sdbd_set_groups() < 0) { D("set groups failed (errno: %d)\n", errno); - return -1; } if (setgid(g_sdk_group_id) != 0) { D("set group id failed (errno: %d)\n", errno); - return -1; } if (setuid(g_sdk_user_id) != 0) { D("set user id failed (errno: %d)\n", errno); - return -1; } if (chdir(g_sdk_home_dir) < 0) { D("unable to change working directory to %s\n", g_sdk_home_dir); - return -1; } // TODO: use pam later - putenv(g_sdk_home_dir_env); + if (g_sdk_home_dir_env) { + putenv(g_sdk_home_dir_env); + } + return 0; } @@ -1721,38 +1744,48 @@ static void load_sdbd_plugin() { D("using sdbd plugin interface.(%s)\n", SDBD_PLUGIN_PATH); } +#define SDB_PW_GR_DEFAULT_SIZE (16*1024) static long get_passwd_bufsize() { long bufsize = 0; bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); if(bufsize < 0) { - bufsize = (16*1024); + bufsize = SDB_PW_GR_DEFAULT_SIZE; + } + + return bufsize; +} + +static long get_group_bufsize() { + long bufsize = 0; + + bufsize = sysconf(_SC_GETGR_R_SIZE_MAX); + if(bufsize < 0) { + bufsize = SDB_PW_GR_DEFAULT_SIZE; } return bufsize; } static int init_sdb_default_groups() { - struct passwd pwd; + struct group grp; char *buf = NULL; long bufsize = 0; int i = 0; - bufsize = get_passwd_bufsize(); + bufsize = get_group_bufsize(); buf = malloc(bufsize); if (buf == NULL) { - D("failed to allocate passwd buf(%ld)\n", bufsize); + D("failed to allocate gruop buf(%ld)\n", bufsize); return -1; } for (i = 0; g_default_groups[i].name != NULL; i++) { memset(buf, 0, bufsize); - if (sdbd_get_user_pwd(g_default_groups[i].name, &pwd, buf, bufsize) == 0) { - g_default_groups[i].gid = pwd.pw_gid; + if (sdbd_get_group(g_default_groups[i].name, &grp, buf, bufsize) == 0) { + g_default_groups[i].gid = grp.gr_gid; } else { - D("get user passwd info.(errno: %d)\n", errno); - free(buf); - return -1; + D("failed get group info.(errno: %d)\n", errno); } } @@ -1760,6 +1793,12 @@ static int init_sdb_default_groups() { return 0; } +static void set_static_userinfo() { + g_sdk_user_id = STATIC_SDK_USER_ID; + g_sdk_group_id = STATIC_SDK_GROUP_ID; + g_sdk_home_dir = STATIC_SDK_HOME_DIR; +} + static int init_sdk_userinfo() { struct passwd pwd; char *buf = NULL; @@ -1769,42 +1808,36 @@ static int init_sdk_userinfo() { return 0; } + if (init_sdb_default_groups() < 0) { + D("failed to initialize default groups.\n"); + } + bufsize = get_passwd_bufsize(); buf = malloc(bufsize); if (buf == NULL) { D("failed to allocate passwd buf(%ld)\n", bufsize); - return -1; - } + set_static_userinfo(); + } else { + if (sdbd_get_user_pwd(SDK_USER_NAME, &pwd, buf, bufsize) < 0) { + D("get user passwd info.(errno: %d)\n", errno); + set_static_userinfo(); + } else { + D("username=%s, uid=%d, gid=%d, dir=%s\n", pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_dir); - if (sdbd_get_user_pwd(SDK_USER_NAME, &pwd, buf, bufsize) < 0) { - D("get user passwd info.(errno: %d)\n", errno); + g_sdk_user_id = pwd.pw_uid; + g_sdk_group_id = pwd.pw_gid; + g_sdk_home_dir = strdup(pwd.pw_dir); + } free(buf); - return -1; - } - D("username=%s, uid=%d, gid=%d, dir=%s\n", pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_dir); - - g_sdk_user_id = pwd.pw_uid; - g_sdk_group_id = pwd.pw_gid; - g_sdk_home_dir = strdup(pwd.pw_dir); - - free(buf); - - if (init_sdb_default_groups() < 0) { - D("failed to initialize default groups.\n"); - free(g_sdk_home_dir); - g_sdk_home_dir = NULL; - return -1; } int env_size = strlen("HOME=") + strlen(g_sdk_home_dir) + 1; g_sdk_home_dir_env = malloc(env_size); - if(g_sdk_home_dir_env == 0) { + if(g_sdk_home_dir_env == NULL) { D("failed to allocate for home dir env string\n"); - free(g_sdk_home_dir); - g_sdk_home_dir = NULL; - return -1; + } else { + snprintf(g_sdk_home_dir_env, env_size, "HOME=%s", g_sdk_home_dir); } - snprintf(g_sdk_home_dir_env, env_size, "HOME=%s", g_sdk_home_dir); is_init_sdk_userinfo = 1; return 0; diff --git a/src/sdb.h b/src/sdb.h index dd0fe23..7e3d1f1 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -385,6 +385,9 @@ int booting_done; // 0: platform booting is in progess 1: platform booting is do #define SDK_USER_NAME tzplatform_getenv(TZ_SDK_USER_NAME) #define SDK_TOOL_PATH tzplatform_getenv(TZ_SDK_TOOLS) +#define STATIC_SDK_USER_ID 5001 +#define STATIC_SDK_GROUP_ID 100 +#define STATIC_SDK_HOME_DIR "/home/owner" extern uid_t g_sdk_user_id; extern gid_t g_sdk_group_id; extern char* g_sdk_home_dir; -- 2.7.4 From 7dff08909ee26b253d7465803ae2820783e87cb3 Mon Sep 17 00:00:00 2001 From: "yoonki.park" Date: Tue, 10 May 2016 17:37:32 +0900 Subject: [PATCH 10/16] Added to check validation of pointer - If packet pointer has invalid address then restart SDBD. Change-Id: Ieff9343bba35dcfe5122c18ddea60eec615bac76 Signed-off-by: shingil.kang --- packaging/sdbd.spec | 2 +- packaging/sdbd_device.service | 2 +- src/fdevent.c | 2 +- src/sdb.c | 7 +++++++ src/transport.c | 8 ++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index a05aff7..826c4f0 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.10 +Version: 3.0.11 Release: 0 License: Apache-2.0 Summary: SDB daemon diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service index e83b1f7..4fe803f 100644 --- a/packaging/sdbd_device.service +++ b/packaging/sdbd_device.service @@ -7,7 +7,7 @@ After=tmp.mount Type=forking EnvironmentFile=-/run/tizen-system-env PIDFile=/tmp/.sdbd.pid -RemainAfterExit=yes +Restart=on-failure ExecStart=/usr/sbin/sdbd [Install] diff --git a/src/fdevent.c b/src/fdevent.c index ca1bf3c..2e8a45a 100644 --- a/src/fdevent.c +++ b/src/fdevent.c @@ -50,7 +50,7 @@ static void fatal(const char *fn, const char *fmt, ...) fprintf(stderr, "%s:", fn); vfprintf(stderr, fmt, ap); va_end(ap); - abort(); + exit(-1); } #define FATAL(x...) fatal(__FUNCTION__, x) diff --git a/src/sdb.c b/src/sdb.c index 793d8ec..1fbd885 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -630,6 +630,13 @@ void parse_banner(char *banner, atransport *t) void handle_packet(apacket *p, atransport *t) { + // 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); + } + asocket *s; D("handle_packet() %c%c%c%c\n", ((char*) (&(p->msg.command)))[0], diff --git a/src/transport.c b/src/transport.c index a697eee..1fe4b9d 100644 --- a/src/transport.c +++ b/src/transport.c @@ -323,6 +323,14 @@ static void *input_thread(void *_t) t->serial, t->fd ); break; } + + // 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); + } + if(p->msg.command == A_SYNC){ if(p->msg.arg0 == 0) { D("%s: transport SYNC offline\n", t->serial); -- 2.7.4 From 98350bb2861dd178c159f3ab00310d77038942c0 Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Mon, 18 Apr 2016 13:21:57 +0900 Subject: [PATCH 11/16] Change the routine for determining whether the emulator or device. - Determined to look at kernel parameters that includes the vm_name in case of emulator. Change-Id: I06734a63eb3afcb9b9638bc1044275e5291fc5eb Signed-off-by: Kim Gunsoo --- src/sdb.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index 1fbd885..4f9040b 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -102,11 +102,18 @@ int (*usb_read)(usb_handle *h, void *data, size_t len) = NULL; int (*usb_close)(usb_handle *h) = NULL; void (*usb_kick)(usb_handle *h) = NULL; +int g_is_emulator = -1; int is_emulator(void) { #if SDB_HOST - return 0; + return 0; #else - return sdbd_commandline_args.emulator.host != NULL; + if (g_is_emulator >= 0) { + return g_is_emulator; + } else { + D("failed to initialize check emulator\n"); + } + + return sdbd_commandline_args.emulator.host != NULL; #endif } @@ -2112,9 +2119,33 @@ static int is_support_sockproto() return (!strncmp(g_capabilities.sockproto_support, SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED))); } +#define EMULATOR_MODEL_NAME "Emulator" +static check_emulator_or_device() +{ + char model_name[256]={0,}; + int ret = -1; + + // Get the model name from model_config.xml + ret = get_device_name(model_name, sizeof model_name); + if (ret == 0) { + if(!strncmp(model_name, EMULATOR_MODEL_NAME, sizeof(EMULATOR_MODEL_NAME))){ + g_is_emulator = 1; + D("This target type is Emulator\n"); + } else { + g_is_emulator = 0; + D("This target type is Device\n"); + } + } else { + g_is_emulator = -1; + D("failed to get the model name.\n"); + } +} + int sdb_main(int is_daemon, int server_port) { #if !SDB_HOST + check_emulator_or_device(); + load_sdbd_plugin(); init_capabilities(); -- 2.7.4 From c0cc4c69e65107bb2b0f955c2589ca53551c6940 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Wed, 27 Apr 2016 17:43:11 +0900 Subject: [PATCH 12/16] Modify modules that need root permission. - Removed to permit root permission for push/pull(unitest, codecoverage, DA) - Changed uid/gid of SDBD into sdk Change-Id: Idd874377159afa3d387c9abb59aada2a9d34dbc3 Signed-off-by: shingil.kang --- packaging/sdbd.spec | 2 +- packaging/sdbd_device.service | 2 ++ packaging/sdbd_emulator.service | 2 ++ src/file_sync_service.c | 64 +---------------------------------------- 4 files changed, 6 insertions(+), 64 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 826c4f0..6e1ba42 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.11 +Version: 3.0.12 Release: 0 License: Apache-2.0 Summary: SDB daemon diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service index 4fe803f..5aaac68 100644 --- a/packaging/sdbd_device.service +++ b/packaging/sdbd_device.service @@ -4,6 +4,8 @@ Requires=tizen-system-env.service After=tmp.mount [Service] +User=sdk +Group=sdk Type=forking EnvironmentFile=-/run/tizen-system-env PIDFile=/tmp/.sdbd.pid diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service index 1a2f298..01d3d04 100644 --- a/packaging/sdbd_emulator.service +++ b/packaging/sdbd_emulator.service @@ -5,6 +5,8 @@ After=tmp.mount dbus.service #DefaultDependencies=false [Service] +User=sdk +Group=sdk Type=forking Environment=DISPLAY=:0 PIDFile=/tmp/.sdbd.pid diff --git a/src/file_sync_service.c b/src/file_sync_service.c index 5fc6642..c15ae10 100644 --- a/src/file_sync_service.c +++ b/src/file_sync_service.c @@ -39,42 +39,11 @@ #define SYNC_TIMEOUT 15 -struct sync_permit_rule -{ - const char *name; - char *regx; - int mode; // 0:push, 1: pull, 2: push&push -}; - -struct sync_permit_rule sdk_sync_permit_rule[] = { - /* 0 */ {"unitest", "", 1}, - /* 1 */ {"codecoverage", "", 1}, - /* 2 */ {"da", "", 1}, - /* end */ {NULL, NULL, 0} -}; - /* The typical default value for the umask is S_IWGRP | S_IWOTH (octal 022). * Before use the DIR_PERMISSION, the process umask value should be set 0 using umask(). */ #define DIR_PERMISSION 0777 -void init_sdk_sync_permit_rule_regx(void) -{ - int ret; - ret = asprintf(&sdk_sync_permit_rule[0].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); - if(ret < 0) { - D("failed to run asprintf for unittest\n"); - } - ret = asprintf(&sdk_sync_permit_rule[1].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/+(.)*\\.gcda$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); - if (ret < 0) { - D("failed to run asprintf for codecoverage\n"); - } - ret = asprintf(&sdk_sync_permit_rule[2].regx, "^(/tmp/da/)*+[a-zA-Z0-9_\\-\\.]{1,50}\\.png$"); - if (ret < 0) { - D("failed to run asprintf for da\n"); - } -} - static void set_syncfile_smack_label(char *src) { char *label_transmuted = NULL; char *label = NULL; @@ -589,37 +558,6 @@ static int do_recv(int s, const char *path, char *buffer) return 0; } -static int verify_sync_rule(const char* path) { - regex_t regex; - int ret; - char buf[PATH_MAX]; - int i=0; - - init_sdk_sync_permit_rule_regx(); - for (i=0; sdk_sync_permit_rule[i].regx != NULL; i++) { - ret = regcomp(®ex, sdk_sync_permit_rule[i].regx, REG_EXTENDED); - if(ret){ - return 0; - } - // execute regular expression - ret = regexec(®ex, path, 0, NULL, 0); - if(!ret){ - regfree(®ex); - D("found matched rule(%s) from %s path\n", sdk_sync_permit_rule[i].name, path); - return 1; - } else if( ret == REG_NOMATCH ){ - // do nothin - } else{ - regerror(ret, ®ex, buf, sizeof(buf)); - D("regex match failed(%s): %s\n",sdk_sync_permit_rule[i].name, buf); - } - } - regfree(®ex); - for (i=0; sdk_sync_permit_rule[i].regx != NULL; i++){ - free(sdk_sync_permit_rule[i].regx); - } - return 0; -} void file_sync_service(int fd, void *cookie) { @@ -684,7 +622,7 @@ void file_sync_service(int fd, void *cookie) D("sync: '%s' '%s'\n", (char*) &msg.req, name); - if (should_drop_privileges() && !verify_sync_rule(name)) { + if (should_drop_privileges()) { set_sdk_user_privileges(); } -- 2.7.4 From 7038519e1a244ae6d26ac00ec520b211ad62e085 Mon Sep 17 00:00:00 2001 From: Kim Gunsoo Date: Wed, 25 May 2016 13:18:15 +0900 Subject: [PATCH 13/16] Fixed SVACE issue. - Invalid function definition. Change-Id: I9b3367185add114459359d25422985ab9599d4c7 Signed-off-by: Kim Gunsoo --- src/sdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdb.c b/src/sdb.c index 4f9040b..4c3009f 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -2120,7 +2120,7 @@ static int is_support_sockproto() } #define EMULATOR_MODEL_NAME "Emulator" -static check_emulator_or_device() +static void check_emulator_or_device() { char model_name[256]={0,}; int ret = -1; -- 2.7.4 From ff03cf6d6131893619b03875c15b5039901dcd32 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Thu, 26 May 2016 17:11:31 +0900 Subject: [PATCH 14/16] Added sdbd service to emulator_preinit.target - Sdbd needs to be booted early for debugging. - Moved the target of sdbd service to emulator_preinit.target from emulator.target Change-Id: I55708052dd8b831684a0a83139935cd14e96af98 Signed-off-by: shingil.kang --- packaging/sdbd.spec | 8 ++++---- packaging/sdbd_emulator.service | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 826c4f0..6a3da0b 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.11 +Version: 3.0.12 Release: 0 License: Apache-2.0 Summary: SDB daemon @@ -59,8 +59,8 @@ mkdir -p %{buildroot}%{_libdir}/systemd/system mkdir -p %{buildroot}%{_unitdir} %ifarch %{ix86} install -m 0644 %SOURCE1002 %{buildroot}%{_libdir}/systemd/system/sdbd.service -mkdir -p %{buildroot}/%{_libdir}/systemd/system/emulator.target.wants -ln -s %{_libdir}/systemd/system/sdbd.service %{buildroot}/%{_libdir}/systemd/system/emulator.target.wants/ +mkdir -p %{buildroot}/%{_libdir}/systemd/system/emulator_preinit.target.wants +ln -s %{_libdir}/systemd/system/sdbd.service %{buildroot}/%{_libdir}/systemd/system/emulator_preinit.target.wants/ %else install -m 0644 %SOURCE1001 %{buildroot}%{_unitdir}/sdbd.service install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.service @@ -94,7 +94,7 @@ fi %attr(0755, root, root) %{_sysconfdir}/init.d/sdbd %{_unitdir}/sdbd.service %ifarch %{ix86} -%{_libdir}/systemd/system/emulator.target.wants/sdbd.service +%{_libdir}/systemd/system/emulator_preinit.target.wants/sdbd.service %else %{_unitdir}/sdbd_tcp.service %{_libdir}/systemd/system/multi-user.target.wants/sdbd.service diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service index 1a2f298..3db25cf 100644 --- a/packaging/sdbd_emulator.service +++ b/packaging/sdbd_emulator.service @@ -14,5 +14,5 @@ SmackProcessLabel=User ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`" [Install] -WantedBy=emulator.target +WantedBy=emulator_preinit.target -- 2.7.4 From 935e0b600c01ef6c81e22053453fe32e2c53995c Mon Sep 17 00:00:00 2001 From: Taeyoung Kim Date: Thu, 26 May 2016 14:27:32 +0900 Subject: [PATCH 15/16] sdb: change group and owner of sdb device node - The owner and group of sdbd are changed from "root "to "sdk". Thus the udev rule is changed for it. - Previous: bash-3.2# ls -alZ /dev/samsung_sdb crw------- 1 root root * 10, 15 Jan 1 23:41 /dev/samsung_sdb bash-3.2# - Now: bash-3.2# ls -alZ /dev/samsung_sdb crw-rw---- 1 sdk sdk * 10, 15 Jan 2 04:09 /dev/samsung_sdb bash-3.2# Change-Id: Ifef41987d391bc544cd8792fc21458624306ce29 Signed-off-by: Taeyoung Kim --- packaging/sdbd.spec | 8 +++++++- rules/99-sdbd.rules | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 rules/99-sdbd.rules diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 6a3da0b..22f6be6 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.12 +Version: 3.0.13 Release: 0 License: Apache-2.0 Summary: SDB daemon @@ -74,6 +74,11 @@ install -m 755 script/sdk_launch %{buildroot}%{_prefix}/sbin/ mkdir -p %{buildroot}%{TZ_SYS_BIN} install -m 755 script/profile_command %{buildroot}%{TZ_SYS_BIN}/ +%ifnarch %{ix86} +mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d/ +install -m 644 rules/99-sdbd.rules %{buildroot}%{_prefix}/lib/udev/rules.d/ +%endif + %post . %{_sysconfdir}/tizen-platform.conf if ! getent passwd "${TZ_SDK_USER_NAME}" > /dev/null; then @@ -98,6 +103,7 @@ fi %else %{_unitdir}/sdbd_tcp.service %{_libdir}/systemd/system/multi-user.target.wants/sdbd.service +%{_prefix}/lib/udev/rules.d/99-sdbd.rules %endif /usr/share/license/%{name} %{TZ_SYS_BIN}/profile_command diff --git a/rules/99-sdbd.rules b/rules/99-sdbd.rules new file mode 100644 index 0000000..c441d87 --- /dev/null +++ b/rules/99-sdbd.rules @@ -0,0 +1 @@ +KERNEL=="samsung_sdb", OWNER="sdk", GROUP="sdk", SECLABEL{smack}="*" -- 2.7.4 From 6e1c6e26f4a60ef1aabbcb6fa0035b6ccafa1376 Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Mon, 30 May 2016 14:25:24 +0300 Subject: [PATCH 16/16] Move variables declarations from header to source This prevents 'multiple definition' error when building with -fno-common this is used in Address Sanitizer builds. Change-Id: I0004622648c6e442bfed36f7aa14405b858d995b Signed-off-by: Slava Barinov --- src/sdb.c | 3 +++ src/sdb.h | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index 4c3009f..c31020b 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -71,6 +71,9 @@ uid_t g_sdk_user_id; gid_t g_sdk_group_id; char* g_sdk_home_dir = NULL; char* g_sdk_home_dir_env = NULL; +pcap g_capabilities; +int rootshell_mode; // 0: sdk user, 1: root +int booting_done; // 0: platform booting is in progess 1: platform booting is done struct group_info { diff --git a/src/sdb.h b/src/sdb.h index 7e3d1f1..a521466 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -268,7 +268,7 @@ typedef struct platform_capabilities char sdbd_version[CAPBUF_ITEMSIZE]; // sdbd version char sdbd_plugin_version[CAPBUF_ITEMSIZE]; // sdbd plugin version } pcap; -pcap g_capabilities; +extern pcap g_capabilities; #define SDBD_PLUGIN_PATH "/usr/lib/libsdbd_plugin.so" #define SDBD_PLUGIN_INTF "sdbd_plugin_cmd_proc" @@ -376,8 +376,8 @@ void log_service(int fd, void *cookie); void remount_service(int fd, void *cookie); char * get_log_file_path(const char * log_name); -int rootshell_mode; // 0: sdk user, 1: root -int booting_done; // 0: platform booting is in progess 1: platform booting is done +extern int rootshell_mode; // 0: sdk user, 1: root +extern int booting_done; // 0: platform booting is in progess 1: platform booting is done // This is the users and groups config for the platform -- 2.7.4