diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-26 19:43:14 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-26 19:43:14 +0200 |
commit | 5fc523db68849a340bb73bd352048435a3178c52 (patch) | |
tree | 1a1078834a4eb9eafdecf0925edf81766b008354 /udev | |
parent | cd42b50d866c35c7ffbab07920dc1323dd978a23 (diff) |
libudev: initialize selinux only when needed
Diffstat (limited to 'udev')
-rw-r--r-- | udev/lib/libudev.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/udev/lib/libudev.c b/udev/lib/libudev.c index 3ff6cabbb0..4fd8196bd9 100644 --- a/udev/lib/libudev.c +++ b/udev/lib/libudev.c @@ -43,6 +43,7 @@ struct udev { char *rules_path; int log_priority; #ifdef USE_SELINUX + int selinux_initialized; int selinux_enabled; security_context_t selinux_prev_scontext; #endif @@ -87,6 +88,7 @@ static void selinux_init(struct udev *udev) udev->selinux_prev_scontext = NULL; } } + udev->selinux_initialized = 1; #endif } @@ -107,6 +109,8 @@ void udev_set_userdata(struct udev *udev, void *userdata) static void selinux_exit(struct udev *udev) { #ifdef USE_SELINUX + if (!udev->selinux_initialized) + return; if (udev->selinux_enabled) { freecon(udev->selinux_prev_scontext); udev->selinux_prev_scontext = NULL; @@ -117,6 +121,8 @@ static void selinux_exit(struct udev *udev) void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int mode) { #ifdef USE_SELINUX + if (!udev->selinux_initialized) + selinux_init(udev); if (udev->selinux_enabled) { security_context_t scontext = NULL; @@ -134,6 +140,8 @@ void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned int mode) { #ifdef USE_SELINUX + if (!udev->selinux_initialized) + selinux_init(udev); if (udev->selinux_enabled) { security_context_t scontext = NULL; @@ -151,6 +159,8 @@ void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned i void udev_selinux_resetfscreatecon(struct udev *udev) { #ifdef USE_SELINUX + if (!udev->selinux_initialized) + selinux_init(udev); if (udev->selinux_enabled) { if (setfscreatecon(udev->selinux_prev_scontext) < 0) err(udev, "setfscreatecon failed: %s\n", strerror(errno)); @@ -307,7 +317,6 @@ struct udev *udev_new(void) if (udev->dev_path == NULL || udev->sys_path == NULL) goto err; - selinux_init(udev); info(udev, "context %p created\n", udev); info(udev, "log_priority=%d\n", udev->log_priority); info(udev, "config_file='%s'\n", config_file); |