Skip to content

A UDF library with functions to interact with the operating system. These functions allow you to interact with the execution environment in which MySQL runs.

Notifications You must be signed in to change notification settings

pavelsr/lib_mysqludf_sys

 
 

Repository files navigation

docker-cloud-automated docker-cloud-build docker-stars docker-pulls

DESCRIPTION

Functions that allow to interact with the operating system

FUNCTIONS

sys_eval

executes an arbitrary command, and returns it's output

syntax: sys_eval(arg1)

sys_exec

executes an arbitrary command, and returns it's exit code

syntax: sys_exec(arg1)

sys_get

gets the value of an environment variable

syntax: sys_get(arg1)

sys_set

create an environment variable, or update the value of an existing environment variable

syntax: sys_set(arg1, arg2)

arg1 - name of an environment value

arg2 - expression that contains the value that is to be assigned to the environment variabl

INSTALLATION

On runnning MySQL server just run install.sh script (don't forget to change here mysql root login and password)

DOCKER IMAGE

Build

docker build -t mysqludf/sys .

Run

docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysqludf/sys

EXAMPLES

SELECT sys_eval('id')
SELECT sys_eval('echo $HOME')
SELECT sys_eval('~/hello_world.sh')
SELECT sys_eval('bash /root/lib_mysqludf_sys/hello_world.sh')

SECUIRITY PRECAUTIONS

UDFs are available to all database users - you cannot grant EXECUTE privileges for them. As the commandstring passed to sys_exec or sys_eval can do pretty much everything, exposing the function poses a very real security hazard.

Even for a benign user, it is possible to accidentally do a lot of damage with it. The call will be executed with the privileges of the os user that runs MySQL, so it is entirely feasible to delete MySQL's data directory, or worse.

About

A UDF library with functions to interact with the operating system. These functions allow you to interact with the execution environment in which MySQL runs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 46.3%
  • C 36.0%
  • TSQL 7.7%
  • Shell 7.4%
  • Dockerfile 2.0%
  • Makefile 0.6%