| Index: configure.in |
| =================================================================== |
| --- configure.in (revision 17608) |
| +++ configure.in (working copy) |
| @@ -52,8 +52,8 @@ |
| dnl - APR_GSETID added |
| dnl - bug in apr_temp_dir_get() fixed |
| |
| -APR_VER_REGEXES=["0\.9\.[5-9] 0\.9\.1[0-9] 1\."] |
| -APU_VER_REGEXES=["0\.9\.[5-9] 0\.9\.1[0-9] 1\."] |
| +APR_VER_REGEXES=["0\.9\.[4-9] 0\.9\.1[0-9] 1\."] |
| +APU_VER_REGEXES=["0\.9\.[4-9] 0\.9\.1[0-9] 1\."] |
| |
| SVN_LIB_APR($APR_VER_REGEXES) |
| SVN_LIB_APRUTIL($APU_VER_REGEXES) |
| Index: subversion/libsvn_fs_base/fs.c |
| =================================================================== |
| --- subversion/libsvn_fs_base/fs.c (revision 17608) |
| +++ subversion/libsvn_fs_base/fs.c (working copy) |
| @@ -1029,6 +1029,12 @@ |
| #endif /* DB_LOG_AUTOREMOVE */ |
| |
| |
| +/* Ensure compatibility with older APR 0.9.5 snapshots which don't |
| + * support the APR_LARGEFILE flag. */ |
| +#ifndef APR_LARGEFILE |
| +#define APR_LARGEFILE (0) |
| +#endif |
| + |
| /* Copy FILENAME from SRC_DIR to DST_DIR in byte increments of size |
| CHUNKSIZE. The read/write buffer of size CHUNKSIZE will be |
| allocated in POOL. */ |
| Index: subversion/libsvn_subr/io.c |
| =================================================================== |
| --- subversion/libsvn_subr/io.c (revision 17608) |
| +++ subversion/libsvn_subr/io.c (working copy) |
| @@ -23,6 +23,12 @@ |
| |
| #ifndef WIN32 |
| #include <unistd.h> |
| +#ifndef APR_GSETID |
| +/* Needed for fallback setgid code in dir_make */ |
| +#include <sys/types.h> |
| +#include <sys/stat.h> |
| +#include <errno.h> |
| +#endif |
| #endif |
| |
| #ifndef APR_STATUS_IS_EPERM |
| @@ -594,18 +600,118 @@ |
| } |
| |
| |
| +#if 1 /* TODO: Remove this code when APR 0.9.6 is released. */ |
| +#include <apr_env.h> |
| + |
| +/* Try to open a temporary file in the temporary dir, write to it, |
| + and then close it. */ |
| +static int test_tempdir(const char *temp_dir, apr_pool_t *p) |
| +{ |
| + apr_file_t *dummy_file; |
| + char *path = apr_pstrcat(p, temp_dir, "/apr-tmp.XXXXXX", NULL); |
| + |
| + if (apr_file_mktemp(&dummy_file, path, 0, p) == APR_SUCCESS) { |
| + if (apr_file_putc('!', dummy_file) == APR_SUCCESS) { |
| + if (apr_file_close(dummy_file) == APR_SUCCESS) { |
| + return 1; |
| + } |
| + } |
| + } |
| + return 0; |
| +} |
| +#endif |
| + |
| + |
| svn_error_t * |
| svn_io_temp_dir(const char **dir, |
| apr_pool_t *pool) |
| { |
| +#if 1 /* TODO: Remove this code when APR 0.9.6 is released. */ |
| + apr_status_t apr_err; |
| + static const char *try_dirs[] = { "/tmp", "/usr/tmp", "/var/tmp" }; |
| + static const char *try_envs[] = { "TMP", "TEMP", "TMPDIR" }; |
| + const char *temp_dir; |
| + char *cwd; |
| + apr_size_t i; |
| + |
| + /* Our goal is to find a temporary directory suitable for writing |
| + into. We'll only pay the price once if we're successful -- we |
| + cache our successful find. Here's the order in which we'll try |
| + various paths: |
| + |
| + $TMP |
| + $TEMP |
| + $TMPDIR |
| + "C:\TEMP" (windows only) |
| + "/tmp" |
| + "/var/tmp" |
| + "/usr/tmp" |
| + `pwd` |
| + |
| + NOTE: This algorithm is basically the same one used by Python |
| + 2.2's tempfile.py module. */ |
| + |
| + /* Try the environment first. */ |
| + for (i = 0; i < (sizeof(try_envs) / sizeof(const char *)); i++) |
| + { |
| + char *value; |
| + apr_err = apr_env_get(&value, try_envs[i], pool); |
| + if ((apr_err == APR_SUCCESS) && value) |
| + { |
| + apr_size_t len = strlen(value); |
| + if (len && (len < APR_PATH_MAX) && test_tempdir(value, pool)) |
| + { |
| + temp_dir = value; |
| + goto end; |
| + } |
| + } |
| + } |
| +#ifdef WIN32 |
| + /* Next, on Win32, try the C:\TEMP directory. */ |
| + if (test_tempdir("C:\\TEMP", pool)) |
| + { |
| + temp_dir = "C:\\TEMP"; |
| + goto end; |
| + } |
| +#endif /* WIN32 */ |
| + |
| + /* Next, try a set of hard-coded paths. */ |
| + for (i = 0; i < (sizeof(try_dirs) / sizeof(const char *)); i++) |
| + { |
| + if (test_tempdir(try_dirs[i], pool)) |
| + { |
| + temp_dir = try_dirs[i]; |
| + goto end; |
| + } |
| + } |
| + |
| + /* Finally, try the current working directory. */ |
| + if (APR_SUCCESS == apr_filepath_get(&cwd, APR_FILEPATH_NATIVE, pool)) |
| + { |
| + if (test_tempdir(cwd, pool)) |
| + { |
| + temp_dir = cwd; |
| + goto end; |
| + } |
| + } |
| + |
| + return svn_error_create |
| + (APR_EGENERAL, NULL, _("Can't find a temporary directory")); |
| + |
| +end: |
| + *dir = svn_path_canonicalize(temp_dir, pool); |
| + return SVN_NO_ERROR; |
| + |
| +#else |
| apr_status_t apr_err = apr_temp_dir_get(dir, pool); |
| |
| if (apr_err) |
| - return svn_error_wrap_apr(apr_err, _("Can't find a temporary directory")); |
| + return svn_err r_wrap_apr(apr_err, _("Can't find a temporary directory")); |
| |
| *dir = svn_path_canonicalize(*dir, pool); |
| |
| - return svn_path_cstring_to_utf8(dir, *dir, pool); |
| + return SVN_NO_ERROR; |
| +#endif |
| } |
| |
| |
| @@ -2787,6 +2893,7 @@ |
| } |
| #endif |
| |
| +#if defined(APR_GSETID) |
| if (sgid) |
| { |
| apr_finfo_t finfo; |
| @@ -2801,6 +2908,20 @@ |
| * don't support the sgid bit, and that's okay. */ |
| apr_file_perms_set(path_apr, finfo.protection | APR_GSETID); |
| } |
| +#elif !defined (WIN32) |
| + /* APR_GSETID appears in APR 0.9.5, so we need some fallback code |
| + until Subversion can require 0.9.5. */ |
| + if (sgid) |
| + { |
| + struct stat st; |
| + |
| + if (stat (path_apr, &st) != 0) |
| + return svn_error_wrap_apr (APR_FROM_OS_ERROR (errno), |
| + _("Can't stat new directory '%s'"), |
| + svn_path_local_style (path, pool)); |
| + chmod (path_apr, (st.st_mode & ~S_IFMT) | S_ISGID); |
| + } |
| +#endif |
| |
| return SVN_NO_ERROR; |
| } |