1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package Gitolite::Triggers::RepoUmask;
use Gitolite::Rc;
use Gitolite::Common;
use Gitolite::Conf::Load;
use strict;
use warnings;
# setting a repo specific umask
# ----------------------------------------------------------------------
# this is for people who are too paranoid to trust e.g., gitweb's repo
# exclusion logic, but not paranoid enough to put it on a different server
=for usage
* In the rc file, add the line
'RepoUmask',
somewhere in the ENABLE list
* For each repo that is to get a different umask than the default, add a
line like this:
option umask = 0027
* Anytime you add or change the value, if there are existing repos that
would be affected, you will need to do a manual "chmod" adjustment,
because umask only affects newly created files.
=cut
# sadly option/config values are not available at pre_create time for normal
# repos. So we have to do a one-time fixup in a post_create trigger.
sub post_create {
my $repo = $_[1];
my $umask = option( $repo, 'umask' );
_chdir( $rc{GL_REPO_BASE} ); # because using option() moves us to ADMIN_BASE!
return unless $umask;
# unlike the one in the rc file, this is a string
$umask = oct($umask);
my $mode = "0" . sprintf( "%o", $umask ^ 0777 );
system("chmod -R $mode $repo.git >&2");
system("find $repo.git -type f -exec chmod a-x '{}' \\;");
}
sub pre_git {
my $repo = $_[1];
my $umask = option( $repo, 'umask' );
_chdir( $rc{GL_REPO_BASE} ); # because using option() moves us to ADMIN_BASE!
return unless $umask;
# unlike the one in the rc file, this is a string
umask oct($umask);
}
1;
|