1 /*
2 * Copyright (C) 2017 Mellanox Technologies Inc
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
15 struct semanage_ibpkey;
16 struct semanage_ibpkey_key;
17 typedef struct semanage_ibpkey record_t;
18 typedef struct semanage_ibpkey_key record_key_t;
19 #define DBASE_RECORD_DEFINED
20
21 struct dbase_policydb;
22 typedef struct dbase_policydb dbase_t;
23 #define DBASE_DEFINED
24
25 #include <sepol/ibpkeys.h>
26 #include <semanage/handle.h>
27 #include "ibpkey_internal.h"
28 #include "debug.h"
29 #include "database_policydb.h"
30 #include "semanage_store.h"
31
32 /* PKEY RECORD (SEPOL): POLICYDB extension : method table */
33 record_policydb_table_t SEMANAGE_IBPKEY_POLICYDB_RTABLE = {
34 .add = NULL,
35 .modify = (record_policydb_table_modify_t)sepol_ibpkey_modify,
36 .set = NULL,
37 .query = (record_policydb_table_query_t)sepol_ibpkey_query,
38 .count = (record_policydb_table_count_t)sepol_ibpkey_count,
39 .exists = (record_policydb_table_exists_t)sepol_ibpkey_exists,
40 .iterate = (record_policydb_table_iterate_t)sepol_ibpkey_iterate,
41 };
42
ibpkey_policydb_dbase_init(semanage_handle_t * handle,dbase_config_t * dconfig)43 int ibpkey_policydb_dbase_init(semanage_handle_t *handle,
44 dbase_config_t *dconfig)
45 {
46 if (dbase_policydb_init(handle,
47 semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL),
48 semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL),
49 &SEMANAGE_IBPKEY_RTABLE,
50 &SEMANAGE_IBPKEY_POLICYDB_RTABLE,
51 &dconfig->dbase) < 0)
52 return STATUS_ERR;
53
54 dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
55
56 return STATUS_SUCCESS;
57 }
58
ibpkey_policydb_dbase_release(dbase_config_t * dconfig)59 void ibpkey_policydb_dbase_release(dbase_config_t *dconfig)
60 {
61 dbase_policydb_release(dconfig->dbase);
62 }
63