rc: fix automatic restart with runlevel-specific conf.d files

Commit fc4f15d6cd broke the automatic restart of
services having runlevel-specific conf.d files.

The double dirname() was not a mistake, but the way of getting from the
service script in init.d to the upper directory containing the conf.d
directory. dirname() modifies the argument in-place, so the second call
operated on a modified value. To make it more obvious what is going on,
have the second call operate on the returned value from the first call.

Fixes: fc4f15d ("openrc: fix double-assignment to dir")
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
This commit is contained in:
Sven Wegener 2023-07-15 16:52:12 +02:00 committed by Doug Freed
parent cd53239701
commit 86efc43d0e

View File

@ -527,7 +527,7 @@ runlevel_config(const char *service, const char *level)
char *conf, *dir;
bool retval;
dir = dirname(init);
dir = dirname(dirname(init));
xasprintf(&conf, "%s/conf.d/%s.%s", dir, service, level);
retval = exists(conf);
free(conf);