X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fetc%2Facl.Pg;h=dd1b334147d1e1a4f2a4e6dc518bbf21a74f51ec;hb=HEAD;hp=16ea71b2d96d0cce17a1afd2d9ccfa3c1077cf08;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/rt/etc/acl.Pg b/rt/etc/acl.Pg index 16ea71b2d..dd1b33414 100755 --- a/rt/etc/acl.Pg +++ b/rt/etc/acl.Pg @@ -1,63 +1,85 @@ + sub acl { my $dbh = shift; my @acls; my @tables = qw ( - - attachments_id_seq - Attachments - queues_id_seq - Queues - links_id_seq - Links - principals_id_seq - Principals - groups_id_seq - Groups - scripconditions_id_seq - ScripConditions - transactions_id_seq - Transactions - scrips_id_seq - Scrips - acl_id_seq - ACL - groupmembers_id_seq - GroupMembers - cachedgroupmembers_id_seq - CachedGroupMembers - users_id_seq - Users - tickets_id_seq - Tickets - scripactions_id_seq - ScripActions - templates_id_seq - Templates - ticketcustomfieldvalues_id_s - TicketCustomFieldValues - customfields_id_seq - CustomFields - customfieldvalues_id_seq - CustomFieldValues - sessions + attachments_id_seq + Attachments + Attributes + attributes_id_seq + queues_id_seq + Queues + links_id_seq + Links + principals_id_seq + Principals + groups_id_seq + Groups + scripconditions_id_seq + ScripConditions + transactions_id_seq + Transactions + scrips_id_seq + Scrips + objectscrips_id_seq + ObjectScrips + acl_id_seq + ACL + groupmembers_id_seq + GroupMembers + cachedgroupmembers_id_seq + CachedGroupMembers + users_id_seq + Users + tickets_id_seq + Tickets + scripactions_id_seq + ScripActions + templates_id_seq + Templates + objectcustomfieldvalues_id_s + ObjectCustomFieldValues + customfields_id_seq + CustomFields + objectcustomfields_id_s + ObjectCustomFields + customfieldvalues_id_seq + CustomFieldValues + sessions + classes_id_seq + Classes + articles_id_seq + Articles + topics_id_seq + Topics + objecttopics_id_seq + ObjectTopics + objectclasses_id_seq + ObjectClasses ); - # if there's already an rt_user, drop it. - my @row = - $dbh->selectrow_array( "select usename from pg_user where usename = '" . $RT::DatabaseUser."'" ); - if ( $row[0] ) { - push @acls, "drop user ${RT::DatabaseUser};",; + my $db_user = RT->Config->Get('DatabaseUser'); + my $db_pass = RT->Config->Get('DatabasePassword'); + + # if there's already an rt_user, use it. + my @row = $dbh->selectrow_array( "SELECT usename FROM pg_user WHERE usename = '$db_user'" ); + unless ( $row[0] ) { + push @acls, "CREATE USER \"$db_user\" WITH PASSWORD '$db_pass' NOCREATEDB NOSUPERUSER;"; } - push @acls, "create user ${RT::DatabaseUser} with password '${RT::DatabasePassword}' NOCREATEDB NOCREATEUSER;"; foreach my $table (@tables) { - push @acls, - "GRANT SELECT, INSERT, UPDATE, DELETE ON $table to " - . $RT::DatabaseUser . ";"; - + if ( $table =~ /^[a-z]/ && $table ne 'sessions' ) { + # Sequences; not all end with _seq because + # objectcustomfieldvalues_id_s is too long + push @acls, "GRANT USAGE, SELECT, UPDATE ON $table TO \"$db_user\";" + } + else { + push @acls, "GRANT SELECT, INSERT, UPDATE, DELETE ON $table TO \"$db_user\";" + } } return (@acls); } + 1;