From 6282d6e36439a5c013d3724a79e52ecb98c61677 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 31 Jan 2001 22:45:35 +0000 Subject: [PATCH] Eliminate all assumptions that finfo.protection reflects the existance or absense of a file. finfo.filetype is defined as 0 if APR_NOFILE, or a non-zero value if the file could be apr_stat()'ed. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87933 13f79535-47bb-0310-9956-ffa450edef68 --- modules/dav/fs/repos.c | 21 ++++++++++----------- modules/filters/mod_include.c | 14 ++++++-------- modules/generators/mod_asis.c | 2 +- modules/generators/mod_autoindex.c | 2 +- modules/generators/mod_cgi.c | 4 ++-- modules/generators/mod_cgid.c | 2 +- modules/http/http_core.c | 2 +- modules/http/http_protocol.c | 2 +- modules/http/http_request.c | 8 +++----- modules/mappers/mod_actions.c | 2 +- modules/mappers/mod_negotiation.c | 2 +- modules/mappers/mod_speling.c | 2 +- modules/metadata/mod_cern_meta.c | 2 +- modules/metadata/mod_expires.c | 2 +- modules/metadata/mod_mime_magic.c | 4 ++-- modules/test/mod_autoindex.c | 2 +- 16 files changed, 34 insertions(+), 39 deletions(-) diff --git a/modules/dav/fs/repos.c b/modules/dav/fs/repos.c index a6a102ee24..c5917dccb8 100644 --- a/modules/dav/fs/repos.c +++ b/modules/dav/fs/repos.c @@ -654,7 +654,7 @@ static dav_error * dav_fs_get_resource( resource->uri = r->uri; } - if (r->finfo.protection != 0) { + if (r->finfo.filetype != 0) { resource->exists = 1; resource->collection = r->finfo.filetype == APR_DIR; @@ -688,7 +688,7 @@ static dav_error * dav_fs_get_resource( /* retain proper integrity across the structures */ if (!resource->exists) { - ctx->finfo.protection = 0; + ctx->finfo.filetype = 0; } } } @@ -765,7 +765,7 @@ static int dav_fs_is_same_resource( #ifdef WIN32 return stricmp(ctx1->pathname, ctx2->pathname) == 0; #else - if (ctx1->finfo.protection != 0) + if (ctx1->finfo.filetype != 0) return ctx1->finfo.inode == ctx2->finfo.inode; else return strcmp(ctx1->pathname, ctx2->pathname) == 0; @@ -1134,7 +1134,7 @@ static dav_error * dav_fs_move_resource( /* determine whether a simple rename will work. * Assume source exists, else we wouldn't get called. */ - if (dstinfo->finfo.protection != 0) { + if (dstinfo->finfo.filetype != 0) { if (dstinfo->finfo.device == srcinfo->finfo.device) { /* target exists and is on the same device. */ can_rename = 1; @@ -1692,7 +1692,7 @@ static const char *dav_fs_getetag(const dav_resource *resource) if (!resource->exists) return apr_pstrdup(ctx->pool, ""); - if (ctx->finfo.protection != 0) { + if (ctx->finfo.filetype != 0) { return apr_psprintf(ctx->pool, "\"%lx-%lx-%lx\"", (unsigned long) ctx->finfo.inode, (unsigned long) ctx->finfo.size, @@ -1788,21 +1788,20 @@ static dav_prop_insert dav_fs_insert_prop(const dav_resource *resource, break; case DAV_PROPID_FS_executable: -#ifdef WIN32 - /* our property, but not defined on the Win32 platform */ - return DAV_PROP_INSERT_NOTDEF; -#else /* our property, but not defined on collection resources */ if (resource->collection) return DAV_PROP_INSERT_NOTDEF; - /* the files are "ours" so we only need to check owner exec privs */ + /* our property, but not defined on this platform */ + if (!(resource->info->finfo.valid & APR_FINFO_UPROT)) + return DAV_PROP_INSERT_NOTDEF; + + /* the files are "ours" so we only need to check owner exec privs */ if (resource->info->finfo.protection & APR_UEXECUTE) value = "T"; else value = "F"; break; -#endif /* WIN32 */ default: /* ### what the heck was this property? */ diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index 402006f1cc..6aeef3da82 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -701,7 +701,7 @@ static int include_cgi(char *s, request_rec *r, ap_filter_t *next, if ((rr->path_info && rr->path_info[0]) || rr->args) { return -1; } - if (rr->finfo.protection == 0) { + if (rr->finfo.filetype == 0) { return -1; } @@ -1274,7 +1274,7 @@ static int find_file(request_rec *r, const char *directive, const char *tag, we never attempt to "run" this sub request. */ rr = ap_sub_req_lookup_file(tag_val, r, NULL); - if (rr->status == HTTP_OK && rr->finfo.protection != 0) { + if (rr->status == HTTP_OK && rr->finfo.filetype != 0) { to_send = rr->filename; if ((rv = apr_stat(finfo, to_send, APR_FINFO_GPROT | APR_FINFO_MIN, rr->pool)) != APR_SUCCESS @@ -1304,7 +1304,7 @@ static int find_file(request_rec *r, const char *directive, const char *tag, we never attempt to "run" this sub request. */ rr = ap_sub_req_lookup_uri(tag_val, r, NULL); - if (rr->status == HTTP_OK && rr->finfo.protection != 0) { + if (rr->status == HTTP_OK && rr->finfo.filetype != 0) { memcpy((char *) finfo, (const char *) &rr->finfo, sizeof(rr->finfo)); ap_destroy_sub_req(rr); @@ -2970,12 +2970,10 @@ static int includes_filter(ap_filter_t *f, apr_bucket_brigade *b) } } + /* Assure the platform supports Group protections */ if ((*state == xbithack_full) -#if !defined(OS2) && !defined(WIN32) - /* OS/2 dosen't support Groups. */ - && (r->finfo.protection & APR_GEXECUTE) -#endif - ) { + && (r->finfo.valid & APR_FINFO_GPROT) + && (r->finfo.protection & APR_GEXECUTE)) { ap_update_mtime(r, r->finfo.mtime); ap_set_last_modified(r); } diff --git a/modules/generators/mod_asis.c b/modules/generators/mod_asis.c index 7e5daa6b53..858bd208dd 100644 --- a/modules/generators/mod_asis.c +++ b/modules/generators/mod_asis.c @@ -81,7 +81,7 @@ static int asis_handler(request_rec *r) r->allowed |= (1 << M_GET); if (r->method_number != M_GET) return DECLINED; - if (r->finfo.protection == 0) { + if (r->finfo.filetype == 0) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "File does not exist: %s", r->filename); return HTTP_NOT_FOUND; diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 518198c5ae..ce5c6c2612 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -1186,7 +1186,7 @@ static struct ent *make_autoindex_entry(const char *name, int autoindex_opts, if (autoindex_opts & FANCY_INDEXING) { request_rec *rr = ap_sub_req_lookup_file(name, r, NULL); - if (rr->finfo.protection != 0) { + if (rr->finfo.filetype != 0) { p->lm = rr->finfo.mtime; if (rr->finfo.filetype == APR_DIR) { if (!(p->icon = find_icon(d, rr, 1))) { diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 9c1c3e2f3d..4e0767d09d 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -550,7 +550,7 @@ static int cgi_handler(request_rec *r) * entity until the sysadmin overrides that behavior. * Allow for cgi files without the .EXE extension on them under OS/2 */ - if (r->finfo.protection == 0) { + if (r->finfo.filetype == 0) { apr_finfo_t finfo; char *newfile; apr_status_t rv; @@ -565,7 +565,7 @@ static int cgi_handler(request_rec *r) } } #else - if (r->finfo.protection == 0) + if (r->finfo.filetype == 0) return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, "script not found or unable to stat"); #endif diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 625dd13025..8eb17f2f97 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -816,7 +816,7 @@ static int cgid_handler(request_rec *r) #error mod_cgid does not work on this platform. If you teach it to, look #error at mod_cgi.c for required code in this path. #else - if (r->finfo.protection == 0) + if (r->finfo.filetype == 0) return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, "script not found or unable to stat"); #endif diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 29da4704d7..224e9227b1 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -2992,7 +2992,7 @@ static int default_handler(request_rec *r) if (r->method_number == M_PUT) { return HTTP_METHOD_NOT_ALLOWED; } - if (r->finfo.protection == 0 || (r->path_info && *r->path_info)) { + if (r->finfo.filetype == 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 ? apr_pstrcat(r->pool, r->filename, r->path_info, NULL) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index f500b0b9f6..659c8b7531 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -630,7 +630,7 @@ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak) weak = ((r->request_time - r->mtime > APR_USEC_PER_SEC) && !force_weak) ? "" : "W/"; - if (r->finfo.protection != 0) { + if (r->finfo.filetype != 0) { etag = apr_psprintf(r->pool, "%s\"%lx-%lx-%lx\"", weak, (unsigned long) r->finfo.inode, diff --git a/modules/http/http_request.c b/modules/http/http_request.c index d47f6274c4..4cff257279 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -134,7 +134,7 @@ AP_IMPLEMENT_HOOK_VOID(insert_filter, (request_rec *r), (r)) static int check_safe_file(request_rec *r) { - if (r->finfo.protection == 0 /* doesn't exist */ + if (r->finfo.filetype == 0 /* doesn't exist */ || r->finfo.filetype == APR_DIR || r->finfo.filetype == APR_REG || r->finfo.filetype == APR_LNK) { @@ -226,7 +226,7 @@ static int get_path_info(request_rec *r) char bStripSlash=1; #endif - if (r->finfo.protection) { + if (r->finfo.filetype) { /* assume path_info already set */ return OK; } @@ -294,7 +294,6 @@ static int get_path_info(request_rec *r) * argument starts with the component after that. */ if (r->finfo.filetype == APR_DIR && last_cp) { - r->finfo.protection = 0; /* XXX: Wrong test for no such file... */ r->finfo.filetype = APR_NOFILE; /* No such file... */ cp = last_cp; } @@ -351,7 +350,6 @@ static int directory_walk(request_rec *r) if (r->filename == NULL) { r->filename = apr_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; @@ -982,7 +980,7 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file, if (((rv = apr_stat(&rnew->finfo, rnew->filename, APR_FINFO_NORM, rnew->pool)) != APR_SUCCESS) && (rv != APR_INCOMPLETE)) { - rnew->finfo.protection = 0; + rnew->finfo.filetype = 0; } if ((res = check_safe_file(rnew))) { diff --git a/modules/mappers/mod_actions.c b/modules/mappers/mod_actions.c index 35e2e3497d..8c28246c88 100644 --- a/modules/mappers/mod_actions.c +++ b/modules/mappers/mod_actions.c @@ -194,7 +194,7 @@ static int action_handler(request_rec *r) if ((t = apr_table_get(conf->action_types, action ? action : ap_default_type(r)))) { script = t; - if (r->finfo.protection == 0) { + if (r->finfo.filetype == 0) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "File does not exist: %s", r->filename); return HTTP_NOT_FOUND; diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index b86e65674e..f6e6f4f97c 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -2601,7 +2601,7 @@ static int handle_multi(request_rec *r) int res; int j; - if (r->finfo.protection != 0 || !(ap_allow_options(r) & OPT_MULTI)) { + if (r->finfo.filetype != 0 || !(ap_allow_options(r) & OPT_MULTI)) { return DECLINED; } diff --git a/modules/mappers/mod_speling.c b/modules/mappers/mod_speling.c index 4893c02ccd..845b3b2fec 100644 --- a/modules/mappers/mod_speling.c +++ b/modules/mappers/mod_speling.c @@ -253,7 +253,7 @@ static int check_speling(request_rec *r) } /* We've already got a file of some kind or another */ - if (r->proxyreq || (r->finfo.protection != 0)) { + if (r->proxyreq || (r->finfo.filetype != 0)) { return DECLINED; } diff --git a/modules/metadata/mod_cern_meta.c b/modules/metadata/mod_cern_meta.c index 66e8acb680..79aab42faf 100644 --- a/modules/metadata/mod_cern_meta.c +++ b/modules/metadata/mod_cern_meta.c @@ -323,7 +323,7 @@ static int add_cern_meta_data(request_rec *r) /* if ./.web/$1.meta exists then output 'asis' */ - if (r->finfo.protection == 0) { + if (r->finfo.filetype == 0) { return DECLINED; }; diff --git a/modules/metadata/mod_expires.c b/modules/metadata/mod_expires.c index d122474b4d..e3a96678fb 100644 --- a/modules/metadata/mod_expires.c +++ b/modules/metadata/mod_expires.c @@ -467,7 +467,7 @@ static int add_expires(request_rec *r) switch (code[0]) { case 'M': - if (r->finfo.protection == 0) { + if (r->finfo.filetype == 0) { /* file doesn't exist on disk, so we can't do anything based on * modification time. Note that this does _not_ log an error. */ diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c index 51725097d7..d54d313974 100644 --- a/modules/metadata/mod_mime_magic.c +++ b/modules/metadata/mod_mime_magic.c @@ -1493,7 +1493,7 @@ static int fsmagic(request_rec *r, const char *fn) break; default: ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r, - MODNAME ": invalid mode 0%o.", (unsigned int)r->finfo.protection); + MODNAME ": invalid file type %d.", r->finfo.filetype); return HTTP_INTERNAL_SERVER_ERROR; } @@ -2432,7 +2432,7 @@ static int magic_find_ct(request_rec *r) magic_server_config_rec *conf; /* the file has to exist */ - if (r->finfo.protection == 0 || !r->filename) { + if (r->finfo.filetype == 0 || !r->filename) { return DECLINED; } diff --git a/modules/test/mod_autoindex.c b/modules/test/mod_autoindex.c index 518198c5ae..ce5c6c2612 100644 --- a/modules/test/mod_autoindex.c +++ b/modules/test/mod_autoindex.c @@ -1186,7 +1186,7 @@ static struct ent *make_autoindex_entry(const char *name, int autoindex_opts, if (autoindex_opts & FANCY_INDEXING) { request_rec *rr = ap_sub_req_lookup_file(name, r, NULL); - if (rr->finfo.protection != 0) { + if (rr->finfo.filetype != 0) { p->lm = rr->finfo.mtime; if (rr->finfo.filetype == APR_DIR) { if (!(p->icon = find_icon(d, rr, 1))) { -- 2.40.0