MCPcopy Create free account
hub / github.com/apache/httpd / get_realm_hash

Function get_realm_hash

modules/aaa/mod_authn_file.c:113–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static authn_status get_realm_hash(request_rec *r, const char *user,
114 const char *realm, char **rethash)
115{
116 authn_file_config_rec *conf = ap_get_module_config(r->per_dir_config,
117 &authn_file_module);
118 ap_configfile_t *f;
119 char l[MAX_STRING_LEN];
120 apr_status_t status;
121 char *file_hash = NULL;
122
123 if (!conf->pwfile) {
124 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01621)
125 "AuthUserFile not specified in the configuration");
126 return AUTH_GENERAL_ERROR;
127 }
128
129 status = ap_pcfg_openfile(&f, r->pool, conf->pwfile);
130
131 if (status != APR_SUCCESS) {
132 ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01622)
133 "Could not open password file: %s", conf->pwfile);
134 return AUTH_GENERAL_ERROR;
135 }
136
137 while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
138 const char *rpw, *w, *x;
139
140 /* Skip # or blank lines. */
141 if ((l[0] == '#') || (!l[0])) {
142 continue;
143 }
144
145 rpw = l;
146 w = ap_getword(r->pool, &rpw, ':');
147 x = ap_getword(r->pool, &rpw, ':');
148
149 if (x && w && !strcmp(user, w) && !strcmp(realm, x)) {
150 /* Remember that this is a md5 hash of user:realm:password. */
151 file_hash = ap_getword(r->pool, &rpw, ':');
152 break;
153 }
154 }
155 ap_cfg_closefile(f);
156
157 if (!file_hash) {
158 return AUTH_USER_NOT_FOUND;
159 }
160
161 *rethash = file_hash;
162 AUTHN_CACHE_STORE(r, user, realm, file_hash);
163
164 return AUTH_USER_FOUND;
165}
166
167static const authn_provider authn_file_provider =
168{

Callers

nothing calls this directly

Calls 4

ap_get_module_configFunction · 0.85
ap_cfg_getlineFunction · 0.85
ap_getwordFunction · 0.85
ap_cfg_closefileFunction · 0.85

Tested by

no test coverage detected