import rt 3.4.4
[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  objectcustomfieldvalues_id_s
41  ObjectCustomFieldValues 
42       customfields_id_seq
43  CustomFields 
44  objectcustomfields_id_s
45  ObjectCustomFields 
46       customfieldvalues_id_seq
47       CustomFieldValues
48       sessions
49     );
50
51     # if there's already an rt_user, drop it.
52     my @row =
53       $dbh->selectrow_array( "select usename from pg_user where usename = '" . $RT::DatabaseUser."'" );
54     if ( $row[0] ) {
55         push @acls, "drop user ${RT::DatabaseUser};",;
56     }
57
58     push @acls, "create user ${RT::DatabaseUser} with password '${RT::DatabasePassword}' NOCREATEDB NOCREATEUSER;";
59     foreach my $table (@tables) {
60         push @acls,
61           "GRANT SELECT, INSERT, UPDATE, DELETE ON $table to "
62           . $RT::DatabaseUser . ";";
63
64     }
65     return (@acls);
66 }
67 1;