提交 319e4a74 编写于 作者: 熊磊 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/startup_init_lite into master_0415

......@@ -48,7 +48,8 @@
"//base/startup/init_lite/interfaces/innerkits/file:libfile",
"//base/startup/init_lite/interfaces/innerkits/socket:libsocket",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/interfaces/innerkits/plugin:libplugin",
"//base/startup/init_lite/services/init/plugin_engine:libinit_plugin_engine",
"//base/startup/init_lite/services/init/plugin_engine:libinit_stub_empty",
"//base/startup/init_lite/device_info:device_info_group",
"//base/startup/init_lite/interfaces/innerkits/sandbox:libsandbox"
],
......@@ -76,10 +77,20 @@
]
},
"name": "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy"
},
{
"header": {
"header_base": "//base/startup/init_lite/services/init/plugin_engine/include",
"header_files": [
"init_plugin_engine.h"
]
},
"name": "//base/startup/init_lite/services/init/plugin_engine:libinit_plugin_engine"
}
],
"test": [
"//base/startup/init_lite/test/unittest:init_test"
"//base/startup/init_lite/test/unittest:init_test",
"//base/startup/init_lite/test/fuzztest:fuzztest"
]
}
}
......
......@@ -27,10 +27,7 @@ ohos_prebuilt_etc("device_info.cfg") {
ohos_shared_library("deviceinfoservice") {
sources = [ "device_info_stub.cpp" ]
defines = [
"INIT_AGENT",
"DINFO_LABEL=\"DeviceInfoService\"",
]
defines = [ "DINFO_LABEL=\"DeviceInfoService\"" ]
include_dirs = [
".",
"//base/startup/init_lite/interfaces/innerkits/include",
......
......@@ -129,7 +129,8 @@ const char *AclGetSerial(void)
OHOS::device_info::DeviceInfoKits &instance = OHOS::device_info::DeviceInfoKits::GetInstance();
int ret = instance.GetSerialID(result);
if (ret == 0) {
(void)strcpy_s(serialNumber, sizeof(serialNumber), result.c_str());
ret = strcpy_s(serialNumber, sizeof(serialNumber), result.c_str());
DINFO_CHECK(ret == 0, return nullptr, "Failed to copy");
}
DINFO_LOGI("GetSerial %s", serialNumber);
return serialNumber;
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -77,9 +77,7 @@ bool DeviceInfoStub::CheckPermission(MessageParcel &data, const std::string &per
int32_t result = TypePermissionState::PERMISSION_GRANTED;
int32_t tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken);
if (tokenType == TOKEN_NATIVE) {
#ifdef SUPPORT_NATIVE
result = AccessTokenKit::VerifyNativeToken(callerToken, permission);
#endif
} else if (tokenType == TOKEN_HAP) {
result = AccessTokenKit::VerifyAccessToken(callerToken, permission);
} else {
......@@ -90,7 +88,7 @@ bool DeviceInfoStub::CheckPermission(MessageParcel &data, const std::string &per
DINFO_LOGE("AccessTokenID:%d, permission:%s denied!", callerToken, permission.c_str());
return false;
}
DINFO_LOGI("dAccessTokenID:%d, permission:%s matched!", callerToken, permission.c_str());
DINFO_LOGI("tokenType %d dAccessTokenID:%d, permission:%s matched!", tokenType, callerToken, permission.c_str());
return true;
}
......
文件模式从 100755 更改为 100644
......@@ -39,9 +39,13 @@ public:
} // namespace device_info
} // namespace OHOS
#define DINFO_LOGI(fmt, ...) STARTUP_LOGI("begetctrl.log", "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_LOGE(fmt, ...) STARTUP_LOGE("begetctrl.log", "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_LOGV(fmt, ...) STARTUP_LOGV("begetctrl.log", "DeviceInfoKits", fmt, ##__VA_ARGS__)
#ifndef DINFO_DOMAIN
#define DINFO_DOMAIN (BASE_DOMAIN + 8)
#endif
#define DINFO_LOGI(fmt, ...) STARTUP_LOGI(DINFO_DOMAIN, "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_LOGE(fmt, ...) STARTUP_LOGE(DINFO_DOMAIN, "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_LOGV(fmt, ...) STARTUP_LOGV(DINFO_DOMAIN, "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_CHECK(ret, exper, ...) \
if (!(ret)) { \
......
......@@ -11,101 +11,127 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init_lite/begetd.gni")
import("//build/ohos.gni")
if (defined(ohos_lite)) {
static_library("libbegetutil") {
sources = [ "//base/startup/init_lite/services/log/init_log.c" ]
defines = [
"_GNU_SOURCE",
"OHOS_LITE",
"INIT_LOG_INIT=3",
]
include_dirs = [
"./include",
"//third_party/bounds_checking_function/include",
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/include/param",
"//base/startup/init_lite/interfaces/innerkits/fd_holder",
]
deps = [
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/utils:libinit_tools",
"//third_party/bounds_checking_function:libsec_static",
]
}
} else {
import("//base/startup/init_lite/begetd.gni")
import("//build/ohos.gni")
config("exported_header_files") {
visibility = [ ":*" ]
include_dirs = [ "include/" ]
}
fs_manager_sources = [
"fs_manager/fstab.c",
"fs_manager/fstab_mount.c",
]
config("exported_header_files") {
visibility = [ ":*" ]
include_dirs = [ "include/" ]
}
ohos_shared_library("libbegetutil") {
sources = [
"fd_holder/fd_holder.c",
"file/init_file.c",
"reboot/init_reboot_innerkits.c",
"service_control/service_control.c",
"socket/init_socket.c",
"syscap/init_syscap.c",
fs_manager_sources = [
"fs_manager/fstab.c",
"fs_manager/fstab_mount.c",
]
sources += fs_manager_sources
include_dirs = [
"./include",
"//third_party/bounds_checking_function/include",
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/include/param",
"//base/startup/init_lite/interfaces/innerkits/fd_holder",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/interfaces/innerkits/fd_holder:libfdholder_internal_static",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/openssl:libcrypto_static",
"//utils/native/base:utils",
]
ohos_shared_library("libbegetutil") {
sources = [
"//base/startup/init_lite/services/log/init_log.c",
"fd_holder/fd_holder.c",
"fd_holder/fd_holder_internal.c",
"file/init_file.c",
"reboot/init_reboot_innerkits.c",
"service_control/service_control.c",
"socket/init_socket.c",
"syscap/init_syscap.c",
]
sources += fs_manager_sources
defines = [ "INIT_AGENT" ]
deps += [ "//base/startup/init_lite/services/log:init_log" ]
include_dirs = [
"./include",
"//third_party/bounds_checking_function/include",
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/include/param",
"//base/startup/init_lite/interfaces/innerkits/fd_holder",
]
deps = [
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//utils/native/base:utils",
]
external_deps = [ "hilog_native:libhilog_base" ]
public_configs = [ ":exported_header_files" ]
part_name = "init"
install_images = [
"system",
"updater",
]
}
public_configs = [ ":exported_header_files" ]
part_name = "init"
install_images = [
"system",
"updater",
]
}
# watcher lib must separate compilation avoid interdependence.
ohos_shared_library("libbeget_proxy") {
sources = [
"//base/startup/init_lite/device_info/device_info_kits.cpp",
"//base/startup/init_lite/device_info/device_info_proxy.cpp",
"//base/startup/init_lite/services/log/init_log.c",
"service_watcher/service_watcher.c",
]
# watcher lib must separate compilation avoid interdependence.
ohos_shared_library("libbeget_proxy") {
sources = [
"//base/startup/init_lite/device_info/device_info_kits.cpp",
"//base/startup/init_lite/device_info/device_info_proxy.cpp",
"service_watcher/service_watcher.c",
]
include_dirs = [
"./include",
"//base/startup/init_lite/device_info",
"//utils/native/base/include",
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/include/param",
"//third_party/bounds_checking_function/include",
]
include_dirs = [
"./include",
"//base/startup/init_lite/device_info",
"//utils/native/base/include",
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/include/param",
"//third_party/bounds_checking_function/include",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//utils/native/base:utils",
]
deps = [
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//utils/native/base:utils",
]
external_deps = [
"hilog_native:libhilog_base",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
part_name = "init"
install_images = [ "system" ]
}
external_deps = [
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
part_name = "init"
install_images = [ "system" ]
}
# For init only
ohos_static_library("libfsmanager_static") {
sources = fs_manager_sources
include_dirs = [
"//base/startup/init_lite/interfaces/innerkits/include",
"//third_party/bounds_checking_function/include",
"//base/startup/init_lite/services/log",
"//base/startup/init_lite/services/include",
]
# For init only
ohos_static_library("libfsmanager_static") {
sources = fs_manager_sources
include_dirs = [
"//base/startup/init_lite/interfaces/innerkits/include",
"//third_party/bounds_checking_function/include",
"//base/startup/init_lite/services/log",
"//base/startup/init_lite/services/include",
]
deps = [ "//base/startup/init_lite/services/log:init_log" ]
part_name = "init"
part_name = "init"
}
}
......@@ -21,9 +21,5 @@ ohos_static_library("libfdholder_internal_static") {
"//base/startup/init_lite/services/log",
"//base/startup/init_lite/interfaces/innerkits/include",
]
deps = [ "//base/startup/init_lite/services/log:init_log" ]
defines = [ "INIT_AGENT" ]
part_name = "init"
}
......@@ -20,7 +20,7 @@ service_file_include = [
"//third_party/bounds_checking_function/include",
]
service_file_deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
]
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -143,7 +143,7 @@ MountStatus GetMountStatusForMountPoint(const char *mp)
FreeStringVector(mountItems, count);
}
}
if (found == true) {
if (found) {
status = MOUNT_MOUNTED;
} else if (feof(fp) > 0) {
status = MOUNT_UMOUNTED;
......
......@@ -22,12 +22,9 @@ extern "C" {
#endif
#endif
#if defined(ENABLE_HILOG) || defined(OHOS_LITE)
#include "hilog/log.h"
#undef LOG_DOMAIN
#define LOG_DOMAIN 0xD000719
#ifndef INIT_LOG_PATH
#define INIT_LOG_PATH "/data/init_agent/"
#endif
typedef enum InitLogLevel {
INIT_DEBUG = 0,
INIT_INFO,
......@@ -36,88 +33,33 @@ typedef enum InitLogLevel {
INIT_FATAL
} InitLogLevel;
#ifndef INIT_LOG_PATH
#define INIT_LOG_PATH "/data/init_agent/"
#endif
#define FILE_NAME (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__))
void InitLogInit(const char *outFileName, InitLogLevel logLevel, const char *kLevel, const char *fmt, ...);
void InitLogAgent(const char *outFileName, InitLogLevel logLevel, const char *kLevel, const char *fmt, ...);
void OpenLogDevice(void);
#ifndef INIT_AGENT
#define InitLogPrint InitLogInit
#else
#define InitLogPrint InitLogAgent
#endif
#ifndef OHOS_LITE
#ifndef ENABLE_HILOG
#define STARTUP_LOGV(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_DEBUG, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGI(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_INFO, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGE(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_ERROR, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGW(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_WARN, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#else
#define STARTUP_LOGV(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_DEBUG, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_DEBUG, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGI(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_INFO, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_INFO, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGE(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_ERROR, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_ERROR, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGW(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_WARN, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_WARN, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
void SetInitLogLevel(InitLogLevel logLevel);
void InitLog(InitLogLevel logLevel, unsigned int domain, const char *tag, const char *fmt, ...);
#define STARTUP_LOGV(domain, tag, fmt, ...) \
InitLog(INIT_DEBUG, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
#define STARTUP_LOGI(domain, tag, fmt, ...) \
InitLog(INIT_INFO, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
#define STARTUP_LOGW(domain, tag, fmt, ...) \
InitLog(INIT_WARN, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
#define STARTUP_LOGE(domain, tag, fmt, ...) \
InitLog(INIT_ERROR, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
#define STARTUP_LOGF(domain, tag, fmt, ...) \
InitLog(INIT_FATAL, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
#define BASE_DOMAIN 0xA000
#ifndef BEGET_DOMAIN
#define BEGET_DOMAIN (BASE_DOMAIN + 0xb)
#endif
#endif
#define BEGET_LOG_FILE "begetctrl.log"
#define BEGET_LABEL "BEGET"
#define BEGET_LOGI(fmt, ...) STARTUP_LOGI(BEGET_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGE(fmt, ...) STARTUP_LOGE(BEGET_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGV(fmt, ...) STARTUP_LOGV(BEGET_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGW(fmt, ...) STARTUP_LOGW(BEGET_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGI(fmt, ...) STARTUP_LOGI(BEGET_DOMAIN, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGE(fmt, ...) STARTUP_LOGE(BEGET_DOMAIN, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGV(fmt, ...) STARTUP_LOGV(BEGET_DOMAIN, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGW(fmt, ...) STARTUP_LOGW(BEGET_DOMAIN, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define InitLogPrint(outFileName, logLevel, kLevel, fmt, ...) \
InitLog(logLevel, BEGET_DOMAIN, kLevel, fmt, ##__VA_ARGS__)
#define BEGET_ERROR_CHECK(ret, statement, format, ...) \
if (!(ret)) { \
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -31,14 +31,13 @@ ohos_shared_library("libsandbox") {
"//base/startup/init_lite/interfaces/innerkits/include",
"//third_party/cJSON",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/cJSON:cjson_static",
]
deps += [ "//base/startup/init_lite/services/log:init_log" ]
deps += [ "//base/startup/init_lite/services/log:agent_log" ]
part_name = "init"
install_images = [ "system" ]
......@@ -62,6 +61,5 @@ ohos_static_library("libsandbox_static") {
"//third_party/bounds_checking_function:libsec_static",
"//third_party/cJSON:cjson_static",
]
deps += [ "//base/startup/init_lite/services/log:init_log" ]
part_name = "init"
}
{
"sandbox-root" : "/mnt/sandbox/app",
"mount-bind-paths" : [{
"src-path" : "/mnt",
"sandbox-path" : "/mnt",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/bin",
"sandbox-path" : "/system/bin",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/lib64",
"sandbox-path" : "/system/lib64",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/lib64/module",
"sandbox-path" : "/system/lib64/module",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/etc",
"sandbox-path" : "/system/etc",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/sys",
"sandbox-path" : "/sys",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/proc",
"sandbox-path" : "/proc",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/dev",
"sandbox-path" : "/dev",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/data",
"sandbox-path" : "/data",
"sandbox-flags" : [ "bind", "rec", "private" ]
}
],
"mount-bind-files" : [{
}],
"symbol-links" : [{
"target-name" : "/system/bin",
"link-name" : "/bin"
}, {
"target-name" : "/system/lib64",
"link-name" : "/lib64"
}, {
"target-name" : "/system/etc",
"link-name" : "/etc"
}
]
}
{
"sandbox-root" : "/mnt/sandbox/chipset",
"mount-bind-paths" : [{
"src-path" : "/system/lib64/vndk",
"sandbox-path" : "/system/lib64/vndk",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/lib64/platform-vndk",
"sandbox-path" : "/system/lib64/platform-vndk",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/lib64/ndk",
"sandbox-path" : "/system/lib64/ndk",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/vendor/lib64",
"sandbox-path" : "/vendor/lib64",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/vendor/bin",
"sandbox-path" : "/vendor/bin",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/vendor/etc",
"sandbox-path" : "/vendor/etc",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/dev",
"sandbox-path" : "/dev",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/proc",
"sandbox-path" : "/proc",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/data",
"sandbox-path" : "/data",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/sys",
"sandbox-path" : "/sys",
"sandbox-flags" : [ "bind", "rec", "private" ]
}
],
"mount-bind-files" : [{
}],
"symbol-links" : [{
"target-name" : "/vendor/lib64",
"link-name" : "/lib64"
}, {
"target-name" : "/vendor/bin",
"link-name" : "/bin"
}, {
"target-name" : "/vendor/etc",
"link-name" : "/etc"
}
]
}
{
"sandbox-root" : "/mnt/sandbox/priv-app",
"mount-bind-paths" : [{
"src-path" : "/mnt",
"sandbox-path" : "/mnt",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/system/bin",
"sandbox-path" : "/system/bin",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/system/bin",
"sandbox-path" : "/system/common/bin",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/system/lib64",
"sandbox-path" : "/system/lib64",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/system/lib64/module",
"sandbox-path" : "/system/lib64/module",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/system/etc",
"sandbox-path" : "/system/etc",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/sys",
"sandbox-path" : "/sys",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/proc",
"sandbox-path" : "/proc",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/dev",
"sandbox-path" : "/dev",
"sandbox-flags" : [ "bind", "rec" ]
}, {
"src-path" : "/data",
"sandbox-path" : "/data",
"sandbox-flags" : [ "bind", "rec" ]
}
],
"mount-bind-files": [{
}],
"symbol-links": [{
"target-name" : "/system/bin",
"link-name" : "/bin"
}, {
"target-name" : "/system/lib64",
"link-name" : "/lib64"
}, {
"target-name" : "/system/etc",
"link-name" : "/etc"
}
]
}
......@@ -53,7 +53,7 @@ struct SandboxMountFlags {
unsigned long value;
};
struct SandboxMountFlags g_flags[] = {
static const struct SandboxMountFlags g_flags[] = {
{
.flag = "bind",
.value = MS_BIND,
......@@ -84,7 +84,7 @@ struct SandboxMap {
const char *configfile;
};
struct SandboxMap g_map[] = {
static const struct SandboxMap g_map[] = {
{
.name = "system",
.sandbox = &g_systemSandbox,
......@@ -276,7 +276,7 @@ static int ParseSandboxConfig(sandbox_t *sandbox, const char *sandboxConfig)
return 0;
}
static struct SandboxMap *GetSandboxMapByName(const char *name)
static const struct SandboxMap *GetSandboxMapByName(const char *name)
{
if (name == NULL) {
BEGET_LOGE("Failed get sandbox map name is NULL.");
......@@ -298,7 +298,7 @@ static void InitSandbox(sandbox_t *sandbox, const char *sandboxConfig, const cha
return;
}
if (sandbox->isCreated) {
BEGET_LOGE("Sandbox %s has created.");
BEGET_LOGE("Sandbox %s has created.", name);
return;
}
if (UnshareNamespace(CLONE_NEWNS) < 0) {
......@@ -445,7 +445,7 @@ int PrepareSandbox(const char *name)
{
BEGET_ERROR_CHECK(name != NULL, return -1, "Prepare sandbox name is NULL.");
BEGET_ERROR_CHECK(getuid() == 0, return -1, "Current process uid is not root, exit.");
struct SandboxMap *map = GetSandboxMapByName(name);
const struct SandboxMap *map = GetSandboxMapByName(name);
BEGET_ERROR_CHECK(map != NULL, return -1, "Failed get sandbox map by name %s.", name);
sandbox_t *sandbox = map->sandbox;
BEGET_CHECK(IsValidSandbox(sandbox) == true, return -1);
......@@ -549,7 +549,7 @@ bool InitSandboxWithName(const char *name)
BEGET_LOGE("Init sandbox name is NULL.");
return isFound;
}
struct SandboxMap *map = GetSandboxMapByName(name);
const struct SandboxMap *map = GetSandboxMapByName(name);
if (map != NULL) {
InitSandbox(map->sandbox, map->configfile, name);
isFound = true;
......@@ -567,7 +567,7 @@ void DestroySandbox(const char *name)
BEGET_LOGE("Destroy sandbox name is NULL.");
return;
}
struct SandboxMap *map = GetSandboxMapByName(name);
const struct SandboxMap *map = GetSandboxMapByName(name);
if (map == NULL) {
BEGET_LOGE("Failed get sandbox map by name %s.", name);
return;
......@@ -597,7 +597,7 @@ int EnterSandbox(const char *name)
BEGET_LOGE("Sandbox name is NULL.");
return -1;
}
struct SandboxMap *map = GetSandboxMapByName(name);
const struct SandboxMap *map = GetSandboxMapByName(name);
if (map == NULL) {
BEGET_LOGE("Failed to get sandbox map by name %s.", name);
return -1;
......@@ -629,7 +629,7 @@ void DumpSandboxByName(const char *name)
BEGET_LOGE("Init sandbox name is NULL.");
return;
}
struct SandboxMap *map = GetSandboxMapByName(name);
const struct SandboxMap *map = GetSandboxMapByName(name);
if (map == NULL) {
return;
}
......
......@@ -24,6 +24,10 @@
"src-path" : "/system/fonts",
"sandbox-path" : "/system/fonts",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/usr",
"sandbox-path" : "/system/usr",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/vendor",
"sandbox-path" : "/vendor",
......@@ -56,6 +60,10 @@
"src-path" : "/storage",
"sandbox-path" : "/storage",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/sys_prod",
"sandbox-path" : "/sys_prod",
"sandbox-flags" : [ "bind", "rec", "private" ]
}
],
"mount-bind-files" : [{
......@@ -71,4 +79,4 @@
"link-name" : "/etc"
}
]
}
\ No newline at end of file
}
{
"sandbox-root" : "/mnt/sandbox/system",
"mount-bind-paths" : [{
"src-path" : "/system/bin",
"sandbox-path" : "/system/bin",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/etc",
"sandbox-path" : "/system/etc",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/lib64",
"sandbox-path" : "/system/lib64",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/profile",
"sandbox-path" : "/system/profile",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/app",
"sandbox-path" : "/system/app",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/fonts",
"sandbox-path" : "/system/fonts",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/system/usr",
"sandbox-path" : "/system/usr",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/vendor",
"sandbox-path" : "/vendor",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/dev",
"sandbox-path" : "/dev",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/proc",
"sandbox-path" : "/proc",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/data",
"sandbox-path" : "/data",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/sys",
"sandbox-path" : "/sys",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/config",
"sandbox-path" : "/config",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/mnt",
"sandbox-path" : "/mnt",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/storage",
"sandbox-path" : "/storage",
"sandbox-flags" : [ "bind", "rec", "private" ]
}, {
"src-path" : "/sys_prod",
"sandbox-path" : "/sys_prod",
"sandbox-flags" : [ "bind", "rec", "private" ]
}
],
"mount-bind-files" : [{
}],
"symbol-links" : [{
"target-name" : "/system/lib64",
"link-name" : "/lib64"
}, {
"target-name" : "/system/bin",
"link-name" : "/bin"
}, {
"target-name" : "/system/etc",
"link-name" : "/etc"
}
]
}
......@@ -28,7 +28,7 @@
static int StartProcess(const char *name, const char *extArgv[], int extArgc)
{
if (name == NULL) {
BEGET_LOGE("Start dynamic service failed, service name is null.");
BEGET_LOGE("Start ondemand service failed, service name is null.");
return -1;
}
int extraArg = 0;
......@@ -79,7 +79,7 @@ static int StartProcess(const char *name, const char *extArgv[], int extArgc)
static int StopProcess(const char *serviceName)
{
if (serviceName == NULL) {
BEGET_LOGE("Stop dynamic service failed, service is null.\n");
BEGET_LOGE("Stop ondemand service failed, service is null.\n");
return -1;
}
if (SystemSetParameter("ohos.ctl.stop", serviceName) != 0) {
......@@ -112,7 +112,7 @@ static int GetCurrentServiceStatus(const char *serviceName, ServiceStatus *statu
static int RestartProcess(const char *serviceName, const char *extArgv[], int extArgc)
{
if (serviceName == NULL) {
BEGET_LOGE("Restart dynamic service failed, service is null.\n");
BEGET_LOGE("Restart ondemand service failed, service is null.\n");
return -1;
}
ServiceStatus status = SERVICE_IDLE;
......@@ -221,7 +221,7 @@ int ServiceSetReady(const char *serviceName)
BEGET_LOGE("Set param for %s failed.", paramName);
return -1;
}
BEGET_LOGI("Success set %d read", serviceName);
BEGET_LOGI("Success set %s read", serviceName);
return 0;
}
......
......@@ -19,7 +19,7 @@ service_socket_include = [
"//third_party/bounds_checking_function/include",
]
service_socket_deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/log:agent_log",
"//third_party/bounds_checking_function:libsec_static",
]
......@@ -50,6 +50,5 @@ if (defined(ohos_lite)) {
"system",
"updater",
]
relative_install_dir = "platform-vndk"
}
}
文件模式从 100755 更改为 100644
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2022 Huawei Device 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
......@@ -13,18 +13,24 @@
import("//build/ohos.gni")
ohos_shared_library("libplugin") {
sources = [ "init_plugin.c" ]
config("syscap_config") {
include_dirs = [ "../include" ]
}
ohos_shared_library("syscap") {
sources = [ "init_syscap.c" ]
include_dirs = [
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/services/log",
"../include",
"../../../services/include/param",
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
"../../../services/log:init_log",
"../../../services/param:param_client",
"//third_party/bounds_checking_function:libsec_shared",
]
install_enable = true
public_configs = [ ":syscap_config" ]
part_name = "init"
install_images = [ "system" ]
}
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -102,6 +102,7 @@ if (defined(ohos_lite)) {
} else {
import("//base/startup/init_lite/begetd.gni")
import("//build/ohos.gni")
import("//build/ohos/native_stub/native_stub.gni")
ohos_executable("init") {
sources = [
......@@ -123,6 +124,7 @@ if (defined(ohos_lite)) {
sources += init_common_sources
include_dirs = [
"//base/customization/config_policy/interfaces/innerkits/include",
"//base/security/access_token/interfaces/innerkits/token_setproc/include",
"//base/security/access_token/interfaces/innerkits/nativetoken/include",
"//base/startup/init_lite/interfaces/innerkits/sandbox/include",
......@@ -139,6 +141,7 @@ if (defined(ohos_lite)) {
"//third_party/bounds_checking_function/include",
]
deps = [
"//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
"//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
"//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
"//base/startup/init_lite/interfaces/innerkits:libfsmanager_static",
......@@ -153,6 +156,8 @@ if (defined(ohos_lite)) {
"//third_party/cJSON:cjson_static",
]
deps += [ "//base/startup/init_lite/services/init/plugin_engine:libinit_stub_versionscript" ]
cflags = []
if (use_musl) {
......@@ -193,6 +198,11 @@ if (defined(ohos_lite)) {
if (defined(product_name) && product_name == "rk3568") {
defines += [ "PRODUCT_RK" ]
}
version_script = get_label_info(
"//base/startup/init_lite/services/init/plugin_engine:libinit_stub_versionscript",
"target_gen_dir") + "/" + get_label_info(
"//base/startup/init_lite/services/init/plugin_engine:libinit_stub_versionscript",
"name") + stub_version_script_suffix
defines += [ "_GNU_SOURCE" ]
install_images = [
"system",
......@@ -231,6 +241,30 @@ if (defined(ohos_lite)) {
part_name = "init"
}
ohos_prebuilt_etc("misc.cfg") {
source = "//base/startup/init_lite/services/etc/misc.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("watchdog.cfg") {
source = "//base/startup/init_lite/services/etc/watchdog.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("console.cfg") {
source = "//base/startup/init_lite/services/etc/console.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("ueventd.cfg") {
source = "//base/startup/init_lite/services/etc/ueventd.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("passwd") {
source = "//base/startup/init_lite/services/etc/passwd"
install_images = [
......@@ -271,6 +305,12 @@ if (defined(ohos_lite)) {
module_install_dir = "etc/param"
}
ohos_prebuilt_etc("ohos_const.para") {
source = "//base/startup/init_lite/services/etc/param/ohos_const/ohos.para"
part_name = "init"
module_install_dir = "etc/param/ohos_const"
}
ohos_prebuilt_etc("boot.group") {
source = "//base/startup/init_lite/services/etc/device.boot.group.cfg"
part_name = "init"
......@@ -304,26 +344,41 @@ if (defined(ohos_lite)) {
}
ohos_prebuilt_etc("system-sandbox.json") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox.json"
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("chipset-sandbox.json") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox.json"
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("privapp-sandbox.json") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox.json"
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("app-sandbox.json") {
source =
"//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox.json"
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
......@@ -340,13 +395,16 @@ if (defined(ohos_lite)) {
":boot.group",
":charing.group",
":chipset-sandbox.json",
":console.cfg",
":group",
":init.cfg",
":init.reboot",
":init.usb.cfg",
":init.usb.configfs.cfg",
":misc.cfg",
":ohos.para",
":ohos.para.dac",
":ohos_const.para",
":passwd",
":plugin_modules",
":privapp-sandbox.json",
......@@ -354,6 +412,8 @@ if (defined(ohos_lite)) {
":syscap.para",
":system-sandbox.json",
":systemcapability.json",
":ueventd.cfg",
":watchdog.cfg",
]
}
}
......@@ -60,6 +60,8 @@ ohos_executable("begetctl") {
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
defines += [
......@@ -74,6 +76,7 @@ ohos_executable("begetctl") {
"//base/security/selinux/interfaces/policycoreutils/include/",
]
deps += [ "//third_party/selinux:libselinux" ]
external_deps = [ "selinux:libparaperm_checker" ]
defines += [ "WITH_SELINUX" ]
}
......@@ -129,6 +132,8 @@ ohos_executable("paramshell") {
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
defines += [
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -65,7 +65,9 @@ int main(int argc, char *argv[])
args = argv + 1;
}
if (number >= 1 && strcmp(args[0], "devctl") == 0) {
(void)memcpy_s(args[0], strlen(args[0]), "reboot", strlen("reboot"));
if (memcpy_s(args[0], strlen(args[0]), "reboot", strlen("reboot")) != 0) {
printf("Failed to copy\n");
}
}
SetInitLogLevel(0);
BShellParamCmdRegister(g_handle, 0);
......
......@@ -81,13 +81,13 @@ static void WriteLogoContent(int fd, const std::string &logoPath, uint32_t size)
(void)fclose(rgbFile);
return;
}
uint32_t ret = fread(buffer, 1, size, rgbFile);
if (ret < 0) {
(void)fread(buffer, 1, size, rgbFile);
if (ferror(rgbFile)) {
(void)fclose(rgbFile);
free(buffer);
return;
}
ret = write(fd, buffer, size);
uint32_t ret = write(fd, buffer, size);
if (ret != size) {
(void)fclose(rgbFile);
free(buffer);
......
......@@ -31,6 +31,7 @@
#ifdef WITH_SELINUX
#include <policycoreutils.h>
#include <selinux/selinux.h>
#include "selinux_parameter.h"
#endif // WITH_SELINUX
#define MASK_LENGTH_MAX 4
......@@ -91,6 +92,7 @@ static char *GetRealParameter(BShellHandle shell, const char *name, char *buffer
} else {
realLen = sprintf_s(buffer, buffSize, "%s", name);
}
BSH_CHECK(realLen >= 0, return NULL, "Failed to format buffer");
buffer[realLen] = '\0';
BSH_LOGV("GetRealParameter current %s input %s real %s", current, name, buffer);
return buffer;
......@@ -158,7 +160,7 @@ static void ShowParam(BShellHandle shell, const char *name, const char *value)
BSH_LOGE("Failed to get param security for %s", name);
return;
}
char permissionStr[MASK_LENGTH_MAX] = {'-', '-', '-', 0};
char permissionStr[3][MASK_LENGTH_MAX] = {}; // 3 permission
struct passwd *user = getpwuid(auditData.dacData.uid);
struct group *group = getgrgid(auditData.dacData.gid);
if (user == NULL || group == NULL) {
......@@ -166,10 +168,24 @@ static void ShowParam(BShellHandle shell, const char *name, const char *value)
return;
}
BShellEnvOutput(shell, "Parameter infomation:\r\n");
#ifdef WITH_SELINUX
char *context = NULL;
if (strcmp(name, "#") != 0) {
GetParamLabel(name, &context);
}
if (context != NULL) {
BShellEnvOutput(shell, "selinux : %s \r\n", context);
} else {
BShellEnvOutput(shell, "selinux : null \r\n");
}
if (context != NULL) {
free(context);
}
#endif
BShellEnvOutput(shell, " dac : %s(%s) %s(%s) (%s) \r\n",
user->pw_name, GetPermissionString(auditData.dacData.mode, 0, permissionStr, MASK_LENGTH_MAX),
group->gr_name, GetPermissionString(auditData.dacData.mode, DAC_GROUP_START, permissionStr, MASK_LENGTH_MAX),
GetPermissionString(auditData.dacData.mode, DAC_OTHER_START, permissionStr, MASK_LENGTH_MAX));
user->pw_name, GetPermissionString(auditData.dacData.mode, 0, permissionStr[0], MASK_LENGTH_MAX),
group->gr_name, GetPermissionString(auditData.dacData.mode, DAC_GROUP_START, permissionStr[1], MASK_LENGTH_MAX),
GetPermissionString(auditData.dacData.mode, DAC_OTHER_START, permissionStr[2], MASK_LENGTH_MAX)); // 2 other
BShellEnvOutput(shell, " name : %s\r\n", name);
if (value != NULL) {
BShellEnvOutput(shell, " value: %s\r\n", value);
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -86,7 +86,9 @@ int32_t BShellCmdHelp(BShellHandle handle, int32_t argc, char *argv[])
static int32_t BShellCmdExit(BShellHandle handle, int32_t argc, char *argv[])
{
#ifndef STARTUP_INIT_TEST
kill(getpid(), SIGINT);
#endif
return 0;
}
......@@ -99,6 +101,9 @@ int32_t BShellEnvOutput(BShellHandle handle, char *fmt, ...)
int len = vsnprintf_s(shell->data, sizeof(shell->data), sizeof(shell->data) - 1, fmt, list);
va_end(list);
if (len <= 0) {
va_start(list, fmt);
vfprintf(stdout, fmt, list);
va_end(list);
return -1;
}
return BShellEnvOutputString(handle, shell->data);
......@@ -301,7 +306,7 @@ static void BShellEnvHandleNormal(BShellHandle handle, uint8_t data)
} else {
BShellEnvOutputString(shell, BShellEnvErrString(handle, BSH_CMD_TOO_LONG));
BShellEnvOutputString(shell, shell->prompt);
BShellEnvOutputString(shell, shell->buffer);
shell->cursor = shell->length;
}
}
......@@ -310,7 +315,9 @@ static int32_t BShellEnvHandleCtrC(BShellHandle handle, uint8_t code)
{
BSH_CHECK(handle != NULL, return BSH_INVALID_PARAM, "Invalid shell env");
BSH_LOGV("BShellEnvHandleCtrC %d", getpid());
#ifndef STARTUP_INIT_TEST
kill(getpid(), SIGKILL);
#endif
return 0;
}
......@@ -341,7 +348,7 @@ BShellKey *BShellEnvGetDefaultKey(uint8_t code)
return NULL;
}
static void BShellEnvProcessInput(BShellHandle handle, char data)
SHELLSTATIC void BShellEnvProcessInput(BShellHandle handle, char data)
{
BSH_CHECK(handle != NULL, return, "Invalid shell env");
BShellEnv *shell = (BShellEnv *)handle;
......
......@@ -27,11 +27,23 @@
#define BSH_KEY_CTRLC 0x03 // ctr + c
#define BSH_KEY_ESC 0x1B // ecs
#define BSH_COMMAND_MAX_LENGTH 256
#define BSH_COMMAND_MAX_LENGTH (5 * 1024)
#define BSH_PARAMETER_MAX_NUMBER 10
#define BSH_CMD_NAME_END 48
#define BSH_CMD_MAX_KEY 5
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#ifdef STARTUP_INIT_TEST
#define SHELLSTATIC
#else
#define SHELLSTATIC static
#endif
typedef enum {
BSH_IN_NORMAL = 0,
BSH_ANSI_ESC,
......@@ -90,4 +102,15 @@ void BShellEnvOutputByte(BShellHandle handle, char data);
void BShellEnvOutputResult(BShellHandle handle, int32_t result);
char *BShellEnvErrString(BShellHandle handle, int32_t err);
const char *BShellEnvGetStringParam(BShellHandle handle, const char *name);
#ifdef STARTUP_INIT_TEST
void BShellEnvProcessInput(BShellHandle handle, char data);
BShellKey *BShellEnvGetDefaultKey(uint8_t code);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
\ No newline at end of file
文件模式从 100755 更改为 100644
......@@ -22,11 +22,14 @@
#include "init_log.h"
#include "securec.h"
#define BSH_LOG_FILE "begetctrl.log"
#define BSH_LABEL "SHELL"
#define BSH_LOGI(fmt, ...) STARTUP_LOGI(BSH_LOG_FILE, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGE(fmt, ...) STARTUP_LOGE(BSH_LOG_FILE, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGV(fmt, ...) STARTUP_LOGV(BSH_LOG_FILE, BSH_LABEL, fmt, ##__VA_ARGS__)
#ifndef BSH_DOMAIN
#define BSH_DOMAIN (BASE_DOMAIN + 5)
#endif
#define BSH_LOGI(fmt, ...) STARTUP_LOGI(BSH_DOMAIN, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGE(fmt, ...) STARTUP_LOGE(BSH_DOMAIN, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGV(fmt, ...) STARTUP_LOGV(BSH_DOMAIN, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_CHECK(ret, exper, ...) \
if (!(ret)) { \
......
{
"services" : [{
"name" : "console",
"path" : ["/system/bin/sh"],
"start-mode" : "condition",
"disabled" : 1,
"console" : 1,
"sandbox" : 0,
"uid" : "root",
"gid" : ["shell", "log", "readproc"],
"jobs" : {
"on-start" : "services:console"
}
}
]
}
......@@ -4,6 +4,7 @@ system:x:1000:
radio:x:1001:
bluetooth:x:1002:
graphics:x:1003:
samgr:x:1005:
file_manager:x:1006:
log:x:1007:
user_data_rw:x:1008:
......@@ -16,13 +17,15 @@ keystore:x:1017:
usb:x:1018:
drm:x:1019:
media_rw:x:1023:
dsoftbus:x:1024:
nfc:x:1027:
sdcard_r:x:1028:
package_info:x:1032:
logd:x:1036:
shared_relro:x:1037:
audioserver:x:1041:
audio:x:1041:
cameraserver:x:1047:
servicectrl:x:1050:root,shell,system,samgr,hdf_devmgr
shell:x:2000:
cache:x:2001:
net_bw_stats:x:3006:
......@@ -32,5 +35,38 @@ wakelock:x:3010:
uhid:x:3011:
ddms:x:3012:
access_token:x:3020:
blue_host:x:3021:
sample_host:x:3022:
usb_host:x:3023:
usbfnMaster_host:x:3024:
power_host:x:3025:
wifi_host:x:3026:
audio_hdi_server_host:x:3027:
camera_host:x:3028:
input_user_host:x:3029:
display_gralloc_host:x:3030:
codec_host:x:3031:
riladapter_host:x:3032:
sensor_dal_host:x:3033:
vibrator_dal_host:x:3034:
light_dal_host:x:3035:
wifi_c_host:x:3036:
disp_gralloc_host:x:3037:
dcamera_host:x:3038:
hwc_host:x:3039:
gralloc_host:x:3040:
sensor_host:x:3041:
nfc_host:x:3042:
a2dp_host:x:3043:
hdf_devmgr:x:3044:
connected_tag_host:x:3045:
dslm:x:3046:
work_scheduler:x:3047:
device_usage_stats:x:3048:
dms:x:5522:
sensor:x:6688:
input:x:6696:
msdp:x:6699:
misc:x:9998:
app:x:10000:
useriam:x:1088:
......@@ -8,11 +8,6 @@
"name" : "pre-init",
"cmds" : [
"write /proc/sys/kernel/sysrq 0",
"mkdir /acct/uid",
"chown root system /dev/memcg/memory.pressure_level",
"chmod 0040 /dev/memcg/memory.pressure_level",
"mkdir /dev/memcg/apps/ 0755 system system",
"mkdir /dev/memcg/system 0550 system system",
"start ueventd",
"start watchdog_service",
"mkdir /data",
......@@ -21,8 +16,7 @@
"chmod 0771 /data",
"mkdir /data/service 0711 root root",
"mkdir /data/service/el0 0711 root root",
"mksandbox system",
"mksandbox chipset",
"mount configfs none /config nodev noexec nosuid",
"load_persist_params ",
"bootchart start",
"chown access_token access_token /dev/access_token_id",
......@@ -31,45 +25,13 @@
}, {
"name" : "init",
"cmds" : [
"mksandbox system",
"mksandbox chipset",
"copy /proc/cmdline /dev/urandom",
"copy /system/etc/prop.default /dev/urandom",
"symlink /proc/self/fd/0 /dev/stdin",
"symlink /proc/self/fd/1 /dev/stdout",
"symlink /proc/self/fd/2 /dev/stderr",
"symlink /sys/kernel/debug /d",
"mkdir /dev/stune/foreground",
"mkdir /dev/stune/background",
"mkdir /dev/stune/top-app",
"mkdir /dev/stune/rt",
"chown system system /dev/stune",
"chown system system /dev/stune/foreground",
"chown system system /dev/stune/background",
"chown system system /dev/stune/top-app",
"chown system system /dev/stune/rt",
"chown system system /dev/stune/tasks",
"chown system system /dev/stune/foreground/tasks",
"chown system system /dev/stune/background/tasks",
"chown system system /dev/stune/top-app/tasks",
"chown system system /dev/stune/rt/tasks",
"chmod 0664 /dev/stune/tasks",
"chmod 0664 /dev/stune/foreground/tasks",
"chmod 0664 /dev/stune/background/tasks",
"chmod 0664 /dev/stune/top-app/tasks",
"chmod 0664 /dev/stune/rt/tasks",
"mkdir /dev/blkio/background",
"chown system system /dev/blkio",
"chown system system /dev/blkio/background",
"chown system system /dev/blkio/tasks",
"chown system system /dev/blkio/background/tasks",
"chmod 0664 /dev/blkio/tasks",
"chmod 0664 /dev/blkio/background/tasks",
"write /dev/blkio/blkio.weight 1000",
"write /dev/blkio/background/blkio.weight 500",
"write /dev/blkio/blkio.group_idle 0",
"write /dev/blkio/background/blkio.group_idle 0",
"chmod 0770 /config/sdcardfs",
"chown system package_info /config/sdcardfs",
"symlink /storage/self/primary /sdcard",
"write /proc/sys/kernel/panic_on_oops 1",
"write /proc/sys/kernel/hung_task_timeout_secs 0",
"write /proc/cpu/alignment 4",
......@@ -91,53 +53,8 @@
"write /proc/sys/net/ipv4/conf/all/accept_redirects 0",
"write /proc/sys/net/ipv6/conf/all/accept_redirects 0",
"chmod 0400 /proc/net/fib_trie",
"chown system system /dev/cpuctl",
"chown system system /dev/cpuctl/tasks",
"chmod 0666 /dev/cpuctl/tasks",
"write /dev/cpuctl/cpu.rt_period_us 1000000",
"write /dev/cpuctl/cpu.rt_runtime_us 950000",
"mkdir /dev/cpuset/foreground",
"copy /dev/cpuset/cpus /dev/cpuset/foreground/cpus",
"copy /dev/cpuset/mems /dev/cpuset/foreground/mems",
"mkdir /dev/cpuset/background",
"copy /dev/cpuset/cpus /dev/cpuset/background/cpus",
"copy /dev/cpuset/mems /dev/cpuset/background/mems",
"mkdir /dev/cpuset/system-background",
"copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus",
"copy /dev/cpuset/mems /dev/cpuset/system-background/mems",
"mkdir /dev/cpuset/restricted",
"copy /dev/cpuset/cpus /dev/cpuset/restricted/cpus",
"copy /dev/cpuset/mems /dev/cpuset/restricted/mems",
"mkdir /dev/cpuset/top-app",
"copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus",
"copy /dev/cpuset/mems /dev/cpuset/top-app/mems",
"chown system system /dev/cpuset",
"chown system system /dev/cpuset/foreground",
"chown system system /dev/cpuset/background",
"chown system system /dev/cpuset/system-background",
"chown system system /dev/cpuset/top-app",
"chown system system /dev/cpuset/restricted",
"chown system system /dev/cpuset/tasks",
"chown system system /dev/cpuset/foreground/tasks",
"chown system system /dev/cpuset/background/tasks",
"chown system system /dev/cpuset/system-background/tasks",
"chown system system /dev/cpuset/top-app/tasks",
"chown system system /dev/cpuset/restricted/tasks",
"chmod 0775 /dev/cpuset/system-background",
"chmod 0664 /dev/cpuset/foreground/tasks",
"chmod 0664 /dev/cpuset/background/tasks",
"chmod 0664 /dev/cpuset/system-background/tasks",
"chmod 0664 /dev/cpuset/top-app/tasks",
"chmod 0664 /dev/cpuset/restricted/tasks",
"chmod 0664 /dev/cpuset/tasks",
"chown system system /proc/pressure/memory",
"chmod 0664 /proc/pressure/memory",
"chown root net_bw_acct /proc/net/xt_qtaguid/ctrl",
"chown root net_bw_stats /proc/net/xt_qtaguid/stats",
"chmod 0644 /dev/xt_qtaguid",
"chown root root /dev/cg2_bpf",
"chmod 0600 /dev/cg2_bpf",
"mount bpf bpf /sys/fs/bpf nodev noexec nosuid",
"mkdir /dev/fscklogs 0770 root system",
"write /proc/sys/abi/swp 1",
"symlink /proc/self/fd /dev/fd",
......@@ -167,11 +84,6 @@
"trigger early-boot",
"trigger boot"
]
}, {
"name" : "early-fs",
"cmds" : [
"start vold"
]
}, {
"name" : "post-fs",
"cmds" : [
......@@ -227,48 +139,11 @@
"mkdir /data/app-staging 0750 system system",
"copy /data/system/entropy.dat /dev/urandom",
"mkdir /data/misc 01771 system misc",
"mkdir /data/misc/bluedroid 02770 bluetooth bluetooth",
"chmod 0660 /data/misc/bluedroid/bt_config.conf",
"chown bluetooth bluetooth /data/misc/bluedroid/bt_config.conf",
"mkdir /data/misc/bluetooth 0770 bluetooth bluetooth",
"mkdir /data/misc/bluetooth/logs 0770 bluetooth bluetooth",
"mkdir /data/misc/keystore 0700 keystore keystore",
"mkdir /data/misc/gatekeeper 0700 system system",
"mkdir /data/misc/keychain 0771 system system",
"mkdir /data/misc/net 0750 root shell",
"mkdir /data/misc/radio 0770 system radio",
"mkdir /data/misc/sms 0770 system radio",
"mkdir /data/misc/carrierid 0770 system radio",
"mkdir /data/misc/apns 0770 system radio",
"mkdir /data/misc/zoneinfo 0775 system system",
"mkdir /data/misc/network_watchlist 0774 system system",
"mkdir /data/misc/textclassifier 0771 system system",
"mkdir /data/misc/vpn 0770 system vpn",
"mkdir /data/misc/shared_relro 0771 shared_relro shared_relro",
"mkdir /data/misc/systemkeys 0700 system system",
"mkdir /data/misc/wifi 0770 wifi wifi",
"mkdir /data/misc/wifi/sockets 0770 wifi wifi",
"mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi",
"mkdir /data/misc/ethernet 0770 system system",
"mkdir /data/misc/dhcp 0770 dhcp dhcp",
"mkdir /data/misc/user 0771 root root",
"mkdir /data/misc/perfprofd 0775 root root",
"chmod 0660 /data/misc/wifi/wpa_supplicant.conf",
"mkdir /data/local 0751 root root",
"mkdir /data/misc/media 0700 media media",
"mkdir /data/misc/audioserver 0700 audioserver audioserver",
"mkdir /data/misc/cameraserver 0700 cameraserver cameraserver",
"mkdir /data/misc/vold 0700 root root",
"mkdir /data/misc/boottrace 0771 system shell",
"mkdir /data/misc/update_engine 0700 root root",
"mkdir /data/misc/update_engine_log 02750 root log",
"mkdir /data/misc/trace 0700 root root",
"mkdir /data/misc/wmtrace 0700 system system",
"mkdir /data/misc/profiles 0771 system system",
"mkdir /data/misc/profiles/cur 0771 system system",
"mkdir /data/misc/profiles/ref 0771 system system",
"mkdir /data/misc/profman 0770 system shell",
"mkdir /data/misc/gcov 0770 root root",
"mkdir /data/preloads 0775 system system",
"mkdir /data/vendor 0771 root root",
"mkdir /data/vendor_ce 0771 root root",
......@@ -314,7 +189,8 @@
"mkdir /data/init_agent 0770 shell system",
"setparam sys.use_memfd false",
"chown root system /dev/fscklogs/log",
"chmod 0770 /dev/fscklogs/log"
"chmod 0770 /dev/fscklogs/log",
"chmod 0660 /dev/fuse"
]
}, {
"name" : "boot",
......@@ -322,70 +198,15 @@
"write /proc/sys/net/core/xfrm_acq_expires 3600",
"write /proc/sys/vm/overcommit_memory 1",
"write /proc/sys/vm/min_free_order_shift 4",
"chown root system /sys/module/lowmemorykiller/parameters/adj",
"chmod 0664 /sys/module/lowmemorykiller/parameters/adj",
"chown root system /sys/module/lowmemorykiller/parameters/minfree",
"chmod 0664 /sys/module/lowmemorykiller/parameters/minfree",
"chown root system /sys/block/zram0/idle",
"chmod 0664 /sys/block/zram0/idle",
"chown root system /sys/block/zram0/writeback",
"chmod 0664 /sys/block/zram0/writeback",
"write /proc/sys/vm/dirty_expire_centisecs 200",
"write /proc/sys/vm/dirty_background_ratio 5",
"write /sys/fs/f2fs/${dev.mnt.blk.data}/cp_interval 200",
"chown system system /sys/power/autosleep",
"chown radio wakelock /sys/power/wake_lock",
"chown radio wakelock /sys/power/wake_unlock",
"chmod 0660 /sys/power/wake_lock",
"chmod 0660 /sys/power/wake_unlock",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boost",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy",
"chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
"chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
"chown system system /sys/class/leds/vibrator/trigger",
"chown system system /sys/class/leds/vibrator/activate",
"chown system system /sys/class/leds/vibrator/brightness",
"chown system system /sys/class/leds/vibrator/duration",
"chown system system /sys/class/leds/vibrator/state",
"chown system system /sys/class/timed_output/vibrator/enable",
"chown system system /sys/class/leds/keyboard-backlight/brightness",
"chown system system /sys/class/leds/lcd-backlight/brightness",
"chown system system /sys/class/leds/button-backlight/brightness",
"chown system system /sys/class/leds/jogball-backlight/brightness",
"chown system system /sys/class/leds/red/brightness",
"chown system system /sys/class/leds/green/brightness",
"chown system system /sys/class/leds/blue/brightness",
"chown system system /sys/class/leds/red/device/grpfreq",
"chown system system /sys/class/leds/red/device/grppwm",
"chown system system /sys/class/leds/red/device/blink",
"chown system system /sys/module/sco/parameters/disable_esco",
"chown system system /sys/kernel/ipv4/tcp_wmem_min",
"chown system system /sys/kernel/ipv4/tcp_wmem_def",
"chown system system /sys/kernel/ipv4/tcp_wmem_max",
"chown system system /sys/kernel/ipv4/tcp_rmem_min",
"chown system system /sys/kernel/ipv4/tcp_rmem_def",
"chown system system /sys/kernel/ipv4/tcp_rmem_max",
"chown root radio /proc/cmdline",
"setparam net.tcp.default_init_rwnd 60"
]
......@@ -429,53 +250,5 @@
"chmod 0775 /data/misc/wmtrace"
]
}
],
"services" : [{
"name" : "ueventd",
"path" : ["/system/bin/ueventd"],
"socket" : [{
"name" : "ueventd",
"family" : "AF_NETLINK",
"type" : "SOCK_DGRAM",
"protocol" : "NETLINK_KOBJECT_UEVENT",
"permissions" : "0660",
"uid" : "system",
"gid" : "system",
"option" : [
"SOCKET_OPTION_PASSCRED",
"SOCKET_OPTION_RCVBUFFORCE",
"SOCK_CLOEXEC",
"SOCK_NONBLOCK"
]
}],
"critical" : [ 0, 15, 5],
"ondemand" : true,
"sandbox" : 0,
"start-mode" : "condition"
}, {
"name" : "console",
"path" : ["/system/bin/sh"],
"start-mode" : "condition",
"disabled" : 1,
"console" : 1,
"sandbox" : 0,
"uid" : "root",
"gid" : ["shell", "log", "readproc"],
"jobs" : {
"on-start" : "services:console"
}
}, {
"name" : "watchdog_service",
"start-mode" : "condition",
"path" : ["/system/bin/watchdog_service", "10", "2"],
"disabled" : 1,
"sandbox" : 0,
"uid" : "root",
"gid" : ["shell", "log", "readproc"]
}, {
"name" : "misc",
"path" : ["/system/bin/misc_daemon", "--write_logo", "/vendor/logo.rgb"],
"once" : 1
}
]
}
......@@ -2,20 +2,16 @@
"import" : [
"/etc/init.usb.cfg",
"/etc/init.usb.configfs.cfg",
"/etc/init.${ohos.boot.hardware}.cfg",
"/etc/init.${ohos.boot.hardware}.usb.cfg"
"/vendor/etc/init.${ohos.boot.hardware}.cfg"
],
"jobs" : [{
"name" : "pre-init",
"cmds" : [
"write /proc/sys/kernel/sysrq 0",
"mkdir /acct/uid",
"chown root system /dev/memcg/memory.pressure_level",
"chmod 0040 /dev/memcg/memory.pressure_level",
"mkdir /dev/memcg/apps/ 0755 system system",
"mkdir /dev/memcg/system 0550 system system",
"start ueventd",
"start watchdog_service",
"mkdir /data",
"mount_fstab /vendor/etc/fstab.${ohos.boot.hardware}",
"chown system system /data",
"chmod 0771 /data",
"mkdir /data/service 0711 root root",
......@@ -30,40 +26,6 @@
"symlink /proc/self/fd/0 /dev/stdin",
"symlink /proc/self/fd/1 /dev/stdout",
"symlink /proc/self/fd/2 /dev/stderr",
"symlink /sys/kernel/debug /d",
"mkdir /dev/stune/foreground",
"mkdir /dev/stune/background",
"mkdir /dev/stune/top-app",
"mkdir /dev/stune/rt",
"chown system system /dev/stune",
"chown system system /dev/stune/foreground",
"chown system system /dev/stune/background",
"chown system system /dev/stune/top-app",
"chown system system /dev/stune/rt",
"chown system system /dev/stune/tasks",
"chown system system /dev/stune/foreground/tasks",
"chown system system /dev/stune/background/tasks",
"chown system system /dev/stune/top-app/tasks",
"chown system system /dev/stune/rt/tasks",
"chmod 0664 /dev/stune/tasks",
"chmod 0664 /dev/stune/foreground/tasks",
"chmod 0664 /dev/stune/background/tasks",
"chmod 0664 /dev/stune/top-app/tasks",
"chmod 0664 /dev/stune/rt/tasks",
"mkdir /dev/blkio/background",
"chown system system /dev/blkio",
"chown system system /dev/blkio/background",
"chown system system /dev/blkio/tasks",
"chown system system /dev/blkio/background/tasks",
"chmod 0664 /dev/blkio/tasks",
"chmod 0664 /dev/blkio/background/tasks",
"write /dev/blkio/blkio.weight 1000",
"write /dev/blkio/background/blkio.weight 500",
"write /dev/blkio/blkio.group_idle 0",
"write /dev/blkio/background/blkio.group_idle 0",
"chmod 0770 /config/sdcardfs",
"chown system package_info /config/sdcardfs",
"symlink /storage/self/primary /sdcard",
"write /proc/sys/kernel/panic_on_oops 1",
"write /proc/sys/kernel/hung_task_timeout_secs 0",
"write /proc/cpu/alignment 4",
......@@ -85,53 +47,8 @@
"write /proc/sys/net/ipv4/conf/all/accept_redirects 0",
"write /proc/sys/net/ipv6/conf/all/accept_redirects 0",
"chmod 0400 /proc/net/fib_trie",
"chown system system /dev/cpuctl",
"chown system system /dev/cpuctl/tasks",
"chmod 0666 /dev/cpuctl/tasks",
"write /dev/cpuctl/cpu.rt_period_us 1000000",
"write /dev/cpuctl/cpu.rt_runtime_us 950000",
"mkdir /dev/cpuset/foreground",
"copy /dev/cpuset/cpus /dev/cpuset/foreground/cpus",
"copy /dev/cpuset/mems /dev/cpuset/foreground/mems",
"mkdir /dev/cpuset/background",
"copy /dev/cpuset/cpus /dev/cpuset/background/cpus",
"copy /dev/cpuset/mems /dev/cpuset/background/mems",
"mkdir /dev/cpuset/system-background",
"copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus",
"copy /dev/cpuset/mems /dev/cpuset/system-background/mems",
"mkdir /dev/cpuset/restricted",
"copy /dev/cpuset/cpus /dev/cpuset/restricted/cpus",
"copy /dev/cpuset/mems /dev/cpuset/restricted/mems",
"mkdir /dev/cpuset/top-app",
"copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus",
"copy /dev/cpuset/mems /dev/cpuset/top-app/mems",
"chown system system /dev/cpuset",
"chown system system /dev/cpuset/foreground",
"chown system system /dev/cpuset/background",
"chown system system /dev/cpuset/system-background",
"chown system system /dev/cpuset/top-app",
"chown system system /dev/cpuset/restricted",
"chown system system /dev/cpuset/tasks",
"chown system system /dev/cpuset/foreground/tasks",
"chown system system /dev/cpuset/background/tasks",
"chown system system /dev/cpuset/system-background/tasks",
"chown system system /dev/cpuset/top-app/tasks",
"chown system system /dev/cpuset/restricted/tasks",
"chmod 0775 /dev/cpuset/system-background",
"chmod 0664 /dev/cpuset/foreground/tasks",
"chmod 0664 /dev/cpuset/background/tasks",
"chmod 0664 /dev/cpuset/system-background/tasks",
"chmod 0664 /dev/cpuset/top-app/tasks",
"chmod 0664 /dev/cpuset/restricted/tasks",
"chmod 0664 /dev/cpuset/tasks",
"chown system system /proc/pressure/memory",
"chmod 0664 /proc/pressure/memory",
"chown root net_bw_acct /proc/net/xt_qtaguid/ctrl",
"chown root net_bw_stats /proc/net/xt_qtaguid/stats",
"chmod 0644 /dev/xt_qtaguid",
"chown root root /dev/cg2_bpf",
"chmod 0600 /dev/cg2_bpf",
"mount bpf bpf /sys/fs/bpf nodev noexec nosuid",
"mkdir /dev/fscklogs 0770 root system",
"write /proc/sys/abi/swp 1",
"symlink /proc/self/fd /dev/fd",
......@@ -158,11 +75,6 @@
"trigger early-boot",
"trigger boot"
]
}, {
"name" : "early-fs",
"cmds" : [
"start vold"
]
}, {
"name" : "post-fs",
"cmds" : [
......@@ -216,48 +128,11 @@
"mkdir /data/app-staging 0750 system system",
"copy /data/system/entropy.dat /dev/urandom",
"mkdir /data/misc 01771 system misc",
"mkdir /data/misc/bluedroid 02770 bluetooth bluetooth",
"chmod 0660 /data/misc/bluedroid/bt_config.conf",
"chown bluetooth bluetooth /data/misc/bluedroid/bt_config.conf",
"mkdir /data/misc/bluetooth 0770 bluetooth bluetooth",
"mkdir /data/misc/bluetooth/logs 0770 bluetooth bluetooth",
"mkdir /data/misc/keystore 0700 keystore keystore",
"mkdir /data/misc/gatekeeper 0700 system system",
"mkdir /data/misc/keychain 0771 system system",
"mkdir /data/misc/net 0750 root shell",
"mkdir /data/misc/radio 0770 system radio",
"mkdir /data/misc/sms 0770 system radio",
"mkdir /data/misc/carrierid 0770 system radio",
"mkdir /data/misc/apns 0770 system radio",
"mkdir /data/misc/zoneinfo 0775 system system",
"mkdir /data/misc/network_watchlist 0774 system system",
"mkdir /data/misc/textclassifier 0771 system system",
"mkdir /data/misc/vpn 0770 system vpn",
"mkdir /data/misc/shared_relro 0771 shared_relro shared_relro",
"mkdir /data/misc/systemkeys 0700 system system",
"mkdir /data/misc/wifi 0770 wifi wifi",
"mkdir /data/misc/wifi/sockets 0770 wifi wifi",
"mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi",
"mkdir /data/misc/ethernet 0770 system system",
"mkdir /data/misc/dhcp 0770 dhcp dhcp",
"mkdir /data/misc/user 0771 root root",
"mkdir /data/misc/perfprofd 0775 root root",
"chmod 0660 /data/misc/wifi/wpa_supplicant.conf",
"mkdir /data/local 0751 root root",
"mkdir /data/misc/media 0700 media media",
"mkdir /data/misc/audioserver 0700 audioserver audioserver",
"mkdir /data/misc/cameraserver 0700 cameraserver cameraserver",
"mkdir /data/misc/vold 0700 root root",
"mkdir /data/misc/boottrace 0771 system shell",
"mkdir /data/misc/update_engine 0700 root root",
"mkdir /data/misc/update_engine_log 02750 root log",
"mkdir /data/misc/trace 0700 root root",
"mkdir /data/misc/wmtrace 0700 system system",
"mkdir /data/misc/profiles 0771 system system",
"mkdir /data/misc/profiles/cur 0771 system system",
"mkdir /data/misc/profiles/ref 0771 system system",
"mkdir /data/misc/profman 0770 system shell",
"mkdir /data/misc/gcov 0770 root root",
"mkdir /data/preloads 0775 system system",
"mkdir /data/vendor 0771 root root",
"mkdir /data/vendor_ce 0771 root root",
......@@ -303,7 +178,8 @@
"mkdir /data/init_agent 0770 shell system",
"setparam sys.use_memfd false",
"chown root system /dev/fscklogs/log",
"chmod 0770 /dev/fscklogs/log"
"chmod 0770 /dev/fscklogs/log",
"chmod 0660 /dev/fuse"
]
}, {
"name" : "boot",
......@@ -311,70 +187,15 @@
"write /proc/sys/net/core/xfrm_acq_expires 3600",
"write /proc/sys/vm/overcommit_memory 1",
"write /proc/sys/vm/min_free_order_shift 4",
"chown root system /sys/module/lowmemorykiller/parameters/adj",
"chmod 0664 /sys/module/lowmemorykiller/parameters/adj",
"chown root system /sys/module/lowmemorykiller/parameters/minfree",
"chmod 0664 /sys/module/lowmemorykiller/parameters/minfree",
"chown root system /sys/block/zram0/idle",
"chmod 0664 /sys/block/zram0/idle",
"chown root system /sys/block/zram0/writeback",
"chmod 0664 /sys/block/zram0/writeback",
"write /proc/sys/vm/dirty_expire_centisecs 200",
"write /proc/sys/vm/dirty_background_ratio 5",
"write /sys/fs/f2fs/${dev.mnt.blk.data}/cp_interval 200",
"chown system system /sys/power/autosleep",
"chown radio wakelock /sys/power/wake_lock",
"chown radio wakelock /sys/power/wake_unlock",
"chmod 0660 /sys/power/wake_lock",
"chmod 0660 /sys/power/wake_unlock",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boost",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy",
"chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
"chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
"chown system system /sys/class/leds/vibrator/trigger",
"chown system system /sys/class/leds/vibrator/activate",
"chown system system /sys/class/leds/vibrator/brightness",
"chown system system /sys/class/leds/vibrator/duration",
"chown system system /sys/class/leds/vibrator/state",
"chown system system /sys/class/timed_output/vibrator/enable",
"chown system system /sys/class/leds/keyboard-backlight/brightness",
"chown system system /sys/class/leds/lcd-backlight/brightness",
"chown system system /sys/class/leds/button-backlight/brightness",
"chown system system /sys/class/leds/jogball-backlight/brightness",
"chown system system /sys/class/leds/red/brightness",
"chown system system /sys/class/leds/green/brightness",
"chown system system /sys/class/leds/blue/brightness",
"chown system system /sys/class/leds/red/device/grpfreq",
"chown system system /sys/class/leds/red/device/grppwm",
"chown system system /sys/class/leds/red/device/blink",
"chown system system /sys/module/sco/parameters/disable_esco",
"chown system system /sys/kernel/ipv4/tcp_wmem_min",
"chown system system /sys/kernel/ipv4/tcp_wmem_def",
"chown system system /sys/kernel/ipv4/tcp_wmem_max",
"chown system system /sys/kernel/ipv4/tcp_rmem_min",
"chown system system /sys/kernel/ipv4/tcp_rmem_def",
"chown system system /sys/kernel/ipv4/tcp_rmem_max",
"chown root radio /proc/cmdline",
"setparam net.tcp.default_init_rwnd 60"
]
......@@ -427,7 +248,24 @@
"services" : [{
"name" : "ueventd",
"path" : ["/system/bin/ueventd"],
"critical" : 1,
"socket" : [{
"name" : "ueventd",
"family" : "AF_NETLINK",
"type" : "SOCK_DGRAM",
"protocol" : "NETLINK_KOBJECT_UEVENT",
"permissions" : "0660",
"uid" : "system",
"gid" : "system",
"option" : [
"SOCKET_OPTION_PASSCRED",
"SOCKET_OPTION_RCVBUFFORCE",
"SOCK_CLOEXEC",
"SOCK_NONBLOCK"
]
}],
"critical" : [ 0, 15, 5],
"ondemand" : true,
"sandbox" : 0,
"start-mode" : "condition"
}, {
"name" : "console",
......
{
"services" : [{
"name" : "misc",
"path" : ["/system/bin/misc_daemon", "--write_logo", "/vendor/logo.rgb"],
"once" : 1
}
]
}
......@@ -38,47 +38,22 @@ const.product.model=ohos
const.product.name="OpenHarmony 2.0 Canary"
persist.sys.usb.config=hdc
const.sandbox=enable
# const.build.characteristics=default
const.product.devicetype=default
# OHOS_SOFTWARE_MODEL[] = {"default"}
const.software.model=default
# OHOS_MANUFACTURE[] = {"default"}
const.product.manufacturer=default
# OHOS_BRAND[] = {"default"}
const.product.brand=default
# OHOS_PRODUCT_SERIES[] = {"default"}
const.build.product=default
# OHOS_HARDWARE_MODEL[] = {"default"}
const.product.hardwareversion=default
# OHOS_BOOTLOADER_VERSION[] = {"bootloader"}
const.product.bootloader.version=bootloader
# OHOS_ABI_LIST[] = {"default"}
const.product.cpu.abilist=default
# OHOS_SECURITY_PATCH_TAG[] = { "2020-09-01" }
const.ohos.version.security_patch=2020-09-01
# OHOS_DISPLAY_VERSION[] = {"OpenHarmony 3.1.5.2"}
const.product.software.version=OpenHarmony 3.1.5.2
# OHOS_INCREMENTAL_VERSION[] = {"default"}
const.product.software.version=OpenHarmony 3.2.2.1
const.product.incremental.version=default
# OHOS_FIRST_API_LEVEL = 1
const.product.firstapiversion=1
# OHOS_BUILD_TYPE[] = {"default"}
const.product.build.type=default
# OHOS_BUILD_USER[] = {"default"}
const.product.build.user=default
# OHOS_BUILD_HOST[] = {"default"}
const.product.build.host=default
# OHOS_BUILD_TIME[] = {"default"}
const.product.build.date=default
# OHOS_HARDWARE_PROFILE[] = {"default"}
const.product.hardwareprofile=default
# OHOS_RELEASE_TYPE[] = { "Canary1" }
const.ohos.releasetype=Canary1
# OHOS_SDK_API_LEVEL = 8;
const.ohos.apiversion=8
# OHOS_BUILD_ROOT_HASH[] = { "default" }
const.ohos.buildroothash=default
# OHOS_SDK_API_LEVEL = 8
const.ohos.sdkapilevel=8
# OHOS_OS_NAME[] = { "OpenHarmony" }
const.ohos.name=OpenHarmony
......@@ -11,23 +11,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
build_version root:root:0777
hw_sc.build.os.enable root:root:0777
hw_sc.build.os.apiversion root:root:0777
hw_sc.build.os.version root:root:0777
hw_sc.build.os.releasetype root:root:0777
build_version = root:root:0777
hw_sc.build.os.enable = root:root:0777
hw_sc.build.os.apiversion = root:root:0777
hw_sc.build.os.version = root:root:0777
hw_sc.build.os.releasetype = root:root:0777
const.actionable_compatible_property.enabled root:root:0777
const.postinstall.fstab.prefix root:root:0777
const.secure root:root:0777
security.perf_harden root:root:0777
const.allow.mock.location root:root:0777
const.debuggable root:root:0777
persist.sys.usb.config root:root:0777
const.actionable_compatible_property.enabled = root:root:0777
const.postinstall.fstab.prefix = root:root:0777
const.secure = root:root:0777
security.perf_harden = root:root:0777
const.allow.mock.location = root:root:0777
const.debuggable = root:root:0777
persist.sys.usb.config = root:root:0777
# default forbit other user to start service
ohos.servicectrl. system:root:0770
test.permission. root:root:0770
test.permission.read. root:root:0774
test.permission.write. root:root:0772
test.permission.watcher. root:root:0771
\ No newline at end of file
ohos.servicectrl. = system:servicectrl:0775
# Copyright (c) 2021 Huawei Device 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
#
# 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.
const.ohos.version.security_patch=2022-03-30
const.ohos.releasetype=Canary1
const.ohos.apiversion=8
\ No newline at end of file
......@@ -17,13 +17,15 @@ keystore:x:1017:1017:::/bin/false
usb:x:1018:1018:::/bin/false
drm:x:1019:1019:::/bin/false
media_rw:x:1023:1023:::/bin/false
dsoftbus:x:1024:1024:::/bin/false
nfc:x:1027:1027:::/bin/false
sdcard_r:x:1028:1028:::/bin/false
package_info:x:1032:1032:::/bin/false
logd:x:1036:1036:::/bin/false
shared_relro:x:1037:1037:::/bin/false
audioserver:x:1041:1041:::/bin/false
audio:x:1041:1041:::/bin/false
cameraserver:x:1047:1047:::/bin/false
faultloggerd:x:1202:1202:::/bin/false
shell:x:2000:2000:::/bin/false
cache:x:2001:2001:::/bin/false
net_bw_stats:x:3006:3006:::/bin/false
......@@ -33,6 +35,39 @@ wakelock:x:3010:3010:::/bin/false
uhid:x:3011:3011:::/bin/false
ddms:x:3012:3012:::/bin/false
access_token:x:3020:3020:::/bin/false
blue_host:x:3021:3021:::/bin/false
sample_host:x:3022:3022:::/bin/false
usb_host:x:3023:3023:::/bin/false
usbfnMaster_host:x:3024:3024:::/bin/false
power_host:x:3025:3025:::/bin/false
wifi_host:x:3026:3026:::/bin/false
audio_hdi_server_host:x:3027:3027:::/bin/false
camera_host:x:3028:3028:::/bin/false
input_user_host:x:3029:3029:::/bin/false
display_gralloc_host:x:3030:3030:::/bin/false
codec_host:x:3031:3031:::/bin/false
riladapter_host:x:3032:3032:::/bin/false
sensor_dal_host:x:3033:3033:::/bin/false
vibrator_dal_host:x:3034:3034:::/bin/false
light_dal_host:x:3035:3035:::/bin/false
wifi_c_host:x:3036:3036:::/bin/false
disp_gralloc_host:x:3037:3037:::/bin/false
dcamera_host:x:3038:3038:::/bin/false
hwc_host:x:3039:3039:::/bin/false
gralloc_host:x:3040:3040:::/bin/false
sensor_host:x:3041:3041:::/bin/false
nfc_host:x:3042:3042:::/bin/false
a2dp_host:x:3043:3043:::/bin/false
hdf_devmgr:x:3044:3044:::/bin/false
connected_tag_host:x:3045:3045:::/bin/false
dslm:x:3046:3046:::/bin/false
work_scheduler:x:3047:3047:::/bin/false
device_usage_stats:x:3048:3048:::/bin/false
dms:x:5522:5522:::/bin/false
dbms:x:6000:6000:::/bin/false
sensor:x:6688:6688:::/bin/false
input:x:6696:6696:::/bin/false
msdp:x:6699:6699:::/bin/false
misc:x:9998:9998:::/bin/false
app:x:10000:10000:::/bin/false
useriam:x:1088:1088:::/bin/false
{
"services" : [{
"name" : "ueventd",
"path" : ["/system/bin/ueventd"],
"socket" : [{
"name" : "ueventd",
"family" : "AF_NETLINK",
"type" : "SOCK_DGRAM",
"protocol" : "NETLINK_KOBJECT_UEVENT",
"permissions" : "0660",
"uid" : "system",
"gid" : "system",
"option" : [
"SOCKET_OPTION_PASSCRED",
"SOCKET_OPTION_RCVBUFFORCE",
"SOCK_CLOEXEC",
"SOCK_NONBLOCK"
]
}],
"critical" : [ 0, 15, 5],
"ondemand" : true,
"sandbox" : 0,
"start-mode" : "condition"
}
]
}
{
"services" : [{
"name" : "watchdog_service",
"start-mode" : "condition",
"path" : ["/system/bin/watchdog_service", "10", "2"],
"disabled" : 1,
"sandbox" : 0,
"uid" : "root",
"gid" : ["shell", "log", "readproc"]
}
]
}
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -97,6 +97,7 @@ int SystemWatchParameter(const char *keyprefix, ParameterChangePtr change, void
void SystemDumpParameters(int verbose);
int SysCheckParamExist(const char *name);
long long GetSystemCommitId(void);
#ifdef __cplusplus
#if __cplusplus
}
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -17,7 +17,6 @@
#include <stdlib.h>
#include <string.h>
#include "init_plugin.h"
#include "list.h"
#ifdef __cplusplus
......@@ -25,8 +24,11 @@
extern "C" {
#endif
#endif
#ifdef __aarch64__
#define DEFAULT_PLUGIN_PATH "/system/lib64/plugin"
#else
#define DEFAULT_PLUGIN_PATH "/system/lib/plugin"
#endif
#define DEFAULT_PLUGIN_CFG "/system/etc/plugin_modules.cfg"
typedef enum {
PLUGIN_STATE_IDLE,
......@@ -69,8 +71,7 @@ void PluginManagerInit(void);
int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd);
int ParseInitCfg(const char *configFile, void *context);
typedef PluginInterface *(*GetPluginInterfaceFunc)();
int SetPluginInterface(void);
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -48,11 +48,10 @@ extern "C" {
#define SERVICE_ATTR_CRITICAL 0x020 // critical, will reboot if it crash 4 times in 4 minutes
#define SERVICE_ATTR_DISABLED 0x040 // disabled
#define SERVICE_ATTR_CONSOLE 0x080 // console
#define SERVICE_ATTR_DYNAMIC 0x100 // dynamic service
#define SERVICE_ATTR_ONDEMAND 0x200 // ondemand, manage socket by init
#define SERVICE_ATTR_TIMERSTART 0x400 // Mark a service will be started by timer
#define SERVICE_ATTR_NEEDWAIT 0x800 // Mark a service will be started by timer
#define SERVICE_ATTR_SANDBOX 0x1000 // make service will enter sandbox
#define SERVICE_ATTR_ONDEMAND 0x100 // ondemand, manage socket by init
#define SERVICE_ATTR_TIMERSTART 0x200 // Mark a service will be started by timer
#define SERVICE_ATTR_NEEDWAIT 0x400 // service should execute waitpid while stopping
#define SERVICE_ATTR_SANDBOX 0x800 // make service will enter sandbox
#define MAX_SERVICE_NAME 32
#define MAX_APL_NAME 32
......
文件模式从 100755 更改为 100644
......@@ -54,7 +54,7 @@ Service *GetServiceByName(const char *servName);
cJSON *GetArrayItem(const cJSON *fileRoot, int *arrSize, const char *arrName);
int ParseOneService(const cJSON *curItem, Service *service);
void StartServiceByName(const char *serviceName, bool checkDynamic);
void StartServiceByName(const char *serviceName);
void StopServiceByName(const char *serviceName);
void StopAllServices(int flags, const char **exclude, int size,
int (*filter)(const Service *service, const char **exclude, int size));
......
文件模式从 100755 更改为 100644
......@@ -73,12 +73,15 @@ static unsigned int GetCapByString(const char *capStr)
{ "AUDIT_READ", CAP_AUDIT_READ },
};
int mapSize = (int)ARRAY_LENGTH(capStrCapNum);
int capLen = strlen("CAP_");
for (int j = 0; j < mapSize; j++) {
if (strcmp(capStr, capStrCapNum[j].capStr) == 0) {
if ((strcmp(capStr, capStrCapNum[j].capStr) == 0) ||
((strncmp(capStr, "CAP_", capLen) == 0) &&
(strcmp(capStr + capLen, capStrCapNum[j].capStr) == 0))) {
return capStrCapNum[j].CapNum;
}
}
return -1;
return CAP_LAST_CAP + 1;
}
int GetServiceCaps(const cJSON *curArrItem, Service *service)
......@@ -97,26 +100,27 @@ int GetServiceCaps(const cJSON *curArrItem, Service *service)
service->servPerm.caps = (unsigned int *)calloc(1, sizeof(unsigned int) * capsCnt);
INIT_ERROR_CHECK(service->servPerm.caps != NULL, return SERVICE_FAILURE,
"Failed to malloc for service %s", service->name);
service->servPerm.capsCnt = capsCnt;
service->servPerm.capsCnt = 0;
unsigned int caps = FULL_CAP;
for (int i = 0; i < capsCnt; ++i) { // number form
char *capStr = NULL;
cJSON *capJson = cJSON_GetArrayItem(filedJ, i);
if (cJSON_IsNumber(capJson)) { // for number
caps = (unsigned int)cJSON_GetNumberValue(capJson);
} else if (cJSON_IsString(capJson)) {
char *capStr = cJSON_GetStringValue(capJson);
capStr = cJSON_GetStringValue(capJson);
if (capStr == NULL || strlen(capStr) <= 0) { // check all errors
INIT_LOGE("service=%s, parse item[%d] as string, error.", service->name, i);
break;
}
caps = GetCapByString(capStr);
}
INIT_CHECK_RETURN_VALUE(caps >= 0, SERVICE_FAILURE);
if ((caps > CAP_LAST_CAP) && (caps != (unsigned int)FULL_CAP)) {
INIT_LOGE("service=%s, caps = %d, error.", service->name, caps);
return SERVICE_FAILURE;
INIT_LOGE("service=%s not support caps = %s caps %d", service->name, capStr, caps);
continue;
}
service->servPerm.caps[i] = (unsigned int)caps;
service->servPerm.caps[service->servPerm.capsCnt] = (unsigned int)caps;
service->servPerm.capsCnt++;
}
return 0;
}
......@@ -202,7 +202,7 @@ static void DoWait(const struct CmdArgs *ctx)
static void DoStart(const struct CmdArgs *ctx)
{
INIT_LOGV("DoStart %s", ctx->argv[0]);
StartServiceByName(ctx->argv[0], true);
StartServiceByName(ctx->argv[0]);
}
static void DoStop(const struct CmdArgs *ctx)
......@@ -226,7 +226,7 @@ static void DoReset(const struct CmdArgs *ctx)
return;
}
} else {
StartServiceByName(ctx->argv[0], false);
StartServiceByName(ctx->argv[0]);
}
return;
}
......
......@@ -229,7 +229,10 @@ static void PublishHoldFds(Service *service)
fdBuffer[pos - 1] = '\0'; // Remove last ' '
INIT_LOGI("fd buffer: [%s]", fdBuffer);
char envName[MAX_BUFFER_LEN] = {};
(void)snprintf_s(envName, MAX_BUFFER_LEN, MAX_BUFFER_LEN - 1, ENV_FD_HOLD_PREFIX"%s", service->name);
if (snprintf_s(envName, MAX_BUFFER_LEN, MAX_BUFFER_LEN - 1, ENV_FD_HOLD_PREFIX"%s", service->name) < 0) {
INIT_LOGE("snprintf_s failed err=%d", errno);
return;
}
if (setenv(envName, fdBuffer, 1) < 0) {
INIT_LOGE("Failed to set env %s", envName);
}
......@@ -353,6 +356,7 @@ int ServiceStop(Service *service)
"stop service %s pid %d failed! err %d.", service->name, service->pid, errno);
NotifyServiceChange(service, SERVICE_STOPPING);
INIT_LOGI("stop service %s, pid %d.", service->name, service->pid);
service->pid = -1;
return SERVICE_SUCCESS;
}
......@@ -394,10 +398,9 @@ static int ExecRestartCmd(Service *service)
return SERVICE_SUCCESS;
}
static void PollSocketAfresh(Service *service)
static void CheckServiceSocket(Service *service)
{
if (service->socketCfg == NULL) {
INIT_LOGE("service %s socket config is NULL!", service->name);
return;
}
ServiceSocket *tmpSock = service->socketCfg;
......@@ -451,21 +454,21 @@ void ServiceReap(Service *service)
}
if (service->attribute & SERVICE_ATTR_CRITICAL) { // critical
if (CalculateCrashTime(service, service->crashTime, service->crashCount) == false) {
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
INIT_LOGE("Critical service \" %s \" crashed %d times, rebooting system",
service->name, service->crashCount);
ServiceStop(GetServiceByName("appspawn"));
ExecReboot("reboot");
}
} else if (!(service->attribute & SERVICE_ATTR_NEED_RESTART)) {
if (CalculateCrashTime(service, service->crashTime, service->crashCount) == false) {
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
INIT_LOGE("Service name=%s, crash %d times, no more start.", service->name, service->crashCount);
return;
}
}
// service no need to restart which socket managed by init until socket message detected
if (IsOnDemandService(service)) {
PollSocketAfresh(service);
CheckServiceSocket(service);
return;
}
......@@ -570,7 +573,7 @@ static void ServiceTimerStartProcess(const TimerHandle handler, void *context)
ServiceStopTimer(service);
int ret = ServiceStart(service);
if (ret != SERVICE_SUCCESS) {
INIT_LOGE("Start service \' %s \' in timer failed");
INIT_LOGE("Start service \' %s \' in timer failed", service->name);
}
}
......
文件模式从 100755 更改为 100644
......@@ -24,7 +24,8 @@ static InitWorkspace g_initWorkspace = {0, 0, {0}, {0}, {0}};
int GenerateHashCode(const char *key)
{
int code = 0;
for (size_t i = 0; i < strlen(key); i++) {
size_t keyLen = strlen(key);
for (size_t i = 0; i < keyLen; i++) {
code += key[i] - 'A';
}
return code;
......
文件模式从 100755 更改为 100644
......@@ -584,39 +584,6 @@ static int ParseServiceFile(const cJSON *curArrItem, Service *curServ)
return ret;
}
static bool IsServiceInMainStrap(Service *curServ)
{
char *mainServiceList[] = {
"appspawn", "udevd", "samgr", "multimodalinput", "weston", "installs",
"hiview", "hilogd", "hdf_devmgr", "distributedsche", "softbus_server", "foundation"
};
unsigned int length = ARRAY_LENGTH(mainServiceList);
for (unsigned int i = 0; i < length; ++i) {
INIT_INFO_CHECK(strncmp(curServ->name, mainServiceList[i], strlen(mainServiceList[i])) != 0, return true,
"%s must be main service", curServ->name);
}
return false;
}
static int GetDynamicService(const cJSON *curArrItem, Service *curServ)
{
cJSON *item = cJSON_GetObjectItem(curArrItem, "dynamic");
if (item == NULL) {
return SERVICE_SUCCESS;
}
INIT_ERROR_CHECK(cJSON_IsBool(item), return SERVICE_FAILURE,
"Service : %s dynamic value only support bool.", curServ->name);
INIT_INFO_CHECK(cJSON_IsTrue(item), return SERVICE_SUCCESS,
"Service : %s dynamic value is false, it will be started with init.", curServ->name);
INIT_CHECK_RETURN_VALUE(!IsServiceInMainStrap(curServ), SERVICE_SUCCESS);
INIT_LOGI("%s is dynamic service", curServ->name);
curServ->attribute |= SERVICE_ATTR_DYNAMIC;
curServ->attribute |= SERVICE_ATTR_ONCE;
return SERVICE_SUCCESS;
}
static int GetServiceOnDemand(const cJSON *curArrItem, Service *curServ)
{
cJSON *item = cJSON_GetObjectItem(curArrItem, "ondemand");
......@@ -627,7 +594,7 @@ static int GetServiceOnDemand(const cJSON *curArrItem, Service *curServ)
INIT_ERROR_CHECK(cJSON_IsBool(item), return SERVICE_FAILURE,
"Service : %s ondemand value only support bool.", curServ->name);
INIT_INFO_CHECK(cJSON_IsTrue(item), return SERVICE_SUCCESS,
"Service : %s ondemand value is false, it will be manage socket by itself", curServ->name);
"Service : %s ondemand value is false, it should be pulled up by init", curServ->name);
if (curServ->attribute & SERVICE_ATTR_CRITICAL) {
INIT_LOGE("Service : %s is invalid which has both critical and ondemand attribute", curServ->name);
return SERVICE_FAILURE;
......@@ -641,7 +608,7 @@ static int CheckServiceKeyName(const cJSON *curService)
{
char *cfgServiceKeyList[] = {
"name", "path", "uid", "gid", "once", "importance", "caps", "disabled",
"writepid", "critical", "socket", "console", "dynamic", "file", "ondemand",
"writepid", "critical", "socket", "console", "file", "ondemand",
"d-caps", "apl", "jobs", "start-mode", "end-mode", "cpucore", "secon", "sandbox"
};
INIT_CHECK_RETURN_VALUE(curService != NULL, SERVICE_FAILURE);
......@@ -847,8 +814,6 @@ int ParseOneService(const cJSON *curItem, Service *service)
INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get sandbox for service %s", service->name);
ret = GetServiceCaps(curItem, service);
INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get caps for service %s", service->name);
ret = GetDynamicService(curItem, service);
INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get dynamic flag for service %s", service->name);
ret = GetServiceOnDemand(curItem, service);
INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get ondemand flag for service %s", service->name);
ret = GetServiceMode(service, curItem);
......@@ -945,7 +910,7 @@ static Service *GetServiceByExtServName(const char *fullServName)
return service;
}
void StartServiceByName(const char *servName, bool checkDynamic)
void StartServiceByName(const char *servName)
{
INIT_LOGE("StartServiceByName Service %s", servName);
Service *service = GetServiceByName(servName);
......@@ -954,11 +919,6 @@ void StartServiceByName(const char *servName, bool checkDynamic)
}
INIT_ERROR_CHECK(service != NULL, return, "Cannot find service %s.", servName);
if (checkDynamic && (service->attribute & SERVICE_ATTR_DYNAMIC)) {
INIT_LOGI("%s is dynamic service.", servName);
NotifyServiceChange(service, SERVICE_STOPPED);
return;
}
if (ServiceStart(service) != SERVICE_SUCCESS) {
INIT_LOGE("Service %s start failed!", servName);
}
......@@ -1049,12 +1009,6 @@ void StartAllServices(int startMode)
node = GetNextGroupNode(NODE_TYPE_SERVICES, node);
continue;
}
if (service->attribute & SERVICE_ATTR_DYNAMIC) {
INIT_LOGI("%s is dynamic service.", service->name);
NotifyServiceChange(service, SERVICE_STOPPED);
node = GetNextGroupNode(NODE_TYPE_SERVICES, node);
continue;
}
if (ServiceStart(service) != SERVICE_SUCCESS) {
INIT_LOGE("Service %s start failed!", service->name);
}
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -31,16 +31,16 @@ int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, u
static void DoExec(const struct CmdArgs *ctx)
{
// format: exec /xxx/xxx/xxx xxx
if (ctx == NULL || ctx->argv[0] == NULL) {
INIT_LOGE("DoExec: invalid arguments");
return;
}
pid_t pid = fork();
if (pid < 0) {
INIT_LOGE("DoExec: failed to fork child process to exec \"%s\"", ctx->argv[0]);
return;
}
if (pid == 0) {
if (ctx == NULL || ctx->argv[0] == NULL) {
INIT_LOGE("DoExec: invalid arguments");
_exit(0x7f);
}
int ret = execve(ctx->argv[0], ctx->argv, NULL);
if (ret == -1) {
INIT_LOGE("DoExec: execute \"%s\" failed: %d.", ctx->argv[0], errno);
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -67,16 +67,20 @@ int ServiceExec(const Service *service)
INIT_ERROR_CHECK(service != NULL && service->pathArgs.count > 0,
return SERVICE_FAILURE, "Exec service failed! null ptr.");
INIT_LOGI("service->name is %s ", service->name);
char *env[] = { "LD_LIBRARY_PATH=/storage/app/libs", NULL, NULL };
char sockEnv[MAX_ENV_NAME] = {0};
char sockEnvName[MAX_ENV_NAME] = {0};
char sockEnvValue[MAX_ENV_NAME] = {0};
if (service->socketCfg != NULL) {
INIT_ERROR_CHECK(snprintf_s(sockEnv, sizeof(sockEnv), sizeof(sockEnv) - 1, "OHOS_SOCKET_%s=%d",
service->socketCfg->name, service->socketCfg->sockFd) != -1,
return SERVICE_FAILURE, "format socket env failed!");
env[1] = sockEnv;
INIT_ERROR_CHECK(snprintf_s(sockEnvName, MAX_ENV_NAME, MAX_ENV_NAME - 1, "OHOS_SOCKET_%s",
service->socketCfg->name) != -1,
return SERVICE_FAILURE, "format socket env name failed!");
INIT_ERROR_CHECK(snprintf_s(sockEnvValue, MAX_ENV_NAME, MAX_ENV_NAME - 1, "%d",
service->socketCfg->sockFd) != -1,
return SERVICE_FAILURE, "format socket env value failed!");
}
if (execve(service->pathArgs.argv[0], service->pathArgs.argv, env) != 0) {
INIT_LOGE("service %s execve failed! err %d.", service->name, errno);
INIT_CHECK_ONLY_ELOG(setenv(sockEnvName, sockEnvValue, 1) == 0, "DoExport: set %s with %s failed: %d",
sockEnvName, sockEnvValue, errno);
if (execv(service->pathArgs.argv[0], service->pathArgs.argv) != 0) {
INIT_LOGE("service %s execv failed! err %d.", service->name, errno);
return errno;
}
return SERVICE_SUCCESS;
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
# Copyright (c) 2021 Huawei Device 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
#
# 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.
import("//build/ohos.gni")
import("//build/ohos/native_stub/native_stub.gni")
config("libinit_plugin_engine_config") {
include_dirs =
[ "//base/startup/init_lite/services/init/plugin_engine/include" ]
}
ohos_native_stub_library("libinit_plugin_engine") {
output_extension = "so"
public_configs = [ ":libinit_plugin_engine_config" ]
stub_description_file = "./stub/libinit.stub.json"
}
ohos_native_stub_versionscript("libinit_stub_versionscript") {
stub_description_file = "./stub/libinit.stub.json"
}
ohos_native_stub_library("libinit_stub_empty") {
output_extension = "so"
stub_description_file = "./stub/libinit.stub.empty.json"
part_name = "init"
install_enable = true
symlink_target_name = [ "libinit_plugin_engine.so" ]
}
......@@ -26,17 +26,18 @@ extern "C" {
#define PLUGIN_CONSTRUCTOR(void) static void _init(void) __attribute__((constructor)); static void _init(void)
#define PLUGIN_DESTRUCTOR(void) static void _destroy(void) __attribute__((destructor)); static void _destroy(void)
typedef struct {
int (*pluginRegister)(const char *name, const char *config, int (*pluginInit)(void), void (*pluginExit)(void));
int (*addCmdExecutor)(const char *cmdName,
int (*CmdExecutor)(int id, const char *name, int argc, const char **argv));
void (*removeCmdExecutor)(const char *cmdName, int id);
int (*systemWriteParam)(const char *name, const char *value);
int (*systemReadParam)(const char *name, char *value, unsigned int *len);
int (*securityLabelSet)(const char *name, const char *label, const char *paraType);
} PluginInterface;
PluginInterface *GetPluginInterface(void);
int SystemWriteParam(const char *name, const char *value);
int SystemReadParam(const char *name, char *value, unsigned int *len);
typedef int (*CmdExecutor)(int id, const char *name, int argc, const char **argv);
int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd);
void RemoveCmdExecutor(const char *cmdName, int id);
int PluginRegister(const char *name, const char *config, int (*pluginInit)(void), void (*pluginExit)(void));
#ifdef __cplusplus
#if __cplusplus
}
......
[
{ "name": "SystemWriteParam" },
{ "name": "SystemReadParam" },
{ "name": "AddCmdExecutor" },
{ "name": "RemoveCmdExecutor" },
{ "name": "PluginRegister" }
]
......@@ -50,16 +50,13 @@ void MountBasicFs(void)
if (mount("tmpfs", "/storage", "tmpfs", MS_NOEXEC | MS_NODEV| MS_NOSUID, "mode=0755") != 0) {
INIT_LOGE("Mount storage failed. %s", strerror(errno));
}
if (mount("none", "/config", "configfs", MS_NOEXEC | MS_NODEV| MS_NOSUID, "mode=0755") != 0) {
INIT_LOGE("Mount configfs failed. %s", strerror(errno));
}
if (mkdir("/dev/pts", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) {
INIT_LOGE("mkdir /dev/pts failed. %s", strerror(errno));
}
if (mount("devpts", "/dev/pts", "devpts", 0, NULL) != 0) {
INIT_LOGE("Mount devpts failed. %s", strerror(errno));
}
if (mount("proc", "/proc", "proc", 0, "hidepid=2") != 0) {
if (mount("proc", "/proc", "proc", 0, "gid=3009,hidepid=2") != 0) {
INIT_LOGE("Mount procfs failed. %s", strerror(errno));
}
if (mount("sysfs", "/sys", "sysfs", 0, NULL) != 0) {
......
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册