Comments (11)
In my case:
This problem is caused by apparmor and i solved it by disabling its profile. This may help http://www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/
And i see a bit difference in the compile sentence, i used this one: "gcc -DMYSQL_DYNAMIC_PLUGIN -fPIC -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o $(LIBDIR)/lib_mysqludf_sys.so"
from lib_mysqludf_sys.
Thank you!
Now improved somewhat but still not doing what I would like to do. Execute a ffmpeg command or a php script, or even copy a file from a path to another.
I've tested with the compile command that I've posted and yours, both the same result.
Now at least it is working some test commands:
mysql> SELECT sys_eval('id');
+-------------------------------------------------+
| sys_eval('id') |
+-------------------------------------------------+
| uid=116(mysql) gid=125(mysql) groups=125(mysql) |
+-------------------------------------------------+
1 row in set (0.09 sec)
mysql> SELECT sys_eval('pwd');
+-----------------+
| sys_eval('pwd') |
+-----------------+
| /var/lib/mysql |
+-----------------+
1 row in set (0.01 sec)
But others like these not:
mysql> SELECT sys_eval('cp /home/cassiano/Desktop/index.html /home/cassiano/');
+------------------------------------------------------------------+
| sys_eval('cp /home/cassiano/Desktop/index.html /home/cassiano/') |
+------------------------------------------------------------------+
| NULL |
+------------------------------------------------------------------+
1 row in set (0.02 sec)
mysql> SELECT sys_exec('cp /home/cassiano/Desktop/index.html /home/cassiano/');
+------------------------------------------------------------------+
| sys_exec('cp /home/cassiano/Desktop/index.html /home/cassiano/') |
+------------------------------------------------------------------+
| 256 |
+------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT sys_exec('ffmpeg -i ~/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 ~/teste/img%03d.jpg');
+----------------------------------------------------------------------------------------------------------------+
| sys_exec('ffmpeg -i ~/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 ~/teste/img%03d.jpg') |
+----------------------------------------------------------------------------------------------------------------+
| 256 |
+----------------------------------------------------------------------------------------------------------------+
1 row in set (2.03 sec)
mysql> SELECT sys_eval('ffmpeg -i ~/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 ~/teste/img%03d.jpg');
+----------------------------------------------------------------------------------------------------------------+
| sys_eval('ffmpeg -i ~/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 ~/teste/img%03d.jpg') |
+----------------------------------------------------------------------------------------------------------------+
| NULL |
+----------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
from lib_mysqludf_sys.
sys_exec and sys_eval are quite similar, both can run arbitrary code, but the first one returns the exit code and second one the output. Some times i have had to do an explicit cast due to a blob type response (with gui). These are good tests:
mysql> select
-> sys_eval('curl http://ipecho.net/plain') as plain,
-> CAST(sys_eval('curl http://ipecho.net/plain') AS CHAR(10000) CHARACTER SET utf8) as cast,
-> sys_exec('curl http://ipecho.net/plain') as sys_exec;
+---------------+---------------+----------+
| plain | cast | sys_exec |
+---------------+---------------+----------+
| xxx.xx.xx.xxx | xxx.xx.xx.xxx | 0 |
+---------------+---------------+----------+
1 row in set (3.52 sec)
Your ffmpeg issue could be a permissions problem, checkout this command:
which ffmpeg | xargs ls -lh
Anyway make sure in the filesystem that it doesn't run.
"cp", "touch", "mv" does not return anything on success. You should check your fs and confirm the copy.
from lib_mysqludf_sys.
Thank you again daper, I know that the functions are similar but was just to make sure.
Your test worked like expected, returned my ip address in plain and cast columns.
The ffmpeg is under my home folder because I've compiled it and has my user permission:
$ which ffmpeg | xargs ls -lh
-rwxr-xr-x 1 cassiano cassiano 16M Jun 10 16:13 /home/cassiano/bin/ffmpeg
The "cp", "touch", "mv" does not return and does not do anything. The same command line of my example:
cp /home/cassiano/Desktop/index.html /home/cassiano/
Works in the terminal (copy the file) and does not work under udf sys functions.
The command:
ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 /home/cassiano/teste/img%03d.jpg
Works in terminal but not using "sys_exec"
from lib_mysqludf_sys.
Ok... In copy command the output code you are receiving corresponds with errors like "No such file or directory" or "Not a directory". You can try something like:
select sys_exec('ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 /home/cassiano/teste/img%03d.jpg &> /tmp/debug-exec.log'
And review the log file in /tmp/debug-exec.log... But i have no more relevant ideas.
from lib_mysqludf_sys.
Thank you for the time spent trying to help me.
I've tried your idea without success... The command has created the file but it is empty. Maybe is something wrong about permissions, that's the only option in my mind. Some commands run others not. Running "sys_eval('pwd')" return "/var/lib/mysql", running "sys_eval('whoami')" returns "mysql".
Tried to give root privileges to mysql user add the row:
mysql ALL=(ALL:ALL) ALL
in "/etc/sudoers"
The commands still not working.
I've tried to create a php script to run a system command:
<?php
$file = 'results.txt';
$current = file_get_contents($file);
$current .= $argv[1]."\n";
$output = system($argv[1]);
$current .= $output."\n";
file_put_contents($file, $current);
?>
Again, it works in terminal but not using sys_exec
php5 -e "/var/www/html/do_job.php" "/bin/cp /home/cassiano/Desktop/index.html /home/cassiano/"
The weird thing is that this php script create the results.txt inside /var/lib/mysql with the parameter but the index.html it is not copied...
from lib_mysqludf_sys.
Something is going wrong here, I don't know what yet, but when I run:
SELECT sys_eval('/usr/bin/php5 -e "/var/www/html/do_jobs.php" "ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 img%03d.jpg"');
The frame images are generate successfully but under "/var/lib/mysql", the path returned in my "sys_eval('pwd')" test.
When I try to run:
SELECT sys_eval('/usr/bin/php5 -e "/var/www/html/do_jobs.php" "ffmpeg -i /home/cassiano/teste/BigBuckBunny_320x180.mp4 -s 50x10 -f image2 -vf fps=fps=1/60 /home/cassiano/teste/img%03d.jpg"');
Just adding the path "/home/cassiano/teste/" to the image that will be generated nothing happens, the ffmpeg don't generate the images, or even run.
EDITED ================================
WORKS! finally! I don't have enough knowledge to explain but after giving the permissions to the ffmpeg output folder:
sudo chown mysql:mysql /home/cassiano/teste/ -R
It works! I would like to understand because in the last post I mentioned that I gave root privileges to mysql user.
from lib_mysqludf_sys.
Hello, I have the same problem here... I cannot execute even a simple cp command :(
from lib_mysqludf_sys.
Nothing happens :
mysql> SELECT sys_exec('cp /tmp/sefer /MYSQL') as sys_exec;
+----------+
| sys_exec |
+----------+
| 256 |
+----------+
1 row in set (0.02 sec)
from lib_mysqludf_sys.
I had issues with Ubuntu 20.04 getting it to run python scripts - After eventually getting it to compile on an VM & RPI I used the following for testing
select
CAST(sys_eval('pwd') AS CHAR(10000) CHARACTER SET utf8) as PWD,
CAST(sys_eval('id') AS CHAR(10000) CHARACTER SET utf8) as ID,
CAST(sys_eval('/home/sphere/WebAIPy/test.sh') AS CHAR(10000) CHARACTER SET utf8) as MSsql,
CAST(sys_eval(' cp /home/sphere/WebAIPy/MSSql_Minicom_WebAI.py /tmp') AS CHAR(10000) CHARACTER SET utf8) as Copy,
CAST(sys_eval('/home/sphere/WebAIPy//MSSql_Minicom_WebAI.py') AS CHAR(10000) CHARACTER SET utf8) as MSsql_dir;
I tried all the above suggestions - but couldn't get it run the python script
so I used the script to call the python script as a different user
#!/bin/bash exec &> /home/sphere/WebAIPy/myscript.log echo $(date) sudo -u user /home/sphere/WebAIPy/MSSql_Minicom_WebAI.py Password exit 0
note: you will need to change user and password to an appropriate user
from lib_mysqludf_sys.
On the production server I had to give run permissions to the bash script "test.sh" and that was it as far as security changes went
from lib_mysqludf_sys.
Related Issues (20)
- sql file run in phpmyadmin run time error
- Cant't import to phpmyadmin HOT 1
- No paths allowed for shared library (At installation) HOT 2
- 64bits recompilation fails. Error with header files HOT 5
- how to install on mac HOT 1
- need an update for MariaDB 10 HOT 5
- Can't install on Ubuntu 16.04.5 LTS "Unable to locate package libmysqlclient15-dev" HOT 2
- Where should I place this library in my Computer ? can anyone give me a path for that ?
- Out of memory when creating a procedure
- Provide install instruction for mysql Docker container HOT 1
- Need root to install HOT 1
- ERROR 1125 (HY000) at line 29: Function 'lib_mysqludf_sys_info' already exists HOT 2
- ERROR 1126 (HY000) at line 29: Can't open shared library 'lib_mysqludf_sys.so' (errno: 11 /usr/local/mysql/lib/plugin/lib_mysqludf_sys.so: wrong ELF class: ELFCLASS32) HOT 3
- fatal error: my_atomic.h: No such file or directory HOT 2
- Seems impossible to pass a variable from trigger to cmd
- not compatible with mysql 8.0 HOT 1
- Can't find symbol 'lib_mysqludf_sys_info' in library
- mysql crashed with mariadb 10.3 HOT 1
- sys_eval() not freeing memory and can cause crashes
- Not possible to compile on Ubuntu, code doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lib_mysqludf_sys.