1 |
snetram |
1.1 |
--- smeserver-subversion-1.4/root/etc/e-smith/events/actions/subversion-delete-from-access-list.AddHooksToUSerAndGroupDeleteEvents 2008-02-25 22:28:36.000000000 +0100 |
2 |
|
|
+++ smeserver-subversion-1.4/root/etc/e-smith/events/actions/subversion-delete-from-access-list 2008-02-25 22:27:32.000000000 +0100 |
3 |
|
|
@@ -0,0 +1,56 @@ |
4 |
|
|
+#!/usr/bin/perl -w |
5 |
|
|
+ |
6 |
|
|
+package esmith; |
7 |
|
|
+ |
8 |
|
|
+use strict; |
9 |
|
|
+use Errno; |
10 |
|
|
+use esmith::util; |
11 |
|
|
+ |
12 |
|
|
+my $event = $ARGV [0]; |
13 |
|
|
+my $item = $ARGV [1]; |
14 |
|
|
+ |
15 |
|
|
+#------------------------------------------------------------ |
16 |
|
|
+# Delete the user from subversion repositories |
17 |
|
|
+#------------------------------------------------------------ |
18 |
|
|
+ |
19 |
|
|
+die "Username argument missing." unless defined ($userName); |
20 |
|
|
+ |
21 |
|
|
+if ($event eq 'user-delete') { |
22 |
|
|
+ |
23 |
|
|
+ my @entries = qw(UsersWrite UsersRead); |
24 |
|
|
+ |
25 |
|
|
+} elsif ($event eq 'group-delete') { |
26 |
|
|
+ |
27 |
|
|
+ my @entries = qw(GroupsWrite GroupsRead); |
28 |
|
|
+ |
29 |
|
|
+} else { |
30 |
|
|
+ |
31 |
|
|
+ die "Invalid event: $event"; |
32 |
|
|
+ |
33 |
|
|
+} |
34 |
|
|
+ |
35 |
|
|
+use esmith::AccountsDB; |
36 |
|
|
+ |
37 |
|
|
+my $db_accounts = esmith::AccountsDB->open_ro() or |
38 |
|
|
+ die "Couldn't open AccountsDB\n"; |
39 |
|
|
+ |
40 |
|
|
+my @repositories = $db_accounts->get_all_by_prop('type' => 'repository'); |
41 |
|
|
+ |
42 |
|
|
+REPOSITORY: foreach my $repository ( |
43 |
|
|
+ (@repositories), |
44 |
|
|
+) |
45 |
|
|
+{ |
46 |
|
|
+ my $repository_rec = $db_accounts->get($repository) || next REPOSITORY; |
47 |
|
|
+ |
48 |
|
|
+ foreach my $entry (@entries) { |
49 |
|
|
+ |
50 |
|
|
+ my $members = $repository_rec->prop($entry); |
51 |
|
|
+ my @members = split (/,/, $members); |
52 |
|
|
+ @members = grep (!/^$item$/, @members); |
53 |
|
|
+ $repository_rec->set_prop($entry, join(',', @members)); |
54 |
|
|
+ |
55 |
|
|
+ } |
56 |
|
|
+ |
57 |
|
|
+} |
58 |
|
|
+ |
59 |
|
|
+exit(0); |