-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Dockerfile, test script and README #29
Open
pavelsr
wants to merge
3
commits into
mysqludf:master
Choose a base branch
from
pavelsr:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM mariadb | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
gcc \ | ||
libmysqlclient-dev \ | ||
nano \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /root/lib_mysqludf_sys | ||
|
||
COPY lib_mysqludf_sys.c ./ | ||
COPY lib_mysqludf_sys.sql /docker-entrypoint-initdb.d/. | ||
COPY hello_world.sh /home/mysql/hello_world.sh | ||
|
||
RUN gcc -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o $(mysql_config --plugindir)/lib_mysqludf_sys.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
![docker-cloud-automated](https://img.shields.io/docker/cloud/automated/pavelsr/mysqludf_sys) | ||
![docker-cloud-build](https://img.shields.io/docker/cloud/build/pavelsr/mysqludf_sys) | ||
![docker-stars](https://img.shields.io/docker/stars/pavelsr/mysqludf_sys) | ||
![docker-pulls](https://img.shields.io/docker/pulls/pavelsr/mysqludf_sys) | ||
|
||
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 --> | ||
|
||
- [DESCRIPTION](#description) | ||
- [FUNCTIONS](#functions) | ||
- [sys_eval](#syseval) | ||
- [sys_exec](#sysexec) | ||
- [sys_get](#sysget) | ||
- [sys_set](#sysset) | ||
- [INSTALLATION](#installation) | ||
- [DOCKER IMAGE](#docker-image) | ||
- [Build](#build) | ||
- [Run](#run) | ||
- [EXAMPLES](#examples) | ||
- [SECUIRITY PRECAUTIONS](#secuirity-precautions) | ||
|
||
<!-- /TOC --> | ||
|
||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
whoami | ||
echo "Hello world" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo
SECUIRITY
->SECURITY