]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Remove all occurances of strerror from Apache. ap_strerror works just
authorRyan Bloom <rbb@apache.org>
Fri, 9 Jun 2000 18:57:16 +0000 (18:57 +0000)
committerRyan Bloom <rbb@apache.org>
Fri, 9 Jun 2000 18:57:16 +0000 (18:57 +0000)
fine with standard errno values, and it is more portable.  This also allows
me to remove the check for strerror from Apache's configure script.

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

12 files changed:
configure.in
modules/aaa/mod_auth_db.c
modules/aaa/mod_auth_digest.c
modules/proxy/proxy_connect.c
modules/proxy/proxy_ftp.c
modules/proxy/proxy_http.c
os/beos/beosd.c
os/unix/unixd.c
os/win32/os.h
server/log.c
server/util.c
support/suexec.c

index 665a2920b6887e2b0ea26452d44678af821f5564..0bcb5e7fc672041b31c7d2eff169944d7bbf0cb5 100644 (file)
@@ -104,7 +104,6 @@ strdup \
 strcasecmp \
 strncasecmp \
 strstr \
-strerror \
 initgroups \
 waitpid \
 memmove \
index cbc263376e09c3e90a21186a8d9b61829f9d183d..1d325f922e84bc4d669033923e590174f373d5a4 100644 (file)
@@ -319,16 +319,10 @@ static int db_authenticate_basic_user(request_rec *r)
     invalid_pw = ap_validate_password(sent_pw, real_pw);
 
     if (invalid_pw != APR_SUCCESS) {
-#ifdef HAVE_APR_STRERROR
+        char buf[120]
        ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
                      "DB user %s: authentication failure for \"%s\": %s",
-                     r->user, r->uri, apr_strerror(invalid_pw));
-#else
-       ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
-                     "DB user %s: authentication failure for \"%s\": %d",
-                     r->user, r->uri, "error number",
-                     invalid_pw);
-#endif
+                     r->user, r->uri, ap_strerror(invalid_pw, buf, sizeof(buf)));
        ap_note_basic_auth_failure(r);
        return AUTH_REQUIRED;
     }
index f84182fa8283028b937154c054f67552fcf7f4ee..bd32184751c4f408181cbff019563a11abceb039 100644 (file)
@@ -302,9 +302,10 @@ static void initialize_secret(server_rec *s)
     status = ap_generate_random_bytes(secret, sizeof(secret));
 
     if(!(status == APR_SUCCESS)) {
+        char buf[120];
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, 0, s,
                     "Digest: error generating secret: %s", 
-                    /*ap_strerror(status)*/ "need ap_strerror here");
+                    ap_strerror(status, buf, sizeof(buf)));
        exit(1);
     }
 
index 7bf206a44719d42197d4a62c0a7948dd93cbc8e7..b87d81b9acf3873fa7e0825b848bdce103c58f76 100644 (file)
@@ -210,10 +210,12 @@ int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url,
        j++;
     }
     if (i == -1) {
+        char buf[120];
        ap_pclosesocket(r->pool, sock);
        return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, ap_pstrcat(r->pool,
                                        "Could not connect to remote machine:<br>",
-                                       strerror(errno), NULL));
+                                       ap_strerror(errno, buf, sizeof(buf)), 
+                                        NULL));
     }
 
     /* If we are connecting through a remote proxy, we need to pass
index 9804bcd510d98ba0a5424fe2996054f5dd25abe3..8b2e6ec08671644cb39e1fb8fb3967239971bea5 100644 (file)
@@ -605,10 +605,11 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url)
     }
 #endif
     if (i == -1) {
+        char buf[120];
        ap_pclosesocket(p, sock);
        return ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool,
                                "Could not connect to remote machine: ",
-                               strerror(errno), NULL));
+                               ap_strerror(errno, buf, sizeof(buf)), NULL));
     }
 
     f = ap_bcreate(p, B_RDWR | B_SOCKET);
@@ -855,10 +856,12 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url)
            i = ap_proxy_doconnect(dsock, &data_addr, r);
 
            if (i == -1) {
+                char buf[120];
                return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                                      ap_pstrcat(r->pool,
                                                 "Could not connect to remote machine: ",
-                                                strerror(errno), NULL));
+                                                ap_strerror(errno, buf, 
+                                                          sizeof(buf)), NULL));
            }
            else {
                pasvmode = 1;
index 895fb9ec9379a8b9c3b4e8fff0816ca1bbbedbf5..71f24c9b700eb8865ff4f3cab736663d7496811e 100644 (file)
@@ -293,9 +293,10 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url,
        if (proxyhost != NULL)
            return DECLINED;    /* try again another way */
        else
