gc: reach out and touch some objects
[girocco.git] / Girocco / Project.pm
blobe4be9e23a790e152dc11d9e0ae34e45849448a0b
1 package Girocco::Project;
3 use strict;
4 use warnings;
6 BEGIN {
7 use Girocco::CGI;
8 use Girocco::User;
9 use Girocco::Util;
10 use Girocco::HashUtil;
11 use Girocco::ProjPerm;
12 use Girocco::Config;
13 use base ('Girocco::ProjPerm::'.$Girocco::Config::permission_control); # mwahaha
16 BEGIN {
17 eval {
18 require Digest::SHA;
19 Digest::SHA->import(
20 qw(sha1_hex)
21 );1} ||
22 eval {
23 require Digest::SHA1;
24 Digest::SHA1->import(
25 qw(sha1_hex)
26 );1} ||
27 eval {
28 require Digest::SHA::PurePerl;
29 Digest::SHA::PurePerl->import(
30 qw(sha1_hex)
31 );1} ||
32 die "One of Digest::SHA or Digest::SHA1 or Digest::SHA::PurePerl "
33 . "must be available\n";
36 our $metadata_fields = {
37 homepage => ['Homepage URL', 'hp', 'text'],
38 shortdesc => ['Short description', 'desc', 'text'],
39 README => ['<span style="display:inline-block;vertical-align:top">'.
40 'README (HTML, &lt; 8 KiB)<br />leave blank for automatic</span>',
41 'README', 'textarea', 'Enter only &#x201c;<!-- comments -->&#x201d; '.
42 'to completely suppress any README'],
43 notifymail => ['Commit notify &#x2013; mail to', 'notifymail', 'text',
44 'comma separated address list'],
45 notifytag => ['Tag notify &#x2013; mail to', 'notifytag', 'text',
46 'comma separated address list &#x2013; if not empty, tag '.
47 'notifications are sent here INSTEAD of to '.
48 '&#x201c;Commit notify &#x2013; mail to&#x201d; address(es)'],
49 notifyjson => ['Commit notify &#x2013; '.
50 '<a title="'.html_esc('single field name is &#x201c;payload&#x201d;', 1).'" href="'.
51 'https://developer.github.com/v3/activity/events/types/#pushevent'.
52 '">POST JSON</a> at', 'notifyjson', 'text'],
53 notifycia => ['Commit notify &#x2013; <a href="http://cia.vc/doc/">CIA project</a> name',
54 'notifycia', 'text', 'CIA is defunct &#x2013; this value is ignored'],
57 sub _mkdir_forkees {
58 my $self = shift;
59 my @pelems = split('/', $self->{name});
60 pop @pelems; # do not create dir for the project itself
61 my $path = $self->{base_path};
62 foreach my $pelem (@pelems) {
63 $path .= "/$pelem";
64 (-d "$path") or mkdir $path or die "mkdir $path: $!";
65 chmod 02775, $path; # ok if fails (dir may already exist and be owned by someone else)
69 # With a leading ':' get from project local config replacing ':' with 'gitweb.'
70 # With a leading '%' get from project local config after removing '%'
71 # Otherwise it's a project file name to be loaded
72 # %propmapro entries are loaded but never written
74 our %propmap = (
75 url => ':baseurl',
76 email => ':owner',
77 desc => 'description',
78 README => 'README.html',
79 hp => ':homepage',
80 notifymail => '%hooks.mailinglist',
81 notifytag => '%hooks.announcelist',
82 notifyjson => '%hooks.jsonurl',
83 notifycia => '%hooks.cianame',
86 our %propmapro = (
87 lastchange => ':lastchange',
88 lastactivity => 'info/lastactivity',
89 lastgc => ':lastgc',
90 lastreceive => ':lastreceive',
91 lastparentgc => ':lastparentgc',
92 lastrefresh => ':lastrefresh',
93 creationtime => '%girocco.creationtime',
94 reposizek => '%girocco.reposizek',
95 origurl => ':baseurl',
98 # Projects with any of these names will be disallowed to avoid possible
99 # collisions with cgi script paths or chroot paths
100 our %reservedprojectnames = (
101 b => 1, # /b/ -> bundle.cgi
102 c => 1, # /c/ -> cgit
103 h => 1, # /h/ -> html.cgi
104 r => 1, # /r/ -> git http
105 w => 1, # /w/ -> gitweb
106 srv => 1, # /srv/git/ -> chroot ssh git repositories
109 sub _update_index {
110 my $self = shift;
111 system("$Girocco::Config::basedir/gitweb/genindex.sh", $self->{name});
114 sub _readlocalconfigfile {
115 my $self = shift;
116 my $undefonerr = shift || 0;
117 delete $self->{configfilehash};
118 my $configfile = get_git("--git-dir=$self->{path}",
119 'config', '--list', '--local', '--null');
120 my $result = 1;
121 defined($configfile) || $undefonerr or $result = 0, $configfile = '';
122 return undef unless defined($configfile);
123 my %config = map({split(/\n/, $_=~/\n/?$_:"$_\ntrue", 2)} split(/\x00/, $configfile));
124 $self->{configfilehash} = \%config;
125 return $result;
128 # @_[0]: argument to convert to boolean result (0 or 1)
129 # @_[1]: value to use if argument is undef (default is 0)
130 # Returns 0 or 1
131 sub _boolval {
132 my ($val, $def) = @_;
133 defined($def) or $def = 0;
134 defined($val) or $val = $def;
135 $val =~ s/\s+//gs;
136 $val = lc($val);
137 return 0 if $val eq '' || $val eq 'false' || $val eq 'off' || $val =~ /^0+$/;
138 return 1;
141 sub _property_path {
142 my $self = shift;
143 my ($name) = @_;
144 $self->{path}.'/'.$name;
147 sub _property_fget {
148 my $self = shift;
149 my ($name) = @_;
150 my $pname = $propmap{$name};
151 $pname = $propmapro{$name} unless $pname;
152 $pname or die "unknown property: $name";
153 if ($pname =~ /^([:%])(.*)$/) {
154 my ($where, $pname) = ($1,lc($2));
155 $self->_readlocalconfigfile
156 unless ref($self->{configfilehash}) eq 'HASH';
157 my $val = $where eq ':' ?
158 $self->{configfilehash}->{"gitweb.$pname"} :
159 $self->{configfilehash}->{$pname};
160 defined($val) or $val = '';
161 chomp $val;
162 return $val;
165 open my $p, '<', $self->_property_path($pname) or return undef;
166 my @value = <$p>;
167 close $p;
168 my $value = join('', @value); chomp $value;
169 $value;
172 sub _property_fput {
173 my $self = shift;
174 my ($name, $value) = @_;
175 my $pname = $propmap{$name};
176 $pname or die "unknown property: $name";
177 $value ||= '';
178 if ($pname =~ s/^://) {
179 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', "gitweb.$pname", $value);
180 return;
181 } elsif ($pname =~ s/^%//) {
182 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', $pname, $value);
183 return;
186 my $P = lock_file($self->_property_path($pname));
187 chomp $value;
188 $value ne '' and print $P "$value\n";
189 close $P;
190 unlock_file($self->_property_path($pname));
193 sub _cleanup_readme {
194 my $self = shift;
195 defined($self->{README}) or $self->{README} = '';
196 $self->{README} =~ s/\r\n?/\n/gs;
197 $self->{README} =~ s/^\s+//s;
198 $self->{README} =~ s/\s+$//s;
199 $self->{README} eq '' or $self->{README} .= "\n";
202 sub _lint_readme {
203 my $self = shift;
204 return 0 unless defined($self->{README}) && $self->{README} ne '';
205 my $test = '<html xmlns="http://www.w3.org/1999/xhtml"><body><div>';
206 $test .= $self->{README};
207 $test .= '</div></body></html>';
208 my ($code, $errors) = capture_command(2, $test, 'xmllint', '--nonet',
209 '--noout', '--nowarning', '-');
210 return 0 unless $code;
211 my $cnt = 0;
212 my @errs = ();
213 for my $line (split(/\n+/, $errors)) {
214 $line = html_esc($line);
215 $line =~ s/ /\&#160;/gs;
216 ++$cnt, $line = 'README'.$1 if $line =~ /^-(:\d+:.*)$/;
217 push @errs, '<tt>' . $line . '</tt>';
219 return ($cnt, join("<br />\n", @errs));
222 sub _properties_load {
223 my $self = shift;
224 foreach my $prop (keys %propmap) {
225 $self->{$prop} = $self->_property_fget($prop);
227 foreach my $prop (keys %propmapro) {
228 $self->{$prop} = $self->_property_fget($prop);
230 $self->_readlocalconfigfile
231 unless ref($self->{configfilehash}) eq 'HASH';
232 $self->{statusupdates} = _boolval($self->{configfilehash}->{'gitweb.statusupdates'}, 1);
233 delete $self->{auth};
234 my $val = $self->{configfilehash}->{'gitweb.repoauth'};
235 defined($val) or $val = '';
236 chomp $val;
237 if ($val =~ /^# ([A-Z]+)AUTH ([0-9a-f]+) (\d+)/) {
238 my $expire = $3;
239 if (time < $expire) {
240 $self->{authtype} = $1;
241 $self->{auth} = $2;
244 $self->_cleanup_readme;
245 delete $self->{configfilehash};
248 sub _properties_save {
249 my $self = shift;
250 my $fd;
251 foreach my $prop (keys %propmap) {
252 $self->_property_fput($prop, $self->{$prop});
254 $self->{statusupdates} = 1
255 unless defined($self->{statusupdates}) && $self->{statusupdates} =~ /^\d+$/;
256 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', '--bool',
257 "gitweb.statusupdates", $self->{statusupdates});
258 if (defined($self->{origurl}) && defined($self->{url}) &&
259 $self->{origurl} ne $self->{url} && -e $self->_property_path(".banged")) {
260 if (open($fd, '>', $self->_property_path(".bangagain"))) {
261 close $fd;
262 chmod(0664, $self->_property_path(".bangagain"));
267 sub _nofetch_path {
268 my $self = shift;
269 $self->_property_path('.nofetch');
272 sub _nofetch {
273 my $self = shift;
274 my ($nofetch) = @_;
275 my $nf = $self->_nofetch_path;
276 if ($nofetch) {
277 open my $x, '>', $nf or die "nofetch failed: $!";
278 close $x;
279 } else {
280 unlink $nf or die "yesfetch failed: $!";
284 sub _gcp_path {
285 my $self = shift;
286 $self->_property_path('.gc_in_progress');
289 sub _clonelog_path {
290 my $self = shift;
291 $self->_property_path('.clonelog');
294 sub _clonefail_path {
295 my $self = shift;
296 $self->_property_path('.clone_failed');
299 sub _clonep_path {
300 my $self = shift;
301 $self->_property_path('.clone_in_progress');
304 sub _clonep {
305 my $self = shift;
306 my ($nofetch) = @_;
307 my $np = $self->_clonep_path;
308 if ($nofetch) {
309 open my $x, '>', $np or die "clonep failed: $!";
310 close $x;
311 } else {
312 unlink $np or die "clonef failed: $!";
315 sub _alternates_setup {
316 my $self = shift;
317 return unless $self->{name} =~ m#/#;
318 my $forkee_name = get_forkee_name($self->{name});
319 my $forkee_path = get_forkee_path($self->{name});
320 return unless -d $forkee_path;
321 mkdir $self->{path}.'/refs'; chmod 02775, $self->{path}.'/refs';
322 mkdir $self->{path}.'/objects'; chmod 02775, $self->{path}.'/objects';
323 mkdir $self->{path}.'/objects/info'; chmod 02775, $self->{path}.'/objects/info';
325 # We set up both alternates and http_alternates since we cannot use
326 # relative path in alternates - that doesn't work recursively.
328 my $filename = $self->{path}.'/objects/info/alternates';
329 open my $x, '>', $filename or die "alternates failed: $!";
330 print $x "$forkee_path/objects\n";
331 close $x;
332 chmod 0664, $filename or warn "cannot chmod $filename: $!";
334 if ($Girocco::Config::httppullurl) {
335 $filename = $self->{path}.'/objects/info/http-alternates';
336 open my $x, '>', $filename or die "http-alternates failed: $!";
337 my $upfork = $forkee_name;
338 do { print $x "$Girocco::Config::httppullurl/$upfork.git/objects\n"; } while ($upfork =~ s#/?.+?$## and $upfork); #
339 close $x;
340 chmod 0664, $filename or warn "cannot chmod $filename: $!";
343 # copy lastactivity from the parent project
344 if (open $x, '<', $forkee_path.'/info/lastactivity') {{
345 my $activity = <$x>;
346 close $x;
347 last unless $activity;
348 open $x, '>', $self->{path}.'/info/lastactivity' or last;
349 print $x $activity;
350 close $x;
351 chomp $activity;
352 $self->{'lastactivity'} = $activity;
355 # copy refs from parent project
356 local *SAVEOUT;
357 open(SAVEOUT, ">&STDOUT") || die "couldn't dup STDOUT: $!";
358 my $result = open(STDOUT, '>', "$self->{path}/packed-refs");
359 my $resultstr = $!;
360 if (!$result) {
361 open(STDOUT, ">&SAVEOUT") || die "couldn't dup SAVEOUT to STDOUT: $!";
362 close(SAVEOUT) or die "couldn't close SAVEOUT: $!";
363 die "could not write fork's packed-refs file: $resultstr";
365 system($Girocco::Config::git_bin, "--git-dir=$forkee_path", 'for-each-ref', '--format=%(objectname) %(refname)');
366 $result = close(STDOUT);
367 $resultstr = $!;
368 open(STDOUT, ">&SAVEOUT") || die "couldn't dup SAVEOUT to STDOUT: $!";
369 close(SAVEOUT) or die "couldn't close SAVEOUT: $!";
370 $result or die "could not close fork's packed-refs file: $resultstr";
371 unlink("$self->{path}/.delaygc") if -s "$self->{path}/packed-refs";
373 # initialize HEAD
374 my $HEAD = get_git("--git-dir=$forkee_path", 'symbolic-ref', 'HEAD');
375 defined($HEAD) && $HEAD =~ m,^refs/heads/., or $HEAD = 'refs/heads/master';
376 chomp $HEAD;
377 system($Girocco::Config::git_bin, "--git-dir=$self->{path}", 'symbolic-ref', 'HEAD', $HEAD);
378 chmod 0664, "$self->{path}/packed-refs", "$self->{path}/HEAD";
381 sub _set_changed {
382 my $self = shift;
383 my $fd;
384 open $fd, '>', "$self->{path}/htmlcache/changed" and close $fd;
387 sub _set_forkchange {
388 my $self = shift;
389 my $changedtoo = shift;
390 return unless $self->{name} =~ m#/#;
391 my $forkee_path = get_forkee_path($self->{name});
392 return unless -d $forkee_path;
393 # mark forkee as changed
394 my $fd;
395 open $fd, '>', $forkee_path.'/htmlcache/changed' and close $fd if $changedtoo;
396 open $fd, '>', $forkee_path.'/htmlcache/forkchange' and close $fd;
397 return if -e $forkee_path.'/htmlcache/summary.forkchange';
398 open $fd, '>', $forkee_path.'/htmlcache/summary.forkchange' and close $fd;
401 sub _ctags_setup {
402 my $self = shift;
403 my $perms = $Girocco::Config::permission_control eq 'Hooks' ? 02777 : 02775;
404 mkdir $self->{path}.'/ctags'; chmod $perms, $self->{path}.'/ctags';
407 sub _group_add {
408 my $self = shift;
409 my ($xtra) = @_;
410 $xtra .= join(',', @{$self->{users}});
411 filedb_atomic_append(jailed_file('/etc/group'),
412 join(':', $self->{name}, $self->{crypt}, '\i', $xtra));
415 sub _group_update {
416 my $self = shift;
417 my $xtra = join(',', @{$self->{users}});
418 filedb_atomic_edit(jailed_file('/etc/group'),
419 sub {
420 $_ = $_[0];
421 chomp;
422 if ($self->{name} eq (split /:/)[0]) {
423 # preserve readonly flag
424 s/::([^:]*)$/:$1/ and $xtra = ":$xtra";
425 return join(':', $self->{name}, $self->{crypt}, $self->{gid}, $xtra)."\n";
426 } else {
427 return "$_\n";
433 sub _group_remove {
434 my $self = shift;
435 filedb_atomic_edit(jailed_file('/etc/group'),
436 sub {
437 $self->{name} ne (split /:/)[0] and return $_;
442 sub _hook_path {
443 my $self = shift;
444 my ($name) = @_;
445 $self->{path}.'/hooks/'.$name;
448 sub _hook_install {
449 my $self = shift;
450 my ($name) = @_;
451 my $hooksdir = $self->{path}.'/hooks';
452 my $oldmask = umask();
453 umask($oldmask & ~0070);
454 -d $hooksdir or mkdir $hooksdir or
455 die "hooks directory does not exist and unable to create it for project " . $self->{name} . ": $!";
456 umask($oldmask);
457 open my $src, '<', "$Girocco::Config::basedir/hooks/$name" or die "cannot open hook $name: $!";
458 open my $dst, '>', $self->_hook_path($name) or die "cannot open hook $name for writing: $!";
459 while (<$src>) { print $dst $_; }
460 close $dst;
461 close $src;
462 chmod 0775, $self->_hook_path($name) or die "cannot chmod hook $name: $!";
465 sub _hooks_install {
466 my $self = shift;
467 foreach my $hook ('pre-receive', 'post-receive', 'update') {
468 $self->_hook_install($hook);
472 # private constructor, do not use
473 sub _new {
474 my $class = shift;
475 my ($name, $base_path, $path) = @_;
476 does_exist($name,1) || valid_name($name) or die "refusing to create project with invalid name ($name)!";
477 $path ||= "$base_path/$name.git";
478 my $proj = { name => $name, base_path => $base_path, path => $path };
480 bless $proj, $class;
483 # public constructor #0
484 # creates a virtual project not connected to disk image
485 # you can conjure() it later to disk
486 sub ghost {
487 my $class = shift;
488 my ($name, $mirror) = @_;
489 my $self = $class->_new($name, $Girocco::Config::reporoot);
490 $self->{users} = [];
491 $self->{mirror} = $mirror;
492 $self->{email} = $self->{orig_email} = '';
493 $self;
496 # public constructor #1
497 sub load {
498 my $class = shift;
499 my $name = shift || '';
501 open my $fd, '<', jailed_file("/etc/group") or die "project load failed: $!";
502 my $r = qr/^\Q$name\E:/;
503 foreach (grep /$r/, <$fd>) {
504 chomp;
506 my $self = $class->_new($name, $Girocco::Config::reporoot);
507 (-d $self->{path} && $self->_readlocalconfigfile(1))
508 or die "invalid path (".$self->{path}.") for project ".$self->{name};
510 my $ulist;
511 (undef, $self->{crypt}, $self->{gid}, $ulist) = split /:/;
512 $ulist ||= '';
513 $self->{users} = [split /,/, $ulist];
514 $self->{HEAD} = $self->get_HEAD;
515 $self->{orig_HEAD} = $self->{HEAD};
516 $self->{orig_users} = [@{$self->{users}}];
517 $self->{mirror} = ! -e $self->_nofetch_path;
518 $self->{gc_in_progress} = -e $self->_gcp_path;
519 $self->{clone_in_progress} = -e $self->_clonep_path;
520 $self->{clone_logged} = -e $self->_clonelog_path;
521 $self->{clone_failed} = -e $self->_clonefail_path;
522 $self->{ccrypt} = $self->{crypt};
524 $self->_properties_load;
525 $self->{orig_email} = $self->{email};
526 $self->{loaded} = 1; # indicates self was loaded from etc/group file
527 close $fd;
528 return $self;
530 close $fd;
531 undef;
534 # $proj may not be in sane state if this returns false!
535 # fields listed in %$metadata_fields that are NOT also
536 # in @Girocco::Config::project_fields are totally ignored!
537 sub cgi_fill {
538 my $self = shift;
539 my ($gcgi) = @_;
540 my $cgi = $gcgi->cgi;
541 my %allowedfields = map({$_ => 1} @Girocco::Config::project_fields);
542 my $field_enabled = sub {
543 !exists($metadata_fields->{$_[0]}) || exists($allowedfields{$_[0]})};
545 my $pwd = $cgi->param('pwd');
546 my $pwd2 = $cgi->param('pwd2');
547 # in case passwords are disabled
548 defined($pwd) or $pwd = ''; defined($pwd2) or $pwd = '';
549 if ($Girocco::Config::project_passwords and not $self->{crypt} and $pwd eq '' and $pwd2 eq '') {
550 $gcgi->err("Empty passwords are not permitted.");
552 if ($pwd ne '' or not $self->{crypt}) {
553 $self->{crypt} = scrypt_sha1($pwd);
555 if (($pwd ne '' || $pwd2 ne '') and $pwd ne $pwd2) {
556 $gcgi->err("Our high-paid security consultants have determined that the admin passwords you have entered do not match each other.");
559 $self->{cpwd} = $cgi->param('cpwd');
561 my ($forkee,$project) = ($self->{name} =~ m#^(.*/)?([^/]+)$#);
562 my $newtype = $forkee ? 'fork' : 'project';
563 length($project) <= 64
564 or $gcgi->err("The $newtype name is longer than 64 characters. Do you really need that much?");
566 if ($Girocco::Config::project_owners eq 'email') {
567 $self->{email} = $gcgi->wparam('email');
568 valid_email($self->{email})
569 or $gcgi->err("Your email sure looks weird...?");
570 length($self->{email}) <= 96
571 or $gcgi->err("Your email is longer than 96 characters. Do you really need that much?");
574 # No setting the url unless we're either new or an existing mirror!
575 $self->{url} = $gcgi->wparam('url') unless $self->{loaded} && !$self->{mirror};
576 # Always validate the url if we're an existing mirror
577 if ((defined($self->{url}) && $self->{url} ne '') || ($self->{loaded} && $self->{mirror})) {
578 valid_repo_url($self->{url})
579 or $gcgi->err("Invalid URL. Note that only HTTP and Git protocols are supported. If the URL contains funny characters, contact me.");
580 if ($Girocco::Config::restrict_mirror_hosts) {
581 my $mh = extract_url_hostname($self->{url});
582 is_dns_hostname($mh)
583 or $gcgi->err("Invalid URL. Note that only DNS names are allowed, not IP addresses.");
584 !is_our_hostname($mh)
585 or $gcgi->err("Invalid URL. Mirrors from this host are not allowed, please create a fork instead.");
589 if ($field_enabled->('desc')) {
590 $self->{desc} = to_utf8($gcgi->wparam('desc'), 1);
591 length($self->{desc}) <= 1024
592 or $gcgi->err("<b>Short</b> description length &gt; 1kb!");
595 if ($field_enabled->('README')) {
596 $self->{README} = to_utf8($gcgi->wparam('README'), 1);
597 $self->_cleanup_readme;
598 length($self->{README}) <= 8192
599 or $gcgi->err("README length &gt; 8kb!");
600 my ($cnt, $err) = (0);
601 ($cnt, $err) = $self->_lint_readme if $gcgi->ok && $Girocco::Config::xmllint_readme;
602 $gcgi->err($err), $gcgi->{err} += $cnt-1 if $cnt;
605 if ($field_enabled->('hp')) {
606 $self->{hp} = $gcgi->wparam('hp');
607 if ($self->{hp}) {
608 valid_web_url($self->{hp})
609 or $gcgi->err("Invalid homepage URL. Note that only HTTP protocol is supported. If the URL contains funny characters, contact me.");
613 # No mucking about with users unless we're a push project
614 if (($self->{loaded} && !$self->{mirror}) ||
615 (!$self->{loaded} && (!defined($self->{url}) || $self->{url} eq ''))) {
616 my %users = ();
617 my @users = ();
618 foreach my $user ($cgi->multi_param('user')) {
619 if (!exists($users{$user})) {
620 $users{$user} = 1;
621 push(@users, $user) if Girocco::User::does_exist($user, 1);
624 $self->{users} = \@users;
627 $self->{HEAD} = $cgi->param('HEAD') if $cgi->param('HEAD');
629 # schedule deletion of tags (will be committed by update() after auth)
630 $self->{tags_to_delete} = [$cgi->multi_param('tags')];
632 if ($field_enabled->('notifymail')) {
633 $self->{notifymail} = $gcgi->wparam('notifymail');
634 if ($self->{notifymail}) {
635 (valid_email_multi($self->{notifymail}) and length($self->{notifymail}) <= 512)
636 or $gcgi->err("Invalid notify e-mail address. Use mail,mail to specify multiple addresses; total length must not exceed 512 characters, however.");
640 if ($field_enabled->('notifytag')) {
641 $self->{notifytag} = $gcgi->wparam('notifytag');
642 if ($self->{notifytag}) {
643 (valid_email_multi($self->{notifytag}) and length($self->{notifytag}) <= 512)
644 or $gcgi->err("Invalid notify e-mail address. Use mail,mail to specify multiple addresses; total length must not exceed 512 characters, however.");
648 if ($field_enabled->('notifyjson')) {
649 $self->{notifyjson} = $gcgi->wparam('notifyjson');
650 if ($self->{notifyjson}) {
651 valid_web_url($self->{notifyjson})
652 or $gcgi->err("Invalid JSON notify URL. Note that only HTTP protocol is supported. If the URL contains funny characters, contact me.");
656 if ($field_enabled->('notifycia')) {
657 $self->{notifycia} = $gcgi->wparam('notifycia');
658 if ($self->{notifycia}) {
659 $self->{notifycia} =~ /^[a-zA-Z0-9._-]+$/
660 or $gcgi->err("Overly suspicious CIA notify project name. If it's actually valid, don't contact me, CIA is defunct.");
664 if ($cgi->param('setstatusupdates')) {
665 my $val = $gcgi->wparam('statusupdates') || '0';
666 $self->{statusupdates} = $val ? 1 : 0;
669 not $gcgi->err_check;
672 sub form_defaults {
673 my $self = shift;
675 name => $self->{name},
676 email => $self->{email},
677 url => $self->{url},
678 desc => html_esc($self->{desc}),
679 README => html_esc($self->{README}),
680 hp => $self->{hp},
681 users => $self->{users},
682 notifymail => html_esc($self->{notifymail}),
683 notifytag => html_esc($self->{notifytag}),
684 notifyjson => html_esc($self->{notifyjson}),
685 notifycia => html_esc($self->{notifycia}),
689 # return true if $enc_passwd is a match for $plain_passwd
690 my $_check_passwd_match = sub {
691 my $enc_passwd = shift;
692 my $plain_passwd = shift;
693 defined($enc_passwd) or $enc_passwd = '';
694 defined($plain_passwd) or $plain_passwd = '';
695 # $enc_passwd may be crypt or crypt_sha1
696 if ($enc_passwd =~ m(^\$sha1\$(\d+)\$([./0-9A-Za-z]{1,64})\$[./0-9A-Za-z]{28}$)) {
697 # It's using sha1-crypt
698 return $enc_passwd eq crypt_sha1($plain_passwd, $2, -(0+$1));
699 } else {
700 # It's using crypt
701 return $enc_passwd eq crypt($plain_passwd, $enc_passwd);
705 sub authenticate {
706 my $self = shift;
707 my ($gcgi) = @_;
709 $self->{ccrypt} or die "Can't authenticate against a project with no password";
710 defined($self->{cpwd}) or $self->{cpwd} = '';
711 unless ($_check_passwd_match->($self->{ccrypt}, $self->{cpwd})) {
712 $gcgi->err("Your admin password does not match!");
713 return 0;
715 return 1;
718 # return true if the password from the file is empty or consists of all the same
719 # character. However, if the project was NOT loaded from the group file
720 # (!self->{loaded}) then the password is never locked.
721 # This function does NOT check $Girocco::Config::project_passwords, the caller
722 # is responsible for doing so if desired. Same for $self->{email}.
723 sub is_password_locked {
724 my $self = shift;
726 $self->{loaded} or return 0;
727 my $testcrypt = $self->{ccrypt}; # The value from the group file
728 defined($testcrypt) or $testcrypt = '';
729 $testcrypt ne '' or return 1; # No password at all
730 $testcrypt =~ /^(.)\1*$/ and return 1; # Bogus crypt value
731 return 0; # Not locked
734 sub _setup {
735 use POSIX qw(strftime);
736 my $self = shift;
737 my ($pushers) = @_;
738 my $fd;
740 $self->_mkdir_forkees;
742 my $gid;
743 mkdir($self->{path}) or die "mkdir $self->{path} failed: $!";
744 if ($Girocco::Config::owning_group) {
745 $gid = scalar(getgrnam($Girocco::Config::owning_group));
746 chown(-1, $gid, $self->{path}) or die "chgrp $gid $self->{path} failed: $!";
747 chmod(02775, $self->{path}) or die "chmod 02775 $self->{path} failed: $!";
748 } else {
749 chmod(02777, $self->{path}) or die "chmod 02777 $self->{path} failed: $!";
751 $ENV{'GIT_TEMPLATE_DIR'} = $Girocco::Config::chroot.'/var/empty';
752 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'init', '--quiet', '--bare', '--shared='.$self->shared_mode()) == 0
753 or die "git init $self->{path} failed: $?";
754 # we don't need these two, remove them (they will normally be created empty) if they exist
755 rmdir $self->{path}."/branches";
756 rmdir $self->{path}."/remotes";
757 -d $self->{path}."/info" or mkdir $self->{path}."/info"
758 or die "info directory does not exist and unable to create it: $!";
759 -d $self->{path}."/hooks" or mkdir $self->{path}."/hooks"
760 or die "hooks directory does not exist and unable to create it: $!";
761 # clean out any kruft that may have come in from the initial template directory
762 foreach my $cleandir (qw(hooks info)) {
763 if (opendir my $hooksdir, $self->{path}.'/'.$cleandir) {
764 unlink map "$self->{path}/$_", grep { $_ ne '.' && $_ ne '..' } readdir $hooksdir;
765 closedir $hooksdir;
768 if ($Girocco::Config::owning_group) {
769 chown(-1, $gid, $self->{path}."/hooks") or die "chgrp $gid $self->{path}/hooks failed: $!";
771 # hooks never world writable
772 chmod 02775, $self->{path}."/hooks" or die "chmod 02775 $self->{path}/hooks failed: $!";
773 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'core.logallrefupdates', 'false') == 0
774 or die "disabling core.logallrefupdates failed: $?";
775 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'receive.denyNonFastforwards', 'false') == 0
776 or die "disabling receive.denyNonFastforwards failed: $?";
777 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'gc.auto', '0') == 0
778 or die "disabling gc.auto failed: $?";
779 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'receive.autogc', '0') == 0
780 or die "disabling receive.autogc failed: $?";
781 my ($S,$M,$H,$d,$m,$y) = gmtime(time());
782 $self->{creationtime} = strftime("%Y-%m-%dT%H:%M:%SZ", $S, $M, $H, $d, $m, $y, -1, -1, -1);
783 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'girocco.creationtime', $self->{creationtime}) == 0
784 or die "setting girocco.creationtime failed: $?";
785 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'receive.updateserverinfo', 'true') == 0
786 or die "enabling receive.updateserverinfo failed: $?";
787 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'repack.writebitmaps', 'true') == 0
788 or die "enabling repack.writebitmaps failed: $?";
789 -d $self->{path}."/htmlcache" or mkdir $self->{path}."/htmlcache"
790 or die "htmlcache directory does not exist and unable to create it: $!";
791 -d $self->{path}."/bundles" or mkdir $self->{path}."/bundles"
792 or die "bundles directory does not exist and unable to create it: $!";
793 foreach my $file (qw(info/lastactivity .delaygc)) {
794 if (open $fd, '>', $self->{path}."/".$file) {
795 close $fd;
796 chmod 0664, $self->{path}."/".$file;
800 # /info must have right permissions,
801 # and git init didn't do it for some reason.
802 # config must have correct permissions.
803 # and Git 2.1.0 - 2.2.1 incorrectly add +x for some reason.
804 # also make sure /refs, /objects and /htmlcache are correct too.
805 my ($dmode, $dmodestr, $fmode, $fmodestr);
806 if ($Girocco::Config::owning_group) {
807 ($dmode, $dmodestr) = (02775, '02775');
808 ($fmode, $fmodestr) = (0664, '0664');
809 } else {
810 ($dmode, $dmodestr) = (02777, '02777');
811 ($fmode, $fmodestr) = (0666, '0666');
813 foreach my $dir (qw(info refs objects htmlcache bundles)) {
814 chmod($dmode, $self->{path}."/$dir") or die "chmod $dmodestr $self->{path}/$dir failed: $!";
816 foreach my $file (qw(config)) {
817 chmod($fmode, $self->{path}."/$file") or die "chmod $fmodestr $self->{path}/$file failed: $!";
819 # these ones are probably not strictly required but are nice to have
820 foreach my $dir (qw(refs/heads refs/tags objects/info objects/pack)) {
821 -d $self->{path}."/$dir" or mkdir $self->{path}."/$dir";
822 chmod($dmode, $self->{path}."/$dir");
825 $self->_properties_save;
826 $self->_alternates_setup;
827 $self->_ctags_setup;
828 $self->_group_remove;
829 $self->_group_add($pushers);
830 $self->_hooks_install;
831 $self->_update_index;
832 $self->_set_changed;
833 $self->_set_forkchange(1);
836 sub premirror {
837 my $self = shift;
839 $self->_setup(':');
840 $self->_clonep(1);
841 $self->perm_initialize;
844 sub conjure {
845 my $self = shift;
847 $self->_setup;
848 $self->_nofetch(1);
849 if ($Girocco::Config::mob && $Girocco::Config::mob eq "mob") {
850 system("$Girocco::Config::basedir/bin/create-personal-mob-area", $self->{name}) == 0
851 or die "create-personal-mob-area $self->{name} failed";
853 $self->perm_initialize;
856 sub clone {
857 my $self = shift;
859 unlink ($self->_clonefail_path()); # Ignore EEXIST error
860 unlink ($self->_clonelog_path()); # Ignore EEXIST error
862 use IO::Socket;
863 my $sock = IO::Socket::UNIX->new($Girocco::Config::chroot.'/etc/taskd.socket') or die "cannot connect to taskd.socket: $!";
864 select((select($sock),$|=1)[0]);
865 $sock->print("clone ".$self->{name}."\n");
866 # Just ignore reply, we are going to succeed anyway and the I/O
867 # would apparently get quite hairy.
868 $sock->flush();
869 sleep 2; # *cough*
870 $sock->close();
873 sub update {
874 my $self = shift;
876 $self->_properties_save;
877 $self->_group_update;
879 if (exists($self->{tags_to_delete})) {
880 $self->delete_ctag($_) foreach(@{$self->{tags_to_delete}});
883 $self->set_HEAD($self->{HEAD}) unless $self->{orig_HEAD} eq $self->{HEAD};
885 my @users_add = grep { $a = $_; not scalar grep { $a eq $_ } $self->{orig_users} } $self->{users};
886 my @users_del = grep { $a = $_; not scalar grep { $a eq $_ } $self->{users} } $self->{orig_users};
887 $self->perm_user_add($_, Girocco::User::resolve_uid($_)) foreach (@users_add);
888 $self->perm_user_del($_, Girocco::User::resolve_uid($_)) foreach (@users_del);
890 $self->_update_index if $self->{email} ne $self->{orig_email};
891 $self->{orig_email} = $self->{email};
892 $self->_set_changed;
897 sub update_password {
898 my $self = shift;
899 my ($pwd) = @_;
901 $self->{crypt} = scrypt_sha1($pwd);
902 $self->_group_update;
905 # You can explicitly do this just on a ghost() repository too.
906 sub delete {
907 my $self = shift;
909 if (-d $self->{path}) {
910 system('rm', '-rf', $self->{path}) == 0
911 or die "rm -rf $self->{path} failed: $?";
913 # attempt to clean up any empty fork directories by removing them
914 my @pelems = split('/', $self->{name});
915 while (@pelems > 1) {
916 pop @pelems;
917 # okay to fail
918 rmdir join('/', $Girocco::Config::reporoot, @pelems) or last;
920 $self->_group_remove;
921 $self->_update_index;
922 $self->_set_forkchange(1);
927 sub _contains_files {
928 my $dir = shift;
929 (-d $dir) or return 0;
930 opendir(my $dh, $dir) or die "opendir $dir failed: $!";
931 while (my $entry = readdir($dh)) {
932 next if $entry eq '' || $entry eq '.' || $entry eq '..';
933 closedir($dh), return 1
934 if -f "$dir/$entry" ||
935 -d "$dir/$entry" && _contains_files("$dir/$entry");
937 closedir($dh);
938 return 0;
941 sub has_forks {
942 my $self = shift;
944 return _contains_files($Girocco::Config::reporoot.'/'.$self->{name});
947 # Returns an array of 0 or more array refs, one for each bundle:
948 # ->[0]: bundle creation time (seconds since epoch)
949 # ->[1]: bundle name (e.g. foo-xxxxxxxx.bundle)
950 # ->[2]: bundle size in bytes
951 sub bundles {
952 my $self = shift;
953 use Time::Local;
955 return @{$self->{bundles}} if ref($self->{bundles}) eq 'ARRAY';
956 my @blist = ();
957 if (-d $self->{path}.'/bundles') {{
958 my $prefix = $self->{name};
959 $prefix =~ s|^.*[^/]/([^/]+)$|$1|;
960 opendir(my $dh, $self->{path}.'/bundles') or last;
961 while (my $bfile = readdir($dh)) {
962 next unless $bfile =~ /^\d{8}_\d{6}-[0-9a-f]{8}$/;
963 my $ctime = eval {timegm(
964 0+substr($bfile,13,2), 0+substr($bfile,11,2), 0+substr($bfile,9,2),
965 0+substr($bfile,6,2), 0+substr($bfile,4,2)-1, 0+substr($bfile,0,4)-1900)};
966 next unless $ctime;
967 open(my $bh, '<', $self->{path}.'/bundles/'.$bfile) or next;
968 my $f1 = <$bh>;
969 my $f2 = <$bh>;
970 $f1 = $self->{path}.'/objects/pack/'.$f1 if $f1 && $f1 !~ m|^/|;
971 $f2 = $self->{path}.'/objects/pack/'.$f2 if $f2 && $f2 !~ m|^/|;
972 close($bh);
973 next unless $f1 && $f2 && $f1 ne $f2;
974 chomp $f1;
975 chomp $f2;
976 next unless -e $f1 && -e $f2;
977 my $s1 = -s $f1 || 0;
978 my $s2 = -s $f2 || 0;
979 next unless $s1 || $s2;
980 push(@blist, [$ctime, "$prefix-".substr($bfile,16,8).".bundle", $s1+$s2]);
982 closedir($dh);
984 @blist = sort({$b->[0] <=> $a->[0]} @blist);
985 my %seen = ();
986 my @result = ();
987 foreach my $bndl (@blist) {
988 next if $seen{$bndl->[1]};
989 $seen{$bndl->[1]} = 1;
990 push(@result, $bndl);
992 $self->{bundles} = \@result;
993 return @result;
996 sub has_alternates {
997 my $self = shift;
998 return -s $self->{path}.'/objects/info/alternates' ? 1 : 0;
1001 sub has_bundle {
1002 my $self = shift;
1004 return scalar($self->bundles);
1007 # returns true if any of the notify fields are non-empty
1008 sub has_notify {
1009 my $self = shift;
1010 # We do not ckeck notifycia since it's defunct
1011 return $self->{'notifymail'} || $self->{'notifytag'} || $self->{'notifyjson'};
1014 sub is_empty {
1015 # A project is considered empty if the git repository does not
1016 # have any refs. This means packed-refs does not exist or is
1017 # empty or only has lines starting with '#' AND there are no
1018 # files in the refs subdirectory hierarchy (no matter how deep).
1020 my $self = shift;
1022 (-d $self->{path}) or return 0;
1023 if (-e $self->{path}.'/packed-refs') {
1024 open(my $pr, '<', $self->{path}.'/packed-refs')
1025 or die "open $self->{path}./packed-refs failed: $!";
1026 my $foundref = 0;
1027 while (my $ref = <$pr>) {
1028 next if $ref =~ /^#/;
1029 $foundref = 1;
1030 last;
1032 close($pr);
1033 return 0 if $foundref;
1035 (-d $self->{path}.'/refs') or return 1;
1036 return !_contains_files($self->{path}.'/refs');
1039 # returns array:
1040 # [0]: earliest possible scheduled next gc, undef if lastgc not set
1041 # [1]: approx. latest possible scheduled next gc, undef if lastgc not set
1042 # Both values (if not undef) are seconds since epoch
1043 # Result only considers lastgc and min_gc_interval nothing else
1044 sub next_gc {
1045 my $self = shift;
1046 my $lastgcepoch = parse_any_date($self->{lastgc});
1047 return (undef, undef) unless defined $lastgcepoch;
1048 return ($lastgcepoch + $Girocco::Config::min_gc_interval,
1049 int($lastgcepoch + 1.25 * $Girocco::Config::min_gc_interval +
1050 $Girocco::Config::min_mirror_interval));
1053 # returns boolean (0 or 1)
1054 # Attempts to determine whether or not a gc (and corresponding build
1055 # of a .bitmap/.bndl file) will actually take place at the next_gc
1056 # time (as returned by next_gc). Whether or not a .bitmap and .bndl
1057 # end up being built depends on whether or not the local object graph
1058 # is complete. In general if has_alternates is true then a .bitmap/.bndl
1059 # is not possible because the object graph will be incomplete,
1060 # but it *is* possible that even though the repository has_alternates,
1061 # it does not actually borrow any objects so a .bitmap/.bndl will build
1062 # in spite of the presence of alternates -- but this is expected to be rare.
1063 # The result is a best guess and false return value is not an absolute
1064 # guarantee that gc will not take place at the next interval, but it probably
1065 # will not if nothing changes in the meantime.
1066 sub needs_gc {
1067 my $self = shift;
1068 my $lgc = parse_any_date($self->{lastgc});
1069 my $lrecv = parse_any_date($self->{lastreceive});
1070 my $lpgc = parse_any_date($self->{lastparentgc});
1071 return 1 unless defined($lgc) && defined($lrecv);
1072 if ($self->has_alternates) {
1073 return 1 unless defined($lpgc);
1074 return 1 unless $lpgc < $lgc;
1076 return 1 unless $lrecv < $lgc;
1077 # We don't try running any "is_dirty" check, so if somehow the
1078 # repository became dirty without updating lastreceive we might
1079 # incorrectly return false instead of true.
1080 return 0;
1083 sub delete_ctag {
1084 my $self = shift;
1085 my ($ctag) = @_;
1087 # sanity check, disallow filenames starting with . .. or /
1088 unlink($self->{path}.'/ctags/'.$ctag) if($ctag !~ m|^(\.\.?)/|);
1091 sub get_ctag_names {
1092 my $self = shift;
1093 my @ctags = ();
1094 opendir(my $dh, $self->{path}.'/ctags')
1095 or return @ctags;
1096 @ctags = grep { -f "$self->{path}/ctags/$_" } readdir($dh);
1097 closedir($dh);
1098 return sort({lc($a) cmp lc($b)} @ctags);
1101 sub get_heads {
1102 my $self = shift;
1103 my $fh;
1104 my $heads = get_git("--git-dir=$self->{path}", 'for-each-ref', '--format=%(objectname) %(refname)', 'refs/heads');
1105 defined($heads) or $heads = '';
1106 chomp $heads;
1107 my @res = ();
1108 foreach (split(/\n/, $heads)) {
1109 chomp;
1110 next if !m#^[0-9a-f]{40}\s+refs/heads/(.+)$ #x;
1111 push @res, $1;
1113 @res;
1116 sub get_HEAD {
1117 my $self = shift;
1118 my $HEAD = get_git("--git-dir=$self->{path}", 'symbolic-ref', 'HEAD');
1119 defined($HEAD) or $HEAD = '';
1120 chomp $HEAD;
1121 die "could not get HEAD" if ($HEAD !~ m{^refs/heads/(.+)$});
1122 return $1;
1125 sub set_HEAD {
1126 my $self = shift;
1127 my $newHEAD = shift;
1128 # Cursory checks only -- if you want to break your HEAD, be my guest
1129 if ($newHEAD =~ /^\/|['<>]|\.\.|\/$/) {
1130 die "grossly invalid new HEAD: $newHEAD";
1132 system($Girocco::Config::git_bin, "--git-dir=$self->{path}", 'symbolic-ref', 'HEAD', "refs/heads/$newHEAD");
1133 die "could not set HEAD" if ($? >> 8);
1134 ! -d "$self->{path}/mob" || $Girocco::Config::mob ne 'mob'
1135 or system('cp', '-p', '-f', "$self->{path}/HEAD", "$self->{path}/mob/HEAD") == 0;
1138 sub gen_auth {
1139 my $self = shift;
1140 my ($type) = @_;
1141 $type = 'REPO' unless $type && $type =~ /^[A-Z]+$/;
1143 $self->{authtype} = $type;
1145 no warnings;
1146 $self->{auth} = sha1_hex(time . $$ . rand() . join(':',%$self));
1148 my $expire = time + 24 * 3600;
1149 my $propval = "# ${type}AUTH $self->{auth} $expire";
1150 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'gitweb.repoauth', $propval);
1151 $self->{auth};
1154 sub del_auth {
1155 my $self = shift;
1157 delete $self->{auth};
1158 delete $self->{authtype};
1159 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', '--unset', 'gitweb.repoauth');
1162 sub remove_user {
1163 my $self = shift;
1164 my ($username) = @_;
1166 my $before_count = @{$self->{users}};
1167 $self->{users} = [grep { $_ ne $username } @{$self->{users}}];
1168 return @{$self->{users}} != $before_count;
1171 ### static methods
1173 sub get_forkee_name {
1174 local $_ = $_[0];
1175 (m#^(.*)/.*?$#)[0]; #
1178 sub get_forkee_path {
1179 no warnings; # avoid silly 'unsuccessful stat on filename with \n' warning
1180 my $forkee = $Girocco::Config::reporoot.'/'.get_forkee_name($_[0]).'.git';
1181 -d $forkee ? $forkee : '';
1184 # Ultimately the full project/fork name could end up being part of a Git ref name
1185 # when a project's forks are combined into one giant repository for efficiency.
1186 # That means that the project/fork name must satisfy the Git ref name requirements:
1188 # 1. Characters with an ASCII value less than or equal to 32 are not allowed
1189 # 2. The character with an ASCII value of 0x7F is not allowed
1190 # 3. The characters '~', '^', ':', '\', '*', '?', and '[' are not allowed
1191 # 4. The character '/' is a separator and is not allowed within a name
1192 # 5. The name may not start with '.' or end with '.'
1193 # 6. The name may not end with '.lock'
1194 # 7. The name may not contain the '..' sequence
1195 # 8. The name may not contain the '@{' sequence
1196 # 9. If multiple components are used (separated by '/'), no empty '' components
1198 # We also prohibit a trailing '.git' on any path component and futher restrict
1199 # the allowed characters to alphanumeric and [+._-] where names must start with
1200 # an alphanumeric.
1202 sub _valid_name_characters {
1203 local $_ = $_[0];
1204 (not m#^[/+._-]#)
1205 and (not m#//#)
1206 and (not m#\.\.#)
1207 and (not m#/[+._-]#)
1208 and (not m#\./#)
1209 and (not m#\.$#)
1210 and (not m#\.git/#i)
1211 and (not m#\.git$#i)
1212 and (not m#\.lock/#i)
1213 and (not m#\.lock$#i)
1214 and (not m#\.bundle/#i)
1215 and (not m#\.bundle$#i)
1216 and (not m#/$#)
1217 and m#^[a-zA-Z0-9/+._-]+$#
1218 and !has_reserved_suffix($_, $_[1], $_[2]);
1221 sub valid_name {
1222 no warnings; # avoid silly 'unsuccessful stat on filename with \n' warning
1223 local $_ = $_[0];
1224 _valid_name_characters($_) and not exists($reservedprojectnames{lc($_)})
1225 and @{[m#/#g]} <= 5 # maximum fork depth is 5
1226 and ((not m#/#) or -d get_forkee_path($_)); # will also catch ^/
1229 # It's possible that some forks have been kept but the forkee is gone.
1230 # In this case the standard valid_name check is too strict.
1231 sub does_exist {
1232 no warnings; # avoid silly 'unsuccessful stat on filename with \n' warning
1233 my ($name, $nodie) = @_;
1234 my $okay = (
1235 _valid_name_characters($name, $Girocco::Config::reporoot, ".git")
1236 and ((not $name =~ m#/#)
1237 or -d get_forkee_path($name)
1238 or -d $Girocco::Config::reporoot.'/'.get_forkee_name($name)));
1239 (!$okay && $nodie) and return undef;
1240 !$okay and die "tried to query for project with invalid name $name!";
1241 (-d $Girocco::Config::reporoot."/$name.git");
1244 sub get_full_list {
1245 open my $fd, '<', jailed_file("/etc/group") or die "getting project list failed: $!";
1246 my @projects = map {/^([^:_\s#][^:\s#]*):[^:]*:\d{5,}:/ ? $1 : ()} <$fd>;
1247 close $fd;
1248 @projects;