Match-id-245bc76da887818fe1357759f0f0645039ea7ff1

This commit is contained in:
BianTanggui
2020-07-25 10:40:27 +08:00
parent d89d13214f
commit af7ffd82c0
6 changed files with 56 additions and 56 deletions

View File

@@ -135,26 +135,26 @@ int DoPrepare(const struct CmdArgs *args, struct ParsedConfig *config)
ret = GetNsPath(args->pid, "mnt", config->containerNsPath, BUF_SIZE);
if (ret < 0) {
LogError("error: failed to get container mnt ns path: pid(%d)\n", args->pid);
LogError("error: failed to get container mnt ns path: pid(%d).", args->pid);
return -1;
}
ret = GetCgroupPath(args, config->cgroupPath, BUF_SIZE);
if (ret < 0) {
LogError("error: failed to get cgroup path\n");
LogError("error: failed to get cgroup path.");
return -1;
}
char originNsPath[BUF_SIZE] = {0};
ret = GetSelfNsPath("mnt", originNsPath, BUF_SIZE);
if (ret < 0) {
LogError("error: failed to get self ns path\n");
LogError("error: failed to get self ns path.");
return -1;
}
config->originNsFd = open((const char *)originNsPath, O_RDONLY); // proc接口非外部输入
if (config->originNsFd < 0) {
LogError("error: failed to get self ns fd: %s\n", originNsPath);
LogError("error: failed to get self ns fd: %s.", originNsPath);
return -1;
}
@@ -174,28 +174,28 @@ int SetupContainer(struct CmdArgs *args)
ret = DoPrepare(args, &config);
if (ret < 0) {
LogError("error: failed to prepare nesessary config\n");
LogError("error: failed to prepare nesessary config.");
return -1;
}
// enter container's mount namespace
ret = EnterNsByPath((const char *)config.containerNsPath, CLONE_NEWNS);
if (ret < 0) {
LogError("error: failed to set to container ns: %s\n", config.containerNsPath);
LogError("error: failed to set to container ns: %s.", config.containerNsPath);
close(config.originNsFd);
return -1;
}
ret = DoMounting(args);
if (ret < 0) {
LogError("error: failed to do mounting\n");
LogError("error: failed to do mounting.");
close(config.originNsFd);
return -1;
}
ret = SetupCgroup(args, (const char *)config.cgroupPath);
if (ret < 0) {
LogError("error: failed to set up cgroup\n");
LogError("error: failed to set up cgroup.");
close(config.originNsFd);
return -1;
}
@@ -203,7 +203,7 @@ int SetupContainer(struct CmdArgs *args)
// back to original namespace
ret = EnterNsByFd(config.originNsFd, CLONE_NEWNS);
if (ret < 0) {
LogError("error: failed to set ns back\n");
LogError("error: failed to set ns back.");
close(config.originNsFd);
return -1;
}
@@ -228,7 +228,7 @@ int Process(int argc, char **argv)
}
if (!IsCmdArgsValid(&args)) {
LogError("error: information not completed or valid.\n");
LogError("error: information not completed or valid.");
return -1;
}