7 #if defined(WITH_SEPOL)
11 #include <sepol/sepol.h>
17 #define _RPMSP_INTERNAL
36 #if defined(WITH_SEPOL)
38 sepol_module_package_free(sp->P);
40 sepol_context_free(sp->C);
42 sepol_policy_file_free(sp->F);
44 sepol_policydb_free(sp->DB);
46 sepol_handle_destroy(sp->I);
48 sp->fn =
_free(sp->fn);
66 if (_rpmspPool == NULL) {
86 #if defined(WITH_SEPOL)
87 { sepol_handle_t *I = sp->I = sepol_handle_create();
92 fprintf(stderr,
"--> %s(%s,0x%x): sepol_handle_create() failed\n", __FUNCTION__, fn, flags);
97 if ((xx = sepol_context_create(sp->I, (sepol_context_t **)&sp->C)) < 0) {
99 fprintf(stderr,
"--> %s: sepol_context_create: %s\n", __FUNCTION__, strerror(
errno));
104 if ((xx = sepol_module_package_create(&sp->P)) < 0) {
106 fprintf(stderr,
"--> %s: sepol_module_package_create: %s\n", __FUNCTION__, strerror(
errno));
112 FILE * fp = fopen(fn,
"r");
114 if (fp == NULL || ferror(fp)) {
116 fprintf(stderr,
"--> %s: fopen(%s)\n", __FUNCTION__, fn);
117 if (fp) xx = fclose(fp);
123 if ((xx = sepol_policy_file_create(&sp->F)) < 0) {
125 fprintf(stderr,
"--> %s: sepol_policy_file_create: %s\n", __FUNCTION__, strerror(
errno));
126 if (fp) xx = fclose(fp);
131 sepol_policy_file_set_handle(sp->F, sp->I);
132 sepol_policy_file_set_fp(sp->F, fp);
134 if ((xx = sepol_policydb_create(&sp->DB)) < 0) {
136 fprintf(stderr,
"--> %s: sepol_policydb_create: %s\n", __FUNCTION__, strerror(
errno));
141 if ((xx = sepol_policydb_read(sp->DB, sp->F)) < 0) {
143 fprintf(stderr,
"--> %s: sepol_policydb_read: %s\n", __FUNCTION__, strerror(
errno));
155 #if defined(WITH_SEPOL)
157 static const char * _rpmspI_fn =
"minimum";
160 static int _rpmspI_flags;
162 static rpmsp rpmspI(
void)
static void rpmspFini(void *_sp)
rpmsp rpmspFree(rpmsp sp)
Destroy a sepol wrapper.
Yet Another syslog(3) API clone.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
rpmsp rpmspNew(const char *fn, unsigned int flags)
Create and load a sepol wrapper.
rpmsp rpmspLink(rpmsp sp)
Reference a sepol wrapper instance.
const char const bson int mongo_write_concern int flags
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
static rpmsp rpmspGetPool(rpmioPool pool)