summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorivan <ivan>2005-02-25 22:07:57 +0000
committerivan <ivan>2005-02-25 22:07:57 +0000
commit5021bac8641bc1eac15372d455a256123f98ae67 (patch)
treed716316399884df215618f4e3bc6ddc81544240f /bin
parentbd96ee15d52618089a84b70f8edc1170314bb950 (diff)
adding quick pg-readonly tool
Diffstat (limited to 'bin')
-rw-r--r--bin/pg-readonly22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/pg-readonly b/bin/pg-readonly
new file mode 100644
index 000000000..4f6d7c380
--- /dev/null
+++ b/bin/pg-readonly
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+#
+# hack to update/add read-only permissions for a user on the db
+#
+# usage: pg-readonly freesideuser readonlyuser
+
+use strict;
+use DBI;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(dbdef);
+
+my $user = shift or die &usage;
+my $rouser = shift or die &usage;
+
+my $dbh = adminsuidsetup $user;
+
+foreach my $table ( dbdef->tables ) {
+ $dbh->do("GRANT SELECT ON $table TO $rouser");
+ $dbh->commit();
+ $dbh->do("GRANT SELECT ON ${table}_seq TO $rouser");
+ $dbh->commit();
+}