"Fossies" - the Fresh Open Source Software Archive

Member "mod_fastcgi-2.4.7-0910052141/debian/patches/apache2.2-authn.dpatch" (10 Apr 2012, 3234 Bytes) of package /linux/www/apache_httpd_modules/old/mod_fastcgi-2.4.7-0910052141.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /bin/sh /usr/share/dpatch/dpatch-run
    2 ## apache2.2-authn.dpatch by  <sugi@nemui.org>
    3 ##
    4 ## All lines beginning with `## DP:' are a description of the patch.
    5 ## DP: mod_fastcgi works as AUTHN provider for apache 2.2
    6 ## 
    7 
    8 @DPATCH@
    9 diff -urNad libapache-mod-fastcgi~/mod_fastcgi.c libapache-mod-fastcgi/mod_fastcgi.c
   10 --- libapache-mod-fastcgi~/mod_fastcgi.c    2006-10-06 21:55:39.000000000 +0900
   11 +++ libapache-mod-fastcgi/mod_fastcgi.c 2007-08-25 16:51:25.000000000 +0900
   12 @@ -82,6 +82,10 @@
   13  
   14  #include "unixd.h"
   15  
   16 +#ifdef APACHE22
   17 +#include "mod_auth.h"
   18 +#endif
   19 +
   20  #endif
   21  #endif
   22  
   23 @@ -2657,10 +2661,15 @@
   24      r->status_line = NULL;
   25  }
   26  
   27 +#ifdef APACHE22
   28 +static authn_status check_user_authentication(request_rec *r, const char *user, const char *password)
   29 +{
   30 +#else /* !APACHE22 */
   31  static int check_user_authentication(request_rec *r)
   32  {
   33 -    int res, authenticated = 0;
   34      const char *password;
   35 +#endif
   36 +    int res, authenticated = 0;
   37      fcgi_request *fr;
   38      const fcgi_dir_config * const dir_config =
   39          (const fcgi_dir_config *)ap_get_module_config(r->per_dir_config, &fastcgi_module);
   40 @@ -2668,9 +2677,11 @@
   41      if (dir_config->authenticator == NULL)
   42          return DECLINED;
   43  
   44 -    /* Get the user password */
   45 +#ifndef APACHE22
   46 +       /* Get the user password */
   47      if ((res = ap_get_basic_auth_pw(r, &password)) != OK)
   48          return res;
   49 +#endif /* APACHE22 */
   50  
   51      res = create_fcgi_request(r, dir_config->authenticator, &fr);
   52      if (res)
   53 @@ -2704,6 +2715,20 @@
   54          goto AuthenticationFailed;
   55      }
   56  
   57 +#ifdef APACHE22
   58 +    if (authenticated)
   59 +        return AUTH_GRANTED;
   60 +
   61 +AuthenticationFailed:
   62 +    /* @@@ Probably should support custom_responses */
   63 +    ap_note_basic_auth_failure(r);
   64 +    ap_log_rerror(FCGI_LOG_ERR_NOERRNO, r,
   65 +        "FastCGI: authentication failed for user \"%s\": %s",
   66 +        r->user, r->uri);
   67 +
   68 +       return (res == OK) ? AUTH_DENIED : AUTH_GRANTED;
   69 +
   70 +#else /* !APACHE22 */
   71      if (authenticated)
   72          return OK;
   73  
   74 @@ -2722,6 +2747,7 @@
   75  #endif
   76  
   77          return (res == OK) ? HTTP_UNAUTHORIZED : res;
   78 +#endif /* !APACHE22 */
   79  }
   80  
   81  static int check_user_authorization(request_rec *r)
   82 @@ -2913,16 +2939,31 @@
   83  
   84  #ifdef APACHE2
   85  
   86 +#ifdef APACHE22
   87 +static const authn_provider authn_fastcgi_provider =
   88 +{
   89 +    &check_user_authentication,
   90 +       NULL,
   91 +};
   92 +#endif /* APACHE22 */
   93 +
   94 +
   95  static void register_hooks(apr_pool_t * p)
   96  {
   97      /* ap_hook_pre_config(x_pre_config, NULL, NULL, APR_HOOK_MIDDLE); */
   98      ap_hook_post_config(init_module, NULL, NULL, APR_HOOK_MIDDLE);
   99      ap_hook_child_init(fcgi_child_init, NULL, NULL, APR_HOOK_MIDDLE);
  100      ap_hook_handler(content_handler, NULL, NULL, APR_HOOK_MIDDLE);
  101 -    ap_hook_check_user_id(check_user_authentication, NULL, NULL, APR_HOOK_MIDDLE);
  102      ap_hook_access_checker(check_access, NULL, NULL, APR_HOOK_MIDDLE);
  103      ap_hook_auth_checker(check_user_authorization, NULL, NULL, APR_HOOK_MIDDLE);
  104      ap_hook_fixups(fixups, NULL, NULL, APR_HOOK_MIDDLE); 
  105 +#ifdef APACHE22
  106 +       ap_register_provider(p, AUTHN_PROVIDER_GROUP, "fastcgi", "0",
  107 +            &authn_fastcgi_provider);
  108 +#else
  109 +    ap_hook_check_user_id(check_user_authentication, NULL, NULL, APR_HOOK_MIDDLE);
  110 +#endif
  111 +
  112  }
  113  
  114  module AP_MODULE_DECLARE_DATA fastcgi_module =