[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5721] trunk/sql/modules/admin.sql



Revision: 5721
          http://sourceforge.net/p/ledger-smb/code/5721
Author:   ehuelsmann
Date:     2013-04-28 14:27:11 +0000 (Sun, 28 Apr 2013)
Log Message:
-----------
Fix spurious closing paren in admin__create_group().
Make group and role database-local before inserting/granting.

Modified Paths:
--------------
    trunk/sql/modules/admin.sql

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2013-04-28 12:13:00 UTC (rev 5720)
+++ trunk/sql/modules/admin.sql	2013-04-28 14:27:11 UTC (rev 5721)
@@ -462,7 +462,7 @@
         stmt := 'create role '|| quote_ident(group_name);
         execute stmt;
         INSERT INTO lsmb_group (role_name) 
-             values (group_name));
+             values (group_name);
         return 1;
     END;
     
@@ -473,19 +473,24 @@
 CREATE OR REPLACE FUNCTION admin__add_group_to_role
 (in_group_name text, in_role_name text)
 RETURNS BOOL AS
-$$ 
+$$
+DECLARE
+   t_group_name text;
+   t_role_name  text;
 BEGIN
-   PERFORM * FROM lsmb_group_grants 
-     WHERE group_name = in_group_name AND
-           granted_role = in_role_name;
+   t_group_name := lsmb__role(in_group_name);
+   t_role_name := lsmb__role(in_role_name);
+   PERFORM * FROM lsmb_group_grants
+     WHERE group_name = t_group_name AND
+           granted_role = t_role_name;
 
- IF NOT FOUND THEN
-   INSERT INTO lsmb_group_grants(group_name, granted_role) 
-   VALUES (in_group_name, in_role_name);
- END IF;
+   IF NOT FOUND THEN
+      INSERT INTO lsmb_group_grants(group_name, granted_role) 
+           VALUES (t_group_name, t_role_name);
+   END IF;
 
-   EXECUTE 'GRANT ' || quote_ident(in_role_name) || ' TO ' ||
-           quote_literal('lsmb_' || t_dbname || '__' || in_group_name);
+   EXECUTE 'GRANT ' || quote_ident(t_role_name) || ' TO ' ||
+           quote_literal(t_group_name);
    RETURN TRUE;
 END;
 $$ LANGUAGE PLPGSQL SECURITY DEFINER;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.