for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]);
- return syserrno_set(-EFBIG, "Received excessive number of file descriptors");
+ return syserror_set(-EFBIG, "Received excessive number of file descriptors");
}
if (msg.msg_flags & MSG_CTRUNC) {
for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]);
- return syserrno_set(-EFBIG, "Control message was truncated; closing all fds and rejecting incomplete message");
+ return syserror_set(-EFBIG, "Control message was truncated; closing all fds and rejecting incomplete message");
}
if (ret_fds->fd_count_max > num_raw) {
for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]);
- return syserrno_set(-EINVAL, "Received fewer file descriptors than we expected %u != %u",
+ return syserror_set(-EINVAL, "Received fewer file descriptors than we expected %u != %u",
ret_fds->fd_count_max, num_raw);
}
for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]);
- return syserrno_set(-EINVAL, "Received more file descriptors than we expected %u != %u",
+ return syserror_set(-EINVAL, "Received more file descriptors than we expected %u != %u",
ret_fds->fd_count_max, num_raw);
}
for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]);
- return syserrno_set(-EINVAL, "Invalid flag combination; closing to not risk leaking fds %u != %u",
+ return syserror_set(-EINVAL, "Invalid flag combination; closing to not risk leaking fds %u != %u",
ret_fds->fd_count_max, num_raw);
}
/* We expected to receive file descriptors. */
if ((ret_fds->flags & UNIX_FDS_ACCEPT_MASK) &&
!(ret_fds->flags & UNIX_FDS_ACCEPT_NONE))
- return syserrno_set(-EINVAL, "Received no file descriptors");
+ return syserror_set(-EINVAL, "Received no file descriptors");
}
return ret;
int idx;
if (abspath(base_cgroup))
- return syserrno_set(-EINVAL, "Container base path must be relative to controller mount");
+ return syserror_set(-EINVAL, "Container base path must be relative to controller mount");
new = zalloc(sizeof(*new));
if (!new)
* absolute nor walks upwards.
*/
if (abspath(cur))
- return syserrno_set(-EINVAL, "No absolute paths allowed");
+ return syserror_set(-EINVAL, "No absolute paths allowed");
if (strnequal(cur, "..", STRLITERALLEN("..")))
- return syserrno_set(-EINVAL, "No upward walking paths allowed");
+ return syserror_set(-EINVAL, "No upward walking paths allowed");
ret = mkdirat(dfd_cur, cur, mode);
if (ret < 0) {
/* The final cgroup must be succesfully creatd by us. */
if (ret) {
if (ret != -EEXIST || !eexist_ignore)
- return syserrno_set(ret, "Creating the final cgroup %d(%s) failed", dfd_base, path);
+ return syserror_set(ret, "Creating the final cgroup %d(%s) failed", dfd_base, path);
}
return move_fd(dfd_final);
int dirfd = arg->hierarchies[i]->dfd_con;
if (dirfd < 0)
- return syserrno_set(-EBADF, "Invalid cgroup file descriptor");
+ return syserror_set(-EBADF, "Invalid cgroup file descriptor");
(void)fchowmodat(dirfd, "", destuid, nsgid, 0775);
else
ret = device_cgroup_rule_parse(&device_item, key, val);
if (ret < 0)
- return syserrno_set(EINVAL, "Failed to parse device rule %s=%s", key, val);
+ return syserror_set(EINVAL, "Failed to parse device rule %s=%s", key, val);
/*
* Note that bpf_list_add_device() returns 1 if it altered the device
* absolute nor walks upwards.
*/
if (abspath(cur))
- return syserrno_set(-EINVAL, "No absolute paths allowed");
+ return syserror_set(-EINVAL, "No absolute paths allowed");
if (strnequal(cur, "..", STRLITERALLEN("..")))
- return syserrno_set(-EINVAL, "No upward walking paths allowed");
+ return syserror_set(-EINVAL, "No upward walking paths allowed");
ret = lxc_writeat(dfd_cur, "cgroup.subtree_control", add_controllers, full_len);
if (ret < 0)
}
if (!controllers_available(ops))
- return syserrno_set(-ENOENT, "One or more requested controllers unavailable or not delegated");
+ return syserror_set(-ENOENT, "One or more requested controllers unavailable or not delegated");
return 0;
}
}
if (idx == 0)
- return syserrno_set(-ENOENT, "Failed to attach to cgroups");
+ return syserror_set(-ENOENT, "Failed to attach to cgroups");
TRACE("Attached to %s cgroup layout", cgroup_layout_name(ctx->layout));
return 0;
return ret_errno(EBADF);
if (flags & ~(BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI | BPF_F_REPLACE))
- return syserrno_set(-EINVAL, "Invalid flags for bpf program");
+ return syserror_set(-EINVAL, "Invalid flags for bpf program");
/*
* Don't allow the bpf program to be overwritten for now. If we ever
list_elem = malloc(sizeof(*list_elem));
if (!list_elem)
- return syserrno_set(ENOMEM, "Failed to allocate new device list");
+ return syserror_set(ENOMEM, "Failed to allocate new device list");
new_device = memdup(device, sizeof(struct device_item));
if (!new_device)
- return syserrno_set(ENOMEM, "Failed to allocate new device item");
+ return syserror_set(ENOMEM, "Failed to allocate new device item");
lxc_list_add_elem(list_elem, move_ptr(new_device));
lxc_list_add_tail(&bpf_devices->device_item, move_ptr(list_elem));
*/
if ((rsp->datalen > LXC_CMD_DATA_MAX) &&
(cur_cmd != LXC_CMD_CONSOLE_LOG))
- return syserrno_set(-E2BIG, "Response data for command \"%s\" is too long: %d bytes > %d",
+ return syserror_set(-E2BIG, "Response data for command \"%s\" is too long: %d bytes > %d",
cur_cmdstr, rsp->datalen, LXC_CMD_DATA_MAX);
/*
__fallthrough;
case LXC_CMD_GET_LIMIT_CGROUP_FD: /* data */
if (rsp->datalen > sizeof(struct cgroup_fd))
- return syserrno_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
+ return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
/* Don't pointlessly allocate. */
rsp->data = (void *)cmd->req.data;
break;
case LXC_CMD_GET_CGROUP_CTX: /* data */
if (rsp->datalen > sizeof(struct cgroup_ctx))
- return syserrno_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
+ return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
/* Don't pointlessly allocate. */
rsp->data = (void *)cmd->req.data;
rsp->data = tty;
break;
}
- return syserrno_set(-ENOMEM, "Failed to receive response for command \"%s\"", cur_cmdstr);
+ return syserror_set(-ENOMEM, "Failed to receive response for command \"%s\"", cur_cmdstr);
case LXC_CMD_CONSOLE_LOG: /* data */
__data = zalloc(rsp->datalen + 1);
rsp->data = __data;
* Either static or allocated memory.
*/
if (!rsp->data)
- return syserrno_set(-ENOMEM, "Failed to prepare response buffer for command \"%s\"",
+ return syserror_set(-ENOMEM, "Failed to prepare response buffer for command \"%s\"",
cur_cmdstr);
bytes_recv = lxc_recv_nointr(sock, rsp->data, rsp->datalen, 0);
rsp.ret = 0;
return rsp_one_fd_reap(fd, handler->conf->seccomp.notifier.notify_fd, &rsp);
#else
- return syserrno_set(-EOPNOTSUPP, "Seccomp notifier not supported");
+ return syserror_set(-EOPNOTSUPP, "Seccomp notifier not supported");
#endif
}
struct lxc_cmd_rr cmd;
if (strlen(device->access) > STRLITERALLEN("rwm"))
- return syserrno_set(-EINVAL, "Invalid access mode specified %s", device->access);
+ return syserror_set(-EINVAL, "Invalid access mode specified %s", device->access);
lxc_cmd_init(&cmd, LXC_CMD_ADD_BPF_DEVICE_CGROUP);
lxc_cmd_data(&cmd, sizeof(struct device_item), device);
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
- return syserrno_set(ret, "Failed to process new bpf device cgroup command");
+ return syserror_set(ret, "Failed to process new bpf device cgroup command");
if (cmd.rsp.ret < 0)
- return syserrno_set(cmd.rsp.ret, "Failed to add new bpf device cgroup rule");
+ return syserror_set(cmd.rsp.ret, "Failed to add new bpf device cgroup rule");
return 0;
}
};
__lxc_cmd_rsp_send(fd, &rsp);
- return syserrno_set(-ENOSYS, "Invalid command id %d", id);
+ return syserror_set(-ENOSYS, "Invalid command id %d", id);
}
static int lxc_cmd_process(int fd, struct lxc_cmd_req *req,
return clr_config_cgroup_dir(key, lxc_conf, NULL);
if (abspath(value))
- return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+ return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value))
- return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+ return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.dir, value);
}
return clr_config_cgroup_monitor_dir(key, lxc_conf, NULL);
if (abspath(value))
- return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+ return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value))
- return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+ return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.monitor_dir, value);
}
return clr_config_cgroup_monitor_pivot_dir(key, lxc_conf, NULL);
if (abspath(value))
- return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+ return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value))
- return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+ return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.monitor_pivot_dir, value);
}
return clr_config_cgroup_container_dir(key, lxc_conf, NULL);
if (abspath(value))
- return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+ return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value))
- return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+ return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.container_dir, value);
}
return clr_config_cgroup_container_inner_dir(key, lxc_conf, NULL);
if (abspath(value))
- return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+ return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (strchr(value, '/') || strequal(value, ".") || strequal(value, ".."))
return log_error_errno(-EINVAL, EINVAL, "lxc.cgroup.dir.container.inner must be a single directory name");
__internal_ret__; \
})
-#define syserrno_set(__ret__, format, ...) \
- ({ \
- typeof(__ret__) __internal_ret__ = (__ret__); \
- errno = labs(__ret__); \
- SYSERROR(format, ##__VA_ARGS__); \
- __internal_ret__; \
- })
-
#define syswarn_set(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \