Web Hosting Talk







View Full Version : little warning for cpanel users (admins & resellers)


heavypredato
02-03-2006, 12:08 AM
i discovered today that /scripts/killacct has this code:

else {
my $mysql = cPScript::Mysql->new;
$mysql->sendmysql("DELETE FROM user WHERE user='$user';");
$mysql->sendmysql("DELETE FROM user WHERE user LIKE '${user}_%';");
$mysql->sendmysql("DELETE FROM db WHERE user='$user';");
$mysql->sendmysql("DELETE FROM db WHERE user LIKE '${user}_%';");
$mysql->sendmysql("DELETE FROM tables_priv WHERE user='$user';");
$mysql->sendmysql("DELETE FROM tables_priv WHERE user LIKE '${user}_%';");
$mysql->sendmysql("DELETE FROM columns_priv WHERE user='$user';");
$mysql->sendmysql("DELETE FROM columns_priv WHERE user LIKE '${user}_%';");
$mysql->sendmysql("FLUSH PRIVILEGES;");
exit();
}

thanks to this when deleting account "rage", it deleted all mysql users on accounts rage2, rage3, rage4, rage5

DO NOT CREATE(or delete :D) ACCOUNTS WITH THE SAME USERNAME<number> or mysql users on other(username<number>) accounts will be deleted

p.s. no db user was harmed durning writing this thread :D

Scott.Mc
02-03-2006, 12:18 AM
Maybe I am blind but that will not delete rage2 etc.

cPanel stores databases in the format username_databasename

If you look it deletes username_% which is only any any database for that one username. There is no % before the username.

You could cause a deletion if you manually create databases called rage_2 however this means you are going out of the standard cPanel setup.

I can't see how that would have deleted your databases.

-Scott

webbist101
02-03-2006, 05:04 AM
The syntax of the SQL query looks like it puts in the username exactly as it is. SQL won't delete it based on a prefix. At least that's my understanding.

bithost(NET)
02-03-2006, 07:44 AM
If you do believe this is a problem, and can duplicate the issue, be sure to open a ticket in cPanel's Bugzilla ASAP. (Along with your proof/duplication, so the developers can see it in action)

:) Bailey

heavypredato
02-03-2006, 10:22 AM
im shure this is my problem

only users from rageX were deleted right after i deleted account rage

and everyone can recreate it - just try - did that without any problem again

Scott.Mc
02-03-2006, 10:25 AM
It could be the problem, since it's perl _ might be read as part of the regexp and not as a seperator.

I will test that later , I am not a perl programmer but it could provide the effect you have, and if it does


else {
my $mysql = cPScript::Mysql->new;
$mysql->sendmysql("DELETE FROM user WHERE user='$user';");
$mysql->sendmysql("DELETE FROM user WHERE user LIKE '${user}\_%';");
$mysql->sendmysql("DELETE FROM db WHERE user='$user';");
$mysql->sendmysql("DELETE FROM db WHERE user LIKE '${user}\_%';");
$mysql->sendmysql("DELETE FROM tables_priv WHERE user='$user';");
$mysql->sendmysql("DELETE FROM tables_priv WHERE user LIKE '${user}_%';");
$mysql->sendmysql("DELETE FROM columns_priv WHERE user='$user';");
$mysql->sendmysql("DELETE FROM columns_priv WHERE user LIKE '${user}_%';");
$mysql->sendmysql("FLUSH PRIVILEGES;");
exit();
}


Would fix it.

heavypredato
02-03-2006, 11:07 AM
i have submitted bug to bugzilla - and it is not deleting dbases just users

mrzippy
02-08-2006, 08:04 PM
i have submitted bug to bugzilla - and it is not deleting dbases just users
It will never get noticed until 2008 if you leave it in bugzilla.

Be sure to also send them an email to their TICKET support system and ask for assistance. Point them to the bugzilla bug for details, etc.

:)

magixman
02-11-2006, 01:31 AM
The syntax of the SQL query looks like it puts in the username exactly as it is. SQL won't delete it based on a prefix. At least that's my understanding.

I don't see how the code would delete rage1 if you tried to delete rage but I could see how it could delete rage_2 if you deleted rage. cPanel must have seen this coming and eliminate underscores when you create accounts. I just tried to test this.