Skip to contentSkip to conversation

Remove unused relay functions

SEMANAGE Ivan Gyurdiev 2 participants 3 messages Oct 20, 2005 – Oct 21, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

Removes unused relay interfaces for POLICYDB databases (modify functions). Some of them had the wrong names too...

This is basically the logical conclusion of splitting the internal POLICYDB header in half - one half was made public in an earlier patch, and now I'm dropping the other half in favor of more direct access (without relay) - policydb_components.c uses polymorphism and method tables to call the right function itself without relay, which is better.

====

What I don't like very much is that accessing the functions directly via the dbase interfaces assumes binary compatibility between the sepol and semanage record (currently true), while in the previous versions I had convert() functions to change between the two. I've put a warning - not sure if I'll do anything about it.

libsemanage/src/booleans_policy.c +1 -76
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude libsemanage.map --exclude 'module_record*' --exclude 'database_directory*' old/libsemanage/src/booleans_policy.c new/libsemanage/src/booleans_policy.c
@@ -11,9 +11,9 @@ typedef struct dbase_direct dbase_t;
 #include <stddef.h>
 #include <stdlib.h>
 #include <semanage/boolean_record.h>
+#include <semanage/booleans_policy.h>
 #include "handle.h"
 #include "database.h"
-#include "booleans_policy.h"
 #include "debug.h"
 
 static inline int semanage2sepol_key(
@@ -43,81 +43,6 @@ record_table_t SEPOL_BOOL_RTABLE = {
 	.free        = sepol_bool_free,
 };
 
-int semanage_bool_add(
-	semanage_handle_t* handle,
-	semanage_bool_key_t* key,
-	semanage_bool_t* data) {
-
-	dbase_config_t* dconfig = 
-		semanage_bool_dbase_policy(handle);
-	sepol_bool_t* sepol_data;
-	sepol_bool_key_t* sepol_key;
-
-	if (semanage2sepol_key(key, &sepol_key) < 0)
-		goto err;
-
-	if (semanage2sepol_data(data, &sepol_data) < 0)
-		goto err;
-
-	if (dconfig->dtable->add(handle, dconfig->dbase, 
-			sepol_key, sepol_data) < 0)
-		goto err;
-	
-	return STATUS_SUCCESS;
-
-	err:
-	/* FIXME: handle error */
-	return STATUS_ERR;
-}
-
-int semanage_bool_modify_policy(
-	semanage_handle_t* handle,
-	semanage_bool_key_t* key,
-	semanage_bool_t* data) {
-
-	dbase_config_t* dconfig = 
-		semanage_port_dbase_policy(handle);
-	sepol_bool_t* sepol_data;
-	sepol_bool_key_t* sepol_key;
-
-	if (semanage2sepol_key(key, &sepol_key) < 0)
-		goto err;
-
-	if (semanage2sepol_data(data, &sepol_data) < 0)
-		goto err;
-
-	if (dconfig->dtable->modify(handle, dconfig->dbase,
-			sepol_key, sepol_data) <  0)
-		goto err;
-
-	return STATUS_SUCCESS;
-	
-	err:
-	/* FIXME: handle error */
-	return STATUS_ERR;
-}
-
-int semanage_bool_del(
-	semanage_handle_t* handle,
-	semanage_bool_key_t* key) {
-
-	dbase_config_t* dconfig = 
-		semanage_bool_dbase_policy(handle);
-	sepol_bool_key_t* sepol_key;
-
-	if (semanage2sepol_key(key, &sepol_key) < 0)
-		goto err;
-
-	if (dconfig->dtable->del(handle, dconfig->dbase, sepol_key) < 0)
-		goto err;
-
-	return STATUS_SUCCESS;
-
-	err:
-	/* FIXME: handle error */
-	return STATUS_ERR;
-}
-
 int semanage_bool_query(
 	semanage_handle_t* handle,
 	semanage_bool_key_t* key,
libsemanage/src/booleans_policy.h +0 -25
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude libsemanage.map --exclude 'module_record*' --exclude 'database_directory*' old/libsemanage/src/booleans_policy.h new/libsemanage/src/booleans_policy.h
@@ -1,25 +0,0 @@
-#ifndef _SEMANAGE_BOOLEANS_POLICY_INTERNAL_H_
-#define _SEMANAGE_BOOLEANS_POLICY_INTERNAL_H_
-
-#include <semanage/handle.h> 
-#include <semanage/boolean_record.h>
-#include <semanage/booleans_policy.h>
-
-/* BOOLEAN RECORD (SEPOL): method table */
-extern record_table_t SEPOL_BOOL_RTABLE;
-
-extern int semanage_bool_add(
-	semanage_handle_t* handle,
-	semanage_bool_key_t* key,
-	semanage_bool_t* data);
-
-extern int semanage_bool_modify(
-	semanage_handle_t* handle,
-	semanage_bool_key_t* key,
-	semanage_bool_t* data);
-
-extern int semanage_bool_del(
-	semanage_handle_t* handle,
-	semanage_bool_key_t* key);
-
-#endif
libsemanage/src/interfaces_policy.c +1 -76

91 lines not on this page · raw message

libsemanage/src/interfaces_policy.h +0 -25
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude libsemanage.map --exclude 'module_record*' --exclude 'database_directory*' old/libsemanage/src/interfaces_policy.h new/libsemanage/src/interfaces_policy.h
@@ -1,25 +0,0 @@
-#ifndef _SEMANAGE_INTERFACES_POLICY_INTERNAL_H_
-#define _SEMANAGE_INTERFACES_POLICY_INTERNAL_H_
-
-#include <semanage/handle.h> 
-#include <semanage/iface_record.h>
-#include <semanage/interfaces_policy.h>
-
-/* INTERFACE RECORD (SEPOL): method table */
-extern record_table_t SEPOL_IFACE_RTABLE;
-
-extern int semanage_iface_add(
-	semanage_handle_t* handle,
-	semanage_iface_key_t* key,
-	semanage_iface_t* data);
-
-extern int semanage_iface_modify(
-	semanage_handle_t* handle,
-	semanage_iface_key_t* key,
-	semanage_iface_t* data);
-
-extern int semanage_iface_del(
-	semanage_handle_t* handle,
-	semanage_iface_key_t* key);
-
-#endif
libsemanage/src/ports_policy.c +1 -76

91 lines not on this page · raw message

libsemanage/src/ports_policy.h +0 -25
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude libsemanage.map --exclude 'module_record*' --exclude 'database_directory*' old/libsemanage/src/ports_policy.h new/libsemanage/src/ports_policy.h
@@ -1,25 +0,0 @@
-#ifndef _SEMANAGE_PORTS_POLICY_INTERNAL_H_
-#define _SEMANAGE_PORTS_POLICY_INTERNAL_H_
-
-#include <semanage/handle.h> 
-#include <semanage/port_record.h>
-#include <semanage/ports_policy.h>
-
-/* PORT RECORD (SEPOL): method table */
-extern record_table_t SEPOL_PORT_RTABLE;
-
-extern int semanage_port_add(
-	semanage_handle_t* handle,
-	semanage_port_key_t* key,
-	semanage_port_t* data);
-
-extern int semanage_port_modify(
-	semanage_handle_t* handle,
-	semanage_port_key_t* key,
-	semanage_port_t* data);
-
-extern int semanage_port_del(
-	semanage_handle_t* handle,
-	semanage_port_key_t* key);
-
-#endif
libsemanage/src/users_policy.c +1 -76

91 lines not on this page · raw message

libsemanage/src/users_policy.h +0 -25
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude libsemanage.map --exclude 'module_record*' --exclude 'database_directory*' old/libsemanage/src/users_policy.h new/libsemanage/src/users_policy.h
@@ -1,25 +0,0 @@
-#ifndef _SEMANAGE_USERS_POLICY_INTERNAL_H_
-#define _SEMANAGE_USERS_POLICY_INTERNAL_H_
-
-#include <semanage/handle.h> 
-#include <semanage/user_record.h>
-#include <semanage/users_policy.h>
-
-/* USER RECORD (SEPOL): method table */
-extern record_table_t SEPOL_USER_RTABLE;
-
-extern int semanage_user_add(
-	semanage_handle_t* handle,
-	semanage_user_key_t* key,
-	semanage_user_t* data);
-
-extern int semanage_user_modify(
-	semanage_handle_t* handle,
-	semanage_user_key_t* key,
-	semanage_user_t* data);
-
-extern int semanage_user_del(
-	semanage_handle_t* handle,
-	semanage_user_key_t* key);
-
-#endif
#1 lore raw
Quoted 2 lines

What I don't like very much is that accessing the functions directly via the dbase interfaces assumes binary compatibility between the sepol and semanage record (currently true), while in the previous versions I had convert() functions to change between the two. I've put a warning - not sure if I'll do anything about it.

Well, the warning was skipped in this patch, but it will be in the next one:

       switch (arg->mode) {

               /* WARNING:
                * This assumes binary compatibility between
                * the source and target key/record type. This is currently
                * true, but may change in the future (?) */

               case MODE_SET:
                       if (dtable->set(handle, dbase, rkey, record) < 0)
                               goto err;
                       break;

               default:
               case MODE_MODIFY:
                       if (dtable->modify(handle, dbase, rkey, record) < 0)
                               goto err;
                       break;
       }

--
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.

#2 lore raw
In reply to Ivan Gyurdiev
Quoted 2 lines · Ivan Gyurdiev

Removes unused relay interfaces for POLICYDB databases (modify functions). Some of them had the wrong names too...

Merged as of libsemanage 1.3.31.

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.