PERFORCE change 45438 for review
Andrew Reisse
areisse at FreeBSD.org
Fri Jan 16 14:57:14 GMT 2004
http://perforce.freebsd.org/chv.cgi?CH=45438
Change 45438 by areisse at areisse_ibook on 2004/01/16 06:56:59
Call the new sebsd call for requesting type_change rules
Affected files ...
.. //depot/projects/trustedbsd/sedarwin/libsebsd/security_change_context.c#2 edit
Differences ...
==== //depot/projects/trustedbsd/sedarwin/libsebsd/security_change_context.c#2 (text+ko) ====
@@ -93,3 +93,53 @@
}
return (0);
}
+
+struct changesid_args
+{
+ char *domain;
+ char *source;
+ char *sclass;
+ char *out;
+ int *outlen;
+};
+
+int
+security_change_context2(const char *domain, const char *ocontext,
+ const char *oclass, char **newcontext)
+{
+ char *outcon;
+ size_t contexts_len, n;
+ int error;
+ struct changesid_args uap;
+
+bigger:
+ uap.outlen = &contexts_len;
+ uap.domain = domain;
+ uap.source = ocontext;
+ uap.sclass = oclass;
+ uap.out = NULL;
+ if (mac_syscall ("sebsd", 4, &uap))
+ {
+ return (-1);
+ }
+ outcon = malloc(contexts_len);
+ if (outcon == NULL) {
+ return (-1);
+ }
+ uap.out = outcon;
+ error = mac_syscall ("sebsd", 4, &uap);
+ /*
+ * We could possibly race and not have a large enough space
+ * for the current set of contexts.
+ */
+ if (error == -1 && errno == ENOMEM) {
+ free(outcon);
+ goto bigger;
+ }
+ else if (error == -1) {
+ free(outcon);
+ return (-1);
+ }
+ *newcontext = outcon;
+ return 0;
+}
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