1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

Separate the stat structure from the file structure and use ap_stat and

ap_getfileinfo in apache.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84397 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan Bloom
2000-01-06 14:43:41 +00:00
parent 528afcc4d6
commit 8f26ac7df4
16 changed files with 66 additions and 75 deletions

View File

@@ -768,7 +768,7 @@ struct request_rec {
char *filename; char *filename;
char *path_info; char *path_info;
char *args; /* QUERY_ARGS, if any */ char *args; /* QUERY_ARGS, if any */
struct stat finfo; /* ST_MODE set to zero if no such file */ ap_finfo_t finfo; /* ST_MODE set to zero if no such file */
uri_components parsed_uri; /* components of uri, dismantled */ uri_components parsed_uri; /* components of uri, dismantled */
/* Various other config info which may change with .htaccess files /* Various other config info which may change with .htaccess files

View File

@@ -127,23 +127,21 @@ static void add_include_vars(request_rec *r, char *timefmt)
ap_time_t *date = r->request_time; ap_time_t *date = r->request_time;
ap_time_t *mtime = NULL; ap_time_t *mtime = NULL;
ap_make_time(&mtime, r->pool);
ap_set_curtime(mtime, r->finfo.st_mtime);
ap_table_setn(e, "DATE_LOCAL", ap_ht_time(r->pool, date, timefmt, 0)); ap_table_setn(e, "DATE_LOCAL", ap_ht_time(r->pool, date, timefmt, 0));
ap_table_setn(e, "DATE_GMT", ap_ht_time(r->pool, date, timefmt, 1)); ap_table_setn(e, "DATE_GMT", ap_ht_time(r->pool, date, timefmt, 1));
ap_table_setn(e, "LAST_MODIFIED", ap_table_setn(e, "LAST_MODIFIED",
ap_ht_time(r->pool, mtime, timefmt, 0)); ap_ht_time(r->pool, r->finfo.mtime, timefmt, 0));
ap_table_setn(e, "DOCUMENT_URI", r->uri); ap_table_setn(e, "DOCUMENT_URI", r->uri);
ap_table_setn(e, "DOCUMENT_PATH_INFO", r->path_info); ap_table_setn(e, "DOCUMENT_PATH_INFO", r->path_info);
#ifndef WIN32 #ifndef WIN32
pw = getpwuid(r->finfo.st_uid); pw = getpwuid(r->finfo.user);
if (pw) { if (pw) {
ap_table_setn(e, "USER_NAME", ap_pstrdup(r->pool, pw->pw_name)); ap_table_setn(e, "USER_NAME", ap_pstrdup(r->pool, pw->pw_name));
} }
else { else {
ap_table_setn(e, "USER_NAME", ap_psprintf(r->pool, "user#%lu", ap_table_setn(e, "USER_NAME", ap_psprintf(r->pool, "user#%lu",
(unsigned long) r->finfo.st_uid)); (unsigned long) r->finfo.user));
} }
#endif /* ndef WIN32 */ #endif /* ndef WIN32 */
@@ -596,7 +594,7 @@ static int include_cgi(char *s, request_rec *r)
if ((rr->path_info && rr->path_info[0]) || rr->args) { if ((rr->path_info && rr->path_info[0]) || rr->args) {
return -1; return -1;
} }
if (rr->finfo.st_mode == 0) { if (rr->finfo.protection == 0) {
return -1; return -1;
} }
@@ -1026,16 +1024,12 @@ static int handle_config(ap_file_t *in, request_rec *r, char *error, char *tf,
} }
else if (!strcmp(tag, "timefmt")) { else if (!strcmp(tag, "timefmt")) {
ap_time_t *date = r->request_time; ap_time_t *date = r->request_time;
ap_time_t *mtime = NULL;
ap_make_time(&mtime, r->pool);
ap_set_curtime(mtime, r->finfo.st_mtime);
parse_string(r, tag_val, tf, MAX_STRING_LEN, 0); parse_string(r, tag_val, tf, MAX_STRING_LEN, 0);
ap_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, tf, 0)); ap_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, tf, 0));
ap_table_setn(env, "DATE_GMT", ap_ht_time(r->pool, date, tf, 1)); ap_table_setn(env, "DATE_GMT", ap_ht_time(r->pool, date, tf, 1));
ap_table_setn(env, "LAST_MODIFIED", ap_table_setn(env, "LAST_MODIFIED",
ap_ht_time(r->pool, mtime, tf, 0)); ap_ht_time(r->pool, r->finfo.mtime, tf, 0));
} }
else if (!strcmp(tag, "sizefmt")) { else if (!strcmp(tag, "sizefmt")) {
parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0); parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
@@ -1078,7 +1072,7 @@ static int find_file(request_rec *r, const char *directive, const char *tag,
ap_getparents(tag_val); /* get rid of any nasties */ ap_getparents(tag_val); /* get rid of any nasties */
rr = ap_sub_req_lookup_file(tag_val, r); rr = ap_sub_req_lookup_file(tag_val, r);
if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) { if (rr->status == HTTP_OK && rr->finfo.protection != 0) {
to_send = rr->filename; to_send = rr->filename;
if (stat(to_send, finfo)) { if (stat(to_send, finfo)) {
error_fmt = "unable to get information about \"%s\" " error_fmt = "unable to get information about \"%s\" "
@@ -1104,7 +1098,7 @@ static int find_file(request_rec *r, const char *directive, const char *tag,
else if (!strcmp(tag, "virtual")) { else if (!strcmp(tag, "virtual")) {
rr = ap_sub_req_lookup_uri(tag_val, r); rr = ap_sub_req_lookup_uri(tag_val, r);
if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) { if (rr->status == HTTP_OK && rr->finfo.protection != 0) {
memcpy((char *) finfo, (const char *) &rr->finfo, memcpy((char *) finfo, (const char *) &rr->finfo,
sizeof(struct stat)); sizeof(struct stat));
ap_destroy_sub_req(rr); ap_destroy_sub_req(rr);
@@ -2361,7 +2355,7 @@ static int send_parsed_file(request_rec *r)
if (r->method_number != M_GET) { if (r->method_number != M_GET) {
return DECLINED; return DECLINED;
} }
if (r->finfo.st_mode == 0) { if (r->finfo.protection == 0) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"File does not exist: %s", "File does not exist: %s",
(r->path_info (r->path_info
@@ -2381,12 +2375,10 @@ static int send_parsed_file(request_rec *r)
if ((*state == xbithack_full) if ((*state == xbithack_full)
#if !defined(OS2) && !defined(WIN32) #if !defined(OS2) && !defined(WIN32)
/* OS/2 dosen't support Groups. */ /* OS/2 dosen't support Groups. */
&& (r->finfo.st_mode & S_IXGRP) && (r->finfo.protection & S_IXGRP)
#endif #endif
) { ) {
ap_make_time(&mtime, r->pool); ap_update_mtime(r, r->finfo.mtime);
ap_set_curtime(mtime, r->finfo.st_mtime);
ap_update_mtime(r, mtime);
ap_set_last_modified(r); ap_set_last_modified(r);
} }
if ((errstatus = ap_meets_conditions(r)) != OK) { if ((errstatus = ap_meets_conditions(r)) != OK) {
@@ -2411,7 +2403,7 @@ static int send_parsed_file(request_rec *r)
*/ */
r->subprocess_env = parent->subprocess_env; r->subprocess_env = parent->subprocess_env;
ap_pool_join(parent->pool, r->pool); ap_pool_join(parent->pool, r->pool);
r->finfo.st_mtime = parent->finfo.st_mtime; r->finfo.mtime = parent->finfo.mtime;
} }
else { else {
/* we're not a nested include, so we create an initial /* we're not a nested include, so we create an initial
@@ -2455,7 +2447,7 @@ static int xbithack_handler(request_rec *r)
#else #else
enum xbithack *state; enum xbithack *state;
if (!(r->finfo.st_mode & S_IXUSR)) { if (!(r->finfo.protection & S_IXUSR)) {
return DECLINED; return DECLINED;
} }

View File

@@ -72,7 +72,7 @@ static int asis_handler(request_rec *r)
r->allowed |= (1 << M_GET); r->allowed |= (1 << M_GET);
if (r->method_number != M_GET) if (r->method_number != M_GET)
return DECLINED; return DECLINED;
if (r->finfo.st_mode == 0) { if (r->finfo.protection == 0) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"File does not exist: %s", r->filename); "File does not exist: %s", r->filename);
return NOT_FOUND; return NOT_FOUND;

View File

@@ -953,7 +953,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
&& (rr = ap_sub_req_lookup_uri(header_fname, r)) && (rr = ap_sub_req_lookup_uri(header_fname, r))
&& (rr->status == HTTP_OK) && (rr->status == HTTP_OK)
&& (rr->filename != NULL) && (rr->filename != NULL)
&& S_ISREG(rr->finfo.st_mode)) { && S_ISREG(rr->finfo.protection)) {
/* /*
* Check for the two specific cases we allow: text/html and * Check for the two specific cases we allow: text/html and
* text/anything-else. The former is allowed to be processed for * text/anything-else. The former is allowed to be processed for
@@ -1036,7 +1036,7 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
&& (rr = ap_sub_req_lookup_uri(readme_fname, r)) && (rr = ap_sub_req_lookup_uri(readme_fname, r))
&& (rr->status == HTTP_OK) && (rr->status == HTTP_OK)
&& (rr->filename != NULL) && (rr->filename != NULL)
&& S_ISREG(rr->finfo.st_mode)) { && S_ISREG(rr->finfo.protection)) {
/* /*
* Check for the two specific cases we allow: text/html and * Check for the two specific cases we allow: text/html and
* text/anything-else. The former is allowed to be processed for * text/anything-else. The former is allowed to be processed for
@@ -1161,9 +1161,9 @@ static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
if (autoindex_opts & FANCY_INDEXING) { if (autoindex_opts & FANCY_INDEXING) {
request_rec *rr = ap_sub_req_lookup_file(name, r); request_rec *rr = ap_sub_req_lookup_file(name, r);
if (rr->finfo.st_mode != 0) { if (rr->finfo.protection != 0) {
p->lm = rr->finfo.st_mtime; ap_get_curtime(rr->finfo.mtime, (ap_int64_t *)&p->lm);
if (S_ISDIR(rr->finfo.st_mode)) { if (S_ISDIR(rr->finfo.protection)) {
if (!(p->icon = find_icon(d, rr, 1))) { if (!(p->icon = find_icon(d, rr, 1))) {
p->icon = find_default_icon(d, "^^DIRECTORY^^"); p->icon = find_default_icon(d, "^^DIRECTORY^^");
} }
@@ -1176,7 +1176,7 @@ static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
else { else {
p->icon = find_icon(d, rr, 0); p->icon = find_icon(d, rr, 0);
p->alt = find_alt(d, rr, 0); p->alt = find_alt(d, rr, 0);
p->size = rr->finfo.st_size; p->size = rr->finfo.size;
} }
} }

View File

@@ -492,11 +492,11 @@ static int cgi_handler(request_rec *r)
} }
} }
#else #else
if (r->finfo.st_mode == 0) if (r->finfo.protection == 0)
return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO, return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
"script not found or unable to stat"); "script not found or unable to stat");
#endif #endif
if (S_ISDIR(r->finfo.st_mode)) if (S_ISDIR(r->finfo.protection))
return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO, return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
"attempt to invoke directory as script"); "attempt to invoke directory as script");

View File

@@ -2491,7 +2491,7 @@ static int default_handler(request_rec *r)
if (r->method_number == M_PUT) { if (r->method_number == M_PUT) {
return METHOD_NOT_ALLOWED; return METHOD_NOT_ALLOWED;
} }
if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) { if (r->finfo.protection == 0 || (r->path_info && *r->path_info)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
"File does not exist: %s",r->path_info ? "File does not exist: %s",r->path_info ?
ap_pstrcat(r->pool, r->filename, r->path_info, NULL) ap_pstrcat(r->pool, r->filename, r->path_info, NULL)
@@ -2507,25 +2507,23 @@ static int default_handler(request_rec *r)
"file permissions deny server access: %s", r->filename); "file permissions deny server access: %s", r->filename);
return FORBIDDEN; return FORBIDDEN;
} }
ap_make_time(&temp, r->pool); ap_update_mtime(r, r->finfo.mtime);
ap_set_curtime(temp, r->finfo.st_mtime);
ap_update_mtime(r, temp);
ap_set_last_modified(r); ap_set_last_modified(r);
ap_set_etag(r); ap_set_etag(r);
ap_table_setn(r->headers_out, "Accept-Ranges", "bytes"); ap_table_setn(r->headers_out, "Accept-Ranges", "bytes");
if (((errstatus = ap_meets_conditions(r)) != OK) if (((errstatus = ap_meets_conditions(r)) != OK)
|| (errstatus = ap_set_content_length(r, r->finfo.st_size))) { || (errstatus = ap_set_content_length(r, r->finfo.size))) {
ap_close(fd); ap_close(fd);
return errstatus; return errstatus;
} }
#ifdef USE_MMAP_FILES #ifdef USE_MMAP_FILES
if ((r->finfo.st_size >= MMAP_THRESHOLD) if ((r->finfo.size >= MMAP_THRESHOLD)
&& (r->finfo.st_size < MMAP_LIMIT) && (r->finfo.size < MMAP_LIMIT)
&& (!r->header_only || (d->content_md5 & 1))) { && (!r->header_only || (d->content_md5 & 1))) {
/* we need to protect ourselves in case we die while we've got the /* we need to protect ourselves in case we die while we've got the
* file mmapped */ * file mmapped */
if (ap_mmap_create(&mm, fd, 0, r->finfo.st_size, r->pool) != APR_SUCCESS){ if (ap_mmap_create(&mm, fd, 0, r->finfo.size, r->pool) != APR_SUCCESS){
ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r, ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
"default_handler: mmap failed: %s", r->filename); "default_handler: mmap failed: %s", r->filename);
mm = NULL; mm = NULL;
@@ -2584,7 +2582,7 @@ static int default_handler(request_rec *r)
AP_MD5_CTX context; AP_MD5_CTX context;
ap_MD5Init(&context); ap_MD5Init(&context);
ap_MD5Update(&context, addr, (unsigned int)r->finfo.st_size); ap_MD5Update(&context, addr, (unsigned int)r->finfo.size);
ap_table_setn(r->headers_out, "Content-MD5", ap_table_setn(r->headers_out, "Content-MD5",
ap_md5contextTo64(r->pool, &context)); ap_md5contextTo64(r->pool, &context));
} }
@@ -2594,7 +2592,7 @@ static int default_handler(request_rec *r)
if (!r->header_only) { if (!r->header_only) {
if (!rangestatus) { if (!rangestatus) {
ap_send_mmap(mm, r, 0, r->finfo.st_size); ap_send_mmap(mm, r, 0, r->finfo.size);
} }
else { else {
ap_off_t offset; ap_off_t offset;

View File

@@ -537,11 +537,11 @@ API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak)
ap_timediff(r->request_time, r->mtime, &diff); ap_timediff(r->request_time, r->mtime, &diff);
weak = ((diff > 1) && !force_weak) ? "" : "W/"; weak = ((diff > 1) && !force_weak) ? "" : "W/";
if (r->finfo.st_mode != 0) { if (r->finfo.protection != 0) {
etag = ap_psprintf(r->pool, etag = ap_psprintf(r->pool,
"%s\"%lx-%lx-%lx\"", weak, "%s\"%lx-%lx-%lx\"", weak,
(unsigned long) r->finfo.st_ino, (unsigned long) r->finfo.inode,
(unsigned long) r->finfo.st_size, (unsigned long) r->finfo.size,
(unsigned long) r->mtime); (unsigned long) r->mtime);
} }
else { else {

View File

@@ -116,10 +116,10 @@ IMPLEMENT_HOOK_RUN_FIRST(int,auth_checker,(request_rec *r),(r),DECLINED)
static int check_safe_file(request_rec *r) static int check_safe_file(request_rec *r)
{ {
if (r->finfo.st_mode == 0 /* doesn't exist */ if (r->finfo.protection == 0 /* doesn't exist */
|| S_ISDIR(r->finfo.st_mode) || S_ISDIR(r->finfo.protection)
|| S_ISREG(r->finfo.st_mode) || S_ISREG(r->finfo.protection)
|| S_ISLNK(r->finfo.st_mode)) { || S_ISLNK(r->finfo.protection)) {
return OK; return OK;
} }
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
@@ -200,7 +200,7 @@ static int get_path_info(request_rec *r)
char bStripSlash=1; char bStripSlash=1;
#endif #endif
if (r->finfo.st_mode) { if (r->finfo.protection) {
/* assume path_info already set */ /* assume path_info already set */
return OK; return OK;
} }
@@ -260,20 +260,20 @@ static int get_path_info(request_rec *r)
} }
else { else {
errno = 0; errno = 0;
rv = stat(path, &r->finfo); rv = ap_stat(&r->finfo, path, r->pool);
} }
if (cp != end) if (cp != end)
*cp = '/'; *cp = '/';
if (!rv) { if (rv != APR_SUCCESS) {
/* /*
* Aha! Found something. If it was a directory, we will search * Aha! Found something. If it was a directory, we will search
* contents of that directory for a multi_match, so the PATH_INFO * contents of that directory for a multi_match, so the PATH_INFO
* argument starts with the component after that. * argument starts with the component after that.
*/ */
if (S_ISDIR(r->finfo.st_mode) && last_cp) { if (S_ISDIR(r->finfo.protection) && last_cp) {
r->finfo.st_mode = 0; /* No such file... */ r->finfo.protection = 0; /* No such file... */
cp = last_cp; cp = last_cp;
} }
@@ -284,7 +284,7 @@ static int get_path_info(request_rec *r)
/* must set this to zero, some stat()s may have corrupted it /* must set this to zero, some stat()s may have corrupted it
* even if they returned an error. * even if they returned an error.
*/ */
r->finfo.st_mode = 0; r->finfo.protection = 0;
#if defined(ENOENT) && defined(ENOTDIR) #if defined(ENOENT) && defined(ENOTDIR)
if (errno == ENOENT || errno == ENOTDIR) { if (errno == ENOENT || errno == ENOTDIR) {
@@ -354,7 +354,7 @@ static int directory_walk(request_rec *r)
if (r->filename == NULL) { if (r->filename == NULL) {
r->filename = ap_pstrdup(r->pool, r->uri); r->filename = ap_pstrdup(r->pool, r->uri);
r->finfo.st_mode = 0; /* Not really a file... */ r->finfo.protection = 0; /* Not really a file... */
r->per_dir_config = per_dir_defaults; r->per_dir_config = per_dir_defaults;
return OK; return OK;
@@ -436,7 +436,7 @@ static int directory_walk(request_rec *r)
if (test_filename[test_filename_len - 1] == '/') if (test_filename[test_filename_len - 1] == '/')
--num_dirs; --num_dirs;
if (S_ISDIR(r->finfo.st_mode)) if (S_ISDIR(r->finfo.protection))
++num_dirs; ++num_dirs;
/* /*
@@ -571,7 +571,7 @@ static int directory_walk(request_rec *r)
* S_ISDIR test. But if you accessed /symlink/index.html, for example, * S_ISDIR test. But if you accessed /symlink/index.html, for example,
* you would *not* get the 403. * you would *not* get the 403.
*/ */
if (!S_ISDIR(r->finfo.st_mode) if (!S_ISDIR(r->finfo.protection)
&& (res = check_symlinks(r->filename, ap_allow_options(r)))) { && (res = check_symlinks(r->filename, ap_allow_options(r)))) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"Symbolic link not allowed: %s", r->filename); "Symbolic link not allowed: %s", r->filename);
@@ -860,8 +860,8 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file,
rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file); rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file);
ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */ ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */
if (stat(rnew->filename, &rnew->finfo) < 0) { if (ap_stat(&rnew->finfo, rnew->filename, rnew->pool) != APR_SUCCESS) {
rnew->finfo.st_mode = 0; rnew->finfo.protection = 0;
} }
if ((res = check_safe_file(rnew))) { if ((res = check_safe_file(rnew))) {
@@ -875,7 +875,7 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file,
* no matter what, if it's a subdirectory, we need to re-run * no matter what, if it's a subdirectory, we need to re-run
* directory_walk * directory_walk
*/ */
if (S_ISDIR(rnew->finfo.st_mode)) { if (S_ISDIR(rnew->finfo.protection)) {
res = directory_walk(rnew); res = directory_walk(rnew);
if (!res) { if (!res) {
res = file_walk(rnew); res = file_walk(rnew);

View File

@@ -286,7 +286,7 @@ static int find_ct(request_rec *r)
const char *orighandler = r->handler; const char *orighandler = r->handler;
const char *type; const char *type;
if (S_ISDIR(r->finfo.st_mode)) { if (S_ISDIR(r->finfo.protection)) {
r->content_type = DIR_MAGIC_TYPE; r->content_type = DIR_MAGIC_TYPE;
return OK; return OK;
} }

View File

@@ -187,7 +187,7 @@ static int action_handler(request_rec *r)
if ((t = ap_table_get(conf->action_types, if ((t = ap_table_get(conf->action_types,
action ? action : ap_default_type(r)))) { action ? action : ap_default_type(r)))) {
script = t; script = t;
if (r->finfo.st_mode == 0) { if (r->finfo.protection == 0) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"File does not exist: %s", r->filename); "File does not exist: %s", r->filename);
return NOT_FOUND; return NOT_FOUND;

View File

@@ -161,7 +161,7 @@ static int handle_dir(request_rec *r)
char *name_ptr = *names_ptr; char *name_ptr = *names_ptr;
request_rec *rr = ap_sub_req_lookup_uri(name_ptr, r); request_rec *rr = ap_sub_req_lookup_uri(name_ptr, r);
if (rr->status == HTTP_OK && S_ISREG(rr->finfo.st_mode)) { if (rr->status == HTTP_OK && S_ISREG(rr->finfo.protection)) {
char *new_uri = ap_escape_uri(r->pool, rr->uri); char *new_uri = ap_escape_uri(r->pool, rr->uri);
if (rr->args != NULL) if (rr->args != NULL)

View File

@@ -284,15 +284,12 @@ static void set_mime_fields(var_rec *var, accept_rec *mime_info)
static void set_vlist_validator(request_rec *r, request_rec *vlistr) static void set_vlist_validator(request_rec *r, request_rec *vlistr)
{ {
ap_time_t *temp;
/* Calculating the variant list validator is similar to /* Calculating the variant list validator is similar to
* calculating an etag for the source of the variant list * calculating an etag for the source of the variant list
* information, so we use ap_make_etag(). Note that this * information, so we use ap_make_etag(). Note that this
* validator can be 'weak' in extreme case. * validator can be 'weak' in extreme case.
*/ */
ap_make_time(&temp, vlistr->pool); ap_update_mtime(vlistr, vlistr->finfo.mtime);
ap_set_curtime(temp, vlistr->finfo.st_mtime);
ap_update_mtime(vlistr, temp);
r->vlist_validator = ap_make_etag(vlistr, 0); r->vlist_validator = ap_make_etag(vlistr, 0);
/* ap_set_etag will later take r->vlist_validator into account /* ap_set_etag will later take r->vlist_validator into account
@@ -2581,7 +2578,7 @@ static int handle_multi(request_rec *r)
int res; int res;
int j; int j;
if (r->finfo.st_mode != 0 || !(ap_allow_options(r) & OPT_MULTI)) { if (r->finfo.protection != 0 || !(ap_allow_options(r) & OPT_MULTI)) {
return DECLINED; return DECLINED;
} }
@@ -2624,7 +2621,7 @@ static int handle_multi(request_rec *r)
/* BLECH --- don't multi-resolve non-ordinary files */ /* BLECH --- don't multi-resolve non-ordinary files */
if (!S_ISREG(sub_req->finfo.st_mode)) { if (!S_ISREG(sub_req->finfo.protection)) {
res = NOT_FOUND; res = NOT_FOUND;
goto return_from_multi; goto return_from_multi;
} }

View File

@@ -199,7 +199,7 @@ static int translate_userdir(request_rec *r)
const char *w, *dname; const char *w, *dname;
char *redirect; char *redirect;
char *x = NULL; char *x = NULL;
struct stat statbuf; ap_finfo_t statbuf;
/* /*
* If the URI doesn't match our basic pattern, we've nothing to do with * If the URI doesn't match our basic pattern, we've nothing to do with
@@ -313,7 +313,8 @@ static int translate_userdir(request_rec *r)
* anyway, in the hope that some handler might handle it. This can be * anyway, in the hope that some handler might handle it. This can be
* used, for example, to run a CGI script for the user. * used, for example, to run a CGI script for the user.
*/ */
if (filename && (!*userdirs || stat(filename, &statbuf) != -1)) { if (filename && (!*userdirs ||
ap_stat(&statbuf, filename, r->pool) == APR_SUCCESS)) {
r->filename = ap_pstrcat(r->pool, filename, dname, NULL); r->filename = ap_pstrcat(r->pool, filename, dname, NULL);
/* when statbuf contains info on r->filename we can save a syscall /* when statbuf contains info on r->filename we can save a syscall
* by copying it to r->finfo * by copying it to r->finfo

View File

@@ -1021,20 +1021,20 @@ void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *
{ {
const char *errmsg; const char *errmsg;
cmd_parms parms; cmd_parms parms;
ap_file_t *finfo = NULL; ap_finfo_t finfo;
fname = ap_server_root_relative(p, fname); fname = ap_server_root_relative(p, fname);
if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) || if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
!(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) { !(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
if (ap_stat(&finfo, fname, ptemp) != APR_SUCCESS) if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
return; return;
} }
/* don't require conf/httpd.conf if we have a -C or -c switch */ /* don't require conf/httpd.conf if we have a -C or -c switch */
if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) && if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
!(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) { !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
if (ap_stat(&finfo, fname, ptemp) != APR_SUCCESS) if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
return; return;
} }

View File

@@ -514,6 +514,7 @@ API_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
void ap_log_pid(ap_context_t *p, const char *fname) void ap_log_pid(ap_context_t *p, const char *fname)
{ {
ap_file_t *pid_file = NULL; ap_file_t *pid_file = NULL;
ap_finfo_t finfo;
static pid_t saved_pid = -1; static pid_t saved_pid = -1;
pid_t mypid; pid_t mypid;
@@ -522,7 +523,7 @@ void ap_log_pid(ap_context_t *p, const char *fname)
fname = ap_server_root_relative(p, fname); fname = ap_server_root_relative(p, fname);
mypid = getpid(); mypid = getpid();
if (mypid != saved_pid && ap_stat(&pid_file, fname, p) == 0) { if (mypid != saved_pid && ap_stat(&finfo, fname, p) == APR_SUCCESS) {
/* WINCH and HUP call this on each restart. /* WINCH and HUP call this on each restart.
* Only warn on first time through for this pid. * Only warn on first time through for this pid.
* *

View File

@@ -766,6 +766,7 @@ API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p
{ {
configfile_t *new_cfg; configfile_t *new_cfg;
ap_file_t *file = NULL; ap_file_t *file = NULL;
ap_finfo_t finfo;
ap_status_t stat; ap_status_t stat;
ap_filetype_e type; ap_filetype_e type;
@@ -791,7 +792,8 @@ API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p
if (stat != APR_SUCCESS) if (stat != APR_SUCCESS)
return stat; return stat;
stat = ap_get_filetype(&type, file); ap_getfileinfo(&finfo, file);
stat = ap_get_filetype(&type, finfo.protection);
if (stat != APR_SUCCESS) if (stat != APR_SUCCESS)
return stat; return stat;