Subject: bug#723: init-system-helpers: update-rc.d calls systemctl on a SysVinit system, creating a recursion

From: [email-masked] (Wolfgang Wegner)
Date: Sat, 12 Nov 2022 21:20:17 +0100

Package: init-system-helpers
Version: 1.65.2devuan1
Severity: normal
X-Debbugs-Cc: [email-masked]

Dear Maintainer,

I am trying to install a package which expects SystemD. I manually added
scripts and an initial set for sysVinit. However, the post-install script
calls "systemctl --no-reload enable <packagename>", which invokes
update-rc.d, which in turn diverts to a systemctl call, and so on.

Calling update-rc.d from the systemctl "abstraction" (surrogate?) seems
to be correct, but I would have expected update-rc.d to detect the system's
init system and - as I am using sysVinit on Devuan - just modify the links.

update-rc.d behaviour can also be reproduced when calling it for an already
installed service.

-- System Information:
Distributor ID: Devuan
Description:    Devuan GNU/Linux 5 (daedalus/ceres)
Release:        5
Codename:       daedalus ceres
Architecture: x86_64

Kernel: Linux 5.19.9-wolfgang-wolfgang (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages init-system-helpers is related to:
ii  insserv  1.24.0-1

-- no debconf information

---

From: Mark Hindley <[email-masked]>
Date: Sun, 13 Nov 2022 18:38:28 +0000

Control: tags -1 moreinfo

Wolfgang,

Thanks for this.

> update-rc.d, which in turn diverts to a systemctl call, and so on.

Which of the available systemctl emulations do you have installed?

> update-rc.d behaviour can also be reproduced when calling it for an already

Could you give a specific example here. I can't reproduce it.

Thanks

Mark

---

From: [email-masked] (Wolfgang Wegner)
Date: Sun, 13 Nov 2022 22:00:05 +0100

Hi Mark,

thanks for looking into this!

> Which of the available systemctl emulations do you have installed?

Sorry I am not sure what exactly you mean here. I try to list packages that
might be relevant:

ii  init-system-helpers          1.65.2devuan1 all          helper tools for all init systems
ii  initscripts                  3.05-6devuan1 all          scripts for initializing and shutting down the system
ii  orphan-sysvinit-scripts      0.11          all          Orphaned System-V-like init scripts
ii  sysvinit                     3.05-6devuan1 amd64        System-V-like init utilities - transitional package
ii  sysvinit-core                3.05-6devuan1 amd64        System-V-like init
ii  sysvinit-utils               3.05-6devuan1 amd64        System-V-like utilities
ii  systemctl-service-shim 0.0.4-1      all          Adds systemctl translator script
ii  dummy-systemd-dev   0.2          all          Development files extracted from systemd

"systemctl-service-shim" might be what you are asking for, but I did not see
any alternative?

> Could you give a specific example here. I can't reproduce it.

root@<host>:~# update-rc.d rsyslog enable
update-rc.d rsyslog enable
update-rc.d rsyslog enable
update-rc.d rsyslog enable
...

> Mark

Best regards
Wolfgang

---

From: Mark Hindley <[email-masked]>
Date: Mon, 14 Nov 2022 10:24:39 +0000

Wolfgang,

> "systemctl-service-shim" might be what you are asking for, but I did not see

Yes, that what what I meant. There is also a Debian systemctl package, but it is
not really maintained and I wouldn't recommend it.

I notice you have dummy-systemd-dev installed. You really don't want that on a
production system. If is a hack for building sources that Build-Dep: systemd. It
doesn't provide any systemd functionality.

If you remove it does it make any difference?

> update-rc.d rsyslog enable

Hmmm, I get completely different behaviour with that command:-

mark@apollo:~% sudo update-rc.d enable rsyslog
usage: update-rc.d [-f] <basename> remove
       update-rc.d [-f] <basename> defaults
       update-rc.d [-f] <basename> defaults-disabled
       update-rc.d <basename> disable|enable [S|2|3|4|5]
                -f: force

The disable|enable API is not stable and might change in the future.

What systemd-requiring package are you trying to install? What other changes
have you made?

Mark

---

From: [email-masked] (Wolfgang Wegner)
Date: Mon, 14 Nov 2022 11:51:17 +0100

On Mon, Nov 14, 2022 at 10:24:39AM +0000, Mark Hindley wrote:
[...]
> If you remove it does it make any difference?

Thanks - I removed it now, but that does not make any difference.

> mark@apollo:~% sudo update-rc.d enable rsyslog

Is the switched basename/command pair intended here?

> What systemd-requiring package are you trying to install? What other changes

The package I try to install is *cough* "cybereason-sensor", which is now
required to install from our IT department. Their post-install script
relies on either upstart or systemd being present. As in consequence, no
LSB init script is provided with the package, I created a basic one and
also added the standard links in /etc/rc?.d/.

I am not aware of other changes I did to the system - however, the
installation is originating from a Devuan 1.0 install and has only been
updated to the current state, which has been quite cumbersome with respect
to some in-between incompatibilities, especially the usual NVIDIA mess
but also some things concerning qemu/KVM and wine.
(This is to say: I do not remember any changes in the area of the init
system but there has been some fiddling around trying to get some updates
installed.)

As another test, I just tried to remove systemctl-service-shim, and
immediately the weird behaviour of update-rc.d is gone:

root@<host>:~# dpkg -r systemctl-service-shim
(Reading database ... 836967 files and directories currently installed.)
Removing systemctl-service-shim (0.0.4-1) ...
Processing triggers for man-db (2.11.0-1+b1) ...
root@<host>:~# update-rc.d rsyslog enable
root@<host>:~#

So to me it really looks like an unwanted interaction just between
update-rc.d and systemctl-service-shim.

Best regards
Wolfgang

---

From: Mark Hindley <[email-masked]>
Date: Mon, 14 Nov 2022 10:53:24 +0000

Antony,

On Mon, Nov 14, 2022 at 11:31:39AM +0100, Where all about bugs in Devuan packages is reported wrote:
> Um, "update-rc.d rsyslog enable" != "update-rc.d enable rsyslog".

Thanks for pointing out my obvious (but not to me!) mistake.

So I can now reproduce this, but only if systemctl-service-shim is installed. If
it is removed, update-rc.d behaves as expected.

[Adding bgstack15]

Is this an issue in the way systemctl-service-shim behaves? I don't see it with
systemctl on a Debian sysvinit system.

Thanks.

Mark

---

From: B Stack <[email-masked]>
Date: Mon, 14 Nov 2022 07:50:26 -0500

Hi,

The systemctl-service-shim main script /usr/bin/systemctl also has a
symlink at /bin/systemctl. If the script is called from /bin/systemctl
then it will remove this symlink during operations to avoid the
recursive calls like you see happening here. You can check the
relevant logs at /var/log/systemctl.log, and please share them here.

The systemctl service shim script has a known problem particularly on
the "enable" action [0] that I thought was fixed. The logs, if you can
share them, might help make an improvement such as the script getting
called in a particular way where it also needs to remove the symlink
to prevent infinite recursion.

B. Stack
[0]: https://bugs.devuan.org/cgi/bugreport.cgi?bug=688

---

From: Mark Hindley <[email-masked]>
Date: Mon, 14 Nov 2022 16:34:55 +0000

Control: reassign -1 systemctl-service-shim

Ben,

Thanks

Reassigning.

Mark

---

From: "Devuan bug Tracking System" <[email-masked]>
Date: Thu, 02 May 2024 03:40:02 +0000

This is an automatic notification regarding your bug report
which was filed against the systemctl-service-shim package:

#723: init-system-helpers: update-rc.d calls systemctl on a SysVinit system, creating a recursion

It has been closed by [email-masked].

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact [email-masked] by
replying to this email.

-- 
723: https://bugs.devuan.org/cgi/bugreport.cgi?bug=723
Devuan Bug Tracking System
Contact [email-masked] with problems

Subject: #723: fixed in src:systemctl-service-shim version 0.0.7
From: [email-masked]
To: [email-masked]
Date: Thu, 02 May 2024 03:37:45 +0000

Version: 0.0.7

Source package systemctl-service-shim (0.0.7) added to Devuan suite unstable.

This closes bug report 723.

Thanks

DAK managing the Devuan archive

Format: 1.8
Date: Wed, 01 May 2024 22:28:41 -0500
Source: systemctl-service-shim
Architecture: source
Version: 0.0.7
Distribution: unstable
Urgency: medium
Maintainer: B. Stack <[email-masked]>
Changed-By: Plasma (David Paul) <[email-masked]>
Closes: 723
Changes:
 systemctl-service-shim (0.0.7) unstable; urgency=medium
 .
   [ B. Stack ]
   * Relicense to LGPLv2.1
 .
   [ Plasma (David Paul) ]
   * Fix endless loop when calling update-rc.d
     (Closes: #723)
   * Re-remove symlink control logic
   * Bump Standards-Version to 4.7.0 ; no change
Checksums-Sha1:
 deeb6e60e63e5d3c4cbefd06f69adb03f7b07a32 1442 systemctl-service-shim_0.0.7.dsc
 0dcf4dd60ed6b792b7e3cead2c0e2a580d03f30e 16668 systemctl-service-shim_0.0.7.tar.xz
 b3741f94b76eebd1fdc59d982b3e9c5584748106 5415 systemctl-service-shim_0.0.7_source.buildinfo
Checksums-Sha256:
 4266060345da2066345563f45ce01bdf948aa3dd670b11a3a0ad79bb3538bded 1442 systemctl-service-shim_0.0.7.dsc
 a6315a6c78328dd04de9cba8811a3e096af75bf8f9f5126ecebca81c33dcad86 16668 systemctl-service-shim_0.0.7.tar.xz
 62cad4297628802631d6c75cdb090f96f0aa7e781482edb775556362a7fe90b9 5415 systemctl-service-shim_0.0.7_source.buildinfo
Files:
 0d74430a858983dc9f551b01b5883daf 1442 admin optional systemctl-service-shim_0.0.7.dsc
 a266dcbf180d63c09bc2e7812bb56154 16668 admin optional systemctl-service-shim_0.0.7.tar.xz
 dad6ca6d32380a5dcc1cb1166e386c5c 5415 admin optional systemctl-service-shim_0.0.7_source.buildinfo

Subject: init-system-helpers: update-rc.d calls systemctl on a SysVinit system, creating a recursion
From: [email-masked] (Wolfgang Wegner)
To: [email-masked]
Date: Sat, 12 Nov 2022 21:20:17 +0100

Dear Maintainer,

-- System Information:
Distributor ID: Devuan