From 59664783234a29d7ae553f03efa8c75afeb5c0fd Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 19 Sep 2017 11:37:52 +0900 Subject: [PATCH 01/16] package: update version (3.0.37) Change-Id: I19f19ba2b4acbe6b745233ff1179e6452aa3ef3e Signed-off-by: Sooyoung Ha --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index b7ff09d..37840ee 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.36 +Version: 3.0.37 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From a81bccd7f0fc6fe64a991455a7d72810746112ac Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Mon, 25 Sep 2017 17:36:20 +0900 Subject: [PATCH 02/16] service: fix a bug in crash report service Added to watch for the move event. Change-Id: I1e2a8e39217f25d19bc9c84c3dab663311fb5523 Signed-off-by: Jinhyung Jo --- src/services.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/services.c b/src/services.c index ea991c2..2976230 100644 --- a/src/services.c +++ b/src/services.c @@ -227,7 +227,7 @@ void inoti_service(int fd, void *arg) return; } - wd = inotify_add_watch( ifd, CS_PATH, IN_CREATE); + wd = inotify_add_watch(ifd, CS_PATH, IN_CREATE | IN_MOVE); if ( wd < 0 ) { D("inotify_add_watch failed (errno :%d)\n", errno); sdb_close(ifd); @@ -259,6 +259,18 @@ void inoti_service(int fd, void *arg) D( "asprintf was failed\n" ); } } + } else if (event->mask & IN_MOVE) { + if (!(event->mask & IN_ISDIR)) { + char *cspath = NULL; + int len = asprintf(&cspath, "%s/%s", CS_PATH, event->name); + if (len >= 0) { + D("The file %s was moved.\n", cspath); + writex(fd, cspath, len); + free(cspath); + } else { + D("asprintf was failed\n"); + } + } } } if (i + EVENT_SIZE + event->len < event->len) { // in case of integer overflow -- 2.7.4 From b478e56d3de022f1fb5cb755bfd48473c787bf64 Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Mon, 25 Sep 2017 18:13:27 +0900 Subject: [PATCH 03/16] package: update version (3.0.38) Change-Id: I814eec175f304dbfb2640a2747255ab2d39c45eb Signed-off-by: Jinhyung Jo --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 37840ee..39c16ee 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.37 +Version: 3.0.38 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 23da1328e674bade6c281c5cef46ce770a7090ae Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 10 Oct 2017 13:50:30 +0900 Subject: [PATCH 04/16] source: fix some risky codes Change-Id: I09660d031e04a3318849c49f2fe933f6388e0627 Signed-off-by: Sooyoung Ha --- src/default_plugin_appcmd.c | 4 ++-- src/sdb.c | 13 ++++++------- src/services.c | 1 + src/subprocess.c | 1 + src/transport.c | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/default_plugin_appcmd.c b/src/default_plugin_appcmd.c index 8ffb4e3..bd4986c 100644 --- a/src/default_plugin_appcmd.c +++ b/src/default_plugin_appcmd.c @@ -315,7 +315,7 @@ static void appcmd_receiver_default(int fd_in, int fd_out) for(;;) { memset(buf, 0, sizeof(buf)); - r = sdb_read(fd_in, buf, sizeof(buf)); + r = sdb_read(fd_in, buf, sizeof(buf)-1); if (r == 0) { break; } else if(r < 0) { @@ -480,11 +480,11 @@ static int exec_appcmd_shell_process(appcmd_info* p_info) { args[2] = p_info->shell_cmd; ptm_fd = create_subprocess(SHELL_COMMAND, &pid, (char * const*)args, (char * const*)envp); - D("create_subprocess() ptm_fd=%d pid=%d\n", ptm_fd, pid); if (ptm_fd < 0) { D("cannot create service thread\n"); return -1; } + D("create_subprocess() ptm_fd=%d pid=%d\n", ptm_fd, pid); if (p_info->receiver_func != NULL) { p_info->receiver_func(ptm_fd, p_info->fd); diff --git a/src/sdb.c b/src/sdb.c index f614bfb..efb8999 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1176,25 +1176,24 @@ void start_device_log(void) char path_file[PATH_MAX] = {0, }; struct tm now; time_t t; -// char value[PROPERTY_VALUE_MAX]; - char* p_trace = get_sdb_log_conf("SDB_TRACE"); - char* p_path = get_sdb_log_conf("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 - + char* p_trace = get_sdb_log_conf("SDB_TRACE"); if ((p_trace == NULL ) && !is_enable_sdbd_log()) { return; } else { free(p_trace); } - + char* p_path = get_sdb_log_conf("SDBD_LOG_PATH"); if (p_path) { snprintf(path_folder, sizeof(path_folder), "%s", p_path); free(p_path); - } else if (g_capabilities.log_path[0] != '\0') + } else if (g_capabilities.log_path[0] != '\0') { snprintf(path_folder, sizeof(path_folder), "%s", g_capabilities.log_path); - else + } else { return; + } tzset(); time(&t); diff --git a/src/services.c b/src/services.c index 2976230..b8fd31a 100644 --- a/src/services.c +++ b/src/services.c @@ -455,6 +455,7 @@ static ssize_t recv_fd(int fd, void *ptr, size_t nbytes, int *recvfd) } control_un; ssize_t ret; + memset(&msg, 0, sizeof(msg)); msg.msg_control = control_un.control; msg.msg_controllen = sizeof(control_un.control); diff --git a/src/subprocess.c b/src/subprocess.c index 6eb3ca0..9241d85 100644 --- a/src/subprocess.c +++ b/src/subprocess.c @@ -40,6 +40,7 @@ static ssize_t send_fd(int fd, void *ptr, size_t nbytes, int sendfd) char control[CMSG_SPACE(sizeof(int))]; } control_un; + memset(&msg, 0, sizeof(msg)); msg.msg_control = control_un.control; msg.msg_controllen = sizeof(control_un.control); diff --git a/src/transport.c b/src/transport.c index d6ecd66..49895e7 100644 --- a/src/transport.c +++ b/src/transport.c @@ -823,6 +823,7 @@ void broadcast_transport(apacket *p) t->connection_state = CS_PWLOCK; } } + put_apacket(ap); } } sdb_mutex_unlock(&transport_lock); -- 2.7.4 From b025dbcad47db0173a6100dfc7e0cbb7b30f4fac Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 10 Oct 2017 13:51:31 +0900 Subject: [PATCH 05/16] package: update version (3.0.39) Change-Id: I63990255b41482fe7d6985f368253f4f4aa6dd1a Signed-off-by: Sooyoung Ha --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 39c16ee..a90bd1c 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.38 +Version: 3.0.39 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 1a356cc2a085e2e408ad50a8c49d111687d011f5 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 10 Oct 2017 14:01:12 +0900 Subject: [PATCH 06/16] source: add g_main_loop_unref for finished mainloop Change-Id: Iefd46e1882cee1011454eafee4414e4130df21d9 Signed-off-by: Sooyoung Ha --- src/sdb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdb.c b/src/sdb.c index efb8999..a9820bd 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1361,6 +1361,7 @@ static void *bootdone_cb(void *x) { g_main_loop_run(mainloop); D("dbus loop exited"); + g_main_loop_unref(mainloop); dbus_connection_unref(bus); return NULL; -- 2.7.4 From e058b173eab3798595782878f3cb1b48c579af3c Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 10 Oct 2017 14:02:09 +0900 Subject: [PATCH 07/16] package: update version (3.0.40) Change-Id: I21ea7beee26cd393bd589007f9cc52758955ed26 Signed-off-by: Sooyoung Ha --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index a90bd1c..7705184 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.39 +Version: 3.0.40 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 8e6db1f76ab7204528a0a47131b0b06aa9df5411 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Wed, 11 Oct 2017 20:48:03 +0900 Subject: [PATCH 08/16] transport: do not free broadcast transport packet Change-Id: I581877a737e4b860061fca8b62b89ea31d39b695 Signed-off-by: Sooyoung Ha --- src/transport.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/transport.c b/src/transport.c index 49895e7..d6ecd66 100644 --- a/src/transport.c +++ b/src/transport.c @@ -823,7 +823,6 @@ void broadcast_transport(apacket *p) t->connection_state = CS_PWLOCK; } } - put_apacket(ap); } } sdb_mutex_unlock(&transport_lock); -- 2.7.4 From fbef2a86c98ba4d70273fc302f72cc0fe163ea8f Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Wed, 11 Oct 2017 20:49:04 +0900 Subject: [PATCH 09/16] package: update version (3.0.41) Change-Id: I749e0ddd0190e1e9c2d39062676b5ec8af413f94 Signed-off-by: Sooyoung Ha --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 7705184..00815b0 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.40 +Version: 3.0.41 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From fbb3887c013b52229f5310006ec3df850299062a Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Tue, 10 Oct 2017 18:06:20 +0900 Subject: [PATCH 10/16] dbus: change from dbus-glib API to GDBus API As mentioned in the URL below: https://dbus.freedesktop.org/doc/dbus-glib/ dbus-glib is a deprecated API for use of D-Bus from GLib applications. Do not use it in new code. Since version 2.26, GLib's accompanying GIO library provides a high-level API for D-Bus, "GDBus", based on an independent reimplementation of the D-Bus protocol. The maintainers of D-Bus recommend that GLib applications should use GDBus instead of dbus-glib. Change-Id: I5754e0c40fdb246e0a29766ae795e6dcaebc07e4 Signed-off-by: Jinhyung Jo --- CMakeLists.txt | 3 +- packaging/sdbd.spec | 3 +- src/sdb.c | 134 ++++++++++++++++++++++++++-------------------------- 3 files changed, 69 insertions(+), 71 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e06a26d..3bc41e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,8 +70,7 @@ pkg_check_modules(pkgs REQUIRED capi-system-info vconf glib-2.0 - dbus-1 - dbus-glib-1 + gio-2.0 dlog ) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 00815b0..372ceb7 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -23,8 +23,7 @@ BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(dbus-1) -BuildRequires: pkgconfig(dbus-glib-1) +BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(dlog) Requires: dbus Provides: %{name}-profile_common = %{version}-%{release} diff --git a/src/sdb.c b/src/sdb.c index a9820bd..cd9bada 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1280,101 +1280,101 @@ int should_drop_privileges() { return 1; } -#include -#include -#include +#include +#define DEVICED_BUS "org.tizen.system.deviced" +#define DEVICED_CORE_PATH "/Org/Tizen/System/DeviceD/Core" #define BOOTING_DONE_SIGNAL "BootingDone" #define DEVICED_CORE_INTERFACE "org.tizen.system.deviced.core" -#define SDBD_BOOT_INFO_FILE "/tmp/sdbd_boot_info" +#define SDBD_BOOT_INFO_FILE "/tmp/sdbd_boot_info" -static DBusHandlerResult __sdbd_dbus_signal_filter(DBusConnection *conn, - DBusMessage *message, void *user_data) { - D("got dbus message\n"); - const char *interface; +static GMainLoop *g_mainloop; - DBusError error; - dbus_error_init(&error); - - interface = dbus_message_get_interface(message); - if (interface == NULL) { - D("reject by security issue - no interface\n"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +static void booting_done_signal_subscriber(GDBusConnection *connection, + const gchar *sender, const gchar *path, const gchar *interface, + const gchar *signal, GVariant *parameters, gpointer user_data) +{ + if (g_strcmp0(signal, BOOTING_DONE_SIGNAL) != 0) { + D("received signal(%s) does not match the desired signal(%s)\n", + signal, BOOTING_DONE_SIGNAL); + return; } - if (dbus_message_is_signal(message, DEVICED_CORE_INTERFACE, - BOOTING_DONE_SIGNAL)) { - booting_done = 1; - if (access(SDBD_BOOT_INFO_FILE, F_OK) == 0) { - D("booting is done before\n"); - } else { - FILE *f = fopen(SDBD_BOOT_INFO_FILE, "w"); - if (f != NULL) { - fprintf(f, "%d", 1); - fclose(f); - } + D("received the \"%s\" signal\n", signal); + + booting_done = 1; + if (access(SDBD_BOOT_INFO_FILE, F_OK) == 0) { + D("booting is already done\n"); + } else { + FILE *info_file = fopen(SDBD_BOOT_INFO_FILE, "w"); + if (info_file != NULL) { + fprintf(info_file, "%d", 1); + fclose(info_file); } D("booting is done\n"); } - D("handled dbus message\n"); - return DBUS_HANDLER_RESULT_HANDLED; + D("handled the booting done signal\n"); + g_main_loop_quit(g_mainloop); } -static void *bootdone_cb(void *x) { - int MAX_LOCAL_BUFSZ = 128; - DBusError error; - DBusConnection *bus; - 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); +static void *bootdone_cb(void *args) +{ + GError *error = NULL; + GDBusConnection *connection = NULL; + guint id; + + connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); + if (connection == NULL) { + if (error != NULL) { + D("failed to connect to the system bus: %s\n", error->message); + g_error_free(error); + } else { + D("failed to connect to the system bus\n"); + } return NULL; } - dbus_connection_setup_with_g_main(bus, NULL); - snprintf(rule, MAX_LOCAL_BUFSZ, "type='signal',interface='%s'", - DEVICED_CORE_INTERFACE); - /* listening to messages */ - dbus_bus_add_match(bus, rule, &error); - if (dbus_error_is_set(&error)) { - D("Fail to rule set: %s", error.message); - dbus_error_free(&error); - return NULL; + g_mainloop = g_main_loop_new(NULL, false); + if (g_mainloop == NULL) { + D("failed to create a g_main_loop\n"); + goto bootdone_out; } - if (dbus_connection_add_filter(bus, __sdbd_dbus_signal_filter, NULL, NULL) - == FALSE) - return NULL; + id = g_dbus_connection_signal_subscribe(connection, + DEVICED_BUS, DEVICED_CORE_INTERFACE, BOOTING_DONE_SIGNAL, + DEVICED_CORE_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, + booting_done_signal_subscriber, NULL, NULL); + if (id == 0) { + D("failed to subscribe to the booting done signal\n"); + goto bootdone_out; + } - D("booting signal initialized\n"); - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); + D("wait for the booting done signal\n"); + g_main_loop_run(g_mainloop); - D("dbus loop exited"); - g_main_loop_unref(mainloop); - dbus_connection_unref(bus); + g_dbus_connection_signal_unsubscribe(connection, id); + +bootdone_out: + if (g_mainloop != NULL) { + g_main_loop_unref(g_mainloop); + } + if (connection != NULL) { + g_object_unref(connection); + } + D("exit the bootdone_cb thread\n"); return NULL; } -void register_bootdone_cb() { - D("registerd bootdone callback\n"); - +void register_bootdone_cb() +{ sdb_thread_t t; if (sdb_thread_create(&t, bootdone_cb, NULL)) { - D("cannot create service thread\n"); + D("can not create a service thread to check the booting done\n"); return; } + D("created the bootdone_cb thread\n"); } static int sdbd_set_groups(const char *name, int gid, struct group_info default_groups[], int default_groups_size) { -- 2.7.4 From a4cd4e14dbf55d87886f9e3558ce920b79174ed8 Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Wed, 11 Oct 2017 15:50:02 +0900 Subject: [PATCH 11/16] package: update version (3.0.42) Change-Id: I44989f6d30412a1b596e6da8a00314766e59e290 Signed-off-by: Jinhyung Jo --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 372ceb7..894d2ca 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.41 +Version: 3.0.42 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 16d3e0f8ea8641fdde9fad332daeff37587d4138 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Mon, 16 Oct 2017 16:19:57 +0900 Subject: [PATCH 12/16] source: remove unused function Change-Id: I8df28769edca2a8028ddcf984c630c28f5f04d5b Signed-off-by: Sooyoung Ha --- CMakeLists.txt | 1 - src/fileutils.c | 49 ------------------------------------------------- src/fileutils.h | 6 ------ src/sdktools.c | 1 - 4 files changed, 57 deletions(-) delete mode 100644 src/fileutils.c delete mode 100644 src/fileutils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bc41e2..b839a10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,6 @@ SET(SDBD_SRCS src/sdktools.c src/strutils.c src/init.c - src/fileutils.c src/commandline_sdbd.c src/usb_linux_client.c src/usb_funcfs_client.c diff --git a/src/fileutils.c b/src/fileutils.c deleted file mode 100644 index bb5071b..0000000 --- a/src/fileutils.c +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include -#include -#include -#include - -static int recurse(const char *path, mode_t mode, int (*fn)(const char *,mode_t, int)) { - struct stat st; - char dir[PATH_MAX]; - - if (path == NULL) { - return -1; - } - if (lstat (path, &st) == -1) { - return -1; - } - if (strrchr(path, '/') != NULL) { - int n = strlen(path)-strlen(strrchr(path, '/')); - if (n >= PATH_MAX) { - return -1; - } - strncpy(dir, path, n); - dir[n] = '\0'; - fn(dir, mode,1); - return 1; - } - return -1; -} - -int sdb_chmod(const char *path, mode_t mode, int recursive) { -#ifdef HAVE_WIN32_PROC - fprintf(stderr, "error: sdb_chmod not implemented on Win32 (%s)\n", path); - return -1; -#else - struct stat st; - - if (stat (path, &st) == -1) - return -1; - - if (chmod (path, mode) == -1) { - return -1; - } - if (recursive) { - return recurse(path, mode, sdb_chmod); - } - return 1; -#endif -} diff --git a/src/fileutils.h b/src/fileutils.h deleted file mode 100644 index 4debc92..0000000 --- a/src/fileutils.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _FILEUTILS_H_ -#define _FILEUTILS_H_ - -int sdb_chmod(const char *path, mode_t mode, int recursive); -#endif - diff --git a/src/sdktools.c b/src/sdktools.c index 755625a..ddf4b18 100644 --- a/src/sdktools.c +++ b/src/sdktools.c @@ -17,7 +17,6 @@ #include "sdb.h" #include "sdktools.h" #include "strutils.h" -#include "fileutils.h" #include "utils.h" struct sudo_command root_commands[] = { -- 2.7.4 From c64c4afdd702d6647ef6d3d208bb4290880bd657 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Mon, 16 Oct 2017 16:20:38 +0900 Subject: [PATCH 13/16] package: update version (3.0.43) Change-Id: Ic67edc88fa0ac9fc377e912b1ef4e4ddff48d3f3 Signed-off-by: Sooyoung Ha --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 894d2ca..ea1aecd 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.42 +Version: 3.0.43 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 118fbdcfaefb590afa25577c0f916420d10bd27d Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Wed, 18 Oct 2017 12:09:29 +0900 Subject: [PATCH 14/16] plugin: do not null assign saveptr of strtok_r Change-Id: I49b9f386f45cab131be0f22e9c53cffbf40161ed Signed-off-by: Sooyoung Ha --- src/default_plugin_appcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/default_plugin_appcmd.c b/src/default_plugin_appcmd.c index bd4986c..5338854 100644 --- a/src/default_plugin_appcmd.c +++ b/src/default_plugin_appcmd.c @@ -141,7 +141,7 @@ static int appcmd_rununittestapp_gen_shellcmd(appcmd_info* p_info) { char *usr_args = NULL; char *buf = p_info->shell_cmd; int len = sizeof(p_info->shell_cmd); - char *ptr = NULL; + char *ptr; char *p_service = NULL; char *p_appid = NULL; -- 2.7.4 From beef02b4c0bd16b6a4bcd71fa5ea7ae9705ebd5a Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Wed, 18 Oct 2017 12:10:47 +0900 Subject: [PATCH 15/16] package: update version (3.0.44) Change-Id: I68231790d5e787f4a170240867e2aff12720e762 Signed-off-by: Sooyoung Ha --- packaging/sdbd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index ea1aecd..3ffe78f 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.43 +Version: 3.0.44 Release: 0 License: Apache-2.0 Summary: SDB daemon -- 2.7.4 From 9f30b23e7207be90669228aa77d26e01627754b2 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 28 Nov 2017 15:04:48 +0900 Subject: [PATCH 16/16] fopen: add realpath before fopen To prevent path-modification attack using symbolic link. Change-Id: Id5133df718b1e14a22849920082ff1717bc417e6 Signed-off-by: Sooyoung Ha --- src/sdb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index cd9bada..51f6b7e 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1239,11 +1239,18 @@ int daemonize(void) { _exit(0); } #ifdef SDB_PIDPATH - FILE *f = fopen(SDB_PIDPATH, "w"); - - if (f != NULL) { - fprintf(f, "%d\n", getpid()); - fclose(f); + char* tmppath = NULL; + tmppath = realpath(SDB_PIDPATH, NULL); + if (tmppath == NULL && errno == ENOENT) { + FILE *f = fopen(SDB_PIDPATH, "w"); + + if (f != NULL) { + fprintf(f, "%d\n", getpid()); + fclose(f); + } + } else { + D("sdbd: %s file is existed. It might not work properly.\n", SDB_PIDPATH); + free(tmppath); } #endif if (setsid() == -1) -- 2.7.4