+            char buf[120];
            return ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool,
                                "Could not connect to remote machine: ",
-                               strerror(errno), NULL));
+                               ap_strerror(errno, buf, sizeof(buf)), NULL));
     }
 
     clear_connection(r->pool, r->headers_in);  /* Strip connection-based headers */
index 93ec59fca1555a10b0d984d72d831e317a9d5181..09c8d1fa615cda38fc3718276e5030297c560cbd 100644 (file)
@@ -81,9 +81,10 @@ void beosd_detach(void)
 
     /* close out the standard file descriptors */
     if (freopen("/dev/null", "r", stdin) == NULL) {
+        char buf[120];
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
                      "%s: unable to replace stdin with /dev/null: %s",
-               ap_server_argv0, strerror(errno));
+               ap_server_argv0, ap_strerror(errno, buf, sizeof(buf)));
        /* continue anyhow -- note we can't close out descriptor 0 because we
         * have nothing to replace it with, and if we didn't have a descriptor
         * 0 the next file would be created with that value ... leading to
@@ -91,9 +92,10 @@ void beosd_detach(void)
         */
     }
     if (freopen("/dev/null", "w", stdout) == NULL) {
+        char buf[120];
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
                      "%s: unable to replace stdout with /dev/null: %s",
-               ap_server_argv0, strerror(errno));
+               ap_server_argv0, ap_strerror(errno, buf, sizeof(buf)));
     }
     /* stderr is a tricky one, we really want it to be the error_log,
      * but we haven't opened that yet.  So leave it alone for now and it'll
index 4409dd7f5d49c8d800b74cd42dd872b8f3588c33..5a933a8531da62abd1ab23426496d86641bda63b 100644 (file)
@@ -118,9 +118,10 @@ void unixd_detach(void)
 
     /* close out the standard file descriptors */
     if (freopen("/dev/null", "r", stdin) == NULL) {
+        char buf[120];
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
                      "%s: unable to replace stdin with /dev/null: %s",
-               ap_server_argv0, strerror(errno));
+               ap_server_argv0, ap_strerror(errno, buf, sizeof(buf)));
        /* continue anyhow -- note we can't close out descriptor 0 because we
         * have nothing to replace it with, and if we didn't have a descriptor
         * 0 the next file would be created with that value ... leading to
@@ -128,9 +129,10 @@ void unixd_detach(void)
         */
     }
     if (freopen("/dev/null", "w", stdout) == NULL) {
+        char buf[120];
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
                      "%s: unable to replace stdout with /dev/null: %s",
-                    ap_server_argv0, strerror(errno));
+                    ap_server_argv0, ap_strerror(errno, buf, sizeof(buf)));
     }
     /* stderr is a tricky one, we really want it to be the error_log,
      * but we haven't opened that yet.  So leave it alone for now and it'll
index 1b5deb3e4dc934366879b63e9788c2f587301906..d20914d32f1d76b72c8cef8107a3897e9884223b 100644 (file)
@@ -118,7 +118,6 @@ typedef char * caddr_t;
 #define HAVE_MEMMOVE
 #define HAVE_STRCASECMP
 #define HAVE_STRNCASECMP
-#define HAVE_STRERROR
 #define HAVE_STRDUP
 #define HAVE_STRSTR
 
index 60bd796a15c87b78d261c4eb0c8173305e04ff10..9e8d6c93ed562b85f8fd64a32e3824f0868a6a16 100644 (file)
@@ -590,17 +590,19 @@ static int piped_log_spawn(piped_log *pl)
     int rc;
     ap_procattr_t *procattr;
     ap_proc_t procnew;
+    ap_status_t status;
 
 #ifdef SIGHUP
     ap_signal(SIGHUP, SIG_IGN);
 #endif
-    if ((ap_createprocattr_init(&procattr, pl->p)         != APR_SUCCESS) ||
-        (ap_setprocattr_childin(procattr, ap_piped_log_read_fd(pl), 
-                                ap_piped_log_write_fd(pl)) != APR_SUCCESS)) {
+    if (((status = ap_createprocattr_init(&procattr, pl->p)) != APR_SUCCESS) ||
+        ((status = ap_setprocattr_childin(procattr, ap_piped_log_read_fd(pl), 
+                                ap_piped_log_write_fd(pl)))  != APR_SUCCESS)) {
+        char buf[120];
         /* Something bad happened, give up and go away. */
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
-           "piped_log_spawn: unable to exec '%s': %s",
-           pl->program, strerror (errno));
+           "piped_log_spawn: unable to setup child process '%s': %s",
+           pl->program, ap_strerror(status, buf, sizeof(buf)));
         rc = -1;
     }
     else {
@@ -630,6 +632,7 @@ static int piped_log_spawn(piped_log *pl)
 static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
 {
     piped_log *pl = data;
+    ap_status_t stats;
 
     switch (reason) {
     case APR_OC_REASON_DEATH:
@@ -647,12 +650,13 @@ static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
            /* during a restart */
            break;
        }
-       if (piped_log_spawn(pl) != APR_SUCCESS) {
+       if ((stats = piped_log_spawn(pl)) != APR_SUCCESS) {
            /* what can we do?  This could be the error log we're having
             * problems opening up... */
+            char buf[120];
            ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
                "piped_log_maintenance: unable to respawn '%s': %s",
-               pl->program, strerror(errno));
+               pl->program, ap_strerror(stats, buf, sizeof(buf)));
        }
        break;
     
index bc8b9c55e31447a2fae1af8e55e831ea043f21a9..5c7e834aa862d9ace53ed0110e0f1063b1d4ace2 100644 (file)
@@ -838,7 +838,10 @@ API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_pool_t *p, c
     configfile_t *new_cfg;
     ap_file_t *file = NULL;
     ap_finfo_t finfo;
-    ap_status_t stat;
+    ap_status_t status;
+#ifdef DEBUG
+    char buf[120];
+#endif
 
     if (name == NULL) {
         ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
@@ -853,18 +856,19 @@ API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_pool_t *p, c
         return APR_EACCES;
     }
 
-    stat = ap_open(&file, name, APR_READ, APR_OS_DEFAULT, p);
+    status = ap_open(&file, name, APR_READ, APR_OS_DEFAULT, p);
 #ifdef DEBUG
     ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL,
                 "Opening config file %s (%s)",
-                name, (stat != APR_SUCCESS) ? strerror(errno) : "successful");
+                name, (status != APR_SUCCESS) ? 
+                ap_strerror(status, buf, sizeof(buf)) : "successful");
 #endif
