retain old file's permissions in wrap_print()
wrap_print() was written to create a new file and rename the old one to avoid a partially written file being read by other processes. This has only been reported for the 'projects.list' file, but I just did it for all files as a matter of course. list of files currently written via this function: gl-creater, gl-perms, description, git-daemon-export-ok, projects.list However, some people want to do the following: - set REPO_UMASK tight (0077, default) - manually change the perms to something looser (typically g+rX) for specific repos - set core.sharedRepository to 0750 (git is documented to honor that config if available and to override umask) Except that core.sharedRepository does not apply to files written by gitolite and not git itself. So they would open up their description files and the next compile would close them again! This patch prevents this from happening. If the file already exists, it maintains the same permissions after the rename.
This commit is contained in:
parent
7c8c5a899b
commit
6863dca73a
|
@ -110,7 +110,9 @@ sub wrap_print {
|
|||
my $fh = wrap_open(">", "$file.$$");
|
||||
print $fh @text;
|
||||
close($fh) or die "$ABRT close $file failed: $! at ", (caller)[1], " line ", (caller)[2], "\n";
|
||||
my $oldmode = ( (stat $file)[2] );
|
||||
rename "$file.$$", $file;
|
||||
chmod $oldmode, $file if $oldmode;
|
||||
}
|
||||
|
||||
sub slurp {
|
||||
|
|
Loading…
Reference in a new issue