• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Author: Joshua Brindle <jbrindle@tresys.com>
2  *         Jason Tang     <jtang@tresys.com>
3  *         Caleb Case     <ccase@tresys.com>
4  *
5  * Copyright (C) 2005,2009 Tresys Technology, LLC
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public
9  *  License as published by the Free Software Foundation; either
10  *  version 2.1 of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef _SEMANAGE_INTERNAL_MODULES_H_
23 #define _SEMANAGE_INTERNAL_MODULES_H_
24 
25 #include <stdint.h>
26 
27 #include "module_internal.h"
28 
29 int semanage_module_install_pp(semanage_handle_t * sh,
30 			    char *module_data, size_t data_len);
31 int semanage_module_install_hll(semanage_handle_t * sh,
32 			    char *module_data, size_t data_len, const char *name, const char *ext_lang);
33 int semanage_module_upgrade(semanage_handle_t * sh,
34 			    char *module_data, size_t data_len);
35 int semanage_module_upgrade_file(semanage_handle_t * sh,
36 				 const char *module_name);
37 int semanage_module_install_base(semanage_handle_t * sh,
38 				 char *module_data, size_t data_len);
39 int semanage_module_install_base_file(semanage_handle_t * sh,
40 				 const char *module_name);
41 
42 /* Module Info */
43 struct semanage_module_info {
44 	uint16_t priority;	/* key, module priority */
45 	char *name;		/* key, module name */
46 	char *lang_ext;		/* module source language extension */
47 	int enabled;		/* module enabled/disabled status */
48 };
49 
50 /* Initializes a pre-allocated module info struct.
51  *
52  * Returns 0 on success and -1 on error.
53  */
54 int semanage_module_info_init(semanage_handle_t *sh,
55 			      semanage_module_info_t *modinfo);
56 
57 /* Clones module info @source's members into module info @target.
58  *
59  * Returns 0 on success and -1 on error.
60  */
61 int semanage_module_info_clone(semanage_handle_t *sh,
62 			       const semanage_module_info_t *source,
63 			       semanage_module_info_t *target);
64 
65 /* Convert a cstring to a priority.
66  *
67  * Returns 0 on success and -1 on error.
68  */
69 int semanage_string_to_priority(const char *str, uint16_t *priority);
70 
71 int semanage_module_info_validate(const semanage_module_info_t *modinfo);
72 int semanage_module_validate_priority(uint16_t priority);
73 int semanage_module_validate_name(const char *name);
74 int semanage_module_validate_enabled(int enabled);
75 int semanage_module_validate_lang_ext(const char *ext);
76 int semanage_module_validate_version(const char *version);
77 
78 /* Module Key */
79 struct semanage_module_key {
80 	uint16_t priority;	/* module priority */
81 	char *name;		/* module name */
82 };
83 
84 /* Initializes a pre-allocated module key struct.
85  *
86  * Returns 0 on success, and -1 on error.
87  */
88 int semanage_module_key_init(semanage_handle_t *sh,
89 			     semanage_module_key_t *modkey);
90 
91 /* Module Paths */
92 
93 enum semanage_module_path_type {
94 	SEMANAGE_MODULE_PATH_PRIORITY,
95 	SEMANAGE_MODULE_PATH_NAME,
96 	SEMANAGE_MODULE_PATH_HLL,
97 	SEMANAGE_MODULE_PATH_CIL,
98 	SEMANAGE_MODULE_PATH_LANG_EXT,
99 	SEMANAGE_MODULE_PATH_DISABLED,
100 };
101 
102 /* Get the module path for the given path @type.
103  *
104  * Returns 0 on success and -1 on error.
105  */
106 int semanage_module_get_path(semanage_handle_t *sh,
107 			     const semanage_module_info_t *module,
108 			     enum semanage_module_path_type type,
109 			     char *path,
110 			     size_t len);
111 
112 #endif
113