]> granicus.if.org Git - apache/commitdiff
Remove the final vestiges of stat.h from Apache 2.0. All calls are now to
authorRyan Bloom <rbb@apache.org>
Mon, 12 Jun 2000 15:29:09 +0000 (15:29 +0000)
committerRyan Bloom <rbb@apache.org>
Mon, 12 Jun 2000 15:29:09 +0000 (15:29 +0000)
ap_stat.  This also adds the new function ap_lstat().  This function is
analogous to lstat.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85535 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
include/ap_config.h
modules/cache/mod_file_cache.c
modules/filters/mod_include.c
modules/http/http_request.c
modules/mappers/mod_rewrite.c
os/win32/os.h
os/win32/util_win32.c
server/mpm/dexter/dexter.c
server/mpm/mpmt_beos/mpmt_beos.c
server/mpm/mpmt_beos/poll.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c
server/mpm/spmt_os2/spmt_os2.c
server/mpm/winnt/mpm_winnt.c
server/util.c
support/htpasswd.c

index d9b33944830d8e9f0e6798c6db8faee8f125fa0f..852ede7d80e869b380bf40104904d5a30bcd6a1c 100644 (file)
@@ -108,10 +108,6 @@ extern "C" {
 #include <sys/types.h>
 #endif
 
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
index 1326e56c678ab2f99fd423b9196bf3f82857c2e8..ecb15dbcf3116fdf75126578d08b5eb07d5d177e 100644 (file)
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
index 38f043ba489eade8b62224873436dfdcdfbdac8d..f87cb2c7bb195fbe9a3ebefcbc921884018af9ed 100644 (file)
@@ -2415,7 +2415,7 @@ static int send_parsed_file(request_rec *r)
     if ((*state == xbithack_full)
 #if !defined(OS2) && !defined(WIN32)
     /*  OS/2 dosen't support Groups. */
-        && (r->finfo.protection & S_IXGRP)
+        && (r->finfo.protection & APR_GEXECUTE)
 #endif
         ) {
         ap_update_mtime(r, r->finfo.mtime);
@@ -2487,7 +2487,7 @@ static int xbithack_handler(request_rec *r)
 #else
     enum xbithack *state;
 
-    if (!(r->finfo.protection & S_IXUSR)) {
+    if (!(r->finfo.protection & APR_UEXECUTE)) {
         return DECLINED;
     }
 
index be609b0cc44496486bf1c36e5bf3d48d7be7968e..bc7594f4d70d0b696cf5b6a46c80b5252a71f6b9 100644 (file)
@@ -76,6 +76,7 @@
 #include "http_log.h"
 #include "http_main.h"
 #include "util_charset.h"
+#include "apr_file_io.h"
 #include "apr_fnmatch.h"
 
 AP_HOOK_STRUCT(
@@ -136,13 +137,13 @@ static int check_safe_file(request_rec *r)
 }
 
 
-static int check_symlinks(char *d, int opts)
+static int check_symlinks(char *d, int opts, ap_pool_t *p)
 {
 #if defined(OS2) || defined(WIN32)
     /* OS/2 doesn't have symlinks */
     return OK;
 #else
-    struct stat lfi, fi;
+    ap_finfo_t lfi, fi;
     char *lastp;
     int res;
 
@@ -168,7 +169,7 @@ static int check_symlinks(char *d, int opts)
     else
         lastp = NULL;
 
-    res = lstat(d, &lfi);
+    res = ap_lstat(&lfi, d, p);
 
     if (lastp)
         *lastp = '/';
@@ -178,7 +179,7 @@ static int check_symlinks(char *d, int opts)
      * the like may cons up a way to run the transaction anyway)...
      */
 
-    if (!(res >= 0) || !S_ISLNK(lfi.st_mode))
+    if ((res != APR_SUCCESS) || lfi.filetype != APR_LNK)
         return OK;
 
     /* OK, it's a symlink.  May still be OK with OPT_SYM_OWNER */
@@ -186,10 +187,10 @@ static int check_symlinks(char *d, int opts)
     if (!(opts & OPT_SYM_OWNER))
         return HTTP_FORBIDDEN;
 
-    if (stat(d, &fi) < 0)
+    if (ap_stat(&fi, d, p) < 0)
         return HTTP_FORBIDDEN;
 
-    return (fi.st_uid == lfi.st_uid) ? OK : HTTP_FORBIDDEN;
+    return (fi.user == lfi.user) ? OK : HTTP_FORBIDDEN;
 
 #endif
 }
@@ -485,7 +486,7 @@ static int directory_walk(request_rec *r)
          * permissions appropriate to the *parent* directory...
          */
 
-        if ((res = check_symlinks(test_dirname, core_dir->opts))) {
+        if ((res = check_symlinks(test_dirname, core_dir->opts, r->pool))) {
             ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
                         "Symbolic link not allowed: %s", test_dirname);
             return res;
@@ -582,7 +583,7 @@ static int directory_walk(request_rec *r)
      * you would *not* get the 403.
      */
     if (r->finfo.filetype != APR_DIR
-        && (res = check_symlinks(r->filename, ap_allow_options(r)))) {
+        && (res = check_symlinks(r->filename, ap_allow_options(r), r->pool))) {
         ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
                     "Symbolic link not allowed: %s", r->filename);
         return res;
@@ -893,7 +894,8 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file,
             }
         }
         else {
-            if ((res = check_symlinks(rnew->filename, ap_allow_options(rnew)))) {
+            if ((res = check_symlinks(rnew->filename, ap_allow_options(rnew),
+                                      rnew->pool))) {
                 ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, rnew,
                             "Symbolic link not allowed: %s", rnew->filename);
                 rnew->status = res;
index 697d3f5b268de2c84741ea90b11083c5899084bd..b993368319f8cad2458c0de21c6211a9650c8781 100644 (file)
@@ -467,7 +467,7 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, char *a1,
 {
     rewrite_server_conf *sconf;
     rewritemap_entry *newmap;
-    struct stat st;
+    ap_finfo_t st;
 
     sconf = (rewrite_server_conf *)
             ap_get_module_config(cmd->server->module_config, &rewrite_module);
@@ -531,7 +531,7 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, char *a1,
     newmap->fpout = NULL;
 
     if (newmap->checkfile && (sconf->state == ENGINE_ENABLED)
-        && (stat(newmap->checkfile, &st) == -1)) {
+        && (ap_stat(&st, newmap->checkfile, cmd->pool) != APR_SUCCESS)) {
         return ap_pstrcat(cmd->pool,
                           "RewriteMap: map file or program not found:",
                           newmap->checkfile, NULL);
@@ -2182,7 +2182,7 @@ static int apply_rewrite_cond(request_rec *r, rewritecond_entry *p,
                               backrefinfo *briRC)
 {
     char input[MAX_STRING_LEN];
-    struct stat sb;
+    ap_finfo_t sb;
     request_rec *rsub;
     regmatch_t regmatch[MAX_NMATCH];
     int rc;
@@ -2208,31 +2208,31 @@ static int apply_rewrite_cond(request_rec *r, rewritecond_entry *p,
 
     rc = 0;
     if (strcmp(p->pattern, "-f") == 0) {
-        if (stat(input, &sb) == 0) {
-            if (S_ISREG(sb.st_mode)) {
+        if (ap_stat(&sb, input, r->pool) == APR_SUCCESS) {
+            if (sb.filetype == APR_REG) {
                 rc = 1;
             }
         }
     }
     else if (strcmp(p->pattern, "-s") == 0) {
-        if (stat(input, &sb) == 0) {
-            if (S_ISREG(sb.st_mode) && sb.st_size > 0) {
+        if (ap_stat(&sb, input, r->pool) == APR_SUCCESS) {
+            if ((sb.filetype == APR_REG) && sb.size > 0) {
                 rc = 1;
             }
         }
     }
     else if (strcmp(p->pattern, "-l") == 0) {
 #if !defined(OS2) && !defined(WIN32)
-        if (lstat(input, &sb) == 0) {
-            if (S_ISLNK(sb.st_mode)) {
+        if (ap_lstat(&sb, input, r->pool) == APR_SUCCESS) {
+            if (sb.filetype == APR_LNK) {
                 rc = 1;
             }
         }
 #endif
     }
     else if (strcmp(p->pattern, "-d") == 0) {
-        if (stat(input, &sb) == 0) {
-            if (S_ISDIR(sb.st_mode)) {
+        if (ap_stat(&sb, input, r->pool) == APR_SUCCESS) {
+            if (sb.filetype == APR_DIR) {
                 rc = 1;
             }
         }
@@ -2278,7 +2278,7 @@ static int apply_rewrite_cond(request_rec *r, rewritecond_entry *p,
             /* file exists for any result up to 2xx, no redirects */
             if (rsub->status < 300 &&
                 /* double-check that file exists since default result is 200 */
-                stat(rsub->filename, &sb) == 0) {
+                ap_stat(&sb, rsub->filename, r->pool) == APR_SUCCESS) {
                 rc = 1;
             }
 
@@ -2731,7 +2731,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
     rewritemap_entry *entries;
     rewritemap_entry *s;
     char *value;
-    struct stat st;
+    ap_finfo_t st;
     int i;
 
     /* get map configuration */
@@ -2745,7 +2745,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
         s = &entries[i];
         if (strcmp(s->name, name) == 0) {
             if (s->type == MAPTYPE_TXT) {
-                if (stat(s->checkfile, &st) == -1) {
+                if (ap_stat(&st, s->checkfile, r->pool) != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                                  "mod_rewrite: can't access text RewriteMap "
                                  "file %s", s->checkfile);
@@ -2754,7 +2754,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                     return NULL;
                 }
                 value = get_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key);
+                                         st.mtime, key);
                 if (value == NULL) {
                     rewritelog(r, 6, "cache lookup FAILED, forcing new "
                                "map lookup");
@@ -2763,14 +2763,14 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                         rewritelog(r, 5, "map lookup OK: map=%s key=%s[txt] "
                                    "-> val=%s", s->name, key, value);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, value);
+                                         st.mtime, key, value);
                         return value;
                     }
                     else {
                         rewritelog(r, 5, "map lookup FAILED: map=%s[txt] "
                                    "key=%s", s->name, key);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, "");
+                                         st.mtime, key, "");
                         return NULL;
                     }
                 }
@@ -2782,7 +2782,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
             }
             else if (s->type == MAPTYPE_DBM) {
 #ifndef NO_DBM_REWRITEMAP
-                if (stat(s->checkfile, &st) == -1) {
+                if (ap_stat(&st, s->checkfile, r->pool) != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
                                  "mod_rewrite: can't access DBM RewriteMap "
                                  "file %s", s->checkfile);
@@ -2791,7 +2791,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                     return NULL;
                 }
                 value = get_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key);
+                                         st.mtime, key);
                 if (value == NULL) {
                     rewritelog(r, 6,
                                "cache lookup FAILED, forcing new map lookup");
@@ -2800,14 +2800,14 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                         rewritelog(r, 5, "map lookup OK: map=%s[dbm] key=%s "
                                    "-> val=%s", s->name, key, value);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, value);
+                                         st.mtime, key, value);
                         return value;
                     }
                     else {
                         rewritelog(r, 5, "map lookup FAILED: map=%s[dbm] "
                                    "key=%s", s->name, key);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, "");
+                                         st.mtime, key, "");
                         return NULL;
                     }
                 }
@@ -2844,7 +2844,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                 }
             }
             else if (s->type == MAPTYPE_RND) {
-                if (stat(s->checkfile, &st) == -1) {
+                if (ap_stat(&st, s->checkfile, r->pool) == -1) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
                                  "mod_rewrite: can't access text RewriteMap "
                                  "file %s", s->checkfile);
@@ -2853,7 +2853,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                     return NULL;
                 }
                 value = get_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key);
+                                         st.mtime, key);
                 if (value == NULL) {
                     rewritelog(r, 6, "cache lookup FAILED, forcing new "
                                "map lookup");
@@ -2862,13 +2862,13 @@ static char *lookup_map(request_rec *r, char *name, char *key)
                         rewritelog(r, 5, "map lookup OK: map=%s key=%s[txt] "
                                    "-> val=%s", s->name, key, value);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, value);
+                                         st.mtime, key, value);
                     }
                     else {
                         rewritelog(r, 5, "map lookup FAILED: map=%s[txt] "
                                    "key=%s", s->name, key);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, "");
