httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c
Date Thu, 27 Feb 2003 12:33:08 GMT
trawick     2003/02/27 04:33:08

  Modified:    .        Tag: APACHE_2_0_BRANCH CHANGES STATUS
               modules/filters Tag: APACHE_2_0_BRANCH mod_ext_filter.c
               modules/generators Tag: APACHE_2_0_BRANCH mod_cgi.c
                        mod_cgid.c
  Log:
  merge this fix into stable branch:
  
  *) mod_cgi, mod_cgid, mod_ext_filter: Log errors when scripts cannot
     be started on Unix because of such problems as bad permissions,
     bad shebang line, etc.  [Jeff Trawick]
  
  Reviewed by:	nd, stoddard
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.988.2.50 +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.988.2.49
  retrieving revision 1.988.2.50
  diff -u -r1.988.2.49 -r1.988.2.50
  --- CHANGES	27 Feb 2003 11:57:31 -0000	1.988.2.49
  +++ CHANGES	27 Feb 2003 12:33:06 -0000	1.988.2.50
  @@ -1,5 +1,9 @@
   Changes with Apache 2.0.45
   
  +  *) mod_cgi, mod_cgid, mod_ext_filter: Log errors when scripts cannot
  +     be started on Unix because of such problems as bad permissions,
  +     bad shebang line, etc.  [Jeff Trawick]
  +
     *) Fix 64-bit problem in mod_ssl input logic.  
        [Madhusudan Mathihalli <madhusudan_mathihalli@hp.com>]
   
  
  
  
  1.751.2.129 +1 -17     httpd-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/STATUS,v
  retrieving revision 1.751.2.128
  retrieving revision 1.751.2.129
  diff -u -r1.751.2.128 -r1.751.2.129
  --- STATUS	27 Feb 2003 12:09:42 -0000	1.751.2.128
  +++ STATUS	27 Feb 2003 12:33:06 -0000	1.751.2.129
  @@ -109,22 +109,6 @@
         [ This one is under review.  Don't merge.  ]
         +1:
   
  -    * Better report problems with external scripts
  -      modules/filters/mod_ext_filter.c: r1.4
  -      modules/generators/mod_cgi.c: r1.151
  -      modules/generators/mod_cgid.c: r1.148
  -      +1: trawick, nd, stoddard
  -        nd: there's always the same function (foo_child_errfn), shouldn't it
  -        appear only once in util_script.c?
  -        trawick: The implementations are already different for mod_cgi
  -                 vs. mod_cgid, and I fear that a fix to mod_cgid to
  -                 use the right vhost-specific error log is going to
  -                 make them even more different in the future.
  -                 Meanwhile, there isn't enough commonality (LOC, not 
  -                 percentage) to spread the pieces over multiple files.
  -                 nd: argh. Really overlooked the slightly differences...
  -                     sounds right, however.
  -
       * Standardize mod_ldap and mod_auth_ldap SSL support across the various 
         LDAP SDKs.  Isolate the SSL functionality to mod_ldap rather than 
         speading it across mod_auth_ldap and mod_ldap.  Add LDAPTrustedCA
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +23 -0     httpd-2.0/modules/filters/mod_ext_filter.c
  
  Index: mod_ext_filter.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/filters/mod_ext_filter.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- mod_ext_filter.c	3 Feb 2003 17:31:38 -0000	1.1.2.2
  +++ mod_ext_filter.c	27 Feb 2003 12:33:07 -0000	1.1.2.3
  @@ -119,8 +119,11 @@
   static apr_status_t ef_output_filter(ap_filter_t *, apr_bucket_brigade *);
   
   #define DBGLVL_SHOWOPTIONS         1
  +#define DBGLVL_ERRORCHECK          2
   #define DBGLVL_GORY                9
   
  +#define ERRFN_USERDATA_KEY         "EXTFILTCHILDERRFN"
  +
   static void *create_ef_dir_conf(apr_pool_t *p, char *dummy)
   {
       ef_dir_t *dc = (ef_dir_t *)apr_pcalloc(p, sizeof(ef_dir_t));
  @@ -420,6 +423,17 @@
       return apr_file_close(vfile);
   }
   
  +static void child_errfn(apr_pool_t *p, apr_status_t err, const char *desc)
  +{
  +    request_rec *r;
  +    void *vr;
  +
  +    apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, p);
  +    r = vr;
  +    
  +    ap_log_rerror(APLOG_MARK, APLOG_ERR, err, r, "%s", desc);
  +}
  +
   /* init_ext_filter_process: get the external filter process going
    * This is per-filter-instance (i.e., per-request) initialization.
    */
  @@ -451,6 +465,15 @@
           ap_assert(rc == APR_SUCCESS);
       }
   
  +    rc = apr_procattr_child_errfn_set(ctx->procattr, child_errfn);
  +    ap_assert(rc == APR_SUCCESS);
  +    apr_pool_userdata_set(f->r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, ctx->p);
  +    
  +    if (dc->debug >= DBGLVL_ERRORCHECK) {
  +        rc = apr_procattr_error_check_set(ctx->procattr, 1);
  +        ap_assert(rc == APR_SUCCESS);
  +    }
  +    
       /* add standard CGI variables as well as DOCUMENT_URI, DOCUMENT_PATH_INFO,
        * and QUERY_STRING_UNESCAPED
        */
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.148.2.3 +18 -1     httpd-2.0/modules/generators/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
  retrieving revision 1.148.2.2
  retrieving revision 1.148.2.3
  diff -u -r1.148.2.2 -r1.148.2.3
  --- mod_cgi.c	3 Feb 2003 17:31:39 -0000	1.148.2.2
  +++ mod_cgi.c	27 Feb 2003 12:33:07 -0000	1.148.2.3
  @@ -122,6 +122,8 @@
   #define DEFAULT_LOGBYTES 10385760
   #define DEFAULT_BUFBYTES 1024
   
  +#define ERRFN_USERDATA_KEY         "CGICHILDERRFN"
  +
   typedef struct {
       const char *logname;
       long        logbytes;
  @@ -380,6 +382,18 @@
       }
   }
   
  +static void cgi_child_errfn(apr_pool_t *pool, apr_status_t err,
  +                            const char *description)
  +{
  +    request_rec *r;
  +    void *vr;
  +
  +    apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool);
  +    r = vr;
  +
  +    ap_log_rerror(APLOG_MARK, APLOG_ERR, err, r, "%s", description);
  +}
  +
   static apr_status_t run_cgi_child(apr_file_t **script_out,
                                     apr_file_t **script_in,
                                     apr_file_t **script_err, 
  @@ -452,12 +466,15 @@
                                           e_info->cmd_type)) != APR_SUCCESS) ||
   
           ((rc = apr_procattr_detach_set(procattr,
  -                                        e_info->detached)) != APR_SUCCESS)) {
  +                                        e_info->detached)) != APR_SUCCESS) ||
  +        ((rc = apr_procattr_child_errfn_set(procattr, cgi_child_errfn)) != APR_SUCCESS))
{
           /* Something bad happened, tell the world. */
           ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
                         "couldn't set child process attributes: %s", r->filename);
       }
       else {
  +        apr_pool_userdata_set(r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, p);
  +
           procnew = apr_pcalloc(p, sizeof(*procnew));
           if (e_info->prog_type == RUN_AS_SSI) {
               SPLIT_AND_PASS_PRETAG_BUCKETS(*(e_info->bb), e_info->ctx,
  
  
  
  1.145.2.3 +25 -1     httpd-2.0/modules/generators/mod_cgid.c
  
  Index: mod_cgid.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
  retrieving revision 1.145.2.2
  retrieving revision 1.145.2.3
  diff -u -r1.145.2.2 -r1.145.2.3
  --- mod_cgid.c	3 Feb 2003 17:31:39 -0000	1.145.2.2
  +++ mod_cgid.c	27 Feb 2003 12:33:08 -0000	1.145.2.3
  @@ -155,6 +155,8 @@
   #define SSI_REQ    2
   #define GETPID_REQ 3 /* get the pid of script created for prior request */
   
  +#define ERRFN_USERDATA_KEY         "CGIDCHILDERRFN"
  +
   /* DEFAULT_CGID_LISTENBACKLOG controls the max depth on the unix socket's
    * pending connection queue.  If a bunch of cgi requests arrive at about
    * the same time, connections from httpd threads/processes will back up
  @@ -202,6 +204,7 @@
       apr_size_t uri_len;
       apr_size_t args_len;
       apr_size_t mod_userdir_user_len;
  +    int loglevel; /* to stuff in server_rec */
   } cgid_req_t;
   
   /* This routine is called to create the argument list to be passed
  @@ -349,6 +352,7 @@
       if (stat != APR_SUCCESS) {
           return stat;
       }
  +    r->server->loglevel = req->loglevel;
       if (req->req_type == GETPID_REQ) {
           /* no more data sent for this request */
           return APR_SUCCESS;
  @@ -480,6 +484,7 @@
       if (user != NULL) {
           req.mod_userdir_user_len = strlen(user);
       }
  +    req.loglevel = r->server->loglevel;
   
       /* Write the request header */
       if ((stat = sock_write(fd, &req, sizeof(req))) != APR_SUCCESS) {
  @@ -565,6 +570,22 @@
       }
   }
   
  +static void cgid_child_errfn(apr_pool_t *pool, apr_status_t err,
  +                             const char *description)
  +{
  +    request_rec *r;
  +    void *vr;
  +
  +    apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool);
  +    r = vr;
  +
  +    /* sure we got r, but don't call ap_log_rerror() because we don't
  +     * have r->headers_in and possibly other storage referenced by
  +     * ap_log_rerror()
  +     */
  +    ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, "%s", description);
  +}
  +
   static int cgid_server(void *data) 
   { 
       struct sockaddr_un unix_addr;
  @@ -711,12 +732,15 @@
               ((rc = apr_procattr_child_out_set(procattr, inout, NULL)) != APR_SUCCESS) ||
               ((rc = apr_procattr_dir_set(procattr,
                                     ap_make_dirstr_parent(r->pool, r->filename))) !=
APR_SUCCESS) ||
  -            ((rc = apr_procattr_cmdtype_set(procattr, cmd_type)) != APR_SUCCESS)) {
  +            ((rc = apr_procattr_cmdtype_set(procattr, cmd_type)) != APR_SUCCESS) ||
  +            ((rc = apr_procattr_child_errfn_set(procattr, cgid_child_errfn)) != APR_SUCCESS))
{
               /* Something bad happened, tell the world. */
               ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
                         "couldn't set child process attributes: %s", r->filename);
           }
           else {
  +            apr_pool_userdata_set(r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, ptrans);
  +
               argv = (const char * const *)create_argv(r->pool, NULL, NULL, NULL, argv0,
r->args);
   
              /* We want to close sd2 for the new CGI process too.
  
  
  

Mime
View raw message