diff options
Diffstat (limited to 'udev/lib/libudev.c')
-rw-r--r-- | udev/lib/libudev.c | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/udev/lib/libudev.c b/udev/lib/libudev.c index c2c5025b9e..3f7d0e547e 100644 --- a/udev/lib/libudev.c +++ b/udev/lib/libudev.c @@ -25,9 +25,6 @@ #include <errno.h> #include <string.h> #include <ctype.h> -#ifdef USE_SELINUX -#include <selinux/selinux.h> -#endif #include "libudev.h" #include "libudev-private.h" @@ -42,11 +39,6 @@ struct udev { char *dev_path; char *rules_path; int log_priority; -#ifdef USE_SELINUX - int selinux_initialized; - int selinux_enabled; - security_context_t selinux_prev_scontext; -#endif int run; }; @@ -72,26 +64,6 @@ static void log_stderr(struct udev *udev, vfprintf(stderr, format, args); } -static void selinux_init(struct udev *udev) -{ -#ifdef USE_SELINUX - /* - * record the present security context, for file-creation - * restoration creation purposes. - */ - udev->selinux_enabled = (is_selinux_enabled() > 0); - info(udev, "selinux=%i\n", udev->selinux_enabled); - if (udev->selinux_enabled) { - matchpathcon_init_prefix(NULL, udev_get_dev_path(udev)); - if (getfscreatecon(&udev->selinux_prev_scontext) < 0) { - err(udev, "getfscreatecon failed\n"); - udev->selinux_prev_scontext = NULL; - } - } - udev->selinux_initialized = 1; -#endif -} - void *udev_get_userdata(struct udev *udev) { if (udev == NULL) @@ -106,68 +78,6 @@ void udev_set_userdata(struct udev *udev, void *userdata) udev->userdata = 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; - } -#endif -} - -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; - - if (matchpathcon(file, mode, &scontext) < 0) { - err(udev, "matchpathcon(%s) failed\n", file); - return; - } - if (lsetfilecon(file, scontext) < 0) - err(udev, "setfilecon %s failed: %m\n", file); - freecon(scontext); - } -#endif -} - -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; - - if (matchpathcon(file, mode, &scontext) < 0) { - err(udev, "matchpathcon(%s) failed\n", file); - return; - } - if (setfscreatecon(scontext) < 0) - err(udev, "setfscreatecon %s failed: %m\n", file); - freecon(scontext); - } -#endif -} - -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: %m\n"); - } -#endif -} - /** * udev_new: * @@ -364,7 +274,6 @@ void udev_unref(struct udev *udev) udev->refcount--; if (udev->refcount > 0) return; - selinux_exit(udev); free(udev->dev_path); free(udev->sys_path); free(udev->rules_path); |