• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 struct semanage_user_base;
21 struct semanage_user_key;
22 typedef struct semanage_user_base record_t;
23 typedef struct semanage_user_key record_key_t;
24 #define DBASE_RECORD_DEFINED
25 
26 struct dbase_policydb;
27 typedef struct dbase_policydb dbase_t;
28 #define DBASE_DEFINED
29 
30 #include <sepol/users.h>
31 #include <semanage/handle.h>
32 #include "user_internal.h"
33 #include "debug.h"
34 #include "database_policydb.h"
35 #include "semanage_store.h"
36 
37 /* USER BASE record: POLICYDB extension: method table */
38 record_policydb_table_t SEMANAGE_USER_BASE_POLICYDB_RTABLE = {
39 	.add = NULL,
40 	.modify = (record_policydb_table_modify_t) sepol_user_modify,
41 	.set = NULL,
42 	.query = (record_policydb_table_query_t) sepol_user_query,
43 	.count = (record_policydb_table_count_t) sepol_user_count,
44 	.exists = (record_policydb_table_exists_t) sepol_user_exists,
45 	.iterate = (record_policydb_table_iterate_t) sepol_user_iterate,
46 };
47 
user_base_policydb_dbase_init(semanage_handle_t * handle,dbase_config_t * dconfig)48 int user_base_policydb_dbase_init(semanage_handle_t * handle,
49 				  dbase_config_t * dconfig)
50 {
51 
52 	if (dbase_policydb_init(handle,
53 				semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL),
54 				semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL),
55 				&SEMANAGE_USER_BASE_RTABLE,
56 				&SEMANAGE_USER_BASE_POLICYDB_RTABLE,
57 				&dconfig->dbase) < 0)
58 		return STATUS_ERR;
59 
60 	dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE;
61 	return STATUS_SUCCESS;
62 }
63 
user_base_policydb_dbase_release(dbase_config_t * dconfig)64 void user_base_policydb_dbase_release(dbase_config_t * dconfig)
65 {
66 
67 	dbase_policydb_release(dconfig->dbase);
68 }
69