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