Interface record
The attached patches add the interface record to libsepol and libsemanage, which replaces the current sepol_iface_t structure. They also fix a minor namespace issue, and add include guards to sepol/interfaces.h.
include/semanage/iface_record.h +83 -0
@@ -0,0 +1,83 @@ +#ifndef _SEMANAGE_IFACE_RECORD_H_ +#define _SEMANAGE_IFACE_RECORD_H_ + +#include <semanage/context_record.h> + +/* Implentation via sepol */ +#include <sepol/iface_record.h> +typedef sepol_iface_t semanage_iface_t ; +typedef sepol_iface_key_t semanage_iface_key_t ; + +/* Key */ +static inline +int semanage_iface_compare (semanage_iface_t iface,semanage_iface_key_t key) { +return sepol_iface_compare (iface, key); +} + +static inline +int semanage_iface_key_create ( +const char * name, +semanage_iface_key_t * key_ptr) { +return sepol_iface_key_create (name, key_ptr); +} + +static inline +int semanage_iface_key_extract ( +semanage_iface_t iface, +semanage_iface_key_t * key_ptr) { +return sepol_iface_key_extract (iface, key_ptr); +} + +static inline +void semanage_iface_key_free (semanage_iface_key_t key) { +sepol_iface_key_free (key); +} + +/* Name */ +static inline +const char *semanage_iface_get_name (semanage_iface_t iface) { +return sepol_iface_get_name (iface); +} + +static inline +int semanage_iface_set_name (semanage_user_t iface,const char * name) { +return sepol_iface_set_name (iface, name); +} + +/* Context */ +static inline +semanage_context_t semanage_iface_get_ifcon (semanage_iface_t iface) { +return sepol_iface_get_ifcon (iface); +} + +static inline +int semanage_iface_set_ifcon (semanage_iface_t iface,semanage_context_t con) { +return sepol_iface_set_ifcon (iface, con); +} + +static inline +semanage_context_t semanage_iface_get_msgcon (semanage_iface_t iface) { +return sepol_iface_get_msgcon (iface); +} + +static inline +int semanage_iface_set_msgcon (semanage_iface_t iface,semanage_context_t con) { +return sepol_iface_set_msgcon (iface, con); +} + +/* Create/Clone/Destroy */ +static inline +int semanage_iface_create (semanage_iface_t * iface_ptr) { +return sepol_iface_create (iface_ptr); +} + +static inline +int semanage_iface_clone (semanage_iface_t iface,semanage_iface_t * iface_ptr) { +return sepol_iface_clone (iface, iface_ptr); +} + +static inline +void semanage_iface_free (semanage_iface_t iface) { +sepol_iface_free (iface); +} +#endif
ChangeLog +4 -0
@@ -1,3 +1,7 @@ +1.9.3 2005-09-14 + * Merged fix for sepol_enable/disable_debug from Ivan + Gyurdiev. + 1.9.2 2005-09-14 * Merged stddef.h patch and debug conversion patch from Ivan Gyurdiev.
CVS/Entries +4 -4
@@ -1,8 +1,8 @@ /COPYING/1.2/Fri May 20 15:43:20 2005// /Makefile/1.3/Wed Feb 9 22:04:52 2005/-ko/ -D/include//// D/man//// -D/src//// D/utils//// -/ChangeLog/1.58/Wed Sep 14 18:57:30 2005// -/VERSION/1.56/Wed Sep 14 18:57:30 2005/-ko/ +D/include//// +D/src//// +/ChangeLog/1.59/Sun Sep 18 03:02:56 2005// +/VERSION/1.57/Sun Sep 18 03:02:56 2005/-ko/
CVS/Entries.Log +0 -2
@@ -1,2 +0,0 @@ -A D/include//// -A D/src////
include/sepol/iface_record.h +43 -0
43 lines not on this page · raw message
include/sepol/interfaces.h +10 -12
@@ -1,29 +1,27 @@ +#ifndef __SEPOL_INTERFACES_H_ +#define __SEPOL_INTERFACES_H_ +#include <sepol/policydb.h> -#include <sepol/context_record.h> +#include <sepol/iface_record.h> #include <stddef.h> -/* High level representation of an interface */ -typedef struct sepol_iface { -const char * name; -sepol_context_t netif_con; -sepol_context_t netmsg_con; -}sepol_iface_t ; -/* Create a low level interface structure from * a high level representation */ -extern int sepol_iface_create ( +extern int sepol_iface_struct_create (policydb_t * policydb,ocontext_t ** iface, -sepol_iface_t * data); +sepol_iface_t data);/* Get the current context mapping for this interface */ extern int sepol_iface_get_context (policydb_t * policydb, -sepol_iface_t * data, +sepol_iface_t data,char ** ifcon_str,size_t * ifcon_str_len,char ** msgcon_str,size_t * msgcon_str_len);/* Load an interface into policy */ extern int sepol_iface_load (policydb_t * policydb, -sepol_iface_t * data); +sepol_iface_t data); + +#endif
src/CVS/Entries +2 -2
@@ -8,7 +8,6 @@ /constraint.c/1.4/Wed Aug 10 17:39:31 2005// /context.c/1.3/Tue Aug 2 13:17:09 2005// /context_record.c/1.2/Thu Aug 18 20:42:25 2005// -/debug.c/1.2/Wed Sep 14 15:44:44 2005// /debug.h/1.1/Mon Jul 18 14:28:43 2005// /ebitmap.c/1.4/Wed Jul 6 17:45:07 2005/-ko/ /expand.c/1.10/Fri Sep 9 15:42:25 2005//
@@ -21,7 +20,6 @@ /link.c/1.5/Wed Aug 31 16:31:31 2005// /mls.c/1.9/Thu Aug 11 16:57:51 2005// /module.c/1.1/Tue Aug 2 19:41:19 2005// -/policydb.c/1.24/Wed Sep 14 15:44:44 2005/-ko/ /policydb_convert.c/1.2/Tue Jul 26 18:43:30 2005// /port_record.c/1.1/Tue Aug 2 13:17:09 2005// /ports.c/1.2/Tue Aug 2 13:17:09 2005//
@@ -33,4 +31,6 @@ /users.c/1.4/Thu Aug 11 16:57:51 2005// /util.c/1.5/Wed Aug 31 20:19:30 2005// /write.c/1.14/Fri Aug 12 19:05:25 2005/-ko/ +/debug.c/1.3/Sun Sep 18 03:02:56 2005// +/policydb.c/1.25/Sun Sep 18 03:02:56 2005/-ko/ D
src/iface_record.c +159 -0
159 lines not on this page · raw message
src/interfaces.c +17 -14
@@ -8,13 +8,14 @@#include <sepol/sidtab.h> #include <sepol/services.h> #include <sepol/interfaces.h> +#include <sepol/iface_record.h> /* Create a low level interface structure from * a high level representation */ -int sepol_iface_create ( +int sepol_iface_struct_create (policydb_t * policydb,ocontext_t ** iface, -sepol_iface_t * data) { +sepol_iface_t data) {ocontext_t * tmp_iface =NULL ;context_struct_t * tmp_ifcon =NULL ;
@@ -25,20 +26,20 @@ goto omem;/* Name */ - tmp_iface->u.name =strdup (data->name); + tmp_iface->u.name =strdup (sepol_iface_get_name (data));if (!tmp_iface->u.name) goto omem;/* Interface Context */ if (sepol_ctx_struct_create (policydb, - &tmp_ifcon, data->netif_con) <0 ) + &tmp_ifcon,sepol_iface_get_ifcon (data)) <0 ) goto err;context_cpy (&tmp_iface->context[0 ], tmp_ifcon);free (tmp_ifcon);/* Message Context */ -if (sepol_ctx_struct_create (policydb, &tmp_msgcon, - data->netmsg_con) <0 ) +if (sepol_ctx_struct_create (policydb, + &tmp_msgcon,sepol_iface_get_msgcon (data)) <0 ) goto err;context_cpy (&tmp_iface->context[1 ], tmp_msgcon);free (tmp_msgcon);
@@ -58,15 +59,16 @@/* Get the current context mapping for this interface */ int sepol_iface_get_context (policydb_t * policydb, -sepol_iface_t * data, +sepol_iface_t data,char ** ifcon_str,size_t * ifcon_str_len,char ** msgcon_str,size_t * msgcon_str_len) {ocontext_t *c, *head; +const char * name =sepol_iface_get_name (data); head = policydb->ocontexts[OCON_NETIF ];for (c = head; c; c = c->next) { -if (!strcmp (data->name, c->u.name)) { +if (!strcmp (name, c->u.name)) {if (sepol_ctx_struct_to_string (policydb, &c->context[0 ], ifcon_str, ifcon_str_len) <0 ) goto err;
@@ -83,21 +85,23 @@ err:DEBUG (__FUNCTION__,"could not construct context string for " -"interface %s\n" , data->name); +"interface %s\n" , name);return STATUS_ERR ; }/* Load an interface into policy */ int sepol_iface_load (policydb_t * policydb, -sepol_iface_t * data) { +sepol_iface_t data) {ocontext_t * iface =NULL ;char *ifcon_str, *msgcon_str;size_t ifcon_str_len, msgcon_str_len;int rc; -if (sepol_iface_create (policydb, &iface, data) <0 ) +const char * name =sepol_iface_get_name (data); + +if (sepol_iface_struct_create (policydb, &iface, data) <0 ) goto err; rc = sepol_iface_get_context(
@@ -110,7 +114,7 @@else if (rc !=STATUS_NODATA ) {DEBUG (__FUNCTION__,"interface %s is already mapped to " "context %s with message context %s\n" , - data->name, ifcon_str, msgcon_str); + name, ifcon_str, msgcon_str); goto err; }
@@ -121,8 +125,7 @@return STATUS_SUCCESS ; err: -DEBUG (__FUNCTION__,"error while loading interface %s\n" , - data->name); +DEBUG (__FUNCTION__,"error while loading interface %s\n" , name);free (iface);return STATUS_ERR ; }
src/policydb.c +1 -0
@@ -51,6 +51,7 @@#include <sepol/avrule_block.h> #include "private.h" +#include "debug.h" /* These need to be updated if SYM_NUM or OCON_NUM changes */ static struct policydb_compat_info policydb_compat[] = {
VERSION +1 -1
@@ -1 +1 @@ -1.9.2 +1.9.3
The sepol patch is damaged - reattached.
include/sepol/iface_record.h +43 -0
@@ -0,0 +1,43 @@ +#ifndef _SEPOL_IFACE_RECORD_H_ +#define _SEPOL_IFACE_RECORD_H_ + +#include <sepol/context_record.h> + +struct sepol_iface ; +struct sepol_iface_key ; +typedef struct sepol_iface *sepol_iface_t ; +typedef struct sepol_iface_key *sepol_iface_key_t ; + +/* Key */ +extern int sepol_iface_compare ( +sepol_iface_t iface, +sepol_iface_key_t key); + +extern int sepol_iface_key_create ( +const char * name, +sepol_iface_key_t * key_ptr); + +extern int sepol_iface_key_extract ( +sepol_iface_t iface, +sepol_iface_key_t * key_ptr); + +extern void sepol_iface_key_free ( +sepol_iface_key_t key); + +/* Name */ +extern const char *sepol_iface_get_name (sepol_iface_t iface); +extern int sepol_iface_set_name (sepol_iface_t iface,const char * name); + +/* Context */ +extern sepol_context_t sepol_iface_get_ifcon (sepol_iface_t iface); +extern int sepol_iface_set_ifcon (sepol_iface_t iface,sepol_context_t con); + +extern sepol_context_t sepol_iface_get_msgcon (sepol_iface_t iface); +extern int sepol_iface_set_msgcon (sepol_iface_t iface,sepol_context_t con); + +/* Create/Clone/Destroy */ +extern int sepol_iface_create (sepol_iface_t * iface_ptr); +extern int sepol_iface_clone (sepol_iface_t iface,sepol_iface_t * iface_ptr); +extern void sepol_iface_free (sepol_iface_t iface); + +#endif
include/sepol/interfaces.h +10 -12
@@ -1,29 +1,27 @@ +#ifndef __SEPOL_INTERFACES_H_ +#define __SEPOL_INTERFACES_H_ +#include <sepol/policydb.h> -#include <sepol/context_record.h> +#include <sepol/iface_record.h> #include <stddef.h> -/* High level representation of an interface */ -typedef struct sepol_iface { -const char * name; -sepol_context_t netif_con; -sepol_context_t netmsg_con; -}sepol_iface_t ; -/* Create a low level interface structure from * a high level representation */ -extern int sepol_iface_create ( +extern int sepol_iface_struct_create (policydb_t * policydb,ocontext_t ** iface, -sepol_iface_t * data); +sepol_iface_t data);/* Get the current context mapping for this interface */ extern int sepol_iface_get_context (policydb_t * policydb, -sepol_iface_t * data, +sepol_iface_t data,char ** ifcon_str,size_t * ifcon_str_len,char ** msgcon_str,size_t * msgcon_str_len);/* Load an interface into policy */ extern int sepol_iface_load (policydb_t * policydb, -sepol_iface_t * data); +sepol_iface_t data); + +#endif
src/iface_record.c +159 -0
159 lines not on this page · raw message
src/interfaces.c +17 -14
@@ -8,13 +8,14 @@#include <sepol/sidtab.h> #include <sepol/services.h> #include <sepol/interfaces.h> +#include <sepol/iface_record.h> /* Create a low level interface structure from * a high level representation */ -int sepol_iface_create ( +int sepol_iface_struct_create (policydb_t * policydb,ocontext_t ** iface, -sepol_iface_t * data) { +sepol_iface_t data) {ocontext_t * tmp_iface =NULL ;context_struct_t * tmp_ifcon =NULL ;
@@ -25,20 +26,20 @@ goto omem;/* Name */ - tmp_iface->u.name =strdup (data->name); + tmp_iface->u.name =strdup (sepol_iface_get_name (data));if (!tmp_iface->u.name) goto omem;/* Interface Context */ if (sepol_ctx_struct_create (policydb, - &tmp_ifcon, data->netif_con) <0 ) + &tmp_ifcon,sepol_iface_get_ifcon (data)) <0 ) goto err;context_cpy (&tmp_iface->context[0 ], tmp_ifcon);free (tmp_ifcon);/* Message Context */ -if (sepol_ctx_struct_create (policydb, &tmp_msgcon, - data->netmsg_con) <0 ) +if (sepol_ctx_struct_create (policydb, + &tmp_msgcon,sepol_iface_get_msgcon (data)) <0 ) goto err;context_cpy (&tmp_iface->context[1 ], tmp_msgcon);free (tmp_msgcon);
@@ -58,15 +59,16 @@/* Get the current context mapping for this interface */ int sepol_iface_get_context (policydb_t * policydb, -sepol_iface_t * data, +sepol_iface_t data,char ** ifcon_str,size_t * ifcon_str_len,char ** msgcon_str,size_t * msgcon_str_len) {ocontext_t *c, *head; +const char * name =sepol_iface_get_name (data); head = policydb->ocontexts[OCON_NETIF ];for (c = head; c; c = c->next) { -if (!strcmp (data->name, c->u.name)) { +if (!strcmp (name, c->u.name)) {if (sepol_ctx_struct_to_string (policydb, &c->context[0 ], ifcon_str, ifcon_str_len) <0 ) goto err;
@@ -83,21 +85,23 @@ err:DEBUG (__FUNCTION__,"could not construct context string for " -"interface %s\n" , data->name); +"interface %s\n" , name);return STATUS_ERR ; }/* Load an interface into policy */ int sepol_iface_load (policydb_t * policydb, -sepol_iface_t * data) { +sepol_iface_t data) {ocontext_t * iface =NULL ;char *ifcon_str, *msgcon_str;size_t ifcon_str_len, msgcon_str_len;int rc; -if (sepol_iface_create (policydb, &iface, data) <0 ) +const char * name =sepol_iface_get_name (data); + +if (sepol_iface_struct_create (policydb, &iface, data) <0 ) goto err; rc = sepol_iface_get_context(
@@ -110,7 +114,7 @@else if (rc !=STATUS_NODATA ) {DEBUG (__FUNCTION__,"interface %s is already mapped to " "context %s with message context %s\n" , - data->name, ifcon_str, msgcon_str); + name, ifcon_str, msgcon_str); goto err; }
@@ -121,8 +125,7 @@return STATUS_SUCCESS ; err: -DEBUG (__FUNCTION__,"error while loading interface %s\n" , - data->name); +DEBUG (__FUNCTION__,"error while loading interface %s\n" , name);free (iface);return STATUS_ERR ; }
Quoted 3 lines · Ivan Gyurdiev
The attached patches add the interface record to libsepol and libsemanage, which replaces the current
sepol_iface_tstructure. They also fix a minor namespace issue, and add include guards tosepol/interfaces.h.
Thanks, merged (with the corrected patch).
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.