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

Signed-off-by: xionglei <xionglei6@huawei.com>
This commit is contained in:
熊磊 2022-03-29 11:29:51 +00:00 committed by Gitee
commit baeeb7202e
210 changed files with 187 additions and 55 deletions

0
device_info/BUILD.gn Executable file → Normal file
View File

3
device_info/device_info_kits.cpp Executable file → Normal file
View File

@ -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;

0
device_info/device_info_kits.h Executable file → Normal file
View File

0
device_info/device_info_proxy.cpp Executable file → Normal file
View File

0
device_info/device_info_proxy.h Executable file → Normal file
View File

4
device_info/device_info_stub.cpp Executable file → Normal file
View File

@ -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;
}

0
device_info/device_info_stub.h Executable file → Normal file
View File

0
device_info/idevice_info.h Executable file → Normal file
View File

0
interfaces/innerkits/BUILD.gn Executable file → Normal file
View File

0
interfaces/innerkits/file/init_file.c Executable file → Normal file
View File

0
interfaces/innerkits/fs_manager/fstab.c Executable file → Normal file
View File

0
interfaces/innerkits/include/fs_manager/fs_manager.h Executable file → Normal file
View File

0
interfaces/innerkits/include/init_file.h Executable file → Normal file
View File

0
interfaces/innerkits/include/init_plugin.h Executable file → Normal file
View File

0
interfaces/innerkits/include/init_reboot.h Executable file → Normal file
View File

0
interfaces/innerkits/include/init_socket.h Executable file → Normal file
View File

0
interfaces/innerkits/plugin/BUILD.gn Executable file → Normal file
View File

0
interfaces/innerkits/plugin/init_plugin.c Executable file → Normal file
View File

0
interfaces/innerkits/reboot/init_reboot_innerkits.c Executable file → Normal file
View File

0
interfaces/innerkits/sandbox/BUILD.gn Executable file → Normal file
View File

View File

@ -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) {

View File

@ -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"
}
]
}
}

View File

@ -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;
}

View File

@ -50,6 +50,5 @@ if (defined(ohos_lite)) {
"system",
"updater",
]
relative_install_dir = "platform-vndk"
}
}

0
interfaces/innerkits/socket/init_socket.c Executable file → Normal file
View File

0
interfaces/kits/BUILD.gn Executable file → Normal file
View File

0
interfaces/kits/include/syscap_ndk.h Executable file → Normal file
View File

0
interfaces/kits/init_sync.h Executable file → Normal file
View File

0
services/BUILD.gn Executable file → Normal file
View File

0
services/begetctl/BUILD.gn Executable file → Normal file
View File

0
services/begetctl/begetctl.h Executable file → Normal file
View File

0
services/begetctl/bootchart_cmd.c Executable file → Normal file
View File

0
services/begetctl/init_cmd_reboot.c Executable file → Normal file
View File

4
services/begetctl/main.c Executable file → Normal file
View File

@ -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);

6
services/begetctl/misc_daemon.cpp Executable file → Normal file
View File

@ -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);

1
services/begetctl/param_cmd.c Executable file → Normal file
View File

@ -91,6 +91,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;

0
services/begetctl/sandbox.cpp Executable file → Normal file
View File

0
services/begetctl/service_control.c Executable file → Normal file
View File

0
services/begetctl/shell/shell.h Executable file → Normal file
View File

0
services/begetctl/shell/shell_bas.c Executable file → Normal file
View File

0
services/begetctl/shell/shell_bas.h Executable file → Normal file
View File

0
services/begetctl/shell/shell_main.c Executable file → Normal file
View File

0
services/begetctl/shell/shell_utils.h Executable file → Normal file
View File

View File

@ -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,12 +17,13 @@ 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:
shell:x:2000:
cache:x:2001:
@ -32,5 +34,34 @@ 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:
dms:x:5522:
sensor:x:6688:
msdp:x:6699:
misc:x:9998:
app:x:10000:

