diff --git a/interfaces/innerkits/reboot/init_reboot_innerkits.c b/interfaces/innerkits/reboot/init_reboot_innerkits.c index d9bc510cad746daf358ce61f074e2c51c770fcd7..f17a7e9b82dc13710cbf2ab97e7b0994e145906a 100644 --- a/interfaces/innerkits/reboot/init_reboot_innerkits.c +++ b/interfaces/innerkits/reboot/init_reboot_innerkits.c @@ -32,7 +32,7 @@ #define DOREBOOT_PARAM "reboot.ut" #endif -int DoReboot(const char *option) +int DoReboot_(const char *option) { char value[MAX_REBOOT_OPTION_SIZE]; int ret = 0; @@ -63,3 +63,25 @@ int DoReboot(const char *option) BEGET_ERROR_CHECK(ret == 0, return -1, "Set parameter to trigger reboot command \" %s \" failed", value); return 0; } + +int DoReboot(const char *option) +{ + // check if param set ok + const int maxCount = 10; + int count = 0; + DoReboot_(option); + while (count < maxCount) { + usleep(100 * 1000); // 100 * 1000 wait 100ms + char result[10] = {0}; // 10 stop len + uint32_t len = sizeof(result); + int ret = SystemGetParameter(STARTUP_DEVICE_CTL, result, &len); + if (ret == 0 && strcmp(result, DEVICE_CMD_STOP) == 0) { + BEGET_LOGE("Success to reboot system"); + return 0; + } + count++; + DoReboot_(option); + } + BEGET_LOGE("Failed to reboot system"); + return 0; +} diff --git a/interfaces/innerkits/sandbox/app-sandbox.json b/interfaces/innerkits/sandbox/app-sandbox.json index 109121f474b9c4907ab3d6960966c2d4099c745c..a887fc3abc7d708f976e985842a3648d2e030441 100644 --- a/interfaces/innerkits/sandbox/app-sandbox.json +++ b/interfaces/innerkits/sandbox/app-sandbox.json @@ -44,6 +44,22 @@ "src-path" : "/data", "sandbox-path" : "/data", "sandbox-flags" : [ "bind", "rec", "private" ] + }, { + "src-path" : "/system/fonts", + "sandbox-path" : "/system/fonts", + "sandbox-flags" : [ "bind", "rec", "private" ] + }, { + "src-path" : "/config", + "sandbox-path" : "/config", + "sandbox-flags" : [ "bind", "rec" ] + }, { + "src-path" : "/sys_prod", + "sandbox-path" : "/sys_prod", + "sandbox-flags" : [ "bind", "rec" ] + }, { + "src-path" : "/storage", + "sandbox-path" : "/storage", + "sandbox-flags" : [ "bind", "rec", "private" ] } ], "mount-bind-files" : [{ diff --git a/interfaces/innerkits/sandbox/privapp-sandbox.json b/interfaces/innerkits/sandbox/privapp-sandbox.json index ff1e599d06ac829bec98c52c9c03dcd0d405b713..7e8b0c06a642072a1428cac5334fa354228fed8b 100644 --- a/interfaces/innerkits/sandbox/privapp-sandbox.json +++ b/interfaces/innerkits/sandbox/privapp-sandbox.json @@ -48,6 +48,22 @@ "src-path" : "/data", "sandbox-path" : "/data", "sandbox-flags" : [ "bind", "rec" ] + }, { + "src-path" : "/system/fonts", + "sandbox-path" : "/system/fonts", + "sandbox-flags" : [ "bind", "rec", "private" ] + }, { + "src-path" : "/config", + "sandbox-path" : "/config", + "sandbox-flags" : [ "bind", "rec" ] + }, { + "src-path" : "/sys_prod", + "sandbox-path" : "/sys_prod", + "sandbox-flags" : [ "bind", "rec" ] + }, { + "src-path" : "/storage", + "sandbox-path" : "/storage", + "sandbox-flags" : [ "bind", "rec", "private" ] } ], "mount-bind-files": [{ diff --git a/services/include/init_hashmap.h b/services/include/init_hashmap.h index d52a66ca3bd464c4dc3d5c2b1dd39f5a761bd75c..4e869bdeb7a8ce1804a058d646b5937a808fa650 100644 --- a/services/include/init_hashmap.h +++ b/services/include/init_hashmap.h @@ -59,6 +59,8 @@ void HashMapRemove(HashMapHandle handle, const void *key); HashNode *HashMapGet(HashMapHandle handle, const void *key); HashNode *HashMapFind(HashMapHandle handle, int hashCode, const void *key, HashKeyCompare keyCompare); +void HashMapTraverse(HashMapHandle handle, void (*hashNodeTraverse)(const HashNode *node, const void *context), + const void *context); #ifdef __cplusplus #if __cplusplus } diff --git a/services/init/init_common_service.c b/services/init/init_common_service.c index 052d8dbd69e1200905cdf97f6bd49a2fd5ab2240..a900de364cde86f05e209c3ede5203bf2c4aeb1f 100644 --- a/services/init/init_common_service.c +++ b/services/init/init_common_service.c @@ -259,13 +259,15 @@ static int BindCpuCore(Service *service) return SERVICE_SUCCESS; } -static void ClearEnvironment(void) +static void ClearEnvironment(Service *service) { - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGCHLD); - sigaddset(&mask, SIGTERM); - sigprocmask(SIG_UNBLOCK, &mask, NULL); + if (strcmp(service->name, "appspawn") != 0) { + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGCHLD); + sigaddset(&mask, SIGTERM); + sigprocmask(SIG_UNBLOCK, &mask, NULL); + } return; } @@ -297,7 +299,7 @@ int ServiceStart(Service *service) DoJobNow(service->serviceJobs.jobsName[JOB_ON_START]); } - ClearEnvironment(); + ClearEnvironment(service); if (!IsOnDemandService(service)) { INIT_ERROR_CHECK(CreateServiceSocket(service) >= 0, return SERVICE_FAILURE, diff --git a/services/init/init_service_manager.c b/services/init/init_service_manager.c index f7120aee67e1cb94ca1332756b5145d3e4ccd8d7..bf70ce0412f7a2ad230cffb6f38954e6f0f305d6 100644 --- a/services/init/init_service_manager.c +++ b/services/init/init_service_manager.c @@ -781,8 +781,7 @@ int ParseOneService(const cJSON *curItem, Service *service) INIT_CHECK_RETURN_VALUE(curItem != NULL && service != NULL, SERVICE_FAILURE); int ret = 0; #ifdef WITH_SELINUX - ret = GetStringItem(curItem, SECON_STR_IN_CFG, service->secon, MAX_SECON_LEN); - INIT_CHECK_ONLY_ELOG(ret == 0, "GetServiceSecon %s section not found, skip", SECON_STR_IN_CFG); + (void)GetStringItem(curItem, SECON_STR_IN_CFG, service->secon, MAX_SECON_LEN); #endif // WITH_SELINUX ret = GetServiceArgs(curItem, "path", MAX_PATH_ARGS_CNT, &service->pathArgs); INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get path for service %s", service->name); @@ -944,8 +943,10 @@ void StopAllServices(int flags, const char **exclude, int size, int (*filter)(const Service *service, const char **exclude, int size)) { Service *service = GetServiceByName("appspawn"); - if (((SERVICE_ATTR_NEEDWAIT & flags) == SERVICE_ATTR_NEEDWAIT) && service != NULL && service->pid != 0) { + if (service != NULL && service->pid != -1) { // notify appspawn stop + kill(service->pid, SIGTERM); waitpid(service->pid, 0, 0); + service->pid = -1; } InitGroupNode *node = GetNextGroupNode(NODE_TYPE_SERVICES, NULL); diff --git a/services/loopevent/include/loop_event.h b/services/loopevent/include/loop_event.h index d0c19261e0d6e86435b914166d7b7cb2f599870e..779feb9067beb14cc492677c916008970d8d0a24 100644 --- a/services/loopevent/include/loop_event.h +++ b/services/loopevent/include/loop_event.h @@ -100,6 +100,7 @@ typedef int (*LE_IncommingConntect)(const LoopHandle loopHandle, const TaskHandl typedef struct { LE_BaseInfo baseInfo; char *server; + int socketId; LE_DisConntectComplete disConntectComplete; LE_IncommingConntect incommingConntect; LE_SendMessageComplete sendMessageComplete; diff --git a/services/loopevent/signal/le_signal.c b/services/loopevent/signal/le_signal.c index daf4f8712efce055d95df5d89d0704c3025cb110..6f9f2223d401c03e57938fd4a9b6ec8b20708ba3 100644 --- a/services/loopevent/signal/le_signal.c +++ b/services/loopevent/signal/le_signal.c @@ -33,7 +33,7 @@ static LE_STATUS HandleSignalEvent_(const LoopHandle loop, const TaskHandle task } struct signalfd_siginfo fdsi; ssize_t s = read(GetSocketFd(task), &fdsi, sizeof(fdsi)); - LE_CHECK(s == sizeof(fdsi), return LE_FAILURE, "Failed to read sign"); + LE_CHECK(s == sizeof(fdsi), return LE_FAILURE, "Failed to read sign %d %d", s, errno); SignalTask *sigTask = (SignalTask *)task; if (sigTask->processSignal) { sigTask->processSignal(&fdsi); diff --git a/services/loopevent/task/le_streamtask.c b/services/loopevent/task/le_streamtask.c index 3b897369cdc1c424c929c28d1a941629656c7a2c..85e5a9d2d8ad3af0152f8414c82a2cc440372040 100644 --- a/services/loopevent/task/le_streamtask.c +++ b/services/loopevent/task/le_streamtask.c @@ -164,8 +164,11 @@ LE_STATUS LE_CreateStreamServer(const LoopHandle loopHandle, LE_CHECK(info->incommingConntect != NULL, return LE_INVALID_PARAM, "Invalid parameters incommingConntect %s", info->server); - int fd = CreateSocket(info->baseInfo.flags, info->server); - LE_CHECK(fd > 0, return LE_FAILURE, "Failed to create socket %s", info->server); + int fd = info->socketId; + if (info->socketId <= 0) { + fd = CreateSocket(info->baseInfo.flags, info->server); + LE_CHECK(fd > 0, return LE_FAILURE, "Failed to create socket %s", info->server); + } EventLoop *loop = (EventLoop *)loopHandle; StreamServerTask *task = (StreamServerTask *)CreateTask(loopHandle, fd, &info->baseInfo, diff --git a/services/utils/init_hashmap.c b/services/utils/init_hashmap.c index 9864c8d7d0f23c115bd150aa9e94f57117f06696..4abb31003ee3cb28c950e40126bfcd117a0c0fe2 100644 --- a/services/utils/init_hashmap.c +++ b/services/utils/init_hashmap.c @@ -113,7 +113,6 @@ void HashMapRemove(HashMapHandle handle, const void *key) while (node != NULL) { int ret = tab->keyCompare(node, key); if (ret == 0) { - INIT_LOGV("HashMapRemove tableId %d hashCode %d node %p", tab->tableId, hashCode, node); if (node == tab->buckets[hashCode]) { tab->buckets[hashCode] = node->next; } else { @@ -173,4 +172,19 @@ HashNode *HashMapFind(HashMapHandle handle, "Invalid hashcode %d %d", tab->maxBucket, hashCode); INIT_LOGV("HashMapGet tableId %d hashCode %d", tab->tableId, hashCode); return GetHashNodeByKey(tab, tab->buckets[hashCode], key, keyCompare); -} \ No newline at end of file +} + +void HashMapTraverse(HashMapHandle handle, void (*hashNodeTraverse)(const HashNode *node, const void *context), + const void *context) +{ + INIT_ERROR_CHECK(handle != NULL && hashNodeTraverse != NULL, return, "Invalid param"); + HashTab *tab = (HashTab *)handle; + for (int i = 0; i < tab->maxBucket; i++) { + HashNode *node = tab->buckets[i]; + while (node != NULL) { + HashNode *next = node->next; + hashNodeTraverse(node, context); + node = next; + } + } +}