[apparmor] [patch 4/8] mod_apparmor: convert change_hat to aa_change_hat()

Steve Beattie steve at nxnw.org
Wed Jan 22 20:47:50 UTC 2014


mod_apparmor never got converted to use the renamed aa_change_hat()
call (there's a compatibility macro in sys/apparmor.h); this patch does
that as well as converting the type of the magic_token to long from int.

(This patch is somewhat mooted by a later patch in the series to
convert to using aa_change_hatv(), but would be a safer candidate
for e.g. the 2.8 branch.)

Signed-off-by: Steve Beattie <steve at nxnw.org>
---
 changehat/mod_apparmor/mod_apparmor.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

Index: b/changehat/mod_apparmor/mod_apparmor.c
===================================================================
--- a/changehat/mod_apparmor/mod_apparmor.c
+++ b/changehat/mod_apparmor/mod_apparmor.c
@@ -47,7 +47,7 @@
 #endif
 module AP_MODULE_DECLARE_DATA apparmor_module;
 
-static unsigned int magic_token = 0;
+static unsigned long magic_token = 0;
 static int inside_default_hat = 0;
 
 typedef struct {
@@ -94,9 +94,9 @@ immunix_child_init (apr_pool_t *p, serve
     int ret;
 
     ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf, "init: calling change_hat");
-    ret = change_hat (DEFAULT_HAT, magic_token);
+    ret = aa_change_hat(DEFAULT_HAT, magic_token);
     if (ret < 0) {
-    	change_hat (NULL, magic_token);
+    	aa_change_hat(NULL, magic_token);
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "Failed to change_hat to '%s'",
 			DEFAULT_HAT);
     } else {
@@ -145,41 +145,41 @@ immunix_enter_hat (request_rec *r)
     	return OK;
 
     if (inside_default_hat) {
-        change_hat (NULL, magic_token);
+        aa_change_hat(NULL, magic_token);
 	inside_default_hat = 0;
     }
 
     if (dcfg != NULL && dcfg->hat_name != NULL) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "calling change_hat [dcfg] %s", dcfg->hat_name);
-        sd_ret = change_hat (dcfg->hat_name, magic_token);
+        sd_ret = aa_change_hat(dcfg->hat_name, magic_token);
 	if (sd_ret < 0) {
-	    change_hat (NULL, magic_token);
+	    aa_change_hat(NULL, magic_token);
 	} else {
 	    return OK;
 	}
     }
 
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "calling change_hat [uri] %s", r->uri);
-    sd_ret = change_hat (r->uri, magic_token);
+    sd_ret = aa_change_hat(r->uri, magic_token);
     if (sd_ret < 0) {
-    	change_hat (NULL, magic_token);
+    	aa_change_hat(NULL, magic_token);
     } else {
 	    return OK;
     }
 
     if (scfg != NULL && scfg->hat_name != NULL) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "calling change_hat [scfg] %s", scfg->hat_name);
-        sd_ret = change_hat (scfg->hat_name, magic_token);
+        sd_ret = aa_change_hat(scfg->hat_name, magic_token);
 	if (sd_ret < 0) {
-	    change_hat (NULL, magic_token);
+	    aa_change_hat(NULL, magic_token);
 	} else {
 	    return OK;
 	}
     }
 
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "calling change_hat DEFAULT_URI");
-    sd_ret = change_hat (DEFAULT_URI_HAT, magic_token);
-    if (sd_ret < 0) change_hat (NULL, magic_token);
+    sd_ret = aa_change_hat(DEFAULT_URI_HAT, magic_token);
+    if (sd_ret < 0) aa_change_hat(NULL, magic_token);
 
     return OK;
 }
@@ -193,11 +193,11 @@ immunix_exit_hat (request_rec *r)
     /* immunix_srv_cfg * scfg = (immunix_srv_cfg *)
     		ap_get_module_config (r->server->module_config, &apparmor_module); */
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "exiting change_hat - dir hat %s path %s", dcfg->hat_name, dcfg->path);
-    change_hat (NULL, magic_token);
+    aa_change_hat(NULL, magic_token);
 
-    sd_ret = change_hat (DEFAULT_HAT, magic_token);
+    sd_ret = aa_change_hat(DEFAULT_HAT, magic_token);
     if (sd_ret < 0) {
-    	change_hat (NULL, magic_token);
+    	aa_change_hat(NULL, magic_token);
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Failed to change_hat to '%s'",
 			DEFAULT_HAT);
     } else {




More information about the AppArmor mailing list