summaryrefslogtreecommitdiffstats
path: root/extra/svn
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-04-01 19:43:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-04-01 19:43:59 +0000
commit4ff8386e3dfee800591e7f856a26ccc700149b02 (patch)
tree75cd4a45ab9e0298299c821029d6066c29bfbc2b /extra/svn
parentcb6c8bee473332dfacea8d53745eb75407877a06 (diff)
downloadredmine-4ff8386e3dfee800591e7f856a26ccc700149b02.tar.gz
redmine-4ff8386e3dfee800591e7f856a26ccc700149b02.zip
Initial commit for svn repository management and access control:
* Identifier attribute added on Project model. Used as the unix group name for the project * Web services (disabled by default) and scripts for repository management on a remote svn host git-svn-id: http://redmine.rubyforge.org/svn/trunk@396 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'extra/svn')
-rw-r--r--extra/svn/create_views.sql24
-rw-r--r--extra/svn/manage_repos.pl75
-rw-r--r--extra/svn/svnserve.wrapper25
3 files changed, 124 insertions, 0 deletions
diff --git a/extra/svn/create_views.sql b/extra/svn/create_views.sql
new file mode 100644
index 000000000..ce02e0817
--- /dev/null
+++ b/extra/svn/create_views.sql
@@ -0,0 +1,24 @@
+/* ssh views */
+
+CREATE OR REPLACE VIEW ssh_users as
+select login as username, hashed_password as password
+from users
+where status = 1;
+
+
+/* nss views */
+
+CREATE OR REPLACE VIEW nss_groups AS
+select identifier AS name, (id + 5000) AS gid, 'x' AS password
+from projects;
+
+CREATE OR REPLACE VIEW nss_users AS
+select login AS username, CONCAT_WS(' ', firstname, lastname) as realname, (id + 5000) AS uid, 'x' AS password
+from users
+where status = 1;
+
+CREATE OR REPLACE VIEW nss_grouplist AS
+select (members.project_id + 5000) AS gid, users.login AS username
+from users, members
+where users.id = members.user_id
+and users.status = 1;
diff --git a/extra/svn/manage_repos.pl b/extra/svn/manage_repos.pl
new file mode 100644
index 000000000..aab666f41
--- /dev/null
+++ b/extra/svn/manage_repos.pl
@@ -0,0 +1,75 @@
+#!/usr/bin/perl
+#
+# redMine is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+use strict;
+use SOAP::Lite;
+
+my $wdsl = 'http://192.168.0.10:3000/sys/service.wsdl';
+my $service = SOAP::Lite->service($wdsl);
+my $repos_base = '/var/svn';
+
+my $projects = $service->Projects('');
+
+foreach my $project (@{$projects}) {
+ my $repos_name = $project->{identifier};
+
+ if ($repos_name eq "") {
+ print("\tno identifier for project $project->{name}\n");
+ next;
+ }
+
+ unless ($repos_name =~ /^[a-z0-9\-]+$/) {
+ print("\tinvalid identifier for project $project->{name}\n");
+ next;
+ }
+
+ my $repos_path = "$repos_base/$repos_name";
+
+ if (-e $repos_path) {
+ # check unix right and change them if needed
+ my $other_read = (stat($repos_path))[2] & 00007;
+ my $right;
+
+ if ($project->{is_public} and not $other_read) {
+ $right = "0775";
+ } elsif (not $project->{is_public} and $other_read) {
+ $right = "0770";
+ } else {
+ next;
+ }
+
+ # change mode
+ system('chmod', '-R', $right, $repos_path) == 0 or
+ warn("\tunable to change mode on $repos_path : $?\n"), next;
+
+ print "\tmode change on $repos_path\n";
+
+ } else {
+ # change umask to suit the repository's privacy
+ $project->{is_public} ? umask 0002 : umask 0007;
+
+ # create the repository
+ system('svnadmin', 'create', $repos_path) == 0 or
+ warn("\tsystem svnadmin failed unable to create $repos_path\n"), next;
+
+ # set the group owner
+ system('chown', '-R', "root:$repos_name", $repos_path) == 0 or
+ warn("\tunable to create $repos_path : $?\n"), next;
+
+ print "\trepository $repos_path created\n";
+ my $call = $service->RepositoryCreated($project->{id}, "svn://host/$repos_name");
+ }
+}
diff --git a/extra/svn/svnserve.wrapper b/extra/svn/svnserve.wrapper
new file mode 100644
index 000000000..705a17e84
--- /dev/null
+++ b/extra/svn/svnserve.wrapper
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+#
+# redMine is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# modify to suit your repository base
+my $repos_base = '/var/svn';
+
+my $path = '/usr/bin/';
+my %kwown_commands = map { $_ => 1 } qw/svnserve/;
+
+umask 0002;
+
+exec ('/usr/bin/svnserve', '-r', $repos_base, '-t');