]> granicus.if.org Git - apache/commitdiff
Eliminated ap_os_[systemcase|[case_]canonical]_filename() and
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 23 Aug 2001 19:08:20 +0000 (19:08 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 23 Aug 2001 19:08:20 +0000 (19:08 +0000)
  move ap_os_is_path_absolute() into util.c (now relies on apr.)

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

16 files changed:
include/http_config.h
include/httpd.h
os/beos/os.c
os/beos/os.h
os/bs2000/os-inline.c [deleted file]
os/bs2000/os.h
os/os2/os-inline.c [deleted file]
os/os2/os.h
os/os2/util_os2.c
os/tpf/os-inline.c [deleted file]
os/tpf/os.h
os/unix/os-inline.c [deleted file]
os/unix/os.h
os/win32/os.h
os/win32/util_win32.c
server/util.c

index 84903fbbfc0d6dd53ca9cc15435f85ca3a807862..81bb01ca238fa0c69d3534f72e64ab79b52f46bf 100644 (file)
@@ -525,7 +525,7 @@ AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, void *struct_p
  * @param p pool to allocate data from
  * @param fname The file name
  */
-AP_DECLARE(const char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
+AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
 
 /* Finally, the hook for dynamically loading modules in... */
 
index 9397930736f03fe88b3781d4152cc66303ec2d88..7f264f67d98b7be347a0e003345027bdf0f133fa 100644 (file)
@@ -1275,9 +1275,22 @@ AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s);
  * @param dir The directory name
  * @param f The filename
  * @return A copy of the full path
+ * @tip Never consider using this function if you are dealing with filesystem
+ * names that need to remain canonical, unless you are merging an apr_dir_read
+ * path and returned filename.  Otherwise, the result is not canonical.
  */
 AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *dir, const char *f);
 
+/**
+ * Test if the given path has an an absolute path.
+ * @param p The pool to allocate from
+ * @param dir The directory name
+ * @tip The converse is not necessarily true, some OS's (Win32/OS2/Netware) have
+ * multiple forms of absolute paths.  This only reports if the path is absolute
+ * in a canonical sense.
+ */
+AP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir);
+
 /**
  * Does the provided string contain wildcard characters?  This is useful
  * for determining if the string should be passed to strcmp_match or to strcmp.
index 13bcfd8a3cc369afd1a64bcfa6f97ed671698288..44fc6f3013365a29fc36f2c3edbb4a29ba7da90d 100644 (file)
 #include "ap_mpm.h" /* needed for definition of 
                      * ap_os_create_privileged_process */
 
-int ap_os_is_path_absolute(const char *file)
-{
-  return file[0] == '/';
-}
-
 AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
     const request_rec *r,
     apr_proc_t *newproc, const char *progname,
index b7dcd1cdd3d06bc3bd24f13ce6b4f93faa9059c3..5a59697551d9022171e01d9b2ba8b64779d891cc 100644 (file)
   #endif
 #endif
 
-/*
- * This file is included in all Apache source code. It contains definitions
- * of facilities available on _this_ operating system (HAVE_* macros),
- * and prototypes of OS specific functions defined in os.c or os-inline.c
- */
-
-extern int ap_os_is_path_absolute(const char *file);
-#define ap_os_canonical_filename(p,f)  (f)
-#define ap_os_case_canonical_filename(p,f)  (f)
-#define ap_os_systemcase_filename(p,f)  (f)
-
 #endif /* !APACHE_OS_H */
diff --git a/os/bs2000/os-inline.c b/os/bs2000/os-inline.c
deleted file mode 100644 (file)
index c8299b5..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the APR_INLINE modifier. 
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. APR_INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * APR_HAS_INLINE will be zero so we can use this to test if we are
- * compiling this source file.
- */
-
-#include "apr.h"
-
-#if APR_HAS_INLINE
-/* keep inlined functions private to the including file */
-static
-#endif
-APR_INLINE int ap_os_is_path_absolute(const char *file)
-{
-    return file[0] == '/';
-}
index 4b7fd4c893cb9ffda99c5fcfd25ad8e1fb1e142f..b73e369759e49e0c41721c8e3ede40b52ca9d41a 100644 (file)
  * and prototypes of OS specific functions defined in os.c or os-inline.c
  */
 
-#if APR_HAS_INLINE
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-
-#include "os-inline.c"
-
-#else
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *file);
-#endif
-
 /* Other ap_os_ routines not used by this platform */
 
-
 extern pid_t os_fork(const char *user);
 
 #endif /*! APACHE_OS_H*/
diff --git a/os/os2/os-inline.c b/os/os2/os-inline.c
deleted file mode 100644 (file)
index dfcf05c..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the APR_INLINE modifier. 
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. APR_INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * APR_HAS_INLINE will be zero so we can use this to test if we are
- * compiling this source file.
- */
-
-#include "apr.h"
-
-#if APR_HAS_INLINE
-/* keep inlined functions private to the including file */
-static
-#endif
-APR_INLINE int ap_os_is_path_absolute(const char *file)
-{
-    /* For now, just do the same check that http_request.c and mod_alias.c do. 
-     * XXX: Accept /bleh still?  Or do we concur that d:/bleh is a minimum
-     *      requirement?  If so, canonical name needs to convert to drive/path
-     *      syntax, and the test is (file[0] == '/' && file[1] == '/') ||...
-     */
-    return (file[0] == '/'
-            || (file[0] != '\0' && file[1] == ':' && file[2] == '/'));
-}
index 64e0884a7f9bf59ab0d14d56fcdb50eec76fa05a..ae2da225e8bb793319c19e07b2bab9538ec2ba9d 100644 (file)
 #define APACHE_OS_H
 
 #define PLATFORM "OS/2"
+
+/* going away shortly... */
 #define HAVE_CANONICAL_FILENAME
 #define HAVE_DRIVE_LETTERS
 #define HAVE_UNC_PATHS
-
-#include <apr.h>
-#include <apr_pools.h>
+#define CASE_BLIND_FILESYSTEM
 
 /*
  * This file in included in all Apache source code. It contains definitions
  * and prototypes of OS specific functions defined in os.c or os-inline.c
  */
 
-#if APR_HAS_INLINE
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-
-#include "os-inline.c"
-
-#else
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *file);
-#endif
-
-AP_DECLARE(char *)ap_os_canonical_filename(apr_pool_t *p, const char *file);
-AP_DECLARE(char *)ap_os_case_canonical_filename(apr_pool_t *p, const char *szFile);
-
-/* OS/2 doesn't have symlinks so S_ISLNK is always false */
-#define S_ISLNK(m) 0
-
 #endif   /* ! APACHE_OS_H */
index 0ecb9dc4fd3cc5d318c02cd80e760d83ba02b9fc..ac4a72bfb2fcdf489aba426b2d4ad9bc325cf137 100644 (file)
 #include "apr_strings.h"
 
 
-AP_DECLARE(char *)ap_os_case_canonical_filename(apr_pool_t *pPool, const char *szFile)
-{
-    char buf[HUGE_STRING_LEN];
-    char buf2[HUGE_STRING_LEN];
-    int rc, len; 
-    char *pos;
-    
-/* Remove trailing slash unless it's a root directory */
-    strcpy(buf, szFile);
-    len = strlen(buf);
-    
-    if (len > 3 && buf[len-1] == '/')
-        buf[--len] = 0;
-      
-    rc = DosQueryPathInfo(buf, FIL_QUERYFULLNAME, buf2, HUGE_STRING_LEN);
-
-    if (rc) {
-        if (rc != ERROR_INVALID_NAME) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, APR_OS2_STATUS(rc), NULL, "for file [%s]", szFile);
-        }
-        apr_cpystrn(buf2, buf, sizeof(buf2));
-    }
-
-/* Switch backslashes to forward */
-    for (pos=buf2; *pos; pos++)
-        if (*pos == '\\')
-            *pos = '/';
-    
-    return apr_pstrdup(pPool, buf2);
-}
-
-
-
-static void fix_component(char *path, char *lastcomp)
-{
-    FILEFINDBUF3 fb3;
-    HDIR hDir = HDIR_CREATE;
-    ULONG numNames = 1;
-    ULONG rc = DosFindFirst( (UCHAR *)path, &hDir, FILE_NORMAL|FILE_DIRECTORY, &fb3, sizeof(fb3), &numNames, FIL_STANDARD );
-
-    if (rc == 0)
-        strcpy(lastcomp, fb3.achName);
-
-    DosFindClose(hDir);
-}
-
-
-
-char *ap_os_systemcase_canonical_filename(apr_pool_t *pPool, const char *szFile)
-{
-    char *szCanonicalFile = ap_os_case_canonical_filename(pPool, szFile);
-    int startslash = 2, slashnum=0;
-    char *pos, *prevslash = NULL;
-
-    if (szCanonicalFile[0] == '/' && szCanonicalFile[1] == '/') /* a UNC name */
-        startslash = 5;
-
-    for (pos = szCanonicalFile; *pos; pos++) {
-        if (*pos == '/') {
-            slashnum++;
-            if (slashnum >= startslash) {
-                *pos = 0;
-                fix_component(szCanonicalFile, prevslash+1);
-                *pos = '/';
-            }
-            prevslash = pos;
-        }
-    }
-
-    if (slashnum >= startslash) {
-        fix_component(szCanonicalFile, prevslash+1);
-    }
-
-    return szCanonicalFile;
-}
-
-
-
-char *ap_os_canonical_filename(apr_pool_t *pPool, const char *szFile)
-{
-    char *szCanonicalFile;
-    const unsigned char *pos = szFile;
-
-    /* Find any 8 bit characters */
-    while (*pos && *pos < 128) {
-        pos++;
-    }
-
-    /* Only use the very expensive ap_os_systemcase_canonical_filename() if
-     * the file name contains non-english characters as they are the only type
-     * that can't be made canonical with a simple strlwr() 
-     */
-    if (*pos < 128) {
-        szCanonicalFile = ap_os_case_canonical_filename(pPool, szFile);
-    } else {
-        szCanonicalFile = ap_os_systemcase_canonical_filename(pPool, szFile);
-    }
-
-    strlwr(szCanonicalFile);
-    return szCanonicalFile;
-}
-
 AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
     const request_rec *r,
     apr_proc_t *newproc, const char *progname,
diff --git a/os/tpf/os-inline.c b/os/tpf/os-inline.c
deleted file mode 100644 (file)
index c8299b5..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the APR_INLINE modifier. 
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. APR_INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * APR_HAS_INLINE will be zero so we can use this to test if we are
- * compiling this source file.
- */
-
-#include "apr.h"
-
-#if APR_HAS_INLINE
-/* keep inlined functions private to the including file */
-static
-#endif
-APR_INLINE int ap_os_is_path_absolute(const char *file)
-{
-    return file[0] == '/';
-}
index c50fdc5451ef4b83917a40e1927d994407326aff..7c41a39d62fbc4c7550434b53b70d162515bdae0 100644 (file)
 
 #include "apr.h"
 #include "ap_config.h"
-
-#if APR_HAS_INLINE
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-
-#include "os-inline.c"
-
-#else
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *f);
-#endif
-
 #include <strings.h>
 #ifndef __strings_h
 
diff --git a/os/unix/os-inline.c b/os/unix/os-inline.c
deleted file mode 100644 (file)
index c8299b5..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the APR_INLINE modifier. 
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. APR_INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * APR_HAS_INLINE will be zero so we can use this to test if we are
- * compiling this source file.
- */
-
-#include "apr.h"
-
-#if APR_HAS_INLINE
-/* keep inlined functions private to the including file */
-static
-#endif
-APR_INLINE int ap_os_is_path_absolute(const char *file)
-{
-    return file[0] == '/';
-}
index 267210d064da76f4f4e838a2dac5a3965e404db6..bfb0396a27f1d119c0b5074a42854edabfaeb74d 100644 (file)
 #define PLATFORM "Unix"
 #endif
 
