xref: /aosp_15_r20/external/selinux/libsemanage/src/ibendports_policydb.c (revision 2d543d20722ada2425b5bdab9d0d1d29470e7bba)
1*2d543d20SAndroid Build Coastguard Worker /*
2*2d543d20SAndroid Build Coastguard Worker  * Copyright (C) 2017 Mellanox Technologies Inc
3*2d543d20SAndroid Build Coastguard Worker  *
4*2d543d20SAndroid Build Coastguard Worker  *  This library is free software; you can redistribute it and/or
5*2d543d20SAndroid Build Coastguard Worker  *  modify it under the terms of the GNU Lesser General Public
6*2d543d20SAndroid Build Coastguard Worker  *  License as published by the Free Software Foundation; either
7*2d543d20SAndroid Build Coastguard Worker  *  version 2.1 of the License, or (at your option) any later version.
8*2d543d20SAndroid Build Coastguard Worker  *
9*2d543d20SAndroid Build Coastguard Worker  *  This library is distributed in the hope that it will be useful,
10*2d543d20SAndroid Build Coastguard Worker  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11*2d543d20SAndroid Build Coastguard Worker  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*2d543d20SAndroid Build Coastguard Worker  *  Lesser General Public License for more details.
13*2d543d20SAndroid Build Coastguard Worker  */
14*2d543d20SAndroid Build Coastguard Worker 
15*2d543d20SAndroid Build Coastguard Worker struct semanage_ibendport;
16*2d543d20SAndroid Build Coastguard Worker struct semanage_ibendport_key;
17*2d543d20SAndroid Build Coastguard Worker typedef struct semanage_ibendport record_t;
18*2d543d20SAndroid Build Coastguard Worker typedef struct semanage_ibendport_key record_key_t;
19*2d543d20SAndroid Build Coastguard Worker #define DBASE_RECORD_DEFINED
20*2d543d20SAndroid Build Coastguard Worker 
21*2d543d20SAndroid Build Coastguard Worker struct dbase_policydb;
22*2d543d20SAndroid Build Coastguard Worker typedef struct dbase_policydb dbase_t;
23*2d543d20SAndroid Build Coastguard Worker #define DBASE_DEFINED
24*2d543d20SAndroid Build Coastguard Worker 
25*2d543d20SAndroid Build Coastguard Worker #include <sepol/ibendports.h>
26*2d543d20SAndroid Build Coastguard Worker #include <semanage/handle.h>
27*2d543d20SAndroid Build Coastguard Worker #include "ibendport_internal.h"
28*2d543d20SAndroid Build Coastguard Worker #include "debug.h"
29*2d543d20SAndroid Build Coastguard Worker #include "database_policydb.h"
30*2d543d20SAndroid Build Coastguard Worker #include "semanage_store.h"
31*2d543d20SAndroid Build Coastguard Worker 
32*2d543d20SAndroid Build Coastguard Worker /* IBENDPORT RECORD (SEPOL): POLICYDB extension : method table */
33*2d543d20SAndroid Build Coastguard Worker record_policydb_table_t SEMANAGE_IBENDPORT_POLICYDB_RTABLE = {
34*2d543d20SAndroid Build Coastguard Worker 	.add = NULL,
35*2d543d20SAndroid Build Coastguard Worker 	.modify = (record_policydb_table_modify_t)sepol_ibendport_modify,
36*2d543d20SAndroid Build Coastguard Worker 	.set = NULL,
37*2d543d20SAndroid Build Coastguard Worker 	.query = (record_policydb_table_query_t)sepol_ibendport_query,
38*2d543d20SAndroid Build Coastguard Worker 	.count = (record_policydb_table_count_t)sepol_ibendport_count,
39*2d543d20SAndroid Build Coastguard Worker 	.exists = (record_policydb_table_exists_t)sepol_ibendport_exists,
40*2d543d20SAndroid Build Coastguard Worker 	.iterate = (record_policydb_table_iterate_t)sepol_ibendport_iterate,
41*2d543d20SAndroid Build Coastguard Worker };
42*2d543d20SAndroid Build Coastguard Worker 
ibendport_policydb_dbase_init(semanage_handle_t * handle,dbase_config_t * dconfig)43*2d543d20SAndroid Build Coastguard Worker int ibendport_policydb_dbase_init(semanage_handle_t *handle,
44*2d543d20SAndroid Build Coastguard Worker 				  dbase_config_t *dconfig)
45*2d543d20SAndroid Build Coastguard Worker {
46*2d543d20SAndroid Build Coastguard Worker 	if (dbase_policydb_init(handle,
47*2d543d20SAndroid Build Coastguard Worker 				semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL),
48*2d543d20SAndroid Build Coastguard Worker 				semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL),
49*2d543d20SAndroid Build Coastguard Worker 				&SEMANAGE_IBENDPORT_RTABLE,
50*2d543d20SAndroid Build Coastguard Worker 				&SEMANAGE_IBENDPORT_POLICYDB_RTABLE,
51*2d543d20SAndroid Build Coastguard Worker 				&dconfig->dbase) < 0)
52*2d543d20SAndroid Build Coastguard Worker 		return STATUS_ERR;
53*2d543d20SAndroid Build Coastguard Worker 
54*2d543d20SAndroid Build Coastguard Worker 	dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
55*2d543d20SAndroid Build Coastguard Worker 
56*2d543d20SAndroid Build Coastguard Worker 	return STATUS_SUCCESS;
57*2d543d20SAndroid Build Coastguard Worker }
58*2d543d20SAndroid Build Coastguard Worker 
ibendport_policydb_dbase_release(dbase_config_t * dconfig)59*2d543d20SAndroid Build Coastguard Worker void ibendport_policydb_dbase_release(dbase_config_t *dconfig)
60*2d543d20SAndroid Build Coastguard Worker {
61*2d543d20SAndroid Build Coastguard Worker 	dbase_policydb_release(dconfig->dbase);
62*2d543d20SAndroid Build Coastguard Worker }
63