Date: Fri, 16 Jan 2004 06:57:14 -0800 (PST) From: Andrew Reisse <areisse@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 45438 for review Message-ID: <200401161457.i0GEvEm9048340@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=45438 Change 45438 by areisse@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; +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401161457.i0GEvEm9048340>