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
19 /* Copyright (C) 2005 Red Hat, Inc. */
20
21 struct semanage_bool;
22 struct semanage_bool_key;
23 typedef struct semanage_bool record_t;
24 typedef struct semanage_bool_key record_key_t;
25 #define DBASE_RECORD_DEFINED
26
27 struct dbase_policydb;
28 typedef struct dbase_policydb dbase_t;
29 #define DBASE_DEFINED
30
31 #include <sepol/booleans.h>
32 #include <semanage/handle.h>
33 #include "boolean_internal.h"
34 #include "debug.h"
35 #include "database_policydb.h"
36 #include "semanage_store.h"
37
38 /* BOOLEAN RECRORD (SEPOL): POLICYDB extension: method table */
39 record_policydb_table_t SEMANAGE_BOOL_POLICYDB_RTABLE = {
40 .add = NULL,
41 .modify = NULL,
42 /* FIXME: these casts depend on structs in libsepol matching structs
43 * in libsemanage. This is incredibly fragile - the casting gets
44 * rid of warnings, but is not type safe.
45 */
46 .set = (record_policydb_table_set_t) sepol_bool_set,
47 .query = (record_policydb_table_query_t) sepol_bool_query,
48 .count = (record_policydb_table_count_t) sepol_bool_count,
49 .exists = (record_policydb_table_exists_t) sepol_bool_exists,
50 .iterate = (record_policydb_table_iterate_t) sepol_bool_iterate,
51 };
52
bool_policydb_dbase_init(semanage_handle_t * handle,dbase_config_t * dconfig)53 int bool_policydb_dbase_init(semanage_handle_t * handle,
54 dbase_config_t * dconfig)
55 {
56
57 if (dbase_policydb_init(handle,
58 semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL),
59 semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL),
60 &SEMANAGE_BOOL_RTABLE,
61 &SEMANAGE_BOOL_POLICYDB_RTABLE,
62 &dconfig->dbase) < 0)
63 return STATUS_ERR;
64
65 dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
66 return STATUS_SUCCESS;
67 }
68
bool_policydb_dbase_release(dbase_config_t * dconfig)69 void bool_policydb_dbase_release(dbase_config_t * dconfig)
70 {
71
72 dbase_policydb_release(dconfig->dbase);
73 }
74