systemd tmp redirect is blocking database setup install/step2.php #2663
Description
###Expected behaviour
Database Setup (install/step2.php, actually nzedb/db/DbUpdate.php) is copying *.tsv files from resources/db/schema/data/ to /tmp/, and executing SQL queries to import data from tsv files.
###Actual behaviour
tsv files are NOT copied to /tmp/ but a systemd redirected tmp subdirectory under /tmp/
This means mysql cannot read the files, when running the LOAD DATA INFILE query, print errors like these for each '10-*.tsv' file
File: /var/www/nZEDb/resources/db/schema/data/10-binaryblacklist.tsv Inserting data into table: 'binaryblacklist'
[05/Mar/2023 19:26] [NOTICE] [0.00,0.00,0.00] [00H:00M:01S] [MEM:~~~4MB] [USR: 00H:00M:00S SYS: 00H:00M:00S FAULTS: 0 SWAPS: 0] [PID:4202] [nzedb\db\DB.Exec] [SQLSTATE[HY000]: General error: 13 Can't get stat of '/tmp/10-binaryblacklist.tsv' (Errcode: 2 "No such file or directory")]
SQLSTATE[HY000]: General error: 13 Can't get stat of '/tmp/10-binaryblacklist.tsv' (Errcode: 2 "No such file or directory")
[05/Mar/2023 19:26] [SQL] [0.00,0.00,0.00] [00H:00M:01S] [MEM:~~~4MB] [USR: 00H:00M:00S SYS: 00H:00M:00S FAULTS: 0 SWAPS: 0] [PID:4202] [nzedb\db\DB.exec] [LOAD DATA INFILE "/tmp/10-binaryblacklist.tsv" IGNORE INTO TABLE `binaryblacklist` FIELDS TERMINATED BY "\t" LINES TERMINATED BY " " IGNORE 1 LINES (id, groupname, regex, msgcol, optype, status, description)]
/tmp/ directory has no tsv files:
$ ls /tmp/ -al
total 40
drwxrwxrwt 10 root root 4096 Mar 5 19:38 .
drwxr-xr-x 22 root root 4096 Mar 5 16:43 ..
drwxrwxrwt 2 root root 4096 Mar 5 16:45 .font-unix
drwxrwxrwt 2 root root 4096 Mar 5 16:45 .ICE-unix
drwx------ 3 root root 4096 Mar 5 19:24 systemd-private-7ebc474cd90e43ae81d148ce15ed4abb-apache2.service-E1R51f
drwx------ 3 root root 4096 Mar 5 16:45 systemd-private-7ebc474cd90e43ae81d148ce15ed4abb-systemd-resolved.service-38428w
drwx------ 3 root root 4096 Mar 5 16:45 systemd-private-7ebc474cd90e43ae81d148ce15ed4abb-systemd-timesyncd.service-SHRNZw
drwxrwxrwt 2 root root 4096 Mar 5 16:45 .Test-unix
drwxrwxrwt 2 root root 4096 Mar 5 16:45 .X11-unix
drwxrwxrwt 2 root root 4096 Mar 5 16:45 .XIM-unix
... instead they are under systemd-private subfolder:
$ sudo ls -al /tmp/systemd-private-7ebc474cd90e43ae81d148ce15ed4abb-apache2.service-E1R51f/tmp/
total 732
drwxrwxrwt 2 root root 4096 Mar 5 19:26 .
drwx------ 3 root root 4096 Mar 5 19:24 ..
-rwxrwxr-x 1 www-data www-data 3231 Mar 5 19:26 10-binaryblacklist.tsv
-rwxrwxr-x 1 www-data www-data 1216 Mar 5 19:26 10-categories.tsv
-rwxrwxr-x 1 www-data www-data 120 Mar 5 19:26 10-category_regexes.tsv
-rwxrwxr-x 1 www-data www-data 197512 Mar 5 19:26 10-collection_regexes.tsv
-rwxrwxr-x 1 www-data www-data 7322 Mar 5 19:26 10-countries.tsv
-rwxrwxr-x 1 www-data www-data 132 Mar 5 19:26 10-forum_posts.tsv
-rwxrwxr-x 1 www-data www-data 2237 Mar 5 19:26 10-genres.tsv
-rwxrwxr-x 1 www-data www-data 15046 Mar 5 19:26 10-groups.tsv
-rwxrwxr-x 1 www-data www-data 1007 Mar 5 19:26 10-menu_items.tsv
-rwxrwxr-x 1 www-data www-data 449 Mar 5 19:26 10-page_contents.tsv
-rwxrwxr-x 1 www-data www-data 391742 Mar 5 19:26 10-release_naming_regexes.tsv
-rwxrwxr-x 1 www-data www-data 22652 Mar 5 19:26 10-settings.tsv
-rwxrwxr-x 1 www-data www-data 1215 Mar 5 19:26 10-tmux.tsv
-rwxrwxr-x 1 www-data www-data 613 Mar 5 19:26 mysql-data.sql
-rwxrwxr-x 1 www-data www-data 60506 Mar 5 19:26 mysql-ddl.sql
###Steps to reproduce the behaviour
New install on ubuntu server 18.04 LTS - following this guide:
https://github.com/nZEDb/nZEDb/wiki/Install-Guide:-Ubuntu-18.04
I suppose I can work around this, by disabling the systemd/tmp redirect for apache2 service, but the ideal solution would be to perhaps incorporate a perment fix in the code.
Unless I have overlooked something in the install guides?