Skip to contentSkip to conversation

Patches: libsepol

PATCH Ivan Gyurdiev 2 participants 2 messages Jul 15, 2005 – Jul 18, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

The following patch adds a new debugging system, which allows setting the printf function, and provides a separate field for the function name.

libsepol-1-debug.diff

The following patch marks more functions extern, and provides two new functions - policydb_from_image, and policydb_to_image. Those helper functions will be used in future code.

libsepol-4-policydb_convert.diff

The following patch is attached for comments only. It is intended as a replacement for genusers.c, to provide an interface for libsemanage to work with users.

libsepol-5-users.diff

Note that no new functions are added to the shared interface, following up with the plan to make this library static. Also, I've dropped patches which make the policydb an opaque structure, as they will not be necessary, and may cause instability.

include/sepol/debug.h +9 -0
diff -aru libsepol.work/include/sepol/debug.h libsepol-1-debug/include/sepol/debug.h
@@ -0,0 +1,9 @@
+#ifndef _SEPOL_DEBUG_H_
+#define _SEPOL_DEBUG_H_
+
+extern void sepol_enable_debug(
+	void (*fn)(const char* fname, const char *fmt, ...));
+
+extern void sepol_disable_debug();
+
+#endif /* _SEPOL_DEBUG_H_ */
src/debug.c +52 -0

52 lines not on this page · raw message

src/debug.h +17 -0
diff -aru libsepol.work/src/debug.h libsepol-1-debug/src/debug.h
@@ -0,0 +1,17 @@
+#ifndef _SEPOL_INTERNAL_DEBUG_H_
+#define _SEPOL_INTERNAL_DEBUG_H_
+
+#define STATUS_SUCCESS 0
+#define STATUS_ERR -1
+#define STATUS_NODATA 1
+
+extern void sepol_debug_compat(int on);
+
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)))
+#endif
+extern void (*DEBUG) (
+	const char* fname,
+	const char* fmt, ...);
+
+#endif /* _SEPOL_INTERNAL_DEBUG_H_ */
src/genusers.c +7 -1
diff -aru libsepol.work/src/genusers.c libsepol-1-debug/src/genusers.c
@@ -9,11 +9,17 @@
 #include <sepol/mls.h>
 #include <stdarg.h>
 
+#include "debug.h"
 #include "private.h"
 
 static int gdebug=1;
 
-void sepol_debug(int on) { gdebug=on; };
+void sepol_debug(int on) { 
+	gdebug=on; 
+
+	/* New debug system */
+	sepol_debug_compat(on);
+};
 
 void __sepol_debug_printf(const char *fmt, ...) {
 	if (gdebug) {
include/sepol/policydb.h +33 -29

89 lines not on this page · raw message

src/policydb_convert.c +104 -0

104 lines not on this page · raw message

include/sepol/users.h +39 -0
diff -aru libsepol.work/include/sepol/users.h libsepol-5-users/include/sepol/users.h
@@ -0,0 +1,39 @@
+#ifndef _SEPOL_USERS_H_
+#define _SEPOL_USERS_H_
+
+#include <sepol/policydb.h>
+
+typedef struct sepol_uinfo {
+	const char* name;
+	const char** roles;
+	const char* mls_level;
+	const char* mls_range;
+} sepol_uinfo_t;
+
+/* Clear unused users */
+extern void sepol_clear_unused_users(
+	policydb_t* policydb);
+
+/* Add/delete/load users from the policy */
+extern int sepol_add_user(
+	policydb_t* policydb,
+	sepol_uinfo_t* user); 
+
+extern int sepol_del_user(
+	policydb_t* policydb, 
+	const char *username);
+
+extern int sepol_load_user(
+	policydb_t* policydb, 
+	sepol_uinfo_t* user);
+
+extern int sepol_is_role_valid(
+	policydb_t* policydb,
+	const char* role);
+
+extern int sepol_get_valid_roles(
+	policydb_t* policydb, 
+	char*** roles, 
+	int* nroles);
+
+#endif /* _SEPOL_USERS_H_ */
src/genusers.c +2 -7
diff -aru libsepol.work/src/genusers.c libsepol-5-users/src/genusers.c
@@ -30,12 +30,7 @@
 	}
 }
 
-static int delusers = 0;
-
-void sepol_set_delusers(int on)
-{
-	delusers = on;
-}
+extern int selinux_delusers;
 
 #undef BADLINE
 #define BADLINE() { \
@@ -382,7 +377,7 @@
 		goto err;
 	}
 
-	if (delusers) {
+	if (selinux_delusers) {
 		/* Kill unused users and remap to avoid holes. */
 		ebitmap_init(&free_users);
 		kud.policydb = &policydb;
src/users.c +358 -0

358 lines not on this page · raw message

#1 lore raw
Quoted 5 lines · Ivan Gyurdiev

The following patch adds a new debugging system, which allows setting the printf function, and provides a separate field for the function name.

libsepol-1-debug.diff

Merged.

Quoted 5 lines

The following patch marks more functions extern, and provides two new functions - policydb_from_image, and policydb_to_image. Those helper functions will be used in future code.

libsepol-4-policydb_convert.diff

Merged.

Quoted 10 lines

The following patch is attached for comments only. It is intended as a replacement for genusers.c, to provide an interface for libsemanage to work with users.

libsepol-5-users.diff

Note that no new functions are added to the shared interface, following up with the plan to make this library static. Also, I've dropped patches which make the policydb an opaque structure, as they will not be necessary, and may cause instability.

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.