refs: and we're logging...
[girocco.git] / Girocco / Config.pm
blob5c0fee08f6efdba6bf7088d9e81df5f7723fc41d
1 package Girocco::Config;
3 use strict;
4 use warnings;
8 ## --------------
9 ## Basic settings
10 ## --------------
13 # Name of the service (typically a single word or a domain name)
14 # (no spaces allowed)
15 our $name = "GiroccoEx";
17 # Nickname of the service (undef for initial part of $name upto first '.')
18 # (no spaces allowed)
19 our $nickname = undef;
21 # Title of the service (as shown in gitweb)
22 # (may contain spaces)
23 our $title = "Example Girocco Hosting";
25 # Path to the Git binary to use (you MUST set this, even if to /usr/bin/git!)
26 our $git_bin = '/usr/bin/git';
28 # Path to the git-daemon binary to use (undef to use default)
29 # If $gitpullurl is undef this will never be used (assuming no git inetd
30 # service has been set up in that case).
31 # The default if this is undef is `$git_bin --exec-path`/git-daemon
32 our $git_daemon_bin = undef;
34 # Path to the git-http-backend binary to use (undef to use default)
35 # If both $httppullurl and $httpspushurl are undef this will never be used
36 # The default if this is undef is `$git_bin --exec-path`/git-http-backend
37 our $git_http_backend_bin = undef;
39 # Name (if in $PATH) or full path to netcat executable that accepts a -U option
40 # to connect to a unix socket. This may simply be 'nc' on many systems.
41 our $nc_openbsd_bin = 'nc.openbsd';
43 # Path to POSIX sh executable to use. Set to undef to use /bin/sh
44 our $posix_sh_bin = undef;
46 # Path to Perl executable to use. Set to undef to use Perl found in $PATH
47 our $perl_bin = undef;
49 # Path to the sendmail instance to use. It should understand the -f <from>, -i and -t
50 # options as well as accepting a list of recipient addresses in order to be used here.
51 # You MUST set this, even if to '/usr/sbin/sendmail'!
52 # Setting this to 'sendmail.pl' is special and will automatically be expanded to
53 # a full path to the ../bin/sendmail.pl executable in this Girocco installation.
54 # sendmail.pl is a sendmail-compatible script that delivers the message directly
55 # using SMTP to a mail relay host. This is the recommended configuration as it
56 # minimizes the information exposed to recipients (no sender account names or uids),
57 # can talk to an SMTP server on another host (eliminating the need for a working
58 # sendmail and/or SMTP server on this host) and avoids any unwanted address rewriting.
59 # By default it expects the mail relay to be listening on localhost port 25.
60 # See the sendmail.pl section below for more information on configuring sendmail.pl.
61 our $sendmail_bin = 'sendmail.pl';
63 # E-mail of the site admin
64 our $admin = 'admin@example.org';
66 # Sender of emails
67 # This is the SMTP 'MAIL FROM:' value
68 # It will be passed to $sendmail_bin with the -f option
69 # Some sites may not allow non-privileged users to pass the -f option to
70 # $sendmail_bin. In that case set this to undef and no -f option will be
71 # passed which means the 'MAIL FROM:' value will be the user the mail is
72 # sent as (either $cgi_user or $mirror_user depending on the activity).
73 # To avoid having bounce emails go to $admin, this may be set to something
74 # else such as 'admin-noreply@example.org' and then the 'admin-noreply' address
75 # may be redirected to /dev/null. Setting this to '' or '<>' is not
76 # recommended because that will likely cause the emails to be marked as SPAM
77 # by the receiver's SPAM filter. If $sendmail_bin is set to 'sendmail.pl' this
78 # value must be acceptable to the receiving SMTP server as a 'MAIL FROM:' value.
79 # If this is set to undef and 'sendmail.pl' is used, the 'MAIL FROM:' value will
80 # be the user the mail is sent as (either $cgi_user or $mirror_user).
81 our $sender = $admin;
83 # Copy $admin on failure/recovery messages?
84 our $admincc = 1;
86 # Girocco branch to use for html.cgi view source links (undef for HEAD)
87 our $giroccobranch = undef;
89 # PATH adjustments
90 # If the PATH needs to be customized to find required executables on
91 # the system, it can be done here.
92 # For example something like this:
93 #$ENV{PATH} = substr(`/usr/bin/getconf PATH`,0,-1).":/usr/local/bin";
97 ## ----------------------
98 ## Git user agent strings
99 ## ----------------------
102 # Git clients (i.e. fetch/clone) always send a user agent string when fetching
103 # over HTTP. Since version 1.7.12.1 an 'agent=' capability string is included
104 # as well which affects git:, smart HTTP and ssh: protocols.
106 # These settings allow the default user agent string to be changed independently
107 # for fetch/clone operations (only matters if $mirror is true) and server
108 # operations (some other Git client fetching from us). Note that it is not
109 # possible to suppress the capability entirely although it can be set to an
110 # empty string. If these values are not set, the default user agent string
111 # will be used. Typically (unless Git was built with non-standard options) the
112 # default is "git/" plus the version. So for example "git/1.8.5.6" or
113 # "git/2.1.4" might be seen.
115 # One might want to change the default user agent strings in order to prevent
116 # an attacker from learning the exact Git version being used to avoid being
117 # able to quickly target any version-specific vulnerabilities. Note that
118 # no matter what's set here, an attacker can easily determine whether a server
119 # is running JGit, libgit2 or Git and for Git whether it's version 1.7.12.1 or
120 # later. A reasonable value to hide the exact Git version number while
121 # remaining compatible with servers that require a "Git/" user agent string
122 # would be something like "git/2" or even just "git/".
124 # The GIT_USER_AGENT value to use when acting as a client (i.e. clone/fetch)
125 # This value is only used if $mirror is true and at least one mirror is set up.
126 # Setting this to the empty string will suppress the HTTP User-Agent header,
127 # but will still include an "agent=" capability in the packet protocol. The
128 # empty string is not recommended because some servers match on "git/".
129 # Leave undef to use the default Git user agent string
130 # IMPORTANT: some server sites will refuse to serve up Git repositories unless
131 # the client user agent string contains "Git/" (matched case insensitively)!
132 our $git_client_ua = undef;
134 # The GIT_USER_AGENT value to use when acting as a server (i.e. some Git client
135 # is fetching/cloning from us).
136 # Leave undef to use the default Git user agent string
137 our $git_server_ua = undef;
141 ## -------------
142 ## Feature knobs
143 ## -------------
146 # Enable mirroring mode if true (see "Foreign VCS mirrors" section below)
147 our $mirror = 1;
149 # Enable push mode if true
150 our $push = 1;
152 # If both $mirror and $push are enabled, setting this to 'mirror' pre-selects
153 # mirror mode on the initial regproj display, otherwise 'push' mode will be
154 # pre-selected. When forking the initial mode will be 'push' if $push enabled.
155 our $initial_regproj_mode = 'mirror';
157 # Enable user management if true; this means the interface for registering
158 # user accounts and uploading SSH keys. This implies full chroot.
159 our $manage_users = 1;
161 # Minimum key length (in bits) for uploaded SSH RSA/DSA keys.
162 # If this is not set (i.e. undef) keys as small as 512 bits will be allowed.
163 # Nowadays keys less than 2048 bits in length should probably not be allowed.
164 # Note, however, that versions of OpenSSH starting with 4.3p1 will only generate
165 # DSA keys of exactly 1024 bits in length even though that length is no longer
166 # recommended. (OpenSSL can be used to generate DSA keys with lengths > 1024.)
167 # OpenSSH does not have any problem generating RSA keys longer than 1024 bits.
168 # This setting is only checked when new keys are added so setting it/increasing it
169 # will not affect existing keys. For maximum compatibility a value of 1024 may
170 # be used however 2048 is recommended. Setting it to anything other than 1024,
171 # 2048 or 3072 may have the side effect of making it very difficult to generate
172 # DSA keys that satisfy the restriction (but RSA keys should not be a problem).
173 # Note that no matter what setting is specified here keys smaller than 512 bits
174 # will never be allowed via the reguser.cgi/edituser.cgi interface.
175 # RECOMMENDED VALUE: 2048 (ok) or 3072 (better)
176 our $min_key_length = 3072;
178 # Disable DSA public keys?
179 # If this is set to 1, adding DSA keys at reguser.cgi/edituser.cgi time will be
180 # prohibited. If $pushurl is undef then this is implicitly set to 1 since DSA
181 # keys are not usable with https push.
182 # OpenSSH will only generate 1024 bit DSA keys starting with version 4.3p1.
183 # Even if OpenSSL is used to generate a longer DSA key (which can then be used
184 # with OpenSSH), the SSH protocol itself still forces use of SHA-1 in the DSA
185 # signature blob which tends to defeat the purpose of going to a longer key in
186 # the first place. So it may be better from a security standpoint to simply
187 # disable DSA keys especially if $min_key_length and $rsakeylength have been set
188 # to something higher such as 3072 or 4096. This setting is only checked when
189 # new keys are added so setting it/increasing it will not affect existing keys.
190 # There is no way to disable DSA keys in the OpenSSH server config file itself.
191 # If this is set to 1, no ssh_host_dsa_key will be generated or used with the
192 # sshd running in the jail (but if the sshd_config has already been generated
193 # in the jail, it must be removed and 'sudo make install' run again or otherwise
194 # the sshd_config needs to be edited by hand for the change to take effect).
195 # RECOMMENDED VALUE: 1
196 our $disable_dsa = 1;
198 # Enable the special 'mob' user if set to 'mob'
199 our $mob = "mob";
201 # Let users set admin passwords; if false, all password inputs are assumed empty.
202 # This will make new projects use empty passwords and all operations on them
203 # unrestricted, but you will be able to do no operations on previously created
204 # projects you have set a password on.
205 our $project_passwords = 1;
207 # How to determine project owner; 'email' adds a form item asking for their
208 # email contact, 'source' takes realname of owner of source repository if it
209 # is a local path (and empty string otherwise). 'source' is suitable in case
210 # the site operates only as mirror of purely local-filesystem repositories.
211 our $project_owners = 'email';
213 # Which project fields to make editable, out of 'shortdesc', 'homepage', 'README',
214 # 'cleanmirror', 'notifymail', 'reverseorder', 'summaryonly', 'notifytag' and 'notifyjson'
215 # 'notifycia' was used by the now defunct CIA service and while allowing it to
216 # be edited does work and the value is saved, the value is totally ignored by Girocco
217 our @project_fields = qw(cleanmirror homepage shortdesc README notifymail reverseorder summaryonly notifytag notifyjson);
219 # Minimal number of seconds to pass between two updates of a project.
220 our $min_mirror_interval = 3600; # 1 hour
222 # Minimal number of seconds to pass between two garbage collections of a project.
223 our $min_gc_interval = 604800; # 1 week
225 # Minimal number of seconds to pass after first failure before sending failure email.
226 # A mirror update failed message will not be sent until mirror updates have been
227 # failing for at least this long. Set to 0 to send a failure message right away
228 # (provided the $min_mirror_failure_message_count coundition has been met).
229 our $min_mirror_failure_message_interval = 216000; # 2.5 days
231 # Minimal number of consecutive failures required before sending failure email.
232 # A mirror update failed message will not be sent until mirror updates have failed
233 # for this many consecutive updates. Set to 0 to send a failure message right away
234 # (provided the $min_mirror_failure_message_interval coundition has been met).
235 our $min_mirror_failure_message_count = 3;
237 # Maximum window memory size when repacking. If this is set, it will be used
238 # instead of the automatically computed value if it's less than that value.
239 # May use a 'k', 'm', or 'g' suffix otherwise value is in bytes.
240 our $max_gc_window_memory_size = undef;
242 # Maximum big file threshold size when repacking. If this is set, it will be
243 # used instead of the automatically computed value if it's less than that value.
244 # May use a 'k', 'm', or 'g' suffix otherwise value is in bytes.
245 our $max_gc_big_file_threshold_size = undef;
247 # Whether or not to run the ../bin/update-pwd-db script whenever the etc/passwd
248 # database is changed. This is typically needed (i.e. set to a true value) for
249 # FreeBSD style systems when using an sshd chroot jail for push access. So if
250 # $pushurl is undef or the system Girocco is running on is not like FreeBSD
251 # (e.g. a master.passwd file that must be transformed into pwd.db and spwd.db), then
252 # this setting should normally be left false (i.e. 0). See comments in the
253 # provided ../bin/update-pwd-db script about when and how it's invoked.
254 our $update_pwd_db = 0;
256 # Port the sshd running in the jail should listen on
257 # Be sure to update $pushurl to match
258 # Not used if $pushurl is undef
259 our $sshd_jail_port = 22;
261 # If this is true then host names used in mirror source URLs will be checked
262 # and any that are not DNS names (i.e. IPv4 or IPv6) or match one of the DNS
263 # host names in any of the URL settings below will be rejected.
264 our $restrict_mirror_hosts = 1;
266 # If $restrict_mirror_hosts is enabled this is the minimum number of labels
267 # required in a valid dns name. Normally 2 is the correct value, but if
268 # Girocco is being used internally where a common default or search domain
269 # is set for everyone then this should be changed to 1 to allow a dns name
270 # with a single label in it. No matter what is set here at least 1 label
271 # is always required when $restrict_mirror_hosts is enabled.
272 our $min_dns_labels = 2;
274 # If $xmllint_readme is true then the contents of the README.html section
275 # will be passed through xmllint and any errors must be corrected before
276 # it can be saved. If this is set to true then xmllint must be in the $PATH.
277 # RECOMMENDED VALUE: 1
278 our $xmllint_readme = 0;
282 ## -------------------
283 ## Foreign VCS mirrors
284 ## -------------------
287 # Note that if any of these settings are changed from true to false, then
288 # any pre-existing mirrors using the now-disabled foreign VCS will stop
289 # updating, new mirrors using the now-disabled foreign VCS will be disallowed
290 # and attempts to update ANY project settings for a pre-existing project that
291 # uses a now-disabled foreign VCS source URL will also be disallowed.
293 # If $mirror is true and $mirror_svn is true then mirrors from svn source
294 # repositories will be allowed (and be converted to Git). These URLs have
295 # the form svn://... or svn+http://... or svn+https://...
296 # Note that for this to work the "svn" command line command must be available
297 # in PATH and the "git svn" commands must work (which generally requires both
298 # Perl and the subversion perl bindings be installed).
299 our $mirror_svn = 1;
301 # Prior to Git v1.5.1, git-svn always used a log window size of 1000.
302 # Starting with Git v1.5.1, git-svn defaults to using a log window size of 100
303 # and provides a --log-window-size= option to change it. Starting with Git
304 # v2.2.0, git-svn disconnects and reconnects to the server every log window size
305 # interval to attempt to reduce memory use by git-svn. If $svn_log_window_size
306 # is undefined, Girocco will use a log window size of 250 (instead of the
307 # the default 100). If $svn_log_window_size is set, Girocco will use that
308 # value instead. Beware that setting it too low (i.e. < 50) will almost
309 # certainly cause performance issues if not failures. Unless there are concerns
310 # about git-svn memory use on a server with extremely limited memory, the
311 # value of 250 that Girocco uses by default should be fine. Obviously if
312 # $mirror or $mirror_svn is false this setting is irrelevant.
313 our $svn_log_window_size = undef;
315 # If $mirror is true and $mirror_darcs is true then mirrors from darcs source
316 # repositories will be allowed (and be converted to Git). These URLs have
317 # the form darcs://...
318 # Note that for this to work the "darcs" command line command must be available
319 # in PATH and so must python (required to run the darcs-fast-export script).
320 our $mirror_darcs = 1;
322 # If $mirror is true and $mirror_bzr is true then mirrors from bzr source
323 # repositories will be allowed (and be converted to Git). These URLs have
324 # the form bzr://...
325 # Note that for this to work the "bzr" command line command must be available
326 # in PATH (it's a python script so python is required as well).
327 our $mirror_bzr = 1;
329 # If $mirror is true and $mirror_hg is true then mirrors from hg source
330 # repositories will be allowed (and be converted to Git). These URLs have
331 # the form hg+http://... or hg+https://...
332 # Note that for this to work the "hg" command line command must be available
333 # in PATH and so must python (required to run the hg-fast-export.py script).
334 # Note that if the PYTHON environment variable is set that will be used instead
335 # of just plain "python" to run the hg-fast-export.py script (which needs to
336 # be able to import from mercurial).
337 our $mirror_hg = 1;
341 ## -----
342 ## Paths
343 ## -----
346 # Path where the main chunk of Girocco files will be installed
347 # This will get COMPLETELY OVERWRITTEN by each make install!!!
348 our $basedir = '/home/repo/repomgr';
350 # Path where the automatically generated non-user certificates will be stored
351 # (The per-user certificates are always stored in $chroot/etc/sshcerts/)
352 # This is preserved by each make install and MUST NOT be under $basedir!
353 # Not used unless $httpspushurl is defined
354 our $certsdir = '/home/repo/certs';
356 # The repository collection
357 # "$reporoot/_recyclebin" will also be created for use by toolbox/trash-project.pl
358 our $reporoot = "/srv/git";
360 # The repository collection's location within the chroot jail
361 # Normally $reporoot will be bind mounted onto $chroot/$jailreporoot
362 # Should NOT start with '/'
363 our $jailreporoot = "srv/git";
365 # The chroot for ssh pushing; location for project database and other run-time
366 # data even in non-chroot setups
367 our $chroot = "/home/repo/j";
369 # The gitweb files web directory (corresponds to $gitwebfiles)
370 # Note that it is safe to place this under $basedir since it's set up after
371 # $basedir is completely replaced during install time. Be WARNED, however,
372 # that normally the install process only adds/replaces things in $webroot,
373 # but if $webroot is under $basedir then it will be completely removed and
374 # rebuilt each time "make install" is run. This will make gitweb/git-browser
375 # web services very briefly unavailable while this is happening.
376 our $webroot = "/home/repo/www";
378 # The CGI-enabled web directory (corresponds to $gitweburl and $webadmurl)
379 # This will not be web-accessible except that if any aliases point to
380 # a *.cgi file in here it will be allowed to run as a cgi-script.
381 # Note that it is safe to place this under $basedir since it's set up after
382 # $basedir is completely replaced during install time. Be WARNED, however,
383 # that normally the install process only adds/replaces things in $cgiroot,
384 # but if $cgiroot is under $basedir then it will be completely removed and
385 # rebuilt each time "make install" is run. This will make gitweb/git-browser
386 # web services very briefly unavailable while this is happening.
387 our $cgiroot = "/home/repo/cgibin";
389 # A web-accessible symlink to $reporoot (corresponds to $httppullurl, can be undef)
390 # If using the sample apache.conf (with paths suitably updated) this is not required
391 # to serve either smart or non-smart HTTP repositories to the Git client
392 our $webreporoot = "/home/repo/www/r";
394 # The location to store the project list cache, gitweb project list and gitweb
395 # cache file. Normally this should not be changed. Note that it must be in
396 # a directory that is writable by $mirror_user and $cgi_user (just in case the
397 # cache file is missing). The directory should have its group set to $owning_group.
398 # Again, this setting should not normally need to be changed.
399 our $projlist_cache_dir = "$chroot/etc";
403 ## ----------------------------------------------------
404 ## Certificates (only used if $httpspushurl is defined)
405 ## ----------------------------------------------------
408 # path to root certificate (undef to use automatic root cert)
409 # this certificate is made available for easy download and should be whatever
410 # the root certificate is for the https certificate being used by the web server
411 our $rootcert = undef;
413 # The certificate to sign user push client authentication certificates with (undef for auto)
414 # The automatically generated certificate should always be fine
415 our $clientcert = undef;
417 # The private key for $clientcert (undef for auto)
418 # The automatically generated key should always be fine
419 our $clientkey = undef;
421 # The client certificate chain suffix (a pemseq file to append to user client certs) (undef for auto)
422 # The automatically generated chain should always be fine
423 # This suffix will also be appended to the $mobusercert before making it available for download
424 our $clientcertsuffix = undef;
426 # The mob user certificate signed by $clientcert (undef for auto)
427 # The automatically generated certificate should always be fine
428 # Not used unless $mob is set to 'mob'
429 # The $clientcertsuffix will be appended before making $mobusercert available for download
430 our $mobusercert = undef;
432 # The private key for $mobusercert (undef for auto)
433 # The automatically generated key should always be fine
434 # Not used unless $mob is set to 'mob'
435 our $mobuserkey = undef;
437 # Server alt names to embed in the auto-generated girocco_www_crt.pem certificate.
438 # The common name (CN) in the server certificate is the host name from $httpspushurl.
439 # By default no server alt names are embedded (not even the host from $httpspushurl).
440 # If the web server configuration is not using this auto-generated server certificate
441 # then the values set here will have no impact and this setting can be ignored.
442 # To embed server alternative names, list each (separated by spaces). The names
443 # may be DNS names, IPv4 addresses or IPv6 addresses (NO surrounding '[' ']' please).
444 # If ANY DNS names are included here be sure to also include the host name from
445 # the $httpspushurl or else standards-conforming clients will fail with a host name
446 # mismatch error when they attempt to verify the connection.
447 #our $wwwcertaltnames = 'example.com www.example.com git.example.com 127.0.0.1 ::1';
448 our $wwwcertaltnames = undef;
450 # The key length for automatically generated RSA private keys (in bits).
451 # These keys are then used to create the automatically generated certificates.
452 # If undef or set to a value less than 2048, then 2048 will be used.
453 # Set to 3072 to generate more secure keys/certificates. Set to 4096 (or higher) for
454 # even greater security. Be warned that setting to a non-multiple of 8 and/or greater
455 # than 4096 could negatively impact compatibility with some clients.
456 # The values 2048, 3072 and 4096 are expected to be compatible with all clients.
457 # Note that OpenSSL has no problem with > 4096 or non-multiple of 8 lengths.
458 # See also the $min_key_length setting above to restrict user key sizes.
459 # This value is also used when generating the ssh_host_rsa_key for the chroot jail sshd.
460 # RECOMMENDED VALUE: 3072
461 our $rsakeylength = 3072;
465 ## -------------
466 ## URL addresses
467 ## -------------
470 # URL of the gitweb.cgi script (must be in pathinfo mode). If the sample
471 # apache.conf configuration is used, the trailing "/w" is optional.
472 our $gitweburl = "http://repo.or.cz/w";
474 # URL of the extra gitweb files (CSS, .js files, images, ...)
475 our $gitwebfiles = "http://repo.or.cz";
477 # URL of the Girocco CGI web admin interface (Girocco cgi/ subdirectory)
478 # e.g. reguser.cgi, edituser.cgi, regproj.cgi, editproj.cgi etc.
479 our $webadmurl = "http://repo.or.cz";
481 # URL of the Girocco CGI bundles information generator (Girocco cgi/bundles.cgi)
482 # If the sample apache.conf configuration is used, the trailing "/b" is optional.
483 # This is different from $httpbundleurl. This URL lists all available bundles
484 # for a project and returns that as an HTML page.
485 our $bundlesurl = "http://repo.or.cz/b";
487 # URL of the Girocco CGI html templater (Girocco cgi/html.cgi)
488 # If mod_rewrite is enabled and the sample apache.conf configuration is used,
489 # the trailing "/h" is optional when the template file name ends in ".html"
490 # (which all the provided ones do).
491 our $htmlurl = "http://repo.or.cz/h";
493 # HTTP URL of the repository collection (undef if N/A)
494 # If the sample apache.conf configuration is used, the trailing "/r" is optional.
495 our $httppullurl = "http://repo.or.cz/r";
497 # HTTP URL of the repository collection when fetching a bundle (undef if N/A)
498 # Normally this will be the same as $httppullurl, but note that the bundle
499 # fetching logic is located in git-http-backend-verify so whatever URL is
500 # given here MUST end up running the git-http-backend-verify script!
501 # For example, if we're fetching the 'clone.bundle' for the 'girocco.git'
502 # repository, the final URL will be "$httpbundleurl/girocco.git/clone.bundle"
503 # If the sample apache.conf configuration is used, the trailing "/r" is optional.
504 # This is different from $bundlesurl. This URL fetches a single Git-format
505 # .bundle file that is only usable with the 'git bundle' command.
506 our $httpbundleurl = "http://repo.or.cz/r";
508 # HTTPS push URL of the repository collection (undef if N/A)
509 # If this is defined, the openssl command must be available
510 # The sample apache.conf configuration requires mod_ssl, mod_authn_anon and
511 # mod_rewrite be enabled to support https push operations.
512 # Normally this should be set to $httppullurl with http: replaced with https:
513 # If the sample apache.conf configuration is used, the trailing "/r" is optional.
514 our $httpspushurl = undef;
516 # Git URL of the repository collection (undef if N/A)
517 # (You need to set up git-daemon on your system, and Girocco will not
518 # do this particular thing for you.)
519 our $gitpullurl = "git://repo.or.cz";
521 # Pushy SSH URL of the repository collection (undef if N/A)
522 # Note that the "/$jailreporoot" portion is optional and will be automatically
523 # added if appropriate when omitted by the client so this URL can typically
524 # be made the same as $gitpullurl with git: replaced with ssh:
525 our $pushurl = "ssh://repo.or.cz/$jailreporoot";
527 # URL of gitweb of this Girocco instance (set to undef if you're not nice
528 # to the community)
529 our $giroccourl = "$Girocco::Config::gitweburl/girocco.git";
533 ## -------------------
534 ## web server controls
535 ## -------------------
538 # If true then non-smart HTTP access will be disabled
539 # There's normally no reason to leave non-smart HTTP access enabled
540 # since downloadable bundles are provided. However, in case the
541 # non-smart HTTP access is needed for some reason, this can be set to undef or 0.
542 # This affects access via http: AND https: and processing of apache.conf.in.
543 # Note that this setting does not affect gitweb, ssh: or git: URL access in any way.
544 # RECOMMENDED VALUE: 1
545 our $SmartHTTPOnly = 1;
547 # If true, the https <VirtualHost ...> section in apache.conf.in will be
548 # automatically enabled when it's converted to apache.conf by the conversion
549 # script. Do NOT enable this unless the required Apache modules are present
550 # and loaded (mod_ssl, mod_rewrite, mod_authn_anon) AND $httpspushurl is
551 # defined above otherwise the server will fail to start (with various errors)
552 # when the resulting apache.conf is used.
553 our $TLSHost = 0;
557 ## ------------------------
558 ## Some templating settings
559 ## ------------------------
562 # Legal warning (on reguser and regproj pages)
563 our $legalese = <<EOT;
564 <p>By submitting this form, you are confirming that you will mirror or push
565 only what we can store and show to anyone else who can visit this site without
566 breaking any law, and that you will be nice to all small furry animals.
567 <sup><a href="/h/about.html">(more details)</a></sup>
568 </p>
571 # Pre-configured mirror sources (set to undef for none)
572 # Arrayref of name - record pairs, the record has these attributes:
573 # label: The label of this source
574 # url: The template URL; %1, %2, ... will be substituted for inputs
575 # desc: Optional VERY short description
576 # link: Optional URL to make the desc point at
577 # inputs: Arrayref of hashref input records:
578 # label: Label of input record
579 # suffix: Optional suffix
580 # If the inputs arrayref is undef, single URL input is shown,
581 # pre-filled with url (probably empty string).
582 our $mirror_sources = [
584 label => 'Anywhere',
585 url => '',
586 desc => 'Any HTTP/Git/rsync pull URL - bring it on!',
587 inputs => undef
590 label => 'GitHub',
591 url => 'https://github.com/%1/%2.git',
592 desc => 'GitHub Social Code Hosting',
593 link => 'http://github.com/',
594 inputs => [ { label => 'User:' }, { label => 'Project:', suffix => '.git' } ]
597 label => 'GitLab',
598 url => 'https://gitlab.com/%1/%2.git',
599 desc => 'Engulfed the Green and Orange Boxes',
600 link => 'https://gitlab.com/',
601 inputs => [ { label => 'Project:' }, { label => 'Repository:', suffix => '.git' } ]
605 # You can customize the gitweb interface widely by editing
606 # gitweb/gitweb_config.perl
610 ## -------------------
611 ## Permission settings
612 ## -------------------
615 # Girocco needs some way to manipulate write permissions to various parts of
616 # all repositories; this concerns three entities:
617 # - www-data: the web interface needs to be able to rewrite few files within
618 # the repository
619 # - repo: a user designated for cronjobs; handles mirroring and repacking;
620 # this one is optional if not $mirror
621 # - others: the designated users that are supposed to be able to push; they
622 # may have account either within chroot, or outside of it
624 # There are several ways how to use Girocco based on a combination of the
625 # following settings.
627 # (Non-chroot) UNIX user the CGI scripts run on; note that if some non-related
628 # untrusted CGI scripts run on this account too, that can be a big security
629 # problem and you'll probably need to set up suexec (poor you).
630 # This must always be set.
631 our $cgi_user = 'www-data';
633 # (Non-chroot) UNIX user performing mirroring jobs; this is the user who
634 # should run all the daemons and cronjobs and
635 # the user who should be running make install (if not root).
636 # This must always be set.
637 our $mirror_user = 'repo';
639 # (Non-chroot) UNIX group owning the repositories by default; it owns whole
640 # mirror repositories and at least web-writable metadata of push repositories.
641 # If you undefine this, all the data will become WORLD-WRITABLE.
642 # Both $cgi_user and $mirror_user should be members of this group!
643 our $owning_group = 'repo';
645 # Whether to use chroot jail for pushing; this must be always the same
646 # as $manage_users.
647 # TODO: Gitosis support for $manage_users and not $chrooted?
648 our $chrooted = $manage_users;
650 # How to control permissions of push-writable data in push repositories:
651 # * 'Group' for the traditional model: The $chroot/etc/group project database
652 # file is used as the UNIX group(5) file; the directories have gid appropriate
653 # for the particular repository and are group-writable. This works only if
654 # $chrooted so that users are put in the proper groups on login when using
655 # SSH push. Smart HTTPS push does not require a chroot to work -- simply
656 # run "make install" as the non-root $mirror_user user, but leave
657 # $manage_users and $chrooted enabled.
658 # * 'ACL' for a model based on POSIX ACL: The directories are coupled with ACLs
659 # listing the users with push permissions. This works for both chroot and
660 # non-chroot setups, however it requires ACL support within the filesystem.
661 # This option is BASICALLY UNTESTED, too. And UNIMPLEMENTED. :-)
662 # * 'Hooks' for a relaxed model: The directories are world-writable and push
663 # permission control is purely hook-driven. This is INSECURE and works only
664 # when you trust all your users; on the other hand, the attack vectors are
665 # mostly just DoS or fully-traceable tinkering.
666 our $permission_control = 'Group';
668 # Path to alternate screen multiuser acl file (see screen/README, undef for none)
669 our $screen_acl_file = undef;
671 # Reserved project name and user name suffixes.
673 # Note that with personal mob branches enabled, a user name can end up being a
674 # file name after having a 'mob.' prefix added or a directory name after having
675 # a 'mob_' prefix added. If there is ANY possibility that a file with a
676 # .suffix name may need to be served by the web server, lc(suffix) SHOULD be in
677 # this hash! Pre-existing project names or user names with a suffix in this
678 # table can continue to be used, but no new projects or users can be created
679 # that have a suffix (case-insensitive) listed here.
680 our %reserved_suffixes = (
681 # Entries must be lowercase WITHOUT a leading '.'
682 bmp => 1,
683 bz2 => 1,
684 cgi => 1,
685 css => 1,
686 dmg => 1,
687 fcgi => 1,
688 gif => 1,
689 gz => 1,
690 htm => 1,
691 html => 1,
692 ico => 1,
693 jp2 => 1,
694 jpeg => 1,
695 jpg => 1,
696 jpg2 => 1,
697 js => 1,
698 pdf => 1,
699 pem => 1,
700 php => 1,
701 png => 1,
702 shtml => 1,
703 svg => 1,
704 svgz => 1,
705 tar => 1,
706 text => 1,
707 tgz => 1,
708 tif => 1,
709 tiff => 1,
710 txt => 1,
711 xbm => 1,
712 xht => 1,
713 xhtml => 1,
714 xz => 1,
715 zip => 1,
720 ## -------------------------
721 ## sendmail.pl configuration
722 ## -------------------------
725 # Full information on available sendmail.pl settings can be found by running
726 # ../bin/sendmail.pl -v -h
728 # These settings will only used if $sendmail_bin is set to 'sendmail.pl'
730 # sendmail.pl host name
731 #$ENV{'SENDMAIL_PL_HOST'} = 'localhost'; # localhost is the default
733 # sendmail.pl port name
734 #$ENV{'SENDMAIL_PL_PORT'} = '25'; # port 25 is the default
736 # sendmail.pl nc executable
737 #$ENV{'SENDMAIL_PL_NCBIN'} = "$chroot/bin/nc.openbsd"; # default is nc found in $PATH
739 # sendmail.pl nc options
740 # multiple options may be included, e.g. '-4 -X connect -x 192.168.100.10:8080'
741 #$ENV{'SENDMAIL_PL_NCOPT'} = '-4'; # force IPv4, default is to allow IPv4 & IPv6
745 ## -------------------------
746 ## Obscure Tuneable Features
747 ## -------------------------
750 # Throttle classes configured here override the defaults for them that
751 # are located in taskd/taskd.pl. See comments in that file for more info.
752 our @throttle_classes = ();
754 # Any tag names listed here will be allowed even if they would otherwise not be.
755 # Note that @allowed_tags takes precedence over @blocked_tags.
756 our @allowed_tags = ();
758 # Any tag names listed here will be disallowed in addition to the standard
759 # list of nonsense words etc. that are blocked as tags.
760 our @blocked_tags = ();
762 # If there are no more than this many objects, then all deltas will be
763 # recomputed when gc takes place. Note that this does not affect any
764 # fast-import created packs as they ALWAYS have their deltas recomputed.
765 # Also when combining small packs, if the total object count in the packs
766 # to be combined is no more than this then the new, combined pack will have
767 # its deltas recomputed during the combine operation.
768 # Leave undef to use the default (which should generally be fine).
769 # Lowering this from the default can increase disk use.
770 # Values less than 1000 * number of CPU cores will be silently ignored.
771 # The "girocco.redelta" config item can be used to modify this behavior on
772 # a per-repository basis. See the description of it in gc.sh.
773 our $new_delta_threshold = undef;
775 # This setting is irrelevant unless foreign vcs mirrors that use git fast-import
776 # are enabled (e.g. $mirror_darcs, $mirror_bzr or $mirror_hg -- $mirror_svn does
777 # NOT use git fast-import and is not affected by this setting).
778 # The packs generated by git fast-import are very poor quality. For this reason
779 # they ALWAYS have their deltas recomputed at some point. Normally this is
780 # delayed until the next full (or mini) gc takes place. For this reason a full
781 # gc is always scheduled immediately after a fresh mirror clone completes.
782 # However, in the case of normal mirror updates, several git fast-import created
783 # packs may exist as a result of changes fetched during the normal mirror update
784 # process. These packs will persist (with their git fast-import poor quality)
785 # until the next full (or mini) gc triggers. The bad deltas in these update
786 # packs could be sent down to clients who fetch updates before the next gc
787 # triggers. To reduce (i.e. practically eliminate) the likelihood of this
788 # occurring, this setting can be changed to a false (0 or undef) value in which
789 # case after each mirror update of a git fast-import mirror, any newly created
790 # git fast-import packs (as a result of the mirror update running) will have
791 # their deltas recomputed shortly thereafter instead of waiting for the next gc.
792 # Recomputing deltas immediately (almost immediately) will result in an extra
793 # redeltification step (with associated CPU cost) that would otherwise not
794 # occur and, in some cases (mainly large repositories), could ultimately result
795 # in slightly less efficient deltas being retained.
796 # RECOMMENDED VALUE: 1
797 our $delay_gfi_redelta = 1;
799 # If this is set to a true value, then core.packedGitWindowSize will be set
800 # to 1 MiB (the same as if Git was compiled with NO_MMAP set). If this is NOT
801 # set, core.packedGitWindowSize will be set to 32 MiB (even on 64-bit) to avoid
802 # memory blowout. If your Git was built with NO_MMAP set and will not work
803 # without NO_MMAP set, you MUST set this to a true value!
804 our $git_no_mmap = undef;
806 # If set to a true value, the "X-Girocco: $gitweburl" header included in all
807 # Girocco-generated emails will be suppressed.
808 our $suppress_x_girocco = undef;
810 # Number of days to keep reflogs around
811 # May be set to a value between 1 and 30 (inclusive)
812 # The default of one day should normally suffice unless there's a need to
813 # support a "Where's the undo? WHERE IS THE UNDO?!!!" option ;)
814 our $reflogs_lifetime = 1;
818 ## ------------------------
819 ## Sanity checks & defaults
820 ## ------------------------
822 # Changing anything in this section can result in unexpected breakage
824 # Couple of sanity checks and default settings (do not change these)
825 use Digest::MD5 qw(md5);
826 use MIME::Base64 qw(encode_base64);
827 $name =~ s/\s+/_/gs;
828 $nickname = lc((split(/[.]/, $name))[0]) unless $nickname;
829 $nickname =~ s/\s+/_/gs;
830 our $tmpsuffix = substr(encode_base64(md5($name.':'.$nickname)),0,6);
831 $tmpsuffix =~ tr,+/,=_,;
832 ($mirror_user) or die "Girocco::Config: \$mirror_user must be set even if to current user";
833 ($basedir) or die "Girocco::Config: \$basedir must be set";
834 ($sendmail_bin) or die "Girocco::Config: \$sendmail_bin must be set";
835 $sendmail_bin = "$basedir/bin/sendmail.pl" if $sendmail_bin eq "sendmail.pl";
836 $screen_acl_file = "$basedir/screen/giroccoacl" unless $screen_acl_file;
837 $jailreporoot =~ s,^/+,,;
838 ($reporoot) or die "Girocco::Config \$reporoot must be set";
839 ($jailreporoot) or die "Girocco::Config \$jailreporoot must be set";
840 (not $mob or $mob eq 'mob') or die "Girocco::Config \$mob must be undef (or '') or 'mob'";
841 (not $min_key_length or $min_key_length =~ /^[1-9][0-9]*$/)
842 or die "Girocco::Config \$min_key_length must be undef or numeric";
843 $admincc = $admincc ? 1 : 0;
844 $rootcert = "$certsdir/girocco_root_crt.pem" if $httpspushurl && !$rootcert;
845 $clientcert = "$certsdir/girocco_client_crt.pem" if $httpspushurl && !$clientcert;
846 $clientkey = "$certsdir/girocco_client_key.pem" if $httpspushurl && !$clientkey;
847 $clientcertsuffix = "$certsdir/girocco_client_suffix.pem" if $httpspushurl && !$clientcertsuffix;
848 $mobusercert = "$certsdir/girocco_mob_user_crt.pem" if $httpspushurl && $mob && !$mobusercert;
849 $mobuserkey = "$certsdir/girocco_mob_user_key.pem" if $httpspushurl && $mob && !$mobuserkey;
850 our $mobpushurl = $pushurl;
851 $mobpushurl =~ s,^ssh://,ssh://mob@,i if $mobpushurl;
852 $disable_dsa = 1 unless $pushurl;
853 $disable_dsa = $disable_dsa ? 1 : '';
854 our $httpdnsname = ($gitweburl =~ m,https?://([A-Za-z0-9.-]+),i) ? lc($1) : undef if $gitweburl;
855 our $httpsdnsname = ($httpspushurl =~ m,https://([A-Za-z0-9.-]+),i) ? lc($1) : undef if $httpspushurl;
856 ($mirror or $push) or die "Girocco::Config: neither \$mirror nor \$push is set?!";
857 (not $push or ($pushurl or $httpspushurl or $gitpullurl or $httppullurl)) or die "Girocco::Config: no pull URL is set";
858 (not $push or ($pushurl or $httpspushurl)) or die "Girocco::Config: \$push set but \$pushurl and \$httpspushurl are undef";
859 (not $mirror or $mirror_user) or die "Girocco::Config: \$mirror set but \$mirror_user is undef";
860 ($manage_users == $chrooted) or die "Girocco::Config: \$manage_users and \$chrooted must be set to the same value";
861 (not $chrooted or $permission_control ne 'ACL') or die "Girocco::Config: resolving uids for ACL not supported when using chroot";
862 (grep { $permission_control eq $_ } qw(Group Hooks)) or die "Girocco::Config: \$permission_control must be set to Group or Hooks";
863 ($chrooted or not $mob) or die "Girocco::Config: mob user supported only in the chrooted mode";
864 (not $httpspushurl or $httpsdnsname) or die "Girocco::Config invalid \$httpspushurl does not start with https://domainname";
865 (not $svn_log_window_size or $svn_log_window_size =~ /^[1-9][0-9]*$/)
866 or die "Girocco::Config \$svn_log_window_size must be undef or numeric";
867 (not $posix_sh_bin or $posix_sh_bin !~ /\s/) or die "Girocco::Config: \$posix_sh_bin must not contain any whitespace";
868 (not $perl_bin or $perl_bin !~ /\s/) or die "Girocco::Config: \$perl_bin must not contain any whitespace";
869 !$delay_gfi_redelta and $delay_gfi_redelta = undef;
870 !$git_no_mmap and $git_no_mmap = undef;
871 !$suppress_x_girocco and $suppress_x_girocco = undef;
872 (not $reflogs_lifetime or $reflogs_lifetime !~ /^[1-9][0-9]*$/) and $reflogs_lifetime = 1;
873 $reflogs_lifetime = 0 + $reflogs_lifetime;
874 $reflogs_lifetime >= 0 or $reflogs_lifetime = 1;
875 $reflogs_lifetime <= 30 or $reflogs_lifetime = 30;
877 # Make sure Git has a consistent and reproducible environment
879 $ENV{'XDG_CONFIG_HOME'} = $chroot.'/var/empty';
880 $ENV{'HOME'} = $chroot.'/etc/girocco';
881 $ENV{'TMPDIR'} = '/tmp';
882 $ENV{'GIT_CONFIG_NOSYSTEM'} = 1;
883 $ENV{'GIT_ATTR_NOSYSTEM'} = 1;
884 $ENV{'GIT_NO_REPLACE_OBJECTS'} = 1;
885 $ENV{'GIT_TERMINAL_PROMPT'} = 0;
886 $ENV{'GIT_ASKPASS'} = $basedir.'/bin/git-askpass-password';
887 delete $ENV{'GIT_USER_AGENT'};
888 $ENV{'GIT_USER_AGENT'} = $git_client_ua if defined($git_client_ua);
889 delete $ENV{'GIT_HTTP_USER_AGENT'};
890 $ENV{'GIT_HTTP_USER_AGENT'} = $git_client_ua if defined($git_client_ua);
891 delete $ENV{'GIT_CONFIG_PARAMETERS'};
892 delete $ENV{'GIT_ALTERNATE_OBJECT_DIRECTORIES'};
893 delete $ENV{'GIT_CONFIG'};
894 delete $ENV{'GIT_DIR'};
895 delete $ENV{'GIT_GRAFT_FILE'};
896 delete $ENV{'GIT_INDEX_FILE'};
897 delete $ENV{'GIT_OBJECT_DIRECTORY'};
898 delete $ENV{'GIT_NAMESPACE'};
900 # Guarantee a sane umask for Girocco
902 umask(umask() & ~0770);