diff --git a/add.cgi b/add.cgi index 1472a18..2a32073 100755 --- a/add.cgi +++ b/add.cgi @@ -1,5 +1,9 @@ #!/usr/local/bin/perl # Create one Git repository +use strict; +use warnings; +our (%access, %text, %in); +our $module_name; require './virtualmin-git-lib.pl'; &ReadParse(); @@ -7,12 +11,13 @@ require './virtualmin-git-lib.pl'; # Validate inputs &error_setup($text{'add_err'}); $in{'rep'} =~ /^[a-z0-9\.\-\_]+$/i || &error($text{'add_erep'}); -$dom = &virtual_server::get_domain($in{'dom'}); +my $dom = &virtual_server::get_domain($in{'dom'}); &can_edit_domain($dom) || &error($text{'add_edom'}); # Check limit on repositories +my @reps; if ($access{'max'}) { - foreach $d (&virtual_server::list_domains()) { + foreach my $d (&virtual_server::list_domains()) { next if (!$d->{$module_name}); next if (!&can_edit_domain($d)); push(@reps, &list_reps($d)); @@ -21,22 +26,23 @@ if ($access{'max'}) { } # Run the create command -$rep = { 'rep' => $in{'rep'} }; -$err = &create_rep($dom, $rep, $in{'desc'}, $in{'anon'}); +my $rep = { 'rep' => $in{'rep'} }; +my $err = &create_rep($dom, $rep, $in{'desc'}, $in{'anon'}); &error("
$err") if ($err); # Grant selected users -@grants = split(/\r?\n/, $in{'users'}); -%already = map { $_->{'user'}, $_ } &list_users($dom); -@domusers = &virtual_server::list_domain_users($dom, 0, 1, 1, 1); +my @grants = split(/\r?\n/, $in{'users'}); +my %already = map { $_->{'user'}, $_ } &list_users($dom); +my @domusers = &virtual_server::list_domain_users($dom, 0, 1, 1, 1); -foreach $uname (@grants) { +my @repousers; +foreach my $uname (@grants) { if (!$already{$uname}) { # Need to create the user - ($domuser) = grep { &virtual_server::remove_userdom( + my ($domuser) = grep { &virtual_server::remove_userdom( $_->{'user'}, $dom) eq $uname } @domusers; next if (!$domuser); - local $newuser = { 'user' => $uname, + my $newuser = { 'user' => $uname, 'enabled' => 1 }; &set_user_password($newuser, $domuser, $dom); &virtual_server::write_as_domain_user($dom, diff --git a/delete.cgi b/delete.cgi index 4d277dc..862c0b3 100755 --- a/delete.cgi +++ b/delete.cgi @@ -1,19 +1,22 @@ #!/usr/local/bin/perl # Delete one Git repository +use strict; +use warnings; +our (%text, %in); require './virtualmin-git-lib.pl'; &ReadParse(); # Get the domain and repository -($repdom) = grep { $_ ne "confirm" && $_ ne "show" } (keys %in); -($repname, $id) = split(/\@/, $repdom); -$dom = &virtual_server::get_domain($id); +my ($repdom) = grep { $_ ne "confirm" && $_ ne "show" } (keys %in); +my ($repname, $id) = split(/\@/, $repdom); +my $dom = &virtual_server::get_domain($id); &can_edit_domain($dom) || &error($text{'add_edom'}); -@reps = &list_reps($dom); -($rep) = grep { $_->{'rep'} eq $repname } @reps; +my @reps = &list_reps($dom); +my ($rep) = grep { $_->{'rep'} eq $repname } @reps; $rep || &error($text{'delete_erep'}); -$button = $in{$repdom}; +my $button = $in{$repdom}; if ($button eq &entities_to_ascii($text{'delete'})) { # Deleting repo if ($in{'confirm'}) { @@ -29,7 +32,7 @@ if ($button eq &entities_to_ascii($text{'delete'})) { $text{'delete_title'}, ""); print "
$out")); @@ -405,7 +414,7 @@ sub feature_backup &unlink_file($temp); # Copy users file -local $pfile = &passwd_file($_[0]); +my $pfile = &passwd_file($_[0]); if (!-r $pfile) { &$virtual_server::second_print($text{'feat_nopfile'}); return 0; @@ -420,14 +429,14 @@ sub feature_backup # Restore Git repositories and the users file sub feature_restore { -local ($d, $file, $opts) = @_; +my ($d, $file, $opts) = @_; &$virtual_server::first_print($text{'feat_restore'}); # Extract tar file of repositories (deleting old ones first) -local $phd = &virtual_server::public_html_dir($d); -local $tar = &virtual_server::get_tar_command(); +my $phd = &virtual_server::public_html_dir($d); +my $tar = &virtual_server::get_tar_command(); &execute_command("rm -rf ".quotemeta("$phd/git")."/*"); -local ($out, $ex) = &virtual_server::run_as_domain_user($d, +my ($out, $ex) = &virtual_server::run_as_domain_user($d, "cd ".quotemeta("$phd/git")." && $tar xf ".quotemeta($file)." 2>&1"); if ($ex) { &$virtual_server::second_print(&text('feat_untar', "
$out")); @@ -440,11 +449,11 @@ sub feature_restore } # Copy users file -local $pfile = &passwd_file($d); -local ($ok, $out) = &virtual_server::copy_source_dest_as_domain_user( +my $pfile = &passwd_file($d); +my ($ok, $uout) = &virtual_server::copy_source_dest_as_domain_user( $d, $file."_users", $pfile); if (!$ok) { - &$virtual_server::second_print(&text('feat_copypfile2', $out)); + &$virtual_server::second_print(&text('feat_copypfile2', $uout)); return 0; } @@ -462,16 +471,16 @@ sub feature_backup_name # an error message if any problem is found sub feature_validate { -local ($d) = @_; -local $passwd_file = &passwd_file($d); +my ($d) = @_; +my $passwd_file = &passwd_file($d); -r $passwd_file || return &text('feat_evalidatefile', "$passwd_file"); -local ($virt, $vconf) = &virtual_server::get_apache_virtual($d->{'dom'}, $port); +my ($virt, $vconf) = &virtual_server::get_apache_virtual($d->{'dom'}); $virt || return &virtual_server::text('validate_eweb', $d->{'dom'}); -local $lref = &read_file_lines($virt->{'file'}); -local ($locstart, $locend) = +my $lref = &read_file_lines($virt->{'file'}); +my ($locstart, $locend) = &find_git_lines($lref, $virt->{'line'}, $virt->{'eline'}); $locstart || return &text('feat_evalidateloc'); -local $phd = &virtual_server::public_html_dir($d); +my $phd = &virtual_server::public_html_dir($d); -d "$phd/git" || return &text('feat_evalidategit', "$phd/git"); return undef; } @@ -481,25 +490,27 @@ sub feature_validate # formatted to appear inside a table. sub mailbox_inputs { -local ($user, $new, $dom) = @_; +my ($user, $new, $dom) = @_; return undef if (!$dom || !$dom->{$module_name}); -local $un = &virtual_server::remove_userdom($user->{'user'}, $dom); -local $suser; +my $un = &virtual_server::remove_userdom($user->{'user'}, $dom); +my $suser; if (!$new) { - local @users = &list_users($dom); + my @users = &list_users($dom); ($suser) = grep { $_->{'user'} eq $un } @users; } -local $main::ui_table_cols = 2; -local @reps = &list_reps($dom); -local @rwreps; -foreach $r (@reps) { - local @rusers = &list_rep_users($dom, $r); - local ($ruser) = grep { $_->{'user'} eq $un } @rusers; +no warnings "once"; +$main::ui_table_cols = 2; +use warnings "once"; +my @reps = &list_reps($dom); +my @rwreps; +foreach my $r (@reps) { + my @rusers = &list_rep_users($dom, $r); + my ($ruser) = grep { $_->{'user'} eq $un } @rusers; if ($ruser) { push(@rwreps, $r->{'rep'}); } } -local %defs; +my %defs; &read_file("$module_config_directory/defaults.$dom->{'id'}", \%defs); if (!$suser && !@rwreps) { # Use default repositories @@ -507,12 +518,12 @@ sub mailbox_inputs } @rwreps = sort { $a cmp $b } @rwreps; @reps = sort { $a->{'rep'} cmp $b->{'rep'} } @reps; -local @inputs = ( $input_name."_rwreps_opts", $input_name."_rwreps_vals", +my @inputs = ( $input_name."_rwreps_opts", $input_name."_rwreps_vals", $input_name."_rwreps_add", $input_name."_rwreps_remove" ); -local $hasuser = $suser || $new && $defs{'git'}; -local $dis = $hasuser ? 0 : 1; -local $jsenable = &js_disable_inputs([ ], \@inputs, "onClick"); -local $jsdisable = &js_disable_inputs(\@inputs, [ ], "onClick"); +my $hasuser = $suser || $new && $defs{'git'}; +my $dis = $hasuser ? 0 : 1; +my $jsenable = &js_disable_inputs([ ], \@inputs, "onClick"); +my $jsdisable = &js_disable_inputs(\@inputs, [ ], "onClick"); return &ui_table_row(&hlink($text{'mail_git'}, "git"), &ui_radio($input_name, $hasuser ? 1 : 0, [ [ 1, $text{'yes'}, $jsenable ], @@ -531,17 +542,17 @@ sub mailbox_inputs # success or an error message sub mailbox_validate { -local ($user, $olduser, $in, $new, $dom) = @_; +my ($user, $olduser, $in, $new, $dom) = @_; return undef if (!$dom || !$dom->{$module_name}); if ($in->{$input_name}) { - local @users = &list_users($dom); - local $un = &virtual_server::remove_userdom($user->{'user'}, $dom); - local $oun = &virtual_server::remove_userdom($olduser->{'user'}, $dom); - local ($suser) = grep { $_->{'user'} eq $oun } @users; + my @users = &list_users($dom); + my $un = &virtual_server::remove_userdom($user->{'user'}, $dom); + my $oun = &virtual_server::remove_userdom($olduser->{'user'}, $dom); + my ($suser) = grep { $_->{'user'} eq $oun } @users; # Make sure Git user doesn't clash if ($new || $user->{'user'} ne $olduser->{'user'}) { - local ($clash) = grep { $_->{'user'} eq $un } @users; + my ($clash) = grep { $_->{'user'} eq $un } @users; return &text('mail_clash', $un) if ($clash); } } @@ -552,14 +563,14 @@ sub mailbox_validate # Updates the user based on inputs generated by mailbox_inputs sub mailbox_save { -local ($user, $olduser, $in, $new, $dom) = @_; +my ($user, $olduser, $in, $new, $dom) = @_; return undef if (!$dom || !$dom->{$module_name}); &foreign_require("htaccess-htpasswd", "htaccess-lib.pl"); -local @users = &list_users($dom); -local $suser; -local $un = &virtual_server::remove_userdom($user->{'user'}, $dom); -local $oun = &virtual_server::remove_userdom($olduser->{'user'}, $dom); -local $rv; +my @users = &list_users($dom); +my $suser; +my $un = &virtual_server::remove_userdom($user->{'user'}, $dom); +my $oun = &virtual_server::remove_userdom($olduser->{'user'}, $dom); +my $rv; &lock_file(&passwd_file($dom)); if (!$new) { @@ -567,7 +578,7 @@ sub mailbox_save } if ($in->{$input_name} && !$suser) { # Add the user - local $newuser = { 'user' => $un, + my $newuser = { 'user' => $un, 'enabled' => 1 }; &set_user_password($newuser, $user, $dom); &virtual_server::write_as_domain_user($dom, @@ -596,13 +607,13 @@ sub mailbox_save &unlock_file(&passwd_file($dom)); # Update list of repositories user has access to -local %canrwreps = map { $_, 1 } split(/\r?\n/, $in->{$input_name."_rwreps"}); +my %canrwreps = map { $_, 1 } split(/\r?\n/, $in->{$input_name."_rwreps"}); if (!$in->{$input_name}) { %canrwreps = ( ); } foreach my $r (&list_reps($dom)) { - local @rusers = &list_rep_users($dom, $r); - local ($ruser) = grep { $_->{'user'} eq $oun } @rusers; + my @rusers = &list_rep_users($dom, $r); + my ($ruser) = grep { $_->{'user'} eq $oun } @rusers; @rusers = grep { $_ ne $ruser } @rusers; if ($canrwreps{$r->{'rep'}}) { push(@rusers, { 'user' => $un, @@ -621,13 +632,13 @@ sub mailbox_save # Called when a user is modified by some method other than the edit user form sub mailbox_modify { -local ($user, $olduser, $dom) = @_; +my ($user, $olduser, $dom) = @_; return undef if (!$dom || !$dom->{$module_name}); &foreign_require("htaccess-htpasswd", "htaccess-lib.pl"); -local @users = &list_users($dom); -local $un = &virtual_server::remove_userdom($user->{'user'}, $dom); -local $oun = &virtual_server::remove_userdom($olduser->{'user'}, $dom); -local ($suser) = grep { $_->{'user'} eq $oun } @users; +my @users = &list_users($dom); +my $un = &virtual_server::remove_userdom($user->{'user'}, $dom); +my $oun = &virtual_server::remove_userdom($olduser->{'user'}, $dom); +my ($suser) = grep { $_->{'user'} eq $oun } @users; return undef if (!$suser); &lock_file(&passwd_file($dom)); @@ -637,8 +648,8 @@ sub mailbox_modify $suser->{'user'} = $un; &htaccess_htpasswd::modify_user($suser); foreach my $r (&list_reps($dom)) { - local @rusers = &list_rep_users($dom, $r->{'rep'}); - local ($ruser) = grep { $_->{'user'} eq $oun } @rusers; + my @rusers = &list_rep_users($dom, $r->{'rep'}); + my ($ruser) = grep { $_->{'user'} eq $oun } @rusers; if ($ruser) { $ruser->{'user'} = $un; &save_rep_users($dom, $r, \@rusers); @@ -661,24 +672,24 @@ sub mailbox_modify # Removes any extra features for this user sub mailbox_delete { -local ($user, $dom) = @_; +my ($user, $dom) = @_; return undef if (!$dom || !$dom->{$module_name}); &foreign_require("htaccess-htpasswd", "htaccess-lib.pl"); &lock_file(&passwd_file($dom)); -local @users = &list_users($dom); -local $un = &virtual_server::remove_userdom($user->{'user'}, $dom); -local ($suser) = grep { $_->{'user'} eq $un } @users; +my @users = &list_users($dom); +my $un = &virtual_server::remove_userdom($user->{'user'}, $dom); +my ($suser) = grep { $_->{'user'} eq $un } @users; if ($suser) { &virtual_server::write_as_domain_user($dom, sub { &htaccess_htpasswd::delete_user($suser) }); } # Remove from all repositories -foreach $r (&list_reps($dom)) { - local @rusers = &list_rep_users($dom, $r->{'rep'}); - local ($ruser) = grep { $_->{'user'} eq $un } @rusers; - local @newrusers = grep { $_ ne $ruser } @rusers; +foreach my $r (&list_reps($dom)) { + my @rusers = &list_rep_users($dom, $r->{'rep'}); + my ($ruser) = grep { $_->{'user'} eq $un } @rusers; + my @newrusers = grep { $_ ne $ruser } @rusers; if (@newrusers != @rusers) { &save_rep_users($dom, $r, \@newrusers); } @@ -689,9 +700,10 @@ sub mailbox_delete # mailbox_header(&domain) # Returns a column header for the user display, or undef for none +my @column_users; # XXX whiff. sub mailbox_header { -local ($d) = @_; +my ($d) = @_; if ($d->{$module_name}) { @column_users = &list_users($d); return $text{'mail_header'}; @@ -705,9 +717,9 @@ sub mailbox_header # Returns the text to display in the column for some user sub mailbox_column { -local ($user, $dom) = @_; -local $un = &virtual_server::remove_userdom($user->{'user'}, $dom); -local ($duser) = grep { $_->{'user'} eq $un } @column_users; +my ($user, $dom) = @_; +my $un = &virtual_server::remove_userdom($user->{'user'}, $dom); +my ($duser) = grep { $_->{'user'} eq $un } @column_users; return $duser ? $text{'yes'} : $text{'no'}; return undef; } @@ -717,11 +729,11 @@ sub mailbox_column # users in this virtual server sub mailbox_defaults_inputs { -local ($defs, $dom) = @_; +my ($defs, $dom) = @_; if ($dom->{$module_name}) { - local %defs; + my %defs; &read_file("$module_config_directory/defaults.$dom->{'id'}", \%defs); - local @reps = &list_reps($dom); + my @reps = &list_reps($dom); return &ui_table_row($text{'mail_git'}, &ui_yesno_radio($input_name, int($defs{'git'})))."\n". &ui_table_row($text{'mail_reps'}, @@ -737,9 +749,9 @@ sub mailbox_defaults_inputs # file internal to this module to store them sub mailbox_defaults_parse { -local ($defs, $dom, $in) = @_; +my ($defs, $dom, $in) = @_; if ($dom->{$module_name}) { - local %defs; + my %defs; &read_file("$module_config_directory/defaults.$dom->{'id'}", \%defs); $defs{'git'} = $in->{$input_name}; $defs{'reps'} = join(" ", split(/\0/, $in->{$input_name."_reps"})); @@ -751,8 +763,8 @@ sub mailbox_defaults_parse # Returns HTML for editing per-template options for this plugin sub template_input { -local ($tmpl) = @_; -local $v = $tmpl->{$module_name."limit"}; +my ($tmpl) = @_; +my $v = $tmpl->{$module_name."limit"}; $v = "none" if (!defined($v) && $tmpl->{'default'}); return &ui_table_row($text{'tmpl_limit'}, &ui_radio($input_name."_mode", @@ -768,7 +780,7 @@ sub template_input # template_input. All template fields must start with the module name. sub template_parse { -local ($tmpl, $in) = @_; +my ($tmpl, $in) = @_; if ($in->{$input_name.'_mode'} == 0) { $tmpl->{$module_name."limit"} = ""; } diff --git a/virtualmin-git-lib.pl b/virtualmin-git-lib.pl index 8e306bc..51f7f3a 100644 --- a/virtualmin-git-lib.pl +++ b/virtualmin-git-lib.pl @@ -1,13 +1,17 @@ +use strict; +use warnings; +our %config; +our $module_root_directory; BEGIN { push(@INC, ".."); }; eval "use WebminCore;"; &init_config(); &foreign_require("virtual-server", "virtual-server-lib.pl"); -%access = &get_module_acl(); +my %access = &get_module_acl(); sub can_edit_domain { -local ($d) = @_; +my ($d) = @_; return &virtual_server::can_edit_domain($d); } @@ -15,20 +19,20 @@ sub can_edit_domain # Returns a list of all repositories in some domain sub list_reps { -local ($d) = @_; -local @rv; -local $dir = &virtual_server::public_html_dir($d)."/git"; -opendir(DIR, $dir); -while(my $f = readdir(DIR)) { +my ($d) = @_; +my @rv; +my $dir = &virtual_server::public_html_dir($d)."/git"; +opendir(my $DIR, $dir); +while(my $f = readdir($DIR)) { if ($f =~ /^(\S+)\.git$/) { - local $rep = { 'dom' => $d, - 'rep' => $1, - 'dir' => "$dir/$f" }; + my $rep = { 'dom' => $d, + 'rep' => $1, + 'dir' => "$dir/$f" }; $rep->{'desc'} = &virtual_server::read_file_contents_as_domain_user($d, $rep->{'dir'}."/description"); push(@rv, $rep); } } -closedir(DIR); +closedir($DIR); return @rv; } @@ -43,7 +47,7 @@ sub git_check # Returns the path to the Git password file for a domain sub passwd_file { -local ($d) = @_; +my ($d) = @_; if ($config{'passfile'}) { return "$d->{'home'}/$config{'passfile'}"; } @@ -56,8 +60,8 @@ sub passwd_file # Creates a new Git repository in some domain sub create_rep { -local ($d, $rep, $desc, $anon) = @_; -local $git = &has_command($config{'git'}); +my ($d, $rep, $desc, $anon) = @_; +my $git = &has_command($config{'git'}); $git || return "Git command $config{'git'} was not found!"; # Make the dir and setup a repo in it @@ -65,8 +69,8 @@ sub create_rep if (!-d $rep->{'dir'}) { &virtual_server::make_dir_as_domain_user($d, $rep->{'dir'}); } -local $cmd = "cd ".quotemeta($rep->{'dir'})." && $git --bare init"; -local ($out, $ex) = &virtual_server::run_as_domain_user($d, $cmd); +my $cmd = "cd ".quotemeta($rep->{'dir'})." && $git --bare init"; +my ($out, $ex) = &virtual_server::run_as_domain_user($d, $cmd); if ($ex) { return $out; } @@ -79,23 +83,25 @@ sub create_rep &virtual_server::release_lock_web($d); # Run update-server-info as Apache -local $webuser = &virtual_server::get_apache_user($d); -local $qdir = quotemeta($rep->{'dir'}); +my $webuser = &virtual_server::get_apache_user($d); +my $qdir = quotemeta($rep->{'dir'}); &system_logged(&command_as_user($webuser, 0, "cd $qdir && $git update-server-info")); # Set description file if ($desc) { - local $descfile = "$rep->{'dir'}/description"; + my $descfile = "$rep->{'dir'}/description"; + no strict "subs"; &virtual_server::open_tempfile_as_domain_user($d, DESC, ">$descfile"); &print_tempfile(DESC, $desc."\n"); &virtual_server::close_tempfile_as_domain_user($d, DESC); + use strict "subs"; } # Set domain owner name in config file -local $cfile = "$rep->{'dir'}/config"; +my $cfile = "$rep->{'dir'}/config"; if (-r $cfile) { - local $lref = &virtual_server::read_file_lines_as_domain_user( + my $lref = &virtual_server::read_file_lines_as_domain_user( $d, $cfile); push(@$lref, "", "[gitweb]", "\towner=$d->{'user'}"); &virtual_server::flush_file_lines_as_domain_user($d, $cfile); @@ -147,7 +153,7 @@ sub find_gitweb # Returns the paths to additional files needed by gitweb sub find_gitweb_data { -local @files = ( "git-favicon.png", "git-logo.png", "gitweb.css" ); +my @files = ( "git-favicon.png", "git-logo.png", "gitweb.css" ); foreach my $p ("/var/www/git", # CentOS "/var/www", # Ubuntu $module_root_directory) { @@ -163,10 +169,10 @@ sub find_gitweb_data # written by SVN sub set_rep_permissions { -local ($d, $rep) = @_; -local $qdir = quotemeta($rep->{'dir'}); -local $webuser = &virtual_server::get_apache_user($d); -local @uinfo = getpwnam($webuser); +my ($d, $rep) = @_; +my $qdir = quotemeta($rep->{'dir'}); +my $webuser = &virtual_server::get_apache_user($d); +my @uinfo = getpwnam($webuser); &virtual_server::run_as_domain_user($d, "chmod -R 770 $qdir"); &system_logged("chown -R $uinfo[2] $qdir"); } @@ -175,7 +181,7 @@ sub set_rep_permissions # Delete a Git repository's directory sub delete_rep { -local ($d, $rep) = @_; +my ($d, $rep) = @_; &unlink_logged($rep->{'dir'}); &virtual_server::obtain_lock_web($d); &remove_git_repo_directives($d, $d->{'web_port'}, $rep); @@ -187,9 +193,9 @@ sub delete_rep # Returns a list of htaccess user hashes for Git in some domain sub list_users { -local ($d) = @_; +my ($d) = @_; &foreign_require("htaccess-htpasswd", "htaccess-lib.pl"); -local $users = &htaccess_htpasswd::list_users(&passwd_file($d)); +my $users = &htaccess_htpasswd::list_users(&passwd_file($d)); return @$users; } @@ -197,20 +203,20 @@ sub list_users # Returns a list of user hashes with access to some repo sub list_rep_users { -local ($d, $rep) = @_; -local ($virt, $vconf) = &virtual_server::get_apache_virtual($d->{'dom'}, +my ($d, $rep) = @_; +my ($virt, $vconf) = &virtual_server::get_apache_virtual($d->{'dom'}, $d->{'web_port'}); return () if (!$virt); -local @locs = &apache::find_directive_struct("Location", $vconf); -local ($reploc) = grep { $_->{'words'}->[0] eq "/git/".$rep->{'rep'}.".git" } +my @locs = &apache::find_directive_struct("Location", $vconf); +my ($reploc) = grep { $_->{'words'}->[0] eq "/git/".$rep->{'rep'}.".git" } @locs; return () if (!$reploc); -local ($limitloc) = &apache::find_directive_struct("LimitExcept", +my ($limitloc) = &apache::find_directive_struct("LimitExcept", $reploc->{'members'}); -local $req = &apache::find_directive_struct("Require", +my $req = &apache::find_directive_struct("Require", $limitloc ? $limitloc->{'members'} : $reploc->{'members'}); return () if (!$req); -local @usernames = @{$req->{'words'}}; +my @usernames = @{$req->{'words'}}; shift(@usernames); return map { { 'user' => $_ } } @usernames; } @@ -219,19 +225,19 @@ sub list_rep_users # Updates the list of users for some repository sub save_rep_users { -local ($d, $rep, $users) = @_; -local @usernames = map { $_->{'user'} } @$users; -local @ports = ( $d->{'web_port'} ); +my ($d, $rep, $users) = @_; +my @usernames = map { $_->{'user'} } @$users; +my @ports = ( $d->{'web_port'} ); push(@ports, $d->{'web_sslport'}) if ($d->{'ssl'}); foreach my $p (@ports) { - local ($virt, $vconf, $conf) = + my ($virt, $vconf, $conf) = &virtual_server::get_apache_virtual($d->{'dom'}, $p); next if (!$virt); - local @locs = &apache::find_directive_struct("Location", $vconf); - local ($reploc) = grep { $_->{'words'}->[0] eq + my @locs = &apache::find_directive_struct("Location", $vconf); + my ($reploc) = grep { $_->{'words'}->[0] eq "/git/".$rep->{'rep'}.".git" } @locs; next if (!$reploc); - local ($limitloc) = &apache::find_directive_struct( + my ($limitloc) = &apache::find_directive_struct( "LimitExcept", $reploc->{'members'}); &apache::save_directive("Require", [ "user ".join(" ", @usernames) ], $limitloc ? $limitloc->{'members'} @@ -251,13 +257,13 @@ sub restart_apache_null # Add Apache directives for DAV access to some path under /git sub add_git_repo_directives { -local ($d, $port, $rep, $anon) = @_; -local ($virt, $vconf) = &virtual_server::get_apache_virtual($d->{'dom'}, $port); +my ($d, $port, $rep, $anon) = @_; +my ($virt, $vconf) = &virtual_server::get_apache_virtual($d->{'dom'}, $port); if ($virt) { - local $lref = &read_file_lines($virt->{'file'}); - local ($locstart, $locend) = + my $lref = &read_file_lines($virt->{'file'}); + my ($locstart, $locend) = &find_git_repo_lines($lref, $virt->{'line'}, $virt->{'eline'}, $rep); - local @lines; + my @lines; if (!$locstart) { push(@lines, "