Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f2CKBox57863 for ; Mon, 12 Mar 2001 15:11:50 -0500 (EST) (envelope-from pgsql-general-owner@postgresql.org) Received: from mail.astrofoto.org (roland-0.dsl.speakeasy.net [216.254.9.145]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f27Kepx53249; Wed, 7 Mar 2001 15:40:51 -0500 (EST) (envelope-from roland@rlenter.com) Received: (from roland@localhost) by mail.astrofoto.org (8.11.0/8.8.7) id f27Kei328146; Wed, 7 Mar 2001 15:40:44 -0500 To: pgsql-sql@postgresql.org, pgsql-general@postgresql.org, pgsql-novice@postgresql.org Subject: Re: [SQL] Permissons on database References: <3AA517BE.31EEE461@inet-interactif.com> From: Roland Roberts Date: 07 Mar 2001 15:40:44 -0500 In-Reply-To: <3AA517BE.31EEE461@inet-interactif.com> Message-ID: Lines: 22 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.98 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Archive-Number: 200103/520 X-Sequence-Number: 6017 --=-=-= >>>>> "bk" == Boulat Khakimov writes: bk> How do I grant permissions on everything in the selected bk> databes? bk> GRANT doesnt take as on object database name nor does it bk> accept wild chars.... Attached is some Perl code I wrote long ago to do this. This particular code was done for Keystone, a problem tracking database and it would do a "GRANT ALL". Modify it as needed. Last I checked it worked with both PostgreSQL 6.5.x and 7.0.x --=-=-= Content-Disposition: attachment; filename=pg_grantall.pl Content-Description: Perl code for GRANT on a database #! /usr/bin/perl -w # I'm also appending a Perl script to grant public access to all # keystone tables. It uses the Pg module for PostgreSQL, so you will # need to add that first. However, I find it a bit less tedious than # granting access by hand.... # Roland B. Roberts, PhD Custom Software Solutions # roberts@panix.com 101 West 15th St #4NN # rbroberts@acm.org New York, NY 10011 use Pg; if (defined $ARGV[0]) { $dbname = $ARGV[0]; } else { $dbname = "keystone"; } print "connecting to $dbname\n"; $dbh = Pg::connectdb("dbname=$dbname $ARGV[1]"); die "Pg::connectdb failed, $dbh->errorMessage" unless ($dbh->status == PGRES_CONNECTION_OK); $c{relname} = $dbh->exec ("select relname from pg_class where relname !~ '^pg_' and relkind != 'i'"); die "Pg::exec, $dbh->errorMessage" unless ($c{relname}->resultStatus == PGRES_TUPLES_OK); for ($i = 0; $i < $c{relname}->ntuples; $i++) { $relname = $c{relname}->getvalue($i,0); print "grant all on $relname to public\n"; $c{grant} = $dbh->exec ("grant all on $relname to public"); die "Pg::exec, ".$dbh->errorMessage unless ($c{grant}->resultStatus == PGRES_COMMAND_OK); } --=-=-= roland -- PGP Key ID: 66 BC 3B CD Roland B. Roberts, PhD RL Enterprises roland@rlenter.com 76-15 113th Street, Apt 3B rbroberts@acm.org Forest Hills, NY 11375 --=-=-=--