You are not logged in.

#1 2024-09-27 12:57:57

FishBoneEK
Member
Registered: 2023-09-26
Posts: 57

[SOLVED] MariaDB weird behaviour with /tmp?

Files MariaDB creates and writes under /tmp are invisible:

SELECT * FROM users INTO OUTFILE '/tmp/dump';
SELECT LOAD_FILE('/tmp/dump');
...result is OK
ls /tmp/dump
ls: cannot access '/tmp/dump': No such file or directory

Files created by me under /tmp is invisible to MariaDB:

echo 'hi' > /tmp/bar
SELECT LOAD_FILE('/tmp/bar');
+-----------------------+
| LOAD_FILE('/tmp/bar') |
+-----------------------+
| NULL                  |
+-----------------------+
1 row in set (0.000 sec)

But it just works if I load_file on other files other than /tmp/files:

sudo mkdir /exportdata
echo 'hi' | sudo tee /exportdata/foo
SELECT LOAD_FILE('/exportdata/foo');
+------------------------------+
| LOAD_FILE('/exportdata/foo') |
+------------------------------+
| hi
                          |
+------------------------------+
1 row in set (0.000 sec)
SELECT * FROM users INTO OUTFILE '/exportdata/users';
cat  /exportdata/users
1       John Smith      not-russian
2       '       ''

(By the way, /exportdata is 0755 owned by root:root, how did mariadbd create a file under this directory? mariadbd is run as user mysql)

Privilege of /tmp is ok:

Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

mount info:

tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=19434480k,nr_inodes=1048576,inode64)

It's as if MariaDB is using a different /tmp?

Last edited by FishBoneEK (2024-11-07 02:40:56)

Offline

#2 2024-09-27 13:02:25

FishBoneEK
Member
Registered: 2023-09-26
Posts: 57

Re: [SOLVED] MariaDB weird behaviour with /tmp?

I feel I should ask on StackOverflow instead after posting this, but can't find a delete button.

Offline

#3 2024-10-04 01:31:48

loqs
Member
Registered: 2014-03-06
Posts: 18,213

Re: [SOLVED] MariaDB weird behaviour with /tmp?

FishBoneEK wrote:

It's as if MariaDB is using a different /tmp?

It is.  /usr/lib/systemd/system/mariadb.service contains:

# If you don't use the /tmp directory for SELECT ... OUTFILE and
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
PrivateTmp=true

For more information on PrivateTmp see systemd.exec.5.

Offline

#4 2024-10-09 12:20:16

FishBoneEK
Member
Registered: 2023-09-26
Posts: 57

Re: [SOLVED] MariaDB weird behaviour with /tmp?

loqs wrote:
FishBoneEK wrote:

It's as if MariaDB is using a different /tmp?

It is.  /usr/lib/systemd/system/mariadb.service contains:

# If you don't use the /tmp directory for SELECT ... OUTFILE and
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
PrivateTmp=true

For more information on PrivateTmp see systemd.exec.5.

Wow thanks! This was really mysterious for a sec back there.

Offline

Board footer

Powered by FluxBB