View File

@ -245,9 +245,9 @@
"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/wifi 0770 system system",
"mkdir /data/misc/wifi/sockets 0770 system system",
"mkdir /data/misc/wifi/wpa_supplicant 0660 system system",
"mkdir /data/misc/ethernet 0770 system system",
"mkdir /data/misc/dhcp 0770 dhcp dhcp",
"mkdir /data/misc/user 0771 root root",
@ -255,7 +255,7 @@
"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/audio 0700 audio audio",
"mkdir /data/misc/cameraserver 0700 cameraserver cameraserver",
"mkdir /data/misc/vold 0700 root root",
"mkdir /data/misc/boottrace 0771 system shell",
@ -313,7 +313,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",

View File

@ -245,7 +245,7 @@
"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/audio 0700 audio audio",
"mkdir /data/misc/cameraserver 0700 cameraserver cameraserver",
"mkdir /data/misc/vold 0700 root root",
"mkdir /data/misc/boottrace 0771 system shell",
@ -303,7 +303,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",

View File

@ -55,7 +55,7 @@ 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
const.ohos.version.security_patch=2022-03-30
# OHOS_DISPLAY_VERSION[] = {"OpenHarmony 3.1.5.2"}
const.product.software.version=OpenHarmony 3.1.5.2
# OHOS_INCREMENTAL_VERSION[] = {"default"}

View File

@ -26,7 +26,7 @@ const.debuggable root:root:0777
persist.sys.usb.config root:root:0777
# default forbit other user to start service
ohos.servicectrl. system:root:0770
ohos.servicectrl. system:root:0777
test.permission. root:root:0770
test.permission.read. root:root:0774
test.permission.write. root:root:0772

View File

@ -17,12 +17,13 @@ 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
shell:x:2000:2000:::/bin/false
cache:x:2001:2001:::/bin/false
@ -33,6 +34,34 @@ 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
dms:x:5522:5522:::/bin/false
sensor:x:6688:6688:::/bin/false
msdp:x:6699:6699:::/bin/false
misc:x:9998:9998:::/bin/false
app:x:10000:10000:::/bin/false

0
services/include/init_hashmap.h Executable file → Normal file
View File

0
services/include/init_utils.h Executable file → Normal file
View File

0
services/include/list.h Executable file → Normal file
View File

0
services/include/param/init_param.h Executable file → Normal file
View File

0
services/include/param/param.h Executable file → Normal file
View File

1
services/include/param/sys_param.h Executable file → Normal file
View File

@ -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
}

0
services/include/switch_root.h Executable file → Normal file
View File

0
services/init/adapter/init_adapter.c Executable file → Normal file
View File

0
services/init/include/device.h Executable file → Normal file
View File

0
services/init/include/init.h Executable file → Normal file
View File

0
services/init/include/init_adapter.h Executable file → Normal file
View File

0
services/init/include/init_cmds.h Executable file → Normal file
View File

0
services/init/include/init_group_manager.h Executable file → Normal file
View File

0
services/init/include/init_jobs_internal.h Executable file → Normal file
View File

0
services/init/include/init_plugin_manager.h Executable file → Normal file
View File

0
services/init/include/init_service.h Executable file → Normal file
View File

0
services/init/include/init_service_file.h Executable file → Normal file
View File

0
services/init/include/init_service_manager.h Executable file → Normal file
View File

0
services/init/include/init_service_socket.h Executable file → Normal file
View File

0
services/init/init_capability.c Executable file → Normal file
View File

0
services/init/init_common_cmds.c Executable file → Normal file
View File

7
services/init/init_common_service.c Executable file → Normal file
View File

@ -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);
}
@ -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);
}
}

0
services/init/init_config.c Executable file → Normal file
View File

3
services/init/init_group_manager.c Executable file → Normal file
View File

@ -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;

0
services/init/init_service_file.c Executable file → Normal file
View File

