You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2013/12/05 12:41:23 UTC

svn commit: r1548097 - in /subversion/trunk/subversion: libsvn_fs_fs/rep-cache.c libsvn_subr/sqlite.c libsvn_subr/sqlite3wrapper.c libsvn_wc/wc_db_util.c

Author: philip
Date: Thu Dec  5 11:41:22 2013
New Revision: 1548097

URL: http://svn.apache.org/r1548097
Log:
Centralise SQLITE_DEFAULT_FILE_PERMISSIONS avoidance.

* subversion/libsvn_subr/sqlite.c
  (internal_open): Avoid SQLITE_DEFAULT_FILE_PERMISSIONS here.
  (svn_sqlite__hotcopy): Remove avoidance code.

* subversion/libsvn_fs_fs/rep-cache.c
  (open_rep_cache): Remove avoidance code.

* subversion/libsvn_wc/wc_db_util.c
  (svn_wc__db_util_open_db): Remove avoidance code.

* subversion/libsvn_subr/sqlite3wrapper.c
  (SQLITE_DEFAULT_FILE_PERMISSIONS): Set for amalgamation builds.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
    subversion/trunk/subversion/libsvn_subr/sqlite.c
    subversion/trunk/subversion/libsvn_subr/sqlite3wrapper.c
    subversion/trunk/subversion/libsvn_wc/wc_db_util.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c?rev=1548097&r1=1548096&r2=1548097&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c Thu Dec  5 11:41:22 2013
@@ -79,16 +79,10 @@ open_rep_cache(void *baton,
   svn_sqlite__db_t *sdb;
   const char *db_path;
   int version;
-  svn_boolean_t exists;
-
-  SVN_ERR(svn_fs_fs__exists_rep_cache(&exists, fs, pool));
 
   /* Open (or create) the sqlite database.  It will be automatically
-     closed when fs->pool is destoyed.  We create the empty file first
-     to avoid SQLITE_DEFAULT_FILE_PERMISSIONS. */
+     closed when fs->pool is destoyed.  */
   db_path = path_rep_cache_db(fs->path, pool);
-  if (!exists)
-    SVN_ERR(svn_io_file_create_empty(db_path, pool));
   SVN_ERR(svn_sqlite__open(&sdb, db_path,
                            svn_sqlite__mode_rwcreate, statements,
                            0, NULL,

Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1548097&r1=1548096&r2=1548097&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sqlite.c Thu Dec  5 11:41:22 2013
@@ -808,6 +808,21 @@ internal_open(sqlite3 **db3, const char 
        somebody initialized SQLite before us it is needed anyway.  */
     flags |= SQLITE_OPEN_NOMUTEX;
 
+#if !defined(WIN32) && !defined(SVN_SQLITE_INLINE)
+    if (mode == svn_sqlite__mode_rwcreate)
+      {
+        svn_node_kind_t kind;
+
+        /* Create the file before SQLite to avoid any permissions
+           problems with an SQLite build that uses the default
+           SQLITE_DEFAULT_FILE_PERMISSIONS of 644 modified by umask.
+           We simply want umask permissions. */
+        SVN_ERR(svn_io_check_path(path, &kind, scratch_pool));
+        if (kind == svn_node_none)
+          SVN_ERR(svn_io_file_create_empty(path, scratch_pool));
+      }
+#endif
+
     /* Open the database. Note that a handle is returned, even when an error
        occurs (except for out-of-memory); thus, we can safely use it to
        extract an error message and construct an svn_error_t. */
@@ -1314,12 +1329,6 @@ svn_sqlite__hotcopy(const char *src_path
     svn_sqlite__db_t *dst_db;
     sqlite3_backup *backup;
     int rc1, rc2;
-    svn_node_kind_t kind;
-
-    /* Create empty file first to avoid SQLITE_DEFAULT_FILE_PERMISSIONS. */
-    SVN_ERR(svn_io_check_path(dst_path, &kind, scratch_pool));
-    if (kind == svn_node_none)
-      SVN_ERR(svn_io_file_create_empty(dst_path, scratch_pool));
 
     SVN_ERR(svn_sqlite__open(&dst_db, dst_path, svn_sqlite__mode_rwcreate,
                              NULL, 0, NULL, scratch_pool, scratch_pool));

Modified: subversion/trunk/subversion/libsvn_subr/sqlite3wrapper.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite3wrapper.c?rev=1548097&r1=1548096&r2=1548097&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sqlite3wrapper.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sqlite3wrapper.c Thu Dec  5 11:41:22 2013
@@ -50,6 +50,7 @@
 #      undef inline
 #    endif
 #  endif
+#  define SQLITE_DEFAULT_FILE_PERMISSIONS 0666
 #  include <sqlite3.c>
 #  if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6))
 #    pragma GCC diagnostic pop

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_util.c?rev=1548097&r1=1548096&r2=1548097&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_util.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_util.c Thu Dec  5 11:41:22 2013
@@ -136,22 +136,6 @@ svn_wc__db_util_open_db(svn_sqlite__db_t
                                  svn_dirent_local_style(sdb_abspath,
                                                         scratch_pool));
     }
-#ifndef WIN32
-  else
-    {
-      apr_file_t *f;
-
-      /* A standard SQLite build creates a DB with mode 644 ^ !umask
-         which means the file doesn't have group/world write access
-         even when umask allows it. By ensuring the file exists before
-         SQLite gets involved we give it the permissions allowed by
-         umask. */
-      SVN_ERR(svn_io_file_open(&f, sdb_abspath,
-                               (APR_READ | APR_WRITE | APR_CREATE),
-                               APR_OS_DEFAULT, scratch_pool));
-      SVN_ERR(svn_io_file_close(f, scratch_pool));
-    }
-#endif
 
   SVN_ERR(svn_sqlite__open(sdb, sdb_abspath, smode,
                            my_statements ? my_statements : statements,