Home | History | Annotate | Line # | Download | only in bsd44
      1 /* $NetBSD: secmodel_bsd44.c,v 1.17 2020/03/16 21:20:12 pgoyette 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.17 2020/03/16 21:20:12 pgoyette 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 
     50 SYSCTL_SETUP(sysctl_security_bsd44_setup, "secmodel_bsd44 sysctl")
     51 {
     52 	const struct sysctlnode *rnode;
     53 
     54 	sysctl_createv(clog, 0, NULL, &rnode,
     55 		       CTLFLAG_PERMANENT,
     56 		       CTLTYPE_NODE, "models", NULL,
     57 		       NULL, 0, NULL, 0,
     58 		       CTL_SECURITY, CTL_CREATE, CTL_EOL);
     59 
     60 	sysctl_createv(clog, 0, &rnode, &rnode,
     61 		       CTLFLAG_PERMANENT,
     62 		       CTLTYPE_NODE, "bsd44", NULL,
     63 		       NULL, 0, NULL, 0,
     64 		       CTL_CREATE, CTL_EOL);
     65 
     66 	sysctl_createv(clog, 0, &rnode, NULL,
     67 		       CTLFLAG_PERMANENT,
     68 		       CTLTYPE_STRING, "name", NULL,
     69 		       NULL, 0,
     70 		       __UNCONST(SECMODEL_BSD44_NAME), 0,
     71 		       CTL_CREATE, CTL_EOL);
     72 }
     73 
     74 void
     75 secmodel_bsd44_init(void)
     76 {
     77 
     78 }
     79 
     80 void
     81 secmodel_bsd44_start(void)
     82 {
     83 
     84 }
     85 
     86 void
     87 secmodel_bsd44_stop(void)
     88 {
     89 
     90 }
     91 
     92 static int
     93 secmodel_bsd44_modcmd(modcmd_t cmd, void *arg)
     94 {
     95 	int error = 0;
     96 
     97 	switch (cmd) {
     98 	case MODULE_CMD_INIT:
     99 
    100 		error = secmodel_register(&bsd44_sm,
    101 		    SECMODEL_BSD44_ID, SECMODEL_BSD44_NAME,
    102 		    NULL, NULL, NULL);
    103 		if (error != 0)
    104 			printf("secmodel_bsd44_modcmd::init: "
    105 			    "secmodel_register returned %d\n", error);
    106 
    107 		secmodel_bsd44_init();
    108 		secmodel_bsd44_start();
    109 		break;
    110 
    111 	case MODULE_CMD_FINI:
    112 		secmodel_bsd44_stop();
    113 
    114 		error = secmodel_deregister(bsd44_sm);
    115 		if (error != 0)
    116 			printf("secmodel_bsd44_modcmd::fini: "
    117 			    "secmodel_deregister returned %d\n", error);
    118 		break;
    119 
    120 	default:
    121 		error = ENOTTY;
    122 		break;
    123 	}
    124 
    125 	return error;
    126 }
    127 
    128