Parcourir la source

Roles/procedures: support "with grant option" permissions. Part of issue #16

Reinier Olislagers il y a 11 ans
Parent
commit
689241cee5
2 fichiers modifiés avec 12 ajouts et 5 suppressions
  1. 11 4
      scriptdb.pas
  2. 1 1
      systables.pas

+ 11 - 4
scriptdb.pas

@@ -692,15 +692,22 @@ begin
           Line:= 'Grant ' + PermissionList.CommaText + ' on ' + ObjName + ' to ' + NewUser;
           if Pos('G', Permissions) > 0 then
             Line:= Line + ' with Grant option';
-          List.Add(Line + ' ;');
         end
         else
         if Pos('<P>', OrigObjName) = 1 then // Procedure
-          List.Add('Grant Execute on procedure ' + ObjName + ' to ' + NewUser + ' ;')
+        begin
+          Line:= 'Grant Execute on procedure ' + ObjName + ' to ' + NewUser;
+          if Pos('G', Permissions) > 0 then
+            Line:= Line + ' with Grant option';
+        end
         else
         if Pos('<R>', OrigObjName) = 1 then // Role
-          List.Add('Grant ' + ObjName + ' to ' + NewUser + ' ;');
-
+        begin
+          Line:= 'Grant ' + ObjName + ' to ' + NewUser;
+          if Pos('G', Permissions) > 0 then
+            Line:= Line + ' with Grant option';
+        end;
+        List.Add(Line + ' ;');
       end;
     finally
       PermissionList.Free;

+ 1 - 1
systables.pas

@@ -73,6 +73,7 @@ type
     function GetDBObjectsForPermissions(dbIndex: Integer; AObjectType: Integer = -1): string;
     function GetObjectUsers(dbIndex: Integer; ObjectName: string): string;
     function GetUserObjects(dbIndex: Integer; UserName: string; AObjectType: Integer = -1): string;
+    // Get permissions that specified user has for indicated object
     function GetObjectUserPermission(dbIndex: Integer; ObjectName, UserName: string; var ObjType: Integer): string;
 
     procedure GetBasicTypes(List: TStrings);
@@ -817,7 +818,6 @@ begin
       if not sqQuery.EOF then
         Result:= Result + ',';
     end;
-
   end;
   sqQuery.Close;
 end;