Strange behaviour with the mount namespace of Apache2 on Raspbian

Clash 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?!
mount systemd apache-httpd raspbian
add a comment |Â
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?!
mount systemd apache-httpd raspbian
did you remember to dosudo systemctl daemon-reloadafter editing the service unit?
â meuh
Oct 17 '17 at 18:09
Yes, of course...
â Max Senft
Oct 19 '17 at 11:50
add a comment |Â
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?!
mount systemd apache-httpd raspbian
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?!
mount systemd apache-httpd raspbian
edited Oct 16 '17 at 15:21
asked Oct 16 '17 at 13:13
Max Senft
1234
1234
did you remember to dosudo systemctl daemon-reloadafter editing the service unit?
â meuh
Oct 17 '17 at 18:09
Yes, of course...
â Max Senft
Oct 19 '17 at 11:50
add a comment |Â
did you remember to dosudo systemctl daemon-reloadafter 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
add a comment |Â
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.
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.confwith the linePrivateTmp=falseunder the[Service]group.
â Max Senft
Mar 17 at 14:05
add a comment |Â
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.
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.confwith the linePrivateTmp=falseunder the[Service]group.
â Max Senft
Mar 17 at 14:05
add a comment |Â
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.
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.confwith the linePrivateTmp=falseunder the[Service]group.
â Max Senft
Mar 17 at 14:05
add a comment |Â
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.
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.
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.confwith the linePrivateTmp=falseunder the[Service]group.
â Max Senft
Mar 17 at 14:05
add a comment |Â
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.confwith the linePrivateTmp=falseunder 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
did you remember to do
sudo systemctl daemon-reloadafter editing the service unit?â meuh
Oct 17 '17 at 18:09
Yes, of course...
â Max Senft
Oct 19 '17 at 11:50