Home | History | Annotate | Line # | Download | only in bsd44
secmodel_bsd44.c revision 1.15.10.1
      1 /* $NetBSD: secmodel_bsd44.c,v 1.15.10.1 2014/05/18 17:46:20 rmind Exp $ */
      2 /*-
      3  * Copyright (c) 2006 Elad Efrat <elad (at) NetBSD.org>
      4  * All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. The name of the author may not be used to endorse or promote products
     15  *    derived from this software without specific prior written permission.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #include <sys/cdefs.h>
     30 __KERNEL_RCSID(0, "$NetBSD: secmodel_bsd44.c,v 1.15.10.1 2014/05/18 17:46:20 rmind Exp $");
     31 
     32 #include <sys/types.h>
     33 #include <sys/param.h>
     34 #include <sys/kauth.h>
     35 
     36 #include <sys/sysctl.h>
     37 #include <sys/mount.h>
     38 
     39 #include <sys/module.h>
     40 
     41 #include <secmodel/bsd44/bsd44.h>
     42 #include <secmodel/suser/suser.h>
     43 #include <secmodel/securelevel/securelevel.h>
     44 #include <secmodel/extensions/extensions.h>
     45 
     46 MODULE(MODULE_CLASS_SECMODEL, secmodel_bsd44, "suser,securelevel,extensions");
     47 
     48 static secmodel_t bsd44_sm;
     49 static struct sysctllog *sysctl_bsd44_log;
     50 
     51 void
     52 sysctl_security_bsd44_setup(struct sysctllog **clog)
     53 {
     54 	const struct sysctlnode *rnode;
     55 
     56 	sysctl_createv(clog, 0, NULL, &rnode,
     57 		       CTLFLAG_PERMANENT,
     58 		       CTLTYPE_NODE, "models", NULL,
     59 		       NULL, 0, NULL, 0,
     60 		       CTL_SECURITY, CTL_CREATE, CTL_EOL);
     61 
     62 	sysctl_createv(clog, 0, &rnode, &rnode,
     63 		       CTLFLAG_PERMANENT,
     64 		       CTLTYPE_NODE, "bsd44", NULL,
     65 		       NULL, 0, NULL, 0,
     66 		       CTL_CREATE, CTL_EOL);
     67 
     68 	sysctl_createv(clog, 0, &rnode, NULL,
     69 		       CTLFLAG_PERMANENT,
     70 		       CTLTYPE_STRING, "name", NULL,
     71 		       NULL, 0,
     72 		       __UNCONST(SECMODEL_BSD44_NAME), 0,
     73 		       CTL_CREATE, CTL_EOL);
     74 }
     75 
     76 void
     77 secmodel_bsd44_init(void)
     78 {
     79 
     80 }
     81 
     82 void
     83 secmodel_bsd44_start(void)
     84 {
     85 
     86 }
     87 
     88 void
     89 secmodel_bsd44_stop(void)
     90 {
     91 
     92 }
     93 
     94 static int
     95 secmodel_bsd44_modcmd(modcmd_t cmd, void *arg)
     96 {
     97 	int error = 0;
     98 
     99 	switch (cmd) {
    100 	case MODULE_CMD_INIT:
    101 
    102 		error = secmodel_register(&bsd44_sm,
    103 		    SECMODEL_BSD44_ID, SECMODEL_BSD44_NAME,
    104 		    NULL, NULL, NULL);
    105 		if (error != 0)
    106 			printf("secmodel_bsd44_modcmd::init: "
    107 			    "secmodel_register returned %d\n", error);
    108 
    109 		secmodel_bsd44_init();
    110 		secmodel_bsd44_start();
    111 		sysctl_security_bsd44_setup(&sysctl_bsd44_log);
    112 		break;
    113 
    114 	case MODULE_CMD_FINI:
    115 		sysctl_teardown(&sysctl_bsd44_log);
    116 		secmodel_bsd44_stop();
    117 
    118 		error = secmodel_deregister(bsd44_sm);
    119 		if (error != 0)
    120 			printf("secmodel_bsd44_modcmd::fini: "
    121 			    "secmodel_deregister returned %d\n", error);
    122 		break;
    123 
    124 	default:
    125 		error = ENOTTY;
    126 		break;
    127 	}
    128 
    129 	return error;
    130 }
    131 
    132