This library lib_mysqludf_sys
contains a number of functions that allows one to interact with the operating system.
sys_eval
- executes an arbitrary command, and returns it's output.sys_exec
- executes an arbitrary command, and returns it's exit code.sys_get
- gets the value of an environment variable.sys_set
- create an environment variable, or update the value of an existing environment variable.
Use lib_mysqludf_sys_info()
to obtain information about the currently installed version of lib_mysqludf_sys
.
sys_eval
takes one command string argument and executes it, returning its output.
sys_eval(arg1)
arg1
Place the shared library binary in an appropriate location. Log in to mysql as root or as another user with sufficient privileges, and select any database. Then, create the function using the following DDL statement:
CREATE FUNCTION sys_eval RETURNS STRING SONAME 'lib_mysqludf_sys.so';
The function will be globally available in all databases.
The deinstall the function, run the following statement:
DROP FUNCTION sys_eval;
None yet
Be very careful in deciding whether you need this function.
UDFs are available to all database users - you cannot grant EXECUTE privileges for them.
As the commandstring passed to sys_exec
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.
The function is intended for specialized MySQL applications where one needs extended control over the operating system. Currently, we do not have UDF's for ftp, email and http, and this function can be used to implement such functionality in case it is really necessary (datawarehouse staging areas could be a case in example).
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using AppArmor.
sys_exec
takes one command string argument and executes it.
sys_exec(arg1)
arg1
Place the shared library binary in an appropriate location. Log in to mysql as root or as another user with sufficient privileges, and select any database. Then, create the function using the following DDL statement:
CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so';
The function will be globally available in all databases.
The deinstall the function, run the following statement:
DROP FUNCTION sys_exec;
None yet
Be very careful in deciding whether you need this function.
UDFs are available to all database users - you cannot grant EXECUTE privileges for them.
As the commandstring passed to sys_exec
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.
The function is intended for specialized MySQL applications where one needs extended control over the operating system. Currently, we do not have UDF's for ftp, email and http, and this function can be used to implement such functionality in case it is really necessary (datawarehouse staging areas could be a case in example).
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using AppArmor.
sys_get
takes the name of an environment variable and returns the value of the variable.
sys_get([arg1)
arg1
Place the shared library binary in an appropriate location. Log in to mysql as root or as another user with sufficient privileges, and select any database. Then, create the function using the following DDL statement:
CREATE FUNCTION sys_get RETURNS STRING SONAME 'lib_mysqludf_sys.so';
The function will be globally available in all databases.
The deinstall the function, run the following statement:
DROP FUNCTION sys_get;
None yet
Be very careful in deciding whether you need this function. UDFs are available to all database users - you cannot grant EXECUTE privileges for them. The variables known in the environment where mysql runs are freely accessible using this function. Any user can get access to potentially secret information, such as the user that is running mysqld, the path of the user's home directory etc.
The function is intended for specialized MySQL applications where one needs extended control over the operating system.
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
sys_get
takes the name of an environment variable and returns the value of the variable.
sys_set([arg1, arg2)
arg1
arg2
Place the shared library binary in an appropriate location. Log in to mysql as root or as another user with sufficient privileges, and select any database. Then, create the function using the following DDL statement:
CREATE FUNCTION sys_set RETURNS STRING SONAME 'lib_mysqludf_sys.so';
The function will be globally available in all databases.
The deinstall the function, run the following statement:
DROP FUNCTION sys_set;
None yet
Be very careful in deciding whether you need this function. UDFs are available to all database users - you cannot grant EXECUTE privileges for them. This function will overwrite existing environment variables.
The function is intended for specialized MySQL applications where one needs extended control over the operating system.
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.