pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roland Roberts <roland@astrofoto.org>
To: pgsql-sql@postgresql.org
To: pgsql-general@postgresql.org
To: pgsql-novice@postgresql.org
Subject: Re: [SQL] Permissons on database
Date: 07 Mar 2001 15:40:44 -0500
Message-ID: <m2puftmhwz.fsf@tycho.rlent.pnet> (raw)
In-Reply-To: <3AA517BE.31EEE461@inet-interactif.com>
References: <3AA517BE.31EEE461@inet-interactif.com>

    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
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

Attachments:

pg_grantall.pl (text/plain, 1.2K) download #! /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); }

view thread (6+ messages)  latest in thread

Message-ID: <m2puftmhwz.fsf@tycho.rlent.pnet>
Permalink:  ../m2puftmhwz.fsf@tycho.rlent.pnet/
Also on:    postgresql.org/message-id/m2puftmhwz.fsf@tycho.rlent.pnet

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: roland@astrofoto.org, pgsql-general@postgresql.org, pgsql-novice@postgresql.org
  Subject: Re: [SQL] Permissons on database
  In-Reply-To: <m2puftmhwz.fsf@tycho.rlent.pnet>
  References: <3AA517BE.31EEE461@inet-interactif.com> <m2puftmhwz.fsf@tycho.rlent.pnet>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox