mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Rework ap_finfo_t to split the file type out of the protection field.
I've taken a stab at the unix implementation but tested only on OS/2. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84416 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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->status == HTTP_OK)
|
||||
&& (rr->filename != NULL)
|
||||
&& S_ISREG(rr->finfo.protection)) {
|
||||
&& rr->finfo.filetype == APR_REG) {
|
||||
/*
|
||||
* Check for the two specific cases we allow: text/html and
|
||||
* 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->status == HTTP_OK)
|
||||
&& (rr->filename != NULL)
|
||||
&& S_ISREG(rr->finfo.protection)) {
|
||||
&& rr->finfo.filetype == APR_REG) {
|
||||
/*
|
||||
* Check for the two specific cases we allow: text/html and
|
||||
* text/anything-else. The former is allowed to be processed for
|
||||
@@ -1163,7 +1163,7 @@ static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
|
||||
|
||||
if (rr->finfo.protection != 0) {
|
||||
p->lm = rr->finfo.mtime;
|
||||
if (S_ISDIR(rr->finfo.protection)) {
|
||||
if (rr->finfo.filetype == APR_DIR) {
|
||||
if (!(p->icon = find_icon(d, rr, 1))) {
|
||||
p->icon = find_default_icon(d, "^^DIRECTORY^^");
|
||||
}
|
||||
|
@@ -482,7 +482,7 @@ static int cgi_handler(request_rec *r)
|
||||
|
||||
#if defined(OS2) || defined(WIN32)
|
||||
/* Allow for cgi files without the .EXE extension on them under OS/2 */
|
||||
if (r->finfo.st_mode == 0) {
|
||||
if (r->finfo.protection == 0) {
|
||||
struct stat statbuf;
|
||||
char *newfile;
|
||||
|
||||
@@ -500,7 +500,7 @@ static int cgi_handler(request_rec *r)
|
||||
return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
|
||||
"script not found or unable to stat");
|
||||
#endif
|
||||
if (S_ISDIR(r->finfo.protection))
|
||||
if (r->finfo.filetype == APR_DIR)
|
||||
return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
|
||||
"attempt to invoke directory as script");
|
||||
|
||||
|
@@ -117,11 +117,12 @@ static int check_safe_file(request_rec *r)
|
||||
{
|
||||
|
||||
if (r->finfo.protection == 0 /* doesn't exist */
|
||||
|| S_ISDIR(r->finfo.protection)
|
||||
|| S_ISREG(r->finfo.protection)
|
||||
|| S_ISLNK(r->finfo.protection)) {
|
||||
|| r->finfo.filetype == APR_DIR
|
||||
|| r->finfo.filetype == APR_REG
|
||||
|| r->finfo.filetype == APR_LNK) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
|
||||
"object is not a file, directory or symlink: %s",
|
||||
r->filename);
|
||||
@@ -272,8 +273,9 @@ static int get_path_info(request_rec *r)
|
||||
* contents of that directory for a multi_match, so the PATH_INFO
|
||||
* argument starts with the component after that.
|
||||
*/
|
||||
if (S_ISDIR(r->finfo.protection) && last_cp) {
|
||||
if (r->finfo.filetype == APR_DIR && last_cp) {
|
||||
r->finfo.protection = 0; /* No such file... */
|
||||
r->finfo.filetype = APR_NOFILE; /* No such file... */
|
||||
cp = last_cp;
|
||||
}
|
||||
|
||||
@@ -286,8 +288,8 @@ static int get_path_info(request_rec *r)
|
||||
*/
|
||||
r->finfo.protection = 0;
|
||||
|
||||
#if defined(ENOENT) && defined(ENOTDIR)
|
||||
if (errno == ENOENT || errno == ENOTDIR) {
|
||||
#if defined(APR_ENOENT) && defined(APR_ENOTDIR)
|
||||
if (rv == APR_ENOENT || rv == APR_ENOTDIR) {
|
||||
last_cp = cp;
|
||||
|
||||
while (--cp > path && *cp != '/')
|
||||
@@ -297,10 +299,10 @@ static int get_path_info(request_rec *r)
|
||||
--cp;
|
||||
}
|
||||
else {
|
||||
#if defined(EACCES)
|
||||
if (errno != EACCES)
|
||||
#if defined(APR_EACCES)
|
||||
if (rv != APR_EACCES)
|
||||
#endif
|
||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
|
||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
|
||||
"access to %s failed", r->uri);
|
||||
return HTTP_FORBIDDEN;
|
||||
}
|
||||
@@ -355,6 +357,7 @@ static int directory_walk(request_rec *r)
|
||||
if (r->filename == NULL) {
|
||||
r->filename = ap_pstrdup(r->pool, r->uri);
|
||||
r->finfo.protection = 0; /* Not really a file... */
|
||||
r->finfo.filetype = APR_NOFILE;
|
||||
r->per_dir_config = per_dir_defaults;
|
||||
|
||||
return OK;
|
||||
@@ -436,7 +439,7 @@ static int directory_walk(request_rec *r)
|
||||
if (test_filename[test_filename_len - 1] == '/')
|
||||
--num_dirs;
|
||||
|
||||
if (S_ISDIR(r->finfo.protection))
|
||||
if (r->finfo.filetype == APR_DIR)
|
||||
++num_dirs;
|
||||
|
||||
/*
|
||||
@@ -571,7 +574,7 @@ static int directory_walk(request_rec *r)
|
||||
* S_ISDIR test. But if you accessed /symlink/index.html, for example,
|
||||
* you would *not* get the 403.
|
||||
*/
|
||||
if (!S_ISDIR(r->finfo.protection)
|
||||
if (r->finfo.filetype != APR_DIR
|
||||
&& (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);
|
||||
@@ -875,7 +878,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
|
||||
* directory_walk
|
||||
*/
|
||||
if (S_ISDIR(rnew->finfo.protection)) {
|
||||
if (rnew->finfo.filetype == APR_DIR) {
|
||||
res = directory_walk(rnew);
|
||||
if (!res) {
|
||||
res = file_walk(rnew);
|
||||
|
@@ -286,7 +286,7 @@ static int find_ct(request_rec *r)
|
||||
const char *orighandler = r->handler;
|
||||
const char *type;
|
||||
|
||||
if (S_ISDIR(r->finfo.protection)) {
|
||||
if (r->finfo.filetype == APR_DIR) {
|
||||
r->content_type = DIR_MAGIC_TYPE;
|
||||
return OK;
|
||||
}
|
||||
|
@@ -161,7 +161,7 @@ static int handle_dir(request_rec *r)
|
||||
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.protection)) {
|
||||
if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
|
||||
char *new_uri = ap_escape_uri(r->pool, rr->uri);
|
||||
|
||||
if (rr->args != NULL)
|
||||
|
@@ -2621,7 +2621,7 @@ static int handle_multi(request_rec *r)
|
||||
|
||||
/* BLECH --- don't multi-resolve non-ordinary files */
|
||||
|
||||
if (!S_ISREG(sub_req->finfo.protection)) {
|
||||
if (sub_req->finfo.filetype != APR_REG) {
|
||||
res = NOT_FOUND;
|
||||
goto return_from_multi;
|
||||
}
|
||||
|
@@ -314,7 +314,7 @@ static int add_cern_meta_data(request_rec *r)
|
||||
};
|
||||
|
||||
/* is this a directory? */
|
||||
if (S_ISDIR(r->finfo.protection) || r->uri[strlen(r->uri) - 1] == '/') {
|
||||
if (r->finfo.filetype == APR_DIR || r->uri[strlen(r->uri) - 1] == '/') {
|
||||
return DECLINED;
|
||||
};
|
||||
|
||||
|
@@ -756,7 +756,6 @@ API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p
|
||||
ap_file_t *file = NULL;
|
||||
ap_finfo_t finfo;
|
||||
ap_status_t stat;
|
||||
ap_filetype_e type;
|
||||
|
||||
if (name == NULL) {
|
||||
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
|
||||
@@ -780,12 +779,11 @@ API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p
|
||||
if (stat != APR_SUCCESS)
|
||||
return stat;
|
||||
|
||||
ap_getfileinfo(&finfo, file);
|
||||
stat = ap_get_filetype(&type, finfo.protection);
|
||||
stat = ap_getfileinfo(&finfo, file);
|
||||
if (stat != APR_SUCCESS)
|
||||
return stat;
|
||||
|
||||
if (type != APR_REG &&
|
||||
if (finfo.filetype != APR_REG &&
|
||||
#if defined(WIN32) || defined(OS2)
|
||||
!(strcasecmp(name, "nul") == 0 ||
|
||||
(strlen(name) >= 4 &&
|
||||
|
Reference in New Issue
Block a user