PERFORCE change 91452 for review
Rob Deker
deker at FreeBSD.org
Thu Feb 9 19:28:46 GMT 2006
http://perforce.freebsd.org/chv.cgi?CH=91452
Change 91452 by deker at deker_build1.columbia.sparta.com on 2006/02/09 19:28:42
per millert:
"Simpler version of sebsd_enabled()"
Submitted by: millert
Affected files ...
.. //depot/projects/trustedbsd/sedarwin7/src/sedarwin/libselinux/src/system.c#3 edit
Differences ...
==== //depot/projects/trustedbsd/sedarwin7/src/sedarwin/libselinux/src/system.c#3 (text+ko) ====
@@ -35,37 +35,29 @@
*/
#include <errno.h>
#include <stdio.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <sedarwin/sebsd.h>
#include <sedarwin/sebsd_syscalls.h>
-int sebsd_enabled()
+int
+sebsd_enabled(void)
{
- int args[2];
- int i;
- size_t mibn = sizeof(int) * 64;
- int mibs[64];
+ int i, error;
- args[0] = 0;
- args[1] = 3;
-
- const char *name = "security.mac.sebsd.enforcing";
- i = sysctl (args, 2, mibs, &mibn, name, strlen(name));
- if (i < 0)
- return 0;
- return 1;
+ error = sysctlbyname("security.mac.sebsd.enforcing", &i,
+ sizeof(i), NULL, 0);
+ return (!error || errno != ENOENT);
}
int
-sebsd_enforcing()
+sebsd_enforcing(void)
{
int i, error;
- error = sysctlbyname ("security.mac.sebsd.enforcing",
- &i, sizeof (int), NULL, 0);
- if (error)
- return 0;
- return i;
+
+ error = sysctlbyname("security.mac.sebsd.enforcing", &i,
+ sizeof(i), NULL, 0);
+ return (error ? 0 : i);
}
struct lp_args
@@ -87,9 +79,31 @@
fseek (fp, 0, SEEK_END);
la.len = ftell (fp);
fseek (fp, 0, SEEK_SET);
- la.data = malloc (la.len);
- if (1 != fread (la.data, la.len, 1, fp))
- return EIO;
+ if ((la.data = malloc (la.len)) == NULL)
+ return (ENOMEM);
+ if (fread(la.data, la.len, 1, fp) != 1)
+ return (EIO);
+
+ return (mac_syscall(SEBSD_ID_STRING, SEBSDCALL_LOAD_POLICY, &la));
+}
+
+int
+sebsd_load_migscs(const char *path)
+{
+ FILE *fp;
+ struct lp_args la;
+
+ fp = fopen (path, "rb");
+ if (fp == NULL)
+ return errno;
+
+ fseek(fp, 0, SEEK_END);
+ la.len = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ if ((la.data = malloc(la.len)) == NULL)
+ return (ENOMEM);
+ if (fread(la.data, la.len, 1, fp) != 1)
+ return (EIO);
- return mac_syscall(SEBSD_ID_STRING, SEBSDCALL_LOAD_POLICY, &la);
+ return (mac_syscall(SEBSD_ID_STRING, SEBSDCALL_LOAD_MIGSCS, &la));
}
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list