Author: stsp
Date: Mon Aug  5 14:36:08 2019
New Revision: 1864440

URL: http://svn.apache.org/viewvc?rev=1864440&view=rev
Log:
Fix 'svn patch' setting UNIX permissions to 0600 on patched files with props.

* subversion/libsvn_client/patch.c
  (init_patch_target): Use the working copy's own temp directory to store
   temporary files for patching, instead of using the system-wide temp dir.
   With a system-wide dir, permission paranoia in svn_io_open_unique_file3()
   may kick in and result in patched files with permissions not matching the
   umask. Generally, any temp files that may end up as user-visible files
   in the working copy should be created in the working copy's temp dir.

Reported by: Doug Robinson at wandisco com

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1864440&r1=1864439&r2=1864440&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Mon Aug  5 14:36:08 2019
@@ -1020,6 +1020,7 @@ init_patch_target(patch_target_t **patch
   target_content_t *content;
   svn_boolean_t has_text_changes = FALSE;
   svn_boolean_t follow_moves;
+  const char *tempdir_abspath;
 
   has_text_changes = ((patch->hunks && patch->hunks->nelts > 0)
                       || patch->binary_patch);
@@ -1225,8 +1226,10 @@ init_patch_target(patch_target_t **patch
         }
 
       /* Open a temporary file to write the patched result to. */
+      SVN_ERR(svn_wc__get_tmpdir(&tempdir_abspath, wc_ctx,
+          target->local_abspath, scratch_pool, scratch_pool));
       SVN_ERR(svn_io_open_unique_file3(&target->patched_file,
-                                       &target->patched_path, NULL,
+                                       &target->patched_path, tempdir_abspath,
                                        remove_tempfiles ?
                                          svn_io_file_del_on_pool_cleanup :
                                          svn_io_file_del_none,
@@ -1238,7 +1241,7 @@ init_patch_target(patch_target_t **patch
 
       /* Open a temporary stream to write rejected hunks to. */
       SVN_ERR(svn_stream_open_unique(&target->reject_stream,
-                                     &target->reject_path, NULL,
+                                     &target->reject_path, tempdir_abspath,
                                      remove_tempfiles ?
                                          svn_io_file_del_on_pool_cleanup :
                                          svn_io_file_del_none,


Reply via email to