1
0
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:
Brian Havard
2000-01-10 15:35:51 +00:00
parent faff1f01dd
commit 0df3ec32ca
8 changed files with 27 additions and 26 deletions

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.protection)) { && rr->finfo.filetype == APR_REG) {
/* /*
* 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.protection)) { && rr->finfo.filetype == APR_REG) {
/* /*
* 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
@@ -1163,7 +1163,7 @@ static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
if (rr->finfo.protection != 0) { if (rr->finfo.protection != 0) {
p->lm = rr->finfo.mtime; 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))) { if (!(p->icon = find_icon(d, rr, 1))) {
p->icon = find_default_icon(d, "^^DIRECTORY^^"); p->icon = find_default_icon(d, "^^DIRECTORY^^");
} }

View File

@@ -482,7 +482,7 @@ static int cgi_handler(request_rec *r)
#if defined(OS2) || defined(WIN32) #if defined(OS2) || defined(WIN32)
/* Allow for cgi files without the .EXE extension on them under OS/2 */ /* 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; struct stat statbuf;
char *newfile; char *newfile;
@@ -500,7 +500,7 @@ static int cgi_handler(request_rec *r)
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.protection)) if (r->finfo.filetype == APR_DIR)
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

@@ -116,12 +116,13 @@ 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.protection == 0 /* doesn't exist */ if (r->finfo.protection == 0 /* doesn't exist */
|| S_ISDIR(r->finfo.protection) || r->finfo.filetype == APR_DIR
|| S_ISREG(r->finfo.protection) || r->finfo.filetype == APR_REG
|| S_ISLNK(r->finfo.protection)) { || r->finfo.filetype == APR_LNK) {
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,
"object is not a file, directory or symlink: %s", "object is not a file, directory or symlink: %s",
r->filename); 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 * 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.protection) && last_cp) { if (r->finfo.filetype == APR_DIR && last_cp) {
r->finfo.protection = 0; /* No such file... */ r->finfo.protection = 0; /* No such file... */
r->finfo.filetype = APR_NOFILE; /* No such file... */
cp = last_cp; cp = last_cp;
} }
@@ -286,8 +288,8 @@ static int get_path_info(request_rec *r)
*/ */
r->finfo.protection = 0; r->finfo.protection = 0;
#if defined(ENOENT) && defined(ENOTDIR) #if defined(APR_ENOENT) && defined(APR_ENOTDIR)
if (errno == ENOENT || errno == ENOTDIR) { if (rv == APR_ENOENT || rv == APR_ENOTDIR) {
last_cp = cp; last_cp = cp;
while (--cp > path && *cp != '/') while (--cp > path && *cp != '/')
@@ -297,10 +299,10 @@ static int get_path_info(request_rec *r)
--cp; --cp;
} }
else { else {
#if defined(EACCES) #if defined(APR_EACCES)
if (errno != EACCES) if (rv != APR_EACCES)
#endif #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); "access to %s failed", r->uri);
return HTTP_FORBIDDEN; return HTTP_FORBIDDEN;
} }
@@ -355,6 +357,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.protection = 0; /* Not really a file... */ r->finfo.protection = 0; /* Not really a file... */
r->finfo.filetype = APR_NOFILE;
r->per_dir_config = per_dir_defaults; r->per_dir_config = per_dir_defaults;
return OK; return OK;
@@ -436,7 +439,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.protection)) if (r->finfo.filetype == APR_DIR)
++num_dirs; ++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, * 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.protection) if (r->finfo.filetype != APR_DIR
&& (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);
@@ -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 * no matter what, if it's a subdirectory, we need to re-run
* directory_walk * directory_walk
*/ */
if (S_ISDIR(rnew->finfo.protection)) { if (rnew->finfo.filetype == APR_DIR) {
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.protection)) { if (r->finfo.filetype == APR_DIR) {
r->content_type = DIR_MAGIC_TYPE; r->content_type = DIR_MAGIC_TYPE;
return OK; return OK;
} }

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.protection)) { if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
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

@@ -2621,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.protection)) { if (sub_req->finfo.filetype != APR_REG) {
res = NOT_FOUND; res = NOT_FOUND;
goto return_from_multi; goto return_from_multi;
} }

View File

@@ -314,7 +314,7 @@ static int add_cern_meta_data(request_rec *r)
}; };
/* is this a directory? */ /* 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; return DECLINED;
}; };

View File

@@ -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_file_t *file = NULL;
ap_finfo_t finfo; ap_finfo_t finfo;
ap_status_t stat; ap_status_t stat;
ap_filetype_e type;
if (name == NULL) { if (name == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, 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) if (stat != APR_SUCCESS)
return stat; return stat;
ap_getfileinfo(&finfo, file); stat = ap_getfileinfo(&finfo, file);
stat = ap_get_filetype(&type, finfo.protection);
if (stat != APR_SUCCESS) if (stat != APR_SUCCESS)
return stat; return stat;
if (type != APR_REG && if (finfo.filetype != APR_REG &&
#if defined(WIN32) || defined(OS2) #if defined(WIN32) || defined(OS2)
!(strcasecmp(name, "nul") == 0 || !(strcasecmp(name, "nul") == 0 ||
(strlen(name) >= 4 && (strlen(name) >= 4 &&