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
20struct semanage_port;
21struct semanage_port_key;
22typedef struct semanage_port record_t;
23typedef struct semanage_port_key record_key_t;
24#define DBASE_RECORD_DEFINED
25
26struct dbase_policydb;
27typedef struct dbase_policydb dbase_t;
28#define DBASE_DEFINED
29
30#include <sepol/ports.h>
31#include <semanage/handle.h>
32#include "port_internal.h"
33#include "debug.h"
34#include "database_policydb.h"
35#include "semanage_store.h"
36
37/* PORT RECORD (SEPOL): POLICYDB extension : method table */
38record_policydb_table_t SEMANAGE_PORT_POLICYDB_RTABLE = {
39	.add = NULL,
40	.modify = (record_policydb_table_modify_t) sepol_port_modify,
41	.set = NULL,
42	.query = (record_policydb_table_query_t) sepol_port_query,
43	.count = (record_policydb_table_count_t) sepol_port_count,
44	.exists = (record_policydb_table_exists_t) sepol_port_exists,
45	.iterate = (record_policydb_table_iterate_t) sepol_port_iterate,
46};
47
48int port_policydb_dbase_init(semanage_handle_t * handle,
49			     dbase_config_t * dconfig)
50{
51
52	if (dbase_policydb_init(handle,
53				semanage_final_path(SEMANAGE_FINAL_SELINUX,
54						    SEMANAGE_KERNEL),
55				semanage_final_path(SEMANAGE_FINAL_TMP,
56						    SEMANAGE_KERNEL),
57				&SEMANAGE_PORT_RTABLE,
58				&SEMANAGE_PORT_POLICYDB_RTABLE,
59				&dconfig->dbase) < 0)
60		return STATUS_ERR;
61
62	dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
63
64	return STATUS_SUCCESS;
65}
66
67void port_policydb_dbase_release(dbase_config_t * dconfig)
68{
69
70	dbase_policydb_release(dconfig->dbase);
71}
72