#include "bus-error.h"
#include "bus-util.h"
#include "chase-symlinks.h"
+#include "constants.h"
#include "copy.h"
#include "dbus-socket.h"
#include "dbus-unit.h"
-#include "def.h"
#include "errno-list.h"
#include "exit-status.h"
#include "fd-util.h"
mode_t directory_mode,
mode_t socket_mode) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
mode_t old_mask;
struct stat st;
int r;
}
static int special_address_create(const char *path, bool writable) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
struct stat st;
assert(path);
}
static int usbffs_address_create(const char *path) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
struct stat st;
assert(path);
long maxmsg,
long msgsize) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
struct stat st;
mode_t old_mask;
struct mq_attr _attr, *attr = NULL;
assert(s);
assert(ret);
- if (s->selinux_context_from_net) {
- /* If this is requested, get the label from the network label */
+ Unit *service;
+ ExecCommand *c;
+ const char *exec_context;
+ _cleanup_free_ char *path = NULL;
- r = mac_selinux_get_our_label(ret);
- if (r == -EOPNOTSUPP)
- goto no_label;
-
- } else {
- /* Otherwise, get it from the executable we are about to start. */
-
- Unit *service;
- ExecCommand *c;
- const char *exec_context;
- _cleanup_free_ char *path = NULL;
-
- r = socket_load_service_unit(s, -1, &service);
- if (r == -ENODATA)
- goto no_label;
- if (r < 0)
- return r;
+ r = socket_load_service_unit(s, -1, &service);
+ if (r == -ENODATA)
+ goto no_label;
+ if (r < 0)
+ return r;
- exec_context = SERVICE(service)->exec_context.selinux_context;
- if (exec_context) {
- char *con;
+ exec_context = SERVICE(service)->exec_context.selinux_context;
+ if (exec_context) {
+ char *con;
- con = strdup(exec_context);
- if (!con)
- return -ENOMEM;
-
- *ret = TAKE_PTR(con);
- return 0;
- }
+ con = strdup(exec_context);
+ if (!con)
+ return -ENOMEM;
- c = SERVICE(service)->exec_command[SERVICE_EXEC_START];
- if (!c)
- goto no_label;
+ *ret = TAKE_PTR(con);
+ return 0;
+ }
- r = chase_symlinks(c->path, SERVICE(service)->exec_context.root_directory, CHASE_PREFIX_ROOT, &path, NULL);
- if (r < 0)
- goto no_label;
+ c = SERVICE(service)->exec_command[SERVICE_EXEC_START];
+ if (!c)
+ goto no_label;
- r = mac_selinux_get_create_label_from_exe(path, ret);
- if (IN_SET(r, -EPERM, -EOPNOTSUPP))
- goto no_label;
- }
+ r = chase_symlinks(c->path, SERVICE(service)->exec_context.root_directory, CHASE_PREFIX_ROOT, &path, NULL);
+ if (r < 0)
+ goto no_label;
+ r = mac_selinux_get_create_label_from_exe(path, ret);
+ if (IN_SET(r, -EPERM, -EOPNOTSUPP))
+ goto no_label;
return r;
no_label:
const SocketAddress *address,
const char *label) {
- _cleanup_close_pair_ int pair[2] = { -1, -1 };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
int fd, r;
pid_t pid;
_cleanup_(exec_params_clear) ExecParameters exec_params = {
.flags = EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN,
- .stdin_fd = -1,
- .stdout_fd = -1,
- .stderr_fd = -1,
- .exec_fd = -1,
+ .stdin_fd = -EBADF,
+ .stdout_fd = -EBADF,
+ .stderr_fd = -EBADF,
+ .exec_fd = -EBADF,
};
pid_t pid;
int r;
}
static int socket_accept_in_cgroup(Socket *s, SocketPort *p, int fd) {
- _cleanup_close_pair_ int pair[2] = { -1, -1 };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
int cfd, r;
pid_t pid;
static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
SocketPort *p = ASSERT_PTR(userdata);
- int cfd = -1;
+ int cfd = -EBADF;
assert(fd >= 0);