From mboxrd@z Thu Jan 1 00:00:00 1970 From: Harald Hoyer Date: Thu, 16 Dec 2004 14:43:39 +0000 Subject: patch for udev and selinux Message-Id: <41C19F1B.3000308@redhat.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------080906020501030309090901" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------080906020501030309090901 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Attached patch fixes: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=142713 --------------080906020501030309090901 Content-Type: text/x-patch; name="udev-039-media.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="udev-039-media.patch" --- udev-039/selinux.h.media 2004-10-16 00:08:30.000000000 +0200 +++ udev-039/selinux.h 2004-12-14 10:23:37.247464735 +0100 @@ -30,31 +30,40 @@ FILE *fp; char buf[PATH_MAX]; char mediabuf[PATH_MAX]; + int ret = -1; *media = NULL; if (!(mode && S_IFBLK)) { return -1; } - snprintf(buf,sizeof(buf), "/proc/ide/%s/media", basename(path)); + + snprintf(buf, sizeof(buf), "/proc/ide/%s/media", basename(path)); + fp=fopen(buf,"r"); - if (fp) { - if (fgets(mediabuf,sizeof(mediabuf), fp)) { - int size = strlen(mediabuf); - while (size-- > 0) { - if (isspace(mediabuf[size])) { - mediabuf[size]='\0'; - } else { - break; - } - } - *media = strdup(mediabuf); - info("selinux_get_media(%s)->%s \n", path, *media); + if (!fp) + goto out; + + mediabuf[0] = '\0'; + + if (fgets(mediabuf, sizeof(mediabuf), fp) == NULL) + goto close_out; + + int size = strlen(mediabuf); + while (size-- > 0) { + if (isspace(mediabuf[size])) { + mediabuf[size]='\0'; + } else { + break; } - fclose(fp); - return 0; - } else { - return -1; } + *media = strdup(mediabuf); + info("selinux_get_media(%s)->%s \n", path, *media); + ret = 0; + +close_out: + fclose(fp); +out: + return ret; } static inline void selinux_setfilecon(char *file, unsigned int mode) --------------080906020501030309090901-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel