]> granicus.if.org Git - apache/commitdiff
Error out a bit more nicely if the RewriteMap prg: is not found. We
authorCliff Woolley <jwoolley@apache.org>
Wed, 29 May 2002 04:38:59 +0000 (04:38 +0000)
committerCliff Woolley <jwoolley@apache.org>
Wed, 29 May 2002 04:38:59 +0000 (04:38 +0000)
can't just apr_stat in the first init round because we haven't run
apr_tokenize_to_argv() yet, and it would be a relatively ugly hack to run
it twice just for that.  Well, I suppose we could store the argv in the
rewritemap structure, but ... nah.  With this, we shutdown (cleanly, as
opposed to the old exit(1) method) if we go to execute a rewritemap
and discover it doesn't exist, and log a nice descriptive message at the
end of the error_log.

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

modules/mappers/mod_rewrite.c
modules/mappers/mod_rewrite.h

index e8f2813cec6042841099409b6cb75d668b63cca0..a352fb3a4620daa28e16698db5235849f32582b6 100644 (file)
@@ -987,8 +987,11 @@ static int post_config(apr_pool_t *p,
      */
     for (; s; s = s->next) {
         open_rewritelog(s, p);
-        if (!first_time)
-           run_rewritemap_programs(s, p);
+        if (!first_time) {
+            if (run_rewritemap_programs(s, p) != APR_SUCCESS) {
+                return HTTP_INTERNAL_SERVER_ERROR;
+            }
+        }
     }
     return OK;
 }
@@ -3365,7 +3368,7 @@ static apr_status_t rewritelock_remove(void *data)
 ** +-------------------------------------------------------+
 */
 
-static void run_rewritemap_programs(server_rec *s, apr_pool_t *p)
+static apr_status_t run_rewritemap_programs(server_rec *s, apr_pool_t *p)
 {
     rewrite_server_conf *conf;
     apr_file_t *fpin = NULL;
@@ -3383,7 +3386,7 @@ static void run_rewritemap_programs(server_rec *s, apr_pool_t *p)
      *  don't even try to do anything.
      */
     if (conf->state == ENGINE_DISABLED) {
-        return;
+        return APR_SUCCESS;
     }
 
     rewritemaps = conf->rewritemaps;
@@ -3405,15 +3408,15 @@ static void run_rewritemap_programs(server_rec *s, apr_pool_t *p)
                                      &fpout, &fpin, &fperr);
         if (rc != APR_SUCCESS || fpin == NULL || fpout == NULL) {
             ap_log_error(APLOG_MARK, APLOG_ERR, rc, s,
-                         "mod_rewrite: could not fork child for "
-                         "RewriteMap process");
-            exit(1);
+                         "mod_rewrite: could not startup RewriteMap "
+                         "program %s", map->datafile);
+            return rc;
         }
         map->fpin  = fpin;
         map->fpout = fpout;
         map->fperr = fperr;
     }
-    return;
+    return APR_SUCCESS;
 }
 
 /* child process code */
@@ -3424,11 +3427,13 @@ static apr_status_t rewritemap_program_child(apr_pool_t *p, const char *progname
     apr_status_t rc;
     apr_procattr_t *procattr;
     apr_proc_t *procnew;
+    apr_finfo_t st;
     char **argv;
 
     rc = apr_tokenize_to_argv(progname, &argv, p);
 
-    if (((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) ||
+    if (((rc = apr_stat(&st, argv[0], APR_FINFO_MIN, p)) != APR_SUCCESS) ||
+        ((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) ||
         ((rc = apr_procattr_io_set(procattr, APR_FULL_BLOCK,
                                   APR_FULL_NONBLOCK,
                                   APR_FULL_NONBLOCK)) != APR_SUCCESS) ||
index 7590c11278408c24e7741d1baf41cbe192cf2cd4..14a4db73588cb60c93ee5337eec0c4da06e904cd 100644 (file)
@@ -455,7 +455,7 @@ static apr_status_t rewritelock_create(server_rec *s, apr_pool_t *p);
 static apr_status_t rewritelock_remove(void *data);
 
     /* program map support */
-static void  run_rewritemap_programs(server_rec *s, apr_pool_t *p);
+static apr_status_t run_rewritemap_programs(server_rec *s, apr_pool_t *p);
 static apr_status_t rewritemap_program_child(apr_pool_t *p, const char *progname,
                                              apr_file_t **fpout, apr_file_t **fpin,
                                              apr_file_t **fperr);