mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-29 09:22:06 +00:00
libsemanage: add functions to public api
include/semanage/handle.h * Exports the handle get/set default priority functions. include/semanage/module.h * Exports the module info management functions. * Exports the get/set enabled status functions. * Exports the module key management functions. * Exports the module install, upgrade, remove info/key functions. include/semanage/semanage.h This patch includes the modifications to the map file for exporting the necessary functions. Examples: /* changing the default priority for a distro install */ semanage_set_default_priority(sh, 100); /* creating module meta data */ semanage_module_info_t *modinfo = NULL; semanage_module_info_create(sh, &modinfo); /* filling in that data */ semanage_module_info_set_priority( sh, modinfo, semanage_get_default_priority(sh)); semanage_module_info_set_name( sh, modinfo, "mymodule"); semanage_module_info_set_version( sh, modinfo, "0.1.2"); semanage_module_info_set_lang_ext( sh, modinfo, "pp"); semanage_module_info_set_enabled( sh, modinfo, -1); /* Sets enabled to default: * If the module was already enabled/disabled * then it will remain so after install. * If it wasn't, then it will be enabled. */ /* install the module */ semanage_module_install_info(sh, modinfo, data, data_len); /* cleanup modinfo */ semanage_module_info_destroy(sh, modinfo); /* create a key for retrieving a module's meta data */ semanage_module_key_t *modkey = NULL; semanage_module_key_create(sh, &modkey); /* Only set the module name, this will find the highest * priority module of that name. */ semanage_module_key_set_name(sh, modkey, "mymodule"); /* get the newly installed module */ semanage_module_get_module_info(sh, modkey, &modinfo); /* get the priority of the module found */ uint16_t priority = 0; semanage_module_info_get_priority(sh, modinfo, &priority); /* set the priority in the key to the one found */ semanage_module_key_set_priority(sh, modkey, priority); /* remove the highest priority module with the name "mymodule" */ semanage_module_remove_key(sh, modkey); /* print all the modules installed */ semanage_module_info_t *modinfos = NULL; int modinfos_len = 0; semanage_module_list_all(sh, &modinfos, &modinfos_len); char *name = NULL; int i = 0; for (i = 0; i < modinfos_len; i++) { semanage_module_info_get_priority( sh, semanage_module_list_nth(modinfos, i), &priority); semanage_module_info_get_name( sh, semanage_module_list_nth(modinfos, i), &name); printf("%d\t%s\n", priority, name); } Signed-off-by: Chad Sellers <csellers@tresys.com>
This commit is contained in:
parent
bb5121efbd
commit
1875c85d5b
@ -21,6 +21,8 @@
|
||||
#ifndef _SEMANAGE_HANDLE_H_
|
||||
#define _SEMANAGE_HANDLE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* All accesses with semanage are through a "semanage_handle". The
|
||||
* handle may ultimately reference local config files,
|
||||
* the binary policy file, a module store, or a policy management server.
|
||||
@ -78,6 +80,12 @@ void semanage_set_disable_dontaudit(semanage_handle_t * handle, int disable_dont
|
||||
/* Set whether or not to execute setfiles to check file contexts upon commit */
|
||||
void semanage_set_check_contexts(semanage_handle_t * sh, int do_check_contexts);
|
||||
|
||||
/* Get the default priority. */
|
||||
uint16_t semanage_get_default_priority(semanage_handle_t *sh);
|
||||
|
||||
/* Set the default priority. */
|
||||
int semanage_set_default_priority(semanage_handle_t *sh, uint16_t priority);
|
||||
|
||||
/* Check whether policy is managed via libsemanage on this system.
|
||||
* Must be called prior to trying to connect.
|
||||
* Return 1 if policy is managed via libsemanage on this system,
|
||||
|
@ -22,8 +22,11 @@
|
||||
#define _SEMANAGE_MODULES_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <semanage/handle.h>
|
||||
|
||||
typedef struct semanage_module_key semanage_module_key_t;
|
||||
|
||||
/* High level module management functions. These are all part of
|
||||
* a transaction
|
||||
*/
|
||||
@ -54,4 +57,221 @@ semanage_module_info_t *semanage_module_list_nth(semanage_module_info_t * list,
|
||||
const char *semanage_module_get_name(semanage_module_info_t *);
|
||||
const char *semanage_module_get_version(semanage_module_info_t *);
|
||||
|
||||
/* Module Info */
|
||||
|
||||
/* Creates a module info struct.
|
||||
*
|
||||
* Returns 0 on success and -1 on failure.
|
||||
*
|
||||
* The @modinfo should be destroyed with semanage_module_info_destroy.
|
||||
* The caller should call free() on the struct.
|
||||
*/
|
||||
int semanage_module_info_create(semanage_handle_t *sh,
|
||||
semanage_module_info_t **modinfo);
|
||||
|
||||
/* Frees the members of the module info struct.
|
||||
*
|
||||
* Returns 0 on success and -1 on failure.
|
||||
*
|
||||
* The caller should call free() on the struct.
|
||||
*/
|
||||
int semanage_module_info_destroy(semanage_handle_t *handle,
|
||||
semanage_module_info_t *modinfo);
|
||||
|
||||
/* Module Info Getters */
|
||||
|
||||
/* Get @priority from @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_priority(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
uint16_t *priority);
|
||||
|
||||
/* Get @name from @modinfo. Caller should not free @name.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_name(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **name);
|
||||
|
||||
/* Get @lang_ext from @modinfo. Caller should not free @lang_ext.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_lang_ext(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **lang_ext);
|
||||
|
||||
/* Get @enabled from @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_enabled(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
int *enabled);
|
||||
|
||||
/* Module Info Setters */
|
||||
|
||||
/* Set @priority in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_priority(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
uint16_t priority);
|
||||
|
||||
/* Set @name in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_name(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *name);
|
||||
|
||||
/* Set @lang_ext in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_lang_ext(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *lang_ext);
|
||||
|
||||
/* Set @enabled in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_enabled(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
int enabled);
|
||||
|
||||
/* Module Key */
|
||||
|
||||
/* Creates a module key struct.
|
||||
*
|
||||
* Return 0 on success, and -1 on error.
|
||||
*
|
||||
* The @modkey should be destroyed with semanage_module_key_destroy.
|
||||
* The caller should call free() on the struct.
|
||||
*/
|
||||
int semanage_module_key_create(semanage_handle_t *sh,
|
||||
semanage_module_key_t **modkey);
|
||||
|
||||
/* Frees members of the @modkey, but not the struct. The caller should
|
||||
* call free() on struct.
|
||||
*
|
||||
* Returns 0 on success, and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_destroy(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey);
|
||||
|
||||
/* Module Key Getters */
|
||||
|
||||
/* Get @name from @modkey. Caller should not free @name.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_get_name(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
const char **name);
|
||||
|
||||
/* Get @name from @modkey.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_get_priority(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
uint16_t *priority);
|
||||
|
||||
/* Module Key Setters */
|
||||
|
||||
/* Set @name in @modkey.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_set_name(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
const char *name);
|
||||
|
||||
/* Set @priority in @modkey.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_set_priority(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
uint16_t priority);
|
||||
|
||||
/* Set module @enabled status from @modkey. Modules are enabled on a per
|
||||
* module name basis (across all priorities). @modkey only needs to have
|
||||
* name set (priority is ignored).
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_set_enabled(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
int enabled);
|
||||
|
||||
/* Lookup @modinfo by @modkey. Caller should use
|
||||
* semanage_module_info_destroy and free on @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_get_module_info(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
semanage_module_info_t **modinfo);
|
||||
|
||||
/* Create a list of all modules in @modinfos of length @modinfos_len.
|
||||
* The list will be sorted from high priority to low and alphabetically
|
||||
* by module name within a priority.
|
||||
*
|
||||
* Caller should use semanage_module_info_destroy on each modinfo in
|
||||
* @modinfos and free on @modinfos.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_list_all(semanage_handle_t *sh,
|
||||
semanage_module_info_t **modinfos,
|
||||
int *modinfos_len);
|
||||
|
||||
/* Install the module indicated by @modinfo with input data from
|
||||
* @module_data with length @data_len.
|
||||
*
|
||||
* @modinfo must have all values filled in.
|
||||
* @module_data may be bzip compressed.
|
||||
*
|
||||
* Returns:
|
||||
* 0 success
|
||||
* -1 failure, out of memory
|
||||
* -2 failure, invalid @modinfo
|
||||
* -3 failure, error writing file
|
||||
*/
|
||||
int semanage_module_install_info(semanage_handle_t *sh,
|
||||
const semanage_module_info_t *modinfo,
|
||||
char *data,
|
||||
size_t data_len);
|
||||
|
||||
/* Remove the module indicated by @modkey.
|
||||
* @modkey must have key values filled in.
|
||||
*
|
||||
* Returns:
|
||||
* 0 success
|
||||
* -1 failure, out of memeory
|
||||
* -2 failure, @module not found or couldn't be removed
|
||||
*/
|
||||
int semanage_module_remove_key(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey);
|
||||
|
||||
/* Module Enabled */
|
||||
|
||||
/* Get module @enabled status from @modkey. Modules are enabled on a per
|
||||
* module name basis (across all priorities). @modkey only needs to have
|
||||
* name set (priority is ignored).
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_get_enabled(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
int *enabled);
|
||||
|
||||
#endif
|
||||
|
@ -21,3 +21,35 @@ LIBSEMANAGE_1.0 {
|
||||
semanage_get_preserve_tunables; semanage_set_preserve_tunables;
|
||||
local: *;
|
||||
};
|
||||
|
||||
LIBSEMANAGE_1.1 {
|
||||
global:
|
||||
semanage_get_default_priority;
|
||||
semanage_set_default_priority;
|
||||
semanage_module_info_create;
|
||||
semanage_module_info_destroy;
|
||||
semanage_module_info_get_priority;
|
||||
semanage_module_info_get_name;
|
||||
semanage_module_info_get_version;
|
||||
semanage_module_info_get_lang_ext;
|
||||
semanage_module_info_get_enabled;
|
||||
semanage_module_info_set_priority;
|
||||
semanage_module_info_set_name;
|
||||
semanage_module_info_set_version;
|
||||
semanage_module_info_set_lang_ext;
|
||||
semanage_module_info_set_enabled;
|
||||
semanage_module_key_create;
|
||||
semanage_module_key_destroy;
|
||||
semanage_module_key_get_priority;
|
||||
semanage_module_key_get_name;
|
||||
semanage_module_key_set_priority;
|
||||
semanage_module_key_set_name;
|
||||
semanage_module_get_module_info;
|
||||
semanage_module_list_all;
|
||||
semanage_module_get_enabled;
|
||||
semanage_module_set_enabled;
|
||||
semanage_module_install_info;
|
||||
semanage_module_upgrade_info;
|
||||
semanage_module_remove_key;
|
||||
local: *;
|
||||
} LIBSEMANAGE_1.0;
|
||||
|
@ -8,4 +8,24 @@ hidden_proto(semanage_module_get_name)
|
||||
hidden_proto(semanage_module_get_version)
|
||||
hidden_proto(semanage_module_info_datum_destroy)
|
||||
hidden_proto(semanage_module_list_nth)
|
||||
hidden_proto(semanage_module_info_create)
|
||||
hidden_proto(semanage_module_info_destroy)
|
||||
hidden_proto(semanage_module_info_get_priority)
|
||||
hidden_proto(semanage_module_info_get_name)
|
||||
hidden_proto(semanage_module_info_get_version)
|
||||
hidden_proto(semanage_module_info_get_lang_ext)
|
||||
hidden_proto(semanage_module_info_get_enabled)
|
||||
hidden_proto(semanage_module_info_set_priority)
|
||||
hidden_proto(semanage_module_info_set_name)
|
||||
hidden_proto(semanage_module_info_set_version)
|
||||
hidden_proto(semanage_module_info_set_lang_ext)
|
||||
hidden_proto(semanage_module_info_set_enabled)
|
||||
hidden_proto(semanage_module_key_create)
|
||||
hidden_proto(semanage_module_key_destroy)
|
||||
hidden_proto(semanage_module_key_get_priority)
|
||||
hidden_proto(semanage_module_key_get_name)
|
||||
hidden_proto(semanage_module_key_set_priority)
|
||||
hidden_proto(semanage_module_key_set_name)
|
||||
hidden_proto(semanage_module_get_enabled)
|
||||
hidden_proto(semanage_module_set_enabled)
|
||||
#endif
|
||||
|
@ -246,6 +246,8 @@ int semanage_module_info_create(semanage_handle_t *sh,
|
||||
return semanage_module_info_init(sh, *modinfo);
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_create)
|
||||
|
||||
int semanage_module_info_destroy(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo)
|
||||
{
|
||||
@ -262,6 +264,8 @@ int semanage_module_info_destroy(semanage_handle_t *sh,
|
||||
return semanage_module_info_init(sh, modinfo);
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_destroy)
|
||||
|
||||
int semanage_module_info_init(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo)
|
||||
{
|
||||
@ -342,6 +346,8 @@ int semanage_module_info_get_priority(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_get_priority)
|
||||
|
||||
int semanage_module_info_get_name(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **name)
|
||||
@ -355,6 +361,8 @@ int semanage_module_info_get_name(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_get_name)
|
||||
|
||||
int semanage_module_info_get_version(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **version)
|
||||
@ -368,6 +376,8 @@ int semanage_module_info_get_version(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_get_version)
|
||||
|
||||
int semanage_module_info_get_lang_ext(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **lang_ext)
|
||||
@ -381,6 +391,8 @@ int semanage_module_info_get_lang_ext(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_get_lang_ext)
|
||||
|
||||
int semanage_module_info_get_enabled(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
int *enabled)
|
||||
@ -394,6 +406,8 @@ int semanage_module_info_get_enabled(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_get_enabled)
|
||||
|
||||
int semanage_module_info_set_priority(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
uint16_t priority)
|
||||
@ -413,6 +427,8 @@ int semanage_module_info_set_priority(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_set_priority)
|
||||
|
||||
int semanage_module_info_set_name(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *name)
|
||||
@ -441,6 +457,8 @@ int semanage_module_info_set_name(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_set_name)
|
||||
|
||||
int semanage_module_info_set_version(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *version)
|
||||
@ -469,6 +487,8 @@ int semanage_module_info_set_version(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_set_version)
|
||||
|
||||
int semanage_module_info_set_lang_ext(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *lang_ext)
|
||||
@ -497,6 +517,8 @@ int semanage_module_info_set_lang_ext(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_set_lang_ext)
|
||||
|
||||
int semanage_module_info_set_enabled(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
int enabled)
|
||||
@ -516,6 +538,8 @@ int semanage_module_info_set_enabled(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_info_set_enabled)
|
||||
|
||||
int semanage_module_get_path(semanage_handle_t *sh,
|
||||
const semanage_module_info_t *modinfo,
|
||||
enum semanage_module_path_type type,
|
||||
@ -721,6 +745,8 @@ int semanage_module_key_create(semanage_handle_t *sh,
|
||||
return semanage_module_key_init(sh, *modkey);
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_key_create)
|
||||
|
||||
int semanage_module_key_destroy(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey)
|
||||
{
|
||||
@ -733,6 +759,8 @@ int semanage_module_key_destroy(semanage_handle_t *sh,
|
||||
return semanage_module_key_init(sh, modkey);
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_key_destroy)
|
||||
|
||||
int semanage_module_key_init(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey)
|
||||
{
|
||||
@ -758,6 +786,8 @@ int semanage_module_key_get_name(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_key_get_name)
|
||||
|
||||
int semanage_module_key_get_priority(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
uint16_t *priority)
|
||||
@ -771,6 +801,8 @@ int semanage_module_key_get_priority(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_key_get_priority)
|
||||
|
||||
int semanage_module_key_set_name(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
const char *name)
|
||||
@ -801,6 +833,8 @@ cleanup:
|
||||
return status;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_key_set_name)
|
||||
|
||||
int semanage_module_key_set_priority(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
uint16_t priority)
|
||||
@ -819,6 +853,8 @@ int semanage_module_key_set_priority(semanage_handle_t *sh,
|
||||
return 0;
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_key_set_priority)
|
||||
|
||||
int semanage_module_get_enabled(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
int *enabled)
|
||||
@ -839,6 +875,8 @@ int semanage_module_get_enabled(semanage_handle_t *sh,
|
||||
return sh->funcs->get_enabled(sh, modkey, enabled);
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_get_enabled)
|
||||
|
||||
int semanage_module_set_enabled(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
int enabled)
|
||||
@ -863,6 +901,8 @@ int semanage_module_set_enabled(semanage_handle_t *sh,
|
||||
return sh->funcs->set_enabled(sh, modkey, enabled);
|
||||
}
|
||||
|
||||
hidden_def(semanage_module_set_enabled)
|
||||
|
||||
/* Converts a string to a priority
|
||||
*
|
||||
* returns -1 if str is not a valid priority.
|
||||
|
@ -35,25 +35,6 @@ struct semanage_module_info {
|
||||
int enabled; /* module enabled/disabled status */
|
||||
};
|
||||
|
||||
/* Creates a module info struct.
|
||||
*
|
||||
* Returns 0 on success and -1 on failure.
|
||||
*
|
||||
* The @modinfo should be destroyed with semanage_module_info_destroy.
|
||||
* The caller should call free() on the struct.
|
||||
*/
|
||||
int semanage_module_info_create(semanage_handle_t *sh,
|
||||
semanage_module_info_t **modinfo);
|
||||
|
||||
/* Frees the members of the module info struct.
|
||||
*
|
||||
* Returns 0 on success and -1 on failure.
|
||||
*
|
||||
* The caller should call free() on the struct.
|
||||
*/
|
||||
int semanage_module_info_destroy(semanage_handle_t *handle,
|
||||
semanage_module_info_t *modinfo);
|
||||
|
||||
/* Initializes a pre-allocated module info struct.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
@ -69,90 +50,6 @@ int semanage_module_info_clone(semanage_handle_t *sh,
|
||||
const semanage_module_info_t *source,
|
||||
semanage_module_info_t *target);
|
||||
|
||||
/* Module Info Getters */
|
||||
|
||||
/* Get @priority from @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_priority(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
uint16_t *priority);
|
||||
|
||||
/* Get @name from @modinfo. Caller should not free @name.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_name(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **name);
|
||||
|
||||
/* Get @version from @modinfo. Caller should not free @version.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_version(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **version);
|
||||
|
||||
/* Get @lang_ext from @modinfo. Caller should not free @lang_ext.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_lang_ext(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char **lang_ext);
|
||||
|
||||
/* Get @enabled from @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_get_enabled(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
int *enabled);
|
||||
|
||||
/* Module Info Setters */
|
||||
|
||||
/* Set @priority in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_priority(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
uint16_t priority);
|
||||
|
||||
/* Set @name in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_name(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *name);
|
||||
|
||||
/* Set @version in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_version(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *version);
|
||||
|
||||
/* Set @lang_ext in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_lang_ext(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
const char *lang_ext);
|
||||
|
||||
/* Set @enabled in @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_info_set_enabled(semanage_handle_t *sh,
|
||||
semanage_module_info_t *modinfo,
|
||||
int enabled);
|
||||
|
||||
/* Convert a cstring to a priority.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
@ -167,28 +64,10 @@ int semanage_module_validate_lang_ext(const char *ext);
|
||||
int semanage_module_validate_version(const char *version);
|
||||
|
||||
/* Module Key */
|
||||
typedef struct semanage_module_key {
|
||||
struct semanage_module_key {
|
||||
uint16_t priority; /* module priority */
|
||||
char *name; /* module name */
|
||||
} semanage_module_key_t;
|
||||
|
||||
/* Creates a module key struct.
|
||||
*
|
||||
* Return 0 on success, and -1 on error.
|
||||
*
|
||||
* The @modkey should be destroyed with semanage_module_key_destroy.
|
||||
* The caller should call free() on the struct.
|
||||
*/
|
||||
int semanage_module_key_create(semanage_handle_t *sh,
|
||||
semanage_module_key_t **modkey);
|
||||
|
||||
/* Frees members of the @modkey, but not the struct. The caller should
|
||||
* call free() on struct.
|
||||
*
|
||||
* Returns 0 on success, and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_destroy(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey);
|
||||
};
|
||||
|
||||
/* Initializes a pre-allocated module key struct.
|
||||
*
|
||||
@ -197,42 +76,6 @@ int semanage_module_key_destroy(semanage_handle_t *sh,
|
||||
int semanage_module_key_init(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey);
|
||||
|
||||
/* Module Key Getters */
|
||||
|
||||
/* Get @name from @modkey. Caller should not free @name.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_get_name(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
const char **name);
|
||||
|
||||
/* Get @name from @modkey.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_get_priority(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
uint16_t *priority);
|
||||
|
||||
/* Module Key Setters */
|
||||
|
||||
/* Set @name in @modkey.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_set_name(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
const char *name);
|
||||
|
||||
/* Set @priority in @modkey.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_key_set_priority(semanage_handle_t *sh,
|
||||
semanage_module_key_t *modkey,
|
||||
uint16_t priority);
|
||||
|
||||
/* Module Paths */
|
||||
|
||||
enum semanage_module_path_type {
|
||||
@ -255,96 +98,4 @@ int semanage_module_get_path(semanage_handle_t *sh,
|
||||
char *path,
|
||||
size_t len);
|
||||
|
||||
/* Module Enabled */
|
||||
|
||||
/* Get module @enabled status from @modkey. Modules are enabled on a per
|
||||
* module name basis (across all priorities). @modkey only needs to have
|
||||
* name set (priority is ignored).
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_get_enabled(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
int *enabled);
|
||||
|
||||
/* Set module @enabled status from @modkey. Modules are enabled on a per
|
||||
* module name basis (across all priorities). @modkey only needs to have
|
||||
* name set (priority is ignored).
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_set_enabled(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
int enabled);
|
||||
|
||||
/* Lookup @modinfo by @modkey. Caller should use
|
||||
* semanage_module_info_destroy and free on @modinfo.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_get_module_info(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey,
|
||||
semanage_module_info_t **modinfo);
|
||||
|
||||
/* Create a list of all modules in @modinfos of length @modinfos_len.
|
||||
* The list will be sorted from high priority to low and alphabetically
|
||||
* by module name within a priority.
|
||||
*
|
||||
* Caller should use semanage_module_info_destroy on each modinfo in
|
||||
* @modinfos and free on @modinfos.
|
||||
*
|
||||
* Returns 0 on success and -1 on error.
|
||||
*/
|
||||
int semanage_module_list_all(semanage_handle_t *sh,
|
||||
semanage_module_info_t **modinfos,
|
||||
int *modinfos_len);
|
||||
|
||||
/* Install the module indicated by @modinfo with input data from
|
||||
* @module_data with length @data_len.
|
||||
*
|
||||
* @modinfo must have all values filled in.
|
||||
* @module_data may be bzip compressed.
|
||||
*
|
||||
* Returns:
|
||||
* 0 success
|
||||
* -1 failure, out of memory
|
||||
* -2 failure, invalid @modinfo
|
||||
* -3 failure, error writing file
|
||||
*/
|
||||
int semanage_module_install_info(semanage_handle_t *sh,
|
||||
const semanage_module_info_t *modinfo,
|
||||
char *data,
|
||||
size_t data_len);
|
||||
|
||||
/* Upgrade the module indicated by @modinfo with input data from
|
||||
* @module_data with length @data_len.
|
||||
*
|
||||
* If the module is not already installed, then this will install it.
|
||||
*
|
||||
* @modinfo must have all values filled in.
|
||||
* @module_data may be bzip compressed.
|
||||
*
|
||||
* Returns:
|
||||
* 0 success
|
||||
* -1 failure, out of memory
|
||||
* -2 failure, invalid @modinfo
|
||||
* -3 failure, error writing file
|
||||
* -4 failure, same or newer version module exists
|
||||
*/
|
||||
int semanage_module_upgrade_info(semanage_handle_t *sh,
|
||||
const semanage_module_info_t *modinfo,
|
||||
char *data,
|
||||
size_t data_len);
|
||||
|
||||
/* Remove the module indicated by @modkey.
|
||||
* @modkey must have key values filled in.
|
||||
*
|
||||
* Returns:
|
||||
* 0 success
|
||||
* -1 failure, out of memeory
|
||||
* -2 failure, @module not found or couldn't be removed
|
||||
*/
|
||||
int semanage_module_remove_key(semanage_handle_t *sh,
|
||||
const semanage_module_key_t *modkey);
|
||||
|
||||
#endif
|
||||
|
@ -28,6 +28,8 @@
|
||||
#define STATUS_ERR -1
|
||||
%}
|
||||
|
||||
%include "stdint.i"
|
||||
|
||||
%wrapper %{
|
||||
|
||||
|
||||
@ -98,6 +100,7 @@
|
||||
%apply int *OUTPUT { int * };
|
||||
%apply int *OUTPUT { size_t * };
|
||||
%apply int *OUTPUT { unsigned int * };
|
||||
%apply int *OUTPUT { uint16_t * };
|
||||
|
||||
%typemap(in, numinputs=0) char **(char *temp=NULL) {
|
||||
$1 = &temp;
|
||||
@ -144,6 +147,18 @@
|
||||
$result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
|
||||
}
|
||||
|
||||
/** module key typemaps **/
|
||||
|
||||
/* the wrapper will setup this parameter for passing... the resulting python functions
|
||||
will not take the semanage_module_key_t ** parameter */
|
||||
%typemap(in, numinputs=0) semanage_module_key_t **(semanage_module_key_t *temp=NULL) {
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(argout) semanage_module_key_t ** {
|
||||
$result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
|
||||
}
|
||||
|
||||
/** context typemaps **/
|
||||
|
||||
/* the wrapper will setup this parameter for passing... the resulting python functions
|
||||
|
Loading…
Reference in New Issue
Block a user