You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brad Nicholes <BN...@novell.com> on 2002/05/06 21:49:36 UTC

Re: cvs commit: httpd-2.0/modules/mappers mod_rewrite.c mod_rewrite.h

  Why are we calling a Unix specific function in the middle of a module?
 Since unixd_set_global_mutex_perms() doesn't exist on NetWare,
mod_rewrite won't compile.  Should this be handled in APR somewhere?

Brad



Brad Nicholes
Senior Software Engineer
Novell, Inc., a leading provider of Net business solutions
http://www.novell.com 

>>> aaron@apache.org Monday, May 06, 2002 12:24:04 PM >>>
aaron       02/05/06 11:24:04

  Modified:    modules/mappers mod_rewrite.c mod_rewrite.h
  Log:
  Fix mod_rewrite hang when APR uses SysV Semaphores. Before we were
  silently failing when locking/unlocking the mutex, since httpd
  child processes didn't have permissions to access the root-created
  semaphore.
  
  PR: 8143
  
  Revision  Changes    Path
  1.111     +26 -6     httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- mod_rewrite.c	6 May 2002 18:04:53 -0000	1.110
  +++ mod_rewrite.c	6 May 2002 18:24:03 -0000	1.111
  @@ -964,7 +964,19 @@
           return HTTP_INTERNAL_SERVER_ERROR;
       }
   
  -    rewritelock_create(s, p);
  +    rv = unixd_set_global_mutex_perms(rewrite_log_lock);
  +    if (rv != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
  +                     "mod_rewrite: Could not set permissions on "
  +                     "rewrite_log_lock; check User and Group
directives");
  +        return HTTP_INTERNAL_SERVER_ERROR;
  +    }
  +
  +    rv = rewritelock_create(s, p);
  +    if (rv != APR_SUCCESS) {
  +        return HTTP_INTERNAL_SERVER_ERROR;
  +    }
  +
       apr_pool_cleanup_register(p, (void *)s, rewritelock_remove,
apr_pool_cleanup_null);
   
       /* step through the servers and
  @@ -3296,26 +3308,34 @@
   
   #define REWRITELOCK_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD |
APR_WREAD )
   
  -static void rewritelock_create(server_rec *s, apr_pool_t *p)
  +static apr_status_t rewritelock_create(server_rec *s, apr_pool_t
*p)
   {
       apr_status_t rc;
   
       /* only operate if a lockfile is used */
       if (lockname == NULL || *(lockname) == '\0') {
  -        return;
  +        return APR_EINVAL;
       }
   
       /* create the lockfile */
       rc = apr_global_mutex_create(&rewrite_mapr_lock_acquire,
lockname,
                                    APR_LOCK_DEFAULT, p);
       if (rc != APR_SUCCESS) {
  -        ap_log_error(APLOG_MARK, APLOG_ERR, rc, s,
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s,
                        "mod_rewrite: Parent could not create
RewriteLock "
                        "file %s", lockname);
  -        exit(1);
  +        return rc;
       }
   
  -    return;
  +    rc = unixd_set_global_mutex_perms(rewrite_mapr_lock_acquire);
  +    if (rc != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s,
  +                     "mod_rewrite: Parent could not set permissions
"
  +                     "on RewriteLock; check User and Group
directives");
  +        return rc;
  +    }
  +
  +    return APR_SUCCESS;
   }
   
   static apr_status_t rewritelock_remove(void *data)
  
  
  
  1.32      +1 -1      httpd-2.0/modules/mappers/mod_rewrite.h
  
  Index: mod_rewrite.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- mod_rewrite.h	6 May 2002 03:10:24 -0000	1.31
  +++ mod_rewrite.h	6 May 2002 18:24:03 -0000	1.32
  @@ -451,7 +451,7 @@
   static char *current_logtime(request_rec *r);
   
       /* rewriting lockfile support */
  -static void rewritelock_create(server_rec *s, apr_pool_t *p);
  +static apr_status_t rewritelock_create(server_rec *s, apr_pool_t
*p);
   static apr_status_t rewritelock_remove(void *data);
   
       /* program map support */
  
  
  

Re: cvs commit: httpd-2.0/modules/mappers mod_rewrite.c mod_rewrite.h

Posted by Aaron Bannert <aa...@clove.org>.
On Mon, May 06, 2002 at 01:49:36PM -0600, Brad Nicholes wrote:
>   Why are we calling a Unix specific function in the middle of a module?
>  Since unixd_set_global_mutex_perms() doesn't exist on NetWare,
> mod_rewrite won't compile.  Should this be handled in APR somewhere?

For now, would this take care of it? I know this is a stupid thing
to have, but until we have a better permissions setup in APR this
seems like the only way to get it working. The same thing needs to
happen anywhere we use an inherited proc or global mutex in a module
(mod_ssl is the next target).

-aaron



Index: modules/mappers/mod_rewrite.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
retrieving revision 1.111
diff -u -u -r1.111 mod_rewrite.c
--- modules/mappers/mod_rewrite.c	6 May 2002 18:24:03 -0000	1.111
+++ modules/mappers/mod_rewrite.c	6 May 2002 20:02:08 -0000
@@ -964,6 +964,7 @@
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
+#if !defined(OS2) && !defined(WIN32) && !defined(BEOS)  && !defined(NETWARE)
     rv = unixd_set_global_mutex_perms(rewrite_log_lock);
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
@@ -971,6 +972,7 @@
                      "rewrite_log_lock; check User and Group directives");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
+#endif
 
     rv = rewritelock_create(s, p);
     if (rv != APR_SUCCESS) {
@@ -3327,6 +3329,7 @@
         return rc;
     }
 
+#if !defined(OS2) && !defined(WIN32) && !defined(BEOS)  && !defined(NETWARE)
     rc = unixd_set_global_mutex_perms(rewrite_mapr_lock_acquire);
     if (rc != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s,
@@ -3334,6 +3337,7 @@
                      "on RewriteLock; check User and Group directives");
         return rc;
     }
+#endif
 
     return APR_SUCCESS;
 }

Re: cvs commit: httpd-2.0/modules/mappers mod_rewrite.c mod_rewrite.h

Posted by Aaron Bannert <aa...@clove.org>.
On Mon, May 06, 2002 at 01:49:36PM -0600, Brad Nicholes wrote:
>   Why are we calling a Unix specific function in the middle of a module?
>  Since unixd_set_global_mutex_perms() doesn't exist on NetWare,
> mod_rewrite won't compile.  Should this be handled in APR somewhere?

Hmm...good point. What #ifdef protection should I use?

This *should* be handled by APR, but I think that will take a lot more
work and for now SysV Sem is broken whenever we use setuid(). We need to
abstract out some concept of permissions that works across all platforms
and can be used for things like this. In this case, it would be useful
to perscribe to the apr_global_mutex.h interface that we want a lock
that is accessible to the httpd child processes. I have no idea how we
can do this across the different types of authn/authz frameworks on our
various platforms.

-aaron