diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 4be8b0536643358954aed4f3f4f9b569d0183814..b4af08bdc44b7643aaadadb4beae90f758c050db 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -67,7 +67,6 @@ if (defined(ohos_lite)) { ] deps += [ "//base/startup/init_lite/services/log:init_log", - "//base/startup/init_lite/services/param/base:parameterbase", "//base/startup/init_lite/services/utils:libinit_utils", ] if (enable_ohos_startup_init_feature_begetctl_liteos) { @@ -87,6 +86,7 @@ if (defined(ohos_lite)) { defines += [ "__LINUX__" ] deps += [ "//base/startup/init_lite/services/loopevent:loopevent", + "//base/startup/init_lite/services/param/base:parameterbase", "//base/startup/init_lite/services/param/linux:param_client", ] } @@ -121,7 +121,6 @@ if (defined(ohos_lite)) { defines += [ "USE_MBEDTLS" ] } deps += [ - "//base/startup/init_lite/services/param/base:parameterbase", "//base/startup/init_lite/services/param/liteos:param_client_lite", "//base/startup/init_lite/services/utils:libinit_utils", ] @@ -149,6 +148,7 @@ if (defined(ohos_lite)) { ohos_shared_library("libbegetutil") { sources = [ + "fd_holder/fd_holder.c", "reboot/init_reboot_innerkits.c", "service_control/service_control.c", ] diff --git a/interfaces/innerkits/syspara/param_wrapper.cpp b/interfaces/innerkits/syspara/param_wrapper.cpp old mode 100755 new mode 100644 diff --git a/interfaces/kits/jskits/src/native_deviceinfo_js.cpp b/interfaces/kits/jskits/src/native_deviceinfo_js.cpp old mode 100755 new mode 100644 diff --git a/interfaces/kits/jskits/src/native_parameters_js.cpp b/interfaces/kits/jskits/src/native_parameters_js.cpp old mode 100755 new mode 100644 diff --git a/interfaces/kits/jskits/src/native_parameters_watch.cpp b/interfaces/kits/jskits/src/native_parameters_watch.cpp old mode 100755 new mode 100644 diff --git a/services/etc/param/ohos.para b/services/etc/param/ohos.para index 20e8b3bf4752b286a9565d35363eef76d0446089..0eb7e9728d0cdd017542a7b35b160fa4f4c07b26 100755 --- a/services/etc/param/ohos.para +++ b/services/etc/param/ohos.para @@ -46,7 +46,7 @@ const.build.product=default const.product.hardwareversion=default const.product.bootloader.version=bootloader const.product.cpu.abilist=default -const.product.software.version=OpenHarmony 3.2.3.5 +const.product.software.version=OpenHarmony 3.2.5.1 const.product.incremental.version=default const.product.firstapiversion=1 const.product.build.type=default @@ -55,4 +55,3 @@ const.product.build.host=default const.product.build.date=default const.product.hardwareprofile=default const.ohos.buildroothash=default -const.ohos.sdkapilevel=8 diff --git a/services/etc/param/ohos_const/ohos.para b/services/etc/param/ohos_const/ohos.para index cd7f6e8cabc06fa2421ded24e9064fcaf7381e8b..a1a8ed9961117bf4be76c1e329cce35bed94f8bd 100755 --- a/services/etc/param/ohos_const/ohos.para +++ b/services/etc/param/ohos_const/ohos.para @@ -12,5 +12,5 @@ # limitations under the License. const.ohos.version.security_patch=2022-03-30 const.ohos.releasetype=Canary1 -const.ohos.apiversion=8 +const.ohos.apiversion=9 const.ohos.fullname=OpenHarmony-2.2.0.0 \ No newline at end of file diff --git a/services/include/init_utils.h b/services/include/init_utils.h index ba29ecef680e783f7e021eec519c55dd46ed72d0..9786501336841f515e8f7af8281a62fffc5d2921 100644 --- a/services/include/init_utils.h +++ b/services/include/init_utils.h @@ -60,6 +60,7 @@ void WaitForFile(const char *source, unsigned int maxSecond); size_t WriteAll(int fd, const char *buffer, size_t size); char *GetRealPath(const char *source); int StringToInt(const char *str, int defaultValue); +int StringToUint(const char *name, unsigned int *value); int MakeDirRecursive(const char *dir, mode_t mode); void CheckAndCreateDir(const char *fileName); int CheckAndCreatFile(const char *file, mode_t mode); diff --git a/services/modules/bootchart/bootchart.c b/services/modules/bootchart/bootchart.c index 76a4610b4b4123bb13b40cff230663414a865cfb..188fcc538a480a9d61b3c636e3cbfffe347eacaf 100755 --- a/services/modules/bootchart/bootchart.c +++ b/services/modules/bootchart/bootchart.c @@ -78,7 +78,7 @@ static void BootchartLogHeader(void) char release[PARAM_VALUE_LEN_MAX] = {}; uint32_t len = sizeof(release); - (void)SystemReadParam("hw_sc.build.os.releasetype", release, &len); + (void)SystemReadParam("const.ohos.releasetype", release, &len); char *cmdLine = ReadFileToBuffer("/proc/cmdline", g_bootchartCtrl->buffer, g_bootchartCtrl->bufferSize); PLUGIN_CHECK(cmdLine != NULL, return, "Failed to open file /data/bootchart/header"); diff --git a/services/param/liteos/BUILD.gn b/services/param/liteos/BUILD.gn index 638eb1250fd13676f6fac7bd92b0ffd2a24f3306..2bc1447eedcfdfd99e217c6608071bf37f731088 100644 --- a/services/param/liteos/BUILD.gn +++ b/services/param/liteos/BUILD.gn @@ -12,11 +12,6 @@ # limitations under the License. import("//base/startup/init_lite/begetd.gni") -param_comm_sources = [ - "//base/startup/init_lite/services/param/manager/param_manager.c", - "//base/startup/init_lite/services/param/manager/param_server.c", -] - param_include_dirs = [ "//base/startup/init_lite/services/param/include", "//base/startup/init_lite/services/param/adapter", @@ -91,10 +86,27 @@ config("exported_header_files") { ] } +base_sources = [ + "//base/startup/init_lite/services/log/init_commlog.c", + "//base/startup/init_lite/services/param/base/param_base.c", + "//base/startup/init_lite/services/param/base/param_comm.c", + "//base/startup/init_lite/services/param/base/param_trie.c", + "//base/startup/init_lite/services/param/liteos/param_client.c", + "//base/startup/init_lite/services/param/liteos/param_litedac.c", + "//base/startup/init_lite/services/param/liteos/param_osadp.c", + "//base/startup/init_lite/services/param/manager/param_manager.c", + "//base/startup/init_lite/services/param/manager/param_persist.c", + "//base/startup/init_lite/services/utils/init_hashmap.c", + "//base/startup/init_lite/services/utils/list.c", +] + static_library("param_init_lite") { defines = [] deps = [] - sources = param_comm_sources + sources = [ + "//base/startup/init_lite/services/param/manager/param_manager.c", + "//base/startup/init_lite/services/param/manager/param_server.c", + ] include_dirs = param_include_dirs defines += param_build_defines public_configs = [ ":exported_header_files" ] @@ -116,18 +128,15 @@ static_library("param_init_lite") { } static_library("param_client_lite") { - sources = param_comm_sources + sources = base_sources include_dirs = param_include_dirs cflags = [ "-fPIC" ] defines = param_build_defines public_configs = [ ":exported_header_files" ] if (ohos_kernel_type == "liteos_a") { - sources += [ - "//base/startup/init_lite/services/param/adapter/param_persistadp.c", - "//base/startup/init_lite/services/param/liteos/param_client.c", - "//base/startup/init_lite/services/param/manager/param_persist.c", - ] + sources += + [ "//base/startup/init_lite/services/param/adapter/param_persistadp.c" ] defines += [ "__LITEOS_A__", "WORKSPACE_AREA_NEED_MUTEX", @@ -135,16 +144,8 @@ static_library("param_client_lite") { "PARAMWORKSPACE_NEED_MUTEX", ] } else if (ohos_kernel_type == "liteos_m") { - sources += [ - "//base/startup/init_lite/services/log/init_commlog.c", - "//base/startup/init_lite/services/param/base/param_base.c", - "//base/startup/init_lite/services/param/base/param_comm.c", - "//base/startup/init_lite/services/param/base/param_trie.c", - "//base/startup/init_lite/services/param/liteos/param_client.c", - "//base/startup/init_lite/services/param/manager/param_persist.c", - "//base/startup/init_lite/services/utils/init_hashmap.c", - "//base/startup/init_lite/services/utils/list.c", - ] + sources += + [ "//base/startup/init_lite/services/param/manager/param_server.c" ] if (enable_ohos_startup_init_lite_use_posix_file_api) { sources += [ "//base/startup/init_lite/services/param/adapter/param_persistadp.c", diff --git a/services/utils/init_utils.c b/services/utils/init_utils.c index 48508681755206afce3ae50b773be3e87544d464..67c88844dc0d8322df654648e1c5bcb5a37974b8 100644 --- a/services/utils/init_utils.c +++ b/services/utils/init_utils.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -48,43 +49,74 @@ float ConvertMicrosecondToSecond(int x) return ((x / THOUSAND_UNIT_INT) / THOUSAND_UNIT_FLOAT); } -static uid_t DecodeId(const char *name, bool isUid) +static bool CheckDigit(const char *name) { -#ifndef __LITEOS_M__ - INIT_CHECK_RETURN_VALUE(name != NULL, -1); - int digitFlag = 1; size_t nameLen = strlen(name); - for (unsigned int i = 0; i < nameLen; ++i) { - if (isalpha(name[i])) { - digitFlag = 0; - break; + for (size_t i = 0; i < nameLen; ++i) { + if (!isdigit(name[i])) { + return false; } } - if (digitFlag) { - errno = 0; - uid_t result = strtoul(name, 0, DECIMAL_BASE); - INIT_CHECK_RETURN_VALUE(errno == 0, -1); - return result; - } else { - struct passwd *userInf = getpwnam(name); - if (userInf == NULL) { + return true; +} + +int StringToUint(const char *name, unsigned int *value) +{ + errno = 0; + *value = (unsigned int)strtoul(name, 0, DECIMAL_BASE); + INIT_CHECK_RETURN_VALUE(errno == 0, -1); + return 0; +} + +uid_t DecodeUid(const char *name) +{ +#ifndef __LITEOS_M__ + INIT_CHECK_RETURN_VALUE(name != NULL, -1); + uid_t uid = -1; + if (CheckDigit(name)) { + if (!StringToUint(name, &uid)) { + return uid; + } else { + INIT_LOGE("Failed to decode uid"); return -1; } - return isUid ? userInf->pw_uid : userInf->pw_gid; } + struct passwd *p = getpwnam(name); + if (p == NULL) { + INIT_LOGE("Failed to decode uid"); + return -1; + } + return p->pw_uid; #else return -1; #endif } -uid_t DecodeUid(const char *name) -{ - return DecodeId(name, true); -} - gid_t DecodeGid(const char *name) { - return DecodeId(name, false); +#ifndef __LITEOS_M__ + INIT_CHECK_RETURN_VALUE(name != NULL, -1); + gid_t gid = -1; + if (CheckDigit(name)) { + if (!StringToUint(name, &gid)) { + return gid; + } else { + INIT_LOGE("Failed to decode gid"); + return -1; + } + } + struct group *data = NULL; + while ((data = getgrent()) != NULL) { + if ((data->gr_name != NULL) && (strcmp(data->gr_name, name) == 0)) { + gid = data->gr_gid; + break; + } + } + endgrent(); + return gid; +#else + return -1; +#endif } char *ReadFileToBuf(const char *configFile) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 3f3c947215d85efdebc113569c3fa0b5612ff935..ed8473122c7ef756ef48f453163021c1f698bd61 100755 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -208,7 +208,8 @@ ohos_unittest("init_unittest") { "//third_party/cJSON:cjson_static", "//third_party/googletest:gmock", "//third_party/googletest:gtest", - "//third_party/openssl:libcrypto_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/base:utils", ] defines = [ @@ -219,6 +220,7 @@ ohos_unittest("init_unittest") { "PARAM_SUPPORT_DAC", "_GNU_SOURCE", "PARAM_SUPPORT_TRIGGER", + "USE_MBEDTLS", ] defines += [ "_GNU_SOURCE" ] diff --git a/test/unittest/deviceinfo/DeviceInfoUnittest.cpp b/test/unittest/deviceinfo/DeviceInfoUnittest.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/innerkits/hookmgr_unittest.cpp b/test/unittest/innerkits/hookmgr_unittest.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/innerkits/modulemgr_unittest.cpp b/test/unittest/innerkits/modulemgr_unittest.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/lite/cmd_func_test.cpp b/test/unittest/lite/cmd_func_test.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/param/param_stub.cpp b/test/unittest/param/param_stub.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/param/paramservice_unittest.cpp b/test/unittest/param/paramservice_unittest.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/syspara/syspara_unittest.cpp b/test/unittest/syspara/syspara_unittest.cpp old mode 100755 new mode 100644 diff --git a/watchdog/BUILD.gn b/watchdog/BUILD.gn index 12c326a97953759d9889820b96adb78251f08a4a..5fdf4404302b363ba604a6121e94959f27c3ee88 100644 --- a/watchdog/BUILD.gn +++ b/watchdog/BUILD.gn @@ -17,10 +17,12 @@ group("watchdog") { if (defined(ohos_lite)) { executable("watchdog_service") { - sources = [ "init_watchdog.c" ] + sources = [ + "//base/startup/init_lite/services/log/init_commlog.c", + "//base/startup/init_lite/watchdog/init_watchdog.c", + ] deps = [ "//base/startup/init_lite/services/log:init_log", - "//base/startup/init_lite/services/param/base:parameterbase", "//third_party/bounds_checking_function:libsec_static", ] defines = [