print " 7. Create/append full privileges for an existing database\n";
print " and host combination (user has FULL privilege)\n";
print " and host combination (user has FULL privilege)\n";
print " 8. Remove all privileges for for an existing database and\n";
print " 7. Remove all privileges for for an existing database and\n";
print " host combination.\n";
print " host combination.\n";
print " (user will have all permission fields set to N)\n";
print " (user will have all permission fields set to N)\n";
print " 0. exit this program\n";
print " 0. exit this program\n";
...
@@ -117,10 +114,10 @@ sub q1 { # first question ...
...
@@ -117,10 +114,10 @@ sub q1 { # first question ...
while(<STDIN>){
while(<STDIN>){
$answer=$_;
$answer=$_;
chomp($answer);
chomp($answer);
if($answer=~ /^[12345678]$/){
if($answer=~ /^[1234567]$/){
if($answer== 1){
if($answer== 1){
setpwd();
setpwd();
} elsif ($answer=~ /^[2345678]$/){
} elsif ($answer=~ /^[234567]$/){
addall($answer);
addall($answer);
}else{
}else{
print "Sorry, something went wrong. With such option number you should not get here.\n\n";
print "Sorry, something went wrong. With such option number you should not get here.\n\n";
...
@@ -233,7 +230,7 @@ sub addall {
...
@@ -233,7 +230,7 @@ sub addall {
}
}
}
}
if((!$todo) or not ($todo=~ m/^[2-8]$/)){
if((!$todo) or not ($todo=~ m/^[2-7]$/)){
print STDERR "Sorry, select option $todo isn't known inside the program .. See ya\n";
print STDERR "Sorry, select option $todo isn't known inside the program .. See ya\n";
quit();
quit();
}
}
...
@@ -256,12 +253,9 @@ sub addall {
...
@@ -256,12 +253,9 @@ sub addall {
# user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
# user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
$sth=$dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'")|| die $dbh->errstr;
$sth=$dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'")|| die $dbh->errstr;
} elsif ($todo== 6){
} elsif ($todo== 6){
# admin privileges: GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS
$sth=$dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'")|| die $dbh->errstr;
} elsif ($todo== 7){
# all privileges
# all privileges
$sth=$dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'")|| die $dbh->errstr;
$sth=$dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'")|| die $dbh->errstr;
} elsif ($todo==8){
} elsif ($todo==7){
# all privileges set to N
# all privileges set to N
$sth=$dbh->do("REVOKE ALL ON *.* FROM \'$user\'\@\'$host\'")|| die $dbh->errstr;
$sth=$dbh->do("REVOKE ALL ON *.* FROM \'$user\'\@\'$host\'")|| die $dbh->errstr;