From 5f52d2f736a267fd679407765d8e72d39f858a87 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 11 Jun 2021 15:12:50 +0900 Subject: [PATCH 01/16] libcommon: bring file IO from deviced Change-Id: I0068a42487b31881ff2c8f91de785ae8362984d4 Signed-off-by: Youngjae Cho --- CMakeLists.txt | 1 + src/libcommon/file.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/libcommon/file.h | 113 +++---------------------------------------- 3 files changed, 140 insertions(+), 107 deletions(-) create mode 100644 src/libcommon/file.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e16516d..2c1231a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ SET(libsyscommon_SRCS src/libgdbus/libgdbus.c src/libsystemd/libsystemd.c src/libcommon/ini-parser.c + src/libcommon/file.c ) SET(HEADERS src/libgdbus/libgdbus.h diff --git a/src/libcommon/file.c b/src/libcommon/file.c new file mode 100644 index 0000000..b3ca5f1 --- /dev/null +++ b/src/libcommon/file.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include "file.h" + +#define SHARED_H_BUF_MAX 255 + +int sys_read_buf(char *file, char *buf, int len) +{ + int fd, r; + + if (!file || !buf || len < 0) + return -EINVAL; + + fd = open(file, O_RDONLY); + if (fd == -1) + return -errno; + + r = read(fd, buf, len); + if ((r >= 0) && (r < len)) + buf[r] = '\0'; + else { + buf[0] = '\0'; + r = -EIO; + } + + close(fd); + + return r; +} + +int sys_write_buf(char *file, char *buf) +{ + int fd, r; + + if (!file || !buf) + return -EINVAL; + + fd = open(file, O_WRONLY); + if (fd == -1) + return -errno; + + r = write(fd, buf, strlen(buf)); + if (r < 0) + r = -EIO; + + close(fd); + + return 0; +} + +int sys_get_int(char *fname, int *val) +{ + char buf[SHARED_H_BUF_MAX]; + int r; + + if (!fname || !val) + return -EINVAL; + + r = sys_read_buf(fname, buf, sizeof(buf)); + if (r > 0) { + *val = atoi(buf); + } else { + *val = -1; + r = -EIO; + } + + return r; +} + +int sys_get_str(char *fname, char *str, int len) +{ + int r; + + if (!fname || !str || len < 0) + return -EINVAL; + + r = sys_read_buf(fname, str, len); + if (r < 0) + return r; + + return 0; +} + +int sys_set_int(char *fname, int val) +{ + char buf[SHARED_H_BUF_MAX]; + int r; + + if (!fname) + return -EINVAL; + + snprintf(buf, sizeof(buf), "%d", val); + r = sys_write_buf(fname, buf); + if (r < 0) + return r; + + return 0; +} + +int sys_set_str(char *fname, char *val) +{ + int r; + + if (!fname || !val) + return -EINVAL; + + r = sys_write_buf(fname, val); + if (r < 0) + return r; + + return 0; +} diff --git a/src/libcommon/file.h b/src/libcommon/file.h index 4d256a0..1250da8 100644 --- a/src/libcommon/file.h +++ b/src/libcommon/file.h @@ -18,112 +18,11 @@ #ifndef __LIBCOMMON_FILE_H__ #define __LIBCOMMON_FILE_H__ -#include -#include -#include -#include -#include - -#define SHARED_H_BUF_MAX 255 - -static inline int sys_read_buf(char *file, char *buf, int len) -{ - int fd, r; - - if (!file || !buf || len < 0) - return -EINVAL; - - fd = open(file, O_RDONLY); - if (fd == -1) - return -ENOENT; - - r = read(fd, buf, len); - close(fd); - if ((r >= 0) && (r < len)) - buf[r] = '\0'; - else - return -EIO; - - return 0; -} - -static inline int sys_write_buf(char *file, char *buf) -{ - int fd, r; - - if (!file || !buf) - return -EINVAL; - - fd = open(file, O_WRONLY); - if (fd == -1) - return -EPERM; - - r = write(fd, buf, strlen(buf)); - close(fd); - if (r < 0) - return -EIO; - - return 0; -} - -static inline int sys_get_int(char *fname, int *val) -{ - char buf[SHARED_H_BUF_MAX]; - int r; - - if (!fname || !val) - return -EINVAL; - - r = sys_read_buf(fname, buf, sizeof(buf)); - if (r < 0) - return r; - - *val = atoi(buf); - return 0; -} - -static inline int sys_get_str(char *fname, char *str, int len) -{ - int r; - - if (!fname || !str || len < 0) - return -EINVAL; - - r = sys_read_buf(fname, str, len); - if (r < 0) - return r; - - return 0; -} - -static inline int sys_set_int(char *fname, int val) -{ - char buf[SHARED_H_BUF_MAX]; - int r; - - if (!fname) - return -EINVAL; - - snprintf(buf, sizeof(buf), "%d", val); - r = sys_write_buf(fname, buf); - if (r < 0) - return r; - - return 0; -} - -static inline int sys_set_str(char *fname, char *val) -{ - int r; - - if (!fname || !val) - return -EINVAL; - - r = sys_write_buf(fname, val); - if (r < 0) - return r; - - return 0; -} +int sys_read_buf(char *file, char *buf, int len); +int sys_write_buf(char *file, char *buf); +int sys_get_int(char *fname, int *val); +int sys_get_str(char *fname, char *str, int len); +int sys_set_int(char *fname, int val); +int sys_set_str(char *fname, char *val); #endif /* __LIBCOMMON_FILE_H__ */ -- 2.7.4 From f3b24d981fc721ccaebfd15dc9b160d270979cf1 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Mon, 5 Jul 2021 20:47:06 +0900 Subject: [PATCH 02/16] libcommon: add is_container function Change-Id: I5ba0109e996b3f4e8ff939859499a3de8b623c90 Signed-off-by: Yunmi Ha --- CMakeLists.txt | 2 ++ src/libcommon/common.c | 29 +++++++++++++++++++++++++++++ src/libcommon/common.h | 24 ++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 src/libcommon/common.c create mode 100644 src/libcommon/common.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1231a..049a45b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ SET(libsyscommon_SRCS src/libsystemd/libsystemd.c src/libcommon/ini-parser.c src/libcommon/file.c + src/libcommon/common.c ) SET(HEADERS src/libgdbus/libgdbus.h @@ -24,6 +25,7 @@ SET(HEADERS src/libcommon/list.h src/libcommon/ini-parser.h src/libcommon/file.h + src/libcommon/common.h ) # CHECK PKG diff --git a/src/libcommon/common.c b/src/libcommon/common.c new file mode 100644 index 0000000..fd3a11b --- /dev/null +++ b/src/libcommon/common.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "common.h" + +#define CONTAINER_FILE_PATH "/run/systemd/container" + +bool is_container() +{ + if (access(CONTAINER_FILE_PATH, F_OK) == 0) + return true; + + return false; +} diff --git a/src/libcommon/common.h b/src/libcommon/common.h new file mode 100644 index 0000000..43a1fae --- /dev/null +++ b/src/libcommon/common.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LIBCOMMON_COMMON_H__ +#define __LIBCOMMON_COMMON_H__ + +#include + +bool is_container(); + +#endif /* __LIBCOMMON_COMMON_H__ */ -- 2.7.4 From dc635f86f30269a21e7440279a74265e3989ed4b Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 1 Oct 2021 18:10:18 +0900 Subject: [PATCH 03/16] tests: add test running automatically on building If the test fails, the whole build will fail. Change-Id: Ibb88e60d13bcec09567630d051372fbcfbbb79da Signed-off-by: Youngjae Cho --- CMakeLists.txt | 2 + packaging/libsyscommon.spec | 1 + tests/CMakeLists.txt | 20 ++++ tests/libcommon/CMakeLists.txt | 16 ++++ tests/libcommon/test-common.c | 208 +++++++++++++++++++++++++++++++++++++++++ tests/libcommon/test.conf | 8 ++ tests/test-main.c | 50 ++++++++++ tests/test-main.h | 10 ++ tests/test-mock.c | 65 +++++++++++++ tests/test-mock.h | 8 ++ 10 files changed, 388 insertions(+) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/libcommon/CMakeLists.txt create mode 100644 tests/libcommon/test-common.c create mode 100644 tests/libcommon/test.conf create mode 100644 tests/test-main.c create mode 100644 tests/test-main.h create mode 100644 tests/test-mock.c create mode 100644 tests/test-mock.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 049a45b..bebdb2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,3 +68,5 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_I FOREACH(hfile ${HEADERS}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME}) ENDFOREACH(hfile) + +ADD_SUBDIRECTORY(tests) diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index 80e7db4..4ec8ea2 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -11,6 +11,7 @@ BuildRequires: pkgconfig(glib-2.0) >= 2.44 BuildRequires: pkgconfig(gio-2.0) >= 2.44 BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(cmocka) BuildRequires: cmake Requires: /bin/cp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..bfd44ea --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,20 @@ +SET(TEST_DRIVER "test-driver") + +FILE(GLOB SRCS "${CMAKE_CURRENT_SOURCE_DIR}/*.c") + +SET(TEST_SUITE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +ADD_DEFINITIONS("-DTEST_SUITE_DIRECTORY=\"${TEST_SUITE_DIRECTORY}\"") + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(REQUIRED_PKGS REQUIRED + cmocka) + +ADD_EXECUTABLE(${TEST_DRIVER} ${SRCS}) +TARGET_LINK_LIBRARIES(${TEST_DRIVER} cmocka dl) +SET_TARGET_PROPERTIES(${TEST_DRIVER} PROPERTIES LINK_FLAGS "-Wl,--export-dynamic") + +ADD_CUSTOM_TARGET(run-test ALL "./${TEST_DRIVER}") +ADD_DEPENDENCIES(run-test ${TEST_DRIVER}) + +# add test suites +ADD_SUBDIRECTORY(libcommon) diff --git a/tests/libcommon/CMakeLists.txt b/tests/libcommon/CMakeLists.txt new file mode 100644 index 0000000..9fe27d3 --- /dev/null +++ b/tests/libcommon/CMakeLists.txt @@ -0,0 +1,16 @@ +SET(TEST_SUITE "test-driver-libcommon") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) + +FILE(GLOB SRCS "${CMAKE_CURRENT_SOURCE_DIR}/*.c") +FILE(GLOB ORIG_SRCS "${CMAKE_SOURCE_DIR}/src/libcommon/*.c") + +ADD_LIBRARY(${TEST_SUITE} MODULE ${SRCS} ${ORIG_SRCS}) +SET_TARGET_PROPERTIES(${TEST_SUITE} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${TEST_SUITE_DIRECTORY}) +ADD_DEPENDENCIES(${TEST_DRIVER} ${TEST_SUITE}) + +SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=open") +SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=open64") +SET_TARGET_PROPERTIES(${TEST_SUITE} PROPERTIES LINK_FLAGS ${WRAP_FLAGS}) + +TARGET_LINK_LIBRARIES(${TEST_SUITE} cmocka glib-2.0) diff --git a/tests/libcommon/test-common.c b/tests/libcommon/test-common.c new file mode 100644 index 0000000..76e770c --- /dev/null +++ b/tests/libcommon/test-common.c @@ -0,0 +1,208 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "libcommon/file.h" +#include "libcommon/list.h" +#include "libcommon/ini-parser.h" +#include "../test-main.h" +#include "../test-mock.h" + +#define MOCK_FILE_PATH "testfile" +#define MOCK_FILE_LENGTH 100 + +static int setup(void **state) +{ + FILE *fp; + char cwd[128] = {0, }; + char path[256] = {0, }; + char str[MOCK_FILE_LENGTH]; + + memset(str, 't', MOCK_FILE_LENGTH); + + snprintf(path, sizeof(path), "%s/%s", getcwd(cwd, sizeof(cwd)), MOCK_FILE_PATH); + + fp = fopen(path, "w+"); + + if (!fp) { + printf("Failed to setup mockfile, %m\n"); + return -1; + } + + fwrite(str, 1, MOCK_FILE_LENGTH, fp); + fclose(fp); + + return 0; +} + +static int teardown(void **state) +{ + char cwd[128] = {0, }; + char path[256] = {0, }; + + snprintf(path, sizeof(path), "%s/%s", getcwd(cwd, sizeof(cwd)), MOCK_FILE_PATH); + + unlink(path); + + return 0; +} + +static void test_sys_get_str_p1(void **state) +{ + char buffer[MOCK_FILE_LENGTH * 2]; + int retval; + + /* remove possible null character */ + for (int i = 0; i < sizeof(buffer); ++i) + buffer[i] = 'x'; + + /* mocking open() syscall */ + mock_open(MOCK_FILE_PATH, O_RDONLY); + + /* this is example of how mock works */ + retval = sys_get_str("the pathname will be replaced to mocked one", + buffer, sizeof(buffer)); + + assert_int_equal(retval, 0); +} + +/* test small buffer */ +static void test_sys_get_str_n1(void **state) +{ + char buffer[MOCK_FILE_LENGTH / 2]; + int retval; + + /* remove possible null character */ + for (int i = 0; i < sizeof(buffer); ++i) + buffer[i] = 'x'; + + /* mocking open() syscall */ + mock_open(MOCK_FILE_PATH, O_RDONLY); + + /* this is example of how mock works */ + retval = sys_get_str("the pathname will be replaced to mocked one", + buffer, sizeof(buffer)); + + assert_int_equal(retval, -EIO); + assert_int_equal(buffer[0], 0); +} + +/* test no-exist file */ +static void test_sys_get_str_n2(void **state) +{ + char buffer[MOCK_FILE_LENGTH * 2]; + int retval; + + mock_open(MOCK_FILE_PATH, O_RDONLY); + + retval = sys_get_str("the pathname will be replaced to mocked one", + buffer, sizeof(buffer)); + + assert_int_equal(retval, -ENOENT); +} + +static void test_list_append_p(void **state) +{ + GList *head = NULL; + GList *elem, *elem2; + int i; + int value; + int length; + + for ( i = 0; i < 10; ++i) + SYS_G_LIST_APPEND(head, (intptr_t) i); + + length = SYS_G_LIST_LENGTH(head); + assert_int_equal(length, 10); + + i = 0; + SYS_G_LIST_FOREACH(head, elem, elem2) { + value = (int) elem2; + assert_int_equal(value, i++); + } +} + +static void test_list_prepend_p(void **state) +{ + GList *head = NULL; + GList *elem, *elem2; + int i; + int value; + int length; + + for ( i = 0; i < 10; ++i) + SYS_G_LIST_PREPEND(head, (intptr_t) i); + + length = SYS_G_LIST_LENGTH(head); + assert_int_equal(length, 10); + + i = 10; + SYS_G_LIST_FOREACH(head, elem, elem2) { + value = (int) elem2; + assert_int_equal(value, --i); + } +} + +static int check_user_data = 0x443; +static bool checked1; +static bool checked2; +static bool checked3; +static bool garbage; +static int test_parser(struct parse_result *result, void *data) +{ + assert_int_equal(data, check_user_data); + + if (MATCH(result->section, "Section1") && + MATCH(result->name, "Key1") && + MATCH(result->value, "Value1")) + checked1 = true; + else if (MATCH(result->section, "Section2") && + MATCH(result->name, "Key2") && + MATCH(result->value, "Value2")) + checked2 = true; + else if (MATCH(result->section, "Section2") && + MATCH(result->name, "Key3") && + MATCH(result->value, "Value3")) + checked3 = true; + else + garbage = true; + + return 0; +} + +static void test_config_parse_p(void **state) +{ + char cwd[128]; + char path[256]; + int retval; + + /* load predefined test.conf file */ + retval = snprintf(path, sizeof(path), "%s/libcommon/test.conf", getcwd(cwd, sizeof(cwd))); + if (retval >= sizeof(path)) + path[sizeof(path) - 1] = '\0'; + + config_parse(path, test_parser, (void *)(intptr_t) check_user_data); + + assert_true(checked1); + assert_true(checked2); + assert_true(checked3); + assert_false(garbage); +} + +int run_test_suite(void) +{ + const struct CMUnitTest testsuite[] = { + cmocka_unit_test_setup_teardown(test_sys_get_str_p1, setup, teardown), + cmocka_unit_test_setup_teardown(test_sys_get_str_n1, setup, teardown), + cmocka_unit_test(test_sys_get_str_n2), + cmocka_unit_test(test_list_append_p), + cmocka_unit_test(test_list_prepend_p), + cmocka_unit_test(test_config_parse_p), + }; + + return cmocka_run_group_tests(testsuite, NULL, NULL); +} diff --git a/tests/libcommon/test.conf b/tests/libcommon/test.conf new file mode 100644 index 0000000..c915ae1 --- /dev/null +++ b/tests/libcommon/test.conf @@ -0,0 +1,8 @@ +[Section1] +# this is comment +Key1=Value1 + +[Section2] +# this is comment +Key2=Value2 +Key3=Value3 diff --git a/tests/test-main.c b/tests/test-main.c new file mode 100644 index 0000000..0451498 --- /dev/null +++ b/tests/test-main.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include + +#include "test-main.h" + +int main(int argc, char *argv[]) +{ + int fail = 0; + DIR *dir; + struct dirent *ent; + + dir = opendir(TEST_SUITE_DIRECTORY); + if (!dir) { + printf("Failed to opendir, %m\n"); + return 1; + } + + while ((ent = readdir(dir))) { + void *handle; + char sopath[512] = {0, }; + int (*run_test_suite) (void); + + if (!strstr(ent->d_name, ".so")) + continue; + + snprintf(sopath, sizeof(sopath), "%s/%s", TEST_SUITE_DIRECTORY, ent->d_name); + + handle = dlopen(sopath, RTLD_LAZY); + if (!handle) { + printf("Failed to dlopen, %s\n", dlerror()); + continue; + } + + run_test_suite = dlsym(handle, "run_test_suite"); + if (!run_test_suite) { + printf("Failed to dlsym, %s\n", dlerror()); + dlclose(handle); + continue; + } + + fail += run_test_suite(); + } + + closedir(dir); + + return fail; +} diff --git a/tests/test-main.h b/tests/test-main.h new file mode 100644 index 0000000..4b04a85 --- /dev/null +++ b/tests/test-main.h @@ -0,0 +1,10 @@ +#ifndef __TEST_MAIN_H__ +#define __TEST_MAIN_H__ + +#include +#include +#include +#include + +#endif //__TEST_MAIN_H__ + diff --git a/tests/test-mock.c b/tests/test-mock.c new file mode 100644 index 0000000..4e7f260 --- /dev/null +++ b/tests/test-mock.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include + +#include "test-main.h" +#include "test-mock.h" + +//static FILE *__fp = NULL; + +int __wrap_open(const char *pathname, int flags) +{ + const char *mock_pathname; + int mock_flags; + + mock_pathname = mock_ptr_type(char *); + if (mock_pathname == NULL) { + errno = -ENOENT; + return -1; + } + + mock_flags = mock_type(int); + + return open(mock_pathname, mock_flags); +} + +int __wrap_open64(const char *pathname, int flags) +{ + return __wrap_open(pathname, flags); +} + + +void mock_open(const char *pathname, int flags) +{ + will_return(__wrap_open, pathname); + will_return(__wrap_open, flags); +} + +/* +FILE *__wrap_fopen(const char *pathname, const char *mode) +{ + const char *mock_pathname = mock_ptr_type(char *); + const char *mock_mode = mock_ptr_type(char *); + + __fp = fopen(mock_pathname, mock_mode); + + return __fp; +} + +FILE *__wrap_fopen64(const char *pathname, const char *mode) +{ + return __wrap_fopen(pathname, mode); + +} + +int __wrap_fclose(FILE *stream) +{ + return 0; +} + +int __wrap_fclose64(FILE *stream) +{ + return __wrap_fclose(stream); +} +*/ diff --git a/tests/test-mock.h b/tests/test-mock.h new file mode 100644 index 0000000..22c7196 --- /dev/null +++ b/tests/test-mock.h @@ -0,0 +1,8 @@ +#ifndef __TEST_MOCK_H__ +#define __TEST_MOCK_H__ + +#include + +void mock_open(const char *pathname, int flags); + +#endif //__TEST_MOCK_H__ -- 2.7.4 From 24159abc46b34ca5dad1541398b1beb5e3533440 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 8 Nov 2021 17:18:17 -0800 Subject: [PATCH 04/16] Fix svace issue Change-Id: I920fbb2f16b8af7cf164c58a18a1eb6ff2f1db9a Signed-off-by: Youngjae Cho --- tests/test-main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-main.c b/tests/test-main.c index 0451498..5af3e94 100644 --- a/tests/test-main.c +++ b/tests/test-main.c @@ -42,6 +42,7 @@ int main(int argc, char *argv[]) } fail += run_test_suite(); + dlclose(handle); } closedir(dir); -- 2.7.4 From d01a2dc1a7f1db20d806b19e3a1c956e390fa26e Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Tue, 19 Oct 2021 14:26:02 +0900 Subject: [PATCH 05/16] Modify dbus object path Change-Id: I6377613b93197d45e7873004767a22ddbedb68a1 Signed-off-by: Unsung Lee --- src/libgdbus/dbus-iface-system.h | 3 ++- src/libgdbus/libgdbus.c | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libgdbus/dbus-iface-system.h b/src/libgdbus/dbus-iface-system.h index e65384a..8b8c27b 100644 --- a/src/libgdbus/dbus-iface-system.h +++ b/src/libgdbus/dbus-iface-system.h @@ -39,6 +39,7 @@ #define DBUS_BUS_NAME "org.freedesktop.DBus" #define DBUS_OBJECT_PATH "/org/freedesktop/DBus" #define DBUS_INTERFACE_NAME DBUS_BUS_NAME +#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties" /******************************************************************************* * @@ -338,4 +339,4 @@ /***********************************************/ -#endif \ No newline at end of file +#endif diff --git a/src/libgdbus/libgdbus.c b/src/libgdbus/libgdbus.c index 9295582..9eaa937 100644 --- a/src/libgdbus/libgdbus.c +++ b/src/libgdbus/libgdbus.c @@ -525,9 +525,9 @@ char **gdbus_get_owner_list(dbus_handle_h handle, const char *bus_name) } reply = g_dbus_connection_call_sync(dh->conn, - "org.freedesktop.DBus", - "/", - "org.freedesktop.DBus", + DBUS_BUS_NAME, + DBUS_OBJECT_PATH, + DBUS_INTERFACE_NAME, "ListQueuedOwners", g_variant_new("(s)", bus_name), NULL, @@ -2603,7 +2603,8 @@ int gdbus_connection_get_sender_pid(GDBusConnection *conn, const char * sender) } reply = g_dbus_connection_call_sync(conn, - "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetConnectionUnixProcessID", + DBUS_BUS_NAME, DBUS_OBJECT_PATH, DBUS_INTERFACE_NAME, + "GetConnectionUnixProcessID", g_variant_new("(s)", sender), NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, @@ -2813,7 +2814,7 @@ int check_systemd_active(void) ret = gdbus_call_sync_with_reply("org.freedesktop.systemd1", "/org/freedesktop/systemd1/unit/default_2etarget", - "org.freedesktop.DBus.Properties", + DBUS_INTERFACE_PROPERTIES, "Get", g_variant_new("(ss)", "org.freedesktop.systemd1.Unit", "ActiveState"), &reply); -- 2.7.4 From ccd9bb816cfb02a9ed6e21a726dba6d96526eff8 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 9 Dec 2021 17:14:37 +0900 Subject: [PATCH 06/16] Change interface DEVICED_INTERFACE_POWER Change-Id: I3c605793fb70e4948c8a95dbb2d4c1bf4b75b39f Signed-off-by: Youngjae Cho --- src/libgdbus/dbus-iface-system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libgdbus/dbus-iface-system.h b/src/libgdbus/dbus-iface-system.h index 8b8c27b..a5b838e 100644 --- a/src/libgdbus/dbus-iface-system.h +++ b/src/libgdbus/dbus-iface-system.h @@ -69,7 +69,7 @@ #define DEVICED_INTERFACE_PASS DEVICED_INTERFACE_NAME".pass" /* Power service: set resetkey disable operations about power */ #define DEVICED_PATH_POWER DEVICED_OBJECT_PATH"/Power" -#define DEVICED_INTERFACE_POWER DEVICED_INTERFACE_NAME".power" +#define DEVICED_INTERFACE_POWER DEVICED_INTERFACE_NAME".Power" /* Storage service: get storage size operatioins about storage */ #define DEVICED_PATH_STORAGE DEVICED_OBJECT_PATH"/Storage" #define DEVICED_INTERFACE_STORAGE DEVICED_INTERFACE_NAME".storage" -- 2.7.4 From b953f57f3f6a1aa73d025e83f5d0422a0fd765a0 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 20 Dec 2021 16:46:29 +0900 Subject: [PATCH 07/16] file: add libsys_parse_cmdline_scanf() libsys_parse_cmdline_scanf() scans tokens of file /proc/cmdline. The parameters and return value have same semantics to those of scanf() family. Change-Id: Iac5838fe36b0ed2de36eb0412a13691ba0a50c3b Signed-off-by: Youngjae Cho --- src/libcommon/file.c | 27 +++++++++++++++++++++++++++ src/libcommon/file.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/libcommon/file.c b/src/libcommon/file.c index b3ca5f1..2b0c6ba 100644 --- a/src/libcommon/file.c +++ b/src/libcommon/file.c @@ -131,3 +131,30 @@ int sys_set_str(char *fname, char *val) return 0; } + +int libsys_parse_cmdline_scanf(const char *format, ...) +{ + FILE *fp = NULL; + char *token = NULL; + size_t len = 0; + va_list ap; + int ret = 0; + + fp = fopen("/proc/cmdline", "r"); + if (!fp) + return 0; + + va_start(ap, format); + + while (getdelim(&token, &len, ' ', fp) != EOF) { + ret = vsscanf(token, format, ap); + if (ret > 0) + break; + } + + free(token); + va_end(ap); + fclose(fp); + + return ret; +} diff --git a/src/libcommon/file.h b/src/libcommon/file.h index 1250da8..31df8fa 100644 --- a/src/libcommon/file.h +++ b/src/libcommon/file.h @@ -18,11 +18,14 @@ #ifndef __LIBCOMMON_FILE_H__ #define __LIBCOMMON_FILE_H__ +#include + int sys_read_buf(char *file, char *buf, int len); int sys_write_buf(char *file, char *buf); int sys_get_int(char *fname, int *val); int sys_get_str(char *fname, char *str, int len); int sys_set_int(char *fname, int val); int sys_set_str(char *fname, char *val); +int libsys_parse_cmdline_scanf(const char *format, ...); #endif /* __LIBCOMMON_FILE_H__ */ -- 2.7.4 From 0134007e65c5a07440380ce536a45746ac224482 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 23 Dec 2021 16:33:30 +0900 Subject: [PATCH 08/16] ini-parser: add libsys_config_parse_by_section() The original function, config_parse(), parses configuration file line by line. Due to this, a parser, which is registered by the config_parse(), can hardly handle out-of-ordered section/property or multiple sections with same name. The libsys_config_parse_by_section() now parses configuration file by section. Therefore a parser can now find whole properties of a section when the section is conveyed to the parser. Change-Id: I08f09e2f6aefabea497393edb3c1f88dbe2d8850 Signed-off-by: Youngjae Cho --- src/libcommon/ini-parser.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++ src/libcommon/ini-parser.h | 28 +++++++++++++- 2 files changed, 118 insertions(+), 2 deletions(-) diff --git a/src/libcommon/ini-parser.c b/src/libcommon/ini-parser.c index f3ed8c7..a82192c 100644 --- a/src/libcommon/ini-parser.c +++ b/src/libcommon/ini-parser.c @@ -129,3 +129,95 @@ error: return ret; } +/* scan format after trimming leading/trailing whitespace, comment */ +static int sscanf_trim_whitespace_comment(const char *str, const char *format, ...) +{ + char trimmed_str[1024] = { 0, }; + va_list ap; + int ret; + + str += strspn(str, " \t"); + ret = sscanf(str, "%1023[^ \t\n\r#]", trimmed_str); + if (ret != 1) + return 0; + + va_start(ap, format); + ret = vsscanf(trimmed_str, format, ap); + va_end(ap); + + return ret; +} + +static void free_data(gpointer data) +{ + free(data); +} + +int libsys_config_parse_by_section(const char *fname, int cb(const struct parse_result *, void *), void *user_data) +{ + FILE *fp = NULL; + char *line = NULL; + size_t len = 0; + size_t n_read; + int ret = 0; + int retval; + struct parse_result result = { 0, }; + struct section_property *prop; + char tmp_sectname[128]; + char tmp_key[128]; + char tmp_value[128]; + + if (!fname || !cb) + return -EINVAL; + + fp = fopen(fname, "r"); + if (!fp) { + _E("Failed to open file '%s'.", fname); + return -errno; + } + + while (getline(&line, &len, fp) != EOF) { + // find section + retval = sscanf_trim_whitespace_comment(line, "[%127[^]]]", tmp_sectname); + if (retval != 1) + continue; + + result.section = strndup(tmp_sectname, sizeof(tmp_sectname)); + + // parse properties within the section + while((n_read = getline(&line, &len, fp)) != EOF) { + retval = sscanf_trim_whitespace_comment(line, "[%127[^]]]", tmp_sectname); + if (retval == 1) { // found next section. stop parsing properties + fseek(fp, -n_read, SEEK_CUR); + break; + } + + retval = sscanf_trim_whitespace_comment(line, "%127[^=]=%127s", tmp_key, tmp_value); + if (retval == 2) { // found property + prop = calloc(1, sizeof(struct section_property)); + if (!prop) + continue; + strncpy(prop->key, tmp_key, sizeof(prop->key) - 1); + strncpy(prop->value, tmp_value, sizeof(prop->value) - 1); + result.props = g_list_append(result.props, prop); + } + } + + ret = cb(&result, user_data); + + free(result.section); + result.section = NULL; + + g_list_free_full(result.props, free_data); + result.props = NULL; + + if (ret != 0) + break; + } + + if (fp) + fclose(fp); + free(line); + + return ret; +} diff --git a/src/libcommon/ini-parser.h b/src/libcommon/ini-parser.h index f30096c..7af9f42 100644 --- a/src/libcommon/ini-parser.h +++ b/src/libcommon/ini-parser.h @@ -20,13 +20,28 @@ #ifndef __INI_PARSER_H__ #define __INI_PARSER_H__ +#include + #define MATCH(a, b) (!strncmp(a, b, strlen(a))) #define SET_CONF(a, b) (a = (b > 0.0 ? b : a)) struct parse_result { char *section; - char *name; - char *value; + union { + // config_parse() + struct { + char *name; + char *value; + }; + + // config_parse_by_section() + GList *props; + }; +}; + +struct section_property { + char key[128]; + char value[128]; }; /** @@ -39,4 +54,13 @@ struct parse_result { int config_parse(const char *file_name, int cb(struct parse_result *result, void *user_data), void *user_data); + +/** + * @brief Parse config file and call callback\n + * @param[in] file_name conf file. + * @param[in] cb cb is called when conf file is parsed by section + * @param[in] user_data user data is passed to cb. + * @return 0 on success, negative if failed + */ +int libsys_config_parse_by_section(const char *file_name, int cb(const struct parse_result *, void *), void *user_data); #endif -- 2.7.4 From 0a9dfff66ff265b19f5bd51a76eb2abb8af8363b Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Thu, 20 Jan 2022 14:14:21 +0900 Subject: [PATCH 09/16] Check tmp buffer overflow Change-Id: I5de5195293f72444d91d7b8f89f72bfe3ac5301e Signed-off-by: SangYoun Kwak --- src/libgdbus/libgdbus.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libgdbus/libgdbus.c b/src/libgdbus/libgdbus.c index 9eaa937..917b98f 100644 --- a/src/libgdbus/libgdbus.c +++ b/src/libgdbus/libgdbus.c @@ -802,6 +802,11 @@ static int _get_xml_from_interfaces(char **xml, const dbus_interface_s *interfac ei = _check_brace(pmethod->signature_in + m + 1); if (ei > 0) { char tmp[128] = {0,}; + if(ei + 1 > sizeof(tmp) - 1) { + _E("tmp buffer for signature_in overflow. sizeof(tmp)=%lu ei=%d\n", sizeof(tmp), ei); + free(buf); + return -1; + } strncpy(tmp, pmethod->signature_in + m, ei + 1); nwrite += snprintf(buf + nwrite, buf_cal_free_space(buf_len, nwrite), "\t\t\t""""\n", tmp, m); m += ei; @@ -825,6 +830,11 @@ static int _get_xml_from_interfaces(char **xml, const dbus_interface_s *interfac ei = _check_brace(pmethod->signature_out + m + 1); if (ei > 0) { char tmp[128] = {0,}; + if(ei + 1 > sizeof(tmp) - 1) { + _E("tmp buffer for signature_out overflow. sizeof(tmp)=%lu ei=%d\n", sizeof(tmp), ei); + free(buf); + return -1; + } strncpy(tmp, pmethod->signature_out + m, ei + 1); nwrite += snprintf(buf + nwrite, buf_cal_free_space(buf_len, nwrite), "\t\t\t""""\n", tmp, m); m += ei; -- 2.7.4 From c6ecf79fba84a09feecd7314a150f07f374f530c Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Wed, 6 Apr 2022 15:58:55 +0900 Subject: [PATCH 10/16] Add description for the declaration of the file utils Change-Id: Ia8367863a59fd3f31738fa62db1d0618c4e8ba5a Signed-off-by: SangYoun Kwak --- src/libcommon/file.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/libcommon/file.h b/src/libcommon/file.h index 31df8fa..7154494 100644 --- a/src/libcommon/file.h +++ b/src/libcommon/file.h @@ -20,12 +20,76 @@ #include +/** + * @brief Open file, read and close + * + * @param[in] file File name + * @param[in] len Length of buffer + * @param[out] buf Buffer that stores read data + * + * @return read length if read was successful else negative error value + */ int sys_read_buf(char *file, char *buf, int len); + +/** + * @brief Open file, write and close + * + * @param[in] file File name + * @param[out] buf Buffer that stores data to write + * + * @return zero on success otherwise negative error value + */ int sys_write_buf(char *file, char *buf); + +/** + * @brief Read integer from file + * + * @param[in] fname File name + * @param[out] val integer value that read from file + * + * @return read length if reading integer was successful else negative error value + */ int sys_get_int(char *fname, int *val); + +/** + * @brief Read string from file + * + * @param[in] fname File name + * @param[in] len String length + * @param[out] str Buffer + * + * @return zero on success otherwise negative error value + */ int sys_get_str(char *fname, char *str, int len); + +/** + * @brief Write integer to file + * + * @param[in] fname File name + * @param[in] val Integer value to write + * + * @return zero on success otherwise negative error value + */ int sys_set_int(char *fname, int val); + +/** + * @brief Write string to file + * + * @param[in] fname File name + * @param[out] val String to write + * + * @return zero on success otherwise negative error value + */ int sys_set_str(char *fname, char *val); + +/** + * @brief Parse format from /proc/cmdline + * + * @param[in] format Format string + * @param[out] ... Variable argument + * + * @return zero if cannot read else the number of matched and assigned items + */ int libsys_parse_cmdline_scanf(const char *format, ...); #endif /* __LIBCOMMON_FILE_H__ */ -- 2.7.4 From 7382ed2ef0eb3de36631957c0cee0cbfaf8a8d5b Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 13 Apr 2022 11:26:17 +0900 Subject: [PATCH 11/16] Add libsys_is_emulator() and refactor libsys_is_container() Change-Id: Ic2cce60d76704803cd1c54aa70a9c795b92c9906 Signed-off-by: Hyotaek Shim Signed-off-by: Youngjae Cho --- CMakeLists.txt | 3 ++- packaging/libsyscommon.spec | 10 +++++----- src/.gitignore | 2 -- src/libcommon/common.c | 47 +++++++++++++++++++++++++++++++++++++++++---- src/libcommon/common.h | 14 +++++++++++++- 5 files changed, 63 insertions(+), 13 deletions(-) delete mode 100644 src/.gitignore diff --git a/CMakeLists.txt b/CMakeLists.txt index bebdb2e..2df65ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,9 @@ INCLUDE(FindPkgConfig) pkg_check_modules(syscommon REQUIRED glib-2.0 gio-2.0 + gio-unix-2.0 dlog - gio-unix-2.0) + capi-system-info) FOREACH(flag ${syscommon_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index 4ec8ea2..d4bc949 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -7,16 +7,16 @@ Group: System/Libraries Source: %{name}-%{version}.tar.gz Source1001: %{name}.manifest +BuildRequires: cmake +BuildRequires: pkgconfig(cmocka) BuildRequires: pkgconfig(glib-2.0) >= 2.44 BuildRequires: pkgconfig(gio-2.0) >= 2.44 BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(cmocka) -BuildRequires: cmake - -Requires: /bin/cp +BuildRequires: pkgconfig(capi-system-info) -Requires(post): /sbin/ldconfig +Requires: /bin/cp +Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig %description diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 7ca4570..0000000 --- a/src/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/test-* \ No newline at end of file diff --git a/src/libcommon/common.c b/src/libcommon/common.c index fd3a11b..f2d1831 100644 --- a/src/libcommon/common.c +++ b/src/libcommon/common.c @@ -15,15 +15,54 @@ */ #include +#include +#include #include +#include +#include "shared/log.h" #include "common.h" -#define CONTAINER_FILE_PATH "/run/systemd/container" +#define FEATURE_MODEL_NAME "http://tizen.org/system/model_name" +#define FEATURE_MODEL_NAME_EMULATOR "Emulator" +#define CONTAINER_FILE_PATH "/run/systemd/container" -bool is_container() +bool libsys_is_emulator(void) { + int ret = 0; + char *model_name = NULL; + static bool is_emul = false; + static bool is_cached = false; + + if (is_cached) + return is_emul; + + ret = system_info_get_platform_string(FEATURE_MODEL_NAME, &model_name); + if (ret < 0) { + _E("Cannot get model name: %d, libsys_is_emulator() returns false on operation failure", ret); + return false; + } + + if (!strncmp(FEATURE_MODEL_NAME_EMULATOR, model_name, strlen(model_name) + 1)) + is_emul = true; + + is_cached = true; + free(model_name); + + return is_emul; +} + +bool libsys_is_container(void) +{ + static bool is_container = false; + static bool is_cached = false; + + if (is_cached) + return is_container; + if (access(CONTAINER_FILE_PATH, F_OK) == 0) - return true; + is_container = true; + + is_cached = true; - return false; + return is_container; } diff --git a/src/libcommon/common.h b/src/libcommon/common.h index 43a1fae..057bad4 100644 --- a/src/libcommon/common.h +++ b/src/libcommon/common.h @@ -19,6 +19,18 @@ #include -bool is_container(); +/** + * @brief Check if running on emulator + * + * @return true if running on emulator, otherwise false even on operation failure + */ +bool libsys_is_emulator(void); + +/** + * @brief Check if running on container + * + * @return true if running on container, otherwise false even on operation failure + */ +bool libsys_is_container(void); #endif /* __LIBCOMMON_COMMON_H__ */ -- 2.7.4 From 61dbc6b6e81fb35432bfd17960cb04433a5628cf Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 17 Jan 2022 14:17:58 +0900 Subject: [PATCH 12/16] Fix build warnings Change-Id: Ib5784f64fb176d2916f376ca4c0ca05d6e363c36 Signed-off-by: Youngjae Cho --- src/libcommon/ini-parser.c | 6 ++++-- tests/libcommon/test-common.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libcommon/ini-parser.c b/src/libcommon/ini-parser.c index a82192c..f08b28a 100644 --- a/src/libcommon/ini-parser.c +++ b/src/libcommon/ini-parser.c @@ -197,8 +197,10 @@ int libsys_config_parse_by_section(const char *fname, int cb(const struct parse_ prop = calloc(1, sizeof(struct section_property)); if (!prop) continue; - strncpy(prop->key, tmp_key, sizeof(prop->key) - 1); - strncpy(prop->value, tmp_value, sizeof(prop->value) - 1); + /* to suppress build warning of strncpy(-Wstringop-truncation), + * use memcpy instead. */ + memcpy(prop->key, tmp_key, sizeof(prop->key) - 1); + memcpy(prop->value, tmp_value, sizeof(prop->value) - 1); result.props = g_list_append(result.props, prop); } } diff --git a/tests/libcommon/test-common.c b/tests/libcommon/test-common.c index 76e770c..392830a 100644 --- a/tests/libcommon/test-common.c +++ b/tests/libcommon/test-common.c @@ -121,7 +121,7 @@ static void test_list_append_p(void **state) i = 0; SYS_G_LIST_FOREACH(head, elem, elem2) { - value = (int) elem2; + value = (int)(intptr_t) elem2; assert_int_equal(value, i++); } } @@ -142,7 +142,7 @@ static void test_list_prepend_p(void **state) i = 10; SYS_G_LIST_FOREACH(head, elem, elem2) { - value = (int) elem2; + value = (int)(intptr_t) elem2; assert_int_equal(value, --i); } } -- 2.7.4 From e9fa64472f4d46e4a57d4cd24462789c7efda446 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 27 Apr 2022 11:44:15 +0900 Subject: [PATCH 13/16] Add missing Requires to pkgconfig(capi-system-info) Change-Id: I677a0b3995caaf937e54a318ea655b8822539cd6 Signed-off-by: Hyotaek Shim --- packaging/libsyscommon.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index d4bc949..7be112d 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -29,6 +29,7 @@ Requires: libsyscommon = %{version} Requires: pkgconfig(gio-2.0) Requires: pkgconfig(gio-unix-2.0) Requires: pkgconfig(dlog) +Requires: pkgconfig(capi-system-info) %description -n libsyscommon-devel Development header files for system common library. -- 2.7.4 From 37a724517506368bc7dc9f81db64bb8de8c71c5c Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Sat, 28 May 2022 10:43:38 +0900 Subject: [PATCH 14/16] Fix build errors - different header path Public) /include/system/system_info.h VD TV) /include/capi-system-info/system_info.h Change-Id: Ibae5b76527051ecda6b7e24d546846886e8cb213 Signed-off-by: Hyotaek Shim --- src/libcommon/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcommon/common.c b/src/libcommon/common.c index f2d1831..8f9e973 100644 --- a/src/libcommon/common.c +++ b/src/libcommon/common.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "shared/log.h" #include "common.h" -- 2.7.4 From 64006e638e2f1151d400490ca99ea6c96ddd0de1 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 9 Jun 2022 17:12:42 +0900 Subject: [PATCH 15/16] ini-parser: check closing bracket when parsing section name Change-Id: Ic939bfd6f57c9ee20e41fe7adf34f0debe3539e6 Signed-off-by: Youngjae Cho --- src/libcommon/ini-parser.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcommon/ini-parser.c b/src/libcommon/ini-parser.c index f08b28a..0f145c6 100644 --- a/src/libcommon/ini-parser.c +++ b/src/libcommon/ini-parser.c @@ -166,6 +166,7 @@ int libsys_config_parse_by_section(const char *fname, int cb(const struct parse_ char tmp_sectname[128]; char tmp_key[128]; char tmp_value[128]; + char closing_bracket; if (!fname || !cb) return -EINVAL; @@ -178,16 +179,16 @@ int libsys_config_parse_by_section(const char *fname, int cb(const struct parse_ while (getline(&line, &len, fp) != EOF) { // find section - retval = sscanf_trim_whitespace_comment(line, "[%127[^]]]", tmp_sectname); - if (retval != 1) + retval = sscanf_trim_whitespace_comment(line, "[%127[^]]%c", tmp_sectname, &closing_bracket); + if (retval != 2 || closing_bracket != ']') continue; result.section = strndup(tmp_sectname, sizeof(tmp_sectname)); // parse properties within the section while((n_read = getline(&line, &len, fp)) != EOF) { - retval = sscanf_trim_whitespace_comment(line, "[%127[^]]]", tmp_sectname); - if (retval == 1) { // found next section. stop parsing properties + retval = sscanf_trim_whitespace_comment(line, "[%127[^]]%c", tmp_sectname, &closing_bracket); + if (retval == 2 && closing_bracket == ']') { // found next section. stop parsing properties fseek(fp, -n_read, SEEK_CUR); break; } -- 2.7.4 From 34ba9820f76a2af5e98aeb7f59a6ad48ee98e849 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 18 Aug 2022 16:40:18 +0900 Subject: [PATCH 16/16] Relicense libsyscommon package as MIT to prevent license conflict issues For example, Apache-2.0 is in conflict with GPL-2.0. Change-Id: I52aff6d3d7083fa20939f1fd356c299ddc69e0cf Signed-off-by: Hyotaek Shim --- LICENSE.Apache-2.0 | 202 --------------------------------------- LICENSE.MIT | 9 ++ packaging/libsyscommon.spec | 8 +- src/libcommon/common.c | 30 +++--- src/libcommon/common.h | 30 +++--- src/libcommon/file.c | 30 +++--- src/libcommon/file.h | 37 +++---- src/libcommon/ini-parser.c | 30 +++--- src/libcommon/ini-parser.h | 31 +++--- src/libcommon/list.h | 30 +++--- src/libgdbus/dbus-iface-system.h | 30 +++--- src/libgdbus/libgdbus.c | 30 +++--- src/libgdbus/libgdbus.h | 30 +++--- src/libsystemd/libsystemd.c | 30 +++--- src/libsystemd/libsystemd.h | 31 +++--- src/shared/log-macro.h | 31 +++--- src/shared/log.h | 31 +++--- 17 files changed, 258 insertions(+), 392 deletions(-) delete mode 100644 LICENSE.Apache-2.0 create mode 100644 LICENSE.MIT diff --git a/LICENSE.Apache-2.0 b/LICENSE.Apache-2.0 deleted file mode 100644 index d645695..0000000 --- a/LICENSE.Apache-2.0 +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/LICENSE.MIT b/LICENSE.MIT new file mode 100644 index 0000000..80b056d --- /dev/null +++ b/LICENSE.MIT @@ -0,0 +1,9 @@ +The MIT License + +Copyright (c) 2022 Samsung Electronics Co., Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index 7be112d..d18dac8 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -2,7 +2,7 @@ Name: libsyscommon Summary: System Libraries Version: 4.1 Release: 0%{?release_flags} -License: Apache-2.0 +License: MIT Group: System/Libraries Source: %{name}-%{version}.tar.gz Source1001: %{name}.manifest @@ -24,7 +24,7 @@ System common utility libraries. %package -n libsyscommon-devel Summary: Header files for system common library -License: Apache-2.0 +License: MIT Requires: libsyscommon = %{version} Requires: pkgconfig(gio-2.0) Requires: pkgconfig(gio-unix-2.0) @@ -57,13 +57,13 @@ touch debugsources.list %files %defattr(-,root,root,-) %manifest %{name}.manifest -%license LICENSE.Apache-2.0 +%license LICENSE.MIT %{_libdir}/libsyscommon.so.* %files -n libsyscommon-devel %defattr(-,root,root,-) %manifest %{name}.manifest -%license LICENSE.Apache-2.0 +%license LICENSE.MIT %{_libdir}/libsyscommon.so %{_includedir}/libsyscommon/*.h %{_libdir}/pkgconfig/libsyscommon.pc diff --git a/src/libcommon/common.c b/src/libcommon/common.c index 8f9e973..50cdee6 100644 --- a/src/libcommon/common.c +++ b/src/libcommon/common.c @@ -1,18 +1,24 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved +/* MIT License * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include #include diff --git a/src/libcommon/common.h b/src/libcommon/common.h index 057bad4..bbeee46 100644 --- a/src/libcommon/common.h +++ b/src/libcommon/common.h @@ -1,18 +1,24 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved +/* MIT License * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __LIBCOMMON_COMMON_H__ #define __LIBCOMMON_COMMON_H__ diff --git a/src/libcommon/file.c b/src/libcommon/file.c index 2b0c6ba..e0a3b29 100644 --- a/src/libcommon/file.c +++ b/src/libcommon/file.c @@ -1,18 +1,24 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved +/* MIT License * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include #include diff --git a/src/libcommon/file.h b/src/libcommon/file.h index 7154494..84fca0c 100644 --- a/src/libcommon/file.h +++ b/src/libcommon/file.h @@ -1,19 +1,24 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* MIT License + * + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __LIBCOMMON_FILE_H__ #define __LIBCOMMON_FILE_H__ diff --git a/src/libcommon/ini-parser.c b/src/libcommon/ini-parser.c index 0f145c6..e7d7605 100644 --- a/src/libcommon/ini-parser.c +++ b/src/libcommon/ini-parser.c @@ -1,20 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include #include diff --git a/src/libcommon/ini-parser.h b/src/libcommon/ini-parser.h index 7af9f42..dccd1ac 100644 --- a/src/libcommon/ini-parser.h +++ b/src/libcommon/ini-parser.h @@ -1,21 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __INI_PARSER_H__ #define __INI_PARSER_H__ diff --git a/src/libcommon/list.h b/src/libcommon/list.h index ab27843..aa9e947 100644 --- a/src/libcommon/list.h +++ b/src/libcommon/list.h @@ -1,20 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __LIBCOMMON_LIST_H__ #define __LIBCOMMON_LIST_H__ diff --git a/src/libgdbus/dbus-iface-system.h b/src/libgdbus/dbus-iface-system.h index a5b838e..a4f69da 100644 --- a/src/libgdbus/dbus-iface-system.h +++ b/src/libgdbus/dbus-iface-system.h @@ -1,20 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __DBUS_SYSTEM_IFACE_H__ #define __DBUS_SYSTEM_IFACE_H__ diff --git a/src/libgdbus/libgdbus.c b/src/libgdbus/libgdbus.c index 917b98f..32c15ed 100644 --- a/src/libgdbus/libgdbus.c +++ b/src/libgdbus/libgdbus.c @@ -1,20 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include #include diff --git a/src/libgdbus/libgdbus.h b/src/libgdbus/libgdbus.h index 6828b76..f909d76 100644 --- a/src/libgdbus/libgdbus.h +++ b/src/libgdbus/libgdbus.h @@ -1,20 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __DBUS_SYSTEM_H__ #define __DBUS_SYSTEM_H__ diff --git a/src/libsystemd/libsystemd.c b/src/libsystemd/libsystemd.c index 8b8295c..3d2fbc2 100644 --- a/src/libsystemd/libsystemd.c +++ b/src/libsystemd/libsystemd.c @@ -1,20 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include #include diff --git a/src/libsystemd/libsystemd.h b/src/libsystemd/libsystemd.h index 1f807d3..9080fcf 100644 --- a/src/libsystemd/libsystemd.h +++ b/src/libsystemd/libsystemd.h @@ -1,21 +1,24 @@ -/* - * libsyscommon +/* MIT License * - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __DBUS_SYSTEMD_H__ #define __DBUS_SYSTEMD_H__ diff --git a/src/shared/log-macro.h b/src/shared/log-macro.h index 8532b37..9893820 100644 --- a/src/shared/log-macro.h +++ b/src/shared/log-macro.h @@ -1,21 +1,24 @@ -/* - * deviced +/* MIT License * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __LOG_MACRO_H__ #define __LOG_MACRO_H__ diff --git a/src/shared/log.h b/src/shared/log.h index ad914a3..09a9eb4 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -1,21 +1,24 @@ -/* - * deviced +/* MIT License * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef __LOG_H__ #define __LOG_H__ -- 2.7.4