Girocco::Config::project_owners: Introduce configuration variable
[girocco.git] / Girocco / Config.pm
blob549c4e0d2b869d87cbf431410bb9cd3e55443717
1 package Girocco::Config;
3 use strict;
4 use warnings;
7 ## Basic settings
9 # Name of the service
10 our $name = "repo.or.cz";
12 # Title of the service (as shown in gitweb)
13 our $title = "Public Git Hosting";
15 # Path to the Git binary to use (you MUST set this, even if to /usr/bin/git!)
16 our $git_bin = '/home/pasky/bin/git';
18 # E-mail of the site admin
19 our $admin = 'pasky@suse.cz';
22 ## Feature knobs
24 # Enable mirroring mode if true
25 our $mirror = 1;
27 # Enable push mode if true
28 our $push = 1;
30 # Enable user management if true
31 our $manage_users = 1;
33 # Enable the special 'mob' user if set to 'mob'
34 our $mob = "mob";
36 # Let users set admin passwords; if false, all password inputs are assumed empty.
37 # This will make new projects use empty passwords and all operations on them
38 # unrestricted, but you will be able to do no operations on previously created
39 # projects you have set a password on.
40 our $project_passwords = 1;
42 # How to determine project owner; 'email' adds a form item asking for their
43 # email contact, 'source' takes realname of owner of source repository if it
44 # is a local path (and empty string otherwise).
45 our $project_owners = 'email';
48 ## Paths
50 # Path to the Girocco files (checkout of this project)
51 # This will get COMPLETELY OVERWRITTEN by each make install!
52 our $basedir = '/home/repo/repomgr';
54 # The repository collection
55 our $reporoot = "/srv/git";
57 # The chroot for ssh pushing; location for project database even in non-chroot
58 # setups
59 our $chroot = "/home/repo/j";
61 # The gitweb files web directory (corresponds to $gitwebfiles)
62 our $webroot = "/home/pasky/WWW/repo";
64 # The CGI-enabled web directory (corresponds to $gitweburl and $webadmurl)
65 our $cgiroot = "/home/pasky/WWW/repo";
67 # A web-accessible symlink to $reporoot (corresponds to $httppullurl, can be undef)
68 our $webreporoot = "/home/pasky/WWW/repo/r";
71 ## URL addresses
73 # URL of the gitweb.cgi script (must be in pathinfo mode)
74 our $gitweburl = "http://repo.or.cz/w";
76 # URL of the extra gitweb files (CSS, .js files, images, ...)
77 our $gitwebfiles = "http://repo.or.cz/";
79 # URL of the Girocco CGI web admin interface (Girocco cgi/ subdirectory)
80 our $webadmurl = "http://repo.or.cz/m";
82 # URL of the Girocco CGI html templater (Girocco cgi/html.cgi)
83 our $htmlurl = "http://repo.or.cz/h";
85 # HTTP URL of the repository collection (undef if N/A)
86 our $httppullurl = "http://repo.or.cz/r";
88 # Git URL of the repository collection (undef if N/A)
89 our $gitpullurl = "git://repo.or.cz/";
91 # Pushy URL of the repository collection (undef if N/A)
92 our $pushurl = "ssh://repo.or.cz/srv/git";
94 # URL of gitweb of this Girocco instance (set to undef if you're not nice
95 # to the community)
96 our $giroccourl = "$Girocco::Config::gitweburl/repo.git";
99 ## Some templating settings
101 # Legal warning (on reguser and regproj pages)
102 our $legalese = <<EOT;
103 <p>By submitting this form, you are confirming that you will mirror or push
104 only free software and redistributing it will not violate any law
105 of Czech Republic.
106 <sup><a href="$Girocco::Config::htmlurl/about.html">(more details)</a></sup>
107 </p>
110 # Pre-configured mirror sources (set to undef for none)
111 # Arrayref of name - record pairs, the record has these attributes:
112 # label: The label of this source
113 # url: The template URL; %1, %2, ... will be substituted for inputs
114 # desc: Optional VERY short description
115 # link: Optional URL to make the desc point at
116 # inputs: Arrayref of hashref input records:
117 # label: Label of input record
118 # suffix: Optional suffix
119 # If the inputs arrayref is undef, single URL input is shown,
120 # pre-filled with url (probably empty string).
121 our $mirror_sources = [
123 label => 'Anywhere',
124 url => '',
125 desc => 'Any HTTP/Git/rsync pull URL - bring it on!',
126 inputs => undef
129 label => 'GitHub',
130 url => 'git://github.com/%1/%2.git',
131 desc => 'GitHub Social Code Hosting',
132 link => 'http://github.com/',
133 inputs => [ { label => 'User:' }, { label => 'Project:', suffix => '.git' } ]
136 label => 'Gitorious',
137 url => 'git://gitorious.org/%1/%2.git',
138 desc => 'Green and Orange Boxes',
139 link => 'http://gitorious.org/',
140 inputs => [ { label => 'Project:' }, { label => 'Repository:', suffix => '.git' } ]
145 ## Permission settings
147 # Note that if you are going to need the fixup root cronjob
148 # ($chrooted and $permission_control eq 'Group'), you need to update
149 # the settings in jobs/fixup.sh as well.
151 # Girocco needs some way to manipulate write permissions to various parts of
152 # all repositories; this concerns three entities:
153 # - www-data: the web interface needs to be able to rewrite few files within
154 # the repository
155 # - repo: a user designated for cronjobs; handles mirroring and repacking;
156 # this one is optional if not $mirror
157 # - others: the designated users that are supposed to be able to push
159 # There are several ways how to use Girocco based on a combination of the
160 # following settings.
162 # (Non-chroot) UNIX user the CGI scripts run on
163 our $cgi_user = 'www-data';
165 # (Non-chroot) UNIX user performing mirroring jobs
166 our $mirror_user = 'repo';
168 # (Non-chroot) UNIX group owning the repositories by default; it owns whole
169 # mirror repositories and at least web-writable metadata of push repositories.
170 # If you undefine this, all the data will become WORLD-WRITABLE.
171 our $owning_group = 'repo';
173 # Whether to use chroot jail for pushing; this must be always the same
174 # as $manage_users.
175 # TODO: Gitosis support for $manage_users and not $chrooted?
176 our $chrooted = $manage_users;
178 # How to control permissions of push-writable data in push repositories:
179 # * 'Group' for the traditional model: The $chroot/etc/group project database
180 # file is used as the UNIX group(5) file; the directories have gid appropriate
181 # for the particular repository and are group-writable. This works only if
182 # $chrooted so that users are put in the proper groups on login. This requires
183 # you also to set up the very crude fixup.sh cronjob for root.
184 # * 'ACL' for a model based on POSIX ACL: The directories are coupled with ACLs
185 # listing the users with push permissions. This works for both chroot and
186 # non-chroot setups, however it requires ACL support within the filesystem.
187 # This option is BASICALLY UNTESTED, too. And UNIMPLEMENTED. :-)
188 # * 'Hooks' for a relaxed model: The directories are world-writable and push
189 # permission control is purely hook-driven. This is INSECURE and works only
190 # when you trust all your users; on the other hand, the attack vectors are
191 # mostly just DoS or fully-traceable tinkering.
192 our $permission_control = 'Group';
195 # Couple of sanity checks
196 ($mirror or $push) or die "Girocco::Config: neither \$mirror or \$push is set?!";
197 (not $push or ($pushurl or $gitpullurl or $httppullurl)) or die "Girocco::Config: no pull URL is set";
198 (not $push or $pushurl) or die "Girocco::Config: \$push set but \$pushurl is undef";
199 (not $mirror or $mirror_user) or die "Girocco::Config: \$mirror set but \$mirror_user is undef";
200 ($manage_users == $chrooted) or die "Girocco::Config: \$manage_users and \$chrooted must be set to the same value";
201 (not $chrooted or $permission_control ne 'ACL') or die "Girocco::Config: resolving uids for ACL not supported when using chroot";
202 (grep { $permission_control eq $_ } qw(Group Hooks)) or die "Girocco::Config: \$permission_control must be set to Group or Hooks";
203 ($chrooted or not $mob) or die "Girocco::Config: mob user supported only in the chrooted mode";