• 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 "semanage/modules.h"
28 
29 
30 int semanage_module_upgrade_file(semanage_handle_t * sh,
31 				 const char *module_name);
32 int semanage_module_install_base_file(semanage_handle_t * sh,
33 				 const char *module_name);
34 
35 /* Module Info */
36 struct semanage_module_info {
37 	uint16_t priority;	/* key, module priority */
38 	char *name;		/* key, module name */
39 	char *lang_ext;		/* module source language extension */
40 	int enabled;		/* module enabled/disabled status */
41 };
42 
43 /* Initializes a pre-allocated module info struct.
44  *
45  * Returns 0 on success and -1 on error.
46  */
47 int semanage_module_info_init(semanage_handle_t *sh,
48 			      semanage_module_info_t *modinfo);
49 
50 /* Clones module info @source's members into module info @target.
51  *
52  * Returns 0 on success and -1 on error.
53  */
54 int semanage_module_info_clone(semanage_handle_t *sh,
55 			       const semanage_module_info_t *source,
56 			       semanage_module_info_t *target);
57 
58 /* Convert a cstring to a priority.
59  *
60  * Returns 0 on success and -1 on error.
61  */
62 int semanage_string_to_priority(const char *str, uint16_t *priority);
63 
64 int semanage_module_info_validate(const semanage_module_info_t *modinfo);
65 int semanage_module_validate_priority(uint16_t priority);
66 int semanage_module_validate_name(const char *name);
67 int semanage_module_validate_enabled(int enabled);
68 int semanage_module_validate_lang_ext(const char *ext);
69 int semanage_module_validate_version(const char *version);
70 
71 /* Module Key */
72 struct semanage_module_key {
73 	uint16_t priority;	/* module priority */
74 	char *name;		/* module name */
75 };
76 
77 /* Initializes a pre-allocated module key struct.
78  *
79  * Returns 0 on success, and -1 on error.
80  */
81 int semanage_module_key_init(semanage_handle_t *sh,
82 			     semanage_module_key_t *modkey);
83 
84 /* Module Paths */
85 
86 enum semanage_module_path_type {
87 	SEMANAGE_MODULE_PATH_PRIORITY,
88 	SEMANAGE_MODULE_PATH_NAME,
89 	SEMANAGE_MODULE_PATH_HLL,
90 	SEMANAGE_MODULE_PATH_CIL,
91 	SEMANAGE_MODULE_PATH_LANG_EXT,
92 	SEMANAGE_MODULE_PATH_DISABLED,
93 };
94 
95 /* Get the module path for the given path @type.
96  *
97  * Returns 0 on success and -1 on error.
98  */
99 int semanage_module_get_path(semanage_handle_t *sh,
100 			     const semanage_module_info_t *module,
101 			     enum semanage_module_path_type type,
102 			     char *path,
103 			     size_t len);
104 
105 extern const size_t CHECKSUM_CONTENT_SIZE;
106 void semanage_hash_to_checksum_string(const uint8_t *hash, char *checksum);
107 
108 #endif
109