Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 916776 - net-misc/dhcpcd-10.0.3: starting dhcpcd blanks the /etc/ntp.conf provided by gentoo
Summary: net-misc/dhcpcd-10.0.3: starting dhcpcd blanks the /etc/ntp.conf provided by ...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-04 00:49 UTC by benoit.dufour
Modified: 2024-01-18 06:35 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description benoit.dufour 2023-11-04 00:49:48 UTC
TL;DR
Add this line to your /etc/dhcpcd.conf file:
env NTP_CONF=


Info about my system:
I installed gentoo in 2022 and kept keeping my packages up to date.
My current ntp version is: net-misc/ntp-4.2.8_p17
My current dhcpcd version is: net-misc/dhcpcd-10.0.3
My network is managed by a dhcp configuration of netifrc.


The net-misc/ntp package of gentoo provides a default config file (/etc/ntp.conf ) that allows syncing the system clock to the Gentoo own ntp servers.
The net-misc/dhcpcd package of gentoo provides a default config file (/etc/dhcpcd.conf) that is read by the dhcpcd service when it started.
I didn't touch those config file, I always let them as they were and only applied required cfg-update -u.

On my system, dhcpcd is started through netifrc:
    rc-service net.eno1 start 
Or :
    eselect rc start net.eno1

From there, whenever dhcpcd is started, it erase completly the content of the /etc/ntp.conf file. This totally prevents starting the ntpd service as well as using ntpd -q -g.

Since /etc/ntp.conf was now blank, I tried to reinstall several times net-misc/ntp through those commands:
emerge --ask --verbose net-misc/ntp
emerge --ask --verbose --nomemconf net-misc/ntp
but the /etc/ntp.conf file stayed blank and I wasn't prompted at all to run dispatch-conf or cfg-update -u.

I had to run those command in order to fill /etc/ntp.conf file with the right content.
rm /etc/ntp.conf
emerge --ask --verbose net-misc/ntp
Portage then prompted me to use cfg-update -u in order to update the config file.

The next day, dhcpcd got restarted during boot and the /etc/ntp.conf file went blank again.
In order to make sure dhcpcd was really the cause of the issue, I used this command :
rc-service net.eno1 restart
And then checked if /etc/ntp.conf became blank.

I was finally able to prevent dhcpcd to deletes the /etc/ntp.conf file provided by gentoo by adding this line at the end of the /etc/dhcpcd.conf file.
env NTP_CONF=
This solved starting the ntpd service as well as using ntpd -q -g.
That line should be added to the /etc/dhcpcd.conf file provided by net-misc/dhcpcd if Gentoo still wants to provide a default /etc/ntp.conf.

Reproducible: Always

Steps to Reproduce:
Restart your network connection and check if the content of /etc/ntp.conf gets deleted.
Actual Results:  
The content of /etc/ntp.conf gets deleted whenever I restart my network connection.

Expected Results:  
The content of /etc/ntp.conf should never get deleted by dhcpcd and should stay the one provided by net-misc/ntp.

I sent a similar issue on GitHub:
https://github.com/NetworkConfiguration/dhcpcd/issues/261
Comment 1 benoit.dufour 2023-11-04 19:36:01 UTC
The script of dhcpcd that deletes /etc/ntp.conf is 
https://github.com/NetworkConfiguration/dhcpcd/blob/master/hooks/50-ntp.conf
and probably also deletes the OpenNTPD and Chrony config files provided by Gentoo.
Comment 2 Steve Herber 2024-01-18 06:35:06 UTC
The way to disable features in dhcpcd is to edit /etc/conf.d/net and put entries like this in place:

config_eth2="dhcp"
modules_eth2="dhcpcd"
dhcp_eth2="norelease nodns nontp nonis nogateway nosendhost"