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
21struct semanage_bool;
22struct semanage_bool_key;
23typedef struct semanage_bool record_t;
24typedef struct semanage_bool_key record_key_t;
25#define DBASE_RECORD_DEFINED
26
27struct dbase_policydb;
28typedef 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 */
39record_policydb_table_t SEMANAGE_BOOL_POLICYDB_RTABLE = {
40	.add = NULL,
41	.modify = NULL,
42/* FIXME: these casts depend on stucts 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
53int bool_policydb_dbase_init(semanage_handle_t * handle,
54			     dbase_config_t * dconfig)
55{
56
57	if (dbase_policydb_init(handle,
58				semanage_final_path(SEMANAGE_FINAL_SELINUX,
59						    SEMANAGE_KERNEL),
60				semanage_final_path(SEMANAGE_FINAL_TMP,
61						    SEMANAGE_KERNEL),
62				&SEMANAGE_BOOL_RTABLE,
63				&SEMANAGE_BOOL_POLICYDB_RTABLE,
64				&dconfig->dbase) < 0)
65		return STATUS_ERR;
66
67	dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
68	return STATUS_SUCCESS;
69}
70
71void bool_policydb_dbase_release(dbase_config_t * dconfig)
72{
73
74	dbase_policydb_release(dconfig->dbase);
75}
76