+                                         st.mtime, key, "");
                         return NULL;
                     }
                 }
@@ -3519,7 +3519,7 @@ static char *lookup_variable(request_rec *r, char *var)
 #ifndef WIN32
     struct passwd *pw;
     struct group *gr;
-    struct stat finfo;
+    ap_finfo_t finfo;
 #endif
 
     result = NULL;
@@ -3722,8 +3722,8 @@ static char *lookup_variable(request_rec *r, char *var)
             }
         }
         else {
-            if (stat(r->filename, &finfo) == 0) {
-                if ((pw = getpwuid(finfo.st_uid)) != NULL) {
+            if (ap_stat(&finfo, r->filename, r->pool) == APR_SUCCESS) {
+                if ((pw = getpwuid(finfo.user)) != NULL) {
                     result = pw->pw_name;
                 }
             }
@@ -3737,8 +3737,8 @@ static char *lookup_variable(request_rec *r, char *var)
             }
         }
         else {
-            if (stat(r->filename, &finfo) == 0) {
-                if ((gr = getgrgid(finfo.st_gid)) != NULL) {
+            if (ap_stat(&finfo, r->filename, r->pool) == 0) {
+                if ((gr = getgrgid(finfo.group)) != NULL) {
                     result = gr->gr_name;
                 }
             }
@@ -4131,7 +4131,7 @@ static void add_env_variable(request_rec *r, char *s)
 **
 */
 
-static int prefix_stat(const char *path, struct stat *sb)
+static int prefix_stat(const char *path, ap_finfo_t *sb)
 {
     char curpath[LONG_STRING_LEN];
     char *cp;
@@ -4143,7 +4143,7 @@ static int prefix_stat(const char *path, struct stat *sb)
     if ((cp = strchr(curpath+1, '/')) != NULL) {
         *cp = '\0';
     }
-    if (stat(curpath, sb) == 0) {
+    if (ap_stat(sb, curpath, NULL) == 0) {
         return 1;
     }
     else {
index 9258655c7f3e22573b4ed3e1dd547bdd57cddd78..d17e5accdc09fc12a29437f492053127320b4d0a 100644 (file)
@@ -116,8 +116,6 @@ typedef char * caddr_t;
 
 #define HAVE_MEMMOVE
 
-#define HAVE_SYS_STAT_H
-#define lstat(x, y) stat(x, y)
 #define S_ISLNK(m) (0)
 #define S_ISREG(m) ((m & _S_IFREG) == _S_IFREG)
 #ifndef S_ISDIR
index 330a8573699804bcca4fc00b1e1d7e349d5ec10e..b4c6d8e3c981b780163312f1bff71775e2fc9577 100644 (file)
@@ -59,7 +59,6 @@
 #include "httpd.h"
 #include "http_log.h"
 
-#include <sys/stat.h>
 #include <stdarg.h>
 #include <time.h>
 #include <stdlib.h>
index 9b77058676a9e8ede24bcafcd6a0ded78f8a3c77..7ccec22108f2d32901c130ab69b0a7996560dba2 100644 (file)
@@ -1434,7 +1434,8 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
     }
 
     fname = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || 
+        (finfo.filetype != APR_DIR)) {
        return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, 
                          " does not exist or is not a directory", NULL);
     }
index 2e8229c5a0c00999f09d544ccd9bbe28dd4b94be..a32415fa1c6226a8aa33fe7ecdd36f23aae9166f 100644 (file)
@@ -1106,7 +1106,8 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
     }
 
     fname = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || 
+        (finfo.filetype != APR_DIR)) {
        return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, 
                          " does not exist or is not a directory", NULL);
     }
index a8c471e2db495ea7b005f79865ed8f89598f3b12..c6b6942b227a647fe9e914d64ddfe9c8c9ddf6ef 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <string.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <time.h>
index 94bbed9c2c36ccc34e4e3bdec7fdd55154f1bf7b..bc104818fee95c471d1e669869439ee603e2400b 100644 (file)
@@ -1439,7 +1439,8 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
     }
 
     fname = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if ((ap_stat(&finfofname, cmd->pool) != APR_SUCCESS) || 
+        (finfo.filetype != APR_DIR)) {
        return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, 
                          " does not exist or is not a directory", NULL);
     }
