install: mkfifo only if the file is not fifo yet
[girocco.git] / Girocco / ProjPerm.pm
blob1a802542ebbd621426e67c3a9ce15bff79636074
1 package Girocco::ProjPerm;
3 # This is base class for various permission models; these control updating
4 # permissions of appropriate files in push-enabled repositories.
5 # The /etc/group file is maintained by Girocco::Project itself.
7 # The chosen subclass of this class is used as base class of Girocco::Project.
9 use strict;
10 use warnings;
12 use Girocco::Config;
14 BEGIN {
15 our @interesting = qw(refs info objects);
18 sub perm_initialize {
19 my ($proj) = @_;
20 die "unimplemented";
23 sub perm_user_add {
24 my ($proj, $username, $uid) = @_;
25 die "unimplemented";
28 sub perm_user_del {
29 my ($proj, $username, $uid) = @_;
30 die "unimplemented";
33 sub shared_mode {
34 my ($proj) = @_;
35 # The --shared= argument for git init
36 die "unimplemented";
42 package Girocco::ProjPerm::Group;
44 # This is the naive permission model: on init, we just chgrp the relevant
45 # pieces to our group and make them group-writable. But oh, we cannot do that
46 # since we are not root; so we just sit happily and do nothing else.
47 # Then, we can just sit happily and do nothing else either.
49 use strict;
50 use warnings;
52 BEGIN {
53 use base qw(Girocco::ProjPerm);
56 sub perm_initialize {
57 my ($proj) = @_;
59 # tell fixupd about the new project
60 open(my $fifo, '>'.$Girocco::Config::fixup_queue) or die "Opening fifo failed: $!";
61 print $fifo $proj->{name};
62 close $fifo;
67 sub perm_user_add {
68 my ($proj, $username, $uid) = @_;
72 sub perm_user_del {
73 my ($proj, $username, $uid) = @_;
77 sub shared_mode {
78 my ($proj) = @_;
79 "group";
85 package Girocco::ProjPerm::Hooks;
87 # This is the "soft-security" permission model: we keep the repository
88 # world-writable and check if the user is allowed to push only within
89 # the update hook that will call our can_user_push() method.
91 use strict;
92 use warnings;
94 BEGIN {
95 use base qw(Girocco::ProjPerm);
98 sub perm_initialize {
99 my ($proj) = @_;
103 sub perm_user_add {
104 my ($proj, $username, $uid) = @_;
108 sub perm_user_del {
109 my ($proj, $username, $uid) = @_;
113 sub shared_mode {
114 my ($proj) = @_;
115 "0777";
118 sub can_user_push {
119 my ($proj, $username) = @_;
120 grep { $_ eq $username } @{$proj->{users}};