Solved weird ntpd problem

I just realize my machine did not boot. I was dropped at a shell with the user ntpd, a ctrl+d exited the shell and continued the normal boot. I have no different log entries, /usr/sbin/ntpd, /etc/rc.d/ntpd and /usr/sbin/service have the same hash as a known-good version, the config did not change, /var/db/ntp is owned by ntpd:ntpd. A "service ntpd start" also drops me to a shell of user ntpd. what the...? any ideas?
 
I read the rc script and thought about the policy being loaded, so I added mac_ntpd_load="YES" to my loader.conf - now it works. However, it's still mysterious why suddenly this was necessary.
 
Could you please comment out the line you added to loader.conf for making a screenshot/photo when boot stops?
 
It's worth checking that you don't have a syntax error in one of the configuration files. Inspect these files, and then run /bin/sh -x over each of them to make sure that there's nothing wrong:
  • /etc/rc.d/ntpd
  • /etc/rc.subr
  • /etc/defaults/rc.conf
  • /etc/rc.conf
 
everything seems normal, the rc.conf has not been touched for 3 months and I have not changed the other files. This is on my AMD Ryzen 7 3700X system.
 

Attachments

  • IMG_20200411_014328.jpg
    IMG_20200411_014328.jpg
    277.4 KB · Views: 137
note that the policy MAC_ntpd is loaded before the daemon starts (this is without the line in loader.conf ... loading the module explicitly via loader.conf results in a boot process like 3 days ago (no updates since))
 
Place the system into the configuration it had when service ntpd start caused you to drop into a shell.

Then run sh -x /etc/rc.d/ntpd start. That should get you closer to understanding where the problem is arising. You may have to recursively investigate the files that get "dotted in".
 
the line limits -C daemon su -m ntpd -c 'sh -c "/usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift"' drops me to a shell. On a system without that weird problem I get "11 Apr 10:30:50 ntpd[95617]: must be run as root, not uid 123". When I then "kldload mac_ntpd" and execute that command again it's running fine. I compared the hashsums of limits, su, ntpd and ntp.conf and they are all the same, the login class from login.conf is also the same. Even the shared libraries of limits, su and ntpd have the same hashsum. On that specific system, when I execute the command I am dropped to a shell of user ntpd. When mac_ntpd is loaded and I exit the shell, the service is started like normal, when I exit the shell without mac_ntpd loaded after printing exit the console prints the "must be run as root" message from above.
 
hm, I found it. I put "/usr/local/bin/bash" in /root/.cshrc - so if we substitute the line above with limits -C daemon su -f -m ntpd -c 'sh -c "/usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift"' it works. However, in order to have bash without interactively writing "bash" after a doas and without changing the default shell via chsh, what shall I do? Please no comments a la "don't use bash"
 
using "doas su -l" reads /root/.login so this is probably the simplest and cleanest solution. Thanks for your help!
 
Executing bash out of ~root/.cshrc is wrong. You should revert it.

I'm not sure I understand what you are trying to achieve.

Do you want to login as root and have bash as your shell? I never login as root, unless I'm on a console, and serious problems are happening.

My personal account is a member of the wheel group, and have this in /usr/local/etc/sudoers
Code:
%wheel ALL=(ALL) NOPASSWD:ALL
so I can sudo bash at any time, and operate as root for (just) as long as I need.
 
I just wanted to make sure it feels like bash is the default shell on roots account, no matter if you just do a "doas su" or login on the console, so with the entry in .login it's ok for us
 
Back
Top