-/**
- * @package OS Specific Functions
- */
-
-/*
- * This file in included in all Apache source code. It contains definitions
- * of facilities available on _this_ operating system (HAVE_* macros),
- * and prototypes of OS specific functions defined in os.c or os-inline.c
- */
-
-
-#if APR_HAS_INLINE
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-
-#include "os-inline.c"
-
-#else
-
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-
-/**
- * Is the path an absolute or relative path
- * @param file The path to the file
- * @return 1 if absolute, 0 otherwise
- * @deffunc int ap_os_is_path_absolute(const char *file)
- */
-extern int ap_os_is_path_absolute(const char *file);
-
-#endif
-
-/* Other ap_os_ routines not used by this platform */
-
-/**
- * Perform canonicalization on a given filename.  This means that files on
- * all platforms have the same format
- * @param p The pool to allocate the canonical filename out of
- * @param f The filename to canonicalize
- * @return The new filename
- * @deffunc char *ap_os_canonical_filename(apr_pool_t *p, const char *f)
- */
-#define ap_os_canonical_filename(p,f)  (f)
-
-/**
- * Perform canonicalization on a given filename, except that the input case
- * is preserved.
- * @param p The pool to allocate the canonical filename out of
- * @param f The filename to canonicalize
- * @return The new filename
- * @deffunc char *ap_os_case_canonical_filename(apr_pool_t *p, const char *f)
- */
-#define ap_os_case_canonical_filename(p,f)  (f)
-
-/**
- * Tries to match a filename to the existing patch, and returns the pathname
- * in the case that is present on the existing path.  This routine also
- * converts alias names to long names.
- * @param p The pool to allocate out of
- * @param f The file to match
- * @return The matched file name with the correct case
- * @deffunc char *ap_os_systemcase_filename(apr_pool_t *p, const char *f)
- */
-#define ap_os_systemcase_filename(p,f)  (f)
-
 #endif /* !APACHE_OS_H */
index 560c5963f21871ec2b3181c65929d73462db4ef8..31e2305628d0b0b9ade07abbbf884383a8abed17 100644 (file)
 #define _WIN32
 #endif
 
-#include "apr_general.h"
-#include <process.h>
-#include <malloc.h>
 #include <io.h>
 #include <fcntl.h>
 
 #define PLATFORM "Win32"
 
-#define APACHE_MPM_DIR  "modules/mpm/winnt" /* generated on unix */
-
-/* Although DIR_TYPE is dirent (see nt/readdir.h) we need direct.h for
-   chdir() */
-#include <direct.h>
-
-#define CASE_BLIND_FILESYSTEM
-#define NO_WRITEV
+/* going away shortly... */
 #define HAVE_CANONICAL_FILENAME
 #define HAVE_DRIVE_LETTERS
 #define HAVE_UNC_PATHS
+#define CASE_BLIND_FILESYSTEM
 
-typedef int uid_t;
-typedef int gid_t;
-typedef int pid_t;
-typedef int mode_t;
-typedef char * caddr_t;
-
-#define S_ISLNK(m) (0)
-#define S_ISREG(m) ((m & _S_IFREG) == _S_IFREG)
-#ifndef S_ISDIR
-#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR)
-#endif
-
-#define JMP_BUF jmp_buf
-#define O_CREAT _O_CREAT
-#define O_RDWR _O_RDWR
+#define APACHE_MPM_DIR  "server/mpm/winnt" /* generated on unix */
 
 #include <stddef.h>
 
