Deleted Added
full compact
mac.c (119588) mac.c (122732)
1/*
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed by Robert Watson for the TrustedBSD Project.
7 *
8 * This software was developed for the FreeBSD Project in part by Network

--- 17 unchanged lines hidden (view full) ---

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
1/*
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed by Robert Watson for the TrustedBSD Project.
7 *
8 * This software was developed for the FreeBSD Project in part by Network

--- 17 unchanged lines hidden (view full) ---

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $FreeBSD: head/lib/libc/posix1e/mac.c 119588 2003-08-30 14:51:01Z rwatson $
34 * $FreeBSD: head/lib/libc/posix1e/mac.c 122732 2003-11-15 03:34:58Z rwatson $
35 */
36
37#include <sys/types.h>
38#include <sys/queue.h>
39#include <sys/sysctl.h>
40
41#include <dlfcn.h>
42#include <errno.h>

--- 310 unchanged lines hidden (view full) ---

353
354 return (0);
355}
356
357int
358mac_prepare_type(struct mac **mac, const char *name)
359{
360 struct label_default *ld;
35 */
36
37#include <sys/types.h>
38#include <sys/queue.h>
39#include <sys/sysctl.h>
40
41#include <dlfcn.h>
42#include <errno.h>

--- 310 unchanged lines hidden (view full) ---

353
354 return (0);
355}
356
357int
358mac_prepare_type(struct mac **mac, const char *name)
359{
360 struct label_default *ld;
361 int error;
361
362
363 error = mac_maybe_init_internal();
364 if (error != 0)
365 return (error);
366
362 for (ld = LIST_FIRST(&label_default_head); ld != NULL;
363 ld = LIST_NEXT(ld, ld_entries)) {
367 for (ld = LIST_FIRST(&label_default_head); ld != NULL;
368 ld = LIST_NEXT(ld, ld_entries)) {
369 printf("%s\n", ld->ld_name);
364 if (strcmp(name, ld->ld_name) == 0)
365 return (mac_prepare(mac, ld->ld_labels));
366 }
367
368 errno = ENOENT;
369 return (-1); /* XXXMAC: ENOLABEL */
370}
371
372int
373mac_prepare_ifnet_label(struct mac **mac)
374{
370 if (strcmp(name, ld->ld_name) == 0)
371 return (mac_prepare(mac, ld->ld_labels));
372 }
373
374 errno = ENOENT;
375 return (-1); /* XXXMAC: ENOLABEL */
376}
377
378int
379mac_prepare_ifnet_label(struct mac **mac)
380{
375 int error;
376
381
377 error = mac_maybe_init_internal();
378 if (error != 0)
379 return (error);
380
381 return (mac_prepare_type(mac, "ifnet"));
382}
383
384int
385mac_prepare_file_label(struct mac **mac)
386{
382 return (mac_prepare_type(mac, "ifnet"));
383}
384
385int
386mac_prepare_file_label(struct mac **mac)
387{
387 int error;
388
388
389 error = mac_maybe_init_internal();
390 if (error != 0)
391 return (error);
392
393 return (mac_prepare_type(mac, "file"));
394}
395
396int
397mac_prepare_packet_label(struct mac **mac)
398{
389 return (mac_prepare_type(mac, "file"));
390}
391
392int
393mac_prepare_packet_label(struct mac **mac)
394{
399 int error;
400
395
401 error = mac_maybe_init_internal();
402 if (error != 0)
403 return (error);
404
405 return (mac_prepare_type(mac, "packet"));
406}
407
408int
409mac_prepare_process_label(struct mac **mac)
410{
396 return (mac_prepare_type(mac, "packet"));
397}
398
399int
400mac_prepare_process_label(struct mac **mac)
401{
411 int error;
412
402
413 error = mac_maybe_init_internal();
414 if (error != 0)
415 return (error);
416
417 return (mac_prepare_type(mac, "process"));
418}
419
420/*
421 * Simply test whether the TrustedBSD/MAC MIB tree is present; if so,
422 * return 1 to indicate that the system has MAC enabled overall or for
423 * a given policy.
424 */

--- 38 unchanged lines hidden ---
403 return (mac_prepare_type(mac, "process"));
404}
405
406/*
407 * Simply test whether the TrustedBSD/MAC MIB tree is present; if so,
408 * return 1 to indicate that the system has MAC enabled overall or for
409 * a given policy.
410 */

--- 38 unchanged lines hidden ---