[freeside-commits] freeside/rt/etc acl.Pg,1.2,1.3

Ivan,,, ivan at wavetail.420.am
Sun Feb 19 14:40:46 PST 2012


Update of /home/cvs/cvsroot/freeside/rt/etc
In directory wavetail.420.am:/tmp/cvs-serv15873/etc

Modified Files:
	acl.Pg 
Log Message:
fix ancient vendor branch CVS bs

Index: acl.Pg
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/etc/acl.Pg,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- acl.Pg	15 Jul 2003 13:30:33 -0000	1.2
+++ acl.Pg	19 Feb 2012 22:40:44 -0000	1.3
@@ -1,12 +1,14 @@
+
 sub acl {
     my $dbh = shift;
 
     my @acls;
 
     my @tables = qw (
-
       attachments_id_seq
       Attachments
+        Attributes
+        attributes_id_seq
       queues_id_seq
       Queues
       links_id_seq
@@ -35,29 +37,40 @@
       ScripActions
       templates_id_seq
       Templates
-      ticketcustomfieldvalues_id_s
-      TicketCustomFieldValues
+        objectcustomfieldvalues_id_s
+        ObjectCustomFieldValues 
       customfields_id_seq
       CustomFields
+        objectcustomfields_id_s
+        ObjectCustomFields 
       customfieldvalues_id_seq
       CustomFieldValues
       sessions
     );
 
-    # 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 NOCREATEUSER;";
     }
 
-    push @acls, "create user ${RT::DatabaseUser} with password '${RT::DatabasePassword}' NOCREATEDB NOCREATEUSER;";
+    my $sequence_right
+        = ( $dbh->{pg_server_version} >= 80200 )
+        ? "USAGE, SELECT, UPDATE"
+        : "SELECT, UPDATE";
     foreach my $table (@tables) {
-        push @acls,
-          "GRANT SELECT, INSERT, UPDATE, DELETE ON $table to "
-          . $RT::DatabaseUser . ";";
-
+        if ( $table =~ /^[a-z]/ && $table ne 'sessions' ) {
+# table like objectcustomfields_id_s
+            push @acls, "GRANT $sequence_right ON $table TO \"$db_user\";"
+        }
+        else {
+            push @acls, "GRANT SELECT, INSERT, UPDATE, DELETE ON $table TO \"$db_user\";"
+        }
     }
     return (@acls);
 }
+
 1;



More information about the freeside-commits mailing list