Dear Maintainer,
I noticed that dhclient-script does not honor the executability flag of
either /etc/dhcp/dhclient-{enter,exit}-hooks or files inside the directories
/etc/dhcp/dhclient-{enter,exit}-hooks.d/ and will execute even non-executable
files by sourcing them. This is not supposed to happen according to the
dhclient-script man page.
Quote from the man page:
[dhclient-script] checks for the presence of an executable
/etc/dhcp/dhclient-enter-hooks script, and if present, it invokes the
script inline, using the Bourne shell '.' command. It also invokes all
executable scripts in /etc/dhcp/dhclient-enter-hooks.d/* in the same way.
The passage on the exit-hooks reads likewise.
However, dhclient-script does not actually check the executability of any of
these files. The run-hook function in dhclient-script only checks whether the
argument is a file and then sources it, see lines 144-145 of dhclient-script:
if [ -f $script ]; then
. $script
In addition, the run-hookdir function also iterates over files that are not
executable, see line 162:
for script in $(run-parts --list $dir); do
The problem here is the list switch of run-parts. Quote from the run-parts
man page:
--list print the names of the all matching files (not limited to
executables), but don't actually run them.
It would be better to use the --test switch here instead which will only
print the names of executable files in the folder without actually running
them.
Thus, a fix should be rather trivial to get dhclient-script to actually
invoke executables only.
On a sidenote, though, on my rather fresh installation of Debian Stretch, I
have several files inside /etc/dhcp/dhclient-exit-hooks.d/ that are not
executable by default such as
debug
timesyncd
rfc3442-classless-routes
So, I'm wondering whether their respective authors actually meant them to be
run by default or not.
Regards,
Timo