dnl Copyright (C) 2012, 2014 The Meme Factory, Inc. http:/www.meme.com/ dnl Copyright (C) 2004, 2005, 2008 Karl O. Pinc dnl dnl This file is part of Gombe-MI. dnl dnl Gombe-MI is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 3 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with Gombe-MI. If not, see . dnl dnl Karl O. Pinc dnl dnl Macros to set privliges. dnl dnl Remarks: dnl dnl m4 includes include(`copyright.m4')dnl include(`constants.m4')dnl include(`types.m4')dnl dnl changequote([{[,]}])dnl m4 foolery so includes include only once. dnl Once the macro is in the text, change the quotes back ifdef([{[_grants.m4]}], [{[changequote(`,')]}], [{[dnl changequote(`,')dnl dnl dnl Standard test for having already included the file. define(`_grants.m4')dnl dnl dnl Don't output anything while defining macros. divert(-1) dnl Define m4 macros so we don't have to type so much. dnl (Or at least type stuff that's more fun.) dnl dnl Watch out for using the single quote char as it has speical dnl meaning to m4. dnl dnl The dates and timestamps should probably have some sort of dnl reasonable constraints on them to prevent operator error. dnl (Like entering dates from the last century.) dnl dnl Bugs: dnl Grant privliges to a table. dnl dnl This also prints the name of the table. As every table has dnl priviliges granted on it we get to monitor progress this way. dnl dnl Syntax: grant_priv(tablename) changequote([,]) define([grant_priv],[ grant_update_priv(`$1')dnl grant_noupdate_priv(`$1')dnl ]) changequote(`,') dnl Grant all privliges but update to a table. dnl dnl This also prints the name of the table. As every table has dnl priviliges granted on it we get to monitor progress this way. dnl dnl Syntax: grant_noupdate_priv(tablename) changequote([,]) define([grant_noupdate_priv],[ GRANT SELECT ON $1 TO GROUP gombemi_readers; GRANT SELECT ON $1 TO GROUP gombemi_editors; GRANT INSERT ON $1 TO GROUP gombemi_editors; GRANT DELETE ON $1 TO GROUP gombemi_editors; SELECT '$1' AS done_with; ]) changequote(`,') dnl Grant update privliges to a table. dnl dnl Syntax: grant_update_priv(tablename) changequote([,]) define([grant_update_priv],[ GRANT UPDATE ON $1 TO GROUP gombemi_editors; ]) changequote(`,') dnl Grant update privliges to some columns of a table. dnl dnl Syntax: grant_update_cols_privs(tablename, columnames) dnl dnl tablename Name of table dnl columnnames Names of columns, separated by commas dnl changequote([,]) define([grant_update_cols_privs],[ GRANT UPDATE ($2) ON $1 TO gombemi_editors; ]) changequote(`,') dnl Grant privliges to a table's sequence dnl dnl This also prints the name of the sequence. dnl dnl Syntax: grant_seq_priv(tablename, idname) changequote([,]) define([grant_seq_priv],[ GRANT SELECT ON $1_$2_seq TO GROUP gombemi_readers; GRANT SELECT ON $1_$2_seq TO GROUP gombemi_editors; GRANT UPDATE ON $1_$2_seq TO GROUP gombemi_editors; SELECT '$1_$2_seq' AS done_with; ]) changequote(`,') dnl Grant read-only privliges to a table. dnl dnl Used for those tables updated only by trigger. dnl dnl This also prints the name of the table. As every table has dnl priviliges granted on it we get to monitor progress this way. dnl dnl Syntax: grant_ro_priv(tablename) changequote([,]) define([grant_ro_priv],[ GRANT SELECT ON $1 TO GROUP gombemi_readers; GRANT SELECT ON $1 TO GROUP gombemi_editors; SELECT '$1' AS done_with; ]) changequote(`,') dnl Grant read-only privliges to a table's sequence dnl dnl Used for those tables updated only by trigger. dnl dnl This also prints the name of the sequence. dnl dnl Syntax: grant_ro_seq_priv(tablename, idname) changequote([,]) define([grant_ro_seq_priv],[ GRANT SELECT ON $1_$2_seq TO GROUP gombemi_readers; GRANT SELECT ON $1_$2_seq TO GROUP gombemi_editors; SELECT '$1_$2_seq' AS done_with; ]) changequote(`,') -- Done defining macros. divert`'dnl dnl dnl ]}])dnl End of ifdef over the whole file.