Signed-off-by: 2xsec <dh48.jeong@samsung.com>
if (ret == 0)
(void)strlcpy((char*)arg_start, title, len);
else
if (ret == 0)
(void)strlcpy((char*)arg_start, title, len);
else
- SYSINFO("setting cmdline failed");
+ SYSWARN("Failed to set cmdline");
{
struct dirent *direntp;
DIR *dir;
{
struct dirent *direntp;
DIR *dir;
char pathname[PATH_MAX];
bool hadexclude = false;
dir = opendir(dirname);
if (!dir) {
char pathname[PATH_MAX];
bool hadexclude = false;
dir = opendir(dirname);
if (!dir) {
- ERROR("failed to open %s", dirname);
+ ERROR("Failed to open \"%s\"", dirname);
rc = snprintf(pathname, PATH_MAX, "%s/%s", dirname, direntp->d_name);
if (rc < 0 || rc >= PATH_MAX) {
rc = snprintf(pathname, PATH_MAX, "%s/%s", dirname, direntp->d_name);
if (rc < 0 || rc >= PATH_MAX) {
- ERROR("pathname too long");
+ ERROR("The name of path is too long");
if (ret < 0) {
switch(errno) {
case ENOTEMPTY:
if (ret < 0) {
switch(errno) {
case ENOTEMPTY:
- INFO("Not deleting snapshot %s", pathname);
+ INFO("Not deleting snapshot \"%s\"", pathname);
hadexclude = true;
break;
case ENOTDIR:
ret = unlink(pathname);
if (ret)
hadexclude = true;
break;
case ENOTDIR:
ret = unlink(pathname);
if (ret)
- INFO("Failed to remove %s", pathname);
+ INFO("Failed to remove \"%s\"", pathname);
- SYSERROR("Failed to rmdir %s", pathname);
+ SYSERROR("Failed to rmdir \"%s\"", pathname);
continue;
}
ret = lstat(pathname, &mystat);
if (ret) {
continue;
}
ret = lstat(pathname, &mystat);
if (ret) {
- ERROR("Failed to stat %s", pathname);
+ SYSERROR("Failed to stat \"%s\"", pathname);
/* TODO should we be checking /proc/self/mountinfo for
* pathname and not doing this if found? */
if (btrfs_try_remove_subvol(pathname))
/* TODO should we be checking /proc/self/mountinfo for
* pathname and not doing this if found? */
if (btrfs_try_remove_subvol(pathname))
- INFO("Removed btrfs subvolume at %s\n", pathname);
+ INFO("Removed btrfs subvolume at \"%s\"", pathname);
failed=1;
} else {
if (unlink(pathname) < 0) {
failed=1;
} else {
if (unlink(pathname) < 0) {
- SYSERROR("Failed to delete %s", pathname);
+ SYSERROR("Failed to delete \"%s\"", pathname);
failed=1;
}
}
}
if (rmdir(dirname) < 0 && !btrfs_try_remove_subvol(dirname) && !hadexclude) {
failed=1;
}
}
}
if (rmdir(dirname) < 0 && !btrfs_try_remove_subvol(dirname) && !hadexclude) {
- ERROR("Failed to delete %s", dirname);
+ SYSERROR("Failed to delete \"%s\"", dirname);
failed=1;
}
ret = closedir(dir);
if (ret) {
failed=1;
}
ret = closedir(dir);
if (ret) {
- ERROR("Failed to close directory %s", dirname);
+ SYSERROR("Failed to close directory \"%s\"", dirname);
if (errno == ENOENT)
return 0;
if (errno == ENOENT)
return 0;
- ERROR("Failed to stat %s", path);
+ SYSERROR("Failed to stat \"%s\"", path);
{
const char *tmp = dir;
const char *orig = dir;
{
const char *tmp = dir;
const char *orig = dir;
do {
int ret;
char *makeme;
do {
int ret;
char *makeme;
free(makeme);
return -1;
}
free(makeme);
return -1;
}
} while (tmp != dir);
return 0;
} while (tmp != dir);
return 0;
- INFO("XDG_RUNTIME_DIR isn't set in the environment.");
+ INFO("XDG_RUNTIME_DIR isn't set in the environment");
homedir = getenv("HOME");
if (!homedir) {
homedir = getenv("HOME");
if (!homedir) {
- ERROR("HOME isn't set in the environment.");
+ ERROR("HOME isn't set in the environment");
f = fopen_cloexec(fnam, "r");
if (!f) {
f = fopen_cloexec(fnam, "r");
if (!f) {
- SYSERROR("Error opening template");
+ SYSERROR("Failed to open template \"%s\"", fnam);
return -1;
}
if (fseek(f, 0, SEEK_END) < 0) {
return -1;
}
if (fseek(f, 0, SEEK_END) < 0) {
- SYSERROR("Error seeking to end of template");
+ SYSERROR("Failed to seek to end of template");
fclose(f);
return -1;
}
if ((flen = ftell(f)) < 0) {
fclose(f);
return -1;
}
if ((flen = ftell(f)) < 0) {
- SYSERROR("Error telling size of template");
+ SYSERROR("Failed to tell size of template");
fclose(f);
return -1;
}
if (fseek(f, 0, SEEK_SET) < 0) {
fclose(f);
return -1;
}
if (fseek(f, 0, SEEK_SET) < 0) {
- SYSERROR("Error seeking to start of template");
+ SYSERROR("Failed to seek to start of template");
}
if (fread(buf, 1, flen, f) != flen) {
}
if (fread(buf, 1, flen, f) != flen) {
- SYSERROR("Failure reading template");
+ SYSERROR("Failed to read template");
free(buf);
fclose(f);
return -1;
}
if (fclose(f) < 0) {
free(buf);
fclose(f);
return -1;
}
if (fclose(f) < 0) {
- SYSERROR("Failre closing template");
+ SYSERROR("Failed to close template");
int randseed(bool srand_it)
{
int randseed(bool srand_it)
{
- srand pre-seed function based on /dev/urandom
- */
+ * srand pre-seed function based on /dev/urandom
+ */
unsigned int seed = time(NULL) + getpid();
unsigned int seed = time(NULL) + getpid();
f = fopen("/dev/urandom", "r");
if (f) {
int ret = fread(&seed, sizeof(seed), 1, f);
if (ret != 1)
f = fopen("/dev/urandom", "r");
if (f) {
int ret = fread(&seed, sizeof(seed), 1, f);
if (ret != 1)
- SYSDEBUG("unable to fread /dev/urandom, fallback to time+pid rand seed");
+ SYSDEBUG("Unable to fread /dev/urandom, fallback to time+pid rand seed");
char *line = NULL;
size_t sz = 0;
uid_t nsid, hostid, range;
char *line = NULL;
size_t sz = 0;
uid_t nsid, hostid, range;
- FILE *f = fopen("/proc/self/uid_map", "r");
- if (!f)
+ FILE *f;
+
+ f = fopen("/proc/self/uid_map", "r");
+ if (!f) {
+ SYSERROR("Failed to open uid_map");
while (getline(&line, &sz, f) != -1) {
if (sscanf(line, "%u %u %u", &nsid, &hostid, &range) != 3)
while (getline(&line, &sz, f) != -1) {
if (sscanf(line, "%u %u %u", &nsid, &hostid, &range) != 3)
char *line = NULL;
size_t sz = 0;
gid_t nsid, hostid, range;
char *line = NULL;
size_t sz = 0;
gid_t nsid, hostid, range;
- FILE *f = fopen("/proc/self/gid_map", "r");
- if (!f)
+ FILE *f;
+
+ f = fopen("/proc/self/gid_map", "r");
+ if (!f) {
+ SYSERROR("Failed to open gid_map");
while (getline(&line, &sz, f) != -1) {
if (sscanf(line, "%u %u %u", &nsid, &hostid, &range) != 3)
while (getline(&line, &sz, f) != -1) {
if (sscanf(line, "%u %u %u", &nsid, &hostid, &range) != 3)
- for(bp = buf; bp < (unsigned char *)buf + len; bp++)
- {
+ for(bp = buf; bp < (unsigned char *)buf + len; bp++) {
/* xor the bottom with the current octet */
hval ^= (uint64_t)*bp;
/* xor the bottom with the current octet */
hval ^= (uint64_t)*bp;
{
if (is_shared_mountpoint("/"))
return 1;
{
if (is_shared_mountpoint("/"))
return 1;
fd = open(nspath, O_RDONLY);
if (fd < 0) {
fd = open(nspath, O_RDONLY);
if (fd < 0) {
- SYSERROR("Failed to open %s", nspath);
+ SYSERROR("Failed to open \"%s\"", nspath);
return false;
}
ret = setns(fd, 0);
if (ret) {
return false;
}
ret = setns(fd, 0);
if (ret) {
- SYSERROR("Failed to set process %d to %s of %d.", pid, ns, fd);
+ SYSERROR("Failed to set process %d to \"%s\" of %d.", pid, ns, fd);
close(fd);
return false;
}
close(fd);
return false;
}
int i;
f = fopen("/proc/self/mountinfo", "r");
int i;
f = fopen("/proc/self/mountinfo", "r");
+ if (!f) {
+ SYSERROR("Failed to open mountinfo");
while (getline(&line, &len, f) != -1) {
for (p = line, i = 0; p && i < 4; i++)
while (getline(&line, &len, f) != -1) {
for (p = line, i = 0; p && i < 4; i++)
retv = on_path("init.lxc", rootfs);
retv = on_path("init.lxc", rootfs);
if (unsetenv("PATH"))
SYSERROR("Failed to unsetenv");
if (unsetenv("PATH"))
SYSERROR("Failed to unsetenv");
ret = snprintf(retv, PATH_MAX, "%s/%s/%s", tmp, SBINDIR, "/init.lxc");
if (ret < 0 || ret >= PATH_MAX) {
ret = snprintf(retv, PATH_MAX, "%s/%s/%s", tmp, SBINDIR, "/init.lxc");
if (ret < 0 || ret >= PATH_MAX) {
- ERROR("pathname too long");
+ ERROR("The name of path is too long");
ret = snprintf(retv, PATH_MAX, "%s/%s/%s", tmp, LXCINITDIR, "/lxc/lxc-init");
if (ret < 0 || ret >= PATH_MAX) {
ret = snprintf(retv, PATH_MAX, "%s/%s/%s", tmp, LXCINITDIR, "/lxc/lxc-init");
if (ret < 0 || ret >= PATH_MAX) {
- ERROR("pathname too long");
+ ERROR("The name of path is too long");
ret = snprintf(retv, PATH_MAX, "%s/usr/lib/lxc/lxc-init", tmp);
if (ret < 0 || ret >= PATH_MAX) {
ret = snprintf(retv, PATH_MAX, "%s/usr/lib/lxc/lxc-init", tmp);
if (ret < 0 || ret >= PATH_MAX) {
- ERROR("pathname too long");
+ ERROR("The name of path is too long");
ret = snprintf(retv, PATH_MAX, "%s/sbin/lxc-init", tmp);
if (ret < 0 || ret >= PATH_MAX) {
ret = snprintf(retv, PATH_MAX, "%s/sbin/lxc-init", tmp);
if (ret < 0 || ret >= PATH_MAX) {
- ERROR("pathname too long");
+ ERROR("The name of path is too long");
offset++;
*offsetp = offset;
offset++;
*offsetp = offset;
return (offset < fulllen) ? &path[offset] : NULL;
}
return (offset < fulllen) ? &path[offset] : NULL;
}
static int open_without_symlink(const char *target, const char *prefix_skip)
{
int curlen = 0, dirfd, fulllen, i;
static int open_without_symlink(const char *target, const char *prefix_skip)
{
int curlen = 0, dirfd, fulllen, i;
fulllen = strlen(target);
fulllen = strlen(target);
if (prefix_skip && strlen(prefix_skip) > 0) {
curlen = strlen(prefix_skip);
if (!is_subdir(target, prefix_skip, curlen)) {
if (prefix_skip && strlen(prefix_skip) > 0) {
curlen = strlen(prefix_skip);
if (!is_subdir(target, prefix_skip, curlen)) {
- ERROR("WHOA there - target '%s' didn't start with prefix '%s'",
- target, prefix_skip);
+ ERROR("WHOA there - target \"%s\" didn't start with prefix \"%s\"",
+ target, prefix_skip);
/* Make a copy of target which we can hack up, and tokenize it */
if ((dup = strdup(target)) == NULL) {
/* Make a copy of target which we can hack up, and tokenize it */
if ((dup = strdup(target)) == NULL) {
- SYSERROR("Out of memory checking for symbolic link");
+ ERROR("Out of memory checking for symbolic link");
}
dirfd = open(prefix_skip, O_RDONLY);
}
dirfd = open(prefix_skip, O_RDONLY);
+ if (dirfd < 0) {
+ SYSERROR("Failed to open path \"%s\"", prefix_skip);
while (1) {
int newfd, saved_errno;
while (1) {
int newfd, saved_errno;
/* todo - allow symlinks for relative paths if 'allowsymlinks' option is passed */
if (flags & MS_BIND && src && src[0] != '/') {
/* todo - allow symlinks for relative paths if 'allowsymlinks' option is passed */
if (flags & MS_BIND && src && src[0] != '/') {
- INFO("this is a relative bind mount");
+ INFO("This is a relative bind mount");
srcfd = open_without_symlink(src, NULL);
if (srcfd < 0)
srcfd = open_without_symlink(src, NULL);
if (srcfd < 0)
close(destfd);
if (ret < 0) {
errno = saved_errno;
close(destfd);
if (ret < 0) {
errno = saved_errno;
- SYSERROR("Failed to mount %s onto %s", src ? src : "(null)", dest);
+ SYSERROR("Failed to mount \"%s\" onto \"%s\"", src ? src : "(null)", dest);
*/
int lxc_mount_proc_if_needed(const char *rootfs)
{
*/
int lxc_mount_proc_if_needed(const char *rootfs)
{
+ char path[PATH_MAX] = {0};
int link_to_pid, linklen, mypid, ret;
char link[INTTYPE_TO_STRLEN(pid_t)] = {0};
ret = snprintf(path, PATH_MAX, "%s/proc/self", rootfs);
if (ret < 0 || ret >= PATH_MAX) {
int link_to_pid, linklen, mypid, ret;
char link[INTTYPE_TO_STRLEN(pid_t)] = {0};
ret = snprintf(path, PATH_MAX, "%s/proc/self", rootfs);
if (ret < 0 || ret >= PATH_MAX) {
- SYSERROR("proc path name too long");
+ SYSERROR("The name of proc path is too long");
ret = snprintf(path, PATH_MAX, "%s/proc", rootfs);
if (ret < 0 || ret >= PATH_MAX) {
ret = snprintf(path, PATH_MAX, "%s/proc", rootfs);
if (ret < 0 || ret >= PATH_MAX) {
- SYSERROR("proc path name too long");
+ SYSERROR("The name of proc path is too long");
goto domount;
} else if (linklen >= sizeof(link)) {
link[linklen - 1] = '\0';
goto domount;
} else if (linklen >= sizeof(link)) {
link[linklen - 1] = '\0';
- ERROR("readlink returned truncated content: \"%s\"", link);
+ ERROR("Readlink returned truncated content: \"%s\"", link);
ret = umount2(path, MNT_DETACH);
if (ret < 0)
ret = umount2(path, MNT_DETACH);
if (ret < 0)
- WARN("failed to umount \"%s\" with MNT_DETACH", path);
+ SYSWARN("Failed to umount \"%s\" with MNT_DETACH", path);
domount:
/* rootfs is NULL */
domount:
/* rootfs is NULL */
- INFO("mounted /proc in container for security transition");
+ INFO("Mounted /proc in container for security transition");
return 1;
}
int open_devnull(void)
{
int fd = open("/dev/null", O_RDWR);
return 1;
}
int open_devnull(void)
{
int fd = open("/dev/null", O_RDWR);
if (fd < 0)
SYSERROR("Can't open /dev/null");
if (fd < 0)
SYSERROR("Can't open /dev/null");
bool task_blocks_signal(pid_t pid, int signal)
{
int ret;
bool task_blocks_signal(pid_t pid, int signal)
{
int ret;
- char status[__PROC_STATUS_LEN];
+ char status[__PROC_STATUS_LEN] = {0};
FILE *f;
uint64_t sigblk = 0, one = 1;
size_t n = 0;
FILE *f;
uint64_t sigblk = 0, one = 1;
size_t n = 0;
buf[0] = '\0';
if (pipe(pipefd) < 0) {
buf[0] = '\0';
if (pipe(pipefd) < 0) {
- SYSERROR("failed to create pipe");
+ SYSERROR("Failed to create pipe");
if (child < 0) {
close(pipefd[0]);
close(pipefd[1]);
if (child < 0) {
close(pipefd[0]);
close(pipefd[1]);
- SYSERROR("failed to create new process");
+ SYSERROR("Failed to create new process");
close(pipefd[1]);
if (ret < 0) {
close(pipefd[1]);
if (ret < 0) {
- SYSERROR("failed to duplicate std{err,out} file descriptor");
+ SYSERROR("Failed to duplicate std{err,out} file descriptor");
_exit(EXIT_FAILURE);
}
/* Does not return. */
child_fn(args);
_exit(EXIT_FAILURE);
}
/* Does not return. */
child_fn(args);
- ERROR("failed to exec command");
+ ERROR("Failed to exec command");
int r = 0;
dir = opendir(dirname);
int r = 0;
dir = opendir(dirname);
+ if (!dir) {
+ SYSERROR("Failed to open dir \"%s\"", dirname);
while ((direntp = readdir(dir))) {
char *pathname;
while ((direntp = readdir(dir))) {
char *pathname;
ret = lstat(pathname, &mystat);
if (ret < 0) {
if (!r)
ret = lstat(pathname, &mystat);
if (ret < 0) {
if (!r)
- WARN("Failed to stat \"%s\"", pathname);
+ SYSWARN("Failed to stat \"%s\"", pathname);