- Package:
- network-manager
- Source:
- network-manager
- Description:
- network management framework (daemon and userspace tools)
- Submitter:
- Jarek KamiÅski
- Date:
- 2021-10-28 15:48:05 UTC
- Severity:
- normal
Hi. After installing n-m 0.7 scripts in /etc/dhcp3/dhclient-*-hooks.d/ are no longer executed. It's a regression from n-m 0.6. dhclient is run with -sf /usr/lib/NetworkManager/nm-dhcp-client.action . Looks like either nm-dhcp-client.action should run hooks (maybe by calling /sbin/dhclient-script) or it should be moved to *-hooks.d and -sf option dropped. Jarek.
for me it's a big regression because I'm using the hooks to launch my firewall scripts...
gpe wrote: When you are using NetworkManager, you could/should use /etc/NetworkManager/dispatcher.d/ instead.
Le Tue, 04 Aug 2009 02:27:27 +0200 Michael Biebl <biebl@debian.org> a écrit: With the dhcp hook I'm using the $reason (BOUND), $new_ip_address and $interface variables. How can I do this with the dispatcher? If I well understood it passes only two parameters to the scripts (interface and status up/down)?
Hi, Any news about this bug ? Regards.
Hmmm, how about telling this to all the maintainers whose packages drop their hooks to /etc/dhcp/*.d? This bug is years old, and leads to, for example, Samba not getting the WINS server configured through DHCP, and ntpd not getting the NTP server configured through DHCP. It prevents avahi-autoip from resigning a DHCP configured interface (not checked, but I guess so) and whatever else. Everybody seems to know about the dhclient hooks but there is not a single third-party hook in /etc/NetworkManager/dispatcher.d - since years. I'm quite new to network-manager, is it really that hard to hook NM's dispatcher.d to, in turn, call /sbin/dhclient-script from there? thanks for your work & regards Mario
Hi,
I had also hoped that this issue would be fixed as it seems to be in all
Debian derivatives. I reported this issue as a bug upstream and was
informed that the problem does not existing in RedHat and the solution
is required at the distro level. Dan Williams (at RedHat) - kindly
pointed me in the right direction.
My issues are limited to NTP, so I have hacked a script to fix that by
leveraging the existing ntp script in dhclient-exit-hooks.d. I am no
script writer, but it works fine in my environment. The only real
shortcoming is that it doesn't compare the existing ntp servers with the
ones from DHCP, so arguably it could pointlessly needlessly
create /var/lib/ntp/ntp.conf.dhcp. Hopefully someone more skilled can
fix that, and it can added to the package moving forward.
If you cut and paste the script below, I have tried to catch the wrapped
text, but this needs to be verifed. That aside, I named the script
11ntp... I hope this is useful to others.
Thanks
Alan
#!/bin/sh -e
# Script to take DHCP configured NTP servers
# This heavily leverages the ntp script from dhclient-exit-hooks.d
if [ -z "$1" ]; then
echo "$0: called with no interface" 1>&2
exit 1;
fi
NTP_CONF=/etc/ntp.conf
NTP_DHCP_CONF=/var/lib/ntp/ntp.conf.dhcp
ntp_server_restart() {
invoke-rc.d ntp try-restart
}
ntp_servers_setup_remove() {
if [ ! -e $NTP_DHCP_CONF ]; then
return
fi
rm -f $NTP_DHCP_CONF
ntp_server_restart
}
# Run the right scripts
case "$2" in
up|vpn-up)
if [ -e $NTP_DHCP_CONF ] && [ -z "$DHCP4_NTP_SERVERS" ]; then
ntp_servers_setup_remove
return
fi
tmp=$(mktemp "$NTP_DHCP_CONF.XXXXXX") || return
chmod --reference=$NTP_CONF $tmp
chown --reference=$NTP_CONF $tmp
(
echo "# This file was copied from $NTP_CONF with the server\ options
changed"
echo "# to reflect the information sent by the DHCP server\ Any
changes made"
echo "# here will be lost at the next DHCP event. Edit\ $NTP_CONF
instead."
echo
echo "# NTP server entries received from DHCP server"
for server in $DHCP4_NTP_SERVERS; do
echo "server $server iburst"
done
echo
sed -r -e '/^ *(server|peer).*$/d' $NTP_CONF
) >>$tmp
mv $tmp $NTP_DHCP_CONF
ntp_server_restart
;;
down|vpn-down)
if [ ! -e $NTP_DHCP_CONF ]; then
return
fi
rm -f $NTP_DHCP_CONF
ntp_server_restart
;;
hostname|dhcp4-change|dhcp6-change)
# Do nothing
;;
*)
echo "$0: called with unknown action \`$2'" 1>&2
exit 1
;;
esac
A quick apt-file search reveals the following potentially affected packages: avahi-autoipd: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd avahi-autoipd: /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd controlaula: /etc/dhcp/dhclient-exit-hooks.d/controlaula.dhcp debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/wpad-proxy-update ntp: /etc/dhcp/dhclient-exit-hooks.d/ntp ntpdate: /etc/dhcp/dhclient-exit-hooks.d/ntpdate openresolv: /etc/dhcp/dhclient-enter-hooks.d/resolvconf resolvconf: /etc/dhcp/dhclient-enter-hooks.d/resolvconf samba-common: /etc/dhcp/dhclient-enter-hooks.d/samba sendmail-base: /etc/dhcp/dhclient-exit-hooks.d/sendmail whereami: /etc/dhcp/dhclient-exit-hooks.d/whereami controlaula and debian-edu-config already ship a NM dispatcher hook. Will try to notify the other package maintainers. At least the ntp/ntpdate issue looks like it is sufficiently addressed by the dispatcher script from Alan. Michael
We should probably also contact the chrony maintainers. Even if they are currently not shipping any dhcp hook.
Are there any bug numbers assigned to the offending packages? They should be linked from here. Particularly interested in ntpdate.
Apparently ntpdate is deprecated. Alan's ntp patch looks reasonable to me. I'm still testing it. Only thing I'd change is to replace down|vpn-down) code with a call to ntp_servers_setup_remove(). Michael, can you move this bug to the ntp package so that this patch gets in?
Sent from vivo smartphone