-    if (stat != APR_SUCCESS)
-        return stat;
+    if (status != APR_SUCCESS)
+        return status;
 
-    stat = ap_getfileinfo(&finfo, file);
-    if (stat != APR_SUCCESS)
-        return stat;
+    status = ap_getfileinfo(&finfo, file);
+    if (status != APR_SUCCESS)
+        return status;
 
     if (finfo.filetype != APR_REG &&
 #if defined(WIN32) || defined(OS2)
@@ -2025,19 +2029,6 @@ API_EXPORT(char *) ap_uuencode(ap_pool_t *p, char *string)
     return ap_pbase64encode(p, string);
 }
 
-#ifndef HAVE_STRERROR
-char *
-     strerror(int err)
-{
-
-    char *p;
-    extern char *const sys_errlist[];
-
-    p = sys_errlist[err];
-    return (p);
-}
-#endif
-
 /* we want to downcase the type/subtype for comparison purposes
  * but nothing else because ;parameter=foo values are case sensitive.
  * XXX: in truth we want to downcase parameter names... but really,
index c31a0f3751192a7c78d889d3dffa6a597f9e3ff4..e5e3215afe1e740ea132fb0cd95a5dea236c2381 100644 (file)
@@ -251,6 +251,7 @@ int main(int argc, char *argv[])
     struct group *gr;          /* group entry holder        */
     struct stat dir_info;      /* directory info holder     */
     struct stat prg_info;      /* program info holder       */
+    char buf[120];
 
     /*
      * If there are a proper number of arguments, set
@@ -351,7 +352,7 @@ int main(int argc, char *argv[])
        {
        case -1:        /* Error */
            log_err("failed to setup bs2000 environment for user %s: %s\n",
-                   target_uname, strerror(errno));
+                   target_uname, ap_strerror(errno, buf, sizeof(buf)));
            exit(150);
        case 0: /* Child */
            break;
@@ -558,6 +559,7 @@ int main(int argc, char *argv[])
      *
      * Oh well, log the failure and error out.
      */
-    log_err("(%d)%s: exec failed (%s)\n", errno, strerror(errno), cmd);
+    log_err("(%d)%s: exec failed (%s)\n", errno, 
+            ap_strerror(errno, buf, sizeof(buf)), cmd);
     exit(255);
 }