| 
      
      
      From: <ssm...@us...> - 2007-10-05 13:45:58
      
     | 
| Revision: 2634
          http://selinux.svn.sourceforge.net/selinux/?rev=2634&view=rev
Author:   ssmalley
Date:     2007-10-05 06:45:54 -0700 (Fri, 05 Oct 2007)
Log Message:
-----------
Author: Eamon Walsh
Email: ew...@ty...
Subject: libselinux: minor updates to AVC, mapping, callbacks
Date: Thu, 04 Oct 2007 14:01:12 -0400
This patch introduces a replacement for avc_init(), avc_open().
The purpose of this is to move away from the callbacks specified
to avc_init() and instead set callbacks with selinux_set_callback(),
as well as to use the same option mechanism as selabel_open().
Also updated the old avc_init callbacks to call the new ones if they
are set.
Signed-off-by: Eamon Walsh <ew...@ty...>
Modified Paths:
--------------
    trunk/libselinux/include/selinux/avc.h
    trunk/libselinux/src/avc.c
    trunk/libselinux/src/avc_internal.h
Modified: trunk/libselinux/include/selinux/avc.h
===================================================================
--- trunk/libselinux/include/selinux/avc.h	2007-10-05 13:45:26 UTC (rev 2633)
+++ trunk/libselinux/include/selinux/avc.h	2007-10-05 13:45:54 UTC (rev 2634)
@@ -182,6 +182,17 @@
 	     const struct avc_lock_callback *lock_callbacks);
 
 /**
+ * avc_open - Initialize the AVC.
+ * @opts: array of selabel_opt structures specifying AVC options or NULL.
+ * @nopts: number of elements in opts array or zero for no options.
+ *
+ * This function is identical to avc_init(), except the message prefix
+ * is set to "avc" and any callbacks desired should be specified via
+ * selinux_set_callback().  No options are currently supported.
+ */
+int avc_open(struct selinux_opt *opts, unsigned nopts);
+
+/**
  * avc_cleanup - Remove unused SIDs and AVC entries.
  *
  * Search the SID table for SID structures with zero
Modified: trunk/libselinux/src/avc.c
===================================================================
--- trunk/libselinux/src/avc.c	2007-10-05 13:45:26 UTC (rev 2633)
+++ trunk/libselinux/src/avc.c	2007-10-05 13:45:54 UTC (rev 2634)
@@ -157,6 +157,12 @@
 	return rc;
 }
 
+int avc_open(struct selinux_opt *opts __attribute__((unused)),
+	     unsigned nopts __attribute__((unused)))
+{
+    return avc_init("avc", NULL, NULL, NULL, NULL);
+}
+
 int avc_init(const char *prefix,
 	     const struct avc_memory_callback *mem_cb,
 	     const struct avc_log_callback *log_cb,
Modified: trunk/libselinux/src/avc_internal.h
===================================================================
--- trunk/libselinux/src/avc_internal.h	2007-10-05 13:45:26 UTC (rev 2633)
+++ trunk/libselinux/src/avc_internal.h	2007-10-05 13:45:54 UTC (rev 2634)
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <selinux/avc.h>
+#include "callbacks.h"
 #include "dso.h"
 
 /* SID reference counter manipulation */
@@ -93,13 +94,15 @@
   if (avc_func_log) \
     avc_func_log(format); \
   else \
-    fprintf(stderr, format)
+    selinux_log(SELINUX_ERROR, format);
 
 static inline void avc_suppl_audit(void *ptr, security_class_t class,
 				   char *buf, size_t len)
 {
 	if (avc_func_audit)
 		avc_func_audit(ptr, class, buf, len);
+	else
+		selinux_audit(ptr, class, buf, len);
 }
 
 static inline void *avc_create_thread(void (*run) (void))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |