]> granicus.if.org Git - apache/commitdiff
Rework ap_finfo_t to split the file type out of the protection field.
authorBrian Havard <bjh@apache.org>
Mon, 10 Jan 2000 15:35:51 +0000 (15:35 +0000)
committerBrian Havard <bjh@apache.org>
Mon, 10 Jan 2000 15:35:51 +0000 (15:35 +0000)
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

modules/generators/mod_autoindex.c
modules/generators/mod_cgi.c
modules/http/http_request.c
modules/http/mod_mime.c
modules/mappers/mod_dir.c
modules/mappers/mod_negotiation.c
modules/metadata/mod_cern_meta.c
server/util.c

index a9bd62ad21607049506b70c635f29a8e001df175..47ed08791a0e8240c3268096981b69ba6ea083aa 100644 (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->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^^");
                }
index 8338bcd570511b4429b711ab74aaa77a047deeda..3017955501002bfffb8dd0f84fa652e0095eeb35 100644 (file)
@@ -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");
 
index 55adcc633fbde7b92991f4c46b604b180b25925f..579990333b290403ad8d4db5fd1561972a196aa5 100644 (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)
 {
 
-    if (r->finfo.protection == 0         /* doesn't exist */
-        || S_ISDIR(r->finfo.protection)
-        || S_ISREG(r->finfo.protection)
-        || S_ISLNK(r->finfo.protection)) {
+    if (r->finfo.protection == 0      /* doesn't exist */
+        || 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);
index adccd1f33c8166681b92802590d41a4d88616298..cb31a02651c7881fff0392e56d113b7e722078a2 100644 (file)
@@ -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;
     }
index 8f97e6b2b1a9f1a1cb1eacebee363fbd63785425..885b7c081ea95daebab824bde9286eb5fe21581b 100644 (file)
@@ -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)
index 63b7f6e1c134e9a86155a95a88416a3003a6907c..dc569776e0877ada2459c44991d39a9d77bf1652 100644 (file)
@@ -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;
     }
index 679d0e8af8d2131bfc2647fe9c6d52d04eb3fd9c..4e68df1e93ec64c1075f29e8c7bc67641da14375 100644 (file)
@@ -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;
     };
 
index 0a2342beb4e5b9a16790a917b7cfe49a52aa51cf..c1027a3985cce0652a9cc0b46c636d2e5f3f8250 100644 (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_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 &&