summaryrefslogtreecommitdiffstats
path: root/daemons/dmeventd
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2010-12-13 10:43:56 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2010-12-13 10:43:56 +0000
commit7dfce0e46762d25d7fe253693a66d45a357dbb69 (patch)
treeb97b35821582d3270af7cab2d23ea214e484b6fb /daemons/dmeventd
parentbda30a59b930ee6c88b41ced9c6a6c16b80f7675 (diff)
downloadlvm2-7dfce0e46762d25d7fe253693a66d45a357dbb69.tar.gz
lvm2-7dfce0e46762d25d7fe253693a66d45a357dbb69.tar.xz
lvm2-7dfce0e46762d25d7fe253693a66d45a357dbb69.zip
Add new dm_prepare_selinux_context fn to libdevmapper and use it throughout.
Detect existence of new SELinux selabel interface during configure. Use new dm_prepare_selinux_context instead of dm_set_selinux_context. We should set the SELinux context before the actual file system object creation. The new dm_prepare_selinux_context function sets this using the selabel_lookup fn in conjuction with the setfscreatecon fn. If selinux/label.h interface (that should be a part of the selinux library) is not found during configure, we fallback to the original matchpathcon function instead.
Diffstat (limited to 'daemons/dmeventd')
-rw-r--r--daemons/dmeventd/dmeventd.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 3f015bdc..392d99ee 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1241,14 +1241,30 @@ static void _init_fifos(struct dm_event_fifos *fifos)
/* Open fifos used for client communication. */
static int _open_fifos(struct dm_event_fifos *fifos)
{
- /* Create fifos */
- if (((mkfifo(fifos->client_path, 0600) == -1) && errno != EEXIST) ||
- ((mkfifo(fifos->server_path, 0600) == -1) && errno != EEXIST)) {
- syslog(LOG_ERR, "%s: Failed to create a fifo.\n", __func__);
+ int orig_errno;
+
+ /* Create client fifo. */
+ (void) dm_prepare_selinux_context(fifos->client_path, S_IFIFO);
+ if ((mkfifo(fifos->client_path, 0600) == -1) && errno != EEXIST) {
+ syslog(LOG_ERR, "%s: Failed to create client fifo.\n", __func__);
+ orig_errno = errno;
+ (void) dm_prepare_selinux_context(NULL, 0);
stack;
- return -errno;
+ return -orig_errno;
}
+ /* Create server fifo. */
+ (void) dm_prepare_selinux_context(fifos->server_path, S_IFIFO);
+ if ((mkfifo(fifos->server_path, 0600) == -1) && errno != EEXIST) {
+ syslog(LOG_ERR, "%s: Failed to create server fifo.\n", __func__);
+ orig_errno = errno;
+ (void) dm_prepare_selinux_context(NULL, 0);
+ stack;
+ return -orig_errno;
+ }
+
+ (void) dm_prepare_selinux_context(NULL, 0);
+
struct stat st;
/* Warn about wrong permissions if applicable */
@@ -1806,10 +1822,12 @@ int main(int argc, char *argv[])
openlog("dmeventd", LOG_PID, LOG_DAEMON);
+ (void) dm_prepare_selinux_context(DMEVENTD_PIDFILE, S_IFREG);
if (dm_create_lockfile(DMEVENTD_PIDFILE) == 0)
exit(EXIT_FAILURE);
atexit(remove_lockfile);
+ (void) dm_prepare_selinux_context(NULL, 0);
/* Set the rest of the signals to cause '_exit_now' to be set */
signal(SIGINT, &_exit_handler);