Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2006 Tresys Technology, LLC
      3  *
      4  *  This library is free software; you can redistribute it and/or
      5  *  modify it under the terms of the GNU Lesser General Public
      6  *  License as published by the Free Software Foundation; either
      7  *  version 2.1 of the License, or (at your option) any later version.
      8  *
      9  *  This library is distributed in the hope that it will be useful,
     10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  *  Lesser General Public License for more details.
     13  *
     14  *  You should have received a copy of the GNU Lesser General Public
     15  *  License along with this library; if not, write to the Free Software
     16  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     17  */
     18 /* Copyright (C) 2005 Red Hat, Inc. */
     19 
     20 struct semanage_node;
     21 struct semanage_node_key;
     22 typedef struct semanage_node record_t;
     23 typedef struct semanage_node_key record_key_t;
     24 #define DBASE_RECORD_DEFINED
     25 
     26 struct dbase_policydb;
     27 typedef struct dbase_policydb dbase_t;
     28 #define DBASE_DEFINED
     29 
     30 #include <sepol/nodes.h>
     31 #include <semanage/handle.h>
     32 #include "node_internal.h"
     33 #include "debug.h"
     34 #include "database_policydb.h"
     35 #include "semanage_store.h"
     36 
     37 /* NODE RECORD (SEPOL): POLICYDB extension : method table */
     38 record_policydb_table_t SEMANAGE_NODE_POLICYDB_RTABLE = {
     39 	.add = NULL,
     40 	.modify = (record_policydb_table_modify_t) sepol_node_modify,
     41 	.set = NULL,
     42 	.query = (record_policydb_table_query_t) sepol_node_query,
     43 	.count = (record_policydb_table_count_t) sepol_node_count,
     44 	.exists = (record_policydb_table_exists_t) sepol_node_exists,
     45 	.iterate = (record_policydb_table_iterate_t) sepol_node_iterate,
     46 };
     47 
     48 int node_policydb_dbase_init(semanage_handle_t * handle,
     49 			     dbase_config_t * dconfig)
     50 {
     51 
     52 	if (dbase_policydb_init(handle,
     53 				semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL),
     54 				semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL),
     55 				&SEMANAGE_NODE_RTABLE,
     56 				&SEMANAGE_NODE_POLICYDB_RTABLE,
     57 				&dconfig->dbase) < 0)
     58 		return STATUS_ERR;
     59 
     60 	dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
     61 
     62 	return STATUS_SUCCESS;
     63 }
     64 
     65 void node_policydb_dbase_release(dbase_config_t * dconfig)
     66 {
     67 
     68 	dbase_policydb_release(dconfig->dbase);
     69 }
     70