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