Browse code

- replace the hard coded database table names for GRANT with the defines from openserdbctl.base

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3251 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 03/12/2007 17:50:26
Showing 1 changed files
... ...
@@ -151,18 +151,20 @@ if [ $? -ne 0 ] ; then
151 151
 	mwarn "Create user in database failed, perhaps they allready exist? Try to continue.."
152 152
 fi
153 153
 
154
-# There is no easy way to grant select rights to all tables of a database in postgresl
155
-# so unfortunally its necessary to specify all tables here.
156
-sql_query "$1" "GRANT ALL PRIVILEGES ON DATABASE $1 TO $DBRWUSER;
157
-		GRANT SELECT ON TABLE version, acc, address, aliases, dbaliases, dispatcher, 
158
-		domain, grp, gw, gw_grp, lcr, location, missed_calls, pdt, re_grp, silo,
159
-		speed_dial, subscriber, trusted, uri, usr_preferences TO $DBROUSER;"
160
-
154
+sql_query "$1" "GRANT ALL PRIVILEGES ON DATABASE $1 TO $DBRWUSER;"
161 155
 if [ $? -ne 0 ] ; then
162 156
 	merr "Grant privileges to database failed!"
163 157
 	exit 1
164 158
 fi
165 159
 
160
+for TABLE in $STANDARD_TABLES; do
161
+    sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
162
+	if [ $? -ne 0 ] ; then
163
+		merr "Grant privileges to standard tables failed!"
164
+		exit 1
165
+	fi
166
+done
167
+
166 168
 if [ -e $DB_SCHEMA/extensions-create.sql ]
167 169
 then
168 170
 	minfo "Creating custom extensions tables"
... ...
@@ -215,18 +217,20 @@ if [ $? -ne 0 ] ; then
215 215
 	exit 1
216 216
 fi
217 217
 
218
-sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE 	active_watchers, active_watchers_id_seq,
219
-		presentity, presentity_id_seq, watchers, watchers_id_seq, xcap,
220
-		xcap_id_seq, pua, pua_id_seq, rls_presentity, rls_presentity_id_seq,
221
-		rls_watchers, rls_watchers_id_seq TO $DBRWUSER;
222
-		GRANT SELECT ON TABLE active_watchers, presentity, watchers, xcap,
223
-		pua, rls_presentity, rls_watchers TO $DBROUSER;"
224
-
218
+sql_query "$1" "GRANT ALL PRIVILEGES ON DATABASE $1 TO $DBRWUSER;"
225 219
 if [ $? -ne 0 ] ; then
226
-	merr "Grant privileges to presences tables failed!"
220
+	merr "Grant privileges to database failed!"
227 221
 	exit 1
228 222
 fi
229 223
 
224
+for TABLE in $PRESENCE_TABLES; do
225
+    sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
226
+	if [ $? -ne 0 ] ; then
227
+		merr "Grant privileges to presence tables failed!"
228
+		exit 1
229
+	fi
230
+done
231
+
230 232
 minfo "Presence tables succesfully created."
231 233
 }  # end presence_create
232 234
 
... ...
@@ -249,18 +253,20 @@ for TABLE in $EXTRA_MODULES; do
249 249
     fi
250 250
 done
251 251
 
252
-sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE cpl, cpl_id_seq, imc_members,
253
-		imc_members_id_seq, imc_rooms, imc_rooms_id_seq, sip_trace, 
254
-		sip_trace_id_seq, domainpolicy, domainpolicy_id_seq
255
-		TO $DBRWUSER;
256
-		GRANT SELECT ON TABLE cpl, imc_members, imc_rooms, sip_trace,
257
-		domainpolicy, carrierroute TO $DBROUSER;"
258
-
252
+sql_query "$1" "GRANT ALL PRIVILEGES ON DATABASE $1 TO $DBRWUSER;"
259 253
 if [ $? -ne 0 ] ; then
260
-	merr "Grant privileges to extra tables failed!"
254
+	merr "Grant privileges to database failed!"
261 255
 	exit 1
262 256
 fi
263 257
 
258
+for TABLE in $EXTRA_TABLES; do
259
+    sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
260
+	if [ $? -ne 0 ] ; then
261
+		merr "Grant privileges to extra tables failed!"
262
+		exit 1
263
+	fi
264
+done
265
+
264 266
 minfo "Extra tables succesfully created."
265 267
 }  # end extra_create
266 268
 
... ...
@@ -323,10 +329,7 @@ if [ $? -ne 0 ] ; then
323 323
 	merr "Failed to create presence tables!"
324 324
 	exit 1
325 325
 fi
326
-
327
-sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE phonebook, phonebook_id_seq, pending,
328
-		pending_id_seq, active_sessions, server_monitoring, server_monitoring_agg,
329
-		usr_preferences_types, admin_privileges to $DBRWUSER; 
326
+sql_query "$1" "GRANT ALL PRIVILEGES ON DATABASE $1 TO $DBRWUSER;
330 327
 		GRANT SELECT ON TABLE phonebook, pending, active_sessions, server_monitoring,
331 328
 		server_monitoring_agg, usr_preferences_types, admin_privileges to $DBROUSER;" 
332 329