If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Revoke CONTROL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-06, 14:53
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Revoke CONTROL

Not sure if anyone is interested in this or not, but I figured I would post up.

Requirements. Revoke CONTROL.

Problem. Users having CONTROL access. Prior to 8.2 version for developers to be able to replace the data. Once on 8.2 CONTROL no longer needed S,I,U,D is enough to perform the replace. Problem arrises when you exsecute REVOKE it revokes control but grants INSERT, UPDATE, DELETE, ALTER, INDEX, REFERENCES "with grant option" which now allows developers to grant access on the object to people that should not have access.

Solution. Revoke CONTROL followed by revoking the new given grants followed by granting correct grants.

This script is very primitive but work If you can provide a better solution please do so.

cat revoke_control.sh
#!/bin/ksh
#
# this script is to clean up the control access
#
#

dbname=$1
schema=$2

db2 connect to $dbname;

db2look -d $dbname -z $schema -x | grep -i control > zaza
#______________________________
#clean up the extra characters

sed 's/ "."/./g' zaza >zaza1

sed 's/"//g' zaza1 > zaza

################################################## ####
#Generate revoke and new grants
################################################## ####

sed 's/ GRANT / REVOKE /g' zaza >revoke
sed 's/ TO / FROM /g' revoke >revoke1

sed 's/ CONTROL / ALL /g' revoke1 > revoke2

sed 's/ CONTROL / SELECT, INSERT, UPDATE, DELETE /g' zaza >newgrant

rm revoke
mv revoke1 revoke

db2 -tvf revoke >revoke.out
db2 -tvf revoke2 >>revoke.out
db2 -tvf newgrant >>revoke.out


Have fun.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0

Last edited by Cougar8000; 01-31-06 at 10:07.
Reply With Quote
  #2 (permalink)  
Old 01-29-06, 16:10
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Thanks for sharing the info.

Do you mean REPLACE option using IMPORT or LOAD ?

An alternative to revoking CONTROL, SELECT etc is REVOKE ALL FROM TABLE1
ie
sed 's/ CONTROL / SELECT, INSERT, UPDATE, DELETE, ALTER, INDEX, REFERENCES /g' revoke1 > revoke2

can be

sed 's/ CONTROL / ALL /g' revoke1 > revoke2


HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 01-30-06, 14:26
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Yes

and

Yes
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #4 (permalink)  
Old 01-31-06, 10:06
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Quote:
Originally Posted by sathyaram_s
Thanks for sharing the info.

Do you mean REPLACE option using IMPORT or LOAD ?

An alternative to revoking CONTROL, SELECT etc is REVOKE ALL FROM TABLE1
ie
sed 's/ CONTROL / SELECT, INSERT, UPDATE, DELETE, ALTER, INDEX, REFERENCES /g' revoke1 > revoke2

can be

sed 's/ CONTROL / ALL /g' revoke1 > revoke2


HTH

Sathyaram
Sathyaram,

I have did more testing on this and it looks like your recomendation about using ALL will prevent some of the headache. It is specially comes into play when working with the views. Great catch.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On