Apache 2.4 added addition logging levels. This patch converts some of
the log messages that are more intended for mod_apparmor development
and debugging than for sysadmins configuring mod_apparmor to use trace1
(APLOG_TRACE1) level instead. Since apache 2.2. does not contain this
level (or define), we define it back to APLOG_DEBUG.

An alternate approach for backwards compatibility would be to define
separate wrapper macros for ap_log_error and ap_log_rerror to use
when APLOG_TRACE1 is desired, and disable them in apache 2.2 unless
DEBUG is defined at compile time. But I'm not sure that's worth it,
since I'm still having trouble getting all of the non-request specific
log messages emitted in apache 2.2 to begin with.

Signed-off-by: Steve Beattie <[email protected]>
---
 changehat/mod_apparmor/mod_apparmor.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Index: b/changehat/mod_apparmor/mod_apparmor.c
===================================================================
--- a/changehat/mod_apparmor/mod_apparmor.c
+++ b/changehat/mod_apparmor/mod_apparmor.c
@@ -38,6 +38,7 @@
 
 /* Compatibility with apache 2.2 */
 #if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 3
+  #define APLOG_TRACE1 APLOG_DEBUG
   server_rec *ap_server_conf = NULL;
 #endif
 
@@ -79,7 +80,7 @@ immunix_init (apr_pool_t *p, apr_pool_t
     } else {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "Failed to open 
/dev/urandom");
     }
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Opened 
/dev/urandom successfully");
+    ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf, "Opened 
/dev/urandom successfully");
 
     return OK;
 }
@@ -92,7 +93,7 @@ immunix_child_init (apr_pool_t *p, serve
 {
     int ret;
 
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "init: calling 
change_hat");
+    ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf, "init: calling 
change_hat");
     ret = change_hat (DEFAULT_HAT, magic_token);
     if (ret < 0) {
        change_hat (NULL, magic_token);
@@ -139,7 +140,7 @@ immunix_enter_hat (request_rec *r)
                ap_get_module_config (r->server->module_config, 
&apparmor_module);
 
     debug_dump_uri (&r->parsed_uri);
-    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "in immunix_enter_hat (%s) 
n:0x%lx p:0x%lx main:0x%lx",
+    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "in immunix_enter_hat (%s) 
n:0x%lx p:0x%lx main:0x%lx",
        dcfg->path, (unsigned long) r->next, (unsigned long) r->prev, 
        (unsigned long) r->main);
 
@@ -269,7 +270,7 @@ immunix_create_dir_config (apr_pool_t *
 {
     immunix_dir_cfg * newcfg = (immunix_dir_cfg *) apr_pcalloc(p, sizeof(* 
newcfg));
 
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "in 
immunix_create_dir (%s)", path ? path : ":no path:");
+    ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf, "in 
immunix_create_dir (%s)", path ? path : ":no path:");
     if (newcfg == NULL) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, 
"immunix_create_dir: couldn't alloc dir config");
        return NULL;
@@ -299,7 +300,7 @@ immunix_create_srv_config (apr_pool_t *
 {
     immunix_srv_cfg * newcfg = (immunix_srv_cfg *) apr_pcalloc(p, sizeof(* 
newcfg));
 
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "in 
immunix_create_srv");
+    ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf, "in 
immunix_create_srv");
     if (newcfg == NULL) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, 
"immunix_create_srv: couldn't alloc srv config");
        return NULL;


-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to