1 dnl Copyright (C) 2012, 2014 The Meme Factory, Inc. http:/www.meme.com/
2 dnl Copyright (C) 2004, 2005, 2008 Karl O. Pinc <kop@meme.com>
4 dnl This file is part of Gombe-MI.
6 dnl Gombe-MI is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3 of the License, or
9 dnl (at your option) any later version.
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with Gombe-MI. If not, see <http://www.gnu.org/licenses/>.
19 dnl Karl O. Pinc <kop@meme.com>
21 dnl Macros to set privliges.
26 include(`copyright.m4')dnl
27 include(`constants.m4')dnl
28 include(`types.m4')dnl
30 changequote([{[,]}])dnl m4 foolery so includes include only once.
31 dnl Once the macro is in the text, change the quotes back
32 ifdef([{[_grants.m4]}], [{[changequote(`,')]}], [{[dnl
35 dnl Standard test for having already included the file.
36 define(`_grants.m4')dnl
38 dnl Don't output anything while defining macros.
41 dnl Define m4 macros so we don't have to type so much.
42 dnl (Or at least type stuff that's more fun.)
44 dnl Watch out for using the single quote char as it has speical
47 dnl The dates and timestamps should probably have some sort of
48 dnl reasonable constraints on them to prevent operator error.
49 dnl (Like entering dates from the last century.)
54 dnl Grant privliges to a table.
56 dnl This also prints the name of the table. As every table has
57 dnl priviliges granted on it we get to monitor progress this way.
59 dnl Syntax: grant_priv(tablename)
62 grant_update_priv(`$1')dnl
63 grant_noupdate_priv(`$1')dnl
67 dnl Grant all privliges but update to a table.
69 dnl This also prints the name of the table. As every table has
70 dnl priviliges granted on it we get to monitor progress this way.
72 dnl Syntax: grant_noupdate_priv(tablename)
74 define([grant_noupdate_priv],[
75 GRANT SELECT ON $1 TO GROUP gombemi_readers;
76 GRANT SELECT ON $1 TO GROUP gombemi_editors;
77 GRANT INSERT ON $1 TO GROUP gombemi_editors;
78 GRANT DELETE ON $1 TO GROUP gombemi_editors;
79 SELECT '$1' AS done_with;
83 dnl Grant update privliges to a table.
85 dnl Syntax: grant_update_priv(tablename)
87 define([grant_update_priv],[
88 GRANT UPDATE ON $1 TO GROUP gombemi_editors;
93 dnl Grant update privliges to some columns of a table.
95 dnl Syntax: grant_update_cols_privs(tablename, columnames)
97 dnl tablename Name of table
98 dnl columnnames Names of columns, separated by commas
101 define([grant_update_cols_privs],[
102 GRANT UPDATE ($2) ON $1 TO gombemi_editors;
108 dnl Grant privliges to a table's sequence
110 dnl This also prints the name of the sequence.
112 dnl Syntax: grant_seq_priv(tablename, idname)
114 define([grant_seq_priv],[
115 GRANT SELECT ON $1_$2_seq TO GROUP gombemi_readers;
116 GRANT SELECT ON $1_$2_seq TO GROUP gombemi_editors;
117 GRANT UPDATE ON $1_$2_seq TO GROUP gombemi_editors;
118 SELECT '$1_$2_seq' AS done_with;
123 dnl Grant read-only privliges to a table.
125 dnl Used for those tables updated only by trigger.
127 dnl This also prints the name of the table. As every table has
128 dnl priviliges granted on it we get to monitor progress this way.
130 dnl Syntax: grant_ro_priv(tablename)
132 define([grant_ro_priv],[
133 GRANT SELECT ON $1 TO GROUP gombemi_readers;
134 GRANT SELECT ON $1 TO GROUP gombemi_editors;
135 SELECT '$1' AS done_with;
140 dnl Grant read-only privliges to a table's sequence
142 dnl Used for those tables updated only by trigger.
144 dnl This also prints the name of the sequence.
146 dnl Syntax: grant_ro_seq_priv(tablename, idname)
148 define([grant_ro_seq_priv],[
149 GRANT SELECT ON $1_$2_seq TO GROUP gombemi_readers;
150 GRANT SELECT ON $1_$2_seq TO GROUP gombemi_editors;
151 SELECT '$1_$2_seq' AS done_with;
155 -- Done defining macros.
159 ]}])dnl End of ifdef over the whole file.