[vhffs-dev] [svn] commit: r61 - trunk/vhffs-api/src/Vhffs trunk/vhffs-api/src/Vhffs/Robots trunk/vhffs-api/src/Vhffs/Services trunk/vhffs-backend/src/pgsql trunk/vhffs-panel/svn trunk/vhffs-panel/templates/svn trunk/vhffs-robots/src |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [svn] commit: r61 - trunk/vhffs-api/src/Vhffs trunk/vhffs-api/src/Vhffs/Robots trunk/vhffs-api/src/Vhffs/Services trunk/vhffs-backend/src/pgsql trunk/vhffs-panel/svn trunk/vhffs-panel/templates/svn trunk/vhffs-robots/src
- From: vhffs-dev@xxxxxxxxx
- Date: Tue Jul 19 23:38:44 2005 +00
Author: soda
Date: Wed Jul 20 01:38:41 2005
New Revision: 61
Log:
Improve subversion support
Added:
trunk/vhffs-robots/src/create_svn.pl
- copied unchanged from r52, trunk/vhffs-robots/src/svn_create.pl
trunk/vhffs-robots/src/delete_svn.pl
- copied unchanged from r52, trunk/vhffs-robots/src/svn_delete.pl
Removed:
trunk/vhffs-panel/svn/svn_adduser.pl
trunk/vhffs-panel/svn/svn_chpwd.pl
trunk/vhffs-panel/svn/svn_deleteuser.pl
trunk/vhffs-robots/src/svn_create.pl
trunk/vhffs-robots/src/svn_delete.pl
Modified:
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
trunk/vhffs-api/src/Vhffs/Services/Svn.pm
trunk/vhffs-backend/src/pgsql/create_svn.sql
trunk/vhffs-panel/svn/prefs.pl
trunk/vhffs-panel/svn/prefs_save.pl
trunk/vhffs-panel/templates/svn/prefs.tmpl
trunk/vhffs-robots/src/create_groups.pl
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm Wed Jul 20 01:38:41 2005
@@ -147,8 +147,7 @@
my @files = readdir( DIRECTORY );
foreach $value ( @files )
{
- next if( $value eq "" );
- next if( $value =~ /\./ );
+ next if( $value eq "" );
next if( $value eq ".." );
next if( $value eq "." );
change_owner_recur( $dir . "/" . $value , $uid , $gid);
Modified: trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Svn.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Robots/Svn.pm Wed Jul 20 01:38:41 2005
@@ -17,60 +17,38 @@
return( $request->fetchall_hashref('reponame') );
}
+sub change_conf
+{
+ my $svn = shift;
+ my $file = $svn->get_dir."/conf/svnserve.conf";
+ my @lines;
+ my $line;
+ return -1 if( ! -f $file );
-sub update_users
-{
- use Apache::Htpasswd;
-
- my $main = shift;
- my $svn = shift;
-
- my $dir;
- my $user_file;
-
- if( $svn->fetch > 0 )
- {
- $dir = $svn->get_confdir;
-
- Vhffs::Functions::create_dir( $dir ) if( ! -d $dir );
-
- $user_file = $dir."/users";
-
- my $users = $svn->get_users;
-
- my $passwd;
- my $salt;
-
- open( FILE , ">$user_file" ) or die( "cannot open $user_file" );
-
- foreach( keys %{$users} )
- {
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64];
- $passwd = crypt( $users->{$_}{'password'} , $salt );
-
- print FILE $_.":".$passwd."\n";
+ open( FILE , $file );
+ while( <FILE> )
+ {
+ push( @lines , $_ );
}
-
close( FILE );
- my $apache_file = $dir."/apache";
+ open( FILE , ">$file" );
+ foreach $line ( @lines )
+ {
+ if( $line =~ /.*anon\-access.*/ )
+ {
+ $line = "anon-access = read\n";
+ }
+ print FILE $line;
+ }
+ close( FILE );
- open( FILE , ">$apache_file" ) or die("cannot open user file $user_file");
-
- print FILE "<Location /".$svn->get_group->get_groupname . "/" . $svn->get_reponame.">\n";
- print FILE "DAV svn\n";
- print FILE "SVNPath ".$svn->getdir."\n";
- print FILE "AuthType Basic\n";
- print FILE "AuthName \"Subversion auth\"\n";
- print FILE "AuthUserFile $user_file\n";
- print FILE "Require valid-user\n";
- print FILE "</Location>";
-
- close(FILE);
-
- }
+ $svn->add_history( "Change configuration of SVN repository" );
+
+ return 1;
}
+
sub create_repo
{
@@ -82,15 +60,9 @@
my $apache_file;
my $user_file;
- if( $svn->fetch > 0 )
+ if( ( defined $svn ) && ( $svn->fetch > 0 ) )
{
$dir = $svn->get_dir;
- $dir2 = $svn->get_confdir;
- $apache_file = $dir2."/apache";
- $user_file = $dir2."/users";
-
-
-
if( $svn->get_status == Vhffs::Constants::WAITING_FOR_CREATION )
{
@@ -101,7 +73,9 @@
Vhffs::Functions::create_dir( $dir ) if( ! -d $dir );
$svn->add_history("Ok, robots find the empty directory and will create subversion repository");
system("svnadmin create --fs-type fsfs $dir");
- Vhffs::Functions::change_owner_recur( $dir , $main->get_config->get_svn_uid , $main->get_config->get_svn_gid );
+ Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Functions::change_owner_recur( $dir , $svn->get_owneruid , $svn->get_ownergid );
+ change_conf( $svn );
$svn->add_history("The Robots created the subversion repository");
}
else
@@ -110,29 +84,6 @@
$svn->add_history("Error, directory of this subversion already exists ! Administrators must fix the problem");
}
- if( ! -e $dir2 )
- {
-
- Vhffs::Functions::create_dir( $dir2 ) if( ! -d $dir2 );
-
- open( FILE , ">$apache_file" ) or die("cannot open user file $user_file");
-
- print FILE "<Location /".$svn->get_group->get_groupname . "/" . $svn->get_reponame.">\n";
- print FILE "DAV svn\n";
- print FILE "SVNPath $dir\n";
- print FILE "AuthType Basic\n";
- print FILE "AuthName \"Subversion auth\"\n";
- print FILE "AuthUserFile $user_file\n";
- print FILE "Require valid-user\n";
- print FILE "</Location>";
-
- close(FILE);
- }
- else
- {
- $ok = 0;
- $svn->add_history("Error ! Config for this repository already exists !");
- }
if( $ok == 1 )
@@ -141,11 +92,11 @@
if( $svn->commit < 0 )
{
- $svn->add_history( "Cannot commit changes on the object ! ");
+ $svn->add_history( "Cannot commit changes on the object ! ");
}
else
{
- $svn->add_history( "Subversion repository is now active");
+ $svn->add_history( "Subversion repository is now active");
}
}
else
@@ -172,9 +123,7 @@
if( $svn->fetch > 0 )
{
$dir = $svn->get_dir;
- $dir2 = $svn->get_confdir;
system("rm -rf $dir 2>/dev/null");
- system("rm -rf $dir2 2>/dev/null");
$svn->delete;
}
else
Modified: trunk/vhffs-api/src/Vhffs/Services/Svn.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Svn.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Services/Svn.pm Wed Jul 20 01:38:41 2005
@@ -58,16 +58,9 @@
my $query;
my $request;
-
- $query = "DELETE FROM vhffs_svn_users WHERE svn_id='".$self->{'svn_id'}."'";
- $request = $self->{'db'}->{'DB_WRITE'}->prepare($query);
- $request->execute or return -1;
-
-
$query = "DELETE FROM vhffs_svn WHERE object_id='".$self->{'object_id'}."'";
$request = $self->{'db'}->{'DB_WRITE'}->prepare($query);
$request->execute or return -1;
-
return -1 if( $self->SUPER::delete < 0 );
}
@@ -93,121 +86,20 @@
my $oid = $self->SUPER::create();
if ( $oid lt 0 )
{
- return( -1 );
+ return( -1 );
}
else
{
- $self->{'object_id'} = $oid;
- }
-
-
- #Get the max cvs_id and compute the new cvs_id
- my $svn_id = 1;
- my $resultuid = $self->{'db'}->{'DB_READ'}->selectall_arrayref("SELECT MAX(svn_id) FROM vhffs_svn");
- $svn_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $svn_id++;
-
- $self->{'svn_id'} = $svn_id;
+ $self->{'object_id'} = $oid;
+ }
+
#Finally, create the object
- my $text = "INSERT INTO vhffs_svn VALUES( '".$svn_id."' , '".$self->{'reponame'} . "','".$self->{'user'}->get_uid."','".$self->{'group'}->get_gid."' , '0' , '".$self->{'object_id'}."' )";
+ my $text = "INSERT INTO vhffs_svn (reponame,owner_uid,owner_gid,public,object_id) VALUES( '".$self->{'reponame'} . "','".$self->{'user'}->get_uid."','".$self->{'group'}->get_gid."' , '1' , '".$self->{'object_id'}."' )";
$request = $self->{'db'}->{'DB_WRITE'}->prepare( $text );
$request->execute or return -2;
- return $svn_id;
-}
-
-
-sub del_user
-{
- my $self;
- my $query;
- my $request;
- my $username;
- my $rows;
-
- $self = shift;
- $username = shift;
-
- return -1 if( ! defined $username );
- return -1 if( ! ( $username =~ /^[a-zA-Z0-9]+$/ ) );
-
- $query = "SELECT * FROM vhffs_svn_users WHERE username='".$username."' AND svn_id='".$self->{'svn_id'}."'";
- $request = $self->{'db'}->{'DB_READ'}->prepare( $query );
- $rows = $request->execute;
-
- return -2 if( $rows != 1 );
-
- $query = "DELETE FROM vhffs_svn_users WHERE svn_id='".$self->{'svn_id'}."' AND username='".$username."'";
- $request = $self->{'db'}->{'DB_WRITE'}->prepare( $query );
- $request->execute;
-
- return 1;
-}
-
-
-sub change_pwd
-{
- my $self;
- my $query;
- my $request;
- my $username;
- my $password;
- my $rows;
-
- $self = shift;
- $username = shift;
- $password = shift;
-
- return -1 if( ( ! defined $username ) || ( ! defined $password ) );
- return -1 if( ! ( $username =~ /^[a-zA-Z0-9]+$/ ) );
- return -1 if( ! ( $password =~ /^[a-zA-Z0-9]+$/ ) );
-
-
- $query = "SELECT * FROM vhffs_svn_users WHERE username='".$username."' AND svn_id='".$self->{'svn_id'}."'";
- $request = $self->{'db'}->{'DB_READ'}->prepare( $query );
- $rows = $request->execute;
-
- return -2 if( $rows != 1 );
-
- $query = "UPDATE vhffs_svn_users SET password='".$password."' WHERE svn_id='".$self->{'svn_id'}."' AND username='".$username."'";
- $request = $self->{'db'}->{'DB_WRITE'}->prepare( $query );
- $request->execute;
-
- return 1;
-}
-
-
-
-sub add_user
-{
- my $self;
- my $query;
- my $request;
- my $username;
- my $password;
- my $rows;
-
- $self = shift;
- $username = shift;
- $password = shift;
-
- return -1 if( ( ! defined $username ) || ( ! defined $password ) );
-
- return -1 if( ! ( $username =~ /^[a-zA-Z0-9]+$/ ) );
- return -1 if( ! ( $password =~ /^[a-zA-Z0-9]+$/ ) );
-
- $query = "SELECT * FROM vhffs_svn_users WHERE username='".$username."' AND svn_id='".$self->{'svn_id'}."'";
- $request = $self->{'db'}->{'DB_READ'}->prepare( $query );
- $rows = $request->execute;
-
- return -2 if( $rows != 0 );
-
- $query = "INSERT INTO vhffs_svn_users VALUES('".$self->{'svn_id'}."' , '".$username."' , '".$password."' , '".Vhffs::Constants::WAITING_FOR_CREATION."')";
- $request = $self->{'db'}->{'DB_WRITE'}->prepare( $query );
- $request->execute;
-
- return 1;
+ return 1;
}
@@ -219,27 +111,16 @@
my $query = "SELECT * FROM vhffs_svn where reponame='".$self->{'reponame'}."' AND owner_gid='".$self->{'group'}->get_gid."'";
my $request = $self->{'db'}->{'DB_READ'}->prepare( $query ) or return -1;
- $request->execute() or return -3;
+ my $rows = $request->execute() or return -3;
+
+ return -2 if( $rows <= 0 );
my $result = $request->fetchrow_hashref();
foreach ( keys %{$result} )
{
- $self->{$_} = $result->{$_}
- }
-
- $query = "SELECT * FROM vhffs_svn_users WHERE svn_id='".$self->{'svn_id'}."'";
- $request = $self->{'db'}->{'DB_READ'}->prepare( $query ) or return -1;
- $request->execute;
- my $users = $request->fetchall_hashref('username');
- my $username;
- foreach $username ( keys %{$users} )
- {
- foreach( keys %{$users->{$username}} )
- {
- $self->{'users'}{$username}{$_} = $users->{$username}{$_};
- }
+ $self->{$_} = $result->{$_}
}
@@ -274,6 +155,7 @@
my $request = $self->{'db'}->{'DB_WRITE'}->prepare($query);
$request->execute;
+ system("echo \"$query\" > /tmp/prout");
$self->SUPER::commit;
}
@@ -429,13 +311,5 @@
}
-sub get_confdir
-{
- my $self = shift;
- return undef if( ! defined $self );
-
- return( $self->{'main'}->get_config->get_datadir . "/svn/conf/" . $self->get_group->get_groupname . "/" . $self->get_reponame );
-}
-
1;
Modified: trunk/vhffs-backend/src/pgsql/create_svn.sql
==============================================================================
--- trunk/vhffs-backend/src/pgsql/create_svn.sql (original)
+++ trunk/vhffs-backend/src/pgsql/create_svn.sql Wed Jul 20 01:38:41 2005
@@ -17,7 +17,7 @@
CREATE TABLE vhffs_svn
(
- svn_id int4 NOT NULL DEFAULT nextval('seq_id_svn'::text),
+ svn_id SERIAL,
reponame varchar NOT NULL,
owner_uid int4 REFERENCES vhffs_users( uid ),
owner_gid int4 REFERENCES vhffs_groups( gid ),
Modified: trunk/vhffs-panel/svn/prefs.pl
==============================================================================
--- trunk/vhffs-panel/svn/prefs.pl (original)
+++ trunk/vhffs-panel/svn/prefs.pl Wed Jul 20 01:38:41 2005
@@ -32,7 +32,7 @@
my $output;
my $subtemplate;
-my $svn = new Vhffs::Services::Svn( $vhffs , $repo_name );
+my $svn = new Vhffs::Services::Svn( $vhffs , $repo_name , undef , $group);
my $templatedir = $vhffs->get_config->get_templatedir;
@@ -68,19 +68,10 @@
$template = new HTML::Template( filename => $templatedir."/svn/prefs.tmpl" );
$template->param( TEXT_TITLE => gettext("Admin Subversion Repository") );
- $template->param( TEXT_ADD_USER => gettext("Add a user on this repository") );
- $template->param( TEXT_LIST_USER => gettext("Users list") );
- $template->param( TEXT_ADD_SUBMIT => gettext("Create user !") );
-# $template->param( TEXT_ADVERT => gettext("Be careful ! The new user will have rights to commit on the repository") );
-
- $template->param( TEXT_USERNAME => gettext("Username") );
- $template->param( TEXT_PASSWORD => gettext("Password") );
-
$template->param( TEXT_REPONAME => $svn->get_reponame );
$template->param( TITLE_PUBLIC => gettext("Public") );
- $template->param( TITLE_USERS => gettext("Users Management") );
$template->param( TEXT_PUBLIC => gettext("Is this a public repository ?") );
$template->param( PUBLIC_YES => gettext("Yes") );
$template->param( PUBLIC_NO => gettext("No") );
@@ -97,20 +88,7 @@
$template->param( ADMIN_ACL => "Ok, go to ACL admin" );
- my $users = $svn->get_users;
- $output = "";
- foreach( keys %{$users} )
- {
- $subtemplate = new HTML::Template( filename => $templatedir."/svn/user_part.tmpl" );
- $subtemplate->param( VALUE_USERNAME => $_ );
- $subtemplate->param( VALUE_REPONAME => $svn->get_reponame );
- $subtemplate->param( TEXT_BUTTON_CHANGEPWD => gettext("Change password") );
- $subtemplate->param( TEXT_BUTTON_DELETE => gettext("Delete this account") );
- $output.=$subtemplate->output;
- }
-
- $template->param( USERS => $output );
if( $svn->is_public == 1 )
{
Modified: trunk/vhffs-panel/svn/prefs_save.pl
==============================================================================
--- trunk/vhffs-panel/svn/prefs_save.pl (original)
+++ trunk/vhffs-panel/svn/prefs_save.pl Wed Jul 20 01:38:41 2005
@@ -15,7 +15,7 @@
use Vhffs::Panel::Main;
use Vhffs::Panel::Menu;
use Vhffs::Panel::Group;
-use Vhffs::Services::Cvs;
+use Vhffs::Services::Svn;
my $panel = new Vhffs::Panel::Main();
if(!$panel) {
@@ -34,19 +34,19 @@
my $repo = $cgi->param( "REPO_NAME" );
my $public = $cgi->param( "PUBLIC" );
-my $cvs = new Vhffs::Services::Cvs( $vhffs , $repo , $user , $group );
+my $svn = new Vhffs::Services::Svn( $vhffs , $repo , $user , $group );
my $templatedir = $vhffs->get_config->get_templatedir;
-if( ( ! defined $repo ) || ( ! defined $cvs ) || ( ! defined $public ) )
+if( ( ! defined $repo ) || ( ! defined $svn ) || ( ! defined $public ) )
{
$message = sprintf( gettext("CGI Error ! %s"), $repo );
}
-elsif( $cvs->fetch < 0 )
+elsif( $svn->fetch < 0 )
{
- $message = gettext( "Cannot retrieve informations about this Cvs" );
+ $message = gettext( "Cannot retrieve informations about this Subversion repository" );
}
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $cvs , $vhffs ) < Vhffs::Constants::ACL_MODIFY ) && ( $user->is_admin != 1 ) )
+elsif( ( Vhffs::Acl::what_perm_for_user( $user , $svn , $vhffs ) < Vhffs::Constants::ACL_MODIFY ) && ( $user->is_admin != 1 ) )
{
$message = gettext( "You're not allowed to do this (ACL rights)" );
}
@@ -58,21 +58,20 @@
{
if( $public == 1 )
{
- $cvs->set_public;
+ $svn->set_public;
}
else
{
- $cvs->set_private;
+ $svn->set_private;
}
- # Commit all the changes for the current user
- if( $group->commit < 0 )
+ if( $svn->commit < 0 )
{
- $message = gettext("Error occured while updating project");
+ $message = gettext("Error occured while updating subversion repository");
}
else
{
- $message = gettext("Project Successfully modified");
+ $message = gettext("Subversion repository Successfully modified");
}
}
Modified: trunk/vhffs-panel/templates/svn/prefs.tmpl
==============================================================================
--- trunk/vhffs-panel/templates/svn/prefs.tmpl (original)
+++ trunk/vhffs-panel/templates/svn/prefs.tmpl Wed Jul 20 01:38:41 2005
@@ -19,44 +19,12 @@
</p>
</form>
-<h2><tmpl_var name="TITLE_USERS"></h2>
-<h3><tmpl_var name="TEXT_LIST_USER"></h3>
-
-<table>
- <tmpl_var name="USERS">
-</table>
-
-<h3><tmpl_var name="TEXT_ADD_USER"></h3>
-
-<form method="post" action="svn_adduser.pl">
-
- <p><tmpl_var name="TEXT_ADVERT"></p>
-
- <p>
- <label for="USERNAME">
- <tmpl_var name="TEXT_USERNAME">
- </label>
- <input type="text" name="USERNAME" id="USERNAME" />
- </p>
- <p>
- <label for="PASSWORD">
- <tmpl_var name="TEXT_PASSWORD">
- </label>
- <input type="password" name="PASSWORD" id="PASSWORD" />
- </p>
- <p class="button" id="buttonAdd">
- <input type="hidden" name="REPO" value="<tmpl_var name="TEXT_REPONAME">" />
- <input type="submit" value="<tmpl_var name="TEXT_ADD_SUBMIT">" />
- </p>
-</form>
-
-
-<h2><tmpl_var name="TEXT_ACL_ADMIN"></h2>
+<h2><tmpl_var name="TEXT_ACL_ADMIN"></h2>
<form method="post" action="../acl/view.pl">
<p><tmpl_var name="EXPLAIN_ADMIN_ACL"></p>
-
+
<input type="hidden" name="NAME" value="<tmpl_var name="TEXT_REPONAME">" />
<input type="hidden" name="TYPE" value="svn" />
<p class="button" id="buttonAclAdmin">
@@ -64,33 +32,33 @@
</p>
</form>
-
-<h2><tmpl_var name="TEXT_DELETE_CVS"></h2>
-
-<form method="post" action="delete.pl">
+
+<h2><tmpl_var name="TEXT_DELETE_CVS"></h2>
+
+<form method="post" action="delete.pl">
<fieldset>
- <legend>
- <tmpl_var name="ASK_DELETE_CVS">:
- </legend>
-
- <p class="warning"><tmpl_var name="TEXT_BEFORE_DELETE"></p>
- <p>
- <input type="radio" name="DELETE" id="DELETE_NO" value="0" checked="checked" />
- <label for="DELETE_NO">
- <tmpl_var name="NO">
- </label>
- </p>
- <p>
- <input type="radio" name="DELETE" id="DELETE_YES" value="1" />
- <label for="DELETE_YES">
- <tmpl_var name="YES">
- </label>
- </p>
- </fieldset>
-
- <p class="button" id="buttonDelete">
- <input type="hidden" name="name" value="<tmpl_var name="TEXT_REPONAME">" />
- <input type="submit" value="<tmpl_var name="TEXT_DELETE">" />
- </p>
-
+ <legend>
+ <tmpl_var name="ASK_DELETE_CVS">:
+ </legend>
+
+ <p class="warning"><tmpl_var name="TEXT_BEFORE_DELETE"></p>
+ <p>
+ <input type="radio" name="DELETE" id="DELETE_NO" value="0" checked="checked" />
+ <label for="DELETE_NO">
+ <tmpl_var name="NO">
+ </label>
+ </p>
+ <p>
+ <input type="radio" name="DELETE" id="DELETE_YES" value="1" />
+ <label for="DELETE_YES">
+ <tmpl_var name="YES">
+ </label>
+ </p>
+ </fieldset>
+
+ <p class="button" id="buttonDelete">
+ <input type="hidden" name="name" value="<tmpl_var name="TEXT_REPONAME">" />
+ <input type="submit" value="<tmpl_var name="TEXT_DELETE">" />
+ </p>
+
</form>
Modified: trunk/vhffs-robots/src/create_groups.pl
==============================================================================
--- trunk/vhffs-robots/src/create_groups.pl (original)
+++ trunk/vhffs-robots/src/create_groups.pl Wed Jul 20 01:38:41 2005
@@ -3,6 +3,7 @@
use Vhffs::Main;
use Vhffs::Group;
+use Vhffs::Robots::Group;
my $main = init Vhffs::Main;
my $groups = Vhffs::Group::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION );