caps = cap_get_proc();
if (!caps) {
- ERROR("failed to cap_get_proc: %s", strerror(errno));
+ SYSERROR("Failed to cap_get_proc");
return -1;
}
ret = cap_clear_flag(caps, CAP_EFFECTIVE);
if (ret) {
- ERROR("failed to cap_clear_flag: %s", strerror(errno));
+ SYSERROR("Failed to cap_clear_flag");
goto out;
}
ret = cap_set_proc(caps);
if (ret) {
- ERROR("failed to cap_set_proc: %s", strerror(errno));
+ SYSERROR("Failed to cap_set_proc");
goto out;
}
caps = cap_get_proc();
if (!caps) {
- ERROR("failed to cap_get_proc: %s", strerror(errno));
+ SYSERROR("Failed to cap_get_proc");
return -1;
}
INFO("Last supported cap was %d", cap-1);
break;
} else {
- ERROR("failed to cap_get_flag: %s",
- strerror(errno));
+ SYSERROR("Failed to cap_get_flag");
goto out;
}
}
ret = cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap, flag);
if (ret) {
- ERROR("failed to cap_set_flag: %s", strerror(errno));
+ SYSERROR("Failed to cap_set_flag");
goto out;
}
}
ret = cap_set_proc(caps);
if (ret) {
- ERROR("failed to cap_set_proc: %s", strerror(errno));
+ SYSERROR("Failed to cap_set_proc");
goto out;
}
INFO("command is run as setuid root (uid : %d)", uid);
if (prctl(PR_SET_KEEPCAPS, 1)) {
- ERROR("failed to 'PR_SET_KEEPCAPS': %s",
- strerror(errno));
+ SYSERROR("Failed to 'PR_SET_KEEPCAPS'");
return -1;
}
if (setresgid(gid, gid, gid)) {
- ERROR("failed to change gid to '%d': %s", gid,
- strerror(errno));
+ SYSERROR("Failed to change gid to '%d'", gid);
return -1;
}
if (setresuid(uid, uid, uid)) {
- ERROR("failed to change uid to '%d': %s", uid,
- strerror(errno));
+ SYSERROR("Failed to change uid to '%d'", uid);
return -1;
}
if (lxc_caps_up()) {
- ERROR("failed to restore capabilities: %s",
- strerror(errno));
+ SYSERROR("Failed to restore capabilities");
return -1;
}
}
ret = cap_get_flag(caps, cap, flag, &flagval);
if (ret < 0) {
- ERROR("Failed to perform cap_get_flag(): %s.", strerror(errno));
+ SYSERROR("Failed to perform cap_get_flag()");
return false;
}
* case errno will be set to ENODATA.
*/
if (errno != ENODATA)
- ERROR("Failed to perform cap_get_file(): %s.\n", strerror(errno));
+ SYSERROR("Failed to perform cap_get_file()");
+
return false;
}
caps = cap_get_proc();
if (!caps) {
- ERROR("Failed to perform cap_get_proc(): %s.\n", strerror(errno));
+ SYSERROR("Failed to perform cap_get_proc()");
return false;
}
NOTICE("Exec'ing \"%s\"", my_args.argv[0]);
ret = execvp(my_args.argv[0], my_args.argv);
- ERROR("%s - Failed to exec \"%s\"", strerror(errno), my_args.argv[0]);
+ SYSERROR("Failed to exec \"%s\"", my_args.argv[0]);
exit(ret);
}
if (errno == EINTR)
continue;
- ERROR("%s - Failed to wait on child %d",
- strerror(errno), pid);
+ SYSERROR("Failed to wait on child %d", pid);
goto out;
}
fd = lxc_abstract_unix_open(addr.sun_path, SOCK_STREAM, O_TRUNC);
if (fd < 0) {
- ERROR("Failed to open unix socket: %s.", strerror(errno));
+ SYSERROR("Failed to open unix socket");
return -1;
}
for (i = 0; i < mon->clientfds_cnt; i++) {
ret = write(mon->clientfds[i], &msglxc, sizeof(msglxc));
if (ret < 0)
- ERROR("Failed to send message to client file descriptor %d: %s.",
- mon->clientfds[i], strerror(errno));
+ SYSERROR("Failed to send message to client file descriptor %d",
+ mon->clientfds[i]);
}
return LXC_MAINLOOP_CONTINUE;
if ((rsp->datalen > LXC_CMD_DATA_MAX) &&
(cmd->req.cmd != LXC_CMD_CONSOLE_LOG)) {
errno = EFBIG;
- ERROR("%s - Response data for command \"%s\" is too long: %d "
- "bytes > %d", strerror(errno), lxc_cmd_str(cmd->req.cmd),
- rsp->datalen, LXC_CMD_DATA_MAX);
+ SYSERROR("Response data for command \"%s\" is too long: %d bytes > %d",
+ lxc_cmd_str(cmd->req.cmd), rsp->datalen, LXC_CMD_DATA_MAX);
return -EFBIG;
}
}
if (!rsp->data) {
errno = ENOMEM;
- ERROR("%s - Failed to allocate response buffer for command "
- "\"%s\"", strerror(errno), lxc_cmd_str(cmd->req.cmd));
+ SYSERROR("Failed to allocate response buffer for command \"%s\"",
+ lxc_cmd_str(cmd->req.cmd));
return -ENOMEM;
}
ret = recv(sock, rsp->data, rsp->datalen, 0);
if (ret != rsp->datalen) {
- ERROR("%s - Failed to receive response data for command \"%s\"",
- lxc_cmd_str(cmd->req.cmd), strerror(errno));
+ SYSERROR("Failed to receive response data for command \"%s\"",
+ lxc_cmd_str(cmd->req.cmd));
if (ret >= 0)
ret = -1;
}
ret = send(fd, rsp, sizeof(*rsp), 0);
if (ret < 0 || (size_t)ret != sizeof(*rsp)) {
- ERROR("%s - Failed to send command response %zd",
- strerror(errno), ret);
+ SYSERROR("Failed to send command response %zd", ret);
return -1;
}
* closed.
*/
if (ret > 0) {
- ERROR("%s - Failed to stop container \"%s\"",
- strerror(-cmd.rsp.ret), name);
+ errno = -cmd.rsp.ret;
+ SYSERROR("Failed to stop container \"%s\"", name);
return -1;
}
return ret;
if (cmd.rsp.ret < 0) {
- ERROR("%s - Denied access to tty", strerror(-cmd.rsp.ret));
+ errno = -cmd.rsp.ret;
+ SYSERROR("Denied access to tty");
ret = -1;
goto out;
}
if (ret < 0) {
if (errno != ECONNREFUSED)
- ERROR("%s - Failed to execute command", strerror(errno));
+ SYSERROR("Failed to execute command");
+
return -1;
}
* function.
*/
if (cmd.rsp.ret < 0) {
- ERROR("%s - Failed to receive socket fd", strerror(-cmd.rsp.ret));
+ errno = -cmd.rsp.ret;
+ SYSERROR("Failed to receive socket fd");
return -1;
}
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0) {
- ERROR("%s - Failed to execute command", strerror(errno));
+ SYSERROR("Failed to execute command");
return -1;
}
fd = lxc_abstract_unix_open(path, SOCK_STREAM, 0);
if (fd < 0) {
- ERROR("%s - Failed to create command socket %s",
- strerror(errno), offset);
+ SYSERROR("Failed to create command socket %s", offset);
if (errno == EADDRINUSE)
ERROR("Container \"%s\" appears to be already running", name);
+
return -1;
}
goto again;
}
- ERROR("Failed to receive message: %s", strerror(errno));
+ SYSERROR("Failed to receive message");
return -1;
}
*/
ret = mknod(path, S_IFREG | 0000, 0);
if (ret < 0) /* this isn't fatal, continue */
- ERROR("%s - Failed to create \"%s\"", strerror(errno), path);
+ SYSERROR("Failed to create \"%s\"", path);
ret = mount(tty->name, path, "none", MS_BIND, 0);
if (ret < 0) {
}
if (ret < 0)
- ERROR("Failed to send %zu ttys to parent: %s", ttys->max,
- strerror(errno));
+ SYSERROR("Failed to send %zu ttys to parent", ttys->max);
else
TRACE("Sent %zu ttys to parent", ttys->max);
if (file_exists(path)) {
ret = lxc_unstack_mountpoint(path, false);
if (ret < 0) {
- ERROR("Failed to unmount \"%s\": %s", path, strerror(errno));
+ SYSERROR("Failed to unmount \"%s\"", path);
return -ret;
} else {
DEBUG("Cleared all (%d) mounts from \"%s\"", ret, path);
if (file_exists(path)) {
ret = lxc_unstack_mountpoint(path, false);
if (ret < 0) {
- ERROR("%s - Failed to unmount \"%s\"", strerror(errno), path);
+ SYSERROR("Failed to unmount \"%s\"", path);
return -ret;
} else {
DEBUG("Cleared all (%d) mounts from \"%s\"", ret, path);
#if HAVE_PRLIMIT || HAVE_PRLIMIT64
if (prlimit(pid, resid, &lim->limit, NULL) != 0) {
- ERROR("Failed to set limit %s: %s", lim->resource,
- strerror(errno));
+ SYSERROR("Failed to set limit %s", lim->resource);
return -1;
}
#else
return clr_config_namespace_clone(key, lxc_conf, data);
if (lxc_conf->ns_keep != 0) {
- ERROR("%s - Cannot set both \"lxc.namespace.clone\" and "
- "\"lxc.namespace.keep\"", strerror(EINVAL));
+ errno = EINVAL;
+ SYSERROR("Cannot set both \"lxc.namespace.clone\" and "
+ "\"lxc.namespace.keep\"");
return -EINVAL;
}
return clr_config_namespace_keep(key, lxc_conf, data);
if (lxc_conf->ns_clone != 0) {
- ERROR("%s - Cannot set both \"lxc.namespace.clone\" and "
- "\"lxc.namespace.keep\"", strerror(EINVAL));
+ errno = EINVAL;
+ SYSERROR("Cannot set both \"lxc.namespace.clone\" and "
+ "\"lxc.namespace.keep\"");
return -EINVAL;
}
/* parse current index */
ret = lxc_safe_uint((idx_start + 1), &tmpidx);
if (ret < 0) {
- ERROR("Failed to parse usigned integer from string \"%s\": %s",
- idx_start + 1, strerror(-ret));
+ errno = -ret;
+ SYSERROR("Failed to parse usigned integer from string \"%s\"",
+ idx_start + 1);
*idx = ret;
goto on_error;
}
ret = kill(pid, 0);
if (ret < 0) {
- ERROR("%s - Failed to send signal to pid %d", strerror(errno),
- (int)pid);
+ SYSERROR("Failed to send signal to pid %d", (int)pid);
return -EPERM;
}
ret = resolve_clone_flags(handler);
if (ret < 0) {
- ERROR("%s - Unsupported clone flag specified", strerror(errno));
+ SYSERROR("Unsupported clone flag specified");
goto out_fini_handler;
}
fd = lxc_unpriv(open(name, O_CREAT | O_WRONLY |
O_APPEND | O_CLOEXEC, 0666));
if (fd == -1) {
- ERROR("failed to open log file \"%s\" : %s", name,
- strerror(errno));
+ SYSERROR("Failed to open log file \"%s\"", name);
return -1;
}
newfd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
if (newfd == -1)
- ERROR("failed to dup log fd %d : %s", fd, strerror(errno));
+ SYSERROR("Failed to dup log fd %d", fd);
close(fd);
return newfd;
if (create_dirs)
#endif
if (build_dir(fname)) {
- ERROR("failed to create dir for log file \"%s\" : %s", fname,
- strerror(errno));
+ SYSERROR("Failed to create dir for log file \"%s\"", fname);
return -1;
}
}
if (build_dir(fname)) {
- ERROR("failed to create dir for log file \"%s\" : %s", fname,
- strerror(errno));
+ SYSERROR("Failed to create dir for log file \"%s\"", fname);
return -1;
}
if (n == 1 && v == 0) {
ret = remove(path);
if (ret < 0)
- ERROR("%s - Failed to remove \"%s\"",
- strerror(errno), path);
+ SYSERROR("Failed to remove \"%s\"", path);
+
n = 0;
}
}
+
if (n == 1) {
v += inc ? 1 : -1;
f1 = fopen(path, "w");
if (!f1)
goto out;
+
if (fprintf(f1, "%d\n", v) < 0) {
ERROR("Error writing new snapshots value");
fclose(f1);
goto out;
}
+
ret = fclose(f1);
if (ret != 0) {
SYSERROR("Error writing to or closing snapshots file");
}
if (fbuf.st_size != 0) {
-
buf = lxc_strmmap(NULL, fbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (buf == MAP_FAILED) {
SYSERROR("Failed to create mapping %s", path);
/* If the lxc-snapshot file is empty, remove it. */
if (stat(path, &fbuf) < 0)
goto out;
+
if (!fbuf.st_size) {
ret = remove(path);
if (ret < 0)
SYSERROR("Failed to remove \"%s\"", path);
-
}
}
if(ret == 0) {
ret = unlink(path);
if (ret < 0) {
- ERROR("%s - Failed to remove \"%s\"", strerror(errno), path);
+ SYSERROR("Failed to remove \"%s\"", path);
_exit(EXIT_FAILURE);
}
}
directory_path = dirname(tmp);
ret = mkdir_p(directory_path, 0755);
if (ret < 0 && errno != EEXIST) {
- ERROR("%s - Failed to create path \"%s\"", strerror(errno), directory_path);
+ SYSERROR("Failed to create path \"%s\"", directory_path);
free(tmp);
_exit(EXIT_FAILURE);
}
ret = mknod(path, st->st_mode, st->st_rdev);
free(tmp);
if (ret < 0) {
- ERROR("%s - Failed to create device node at \"%s\"", strerror(errno), path);
+ SYSERROR("Failed to create device node at \"%s\"", path);
_exit(EXIT_FAILURE);
}
DEBUG("opening monitor socket %s with len %zu", &addr.sun_path[1], len);
if (len >= sizeof(addr.sun_path) - 1) {
errno = ENAMETOOLONG;
- ERROR("name of monitor socket too long (%zu bytes): %s", len, strerror(errno));
+ SYSERROR("The name of monitor socket too long (%zu bytes)", len);
return -1;
}
fd = lxc_abstract_unix_connect(addr.sun_path);
if (fd != -1 || errno != ECONNREFUSED)
break;
- ERROR("Failed to connect to monitor socket. Retrying in %d ms: %s", backoff_ms[retry], strerror(errno));
+
+ SYSERROR("Failed to connect to monitor socket. Retrying in %d ms", backoff_ms[retry]);
usleep(backoff_ms[retry] * 1000);
}
if (fd < 0) {
- ERROR("Failed to connect to monitor socket: %s.", strerror(errno));
+ SYSERROR("Failed to connect to monitor socket");
return -1;
}
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#define _GNU_SOURCE
#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
ret = clone(do_clone, stack + stack_size, flags | SIGCHLD, &clone_arg);
#endif
if (ret < 0)
- ERROR("Failed to clone (%#x): %s.", flags, strerror(errno));
+ SYSERROR("Failed to clone (%#x)", flags);
return ret;
}
err = lxc_veth_create(veth1, veth2);
if (err) {
- ERROR("Failed to create veth pair \"%s\" and \"%s\": %s", veth1,
- veth2, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to create veth pair \"%s\" and \"%s\"", veth1, veth2);
goto out_delete;
}
* of a container */
err = setup_private_host_hw_addr(veth1);
if (err) {
- ERROR("Failed to change mac address of host interface \"%s\": %s",
- veth1, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to change mac address of host interface \"%s\"", veth1);
goto out_delete;
}
err = lxc_netdev_set_mtu(veth1, mtu);
if (!err)
err = lxc_netdev_set_mtu(veth2, mtu);
+
if (err) {
- ERROR("Failed to set mtu \"%d\" for veth pair \"%s\" "
- "and \"%s\": %s",
- mtu, veth1, veth2, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to set mtu \"%d\" for veth pair \"%s\" "
+ "and \"%s\"", mtu, veth1, veth2);
goto out_delete;
}
}
if (netdev->link[0] != '\0') {
err = lxc_bridge_attach(netdev->link, veth1);
if (err) {
- ERROR("Failed to attach \"%s\" to bridge \"%s\": %s",
- veth1, netdev->link, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to attach \"%s\" to bridge \"%s\"",
+ veth1, netdev->link);
goto out_delete;
}
INFO("Attached \"%s\" to bridge \"%s\"", veth1, netdev->link);
err = lxc_netdev_up(veth1);
if (err) {
- ERROR("Failed to set \"%s\" up: %s", veth1, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to set \"%s\" up", veth1);
goto out_delete;
}
err = lxc_macvlan_create(netdev->link, peer,
netdev->priv.macvlan_attr.mode);
if (err) {
- ERROR("Failed to create macvlan interface \"%s\" on \"%s\": %s",
- peer, netdev->link, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to create macvlan interface \"%s\" on \"%s\"",
+ peer, netdev->link);
goto on_error;
}
err = lxc_vlan_create(netdev->link, peer, netdev->priv.vlan_attr.vid);
if (err) {
- ERROR("Failed to create vlan interface \"%s\" on \"%s\": %s",
- peer, netdev->link, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to create vlan interface \"%s\" on \"%s\"",
+ peer, netdev->link);
return -1;
}
netdev->name[0] != '\0' ? netdev->name : "(null)");
return -1;
}
+
err = lxc_netdev_set_mtu(peer, mtu);
if (err) {
- ERROR("Failed to set mtu \"%s\" for \"%s\": %s",
- netdev->mtu, peer, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to set mtu \"%s\" for \"%s\"",
+ netdev->mtu, peer);
lxc_netdev_delete_by_name(peer);
return -1;
}
/* Get all the network interfaces. */
ret = getifaddrs(&ifaddr);
if (ret < 0) {
- ERROR("%s - Failed to get network interfaces", strerror(errno));
+ SYSERROR("Failed to get network interfaces");
return NULL;
}
ret = lxc_safe_int(token, &netdev->ifindex);
if (ret < 0) {
- ERROR("%s - Failed to convert string \"%s\" to integer",
- strerror(-ret), token);
+ errno = -ret;
+ SYSERROR("Failed to convert string \"%s\" to integer", token);
return -1;
}
ret = lxc_safe_int(token, &netdev->priv.veth_attr.ifindex);
if (ret < 0) {
- ERROR("%s - Failed to convert string \"%s\" to integer",
- strerror(-ret), token);
+ errno = -ret;
+ SYSERROR("Failed to convert string \"%s\" to integer", token);
return -1;
}
ret = lxc_netdev_move_by_name(ifname, pid, NULL);
if (ret) {
- ERROR("Failed to move network device \"%s\" to "
- "network namespace %d: %s", ifname, pid,
- strerror(-ret));
+ errno = -ret;
+ SYSERROR("Failed to move network device \"%s\" to "
+ "network namespace %d", ifname, pid);
return -1;
}
{
struct sockaddr sockaddr;
struct ifreq ifr;
- int ret, fd, saved_errno;
+ int ret, fd;
ret = lxc_convert_mac(hwaddr, &sockaddr);
if (ret) {
- ERROR("Mac address \"%s\" conversion failed: %s", hwaddr,
- strerror(-ret));
+ errno = -ret;
+ SYSERROR("Mac address \"%s\" conversion failed", hwaddr);
return -1;
}
return -1;
ret = ioctl(fd, SIOCSIFHWADDR, &ifr);
- saved_errno = errno;
- close(fd);
if (ret)
- ERROR("Failed to perform ioctl: %s", strerror(saved_errno));
+ SYSERROR("Failed to perform ioctl");
+
+ close(fd);
DEBUG("Mac address \"%s\" on \"%s\" has been setup", hwaddr,
ifr.ifr_name);
err = lxc_ipv4_addr_add(ifindex, &inetdev->addr,
&inetdev->bcast, inetdev->prefix);
if (err) {
- ERROR("Failed to setup ipv4 address for network device "
- "with eifindex %d: %s", ifindex, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to setup ipv4 address for network device "
+ "with eifindex %d", ifindex);
return -1;
}
}
&inet6dev->mcast, &inet6dev->acast,
inet6dev->prefix);
if (err) {
- ERROR("Failed to setup ipv6 address for network device "
- "with eifindex %d: %s", ifindex, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to setup ipv6 address for network device "
+ "with eifindex %d", ifindex);
return -1;
}
}
if (netdev->flags & IFF_UP) {
err = lxc_netdev_up("lo");
if (err) {
- ERROR("Failed to set the loopback network "
- "device up: %s",
- strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to set the loopback network device up");
return -1;
}
}
if (strcmp(ifname, netdev->name) != 0) {
err = lxc_netdev_rename_by_name(ifname, netdev->name);
if (err) {
- ERROR("Failed to rename network device \"%s\" to "
- "\"%s\": %s", ifname, netdev->name, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to rename network device \"%s\" to \"%s\"",
+ ifname, netdev->name);
return -1;
}
}
err = lxc_netdev_up(current_ifname);
if (err) {
- ERROR("Failed to set network device \"%s\" up: %s",
- current_ifname, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to set network device \"%s\" up",
+ current_ifname);
return -1;
}
/* the network is up, make the loopback up too */
err = lxc_netdev_up("lo");
if (err) {
- ERROR("Failed to set the loopback network device up: %s",
- strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to set the loopback network device up");
return -1;
}
}
if (err) {
err = lxc_ipv4_dest_add(netdev->ifindex, netdev->ipv4_gateway);
if (err) {
- ERROR("Failed to add ipv4 dest for network "
- "device \"%s\": %s", ifname, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to add ipv4 dest for network device \"%s\"",
+ ifname);
}
err = lxc_ipv4_gateway_add(netdev->ifindex, netdev->ipv4_gateway);
if (err) {
- ERROR("Failed to setup ipv4 gateway for "
- "network device \"%s\": %s",
- ifname, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to setup ipv4 gateway for network device \"%s\"",
+ ifname);
+
if (netdev->ipv4_gateway_auto) {
char buf[INET_ADDRSTRLEN];
inet_ntop(AF_INET, netdev->ipv4_gateway, buf, sizeof(buf));
if (err) {
err = lxc_ipv6_dest_add(netdev->ifindex, netdev->ipv6_gateway);
if (err) {
- ERROR("Failed to add ipv6 dest for network "
- "device \"%s\": %s", ifname, strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to add ipv6 dest for network device \"%s\"",
+ ifname);
}
err = lxc_ipv6_gateway_add(netdev->ifindex, netdev->ipv6_gateway);
if (err) {
- ERROR("Failed to setup ipv6 gateway for "
- "network device \"%s\": %s", ifname,
- strerror(-err));
+ errno = -err;
+ SYSERROR("Failed to setup ipv6 gateway for network device \"%s\"",
+ ifname);
+
if (netdev->ipv6_gateway_auto) {
char buf[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, netdev->ipv6_gateway, buf, sizeof(buf));
ret = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_NNP, 0);
if (ret < 0) {
- ERROR("%s - Failed to turn off no-new-privs", strerror(-ret));
+ errno = -ret;
+ SYSERROR("Failed to turn off no-new-privs");
seccomp_release(ctx);
return NULL;
}
ret = seccomp_arch_exist(ctx, arch);
if (ret < 0) {
if (ret != -EEXIST) {
- ERROR("%s - Failed to determine whether arch %d is "
- "already present in the main seccomp context",
- strerror(-ret), (int)n_arch);
+ errno = -ret;
+ SYSERROR("Failed to determine whether arch %d is "
+ "already present in the main seccomp context",
+ (int)n_arch);
seccomp_release(ctx);
return NULL;
}
ret = seccomp_arch_add(ctx, arch);
if (ret != 0) {
- ERROR("%s - Failed to add arch %d to main seccomp context",
- strerror(-ret), (int)n_arch);
+ errno = -ret;
+ SYSERROR("Failed to add arch %d to main seccomp context",
+ (int)n_arch);
seccomp_release(ctx);
return NULL;
}
ret = seccomp_arch_exist(ctx, arch);
if (arch && ret != 0) {
- ERROR("%s - Seccomp: rule and context arch do not match (arch %d)", strerror(-ret), arch);
+ errno = -ret;
+ SYSERROR("Seccomp: rule and context arch do not match (arch %d)", arch);
return false;
}
SCMP_SYS(umount2), 1,
SCMP_A1(SCMP_CMP_MASKED_EQ, MNT_FORCE, MNT_FORCE));
if (ret < 0) {
- ERROR("%s - Failed loading rule to reject force umount", strerror(-ret));
+ errno = -ret;
+ SYSERROR("Failed loading rule to reject force umount");
return false;
}
ret = seccomp_rule_add_exact_array(ctx, rule->action, nr,
rule->args_num, arg_cmp);
if (ret < 0) {
- ERROR("%s - Failed loading rule for %s (nr %d action %d (%s))",
- strerror(-ret), line, nr, rule->action,
- get_action_name(rule->action));
+ errno = -ret;
+ SYSERROR("Failed loading rule for %s (nr %d action %d (%s))",
+ line, nr, rule->action, get_action_name(rule->action));
return false;
}
ret = seccomp_attr_set(conf->seccomp_ctx, SCMP_FLTATR_CTL_NNP, 0);
if (ret < 0) {
- ERROR("%s - Failed to turn off no-new-privs", strerror(-ret));
+ errno = -ret;
+ SYSERROR("Failed to turn off no-new-privs");
return -1;
}
ret = seccomp_attr_set(SCMP_FLTATR_CTL_NNP, 0);
#endif
if (ret < 0) {
- ERROR("%s - Failed to turn off no-new-privs", strerror(-ret));
+ errno = -ret;
+ SYSERROR("Failed to turn off no-new-privs");
return -1;
}
ret = seccomp_load();
#endif
if (ret < 0) {
- ERROR("%s- Error loading the seccomp policy", strerror(-ret));
+ errno = -ret;
+ SYSERROR("Error loading the seccomp policy");
return -1;
}
goto again;
}
- ERROR("%s - Failed to send message to client",
- strerror(errno));
+ SYSERROR("Failed to send message to client");
}
/* kick client from list */
TRACE("Received pty with master fd %d and slave fd %d from "
"parent", tty->master, tty->slave);
}
+
if (ret < 0)
- ERROR("Failed to receive %zu ttys from child: %s", ttys->max,
- strerror(errno));
+ SYSERROR("Failed to receive %zu ttys from child", ttys->max);
else
TRACE("Received %zu ttys from child", ttys->max);
ret = lxc_try_preserve_ns(handler->pid, "net");
if (ret < 0) {
if (ret != -EOPNOTSUPP) {
- ERROR("%s - Failed to preserve net namespace", strerror(errno));
+ SYSERROR("Failed to preserve net namespace");
goto out_delete_net;
}
} else {
ret = lxc_try_preserve_ns(handler->pid, "cgroup");
if (ret < 0) {
if (ret != -EOPNOTSUPP) {
- ERROR("%s - Failed to preserve cgroup namespace",
- strerror(errno));
+ SYSERROR("Failed to preserve cgroup namespace");
goto out_delete_net;
}
} else {
int name_len)
{
struct btrfs_ioctl_ino_lookup_args args;
- int ret, e;
+ int ret;
size_t len, retlen;
char *retpath;
args.objectid = objid;
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
- e = errno;
if (ret) {
- ERROR("Failed to lookup path for %llu %llu %s - %s\n",
- (unsigned long long) dir_id,
- (unsigned long long) objid,
- name, strerror(e));
+ SYSERROR("Failed to lookup path for %llu %llu %s",
+ (unsigned long long) dir_id,
+ (unsigned long long) objid,
+ name);
return NULL;
} else
INFO("Got path for %llu %llu - %s\n",
ret = read(fd, &sync, sizeof(sync));
if (ret < 0) {
- ERROR("sync wait failure : %s", strerror(errno));
+ SYSERROR("Sync wait failure");
return -1;
}
return 0;
if ((size_t)ret != sizeof(sync)) {
- ERROR("unexpected sync size: %zu expected %zu", (size_t)ret, sizeof(sync));
+ ERROR("Unexpected sync size: %zu expected %zu", (size_t)ret, sizeof(sync));
return -1;
}
}
if (sync != sequence) {
- ERROR("invalid sequence number %d. expected %d",
+ ERROR("Invalid sequence number %d. expected %d",
sync, sequence);
return -1;
}
int sync = sequence;
if (write(fd, &sync, sizeof(sync)) < 0) {
- ERROR("sync wake failure : %s", strerror(errno));
+ SYSERROR("Sync wake failure");
return -1;
}
return 0;
goto on_succes;
}
- ERROR("%s - Failed to open proxy terminal \"%s\"",
- strerror(errno), path);
+ SYSERROR("Failed to open proxy terminal \"%s\"", path);
return -ENOTTY;
}
DEBUG("Using terminal \"%s\" as proxy", path);
if (!buf || !count) {
char buf2[100];
size_t count2 = 0;
+
while ((ret = read(fd, buf2, 100)) > 0)
count2 += ret;
+
if (ret >= 0)
ret = count2;
} else {
}
if (ret < 0)
- ERROR("read %s: %s", filename, strerror(errno));
+ SYSERROR("Read %s", filename);
saved_errno = errno;
close(fd);