2 # Reset privilege grants on some table/view/index
4 require './postgresql-lib.pl';
6 &error_setup($text{'dgrant_err'});
7 $access{'users'} || &error($text{'grant_ecannot'});
8 @d = split(/\0/, $in{'d'});
9 @d || &error($text{'dgrant_enone'});
12 ($db, $table, $ns, $type) = split(/\//, $d, -1);
13 $ss = &supports_schemas($db);
17 $s = &execute_sql($db, 'select relname, relacl, nspname from pg_class, pg_namespace where relnamespace = pg_namespace.oid and (relkind = \'r\' OR relkind = \'S\') and relname !~ \'^pg_\' order by relname');
21 $s = &execute_sql($db, 'select relname, relacl, \'public\' from pg_class where (relkind = \'r\' OR relkind = \'S\') and relname !~ \'^pg_\' order by relname');
24 foreach $g (@{$s->{'data'}}) {
25 if ($g->[0] eq $table &&
27 $g->[1] =~ s/^\{//; $g->[1] =~ s/\}$//;
28 @grant = map { /^"(.*)=(.*)"$/ || /^(.*)=(.*)$/; [ $1, $2 ] }
34 $qt = $ss ? "e_table($ns.".".$table)
35 : "e_table($table);
41 elsif ($g->[0] =~ /group\s+(\S+)/) {
42 $who = "group \"$1\"";
47 &execute_sql_logged($db, "revoke all on $qt from $who");
51 &webmin_log("degrant", undef, scalar(@d));
52 &redirect("list_grants.cgi?search=".&urlize($in{'search'}));