0

when use systemd to start ntpd, why ntpd pid's mount namespace is different from pid 1?

when use systemd start ntpd

only mount namespace is different from pid 1;

you see ntpd mnt:[4026532696] , but , pid 1 is mnt:[4026531840]
#ll /proc/`pidof ntpd`/ns
total 0
lrwxrwxrwx 1 root root 0 Jun  7 17:58 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 mnt -> mnt:[4026532696]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 net -> net:[4026531968]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 pid -> pid:[4026531836]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 user -> user:[4026531837]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 uts -> uts:[4026531838]

#ll /proc/1/ns
total 0
lrwxrwxrwx 1 root root 0 Jun  7 17:58 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 mnt -> mnt:[4026531840]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 net -> net:[4026531968]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 pid -> pid:[4026531836]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 user -> user:[4026531837]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 uts -> uts:[4026531838]

when not use systemd to start ntpd

if not use systemd to start ntpd , ntpd pid's mount namespace is same with pid 1 's mount namespace

#systemctl stop ntpd

#/usr/sbin/ntpd -u ntp:ntp -g

#ll /proc/`pidof ntpd`/ns
total 0
lrwxrwxrwx 1 root root 0 Jun 20 19:46 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 root root 0 Jun 20 19:46 mnt -> mnt:[4026531840]
lrwxrwxrwx 1 root root 0 Jun 20 19:46 net -> net:[4026531968]
lrwxrwxrwx 1 root root 0 Jun 20 19:46 pid -> pid:[4026531836]
lrwxrwxrwx 1 root root 0 Jun 20 19:46 user -> user:[4026531837]
lrwxrwxrwx 1 root root 0 Jun 20 19:46 uts -> uts:[4026531838]

#ll /proc/1/ns
total 0
lrwxrwxrwx 1 root root 0 Jun  7 17:58 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 mnt -> mnt:[4026531840]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 net -> net:[4026531968]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 pid -> pid:[4026531836]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 user -> user:[4026531837]
lrwxrwxrwx 1 root root 0 Jun  7 17:58 uts -> uts:[4026531838]

other daemon started by systemd looks good

sshd pid is 1252

#ll /proc/1252/ns/
total 0
lrwxrwxrwx 1 root root 0 Jun 20 19:52 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 root root 0 Jun 20 19:52 mnt -> mnt:[4026531840]
lrwxrwxrwx 1 root root 0 Jun 20 19:52 net -> net:[4026531968]
lrwxrwxrwx 1 root root 0 Jun 20 19:52 pid -> pid:[4026531836]
lrwxrwxrwx 1 root root 0 Jun 20 19:52 user -> user:[4026531837]
lrwxrwxrwx 1 root root 0 Jun 20 19:52 uts -> uts:[4026531838]
1

This will vary from one distro to the next, but I think that this is a result of the use of the PrivateTmp: true feature of systemd.

As described in the Service-Private /tmp section of this blog post from Lennart Poettering:

Internally, this feature makes use of file system namespaces of the kernel. If enabled a new file system namespace is opened inheritng most of the host hierarchy with the exception of /tmp

See, for example, this bug report requesting that this option be added to Fedora.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.