char *filename;
char *path_info;
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 */
/* Various other config info which may change with .htaccess files
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);
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, "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_PATH_INFO", r->path_info);
#ifndef WIN32
- pw = getpwuid(r->finfo.st_uid);
+ pw = getpwuid(r->finfo.user);
if (pw) {
ap_table_setn(e, "USER_NAME", ap_pstrdup(r->pool, pw->pw_name));
}
else {
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 */
if ((rr->path_info && rr->path_info[0]) || rr->args) {
return -1;
}
- if (rr->finfo.st_mode == 0) {
+ if (rr->finfo.protection == 0) {
return -1;
}
}
else if (!strcmp(tag, "timefmt")) {
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);
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, "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")) {
parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
ap_getparents(tag_val); /* get rid of any nasties */
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;
if (stat(to_send, finfo)) {
error_fmt = "unable to get information about \"%s\" "
else if (!strcmp(tag, "virtual")) {
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,
sizeof(struct stat));
ap_destroy_sub_req(rr);
if (r->method_number != M_GET) {
return DECLINED;
}
- if (r->finfo.st_mode == 0) {
+ if (r->finfo.protection == 0) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"File does not exist: %s",
(r->path_info
if ((*state == xbithack_full)
#if !defined(OS2) && !defined(WIN32)
/* OS/2 dosen't support Groups. */
- && (r->finfo.st_mode & S_IXGRP)
+ && (r->finfo.protection & S_IXGRP)
#endif
) {
- ap_make_time(&mtime, r->pool);
- ap_set_curtime(mtime, r->finfo.st_mtime);
- ap_update_mtime(r, mtime);
+ ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);
}
if ((errstatus = ap_meets_conditions(r)) != OK) {
*/
r->subprocess_env = parent->subprocess_env;
ap_pool_join(parent->pool, r->pool);
- r->finfo.st_mtime = parent->finfo.st_mtime;
+ r->finfo.mtime = parent->finfo.mtime;
}
else {
/* we're not a nested include, so we create an initial
#else
enum xbithack *state;
- if (!(r->finfo.st_mode & S_IXUSR)) {
+ if (!(r->finfo.protection & S_IXUSR)) {
return DECLINED;
}
r->allowed |= (1 << M_GET);
if (r->method_number != M_GET)
return DECLINED;
- if (r->finfo.st_mode == 0) {
+ if (r->finfo.protection == 0) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"File does not exist: %s", r->filename);
return NOT_FOUND;
&& (rr = ap_sub_req_lookup_uri(header_fname, r))
&& (rr->status == HTTP_OK)
&& (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
* text/anything-else. The former is allowed to be processed for
&& (rr = ap_sub_req_lookup_uri(readme_fname, r))
&& (rr->status == HTTP_OK)
&& (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
* text/anything-else. The former is allowed to be processed for
if (autoindex_opts & FANCY_INDEXING) {
request_rec *rr = ap_sub_req_lookup_file(name, r);
- if (rr->finfo.st_mode != 0) {
- p->lm = rr->finfo.st_mtime;
- if (S_ISDIR(rr->finfo.st_mode)) {
+ if (rr->finfo.protection != 0) {
+ ap_get_curtime(rr->finfo.mtime, (ap_int64_t *)&p->lm);
+ if (S_ISDIR(rr->finfo.protection)) {
if (!(p->icon = find_icon(d, rr, 1))) {
p->icon = find_default_icon(d, "^^DIRECTORY^^");
}
else {
p->icon = find_icon(d, rr, 0);
p->alt = find_alt(d, rr, 0);
- p->size = rr->finfo.st_size;
+ p->size = rr->finfo.size;
}
}
}
}
#else
- if (r->finfo.st_mode == 0)
+ if (r->finfo.protection == 0)
return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
"script not found or unable to stat");
#endif
- if (S_ISDIR(r->finfo.st_mode))
+ if (S_ISDIR(r->finfo.protection))
return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
"attempt to invoke directory as script");
if (r->method_number == M_PUT) {
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,
"File does not exist: %s",r->path_info ?
ap_pstrcat(r->pool, r->filename, r->path_info, NULL)
"file permissions deny server access: %s", r->filename);
return FORBIDDEN;
}
- ap_make_time(&temp, r->pool);
- ap_set_curtime(temp, r->finfo.st_mtime);
- ap_update_mtime(r, temp);
+ ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);
ap_set_etag(r);
ap_table_setn(r->headers_out, "Accept-Ranges", "bytes");
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);
return errstatus;
}
#ifdef USE_MMAP_FILES
- if ((r->finfo.st_size >= MMAP_THRESHOLD)
- && (r->finfo.st_size < MMAP_LIMIT)
+ if ((r->finfo.size >= MMAP_THRESHOLD)
+ && (r->finfo.size < MMAP_LIMIT)
&& (!r->header_only || (d->content_md5 & 1))) {
/* we need to protect ourselves in case we die while we've got the
* 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,
"default_handler: mmap failed: %s", r->filename);
mm = NULL;
AP_MD5_CTX 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_md5contextTo64(r->pool, &context));
}
if (!r->header_only) {
if (!rangestatus) {
- ap_send_mmap(mm, r, 0, r->finfo.st_size);
+ ap_send_mmap(mm, r, 0, r->finfo.size);
}
else {
ap_off_t offset;
ap_timediff(r->request_time, r->mtime, &diff);
weak = ((diff > 1) && !force_weak) ? "" : "W/";
- if (r->finfo.st_mode != 0) {
+ if (r->finfo.protection != 0) {
etag = ap_psprintf(r->pool,
"%s\"%lx-%lx-%lx\"", weak,
- (unsigned long) r->finfo.st_ino,
- (unsigned long) r->finfo.st_size,
+ (unsigned long) r->finfo.inode,
+ (unsigned long) r->finfo.size,
(unsigned long) r->mtime);
}
else {
static int check_safe_file(request_rec *r)
{
- if (r->finfo.st_mode == 0 /* doesn't exist */
- || S_ISDIR(r->finfo.st_mode)
- || S_ISREG(r->finfo.st_mode)
- || S_ISLNK(r->finfo.st_mode)) {
+ if (r->finfo.protection == 0 /* doesn't exist */
+ || S_ISDIR(r->finfo.protection)
+ || S_ISREG(r->finfo.protection)
+ || S_ISLNK(r->finfo.protection)) {
return OK;
}
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
char bStripSlash=1;
#endif
- if (r->finfo.st_mode) {
+ if (r->finfo.protection) {
/* assume path_info already set */
return OK;
}
}
else {
errno = 0;
- rv = stat(path, &r->finfo);
+ rv = ap_stat(&r->finfo, path, r->pool);
}
if (cp != end)
*cp = '/';
- if (!rv) {
+ if (rv != APR_SUCCESS) {
/*
* Aha! Found something. If it was a directory, we will search
* contents of that directory for a multi_match, so the PATH_INFO
* argument starts with the component after that.
*/
- if (S_ISDIR(r->finfo.st_mode) && last_cp) {
- r->finfo.st_mode = 0; /* No such file... */
+ if (S_ISDIR(r->finfo.protection) && last_cp) {
+ r->finfo.protection = 0; /* No such file... */
cp = last_cp;
}
/* must set this to zero, some stat()s may have corrupted it
* even if they returned an error.
*/
- r->finfo.st_mode = 0;
+ r->finfo.protection = 0;
#if defined(ENOENT) && defined(ENOTDIR)
if (errno == ENOENT || errno == ENOTDIR) {
if (r->filename == NULL) {
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;
return OK;
if (test_filename[test_filename_len - 1] == '/')
--num_dirs;
- if (S_ISDIR(r->finfo.st_mode))
+ if (S_ISDIR(r->finfo.protection))
++num_dirs;
/*
* S_ISDIR test. But if you accessed /symlink/index.html, for example,
* 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)))) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"Symbolic link not allowed: %s", r->filename);
rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file);
ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */
- if (stat(rnew->filename, &rnew->finfo) < 0) {
- rnew->finfo.st_mode = 0;
+ if (ap_stat(&rnew->finfo, rnew->filename, rnew->pool) != APR_SUCCESS) {
+ rnew->finfo.protection = 0;
}
if ((res = check_safe_file(rnew))) {
* no matter what, if it's a subdirectory, we need to re-run
* directory_walk
*/
- if (S_ISDIR(rnew->finfo.st_mode)) {
+ if (S_ISDIR(rnew->finfo.protection)) {
res = directory_walk(rnew);
if (!res) {
res = file_walk(rnew);
const char *orighandler = r->handler;
const char *type;
- if (S_ISDIR(r->finfo.st_mode)) {
+ if (S_ISDIR(r->finfo.protection)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
if ((t = ap_table_get(conf->action_types,
action ? action : ap_default_type(r)))) {
script = t;
- if (r->finfo.st_mode == 0) {
+ if (r->finfo.protection == 0) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"File does not exist: %s", r->filename);
return NOT_FOUND;
char *name_ptr = *names_ptr;
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);
if (rr->args != NULL)
static void set_vlist_validator(request_rec *r, request_rec *vlistr)
{
- ap_time_t *temp;
/* Calculating the variant list validator is similar to
* calculating an etag for the source of the variant list
* information, so we use ap_make_etag(). Note that this
* validator can be 'weak' in extreme case.
*/
- ap_make_time(&temp, vlistr->pool);
- ap_set_curtime(temp, vlistr->finfo.st_mtime);
- ap_update_mtime(vlistr, temp);
+ ap_update_mtime(vlistr, vlistr->finfo.mtime);
r->vlist_validator = ap_make_etag(vlistr, 0);
/* ap_set_etag will later take r->vlist_validator into account
int res;
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;
}
/* 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;
goto return_from_multi;
}
const char *w, *dname;
char *redirect;
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
* anyway, in the hope that some handler might handle it. This can be
* 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);
/* when statbuf contains info on r->filename we can save a syscall
* by copying it to r->finfo
{
const char *errmsg;
cmd_parms parms;
- ap_file_t *finfo = NULL;
+ ap_finfo_t finfo;
fname = ap_server_root_relative(p, fname);
if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_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;
}
/* 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) &&
!(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;
}
void ap_log_pid(ap_context_t *p, const char *fname)
{
ap_file_t *pid_file = NULL;
+ ap_finfo_t finfo;
static pid_t saved_pid = -1;
pid_t mypid;
fname = ap_server_root_relative(p, fname);
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.
* Only warn on first time through for this pid.
*
{
configfile_t *new_cfg;
ap_file_t *file = NULL;
+ ap_finfo_t finfo;
ap_status_t stat;
ap_filetype_e type;
if (stat != APR_SUCCESS)
return stat;
- stat = ap_get_filetype(&type, file);
+ ap_getfileinfo(&finfo, file);
+ stat = ap_get_filetype(&type, finfo.protection);
if (stat != APR_SUCCESS)
return stat;