-__inline int ap_os_is_path_absolute(const char *file)
-{
-  /* For now, just do the same check that http_request.c and mod_alias.c do. 
-   * XXX: Accept /bleh still?  Or do we concur that d:/bleh is a minimum
-   *      requirement?  If so, canonical name needs to convert to drive/path
-   *      syntax, and the test becomes (file[0] == '/' && file[1] == '/') ||...
-   */
-  return file && (file[0] == '/' || (file[1] == ':' && file[2] == '/'));
-}
-
-/* OS-dependent filename routines in util_win32.c */
-AP_DECLARE(char *) ap_os_canonical_filename(apr_pool_t *p, const char *file);
-AP_DECLARE(char *) ap_os_case_canonical_filename(apr_pool_t *pPool, const char *szFile);
-AP_DECLARE(char *) ap_os_systemcase_filename(apr_pool_t *pPool, const char *szFile);
-
 #endif   /* ! APACHE_OS_H */
index 8923db001bb4b07bcb4146d78714a517102f39e6..a930309e9819bfa363d3e363c607ae5d74514bbc 100644 (file)
 #include <time.h>
 #include <stdlib.h>
 
-/* Returns TRUE if the input string is a string
- * of one or more '.' characters.
- */
-static BOOL OnlyDots(char *pString)
-{
-    char *c;
-
-    if (*pString == '\0')
-        return FALSE;
-
-    for (c = pString;*c;c++)
-        if (*c != '.')
-            return FALSE;
-
-    return TRUE;
-}
-
-/* Accepts as input a pathname, and tries to match it to an 
- * existing path and return the pathname in the case that
- * is present on the existing path.  This routine also
- * converts alias names to long names.
- */
-AP_DECLARE(char *) ap_os_systemcase_filename(apr_pool_t *pPool, 
-                                             const char *szFile)
-{
-    char buf[HUGE_STRING_LEN];
-    char *pInputName;
-    char *p, *q, *t;
-    BOOL bDone = FALSE;
-    BOOL bFileExists = TRUE;
-
-    if (!szFile || strlen(szFile) == 0 || strlen(szFile) >= sizeof(buf))
-        return apr_pstrdup(pPool, "");
-
-    t = buf;
-    pInputName = apr_pstrdup(pPool, szFile);
-
-    /* First convert all slashes to \ so Win32 calls work OK */
-    for (p = pInputName; *p; p++) {
-        if (*p == '/')
-            *p = '\\';
-    }
-    
-    q = p = pInputName;
-    /* If there is drive information, copy it over. */ 
-    if (pInputName[1] == ':') {
-        /* This is correct - if systemcase is used for
-         * comparison, d: designations will match
-         */                    
-        *(t++) = tolower(*p++);
-        *(t++) = *p++;
-        q = p;
-
-        /* If all we have is a drive letter, then we are done */
-        if (!*p)
-            bDone = TRUE;
-
-        q = p;
-    }
-    
-    if (*p == '\\') {
-        ++p;
-        if (*p == '\\')  /* UNC name */
-        {
-            p++;
-            /* Get past the machine name.  FindFirstFile
-             * will not find a machine name only 
-             */
-            *(t++) = '\\';
-            ++q;
-            p = strchr(p + 1, '\\');
-            if (p)
-            {
-                p++;
-                /* Get past the share name.  FindFirstFile */
-                /* will not find a \\machine\share name only */
-                p = strchr(p, '\\'); 
-                if (p) {
-                    /* This was faulty - as of 1.3.13 \\machine\share 
-                     * name is now always lowercased
-                     */
-                    strncpy(t,q,p-q);
-                    strlwr(t);
-                    t += p - q;
-                    q = p;
-                    p++;
-                }
-            }
-
-            if (!p) {
-                bFileExists = FALSE;
-                p = q;
-            }
-        }
-    }
-
-    p = strchr(p, '\\');
-
-    while (!bDone) {
-        if (p)
-            *p = '\0';
-
-        if (strchr(q, '*') || strchr(q, '?'))
-            bFileExists = FALSE;
-
-        /* If the path exists so far, call FindFirstFile
-         * again.  However, if this portion of the path contains
-         * only '.' charaters, skip the call to FindFirstFile
-         * since it will convert '.' and '..' to actual names.
-         * Note: in the call to OnlyDots, we may have to skip
-         *       a leading slash.
-         */
-        if (bFileExists && !OnlyDots((*q == '.' ? q : q+1))) {
-            apr_finfo_t fs;
-            if (apr_stat(&fs, pInputName, APR_FINFO_NAME, pPool) != APR_SUCCESS) {
-                bFileExists = FALSE;
-            }
-            else {
-                if (*q == '\\')
-                    *(t++) = '\\';
-                t = strchr(strcpy(t, fs.name), '\0');
-            }
-        }
-        
-        if (!bFileExists || OnlyDots((*q == '.' ? q : q+1))) {
-            /* XXX: Comparison could be faulty ...\unknown
-             * names may not be tested (if they reside outside
-             * of the file system)!
-             */
-            strcpy(t, q);
-            t = strchr(t, '\0');
-        }
-        
-        if (p) {
-            q = p;
-            *p++ = '\\';
-            p = strchr(p, '\\');
-        }
-        else {
-            bDone = TRUE;
-        }
-    }
-    *t = '\0';
-
-    /* Finally, convert all slashes to / so server code handles it ok */
-
-    for (p = buf; *p; p++) {
-        if (*p == '\\')
-            *p = '/';
-    }
-
-    return apr_pstrdup(pPool, buf);
-}
-
-
-/*  Perform canonicalization with the exception that the
- *  input case is preserved.
- */
-AP_DECLARE(char *) ap_os_case_canonical_filename(apr_pool_t *pPool, 
-                                                 const char *szFile)
-{
-    char *pNewStr;
-    char *s;
-    char *p; 
-    char *q;
-
-    if (szFile == NULL || strlen(szFile) == 0)
-        return apr_pstrdup(pPool, "");
-
-    pNewStr = apr_pstrdup(pPool, szFile);
-
-    /*  Change all '\' characters to '/' characters.
-     *  While doing this, remove any trailing '.'.
-     *  Also, blow away any directories with 3 or
-     *  more '.'
-     */
-    for (p = pNewStr,s = pNewStr; *s; s++,p++) {
-        if (*s == '\\' || *s == '/') {
-
-            q = p;
-            while (p > pNewStr && *(p-1) == '.')
-                p--;
-
-            if (p == pNewStr && q-p <= 2 && *p == '.')
-                p = q;
-            else if (p > pNewStr && p < q && *(p-1) == '/') {
-                if (q-p > 2)
-                    p--;
-                else
-                    p = q;
-            }
-
-            *p = '/';
-        }
-        else {
-            *p = *s;
-        }
-    }
-    *p = '\0';
-
-    /*  Blow away any final trailing '.' since on Win32
-     *  foo.bat == foo.bat. == foo.bat... etc.
-     *  Also blow away any trailing spaces since
-     *  "filename" == "filename "
-     */
-    q = p;
-    while (p > pNewStr && (*(p-1) == '.' || *(p-1) == ' '))
-        p--;
-    if ((p > pNewStr) ||
-        (p == pNewStr && q-p > 2))
-        *p = '\0';
-        
-
-    /*  One more security issue to deal with.  Win32 allows
-     *  you to create long filenames.  However, alias filenames
-     *  are always created so that the filename will
-     *  conform to 8.3 rules.  According to the Microsoft
-     *  Developer's network CD (1/98) 
-     *  "Automatically generated aliases are composed of the 
-     *   first six characters of the filename plus ~n 
-     *   (where n is a number) and the first three characters 
-     *   after the last period."
-     *  Here, we attempt to detect and decode these names.
-     *
-     *  XXX: Netware network clients may have alternate short names,
-     *  simply truncated, with no embedded '~'.  Further, this behavior
-     *  can be modified on WinNT volumes.  This was not a safe test,
-     *  therefore exclude the '~' pretest.
-     */     
-#ifdef WIN32_SHORT_FILENAME_INSECURE_BEHAVIOR
-     p = strchr(pNewStr, '~');
-     if (p != NULL)
-#endif
-     {
-        char *pConvertedName, *pQstr, *pPstr;
-        char buf[HUGE_STRING_LEN];
-        /* We potentially have a short name.  Call 
-         * ap_os_systemcase_filename to examine the filesystem
-         * and possibly extract the long name.
-         */
-        pConvertedName = ap_os_systemcase_filename(pPool, pNewStr);
-
-        /* Since we want to preserve the incoming case as much
-         * as we can, compare for differences in the string and
-         * only substitute in the path names that changed.
-         */
-        if (stricmp(pNewStr, pConvertedName)) {
-            buf[0] = '\0';
-
-            q = pQstr = pConvertedName;
-            p = pPstr = pNewStr;
-            do {
-                q = strchr(q,'/');
-                p = strchr(p,'/');
-
-                if (p != NULL) {
-                    *q = '\0';
-                    *p = '\0';
-                }
-
-                if (stricmp(pQstr, pPstr)) 
-                    strcat(buf, pQstr);   /* Converted name */
-                else 
-                    strcat(buf, pPstr);   /* Original name  */
-
-
-                if (p != NULL) {
-                    pQstr = q;
-                    pPstr = p;
-                    *q++ = '/';
-                    *p++ = '/';
-                }
-
-            } while (p != NULL); 
-
-            pNewStr = apr_pstrdup(pPool, buf);
-        }
-    }
-
-    return pNewStr;
-}
-
-/*  Perform complete canonicalization.
- */
-AP_DECLARE(char *) ap_os_canonical_filename(apr_pool_t *pPool, const char *szFile)
-{
-    char *pNewName;
-    pNewName = ap_os_case_canonical_filename(pPool, szFile);
-    strlwr(pNewName);
-    return pNewName;
-}
-
-#ifdef NEVER_SINCE_THESE_TESTS_ARE_MOVING
-/* 
- * XXX we will no longer use this redunant parsing function, it's
- * logic moves off into the canonical filename processing and the
- * apr file handling functions.  Left for today till it's finished.
- *
- * ap_os_is_filename_valid is given a filename, and returns 0 if the filename
- * is not valid for use on this system. On Windows, this means it fails any
- * of the tests below. Otherwise returns 1.
- *
- * Test for filename validity on Win32. This is of tests come in part from
- * the MSDN article at "Technical Articles, Windows Platform, Base Services,
- * Guidelines, Making Room for Long Filenames" although the information
- * in MSDN about filename testing is incomplete or conflicting. There is a
- * similar set of tests in "Technical Articles, Windows Platform, Base Services,
- * Guidelines, Moving Unix Applications to Windows NT".
- *
- * The tests are:
- *
- * 1) total path length greater than MAX_PATH
- *
- * 2) anything using the octets 0-31 or characters " < > | :
- *    (these are reserved for Windows use in filenames. In addition
- *     each file system has its own additional characters that are
- *     invalid. See KB article Q100108 for more details).
- *
- * 3) anything ending in "." (no matter how many)
- *    (filename doc, doc. and doc... all refer to the same file)
- *
- * 4) any segment in which the basename (before first period) matches
- *    one of the DOS device names
- *    (the list comes from KB article Q100108 although  additional 
- *     names such as "COM5" are also special devices).
- *
- * If the path fails ANY of these tests, the result must be to deny access.
- */
-
-AP_DECLARE(int) ap_os_is_filename_valid(const char *file)
-{
-    const char *segstart;
-    unsigned int seglength;
-    const char *pos;
-    static const char * const invalid_characters = "?\"<>*|:";
-    static const char * const invalid_filenames[] = { 
-       "CON", "AUX", "COM1", "COM2", "COM3", 
-       "COM4", "LPT1", "LPT2", "LPT3", "PRN", "NUL", NULL 
-    };
-
-    /* Test 1 */
-    if (strlen(file) >= MAX_PATH) {
-       /* Path too long for Windows. Note that this test is not valid
-        * if the path starts with //?/ or \\?\. */
-       return 0;
-    }
-
-    pos = file;
-
-    /* Skip any leading non-path components. This can be either a
-     * drive letter such as C:, or a UNC path such as \\SERVER\SHARE\.
-     * We continue and check the rest of the path based on the rules above.
-     * This means we could eliminate valid filenames from servers which
-     * are not running NT (such as Samba).
-     */
-
-    if (pos[0] && pos[1] == ':') {
-       /* Skip leading drive letter */
-       pos += 2;
-    }
-    else {
-       if ((pos[0] == '\\' || pos[0] == '/') &&
-           (pos[1] == '\\' || pos[1] == '/')) {
-           /* Is a UNC, so skip the server name and share name */
-           pos += 2;
-           while (*pos && *pos != '/' && *pos != '\\')
-               pos++;
-           if (!*pos) {
-               /* No share name */
-               return 0;
-           }
-           pos++;      /* Move to start of share name */
-           while (*pos && *pos != '/' && *pos != '\\')
-               pos++;
-           if (!*pos) {
-               /* No path information */
-               return 0;
-           }
-       }
-    }
-
-    while (*pos) {
-       unsigned int idx;
-       unsigned int baselength;
-
-       while (*pos == '/' || *pos == '\\') {
-           pos++;
-       }
-       if (*pos == '\0') {
-           break;
-       }
-       segstart = pos; /* start of segment */
-       while (*pos && *pos != '/' && *pos != '\\') {
-           pos++;
-       }
-       seglength = pos - segstart;
-       /* 
-        * Now we have a segment of the path, starting at position "segstart"
-        * and length "seglength"
-        */
-
-       /* Test 2 */
-       for (idx = 0; idx < seglength; idx++) {
-           if ((segstart[idx] > 0 && segstart[idx] < 32) ||
-               strchr(invalid_characters, segstart[idx])) {
-               return 0;
-           }
-       }
-
-       /* Test 3 */
-       if (segstart[seglength-1] == '.') {
-           return 0;
-       }
-
-       /* Test 4 */
-       for (baselength = 0; baselength < seglength; baselength++) {
-           if (segstart[baselength] == '.') {
-               break;
-           }
-       }
-
-       /* baselength is the number of characters in the base path of
-        * the segment (which could be the same as the whole segment length,
-        * if it does not include any dot characters). */
-       if (baselength == 3 || baselength == 4) {
-           for (idx = 0; invalid_filenames[idx]; idx++) {
-               if (strlen(invalid_filenames[idx]) == baselength &&
-                   !strnicmp(invalid_filenames[idx], segstart, baselength)) {
-                   return 0;
-               }
-           }
-       }
-    }
-
-    return 1;
-}
-#endif
 
 AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
     const request_rec *r,
@@ -511,4 +74,3 @@ AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
 {
     return apr_proc_create(newproc, progname, args, env, attr, p);
 }
-
index 604056fb5e043ef6c9b0d6a9a6ebcb2b0c1a4504..eb42a28508719d5bda0036903836304145f7229a 100644 (file)
@@ -250,6 +250,21 @@ AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *exp)
     return (str[x] != '\0');
 }
 
+/* We actually compare the canonical root to this root, (but we don't
+ * waste time checking the case), since every use of this function in 
+ * httpd-2.0 tests if the path is 'proper', meaning we've already passed
+ * it through apr_filepath_merge, or we haven't.
+ */
+AP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir) 
+{
+    const char *newpath;
+    if (apr_filepath_root(&newpath, &dir, 0, p) != APR_SUCCESS
+            || strncmp(newpath, dir, strlen(newpath)) != 0) {
+        return 0;
+    }
+    return 1;
+}
+
 AP_DECLARE(int) ap_is_matchexp(const char *str)
 {
     register int x;