import rt 3.2.2
[freeside.git] / rt / etc / acl.Pg
1 sub acl {
2     my $dbh = shift;
3
4     my @acls;
5
6     my @tables = qw (
7
8       attachments_id_seq
9       Attachments
10       Attributes
11       attributes_id_seq
12       queues_id_seq
13       Queues
14       links_id_seq
15       Links
16       principals_id_seq
17       Principals
18       groups_id_seq
19       Groups
20       scripconditions_id_seq
21       ScripConditions
22       transactions_id_seq
23       Transactions
24       scrips_id_seq
25       Scrips
26       acl_id_seq
27       ACL
28       groupmembers_id_seq
29       GroupMembers
30       cachedgroupmembers_id_seq
31       CachedGroupMembers
32       users_id_seq
33       Users
34       tickets_id_seq
35       Tickets
36       scripactions_id_seq
37       ScripActions
38       templates_id_seq
39       Templates
40       ticketcustomfieldvalues_id_s
41       TicketCustomFieldValues
42       customfields_id_seq
43       CustomFields
44       customfieldvalues_id_seq
45       CustomFieldValues
46       sessions
47     );
48
49     # if there's already an rt_user, drop it.
50     my @row =
51       $dbh->selectrow_array( "select usename from pg_user where usename = '" . $RT::DatabaseUser."'" );
52     if ( $row[0] ) {
53         push @acls, "drop user ${RT::DatabaseUser};",;
54     }
55
56     push @acls, "create user ${RT::DatabaseUser} with password '${RT::DatabasePassword}' NOCREATEDB NOCREATEUSER;";
57     foreach my $table (@tables) {
58         push @acls,
59           "GRANT SELECT, INSERT, UPDATE, DELETE ON $table to "
60           . $RT::DatabaseUser . ";";
61
62     }
63     return (@acls);
64 }
65 1;