d /run/dlog 0755 log log - -
+d /run/dlog/priv 0700 log log - -
+t /run/dlog/priv 0700 log log - security.SMACK64=System
+d /run/dlog/priv/fifo 0700 log log - -
+t /run/dlog/priv/fifo 0700 log log - security.SMACK64TRANSMUTE=TRUE
+t /run/dlog/priv/fifo 0700 log log - security.SMACK64=User::App::Shared
return (reader->read_fd >= 0 ? 0 : -errno);
}
+static int create_fifo_fds(int fifo_id, int *write_fd, int *read_fd)
+{
+ assert(write_fd);
+ assert(read_fd);
+
+ char fifo_path[64];
+ if (snprintf(fifo_path, sizeof fifo_path, "/run/dlog/priv/fifo/%d", fifo_id) < 0)
+ return -errno;
+
+ if (mkfifo(fifo_path, 0600) < 0) {
+ assert(errno != EEXIST);
+ return -errno;
+ }
+
+ int ret = 0;
+
+ *read_fd = open(fifo_path, O_RDONLY | O_NONBLOCK);
+ if (*read_fd < 0) {
+ ret = -errno;
+ goto finish;
+ }
+
+ *write_fd = open(fifo_path, O_WRONLY | O_NONBLOCK);
+ if (*write_fd < 0) {
+ ret = -errno;
+ close(*read_fd);
+ goto finish;
+ }
+
+finish:
+ unlink(fifo_path);
+ return ret;
+}
+
/**
* @brief Parse a command line
* @details Creates a reader from a parsed command line
if (retval < 0)
goto cleanup;
- int fds[2];
- if (pipe2(fds, O_CLOEXEC | O_NONBLOCK) < 0) {
- retval = -errno;
+ int write_fd = -1, read_fd = -1;
+ if (create_fifo_fds(wr->fd_entity.fd, &write_fd, &read_fd) < 0)
goto cleanup;
- }
- set_write_fd_entity(&reader->fd_entity, fds[1]);
+
+ set_write_fd_entity(&reader->fd_entity, write_fd);
assert(wr);
- retval = send_pipe(wr->fd_entity.fd, fds[0], DLOG_FLAG_READ);
- close(fds[0]);
+ retval = send_pipe(wr->fd_entity.fd, read_fd, DLOG_FLAG_READ);
+ close(read_fd);
if (retval)
goto cleanup;
}