0
services/init/init_service_manager.c Executable file → Normal file
View File

0
services/init/init_service_socket.c Executable file → Normal file
View File

0
services/init/lite/init.c Executable file → Normal file
View File

0
services/init/lite/init_cmds.c Executable file → Normal file
View File

0
services/init/lite/init_jobs.c Executable file → Normal file
View File

0
services/init/lite/init_reboot.c Executable file → Normal file
View File

0
services/init/lite/init_service.c Executable file → Normal file
View File

0
services/init/lite/init_signal_handler.c Executable file → Normal file
View File

0
services/init/main.c Executable file → Normal file
View File

0
services/init/standard/device.c Executable file → Normal file
View File

View File

@ -62,12 +62,17 @@ static int HandlerHoldFds(Service *service, int *fds, size_t fdCount, const char
static void SendErrorInfo(int sock, const char *errInfo, const char *serviceName)
{
int ret = 0;
char errBuffer[MAX_FD_HOLDER_BUFFER] = {};
if (UNLIKELY(errInfo == NULL)) { // Should not happen.
char *defaultError = "Unknonw error";
(void)strncpy_s(errBuffer, MAX_FD_HOLDER_BUFFER, defaultError, strlen(defaultError));
ret = strncpy_s(errBuffer, MAX_FD_HOLDER_BUFFER, defaultError, strlen(defaultError));
} else {
(void)strncpy_s(errBuffer, MAX_FD_HOLDER_BUFFER, errInfo, strlen(errInfo));
ret = strncpy_s(errBuffer, MAX_FD_HOLDER_BUFFER, errInfo, strlen(errInfo));
}
if (ret != 0) {
INIT_LOGE("Failed to copy, err = %d", errno);
return;
}
struct iovec iovec = {
@ -96,7 +101,10 @@ static void SendFdsInfo(int sock, Service *service)
return;
}
char sendBuffer[MAX_FD_HOLDER_BUFFER] = {};
(void)strncpy_s(sendBuffer, MAX_FD_HOLDER_BUFFER, "send done", strlen("send done"));
if (strncpy_s(sendBuffer, MAX_FD_HOLDER_BUFFER, "send done", strlen("send done")) != 0) {
INIT_LOGE("Failed to copy, err = %d", errno);
return;
}
struct iovec iovec = {
.iov_base = sendBuffer,
.iov_len = strlen(sendBuffer),
@ -134,7 +142,7 @@ static void HandlerGetFds(int sock, Service *service)
}
if (service->fds == NULL || service->fdCount == 0) {
INIT_LOGE("Service \' %s \' does not have any held fds");
INIT_LOGE("Service \' %s \' does not have any held fds", service->name);
errorInfo = "Service without any fds";
}

0
services/init/standard/init.c Executable file → Normal file
View File

0
services/init/standard/init_cmds.c Executable file → Normal file
View File

0
services/init/standard/init_jobs.c Executable file → Normal file
View File

0
services/init/standard/init_mount.c Executable file → Normal file
View File

0
services/init/standard/init_mount.h Executable file → Normal file
View File

0
services/init/standard/init_plugin_manager.c Executable file → Normal file
View File

0
services/init/standard/init_reboot.c Executable file → Normal file
View File

0
services/init/standard/init_service.c Executable file → Normal file
View File

0
services/init/standard/init_signal_handler.c Executable file → Normal file
View File

0
services/init/standard/switch_root.c Executable file → Normal file
View File

View File

@ -43,7 +43,6 @@ if (defined(ohos_lite)) {
"updater",
]
external_deps = [ "hilog_native:libhilog_base" ]
relative_install_dir = "platform-vndk"
install_enable = true
part_name = "init"
subsystem_name = "startup"

0
services/log/init_log.c Executable file → Normal file
View File

0
services/log/init_log.h Executable file → Normal file
View File

0
services/loopevent/BUILD.gn Executable file → Normal file
View File

0
services/loopevent/include/loop_event.h Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More