提交 c8b1b89f 编写于 作者: S sun_fan

init: fix param

Signed-off-by: Nsun_fan <sun_fan1@hoperun.com>
上级 b06d198c
...@@ -221,9 +221,9 @@ void WatcherManager::RunLoop() ...@@ -221,9 +221,9 @@ void WatcherManager::RunLoop()
continue; continue;
} }
fd = GetServerFd(true); fd = GetServerFd(true);
PARAM_LOGE("Failed to recv msg from server %d errno %d", recvLen, errno); PARAM_LOGE("Failed to recv msg from server errno %d", errno);
} }
PARAM_LOGD("Recv msg from server %d", recvLen); PARAM_LOGD("Recv msg from server");
if (recvLen >= (ssize_t)sizeof(ParamMessage)) { if (recvLen >= (ssize_t)sizeof(ParamMessage)) {
ProcessWatcherMessage(buffer, recvLen); ProcessWatcherMessage(buffer, recvLen);
} }
......
...@@ -484,6 +484,27 @@ static void DoChown(const char *cmdContent, int maxArg) ...@@ -484,6 +484,27 @@ static void DoChown(const char *cmdContent, int maxArg)
return; return;
} }
static int DoPathChown(const char *path, const char *uid, const char *gid)
{
if (path == NULL || uid == NULL || gid == NULL) {
return -1;
}
uid_t user = DecodeUid(uid);
gid_t group = DecodeUid(gid);
if (user == (uid_t) -1 || group == (uid_t)-1) {
INIT_LOGE("Change path owner with invalid user/group");
return -1;
}
int rc = chown(path, user, group);
if (rc < 0) {
INIT_LOGE("Change path \" %s \" ower to user: %s group: %s failed",
path, uid, gid);
return -1;
}
return 0;
}
static void DoMkDir(const char *cmdContent, int maxArg) static void DoMkDir(const char *cmdContent, int maxArg)
{ {
// mkdir support format: // mkdir support format:
...@@ -513,26 +534,11 @@ static void DoMkDir(const char *cmdContent, int maxArg) ...@@ -513,26 +534,11 @@ static void DoMkDir(const char *cmdContent, int maxArg)
INIT_LOGE("Change path \" %s \" mode to %04o failed", ctx->argv[0], mode); INIT_LOGE("Change path \" %s \" mode to %04o failed", ctx->argv[0], mode);
break; break;
} }
if (ctx->argv[++index] != NULL) { // mkdir with user and group index = index + 1;
if (ctx->argv[index + 1] != NULL) { if ((ctx->argv[index] != NULL) && (ctx->argv[index + 1] != NULL)) {
uid_t user = DecodeUid(ctx->argv[index]); rc = DoPathChown(ctx->argv[0], ctx->argv[index], ctx->argv[index + 1]);
gid_t group = DecodeUid(ctx->argv[index + 1]); } else {
if (user == (uid_t) -1 || group == (uid_t)-1) { rc = -1;
INIT_LOGE("Change path owner with invalid user/group");
rc = -1;
break;
}
rc = chown(ctx->argv[0], user, group);
if (rc < 0) {
INIT_LOGE("Change path \" %s \" ower to user: %s group: %s failed",
ctx->argv[0], ctx->argv[index], ctx->argv[index + 1]);
break;
}
} else {
rc = -1; // Miss group
break;
}
} }
} }
if (rc < 0) { if (rc < 0) {
......
...@@ -185,7 +185,6 @@ void DoReboot(const char *value) ...@@ -185,7 +185,6 @@ void DoReboot(const char *value)
return; return;
} }
} }
StopAllServicesBeforeReboot(); StopAllServicesBeforeReboot();
sync(); sync();
if (GetMountStatusForMountPoint("/vendor") != 0 && umount("/vendor") != 0) { if (GetMountStatusForMountPoint("/vendor") != 0 && umount("/vendor") != 0) {
...@@ -194,9 +193,6 @@ void DoReboot(const char *value) ...@@ -194,9 +193,6 @@ void DoReboot(const char *value)
if (GetMountStatusForMountPoint("/data") != 0 && umount("/data") != 0) { if (GetMountStatusForMountPoint("/data") != 0 && umount("/data") != 0) {
INIT_LOGE("DoReboot umount data failed! errno = %d.", errno); INIT_LOGE("DoReboot umount data failed! errno = %d.", errno);
} }
INIT_LOGI("DoReboot value = %s valueData %s", value, valueData);
// "shutdown"
int ret = 0; int ret = 0;
if (valueData == NULL) { if (valueData == NULL) {
ret = reboot(RB_AUTOBOOT); ret = reboot(RB_AUTOBOOT);
...@@ -209,6 +205,6 @@ void DoReboot(const char *value) ...@@ -209,6 +205,6 @@ void DoReboot(const char *value)
} else if (strncmp(valueData, "flashing", strlen("flashing")) == 0) { } else if (strncmp(valueData, "flashing", strlen("flashing")) == 0) {
ret = CheckAndRebootToUpdater(valueData, "flashing", "flashing:", "boot_flashing"); ret = CheckAndRebootToUpdater(valueData, "flashing", "flashing:", "boot_flashing");
} }
INIT_LOGE("DoReboot value = %s %s.", value, (ret == 0) ? "success" : "fail"); INIT_LOGI("DoReboot value = %s %s.", value, (ret == 0) ? "success" : "fail");
return; return;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册