Unverified Commit 2631ae67 by 2xsec Committed by Christian Brauner

log: change WARN macro using strerror to SYSWARN

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent 2cdf1af2
......@@ -380,7 +380,7 @@ static int lxc_attach_set_environment(struct lxc_proc_context_info *init_ctx,
if (extra_keep_store[i]) {
ret = setenv(extra_keep[i], extra_keep_store[i], 1);
if (ret < 0)
WARN("%s - Failed to set environment variable", strerror(errno));
SYSWARN("Failed to set environment variable");
}
free(extra_keep_store[i]);
}
......@@ -395,13 +395,13 @@ static int lxc_attach_set_environment(struct lxc_proc_context_info *init_ctx,
if (!path_kept) {
ret = setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1);
if (ret < 0)
WARN("%s - Failed to set environment variable", strerror(errno));
SYSWARN("Failed to set environment variable");
}
}
ret = putenv("container=lxc");
if (ret < 0) {
WARN("%s - Failed to set environment variable", strerror(errno));
SYSWARN("Failed to set environment variable");
return -1;
}
......@@ -435,7 +435,7 @@ static int lxc_attach_set_environment(struct lxc_proc_context_info *init_ctx,
ret = putenv(p);
if (ret < 0)
WARN("%s - Failed to set environment variable", strerror(errno));
SYSWARN("Failed to set environment variable");
}
}
......
......@@ -196,8 +196,7 @@ int lxc_ambient_caps_up(void)
for (cap = 0; cap <= last_cap; cap++) {
ret = prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap, 0, 0);
if (ret < 0) {
WARN("%s - Failed to raise ambient capability %d",
strerror(errno), cap);
SYSWARN("Failed to raise ambient capability %d", cap);
goto out;
}
}
......
......@@ -1082,14 +1082,14 @@ static int recursive_destroy(char *dirname)
ret = rmdir(dirname);
if (ret < 0) {
if (!r)
WARN("%s - Failed to delete \"%s\"", strerror(errno), dirname);
SYSWARN("Failed to delete \"%s\"", dirname);
r = -1;
}
ret = closedir(dir);
if (ret < 0) {
if (!r)
WARN("%s - Failed to delete \"%s\"", strerror(errno), dirname);
SYSWARN("Failed to delete \"%s\"", dirname);
r = -1;
}
......@@ -1398,15 +1398,13 @@ static int chowmod(char *path, uid_t chown_uid, gid_t chown_gid,
ret = chown(path, chown_uid, chown_gid);
if (ret < 0) {
WARN("%s - Failed to chown(%s, %d, %d)", strerror(errno), path,
(int)chown_uid, (int)chown_gid);
SYSWARN("Failed to chown(%s, %d, %d)", path, (int)chown_uid, (int)chown_gid);
return -1;
}
ret = chmod(path, chmod_mode);
if (ret < 0) {
WARN("%s - Failed to chmod(%s, %d)", strerror(errno), path,
(int)chmod_mode);
SYSWARN("Failed to chmod(%s, %d)", path, (int)chmod_mode);
return -1;
}
......
......@@ -126,8 +126,9 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
ret = lxc_abstract_unix_recv_fds(sock, &rspfd, 1, rsp, sizeof(*rsp));
if (ret < 0) {
WARN("%s - Failed to receive response for command \"%s\"",
strerror(errno), lxc_cmd_str(cmd->req.cmd));
SYSWARN("Failed to receive response for command \"%s\"",
lxc_cmd_str(cmd->req.cmd));
if (errno == ECONNRESET)
return -ECONNRESET;
......@@ -218,8 +219,7 @@ static int lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)
ret = send(fd, rsp->data, rsp->datalen, 0);
if (ret < 0 || ret != (ssize_t)rsp->datalen) {
WARN("%s - Failed to send command response data %zd",
strerror(errno), ret);
SYSWARN("Failed to send command response data %zd", ret);
return -1;
}
......
......@@ -986,15 +986,13 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
/* Prevent leaking the file descriptors to the container */
ret = fcntl(tty->master, F_SETFD, FD_CLOEXEC);
if (ret < 0)
WARN("Failed to set FD_CLOEXEC flag on master fd %d of "
"tty device \"%s\": %s",
tty->master, tty->name, strerror(errno));
SYSWARN("Failed to set FD_CLOEXEC flag on master fd %d of "
"tty device \"%s\"", tty->master, tty->name);
ret = fcntl(tty->slave, F_SETFD, FD_CLOEXEC);
if (ret < 0)
WARN("Failed to set FD_CLOEXEC flag on slave fd %d of "
"tty device \"%s\": %s",
tty->slave, tty->name, strerror(errno));
SYSWARN("Failed to set FD_CLOEXEC flag on slave fd %d of "
"tty device \"%s\"", tty->slave, tty->name);
tty->busy = 0;
}
......@@ -1549,7 +1547,7 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
ret = umount2("/dev/pts", MNT_DETACH);
if (ret < 0)
WARN("%s - Failed to unmount old devpts instance", strerror(errno));
SYSWARN("Failed to unmount old devpts instance");
else
DEBUG("Unmounted old devpts instance");
......
......@@ -113,7 +113,7 @@ static void lxc_monitor_fifo_send(struct lxc_msg *msg, const char *lxcpath)
if (errno == ENXIO || errno == ENOENT)
return;
WARN("%s - Failed to open fifo to send message", strerror(errno));
SYSWARN("Failed to open fifo to send message");
return;
}
......
......@@ -2599,10 +2599,10 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
netdev->name[0] != '\0' ? netdev->name : "(null)",
netdev->ifindex);
} else if (ret < 0) {
WARN("Failed to remove interface \"%s\" with "
"index %d: %s",
netdev->name[0] != '\0' ? netdev->name : "(null)",
netdev->ifindex, strerror(-ret));
errno = -ret;
SYSWARN("Failed to remove interface \"%s\" with index %d",
netdev->name[0] != '\0' ? netdev->name : "(null)",
netdev->ifindex);
goto clear_ifindices;
}
INFO("Removed interface \"%s\" with index %d",
......@@ -2624,8 +2624,9 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
ret = lxc_netdev_delete_by_name(hostveth);
if (ret < 0) {
WARN("Failed to remove interface \"%s\" from \"%s\": %s",
hostveth, netdev->link, strerror(-ret));
errno = -ret;
SYSWARN("Failed to remove interface \"%s\" from \"%s\"",
hostveth, netdev->link);
goto clear_ifindices;
}
INFO("Removed interface \"%s\" from \"%s\"", hostveth, netdev->link);
......
......@@ -427,8 +427,10 @@ scmp_filter_ctx get_new_ctx(enum lxc_hostarch_t n_arch,
#ifdef SCMP_FLTATR_ATL_TSKIP
ret = seccomp_attr_set(ctx, SCMP_FLTATR_ATL_TSKIP, 1);
if (ret < 0)
WARN("%s - Failed to turn on seccomp nop-skip, continuing", strerror(-ret));
if (ret < 0) {
errno = -ret;
SYSWARN("Failed to turn on seccomp nop-skip, continuing");
}
#endif
ret = seccomp_arch_exist(ctx, arch);
......@@ -730,8 +732,10 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
#ifdef SCMP_FLTATR_ATL_TSKIP
ret = seccomp_attr_set(conf->seccomp_ctx, SCMP_FLTATR_ATL_TSKIP, 1);
if (ret < 0)
WARN("%s - Failed to turn on seccomp nop-skip, continuing", strerror(-ret));
if (ret < 0) {
errno = -ret;
SYSWARN("Failed to turn on seccomp nop-skip, continuing");
}
#endif
}
......@@ -1156,11 +1160,13 @@ int lxc_read_seccomp_config(struct lxc_conf *conf)
ERROR("%s - Failed to turn off no-new-privs", strerror(-ret));
return -1;
}
#ifdef SCMP_FLTATR_ATL_TSKIP
ret = seccomp_attr_set(conf->seccomp_ctx, SCMP_FLTATR_ATL_TSKIP, 1);
if (ret < 0)
WARN("%s - Failed to turn on seccomp nop-skip, continuing",
strerror(-ret));
if (ret < 0) {
errno = -ret;
SYSWARN("Failed to turn on seccomp nop-skip, continuing");
}
#endif
f = fopen(conf->seccomp, "r");
......@@ -1203,8 +1209,10 @@ int lxc_seccomp_load(struct lxc_conf *conf)
lxc_log_fd >= 0) {
ret = seccomp_export_pfc(conf->seccomp_ctx, lxc_log_fd);
/* Just give an warning when export error */
if (ret < 0)
WARN("%s - Failed to export seccomp filter to log file", strerror(-ret));
if (ret < 0) {
errno = -ret;
SYSWARN("Failed to export seccomp filter to log file");
}
}
#endif
......
......@@ -160,8 +160,7 @@ static int lxc_try_preserve_ns(const int pid, const char *ns)
return -EINVAL;
}
WARN("%s - Kernel does not support preserving %s namespaces",
strerror(errno), ns);
SYSWARN("Kernel does not support preserving %s namespaces", ns);
return -EOPNOTSUPP;
}
......@@ -228,7 +227,7 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
restart:
dir = opendir("/proc/self/fd");
if (!dir) {
WARN("%s - Failed to open directory", strerror(errno));
SYSWARN("Failed to open directory");
return -1;
}
......@@ -987,7 +986,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
/* Reset mask set by setup_signal_fd. */
ret = pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
if (ret < 0)
WARN("%s - Failed to restore signal mask", strerror(errno));
SYSWARN("Failed to restore signal mask");
lxc_terminal_delete(&handler->conf->console);
lxc_delete_tty(&handler->conf->ttys);
......
......@@ -132,8 +132,7 @@ int btrfs_list_get_path_rootid(int fd, u64 *treeid)
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
if (ret < 0) {
WARN("Warning: can't perform the search -%s\n",
strerror(errno));
SYSWARN("Warning: can't perform the search");
return ret;
}
*treeid = args.treeid;
......
......@@ -786,9 +786,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
else if (!strncmp(upperdir, lxcpath, dirlen) &&
strncmp(upperdir, rootfs_dir, rootfslen))
ret = mkdir_p(upperdir, 0755);
if (ret < 0)
WARN("Failed to create directory \"%s\": %s", upperdir,
strerror(errno));
SYSWARN("Failed to create directory \"%s\"", upperdir);
}
ret = 0;
......@@ -798,9 +798,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
else if (!strncmp(workdir, lxcpath, dirlen) &&
strncmp(workdir, rootfs_dir, rootfslen))
ret = mkdir_p(workdir, 0755);
if (ret < 0)
WARN("Failed to create directory \"%s\": %s", workdir,
strerror(errno));
SYSWARN("Failed to create directory \"%s\"", workdir);
}
fret = 0;
......
......@@ -209,7 +209,7 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts)
close(ts->sigfd);
if (pthread_sigmask(SIG_SETMASK, &ts->oldmask, NULL) < 0)
WARN("%s - Failed to restore signal mask", strerror(errno));
SYSWARN("Failed to restore signal mask");
}
if (isatty(ts->stdinfd))
......@@ -771,7 +771,7 @@ void lxc_terminal_delete(struct lxc_terminal *terminal)
if (terminal->tios && terminal->peer >= 0) {
ret = tcsetattr(terminal->peer, TCSAFLUSH, terminal->tios);
if (ret < 0)
WARN("%s - Failed to set old terminal settings", strerror(errno));
SYSWARN("Failed to set old terminal settings");
}
free(terminal->tios);
terminal->tios = NULL;
......@@ -1106,8 +1106,7 @@ restore_tios:
if (istty) {
istty = tcsetattr(stdinfd, TCSAFLUSH, &oldtios);
if (istty < 0)
WARN("%s - Failed to restore terminal properties",
strerror(errno));
SYSWARN("Failed to restore terminal properties");
}
close_mainloop:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment