From a0862f0fdb997f07f60e257224b970bb76837e2c Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 11 Sep 2008 18:38:12 +0200 Subject: [PATCH] Girocco::Config::project_passwords: Introduce; allow password protection turned off --- Girocco/Config.pm | 6 ++++++ Girocco/Project.pm | 7 ++++--- cgi/delproj.cgi | 6 ++++++ cgi/editproj.cgi | 6 ++++++ cgi/regproj.cgi | 10 +++++++++- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Girocco/Config.pm b/Girocco/Config.pm index 3a65b74..3fa2fc6 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -33,6 +33,12 @@ our $manage_users = 1; # Enable the special 'mob' user if set to 'mob' our $mob = "mob"; +# Let users set admin passwords; if false, all password inputs are assumed empty. +# This will make new projects use empty passwords and all operations on them +# unrestricted, but you will be able to do no operations on previously created +# projects you have set a password on. +our $project_passwords = 1; + ## Paths diff --git a/Girocco/Project.pm b/Girocco/Project.pm index 8e7ad23..194e667 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -274,12 +274,13 @@ sub cgi_fill { my ($gcgi) = @_; my $cgi = $gcgi->cgi; - my $pwd = $cgi->param('pwd'); - if ($pwd ne '' or not $self->{crypt}) { + my ($pwd, $pwd2) = ($cgi->param('pwd'), $cgi->param('pwd2')); + $pwd ||= ''; $pwd2 ||= ''; # in case passwords are disabled + if ($pwd or not $self->{crypt}) { $self->{crypt} = scrypt($pwd); } - if ($cgi->param('pwd2') and $pwd ne $cgi->param('pwd2')) { + if ($pwd2 and $pwd ne $pwd2) { $gcgi->err("Our high-paid security consultants have determined that the admin passwords you have entered do not match each other."); } diff --git a/cgi/delproj.cgi b/cgi/delproj.cgi index 1f0f0e2..4b679f3 100755 --- a/cgi/delproj.cgi +++ b/cgi/delproj.cgi @@ -67,7 +67,13 @@ print <
+EOT +if ($Girocco::Config::project_passwords) { + print <Admin password: (forgot password?)

+EOT +} +print <

EOT diff --git a/cgi/editproj.cgi b/cgi/editproj.cgi index cd22bc7..42bad1d 100755 --- a/cgi/editproj.cgi +++ b/cgi/editproj.cgi @@ -73,12 +73,18 @@ print < Project name:$h{name}.git +EOT +if ($Girocco::Config::project_passwords) { + print <Admin password: (forgot password?) New admin password (twice):
(leave empty to keep it the same)

+EOT +} +print <E-mail contact: EOT diff --git a/cgi/regproj.cgi b/cgi/regproj.cgi index 7839c99..16dfa75 100755 --- a/cgi/regproj.cgi +++ b/cgi/regproj.cgi @@ -142,10 +142,12 @@ push @pwpurp, $me->{pwpurp} if $me; push @pwpurp, $pe->{pwpurp} if $pe; my $pwpurp = join(', ', @pwpurp); -print <You will need the admin password to adjust the project settings later ($pwpurp, project description, ...).

EOT +} unless ($name =~ m#/#) { print < +EOT +if ($Girocco::Config::project_passwords) { + print < +EOT +} +print < $modechooser $mirrorentry -- 2.11.4.GIT
Project name:$forkentry.git
Admin password (twice):
E-mail contact: