]> granicus.if.org Git - apache/commitdiff
- use apr_strerror() instead of strerror()
authorRainer Jung <rjung@apache.org>
Tue, 12 May 2009 16:30:55 +0000 (16:30 +0000)
committerRainer Jung <rjung@apache.org>
Tue, 12 May 2009 16:30:55 +0000 (16:30 +0000)
- log errno via param when using ap_log_*

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@773968 13f79535-47bb-0310-9956-ffa450edef68

modules/arch/unix/mod_privileges.c

index 5d97dd4a2554d0e7fbd1bb2637354d437974a3af..bfdcc99ff2e06a0f1a9bc4ba1a34538bbb132323 100644 (file)
 /* TODO - get rid of unixd dependency */
 #include "unixd.h"
 
-#define CFG_CHECK(x) if (x == -1) return strerror(errno);
+#define CFG_CHECK(x) if ((x) == -1) { \
+    char msgbuf[128]; \
+    apr_strerror(errno, msgbuf, sizeof(msgbuf)); \
+    return apr_pstrdup(cmd->pool, msgbuf); \
+}
 #define CR_CHECK(x) if (x == -1) \
-    ap_log_error(APLOG_MARK, APLOG_CRIT,0,0, \
-                 "Failed to initialise privileges: %s", strerror(errno))
+    ap_log_error(APLOG_MARK, APLOG_CRIT, errno, 0, \
+                 "Failed to initialise privileges")
 
 module AP_MODULE_DECLARE_DATA privileges_module;
 
@@ -161,8 +165,8 @@ static apr_status_t privileges_end_req(void *data)
 
     /* restore default privileges */
     if (setppriv(PRIV_SET, PRIV_EFFECTIVE, priv_default) == -1) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                      "Error restoring default privileges: %s", strerror(errno));
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
+                      "Error restoring default privileges");
     }
     return APR_SUCCESS;
 }
@@ -271,29 +275,28 @@ static int privileges_req(request_rec *r)
     }
     /* set vhost's privileges */
     if (setppriv(PRIV_SET, PRIV_EFFECTIVE, cfg->priv) == -1) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                      "Error setting effective privileges: %s", strerror(errno));
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
+                      "Error setting effective privileges");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
     /* ... including those of any subprocesses */
     if (setppriv(PRIV_SET, PRIV_INHERITABLE, cfg->child_priv) == -1) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                      "Error setting inheritable privileges: %s", strerror(errno));
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
+                      "Error setting inheritable privileges");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
     if (setppriv(PRIV_SET, PRIV_LIMIT, cfg->child_priv) == -1) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                      "Error setting limit privileges: %s", strerror(errno));
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
+                      "Error setting limit privileges");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
     /* If we're in a child process, drop down PPERM too */
     if (fork_req) {
         if (setppriv(PRIV_SET, PRIV_PERMITTED, cfg->priv) == -1) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                          "Error setting permitted privileges: %s",
-                          strerror(errno));
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
+                          "Error setting permitted privileges");
             return HTTP_INTERNAL_SERVER_ERROR;
         }
     }
@@ -301,8 +304,8 @@ static int privileges_req(request_rec *r)
     return OK;
 }
 #define PDROP_CHECK(x) if (x == -1) { \
-        ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, \
-                     "Error dropping privileges: %s", strerror(errno)); \
+        ap_log_error(APLOG_MARK, APLOG_CRIT, errno, s, \
+                     "Error dropping privileges"); \
         return !OK; \
     }
 
@@ -377,8 +380,8 @@ static int privileges_postconf(apr_pool_t *pconf, apr_pool_t *plog,
                               apr_pool_cleanup_null);
     priv_emptyset(priv_setid);
     if (priv_addset(priv_setid, PRIV_PROC_SETID) == -1) {
-        ap_log_perror(APLOG_MARK, APLOG_CRIT, 0, ptemp,
-                      "priv_addset: %s", strerror(errno));
+        ap_log_perror(APLOG_MARK, APLOG_CRIT, errno, ptemp,
+                      "priv_addset");
         return !OK;
     }
     return OK;