From: <ssm...@us...> - 2007-10-05 13:45:30
|
Revision: 2633 http://selinux.svn.sourceforge.net/selinux/?rev=2633&view=rev Author: ssmalley Date: 2007-10-05 06:45:26 -0700 (Fri, 05 Oct 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux: minor updates to AVC, mapping, callbacks Date: Wed, 03 Oct 2007 18:50:30 -0400 This patch introduces the selinux_get_callback() companion to selinux_set_callback() that was discussed on-list recently. Added a format attribute to the callback union definition to squash a gcc warning. Signed-off-by: Eamon Walsh <ew...@ty...> Modified Paths: -------------- trunk/libselinux/include/selinux/selinux.h trunk/libselinux/src/callbacks.c Modified: trunk/libselinux/include/selinux/selinux.h =================================================================== --- trunk/libselinux/include/selinux/selinux.h 2007-10-05 13:43:23 UTC (rev 2632) +++ trunk/libselinux/include/selinux/selinux.h 2007-10-05 13:45:26 UTC (rev 2633) @@ -142,7 +142,8 @@ union selinux_callback { /* log the printf-style format and arguments, with the type code indicating the type of message */ - int (*func_log) (int type, const char *fmt, ...); + int __attribute__((format(printf, 2, 3))) + (*func_log) (int type, const char *fmt, ...); /* store a string representation of auditdata (corresponding to the given security class) into msgbuf. */ int (*func_audit) (void *auditdata, security_class_t cls, @@ -155,6 +156,7 @@ #define SELINUX_CB_AUDIT 1 #define SELINUX_CB_VALIDATE 2 +extern union selinux_callback selinux_get_callback(int type); extern void selinux_set_callback(int type, union selinux_callback cb); /* Logging type codes, passed to the logging callback */ Modified: trunk/libselinux/src/callbacks.c =================================================================== --- trunk/libselinux/src/callbacks.c 2007-10-05 13:43:23 UTC (rev 2632) +++ trunk/libselinux/src/callbacks.c 2007-10-05 13:45:26 UTC (rev 2633) @@ -6,6 +6,7 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> +#include <errno.h> #include <selinux/selinux.h> #include "callbacks.h" @@ -65,3 +66,27 @@ break; } } + +/* callback getting function */ +union selinux_callback +selinux_get_callback(int type) +{ + union selinux_callback cb; + + switch (type) { + case SELINUX_CB_LOG: + cb.func_log = selinux_log; + break; + case SELINUX_CB_AUDIT: + cb.func_audit = selinux_audit; + break; + case SELINUX_CB_VALIDATE: + cb.func_validate = selinux_validate; + break; + default: + memset(&cb, 0, sizeof(cb)); + errno = EINVAL; + break; + } + return cb; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |