avoid silly 'unsuccessful stat on filename with \n' warning
[girocco.git] / Girocco / Project.pm
blob6b93471f218dd19851649e1a1dfe30f82f7a443b
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::ProjPerm;
11 use Girocco::Config;
12 use base ('Girocco::ProjPerm::'.$Girocco::Config::permission_control); # mwahaha
15 BEGIN {
16 eval {
17 require Digest::SHA;
18 Digest::SHA->import(
19 qw(sha1_hex)
20 );1} ||
21 eval {
22 require Digest::SHA1;
23 Digest::SHA1->import(
24 qw(sha1_hex)
25 );1} ||
26 eval {
27 require Digest::SHA::PurePerl;
28 Digest::SHA::PurePerl->import(
29 qw(sha1_hex)
30 );1} ||
31 die "One of Digest::SHA or Digest::SHA1 or Digest::SHA::PurePerl "
32 . "must be available\n";
35 our $metadata_fields = {
36 homepage => ['Homepage URL', 'hp', 'text'],
37 shortdesc => ['Short description', 'desc', 'text'],
38 README => ['README (HTML, lt 8kb)', 'README', 'textarea'],
39 notifymail => ['Commit notify - mail to', 'notifymail', 'text'],
40 notifyjson => ['Commit notify - <a href="http://help.github.com/post-receive-hooks/">POST JSON</a> at', 'notifyjson', 'text'],
41 notifycia => ['Commit notify - <a href="http://cia.vc/doc/">CIA project</a> name', 'notifycia', 'text'],
44 sub _mkdir_forkees {
45 my $self = shift;
46 my @pelems = split('/', $self->{name});
47 pop @pelems; # do not create dir for the project itself
48 my $path = $self->{base_path};
49 foreach my $pelem (@pelems) {
50 $path .= "/$pelem";
51 (-d "$path") or mkdir $path or die "mkdir $path: $!";
52 chmod 02775, $path; # ok if fails (dir may already exist and be owned by someone else)
56 our %propmap = (
57 url => ':baseurl',
58 email => ':owner',
59 desc => 'description',
60 README => 'README.html',
61 hp => ':homepage',
62 notifymail => '%hooks.mailinglist',
63 notifytag => '%hooks.announcelist',
64 notifyjson => '%hooks.jsonurl',
65 notifycia => '%hooks.cianame',
68 our %propmapro = (
69 lastchange => ':lastchange',
72 sub _update_index {
73 system($Girocco::Config::basedir . '/gitweb/genindex.sh');
76 sub _property_path {
77 my $self = shift;
78 my ($name) = @_;
79 $self->{path}.'/'.$name;
82 sub _property_fget {
83 my $self = shift;
84 my ($name) = @_;
85 my $pname = $propmap{$name};
86 $pname = $propmapro{$name} unless $pname;
87 $pname or die "unknown property: $name";
88 if ($pname =~ s/^://) {
89 my $val = `git --git-dir="$self->{path}" config "gitweb.$pname"`;
90 chomp $val;
91 return $val;
92 } elsif ($pname =~ s/^%//) {
93 my $val = `git --git-dir="$self->{path}" config "$pname"`;
94 chomp $val;
95 return $val;
98 open P, '<', $self->_property_path($pname) or return undef;
99 my @value = <P>;
100 close P;
101 my $value = join('', @value); chomp $value;
102 $value;
105 sub _property_fput {
106 my $self = shift;
107 my ($name, $value) = @_;
108 my $pname = $propmap{$name};
109 $pname or die "unknown property: $name";
110 $value ||= '';
111 if ($pname =~ s/^://) {
112 system('git', '--git-dir='.$self->{path}, 'config', "gitweb.$pname", $value);
113 return;
114 } elsif ($pname =~ s/^%//) {
115 system('git', '--git-dir='.$self->{path}, 'config', $pname, $value);
116 return;
119 my $P = lock_file($self->_property_path($pname));
120 $value ne '' and print $P "$value\n";
121 close $P;
122 unlock_file($self->_property_path($pname));
125 sub _properties_load {
126 my $self = shift;
127 foreach my $prop (keys %propmap) {
128 $self->{$prop} = $self->_property_fget($prop);
130 foreach my $prop (keys %propmapro) {
131 $self->{$prop} = $self->_property_fget($prop);
133 my $val = `git --git-dir="$self->{path}" config --bool "gitweb.statusupdates" 2>/dev/null`;
134 chomp $val;
135 $val = ($val eq 'false') ? 0 : 1;
136 $self->{statusupdates} = $val;
137 delete $self->{auth};
138 $val = `git --git-dir="$self->{path}" config "gitweb.delauth"`;
139 chomp $val;
140 if ($val =~ /^# DELAUTH ([0-9a-f]+) (\d+)/) {
141 my $expire = $2;
142 $self->{auth} = $1 unless (time >= $expire);
146 sub _properties_save {
147 my $self = shift;
148 foreach my $prop (keys %propmap) {
149 $self->_property_fput($prop, $self->{$prop});
151 $self->{statusupdates} = 1
152 unless defined($self->{statusupdates}) && $self->{statusupdates} =~ /^\d+$/;
153 system('git', '--git-dir='.$self->{path}, 'config', '--bool',
154 "gitweb.statusupdates", $self->{statusupdates});
157 sub _nofetch_path {
158 my $self = shift;
159 $self->_property_path('.nofetch');
162 sub _nofetch {
163 my $self = shift;
164 my ($nofetch) = @_;
165 my $nf = $self->_nofetch_path;
166 if ($nofetch) {
167 open X, '>', $nf or die "nofetch failed: $!";
168 close X;
169 } else {
170 unlink $nf or die "yesfetch failed: $!";
174 sub _clonelog_path {
175 my $self = shift;
176 $self->_property_path('.clonelog');
179 sub _clonefail_path {
180 my $self = shift;
181 $self->_property_path('.clone_failed');
184 sub _clonep_path {
185 my $self = shift;
186 $self->_property_path('.clone_in_progress');
189 sub _clonep {
190 my $self = shift;
191 my ($nofetch) = @_;
192 my $np = $self->_clonep_path;
193 if ($nofetch) {
194 open X, '>', $np or die "clonep failed: $!";
195 close X;
196 } else {
197 unlink $np or die "clonef failed: $!";
200 sub _alternates_setup {
201 my $self = shift;
202 return unless $self->{name} =~ m#/#;
203 my $forkee_name = get_forkee_name($self->{name});
204 my $forkee_path = get_forkee_path($self->{name});
205 return unless -d $forkee_path;
206 mkdir $self->{path}.'/refs'; chmod 02775, $self->{path}.'/refs';
207 mkdir $self->{path}.'/objects'; chmod 02775, $self->{path}.'/objects';
208 mkdir $self->{path}.'/objects/info'; chmod 02775, $self->{path}.'/objects/info';
210 # We set up both alternates and http_alternates since we cannot use
211 # relative path in alternates - that doesn't work recursively.
213 my $filename = $self->{path}.'/objects/info/alternates';
214 open X, '>', $filename or die "alternates failed: $!";
215 print X "$forkee_path/objects\n";
216 close X;
217 chmod 0664, $filename or warn "cannot chmod $filename: $!";
219 if ($Girocco::Config::httppullurl) {
220 $filename = $self->{path}.'/objects/info/http-alternates';
221 open X, '>', $filename or die "http-alternates failed: $!";
222 my $upfork = $forkee_name;
223 do { print X "$Girocco::Config::httppullurl/$upfork.git/objects\n"; } while ($upfork =~ s#/?.+?$## and $upfork); #
224 close X;
225 chmod 0664, $filename or warn "cannot chmod $filename: $!";
228 # The symlink is problematic since git remote prune will traverse it.
229 #symlink "$forkee_path/refs", $self->{path}.'/refs/forkee';
231 # copy refs from parent project
232 # ownership information is changed by a root cronjob
233 system("cp -pR $forkee_path/refs $self->{path}/");
234 # initialize HEAD, hacky version
235 system("cp $forkee_path/HEAD $self->{path}/HEAD");
238 sub _ctags_setup {
239 my $self = shift;
240 my $perms = $Girocco::Config::permission_control eq 'Hooks' ? 02777 : 02775;
241 mkdir $self->{path}.'/ctags'; chmod $perms, $self->{path}.'/ctags';
244 sub _group_add {
245 my $self = shift;
246 my ($xtra) = @_;
247 $xtra .= join(',', @{$self->{users}});
248 filedb_atomic_append(jailed_file('/etc/group'),
249 join(':', $self->{name}, $self->{crypt}, '\i', $xtra));
252 sub _group_update {
253 my $self = shift;
254 my $xtra = join(',', @{$self->{users}});
255 filedb_atomic_edit(jailed_file('/etc/group'),
256 sub {
257 $_ = $_[0];
258 chomp;
259 if ($self->{name} eq (split /:/)[0]) {
260 # preserve readonly flag
261 s/::([^:]*)$/:$1/ and $xtra = ":$xtra";
262 return join(':', $self->{name}, $self->{crypt}, $self->{gid}, $xtra)."\n";
263 } else {
264 return "$_\n";
270 sub _group_remove {
271 my $self = shift;
272 filedb_atomic_edit(jailed_file('/etc/group'),
273 sub {
274 $self->{name} ne (split /:/)[0] and return $_;
279 sub _hook_path {
280 my $self = shift;
281 my ($name) = @_;
282 $self->{path}.'/hooks/'.$name;
285 sub _hook_install {
286 my $self = shift;
287 my ($name) = @_;
288 open SRC, '<', "$Girocco::Config::basedir/hooks/$name" or die "cannot open hook $name: $!";
289 open DST, '>', $self->_hook_path($name) or die "cannot open hook $name for writing: $!";
290 while (<SRC>) { print DST $_; }
291 close DST;
292 close SRC;
293 chmod 0775, $self->_hook_path($name) or die "cannot chmod hook $name: $!";
296 sub _hooks_install {
297 my $self = shift;
298 foreach my $hook ('post-receive', 'update', 'post-update') {
299 $self->_hook_install($hook);
303 # private constructor, do not use
304 sub _new {
305 my $class = shift;
306 my ($name, $base_path, $path) = @_;
307 valid_name($name) or die "refusing to create project with invalid name ($name)!";
308 $path ||= "$base_path/$name.git";
309 my $proj = { name => $name, base_path => $base_path, path => $path };
311 bless $proj, $class;
314 # public constructor #0
315 # creates a virtual project not connected to disk image
316 # you can conjure() it later to disk
317 sub ghost {
318 my $class = shift;
319 my ($name, $mirror) = @_;
320 my $self = $class->_new($name, $Girocco::Config::reporoot);
321 $self->{users} = [];
322 $self->{mirror} = $mirror;
323 $self->{email} = $self->{orig_email} = '';
324 $self;
327 # public constructor #1
328 sub load {
329 my $class = shift;
330 my $name = shift || '';
332 open F, '<', jailed_file("/etc/group") or die "project load failed: $!";
333 while (<F>) {
334 chomp;
335 @_ = split /:+/;
336 next unless (shift eq $name);
338 my $self = $class->_new($name, $Girocco::Config::reporoot);
339 (-d $self->{path}) or die "invalid path (".$self->{path}.") for project ".$self->{name};
341 my $ulist;
342 ($self->{crypt}, $self->{gid}, $ulist) = @_;
343 $ulist ||= '';
344 $self->{users} = [split /,/, $ulist];
345 $self->{HEAD} = $self->get_HEAD;
346 $self->{orig_HEAD} = $self->{HEAD};
347 $self->{orig_users} = [@{$self->{users}}];
348 $self->{mirror} = ! -e $self->_nofetch_path;
349 $self->{clone_in_progress} = -e $self->_clonep_path;
350 $self->{clone_logged} = -e $self->_clonelog_path;
351 $self->{clone_failed} = -e $self->_clonefail_path;
352 $self->{ccrypt} = $self->{crypt};
354 $self->_properties_load;
355 $self->{orig_email} = $self->{email};
356 return $self;
358 close F;
359 undef;
362 # $proj may not be in sane state if this returns false!
363 sub cgi_fill {
364 my $self = shift;
365 my ($gcgi) = @_;
366 my $cgi = $gcgi->cgi;
368 my ($pwd, $pwd2) = ($cgi->param('pwd'), $cgi->param('pwd2'));
369 $pwd ||= ''; $pwd2 ||= ''; # in case passwords are disabled
370 if ($pwd or not $self->{crypt}) {
371 $self->{crypt} = scrypt($pwd);
374 if ($pwd2 and $pwd ne $pwd2) {
375 $gcgi->err("Our high-paid security consultants have determined that the admin passwords you have entered do not match each other.");
378 $self->{cpwd} = $cgi->param('cpwd');
380 if ($Girocco::Config::project_owners eq 'email') {
381 $self->{email} = $gcgi->wparam('email');
382 valid_email($self->{email})
383 or $gcgi->err("Your email sure looks weird...?");
386 $self->{url} = $gcgi->wparam('url');
387 if ($self->{url}) {
388 valid_repo_url($self->{url})
389 or $gcgi->err("Invalid URL. Note that only HTTP and Git protocol is supported. If the URL contains funny characters, contact me.");
392 $self->{desc} = $gcgi->wparam('desc');
393 length($self->{desc}) <= 1024
394 or $gcgi->err("<b>Short</b> description length &gt; 1kb!");
396 $self->{README} = $gcgi->wparam('README');
397 length($self->{README}) <= 8192
398 or $gcgi->err("README length &gt; 8kb!");
400 $self->{hp} = $gcgi->wparam('hp');
401 if ($self->{hp}) {
402 valid_web_url($self->{hp})
403 or $gcgi->err("Invalid homepage URL. Note that only HTTP protocol is supported. If the URL contains funny characters, contact me.");
406 $self->{users} = [grep { Girocco::User::valid_name($_) && Girocco::User::does_exist($_) } $cgi->param('user')];
408 $self->{HEAD} = $cgi->param('HEAD') if $cgi->param('HEAD');
410 # schedule deletion of tags (will be committed by update() after auth)
411 $self->{tags_to_delete} = [$cgi->param('tags')];
413 $self->{notifymail} = $gcgi->wparam('notifymail');
414 if ($self->{notifymail}) {
415 (valid_email_multi($self->{notifymail}) and length($self->{notifymail}) <= 512)
416 or $gcgi->err("Invalid notify e-mail address. Use mail,mail to specify multiple addresses; total length must not exceed 512 characters, however.");
419 $self->{notifyjson} = $gcgi->wparam('notifyjson');
420 if ($self->{notifyjson}) {
421 valid_web_url($self->{notifyjson})
422 or $gcgi->err("Invalid JSON notify URL. Note that only HTTP protocol is supported. If the URL contains funny characters, contact me.");
425 $self->{notifycia} = $gcgi->wparam('notifycia');
426 if ($self->{notifycia}) {
427 $self->{notifycia} =~ /^[a-zA-Z0-9._-]+$/
428 or $gcgi->err("Overly suspicious CIA notify project name. If it is actually valid, contact me.");
431 if ($cgi->param('setstatusupdates')) {
432 my $val = $gcgi->wparam('statusupdates') || '0';
433 $self->{statusupdates} = $val ? 1 : 0;
436 not $gcgi->err_check;
439 sub form_defaults {
440 my $self = shift;
442 name => $self->{name},
443 email => $self->{email},
444 url => $self->{url},
445 desc => html_esc($self->{desc}),
446 README => html_esc($self->{README}),
447 hp => $self->{hp},
448 users => $self->{users},
449 notifymail => html_esc($self->{notifymail}),
450 notifyjson => html_esc($self->{notifyjson}),
451 notifycia => html_esc($self->{notifycia}),
455 sub authenticate {
456 my $self = shift;
457 my ($gcgi) = @_;
459 $self->{ccrypt} or die "Can't authenticate against a project with no password";
460 $self->{cpwd} ||= '';
461 unless ($self->{ccrypt} eq crypt($self->{cpwd}, $self->{ccrypt})) {
462 $gcgi->err("Your admin password does not match!");
463 return 0;
465 return 1;
468 sub _setup {
469 my $self = shift;
470 my ($pushers) = @_;
472 $self->_mkdir_forkees;
474 mkdir($self->{path}) or die "mkdir $self->{path} failed: $!";
475 if ($Girocco::Config::owning_group) {
476 my $gid = scalar(getgrnam($Girocco::Config::owning_group));
477 chown(-1, $gid, $self->{path}) or die "chgrp $gid $self->{path} failed: $!";
478 chmod(02775, $self->{path}) or die "chmod 2775 $self->{path} failed: $!";
479 } else {
480 chmod(02777, $self->{path}) or die "chmod 2777 $self->{path} failed: $!";
482 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'init', '--bare', '--shared='.$self->shared_mode()) == 0
483 or die "git init $self->{path} failed: $?";
484 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'receive.denyNonFastforwards', 'false') == 0
485 or die "disabling receive.denyNonFastforwards failed: $?";
486 system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'gc.auto', '0') == 0
487 or die "disabling gc.auto failed: $?";
489 # /info must have right permissions,
490 # and git init didn't do it for some reason.
491 if ($Girocco::Config::owning_group) {
492 chmod(02775, $self->{path}."/info") or die "chmod 2775 $self->{path}/info failed: $!";
493 } else {
494 chmod(02777, $self->{path}."/info") or die "chmod 2777 $self->{path}/info failed: $!";
497 $self->_properties_save;
498 $self->_alternates_setup;
499 $self->_ctags_setup;
500 $self->_group_remove;
501 $self->_group_add($pushers);
502 $self->_hooks_install;
503 #$self->perm_initialize;
504 $self->_update_index;
507 sub premirror {
508 my $self = shift;
510 $self->_setup(':');
511 $self->_clonep(1);
512 $self->perm_initialize;
515 sub conjure {
516 my $self = shift;
518 $self->_setup;
519 $self->_nofetch(1);
520 $self->perm_initialize;
523 sub clone {
524 my $self = shift;
526 unlink ($self->_clonefail_path()); # Ignore EEXIST error
527 unlink ($self->_clonelog_path()); # Ignore EEXIST error
529 use IO::Socket;
530 my $sock = IO::Socket::UNIX->new($Girocco::Config::chroot.'/etc/taskd.socket') or die "cannot connect to taskd.socket: $!";
531 $sock->print("clone ".$self->{name}."\n");
532 # Just ignore reply, we are going to succeed anyway and the I/O
533 # would apparently get quite hairy.
534 $sock->flush();
535 sleep 2; # *cough*
536 $sock->close();
539 sub update {
540 my $self = shift;
542 $self->_properties_save;
543 $self->_group_update;
545 if (exists($self->{tags_to_delete})) {
546 $self->delete_ctag($_) foreach(@{$self->{tags_to_delete}});
549 $self->set_HEAD($self->{HEAD}) unless $self->{orig_HEAD} eq $self->{HEAD};
551 my @users_add = grep { $a = $_; not scalar grep { $a eq $_ } $self->{orig_users} } $self->{users};
552 my @users_del = grep { $a = $_; not scalar grep { $a eq $_ } $self->{users} } $self->{orig_users};
553 $self->perm_user_add($_, Girocco::User::resolve_uid($_)) foreach (@users_add);
554 $self->perm_user_del($_, Girocco::User::resolve_uid($_)) foreach (@users_del);
556 $self->_update_index if $self->{email} ne $self->{orig_email};
557 $self->{orig_email} = $self->{email};
562 sub update_password {
563 my $self = shift;
564 my ($pwd) = @_;
566 $self->{crypt} = scrypt($pwd);
567 $self->_group_update;
570 # You can explicitly do this just on a ghost() repository too.
571 sub delete {
572 my $self = shift;
574 if (-d $self->{path}) {
575 system('rm', '-rf', $self->{path}) == 0
576 or die "rm -rf $self->{path} failed: $?";
578 # attempt to clean up any empty fork directories by removing them
579 my @pelems = split('/', $self->{name});
580 while (@pelems > 1) {
581 pop @pelems;
582 # okay to fail
583 rmdir join('/', $Girocco::Config::reporoot, @pelems) or last;
585 $self->_group_remove;
586 $self->_update_index;
589 sub _contains_files {
590 my $dir = shift;
591 (-d $dir) or return 0;
592 opendir(my $dh, $dir) or die "opendir $dir failed: $!";
593 while (my $entry = readdir($dh)) {
594 next if $entry eq '' || $entry eq '.' || $entry eq '..';
595 closedir($dh), return 1
596 if -f "$dir/$entry" ||
597 -d "$dir/$entry" && _contains_files("$dir/$entry");
599 closedir($dh);
600 return 0;
603 sub has_forks {
604 my $self = shift;
606 return _contains_files($Girocco::Config::reporoot.'/'.$self->{name});
609 sub is_empty {
610 # A project is considered empty if the git repository does not
611 # have any refs. This means packed-refs does not exist or is
612 # empty or only has lines starting with '#' AND there are no
613 # files in the refs subdirectory hierarchy (no matter how deep).
615 my $self = shift;
617 (-d $self->{path}) or return 0;
618 if (-e $self->{path}.'/packed-refs') {
619 open(my $pr, '<', $self->{path}.'/packed-refs')
620 or die "open $self->{path}./packed-refs failed: $!";
621 my $foundref = 0;
622 while (my $ref = <$pr>) {
623 next if $ref =~ /^#/;
624 $foundref = 1;
625 last;
627 close($pr);
628 return 0 if $foundref;
630 (-d $self->{path}.'/refs') or return 1;
631 return !_contains_files($self->{path}.'/refs');
634 sub delete_ctag {
635 my $self = shift;
636 my ($ctag) = @_;
638 # sanity check, disallow filenames starting with . .. or /
639 unlink($self->{path}.'/ctags/'.$ctag) if($ctag !~ m|^(\.\.?)/|);
642 sub get_ctag_names {
643 my $self = shift;
644 my @ctags = ();
645 opendir(my $dh, $self->{path}.'/ctags')
646 or return @ctags;
647 @ctags = grep { -f "$self->{path}/ctags/$_" } readdir($dh);
648 closedir($dh);
649 return @ctags;
652 sub get_heads {
653 my $self = shift;
654 my $fh;
655 open($fh, '-|', "$Girocco::Config::git_bin --git-dir=$self->{path} show-ref --heads") or die "could not get list of heads";
656 my @res;
657 while (<$fh>) {
658 chomp;
659 next if !m#^[0-9a-f]{40}\s+refs/heads/(.+)$ #x;
660 push @res, $1;
662 close $fh;
663 @res;
666 sub get_HEAD {
667 my $self = shift;
668 my $HEAD = `$Girocco::Config::git_bin --git-dir=$self->{path} symbolic-ref HEAD`;
669 chomp $HEAD;
670 die "could not get HEAD" if ($HEAD !~ m{^refs/heads/(.+)$});
671 return $1;
674 sub set_HEAD {
675 my $self = shift;
676 my $newHEAD = shift;
677 # Cursory checks only -- if you want to break your HEAD, be my guest
678 if ($newHEAD =~ /^\/|['<>]|\.\.|\/$/) {
679 die "grossly invalid new HEAD: $newHEAD";
681 system($Girocco::Config::git_bin, "--git-dir=$self->{path}", 'symbolic-ref', 'HEAD', "refs/heads/$newHEAD");
682 die "could not set HEAD" if ($? >> 8);
685 sub gen_auth {
686 my $self = shift;
689 no warnings;
690 $self->{auth} = sha1_hex(time . $$ . rand() . join(':',%$self));
692 my $expire = time + 24 * 3600;
693 my $propval = "# DELAUTH $self->{auth} $expire";
694 system('git', '--git-dir='.$self->{path}, 'config', 'gitweb.delauth', $propval);
695 $self->{auth};
698 sub del_auth {
699 my $self = shift;
701 delete $self->{auth};
702 system('git', '--git-dir='.$self->{path}, 'config', '--unset', 'gitweb.delauth');
705 sub remove_user {
706 my $self = shift;
707 my ($username) = @_;
709 my $before_count = @{$self->{users}};
710 $self->{users} = [grep { $_ ne $username } @{$self->{users}}];
711 return @{$self->{users}} != $before_count;
714 ### static methods
716 sub get_forkee_name {
717 local $_ = $_[0];
718 (m#^(.*)/.*?$#)[0]; #
721 sub get_forkee_path {
722 no warnings; # avoid silly 'unsuccessful stat on filename with \n' warning
723 my $forkee = $Girocco::Config::reporoot.'/'.get_forkee_name($_[0]).'.git';
724 -d $forkee ? $forkee : '';
727 sub valid_name {
728 no warnings; # avoid silly 'unsuccessful stat on filename with \n' warning
729 local $_ = $_[0];
730 (not m#/# or -d get_forkee_path($_)) # will also catch ^/
731 and (not m#\./#)
732 and (not m#/$#)
733 and m#^[a-zA-Z0-9+./_-]+$#;
736 sub does_exist {
737 no warnings; # avoid silly 'unsuccessful stat on filename with \n' warning
738 my ($name) = @_;
739 valid_name($name) or die "tried to query for project with invalid name $name!";
740 (-d $Girocco::Config::reporoot."/$name.git");
743 sub get_full_list {
744 my $class = shift;
745 my @projects;
747 open F, '<', jailed_file("/etc/group") or die "getting project list failed: $!";
748 while (<F>) {
749 chomp;
750 @_ = split /:+/;
751 next if ($_[2] < 65536);
753 push @projects, $_[0];
755 close F;
756 @projects;