index 77fec0bfaf6caa2cb728d25c86f74776d916671e..7e21d6c42d9899844b3ad06d86a23de7f943bb86 100644 (file)
@@ -1744,7 +1744,7 @@ static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
 
 static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) 
 {
-    struct stat finfo;
+    ap_finfo_t finfo;
     const char *fname;
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
     if (err != NULL) {
@@ -1752,7 +1752,8 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
     }
 
     fname = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || 
+        (finfo.filetype != APR_DIR)) {
        return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, 
                          " does not exist or is not a directory", NULL);
     }
index 36fcf60ecfe88708856a3f3cb341bd7f1cb579a0..a54b146cfbcc551e592a6a509222794c97191338 100644 (file)
@@ -1608,7 +1608,8 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
     }
 
     fname = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || 
+        (finfo.filetype != APR_DIR)) {
        return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, 
                          " does not exist or is not a directory", NULL);
     }
index 288d29abf475070f7f06579949352185ffd4d78b..fa67a23358e80fd81739d952eb8a49e1fe03c23f 100644 (file)
@@ -2243,7 +2243,8 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
     }
 
     fname = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || 
+        (finfo.filetype != APR_DIR)) {
        return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, 
                          " does not exist or is not a directory", NULL);
     }
index 22c4f76cf74cdb8ccdd6e8c440e8c95f6235320b..0ae566addb9c55ba2625d339af0efc29bf42d95c 100644 (file)
@@ -1648,12 +1648,12 @@ API_EXPORT(char *) ap_escape_html(ap_pool_t *p, const char *s)
 
 API_EXPORT(int) ap_is_directory(const char *path)
 {
-    struct stat finfo;
+    ap_finfo_t finfo;
 
-    if (stat(path, &finfo) == -1)
+    if (ap_stat(&finfo, path, NULL) == -1)
        return 0;               /* in error condition, just return no */
 
-    return (S_ISDIR(finfo.st_mode));
+    return (finfo.filetype == APR_DIR);
 }
 
 API_EXPORT(char *) ap_make_full_path(ap_pool_t *a, const char *src1,
index a31f6fa154c649cbd1e75174eb976f2f1d364bd0..be7e95f459f89732b2eb543dfa0bf845c692d693 100644 (file)
@@ -332,18 +332,10 @@ static int writable(char *fname)
  */
 static int exists(char *fname)
 {
-#ifdef WIN32
-    struct _stat sbuf;
-#else
-    struct stat sbuf;
-#endif
+    ap_finfo_t sbuf;
     int check;
 
-#ifdef WIN32
-    check = _stat(fname, &sbuf);
-#else
-    check = stat(fname, &sbuf);
-#endif
+    check = ap_stat(&sbuf, fname, NULL);
     return ((check == -1) && (errno == ENOENT)) ? 0 : 1;
 }