how to set privatetmp=false permanently in ubuntu 18.04

Viewed 2463

I am running Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-1045-aws x86_64) on AWS. I am running PHP 7.2.24-0ubuntu0.18.04.7 (cli) (built: Oct 7 2020 15:24:25) ( NTS )

When I migrated to 18.04 from 16 I had to set up the following:

sudo su

nano /etc/systemd/system/multi-user.target.wants/apache2.service

[Service] ... PrivateTmp=true <-- Changed this to "false"

Then do the following:

/var/tmp$ sudo systemctl daemon-reload

/var/tmp$ sudo service apache2 restart

All ran fine after this but as of a few days ago the setting PrivateTmp=false changed to PrivateTmp=true so no files got written into the folder /var/tmp that my application depends on. My suspicion is that an update happened and it changed the setting of PrivateTmp=false. I am not sure how to proved that.

My questions:

is there a way to make the setting sticky and not have it undone by the update process.

Jack

2 Answers

Use the command sudo systemctl edit apache2, this will create an override.conf file in /etc/systemd/system/apache2.service.d/ which will not be... overridden on a system update :-) and add these lines:

[Service]
PrivateTmp=false

You can also create that file with any name (but ending in .conf) using your preferred editor.

Remebember to run systemctl daemon-reload command after that.

Copy the apache unit file to:

/etc/systemd/system

Unit files in this directory supersede the default location and will not be replaced when the package receives an update. Modify the unit file as needed, then issue:

systemctl daemon-reload
Related