X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_selinux.c;h=b802e1fc6ee36016824db6968129ee0041839e37;hp=719ff6403ec178d15e412d0e9cc872e46274328e;hb=eef5447934a07279bc76f3f65b0302ddea8556ab;hpb=ff3e4bed21aaff673284f2e024da26c1e39cfda6 diff --git a/udev_selinux.c b/udev_selinux.c index 719ff6403..b802e1fc6 100644 --- a/udev_selinux.c +++ b/udev_selinux.c @@ -1,6 +1,4 @@ /* - * udev_selinux.h - * * Copyright (C) 2004 Daniel Walsh * * This program is free software; you can redistribute it and/or modify it @@ -14,7 +12,7 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ @@ -30,8 +28,8 @@ #include #include +#include "udev.h" #include "udev_selinux.h" -#include "logging.h" static security_context_t prev_scontext = NULL; @@ -54,7 +52,7 @@ static char *get_media(const char *devname, int mode) int size; char *media = NULL; - if (!(mode && S_IFBLK)) + if (!(mode & S_IFBLK)) return NULL; snprintf(procfile, PATH_MAX, "/proc/ide/%s/media", devname); @@ -100,12 +98,12 @@ void selinux_setfilecon(const char *file, const char *devname, unsigned int mode if (ret < 0) if (matchpathcon(file, mode, &scontext) < 0) { - dbg("matchpathcon(%s) failed\n", file); + err("matchpathcon(%s) failed\n", file); return; } if (setfilecon(file, scontext) < 0) - dbg("setfilecon %s failed: %s", file, strerror(errno)); + err("setfilecon %s failed: %s", file, strerror(errno)); freecon(scontext); } @@ -126,12 +124,12 @@ void selinux_setfscreatecon(const char *file, const char *devname, unsigned int if (ret < 0) if (matchpathcon(file, mode, &scontext) < 0) { - dbg("matchpathcon(%s) failed\n", file); + err("matchpathcon(%s) failed\n", file); return; } if (setfscreatecon(scontext) < 0) - dbg("setfscreatecon %s failed: %s", file, strerror(errno)); + err("setfscreatecon %s failed: %s", file, strerror(errno)); freecon(scontext); } @@ -141,7 +139,7 @@ void selinux_resetfscreatecon(void) { if (is_selinux_running()) { if (setfscreatecon(prev_scontext) < 0) - dbg("setfscreatecon failed: %s", strerror(errno)); + err("setfscreatecon failed: %s", strerror(errno)); } } @@ -152,8 +150,9 @@ void selinux_init(void) * restoration creation purposes. */ if (is_selinux_running()) { + matchpathcon_init_prefix(NULL, udev_root); if (getfscreatecon(&prev_scontext) < 0) { - dbg("getfscreatecon failed\n"); + err("getfscreatecon failed\n"); prev_scontext = NULL; } }