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]);
}
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;
}
ret = putenv(p);
if (ret < 0)
- WARN("%s - Failed to set environment variable", strerror(errno));
+ SYSWARN("Failed to set environment variable");
}
}
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;
}
}
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;
}
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;
}
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;
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;
}
/* 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;
}
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");
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;
}
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",
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);
#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);
#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
}
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");
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
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;
}
restart:
dir = opendir("/proc/self/fd");
if (!dir) {
- WARN("%s - Failed to open directory", strerror(errno));
+ SYSWARN("Failed to open directory");
return -1;
}
/* 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);
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;
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;
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;
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))
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;
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: