Command execution with a MySQL UDF - sys_exec does not work

592 views Asked by At

I am trying to run a python script from MariaDB server. I have installed mysqludf library for that. I am trying to run the script using sys_exec function, but there is no result. I have created test file which is just a .txt file with information "DONE".

I am executing the command as a root user, therefore I have all priviliges. Running the command:

SELECT sys_exec('python3 /home/Documents/test.py')

doesn't do anything and returs the error code 512. Running command:

SELECT sys_exec('sudo python3 /home/Documents/test.py')

return error code 256.

I have already checked apparmor status and there is nothing that seems to be a problem:

apparmor module is loaded.
42 profiles are loaded.
40 profiles are in enforce mode.
   /sbin/dhclient
   /snap/core/4486/usr/lib/snapd/snap-confine
   /snap/core/4486/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
   /snap/core/6964/usr/lib/snapd/snap-confine
   /snap/core/6964/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
   /snap/core/7169/usr/lib/snapd/snap-confine
   /snap/core/7169/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
   /snap/core/7270/usr/lib/snapd/snap-confine
   /snap/core/7270/usr/lib/snapd/snap-confine//mount-namespace-capture-helper
   /usr/bin/evince
   /usr/bin/evince-previewer
   /usr/bin/evince-previewer//sanitized_helper
   /usr/bin/evince-thumbnailer
   /usr/bin/evince//sanitized_helper
   /usr/bin/man
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/NetworkManager/nm-dhcp-helper
   /usr/lib/connman/scripts/dhclient-script
   /usr/lib/cups/backend/cups-pdf
   /usr/lib/snapd/snap-confine
   /usr/lib/snapd/snap-confine//mount-namespace-capture-helper
   /usr/sbin/cups-browsed
   /usr/sbin/cupsd
   /usr/sbin/cupsd//third_party
   /usr/sbin/ippusbxd
   /usr/sbin/tcpdump
   man_filter
   man_groff
   snap-update-ns.core
   snap-update-ns.eclipse
   snap-update-ns.gnome-calculator
   snap-update-ns.gnome-characters
   snap-update-ns.gnome-logs
   snap-update-ns.gnome-system-monitor
   snap-update-ns.pycharm-community
   snap.core.hook.configure
   snap.gnome-calculator.gnome-calculator
   snap.gnome-characters.gnome-characters
   snap.gnome-logs.gnome-logs
   snap.gnome-system-monitor.gnome-system-monitor
2 profiles are in complain mode.
   snap.eclipse.eclipse
   snap.pycharm-community.pycharm-community
4 processes have profiles defined.
4 processes are in enforce mode.
   /sbin/dhclient (734) 
   /usr/sbin/cups-browsed (33904) 
   /usr/sbin/cupsd (33899) 
   /usr/sbin/cupsd (33928) 
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.

I have also double checked if root has sudo privileges, and if fact it does.

What can be causeing the problem? Is there any way to run the python script from MariaDB Server?

1

There are 1 answers

0
cbarange On

I solve it using global install, like :

sudo -H pip3 install psycopg2