From fd9aa0403b6fa151630efe5088c5beffe00d8ecd Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Tue, 5 Nov 2013 17:12:22 -0800 Subject: Fix umask stability issues that caused only partially visible repos in gitweb. Signed-off-by: Robin H. Johnson --- src/gitolite.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gitolite.pm b/src/gitolite.pm index 37f3977..487f265 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -286,7 +286,9 @@ sub new_repo { my ($repo, $hooks_dir, $creator, $umask) = @_; - umask($umask ? $umask : get_repo_umask($repo)); + my $oldumask = umask(); + my $newumask = $umask ? $umask : get_repo_umask($repo); + umask($newumask); die "wildrepos disabled, can't set creator $creator on new repo $repo\n" if $creator and not $GL_WILDREPOS; @@ -310,6 +312,7 @@ sub new_repo # set to "gitolite-admin", so we need to make sure that for the duration # of the hook it is set correctly. system("env", "GL_REPO=$repo", "hooks/gl-post-init") if -x "hooks/gl-post-init"; + umask($oldumask); } sub new_wild_repo { @@ -529,7 +532,7 @@ sub setup_daemon_access sub setup_web_access { # input is a hashref; keys are project names if ($WEB_INTERFACE eq 'gitweb') { - + my $oldumask = umask(022); my $projlist = shift; my $projlist_fh = wrap_open( ">", "$PROJECTS_LIST.$$"); for my $proj (sort keys %{ $projlist }) { @@ -537,7 +540,7 @@ sub setup_web_access { } close $projlist_fh; rename "$PROJECTS_LIST.$$", $PROJECTS_LIST; - + umask($oldumask); } else { warn "sorry, unknown web interface $WEB_INTERFACE\n"; } @@ -570,6 +573,9 @@ sub setup_gitweb_access # we may override but we do not remove gitweb.owner and description # for wild repos + my $newumask = get_repo_umask($repo); + my $oldumask = umask(); + if ($desc) { open(DESC, ">", $desc_file); print DESC $desc . "\n"; @@ -590,6 +596,7 @@ sub setup_gitweb_access system("git config --remove-section gitweb 2>/dev/null"); } + umask($oldumask); return (can_read($repo, 'gitweb') or $desc); # this return value is used by the caller to write to projects.list } -- cgit v1.2.3-65-gdbad