/[Apache-SVN]/httpd/httpd/trunk/modules/aaa/mod_authn_dbd.c
ViewVC logotype

Diff of /httpd/httpd/trunk/modules/aaa/mod_authn_dbd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 420983, Tue Jul 11 20:33:53 2006 UTC revision 466865, Sun Oct 22 19:11:51 2006 UTC
# Line 18  Line 18 
18  #include "httpd.h"  #include "httpd.h"
19  #include "http_config.h"  #include "http_config.h"
20  #include "http_log.h"  #include "http_log.h"
21    #include "apr_lib.h"
22  #include "apr_dbd.h"  #include "apr_dbd.h"
23  #include "mod_dbd.h"  #include "mod_dbd.h"
24  #include "apr_strings.h"  #include "apr_strings.h"
25  #include "mod_auth.h"  #include "mod_auth.h"
26  #include "apr_md5.h"  #include "apr_md5.h"
27    #include "apu_version.h"
28    
29  module AP_MODULE_DECLARE_DATA authn_dbd_module;  module AP_MODULE_DECLARE_DATA authn_dbd_module;
30    
# Line 101  static authn_status authn_dbd_password(r Line 103  static authn_status authn_dbd_password(r
103      }      }
104    
105      if (conf->user == NULL) {      if (conf->user == NULL) {
106          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "No DBD Authn configured!");          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "No AuthDBDUserPWQuery has been specified.");
107          return AUTH_GENERAL_ERROR;          return AUTH_GENERAL_ERROR;
108      }      }
109    
110      statement = apr_hash_get(dbd->prepared, conf->user, APR_HASH_KEY_STRING);      statement = apr_hash_get(dbd->prepared, conf->user, APR_HASH_KEY_STRING);
111      if (statement == NULL) {      if (statement == NULL) {
112          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "No DBD Authn configured!");          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "A prepared statement could not be found for AuthDBDUserPWQuery, key '%s'.", conf->user);
113          return AUTH_GENERAL_ERROR;          return AUTH_GENERAL_ERROR;
114      }      }
115      if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement,      if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement,
# Line 126  static authn_status authn_dbd_password(r Line 128  static authn_status authn_dbd_password(r
128          }          }
129          if (dbd_password == NULL) {          if (dbd_password == NULL) {
130              dbd_password = apr_dbd_get_entry(dbd->driver, row, 0);              dbd_password = apr_dbd_get_entry(dbd->driver, row, 0);
131    
132    #if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3)
133                /* add the rest of the columns to the environment */
134                int i = 1;
135                const char *name;
136                for (name = apr_dbd_get_name(dbd->driver, res, i);
137                     name != NULL;
138                     name = apr_dbd_get_name(dbd->driver, res, i)) {
139    
140                    char *str = apr_pstrcat(r->pool, AUTHN_PREFIX,
141                                            name,
142                                            NULL);
143                    int j = 13;
144                    while (str[j]) {
145                        if (!apr_isalnum(str[j])) {
146                            str[j] = '_';
147                        }
148                        else {
149                            str[j] = apr_toupper(str[j]);
150                        }
151                        j++;
152                    }
153                    apr_table_setn(r->subprocess_env, str,
154                                   apr_dbd_get_entry(dbd->driver, row, i));
155                    i++;
156                }
157    #endif
158          }          }
159          /* we can't break out here or row won't get cleaned up */          /* we can't break out here or row won't get cleaned up */
160      }      }
# Line 160  static authn_status authn_dbd_realm(requ Line 189  static authn_status authn_dbd_realm(requ
189          return AUTH_GENERAL_ERROR;          return AUTH_GENERAL_ERROR;
190      }      }
191      if (conf->realm == NULL) {      if (conf->realm == NULL) {
192          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "No DBD Authn configured!");          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "No AuthDBDUserRealmQuery has been specified.");
193          return AUTH_GENERAL_ERROR;          return AUTH_GENERAL_ERROR;
194      }      }
195      statement = apr_hash_get(dbd->prepared, conf->realm, APR_HASH_KEY_STRING);      statement = apr_hash_get(dbd->prepared, conf->realm, APR_HASH_KEY_STRING);
196      if (statement == NULL) {      if (statement == NULL) {
197          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "No DBD Authn configured!");          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "A prepared statement could not be found for AuthDBDUserRealmQuery, key '%s'.", conf->realm);
198          return AUTH_GENERAL_ERROR;          return AUTH_GENERAL_ERROR;
199      }      }
200      if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement,      if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement,
# Line 184  static authn_status authn_dbd_realm(requ Line 213  static authn_status authn_dbd_realm(requ
213          }          }
214          if (dbd_hash == NULL) {          if (dbd_hash == NULL) {
215              dbd_hash = apr_dbd_get_entry(dbd->driver, row, 0);              dbd_hash = apr_dbd_get_entry(dbd->driver, row, 0);
216    
217    #if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3)
218                /* add the rest of the columns to the environment */
219                int i = 1;
220                const char *name;
221                for (name = apr_dbd_get_name(dbd->driver, res, i);
222                     name != NULL;
223                     name = apr_dbd_get_name(dbd->driver, res, i)) {
224    
225                    char *str = apr_pstrcat(r->pool, AUTHN_PREFIX,
226                                            name,
227                                            NULL);
228                    int j = 13;
229                    while (str[j]) {
230                        if (!apr_isalnum(str[j])) {
231                            str[j] = '_';
232                        }
233                        else {
234                            str[j] = apr_toupper(str[j]);
235                        }
236                        j++;
237                    }
238                    apr_table_setn(r->subprocess_env, str,
239                                   apr_dbd_get_entry(dbd->driver, row, i));
240                    i++;
241                }
242    #endif
243          }          }
244          /* we can't break out here or row won't get cleaned up */          /* we can't break out here or row won't get cleaned up */
245      }      }

Legend:
Removed from v.420983  
changed lines
  Added in v.466865

apache@apache.org
ViewVC Help
Powered by ViewVC 1.1.2