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

Function add_cern_meta_data

modules/metadata/mod_cern_meta.c:267–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267static int add_cern_meta_data(request_rec *r)
268{
269 char *metafilename;
270 char *leading_slash;
271 char *last_slash;
272 char *real_file;
273 char *scrap_book;
274 apr_file_t *f = NULL;
275 apr_status_t retcode;
276 cern_meta_dir_config *dconf;
277 int rv;
278 request_rec *rr;
279
280 dconf = ap_get_module_config(r->per_dir_config, &cern_meta_module);
281
282 if (!dconf->metafiles) {
283 return DECLINED;
284 }
285
286 /* if ./.web/$1.meta exists then output 'asis' */
287
288 if (r->finfo.filetype == APR_NOFILE) {
289 return DECLINED;
290 }
291
292 /* is this a directory? */
293 if (r->finfo.filetype == APR_DIR || r->uri[strlen(r->uri) - 1] == '/') {
294 return DECLINED;
295 }
296
297 /* what directory is this file in? */
298 scrap_book = apr_pstrdup(r->pool, r->filename);
299
300 leading_slash = strchr(scrap_book, '/');
301 last_slash = strrchr(scrap_book, '/');
302 if ((last_slash != NULL) && (last_slash != leading_slash)) {
303 /* skip over last slash */
304 real_file = last_slash;
305 real_file++;
306 *last_slash = '\0';
307 }
308 else {
309 /* no last slash, buh?! */
310 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01561)
311 "internal error in mod_cern_meta: %s", r->filename);
312 /* should really barf, but hey, let's be friends... */
313 return DECLINED;
314 }
315
316 metafilename = apr_pstrcat(r->pool, scrap_book, "/",
317 dconf->metadir ? dconf->metadir : DEFAULT_METADIR,
318 "/", real_file,
319 dconf->metasuffix ? dconf->metasuffix : DEFAULT_METASUFFIX,
320 NULL);
321
322 /* It sucks to require this subrequest to complete, because this
323 * means people must leave their meta files accessible to the world.
324 * A better solution might be a "safe open" feature of pfopen to avoid

Callers

nothing calls this directly

Calls 4

ap_get_module_configFunction · 0.85
ap_sub_req_lookup_fileFunction · 0.85
ap_destroy_sub_reqFunction · 0.85
scan_meta_fileFunction · 0.85

Tested by

no test coverage detected