All of lore.kernel.org
 help / color / mirror / Atom feed
* libselinux/policyvers
@ 2004-03-29  5:37 Chris PeBenito
  0 siblings, 0 replies; only message in thread
From: Chris PeBenito @ 2004-03-29  5:37 UTC (permalink / raw)
  To: SELinux Mail List


[-- Attachment #1.1: Type: text/plain, Size: 661 bytes --]

Attached is a suggested patch for libselinux/src/policyvers.c.  It adds
an errno check when the open() for /selinux/policyvers fails.  If its
ENOENT, it returns the default policy version, for the case that its a
older kernel that doesn't have policyvers on selinuxfs.  Otherwise, it
returns -1, so the caller can know that its actually failed, rather than
returning a possibly incorrect policy version.

-- 
Chris PeBenito
<pebenito@gentoo.org>
Developer,
Hardened Gentoo Linux
Embedded Gentoo Linux
 
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243
Key fingerprint = B0E6 877A 883F A57A 8E6A  CB00 BC8E E42D E6AF 9243

[-- Attachment #1.2: libselinux-errno.diff --]
[-- Type: text/x-patch, Size: 643 bytes --]

Index: src/policyvers.c
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/libselinux/src/policyvers.c,v
retrieving revision 1.2
diff -u -r1.2 policyvers.c
--- src/policyvers.c	12 Dec 2003 15:50:11 -0000	1.2
+++ src/policyvers.c	29 Mar 2004 04:24:24 -0000
@@ -20,8 +20,12 @@
 
 	snprintf(path, sizeof path, "%s/policyvers", selinux_mnt);
 	fd = open(path, O_RDONLY);
-	if (fd < 0)
-		return vers;
+	if (fd < 0) {
+		if (errno == ENOENT)
+			return vers;
+		else
+			return -1;
+	}
 	memset(buf, 0, sizeof buf);
 	ret = read(fd, buf, sizeof buf-1);
 	close(fd);

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-03-29 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-29  5:37 libselinux/policyvers Chris PeBenito

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.