1

I am a beginner to lua language.The main concept is when a user fire the DROP TABLE command in mysql it should not be executed.But he can fire all other commands as usual in mysql.But i don't want to use GRANTS for this.Is there any luaScript to perform this action via mysql-proxy?

For example:

mysql> DROP TABLE T1;
Please wait for authentication

Also is LuaSql helpful to perform this task via mysql-proxy?

Hope i made the idea clear.Someone help me solve out this issue.Thanks in advance.

robin
  • 19
  • 1
  • 10
  • sorry to have to ask this, but, could you please somehow rephrase your question using common grammar and typesetting rules? it's very difficult to read, because almost everything is one line/sentence... – nonchip Jun 27 '14 at 14:15
  • @nonchip I have made some changes.Hope u can understand it – robin Jul 01 '14 at 04:32
  • 1
    You could try to filter for any occurences of the string "drop", but i think you really want to use grant for that. – nonchip Jul 01 '14 at 19:25
  • @nonchip I tried a few methods in which it is possible to filter using string occurences via mysql-proxy only after the queries are executed. But i don't know how to filter before executing out the queries. – robin Jul 02 '14 at 03:51
  • may I suggest to change the title to be more precise along the lines of: "use mysql-proxy to block/drop specific queries send to server". The current title is technically correct but less descriptive and when I was personally searching for the answer it showed after multiple different attempts with google and different phrasings. – Sim Jul 26 '17 at 17:42

1 Answers1

0

Yes, you can do that. The idea here is to check a query whether or not it fulfills the requirements you want to filter and if so NOT sending it to the server

function read_query(packet)
        if string.byte(packet) == proxy.COM_QUERY then
                query = packet:sub(2)
                if condition(query) then
                   proxy.response = {
                           type = proxy.MYSQLD_PACKET_OK,
                   }
                   return proxy.PROXY_SEND_RESULT
                end
        end
end

This checks each query the proxy receives for condition and if it matches it will just return a SUCCESS to the client without delivering the query. Thus effectively dropping the query.

Sim
  • 4,199
  • 4
  • 39
  • 77