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 |
snetram |
1.2 |
@@ -0,0 +1,58 @@ |
4 |
snetram |
1.1 |
+#!/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 |
snetram |
1.2 |
+die "Username argument missing." unless defined ($item); |
20 |
|
|
+ |
21 |
|
|
+my @entries = qw(); |
22 |
snetram |
1.1 |
+ |
23 |
|
|
+if ($event eq 'user-delete') { |
24 |
|
|
+ |
25 |
snetram |
1.2 |
+ @entries = qw(UsersWrite UsersRead); |
26 |
snetram |
1.1 |
+ |
27 |
|
|
+} elsif ($event eq 'group-delete') { |
28 |
|
|
+ |
29 |
snetram |
1.2 |
+ @entries = qw(GroupsWrite GroupsRead); |
30 |
snetram |
1.1 |
+ |
31 |
|
|
+} else { |
32 |
|
|
+ |
33 |
|
|
+ die "Invalid event: $event"; |
34 |
|
|
+ |
35 |
|
|
+} |
36 |
|
|
+ |
37 |
|
|
+use esmith::AccountsDB; |
38 |
|
|
+ |
39 |
|
|
+my $db_accounts = esmith::AccountsDB->open_ro() or |
40 |
|
|
+ die "Couldn't open AccountsDB\n"; |
41 |
|
|
+ |
42 |
|
|
+my @repositories = $db_accounts->get_all_by_prop('type' => 'repository'); |
43 |
|
|
+ |
44 |
|
|
+REPOSITORY: foreach my $repository ( |
45 |
|
|
+ (@repositories), |
46 |
|
|
+) |
47 |
|
|
+{ |
48 |
|
|
+ my $repository_rec = $db_accounts->get($repository) || next REPOSITORY; |
49 |
|
|
+ |
50 |
|
|
+ foreach my $entry (@entries) { |
51 |
|
|
+ |
52 |
|
|
+ my $members = $repository_rec->prop($entry); |
53 |
|
|
+ my @members = split (/,/, $members); |
54 |
|
|
+ @members = grep (!/^$item$/, @members); |
55 |
|
|
+ $repository_rec->set_prop($entry, join(',', @members)); |
56 |
|
|
+ |
57 |
|
|
+ } |
58 |
|
|
+ |
59 |
|
|
+} |
60 |
|
|
+ |
61 |
|
|
+exit(0); |