Switch ref-change to take username instead of uid
[girocco.git] / Girocco / Config.pm
blob20f4d5a7c673b19c64e854736ef9871a2449354c
1 package Girocco::Config;
3 use strict;
4 use warnings;
7 ## Basic settings
9 # Name of the service
10 our $name = "GiroccoEx";
12 # Nickname of the service (undef for initial part of $name upto first '.')
13 our $nickname = undef;
15 # Title of the service (as shown in gitweb)
16 our $title = "Example Girocco Hosting";
18 # Path to the Git binary to use (you MUST set this, even if to /usr/bin/git!)
19 our $git_bin = '/usr/bin/git';
21 # Path to the git-http-backend binary to use (undef to use /usr/lib/git-core/git-http-backend)
22 # If both $httppullurl and $httpspushurl are undef this will never be used
23 our $git_http_backend_bin = undef;
25 # E-mail of the site admin
26 our $admin = 'admin@example.org';
28 # Girocco branch to use for html.cgi view source links (undef for HEAD)
29 our $giroccobranch = undef;
32 ## Feature knobs
34 # Enable mirroring mode if true
35 our $mirror = 1;
37 # Enable push mode if true
38 our $push = 1;
40 # Enable user management if true; this means the interface for registering
41 # user accounts and uploading SSH keys. This implies full chroot.
42 our $manage_users = 1;
44 # Enable the special 'mob' user if set to 'mob'
45 our $mob = "mob";
47 # Let users set admin passwords; if false, all password inputs are assumed empty.
48 # This will make new projects use empty passwords and all operations on them
49 # unrestricted, but you will be able to do no operations on previously created
50 # projects you have set a password on.
51 our $project_passwords = 1;
53 # How to determine project owner; 'email' adds a form item asking for their
54 # email contact, 'source' takes realname of owner of source repository if it
55 # is a local path (and empty string otherwise). 'source' is suitable in case
56 # the site operates only as mirror of purely local-filesystem repositories.
57 our $project_owners = 'email';
59 # Which project fields to make editable, out of 'shortdesc', 'homepage',
60 # 'README', 'notifymail', 'notifyjson', 'notifycia'. (This is currently
61 # soft restriction - form fields aren't used, but manually injected values
62 # *are* used. Submit a patch if that's an issue for you.)
63 our @project_fields = qw(homepage shortdesc README notifymail notifyjson notifycia);
65 # Minimal number of seconds to pass between two updates of a project.
66 our $min_mirror_interval = 3600; # 1 hour
68 # Minimal number of seconds to pass between two garbage collections of a project.
69 our $min_gc_interval = 604800; # 1 week
72 ## Paths
74 # Path where the main chunk of Girocco files will be installed
75 # This will get COMPLETELY OVERWRITTEN by each make install!!!
76 our $basedir = '/home/repo/repomgr';
78 # Path where the automatically generated non-user certificates will be stored
79 # (The per-user certificates are always stored in $chroot/etc/sshcerts/)
80 # This is preserved by each make install and MUST NOT be under $basedir!
81 # Not used unless $httpspushurl is defined
82 our $certsdir = '/home/repo/certs';
84 # The repository collection
85 # "$reporoot-recyclebin" will also be created for use by toolbox/trash-project.pl
86 our $reporoot = "/srv/git";
88 # The repository collection's location within the chroot jail
89 # Normally $reporoot will be bind mounted onto $chroot/$jailreporoot
90 # Should NOT start with '/'
91 our $jailreporoot = "srv/git";
93 # The chroot for ssh pushing; location for project database and other run-time
94 # data even in non-chroot setups
95 our $chroot = "/home/repo/j";
97 # The gitweb files web directory (corresponds to $gitwebfiles)
98 our $webroot = "/home/repo/WWW";
100 # The CGI-enabled web directory (corresponds to $gitweburl and $webadmurl)
101 our $cgiroot = "/home/repo/WWW";
103 # A web-accessible symlink to $reporoot (corresponds to $httppullurl, can be undef)
104 our $webreporoot = "/home/repo/WWW/r";
107 ## Certificates (only used if $httpspushurl is defined)
109 # path to root certificate (undef to use automatic root cert)
110 # this certificate is made available for easy download and should be whatever
111 # the root certificate is for the https certificate being used by the web server
112 our $rootcert = undef;
114 # The certificate to sign user push client authentication certificates with (undef for auto)
115 # The automatically generated certificate should always be fine
116 our $clientcert = undef;
118 # The private key for $clientcert (undef for auto)
119 # The automatically generated key should always be fine
120 our $clientkey = undef;
122 # The client certificate chain suffix (a pemseq file to append to user client certs) (undef for auto)
123 # The automatically generated chain should always be fine
124 # This suffix will also be appended to the $mobusercert before making it available for download
125 our $clientcertsuffix = undef;
127 # The mob user certificate signed by $clientcert (undef for auto)
128 # The automatically generated certificate should always be fine
129 # Not used unless $mob is set to 'mob'
130 # The $clientcertsuffix will be appended before making $mobusercert available for download
131 our $mobusercert = undef;
133 # The private key for $mobusercert (undef for auto)
134 # The automatically generated key should always be fine
135 # Not used unless $mob is set to 'mob'
136 our $mobuserkey = undef;
139 ## URL addresses
141 # URL of the gitweb.cgi script (must be in pathinfo mode)
142 our $gitweburl = "http://repo.or.cz/w";
144 # URL of the extra gitweb files (CSS, .js files, images, ...)
145 our $gitwebfiles = "http://repo.or.cz";
147 # URL of the Girocco CGI web admin interface (Girocco cgi/ subdirectory)
148 our $webadmurl = "http://repo.or.cz";
150 # URL of the Girocco CGI html templater (Girocco cgi/html.cgi)
151 our $htmlurl = "http://repo.or.cz/h";
153 # HTTP URL of the repository collection (undef if N/A)
154 our $httppullurl = "http://repo.or.cz/r";
156 # HTTPS push URL of the repository collection (undef if N/A)
157 # If this is defined, the openssl command must be available
158 # Normally this should be set to $httppullurl with http: replaced with https:
159 our $httpspushurl = undef;
161 # Git URL of the repository collection (undef if N/A)
162 # (You need to set up git-daemon on your system, and Girocco will not
163 # do this particular thing for you.)
164 our $gitpullurl = "git://repo.or.cz";
166 # Pushy SSH URL of the repository collection (undef if N/A)
167 our $pushurl = "ssh://repo.or.cz/$jailreporoot";
169 # URL of gitweb of this Girocco instance (set to undef if you're not nice
170 # to the community)
171 our $giroccourl = "$Girocco::Config::gitweburl/girocco.git";
174 ## Some templating settings
176 # Legal warning (on reguser and regproj pages)
177 our $legalese = <<EOT;
178 <p>By submitting this form, you are confirming that you will mirror or push
179 only what we can store and show to anyone else who can visit this site without
180 breaking any law, and that you will be nice to all small furry animals.
181 <sup><a href="$Girocco::Config::htmlurl/about.html">(more details)</a></sup>
182 </p>
185 # Pre-configured mirror sources (set to undef for none)
186 # Arrayref of name - record pairs, the record has these attributes:
187 # label: The label of this source
188 # url: The template URL; %1, %2, ... will be substituted for inputs
189 # desc: Optional VERY short description
190 # link: Optional URL to make the desc point at
191 # inputs: Arrayref of hashref input records:
192 # label: Label of input record
193 # suffix: Optional suffix
194 # If the inputs arrayref is undef, single URL input is shown,
195 # pre-filled with url (probably empty string).
196 our $mirror_sources = [
198 label => 'Anywhere',
199 url => '',
200 desc => 'Any HTTP/Git/rsync pull URL - bring it on!',
201 inputs => undef
204 label => 'GitHub',
205 url => 'git://github.com/%1/%2.git',
206 desc => 'GitHub Social Code Hosting',
207 link => 'http://github.com/',
208 inputs => [ { label => 'User:' }, { label => 'Project:', suffix => '.git' } ]
211 label => 'Gitorious',
212 url => 'git://gitorious.org/%1/%2.git',
213 desc => 'Green and Orange Boxes',
214 link => 'http://gitorious.org/',
215 inputs => [ { label => 'Project:' }, { label => 'Repository:', suffix => '.git' } ]
219 # You can customize the gitweb interface widely by editing
220 # gitweb/gitweb_config.perl
223 ## Permission settings
225 # Girocco needs some way to manipulate write permissions to various parts of
226 # all repositories; this concerns three entities:
227 # - www-data: the web interface needs to be able to rewrite few files within
228 # the repository
229 # - repo: a user designated for cronjobs; handles mirroring and repacking;
230 # this one is optional if not $mirror
231 # - others: the designated users that are supposed to be able to push; they
232 # may have account either within chroot, or outside of it
234 # There are several ways how to use Girocco based on a combination of the
235 # following settings.
237 # (Non-chroot) UNIX user the CGI scripts run on; note that if some non-related
238 # untrusted CGI scripts run on this account too, that can be a big security
239 # problem and you'll probably need to set up suexec (poor you).
240 # This must always be set.
241 our $cgi_user = 'www-data';
243 # (Non-chroot) UNIX user performing mirroring jobs; this is the user who
244 # should run all the daemons and cronjobs and
245 # the user who should be running make install (if not root).
246 # This must always be set.
247 our $mirror_user = 'repo';
249 # (Non-chroot) UNIX group owning the repositories by default; it owns whole
250 # mirror repositories and at least web-writable metadata of push repositories.
251 # If you undefine this, all the data will become WORLD-WRITABLE.
252 # Both $cgi_user and $mirror_user should be members of this group!
253 our $owning_group = 'repo';
255 # Whether to use chroot jail for pushing; this must be always the same
256 # as $manage_users.
257 # TODO: Gitosis support for $manage_users and not $chrooted?
258 our $chrooted = $manage_users;
260 # How to control permissions of push-writable data in push repositories:
261 # * 'Group' for the traditional model: The $chroot/etc/group project database
262 # file is used as the UNIX group(5) file; the directories have gid appropriate
263 # for the particular repository and are group-writable. This works only if
264 # $chrooted so that users are put in the proper groups on login when using
265 # SSH push. Smart HTTPS push does not require a chroot to work -- simply
266 # run "make install" as the non-root $mirror_user user, but leave
267 # $manage_users and $chrooted enabled.
268 # * 'ACL' for a model based on POSIX ACL: The directories are coupled with ACLs
269 # listing the users with push permissions. This works for both chroot and
270 # non-chroot setups, however it requires ACL support within the filesystem.
271 # This option is BASICALLY UNTESTED, too. And UNIMPLEMENTED. :-)
272 # * 'Hooks' for a relaxed model: The directories are world-writable and push
273 # permission control is purely hook-driven. This is INSECURE and works only
274 # when you trust all your users; on the other hand, the attack vectors are
275 # mostly just DoS or fully-traceable tinkering.
276 our $permission_control = 'Group';
278 # Path to alternate screen multiuser acl file (see screen/README, undef for none)
279 our $screen_acl_file = undef;
281 # Couple of sanity checks and default settings (do not change these)
282 $nickname = (split(/[.]/, $Girocco::Config::name))[0] unless $nickname;
283 ($mirror_user) or die "Girocco::Config: \$mirror_user must be set even if to current user";
284 $screen_acl_file = "$basedir/screen/giroccoacl" unless $screen_acl_file;
285 $jailreporoot =~ s,^/+,,;
286 ($reporoot) or die "Girocco::Config \$reporoot must be set";
287 ($jailreporoot) or die "Girocco::Config \$jailreporoot must be set";
288 (not $mob or $mob eq 'mob') or die "Girocco::Config \$mob must be undef (or '') or 'mob'";
289 $rootcert = "$certsdir/girocco_root_crt.pem" if $httpspushurl && !$rootcert;
290 $clientcert = "$certsdir/girocco_client_crt.pem" if $httpspushurl && !$clientcert;
291 $clientkey = "$certsdir/girocco_client_key.pem" if $httpspushurl && !$clientkey;
292 $clientcertsuffix = "$certsdir/girocco_client_suffix.pem" if $httpspushurl && !$clientcertsuffix;
293 $mobusercert = "$certsdir/girocco_mob_user_crt.pem" if $httpspushurl && $mob && !$mobusercert;
294 $mobuserkey = "$certsdir/girocco_mob_user_key.pem" if $httpspushurl && $mob && !$mobuserkey;
295 our $mobpushurl = $pushurl;
296 $mobpushurl =~ s,^ssh://,ssh://mob@,i if $mobpushurl;
297 our $httpsdnsname = ($httpspushurl =~ m,https://([A-Za-z0-9.-]+),i) ? lc($1) : undef if $httpspushurl;
298 ($mirror or $push) or die "Girocco::Config: neither \$mirror nor \$push is set?!";
299 (not $push or ($pushurl or $httpspushurl or $gitpullurl or $httppullurl)) or die "Girocco::Config: no pull URL is set";
300 (not $push or ($pushurl or $httpspushurl)) or die "Girocco::Config: \$push set but \$pushurl and \$httpspushurl are undef";
301 (not $mirror or $mirror_user) or die "Girocco::Config: \$mirror set but \$mirror_user is undef";
302 ($manage_users == $chrooted) or die "Girocco::Config: \$manage_users and \$chrooted must be set to the same value";
303 (not $chrooted or $permission_control ne 'ACL') or die "Girocco::Config: resolving uids for ACL not supported when using chroot";
304 (grep { $permission_control eq $_ } qw(Group Hooks)) or die "Girocco::Config: \$permission_control must be set to Group or Hooks";
305 ($chrooted or not $mob) or die "Girocco::Config: mob user supported only in the chrooted mode";
306 (not $httpspushurl or $httpsdnsname) or die "Girocco::Config invalid \$httpspushurl does not start with https://domainname";