diff options
-rw-r--r-- | Makefile | 18 | ||||
-rw-r--r-- | packaging/sdbd.spec | 1 | ||||
-rw-r--r-- | src/commandline.c | 2 | ||||
-rw-r--r-- | src/file_sync_service.c | 26 | ||||
-rw-r--r-- | src/file_sync_service.h | 2 | ||||
-rw-r--r-- | src/sdb.c | 8 | ||||
-rw-r--r-- | src/sdb.h | 6 | ||||
-rw-r--r-- | src/sdktools.c | 29 | ||||
-rw-r--r-- | src/sdktools.h | 12 | ||||
-rw-r--r-- | src/services.c | 3 |
10 files changed, 79 insertions, 28 deletions
@@ -31,8 +31,9 @@ ifeq ($(HOST_OS),freebsd) EXTRA_SRCS := get_my_path_freebsd.c LOCAL_LDLIBS += -lpthread -lusb endif - - +PKG_CFLAGS := $(shell pkg-config --cflags libtzplatform-config) +PKG_LDFLAGS := $(shell pkg-config --ldflags libtzplatform-config) +PKG_LIBS := $(shell pkg-config --libs libtzplatform-config) SDB_SRC_FILES := \ src/sdb.c \ @@ -59,9 +60,9 @@ SDB_SRC_FILES := \ SDB_CFLAGS := -O2 -g -DSDB_HOST=1 -DSDB_HOST_ON_TARGET=1 -Wall -Wno-unused-parameter SDB_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE -SDB_CFLAGS += -DHAVE_FORKEXEC -DHAVE_TERMIO_H -DHAVE_SYMLINKS -SDB_LFLAGS := $(LOCAL_LDLIBS) - +SDB_CFLAGS += -DHAVE_FORKEXEC -DHAVE_TERMIO_H -DHAVE_SYMLINKS $(PKG_CFLAGS) +SDB_LFLAGS := $(LOCAL_LDLIBS) $(PKG_LDFLAGS) + SDBD_SRC_FILES := \ src/sdb.c \ src/fdevent.c \ @@ -91,7 +92,8 @@ SDBD_SRC_FILES := \ SDBD_CFLAGS := -O2 -g -DSDB_HOST=0 -Wall -Wno-unused-parameter SDBD_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE -SDBD_CFLAGS += -DHAVE_FORKEXEC -fPIE -D_DROP_PRIVILEGE +SDBD_CFLAGS += -DHAVE_FORKEXEC -fPIE -D_DROP_PRIVILEGE $(PKG_CFLAGS) +SDBD_LFLAGS := $(PKG_LDFLAGS) IFLAGS := -Iinclude -Isrc OBJDIR := bin @@ -124,11 +126,11 @@ all : $(MODULE) sdb : $(SDB_SRC_FILES) mkdir -p $(OBJDIR) - $(CC) -pthread -o $(OBJDIR)/$(MODULE) $(SDB_CFLAGS) $(SDB_EXTRA_CFLAGS) $(SDB_LFLAGS) $(IFLAGS) $(SDB_SRC_FILES) + $(CC) -pthread -o $(OBJDIR)/$(MODULE) $(SDB_CFLAGS) $(SDB_EXTRA_CFLAGS) $(SDB_LFLAGS) $(IFLAGS) $(SDB_SRC_FILES) $(PKG_LIBS) sdbd : $(SDBD_SRC_FILES) mkdir -p $(OBJDIR) - $(CC) -pthread -o $(OBJDIR)/$(MODULE) $(SDBD_CFLAGS) $(IFLAGS) $(SDBD_SRC_FILES) + $(CC) -pthread -o $(OBJDIR)/$(MODULE) $(SDBD_CFLAGS) $(SDBD_LFLAGS) $(IFLAGS) $(SDBD_SRC_FILES) $(PKG_LIBS) install : mkdir -p $(DESTDIR)/$(INSTALLDIR) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index de6f404..970e43d 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -6,6 +6,7 @@ Summary: SDB daemon Group: System/Utilities Source0: %{name}-%{version}.tar.gz Source1001: sdbd.manifest +BuildRequires: pkgconfig(libtzplatform-config) %description Description: SDB daemon. diff --git a/src/commandline.c b/src/commandline.c index 7b6f7a9..b8b1705 100644 --- a/src/commandline.c +++ b/src/commandline.c @@ -1465,7 +1465,7 @@ int sdb_command2(const char* cmd) { int install_app_sdb(const char *srcpath) { D("Install start\n"); - const char * APP_DEST = "/opt/apps/PKGS/%s"; + const char * APP_DEST = tzplatform_mkpath(TZ_SYS_RW_APP,"PKGS/%s"); const char* filename = sdb_dirstop(srcpath); char destination[PATH_MAX]; diff --git a/src/file_sync_service.c b/src/file_sync_service.c index 276469d..46128df 100644 --- a/src/file_sync_service.c +++ b/src/file_sync_service.c @@ -41,10 +41,15 @@ struct sync_permit_rule int mode; // 0:push, 1: pull, 2: push&push }; + +#define APP_INSTALL_PATH_PREFIX1 tzplatform_getenv(TZ_SYS_RW_APP) +#define APP_INSTALL_PATH_PREFIX2 tzplatform_getenv(TZ_USER_APP) +#define LEN 200 + struct sync_permit_rule sdk_sync_permit_rule[] = { // /* 0 */ {"rds", "^((/opt/apps)|(/opt/usr/apps))/[a-zA-Z0-9]{10}/info/\\.sdk_delta\\.info$", 1}, - /* 1 */ {"unitest", "^((/opt/apps)|(/opt/usr/apps))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", 1}, - /* 2 */ {"codecoverage", "^((/opt/apps)|(/opt/usr/apps))/[a-zA-Z0-9]{10}/data/+([a-zA-Z0-9_/\\.])*+[a-zA-Z0-9_\\-\\.]{1,50}\\.gcda$", 1}, + /* 1 */ {"unitest", "", 1}, + /* 2 */ {"codecoverage", "", 1}, /* end */ {NULL, NULL, 0} }; @@ -53,6 +58,18 @@ struct sync_permit_rule sdk_sync_permit_rule[] = { */ #define DIR_PERMISSION 0777 + +void init_sdk_sync_permit_rule_regx(){ + int i; + + for (i = 0; i <= 2; i++){ + sdk_sync_permit_rule[i].regx = malloc(LEN* sizeof(char)); + } + + sprintf(sdk_sync_permit_rule[0].regx, "^((%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); + sprintf(sdk_sync_permit_rule[1].regx, "^((%s)|(%s))/[a-zA-Z0-9]{10}/data/+([a-zA-Z0-9_/\\.])*+[a-zA-Z0-9_\\-\\.]{1,50}\\.gcda$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); + +} static int mkdirs(char *name) { int ret; @@ -405,6 +422,7 @@ static int verify_sync_rule(const char* path) { 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){ @@ -424,6 +442,10 @@ static int verify_sync_rule(const char* path) { } } regfree(®ex); + for (i = 0; i <= 2; i++){ + free(sdk_sync_permit_rule[i].regx); + } + return 0; } diff --git a/src/file_sync_service.h b/src/file_sync_service.h index 68059da..61b462a 100644 --- a/src/file_sync_service.h +++ b/src/file_sync_service.h @@ -75,7 +75,7 @@ typedef union { } status; } syncmsg; - +void init_sdk_sync_permit_rule_regx(void); void file_sync_service(int fd, void *cookie); void file_sync_subproc(int fd, void *cookie); int do_sync_ls(const char *path); @@ -29,7 +29,9 @@ #include "sysdeps.h" #include "sdb.h" +#include <tzplatform_config.h> +#define HOME_DEV_PATH tzplatform_getenv(TZ_SDK_HOME) #if !SDB_HOST //#include <private/android_filesystem_config.h> eric #include <linux/capability.h> @@ -1004,7 +1006,7 @@ int set_developer_privileges() { return -1; } - if (chdir("/home/developer") < 0) { + if (chdir(HOME_DEV_PATH) < 0) { D("sdbd: unable to change working directory to /home/developer\n"); } else { if (chdir("/") < 0) { @@ -1013,7 +1015,7 @@ int set_developer_privileges() { } return 1; } -#define ONDEMAND_ROOT_PATH "/home/developer" +#define ONDEMAND_ROOT_PATH tzplatform_getenv(TZ_SDK_HOME) static void init_sdk_requirements() { struct stat st; @@ -1027,7 +1029,7 @@ static void init_sdk_requirements() { } if (st.st_uid != SID_DEVELOPER || st.st_gid != SID_DEVELOPER) { char cmd[128]; - snprintf(cmd, sizeof(cmd), "chown developer:developer %s -R", ONDEMAND_ROOT_PATH); + snprintf(cmd, sizeof(cmd), "chown %s:%s %s -R", ONDEMAND_ROOT_PATH,tzplatform_getenv(TZ_SDK_USER_NAME),tzplatform_getenv(TZ_SDK_USER_NAME)); if (system(cmd) < 0) { D("failed to change ownership to developer to %s\n", ONDEMAND_ROOT_PATH); } @@ -21,6 +21,8 @@ #include "transport.h" /* readx(), writex() */ +#include <tzplatform_config.h> + #define MAX_PAYLOAD 4096 #define A_SYNC 0x434e5953 @@ -326,8 +328,8 @@ int rootshell_mode;// 0: developer, 1: root #define SID_ROOT 0 /* traditional unix root user */ #define SID_TTY 5 /* group for /dev/ptmx */ -#define SID_APP 5000 /* application */ -#define SID_DEVELOPER 5100 /* developer with SDK */ +#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 diff --git a/src/sdktools.c b/src/sdktools.c index 837af3b..71340bb 100644 --- a/src/sdktools.c +++ b/src/sdktools.c @@ -13,6 +13,7 @@ #include "sdktools.h" #define TRACE_TAG TRACE_SERVICES +#define LEN 200 #include "sdb.h" #include "sdktools.h" #include "strutils.h" @@ -27,15 +28,27 @@ struct sudo_command root_commands[] = { }; struct arg_permit_rule sdk_arg_permit_rule[] = { - /* 2 */ {"gcove_env1", "^GCOV_PREFIX=((/opt/apps)|(/opt/usr/apps))/[a-zA-Z0-9]{10}/data$", 1}, - /* 2 */ {"gcove_env2", "GCOV_PREFIX_STRIP=0", 0}, - /* 2 */ {"gcove_env3", "LD_LIBRARY_PATH=/home/developer/sdk_tools/gtest/usr/lib:$LD_LIBRARY_PATH", 0}, - /* 2 */ {"gcove_env4", "TIZEN_LAUNCH_MODE=debug", 0}, - /* 2 */ {"da_env1", "LD_PRELOAD=/usr/lib/da_probe_osp.so", 0}, - /* 2 */ {"gcove_arg1", "^\\-\\-gtest_output=xml:((/opt/apps)|(/opt/usr/apps))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,30}\\.xml$", 1}, + /* 2 */ {"gcove_env1", "", 1}, + /* 2 */ {"gcove_env2", "", 0}, + /* 2 */ {"gcove_env3", "", 0}, + /* 2 */ {"gcove_env4", "", 0}, + /* 2 */ {"da_env1", "", 0}, + /* 2 */ {"gcove_arg1", "", 1}, /* end */ {NULL, NULL, 0} }; +void init_sdk_arg_permit_rule_pattern(){ + int i; + + for (i = 0; i <= 5; i++){ + sdk_arg_permit_rule[i].pattern = malloc(LEN* sizeof(char)); + } + + sprintf(sdk_arg_permit_rule[0].pattern, "^GCOV_PREFIX=((%s)|(%s))/[a-zA-Z0-9]{10}/data$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); + sprintf(sdk_arg_permit_rule[2].pattern, "LD_LIBRARY_PATH=%sgtest/usr/lib:$LD_LIBRARY_PATH", DEV_INSTALL_PATH_PREFIX, APP_INSTALL_PATH_PREFIX2); + sprintf(sdk_arg_permit_rule[5].pattern, "^\\-\\-gtest_output=xml:((%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,30}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2); +} + int verify_commands(const char *arg1) { if (arg1 != NULL) { if (verify_root_commands(arg1)) { @@ -166,6 +179,7 @@ int regcmp(const char* pattern, const char* str) { int env_verify(const char* arg) { int i; + init_sdk_arg_permit_rule_pattern(); for (i=0; sdk_arg_permit_rule[i].name != NULL; i++) { if (sdk_arg_permit_rule[i].expression == 0) { if (!strcmp(sdk_arg_permit_rule[i].pattern, arg)) { @@ -180,6 +194,9 @@ int env_verify(const char* arg) { } } D("failed to set %s\n", arg); + for (i = 0; i <= 5; i++){ + free(sdk_arg_permit_rule[i].pattern); + } return 0; } diff --git a/src/sdktools.h b/src/sdktools.h index 881f122..d75306b 100644 --- a/src/sdktools.h +++ b/src/sdktools.h @@ -5,6 +5,8 @@ extern "C" { #endif +#include <tzplatform_config.h> + struct sudo_command { const char *command; @@ -23,10 +25,11 @@ struct arg_permit_rule }; -#define APP_INSTALL_PATH_PREFIX1 "/opt/apps" -#define APP_INSTALL_PATH_PREFIX2 "/opt/usr/apps" -#define GDBSERVER_PATH "/home/developer/sdk_tools/gdbserver/gdbserver" -#define GDBSERVER_PLATFORM_PATH "/home/developer/sdk_tools/gdbserver-platform/gdbserver" +#define APP_INSTALL_PATH_PREFIX1 tzplatform_getenv(TZ_SYS_RW_APP) +#define APP_INSTALL_PATH_PREFIX2 tzplatform_getenv(TZ_USER_APP) +#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") #define SMACK_LEBEL_SUBJECT_PATH "/proc/self/attr/current" #define APP_GROUPS_MAX 100 #define APP_GROUP_LIST "/usr/share/privilege-control/app_group_list" @@ -34,6 +37,7 @@ struct arg_permit_rule #define SDBD_LABEL_NAME "sdbd" #define SDK_HOME_LABEL_NAME "sdbd::home" +void init_sdk_arg_permit_rule_pattern(void); int verify_commands(const char *arg1); 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 2182b68..9b25bfc 100644 --- a/src/services.c +++ b/src/services.c @@ -22,6 +22,7 @@ #include <grp.h> #include "sysdeps.h" +#include <tzplatform_config.h> #define TRACE_TAG TRACE_SERVICES #include "sdb.h" @@ -236,7 +237,7 @@ void reboot_service(int fd, void *arg) #if !SDB_HOST #define EVENT_SIZE ( sizeof (struct inotify_event) ) #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) -#define CS_PATH "/opt/usr/share/crash/report" +#define CS_PATH tzplatform_mkpath(TZ_USER_SHARE,"crash/report") void inoti_service(int fd, void *arg) { |