From: Harald Hoyer <harald@redhat.com>
To: linux-hotplug@vger.kernel.org
Subject: patch for udev and selinux
Date: Thu, 16 Dec 2004 14:43:39 +0000 [thread overview]
Message-ID: <41C19F1B.3000308@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 82 bytes --]
Attached patch fixes:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=142713
[-- Attachment #2: udev-039-media.patch --]
[-- Type: text/x-patch, Size: 1293 bytes --]
--- 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)
next reply other threads:[~2004-12-16 14:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-16 14:43 Harald Hoyer [this message]
2004-12-16 19:03 ` patch for udev and selinux Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41C19F1B.3000308@redhat.com \
--to=harald@redhat.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.