X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_selinux.c;h=a305e241367e18dc1fafaeebc5765e0fe4c58eeb;hp=94c213d297aca46c0d3927709db2789119bb57fc;hb=27283c2fdaefd9c7fd557fd4663566eacccca33a;hpb=1aa1e24848903d11780db1ade355be73ad61a937 diff --git a/udev_selinux.c b/udev_selinux.c index 94c213d29..a305e2413 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. * */ @@ -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); @@ -92,10 +90,13 @@ void selinux_setfilecon(const char *file, const char *devname, unsigned int mode char *media; int ret = -1; - media = get_media(devname, mode); - if (media) { - ret = matchmediacon(media, &scontext); - free(media); + if(devname) + { + media = get_media(devname, mode); + if (media) { + ret = matchmediacon(media, &scontext); + free(media); + } } if (ret < 0) @@ -104,7 +105,7 @@ void selinux_setfilecon(const char *file, const char *devname, unsigned int mode return; } - if (setfilecon(file, scontext) < 0) + if (lsetfilecon(file, scontext) < 0) err("setfilecon %s failed: %s", file, strerror(errno)); freecon(scontext);