Strange behaviour with the mount namespace of Apache2 on Raspbian

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm currently trying to understand why Apache2 (2.4.25-3+deb9u2) running on Raspbian Stretch (Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux) is having a different view on the root-mountpoint than -for example- bash.



cat /proc/PID of Apache2/mountinfo gives the following output:



129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root ro,data=ordered


cat /proc/self/mountinfo executed from bash gives the following output:



15 0 179:2 / / ro,noatime shared:1 - ext4 /dev/root ro,data=ordered


As far as I have understood the explanations from man 7 mount_namespaces, https://lwn.net/Articles/689856/, https://lwn.net/Articles/690679/ and man 5 proc the output tells me that Apache is a slave to the peer group 1. It itself created a shared peer group with ID 80.



What I don't understand is, why that happens. I thought that systemd is in control of that and so I created the file /etc/systemd/system/apache2.service with the following content:



.include /lib/systemd/system/apache2.service

[Service]
MountFlags=shared


But obviously this didn't help. There's also no difference when I remove the MountFlags line.



So next to understanding why the situation is like it is, I would like to know if there's any way to prevent Apache becoming a slave to the root mount peer group.



Furthermore, if I remount the root directory to be writeable by mount -o remount,rw / in bash, this is not propagated into the Apache2 mount namespace. Example, starting with the mountinfo from above:



# mount -o remount,rw /
# cat /proc/self/mountinfo
15 0 179:2 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered
# cat /proc/PID of Apache2/mountinfo
129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root rw,data=ordered


Is this part of any security feature of Apache?



Update 1: If I (re)start the Apache2 service while root is mounted rw, the remounts will be propagated to the Apache2 mount namespace. Only if the Apache2 service is started while root is ro, it does not work?!







share|improve this question






















  • did you remember to do sudo systemctl daemon-reload after editing the service unit?
    – meuh
    Oct 17 '17 at 18:09










  • Yes, of course...
    – Max Senft
    Oct 19 '17 at 11:50














up vote
0
down vote

favorite












I'm currently trying to understand why Apache2 (2.4.25-3+deb9u2) running on Raspbian Stretch (Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux) is having a different view on the root-mountpoint than -for example- bash.



cat /proc/PID of Apache2/mountinfo gives the following output:



129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root ro,data=ordered


cat /proc/self/mountinfo executed from bash gives the following output:



15 0 179:2 / / ro,noatime shared:1 - ext4 /dev/root ro,data=ordered


As far as I have understood the explanations from man 7 mount_namespaces, https://lwn.net/Articles/689856/, https://lwn.net/Articles/690679/ and man 5 proc the output tells me that Apache is a slave to the peer group 1. It itself created a shared peer group with ID 80.



What I don't understand is, why that happens. I thought that systemd is in control of that and so I created the file /etc/systemd/system/apache2.service with the following content:



.include /lib/systemd/system/apache2.service

[Service]
MountFlags=shared


But obviously this didn't help. There's also no difference when I remove the MountFlags line.



So next to understanding why the situation is like it is, I would like to know if there's any way to prevent Apache becoming a slave to the root mount peer group.



Furthermore, if I remount the root directory to be writeable by mount -o remount,rw / in bash, this is not propagated into the Apache2 mount namespace. Example, starting with the mountinfo from above:



# mount -o remount,rw /
# cat /proc/self/mountinfo
15 0 179:2 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered
# cat /proc/PID of Apache2/mountinfo
129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root rw,data=ordered


Is this part of any security feature of Apache?



Update 1: If I (re)start the Apache2 service while root is mounted rw, the remounts will be propagated to the Apache2 mount namespace. Only if the Apache2 service is started while root is ro, it does not work?!







share|improve this question






















  • did you remember to do sudo systemctl daemon-reload after editing the service unit?
    – meuh
    Oct 17 '17 at 18:09










  • Yes, of course...
    – Max Senft
    Oct 19 '17 at 11:50












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm currently trying to understand why Apache2 (2.4.25-3+deb9u2) running on Raspbian Stretch (Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux) is having a different view on the root-mountpoint than -for example- bash.



cat /proc/PID of Apache2/mountinfo gives the following output:



129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root ro,data=ordered


cat /proc/self/mountinfo executed from bash gives the following output:



15 0 179:2 / / ro,noatime shared:1 - ext4 /dev/root ro,data=ordered


As far as I have understood the explanations from man 7 mount_namespaces, https://lwn.net/Articles/689856/, https://lwn.net/Articles/690679/ and man 5 proc the output tells me that Apache is a slave to the peer group 1. It itself created a shared peer group with ID 80.



What I don't understand is, why that happens. I thought that systemd is in control of that and so I created the file /etc/systemd/system/apache2.service with the following content:



.include /lib/systemd/system/apache2.service

[Service]
MountFlags=shared


But obviously this didn't help. There's also no difference when I remove the MountFlags line.



So next to understanding why the situation is like it is, I would like to know if there's any way to prevent Apache becoming a slave to the root mount peer group.



Furthermore, if I remount the root directory to be writeable by mount -o remount,rw / in bash, this is not propagated into the Apache2 mount namespace. Example, starting with the mountinfo from above:



