Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1003609: readlink: invalid option -- 'b' in /lib/lsb/init-functions.d/40-systemd

80 views
Skip to first unread message

Peter Palfrader

unread,
Jan 12, 2022, 10:20:03 AM1/12/22
to
Package: systemd
Version: 247.3-6
Severity: normal
Tags: patch

Hi!

/lib/lsb/init-functions.d/40-systemd calls
readlink -f "$executable"
which causes warnings if an executable starts with -, like in "-bash" when
/lib/lsb/init-functions is sourced from a login shell.

] root@yukon:~# . /lib/lsb/init-functions
] readlink: invalid option -- 'b'
] Try 'readlink --help' for more information.
] root@yukon:~#

This happens for instance with the slony init script:

| adns002:~# grep 'init-functions ' /etc/init.d/slony1
| su -c ". /lib/lsb/init-functions ; umask 027 ; start_daemon -p $(pidfile $1) $DAEMON -f $(conffile $1) -p $(pidfile $1) >>$(logfile $1) 2>&1 </dev/null &" - postgres

And causes warnings in journald:

} Jan 12 16:02:16 adns002 slony1[41162]: Starting Slony-I daemon: con_prov_slony_dns_2022
} Jan 12 16:02:16 adns002 slony1[41189]: readlink: invalid option -- 'b'
} Jan 12 16:02:16 adns002 slony1[41189]: Try 'readlink --help' for more information.
} Jan 12 16:02:16 adns002 su[41178]: pam_unix(su-l:session): session closed for user postgres
} Jan 12 16:02:16 adns002 slony1[41162]: .
} Jan 12 16:02:16 adns002 systemd[1]: Started LSB: start Slony-I daemon.

Please change /lib/lsb/init-functions.d/40-systemd to fix this.

--- pape/40-systemd 2022-01-12 11:49:22.367583829 +0100
+++ /lib/lsb/init-functions.d/40-systemd 2022-01-12 11:50:27.011956293 +0100
@@ -26,7 +26,7 @@

# Redirect SysV init scripts when executed by the user
if [ $PPID -ne 1 ] && [ -z "${SYSTEMCTL_SKIP_REDIRECT:-}" ]; then
- case $(readlink -f "$executable") in
+ case $(readlink -f -- "$executable") in
/etc/init.d/*)
# If the state is not-found, this might be a newly installed SysV init
# script where systemd-sysv-generator has not been run yet.


--
| .''`. ** Debian **
Peter Palfrader | : :' : The universal
https://www.palfrader.org/ | `. `' Operating System
| `- https://www.debian.org/

Michael Biebl

unread,
Jan 12, 2022, 12:30:04 PM1/12/22
to
Am 12.01.22 um 16:04 schrieb Peter Palfrader:
> /lib/lsb/init-functions.d/40-systemd calls
> readlink -f "$executable"
> which causes warnings if an executable starts with -, like in "-bash" when
> /lib/lsb/init-functions is sourced from a login shell.
>
> ] root@yukon:~# . /lib/lsb/init-functions
> ] readlink: invalid option -- 'b'
> ] Try 'readlink --help' for more information.
> ] root@yukon:~#
>
> This happens for instance with the slony init script:
>
> | adns002:~# grep 'init-functions ' /etc/init.d/slony1
> | su -c ". /lib/lsb/init-functions ; umask 027 ; start_daemon -p $(pidfile $1) $DAEMON -f $(conffile $1) -p $(pidfile $1) >>$(logfile $1) 2>&1 </dev/null &" - postgres

Oh my, not the prettiest way to start a daemon.
Christoph, maybe this is actually better addressed on the slony1-2 side.

Michael
OpenPGP_signature

Peter Palfrader

unread,
Jan 12, 2022, 12:50:03 PM1/12/22
to
I completely agree that it should /also/ be addressed there, but
nevertheless, init-functions should be sourceable from login shells.

Cheers!

Michael Biebl

unread,
Jan 12, 2022, 1:40:05 PM1/12/22
to

Am 12.01.22 um 18:31 schrieb Peter Palfrader:
> On Wed, 12 Jan 2022, Michael Biebl wrote:
>
>> Am 12.01.22 um 16:04 schrieb Peter Palfrader:
>>> /lib/lsb/init-functions.d/40-systemd calls
>>> readlink -f "$executable"
>>> which causes warnings if an executable starts with -, like in "-bash" when
>>> /lib/lsb/init-functions is sourced from a login shell.
>>>
>>> ] root@yukon:~# . /lib/lsb/init-functions
>>> ] readlink: invalid option -- 'b'
>>> ] Try 'readlink --help' for more information.
>>> ] root@yukon:~#
>>>
>>> This happens for instance with the slony init script:
>>>
>>> | adns002:~# grep 'init-functions ' /etc/init.d/slony1
>>> | su -c ". /lib/lsb/init-functions ; umask 027 ; start_daemon -p $(pidfile $1) $DAEMON -f $(conffile $1) -p $(pidfile $1) >>$(logfile $1) 2>&1 </dev/null &" - postgres
>>
>> Oh my, not the prettiest way to start a daemon.
>> Christoph, maybe this is actually better addressed on the slony1-2 side.
>
> I completely agree that it should /also/ be addressed there, but
> nevertheless, init-functions should be sourceable from login shells.

I see it as a helper library for init scripts, not so much a general
purpose shell library that can be sourced from arbitrary contexts. It
wasn't really written with that in mind.
To this day, I wasn't actually aware that anyone was using
/lib/lsb/init-functions outside of an init script context. I don't think
anyone is actually testing that it works for that.


Regards,
Michael
OpenPGP_signature

Michael Biebl

unread,
Jan 12, 2022, 2:30:14 PM1/12/22
to

Control: reassign -1 systemd, slony1-2-bin

I'm rather convinced this should be addressed in slony1-2-bin (by
ideally providing native .service units).
Or at least by avoiding the use a root shell and sourcing
/lib/lsb/init-functions, but instead using something like
start-stop-daemon -u
OpenPGP_signature

Christoph Berg

unread,
Jan 12, 2022, 3:10:04 PM1/12/22
to
Re: Michael Biebl
I hate init scripts, and one of the reasons for that is that I have
inherited too many packages with weird init scripts like the slony
one.

I'll supply a .service unit instead.

Christoph
0 new messages