# mount -o remount,rw /
# cat /proc/self/mountinfo
15 0 179:2 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered
# cat /proc/PID of Apache2/mountinfo
129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root rw,data=ordered


Is this part of any security feature of Apache?



Update 1: If I (re)start the Apache2 service while root is mounted rw, the remounts will be propagated to the Apache2 mount namespace. Only if the Apache2 service is started while root is ro, it does not work?!







share|improve this question














I'm currently trying to understand why Apache2 (2.4.25-3+deb9u2) running on Raspbian Stretch (Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux) is having a different view on the root-mountpoint than -for example- bash.



cat /proc/PID of Apache2/mountinfo gives the following output:



129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root ro,data=ordered


cat /proc/self/mountinfo executed from bash gives the following output:



15 0 179:2 / / ro,noatime shared:1 - ext4 /dev/root ro,data=ordered


As far as I have understood the explanations from man 7 mount_namespaces, https://lwn.net/Articles/689856/, https://lwn.net/Articles/690679/ and man 5 proc the output tells me that Apache is a slave to the peer group 1. It itself created a shared peer group with ID 80.



What I don't understand is, why that happens. I thought that systemd is in control of that and so I created the file /etc/systemd/system/apache2.service with the following content:



.include /lib/systemd/system/apache2.service

[Service]
MountFlags=shared


But obviously this didn't help. There's also no difference when I remove the MountFlags line.



So next to understanding why the situation is like it is, I would like to know if there's any way to prevent Apache becoming a slave to the root mount peer group.



Furthermore, if I remount the root directory to be writeable by mount -o remount,rw / in bash, this is not propagated into the Apache2 mount namespace. Example, starting with the mountinfo from above:



# mount -o remount,rw /
# cat /proc/self/mountinfo
15 0 179:2 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered
# cat /proc/PID of Apache2/mountinfo
129 127 179:2 / / ro,noatime shared:80 master:1 - ext4 /dev/root rw,data=ordered


Is this part of any security feature of Apache?



Update 1: If I (re)start the Apache2 service while root is mounted rw, the remounts will be propagated to the Apache2 mount namespace. Only if the Apache2 service is started while root is ro, it does not work?!









share|improve this question













share|improve this question




share|improve this question








edited Oct 16 '17 at 15:21

























asked Oct 16 '17 at 13:13









Max Senft

1234




1234











  • did you remember to do sudo systemctl daemon-reload after editing the service unit?
    – meuh
    Oct 17 '17 at 18:09










  • Yes, of course...
    – Max Senft
    Oct 19 '17 at 11:50
















  • did you remember to do sudo systemctl daemon-reload after editing the service unit?
    – meuh
    Oct 17 '17 at 18:09










  • Yes, of course...
    – Max Senft
    Oct 19 '17 at 11:50















did you remember to do sudo systemctl daemon-reload after editing the service unit?
– meuh
Oct 17 '17 at 18:09




did you remember to do sudo systemctl daemon-reload after editing the service unit?
– meuh
Oct 17 '17 at 18:09












Yes, of course...
– Max Senft
Oct 19 '17 at 11:50




Yes, of course...
– Max Senft
Oct 19 '17 at 11:50










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Remove the PrivateTmp=true setting in apache2.service.



https://www.freedesktop.org/software/systemd/man/systemd.exec.html :




If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace.







share|improve this answer




















  • I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
    – Max Senft
    Mar 17 at 14:05










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398408%2fstrange-behaviour-with-the-mount-namespace-of-apache2-on-raspbian%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










Remove the PrivateTmp=true setting in apache2.service.



https://www.freedesktop.org/software/systemd/man/systemd.exec.html :




If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace.







share|improve this answer




















  • I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
    – Max Senft
    Mar 17 at 14:05














up vote
0
down vote



accepted










Remove the PrivateTmp=true setting in apache2.service.



https://www.freedesktop.org/software/systemd/man/systemd.exec.html :




If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace.







share|improve this answer




















  • I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
    – Max Senft
    Mar 17 at 14:05












up vote
0
down vote



accepted







up vote
0
down vote



accepted






Remove the PrivateTmp=true setting in apache2.service.



https://www.freedesktop.org/software/systemd/man/systemd.exec.html :




If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace.







share|improve this answer












Remove the PrivateTmp=true setting in apache2.service.



https://www.freedesktop.org/software/systemd/man/systemd.exec.html :




If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace.








share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 19 at 5:32









WhiteWind

1866




1866











  • I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
    – Max Senft
    Mar 17 at 14:05
















  • I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
    – Max Senft
    Mar 17 at 14:05















I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
– Max Senft
Mar 17 at 14:05




I already found out that solution but forgot to update this question. Sorry. But to keep the original config files original, I created the file /etc/systemd/system/apache2.service.d/config_override.conf with the line PrivateTmp=false under the [Service] group.
– Max Senft
Mar 17 at 14:05

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398408%2fstrange-behaviour-with-the-mount-namespace-of-apache2-on-raspbian%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)