Bug 41598 - [container] telinit from systemd-sysvinit re-execs itself in a non-stop loop
Summary: [container] telinit from systemd-sysvinit re-execs itself in a non-stop loop
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: systemd-sysvinit (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 critical
Assignee: Alexey Shabalin
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-20 18:07 MSK by Stanislav Levin
Modified: 2022-08-08 19:39 MSK (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Levin 2021-12-20 18:07:54 MSK
I build Docker images from the official ALT images (for example, `library/alt:sisyphus`).

With the recent sysvinit(2.88-alt7) it's no longer possible to install systemd during Docker build.
apt transaction hangs on:
```
41: systemd-1:249.7-alt5                ####################################### [ 98%]
42: systemd-sysvinit-1:249.7-alt5       ####################################### [100%]
```

process list:
```
[root@acaa6cfff02e /]# ps -auxfww
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   3912  3324 pts/0    Ss   11:27   0:00 /bin/bash
root          88  0.4  0.9 164324 156396 pts/0   T    11:31   0:06 apt-get install -y systemd
root         378  0.0  0.0   3316  2552 pts/0    T    11:31   0:00  \_ /bin/sh -e /usr/lib/rpm/posttrans-filetriggers /var/lib/rpm/files-awaiting-filetriggers
root         380  0.0  0.0   3316  2616 pts/0    T    11:31   0:00      \_ /bin/sh -e /usr/lib/rpm/0ldconfig.filetrigger
root         383  0.2  0.0   1448     4 pts/0    T    11:31   0:03          \_ /sbin/telinit u
```

```
[root@acaa6cfff02e /]# sd_booted ; echo $?
1
```

How to reproduce:
```
docker run -ti library/alt:sisyphus
within container: apt-get install systemd
```

Log of successful installation:
```
Building Dependency Tree... Done
MI2a: mark systemd
MI2a:  target agetty
MI2a:   mark agetty
MI2a:    target login
MI2a:     mark login
MI2a:  target acl
MI2a:   mark acl
MI2a:  target /sbin/sulogin
MI2a:   mark msulogin
MI2a:  target /bin/kmod
MI2a:   mark kmod
MI2a:    target libc.so.6(GLIBC_2.34)(64bit)
MI2a:     mark glibc-core
MI2a:      target glibc-preinstall
MI2a:       mark glibc-preinstall
MI2a:    target libkmod
MI2a:     mark libkmod
MI2a:      target libcrypto.so.1.1()(64bit)
MI2a:       mark libcrypto1.1
MI2a:        target ca-certificates
MI2a:         mark ca-certificates
MI2a:          target ca-trust
MI2a:           mark ca-trust
MI2a:            target p11-kit-trust
MI2a:             mark p11-kit-trust
MI2a:              target /etc/alternatives/packages.d
MI2a:               mark alternatives
MI2a:                target rpm-macros-alternatives
MI2a:                 mark rpm-macros-alternatives
MI2a:              target libtasn1.so.6()(64bit)
MI2a:               mark libtasn1
MI2a:              target libp11-kit
MI2a:               mark libp11-kit
MI2a:                target libffi.so.8()(64bit)
MI2a:                 mark libffi8
MI2a:  target /etc/modules
MI2a:   mark startup
MI2a:    target mount
MI2a:     mark mount
MI2a:    target hwclock
MI2a:     mark hwclock
MI2a:    target /sbin/halt AMB
MI2a:    target /sbin/reboot AMB
MI2a:    target /sbin/shutdown AMB
MI2a:    target /sbin/telinit AMB
MI2a:  target libcryptsetup.so.12()(64bit)
MI2a:   mark libcryptsetup
MI2a:    target libargon2.so.1()(64bit)
MI2a:     mark libargon2
MI2a:    target libdevmapper.so.1.02()(64bit)
MI2a:     mark libdevmapper
MI2a:    target libjson-c.so.5()(64bit)
MI2a:     mark libjson-c5
MI2a:  target libfdisk.so.1()(64bit)
MI2a:   mark libfdisk
MI2a:  target liblz4.so.1()(64bit)
MI2a:   mark liblz4
MI2a:  target libnss-systemd
MI2a:   mark libnss-systemd
MI2a:  target libnss-myhostname
MI2a:   mark libnss-myhostname
MI2a:  target pam_systemd
MI2a:   mark pam_systemd
MI2a:    target dbus
MI2a:     mark dbus
MI2a:      target libexpat.so.1()(64bit)
MI2a:       mark libexpat
MI2a:      target libsystemd.so.0()(64bit)
MI2a:       mark libsystemd
MI2a:      target dbus-tools
MI2a:       mark dbus-tools
MI2a:        target libdbus
MI2a:         mark libdbus
MI2a:  target systemd-boot-efi
MI2a:   mark systemd-boot-efi
MI2a:  target systemd-utils-filetriggers
MI2a:   mark systemd-utils-filetriggers
MI2a:  target systemd-tmpfiles-common
MI2a:   mark systemd-tmpfiles-common
MI2a:  target systemd-sysctl-common
MI2a:   mark systemd-sysctl-common
MI2a:  target udev
MI2a:   mark udev
MI2a:    target dmsetup
MI2a:     mark dmsetup
MI2a:      target lsblk
MI2a:       mark lsblk
MI2a:    target losetup
MI2a:     mark losetup
MI2b: mark startup
MI2b:  target /sbin/halt AMB
MI2b:  target /sbin/reboot AMB
MI2b:  target /sbin/shutdown AMB
MI2b:  target /sbin/telinit AMB
MI2c: mark startup
MI2c:  target /sbin/halt
MI2c:   mark sysvinit
Starting
Starting 2
```
so, previously /sbin/telinit pointed to sysvinit, but it was also called (wrongly?).

Probably, it's safer to skip the telinit call if a system wasn't booted with sysvinit or systemd.
Comment 1 Dmitry V. Levin 2021-12-20 18:20:24 MSK
(In reply to Stanislav Levin from comment #0)
> [root@acaa6cfff02e /]# ps -auxfww
> USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
> root           1  0.0  0.0   3912  3324 pts/0    Ss   11:27   0:00 /bin/bash
> root          88  0.4  0.9 164324 156396 pts/0   T    11:31   0:06 apt-get
> install -y systemd
> root         378  0.0  0.0   3316  2552 pts/0    T    11:31   0:00  \_
> /bin/sh -e /usr/lib/rpm/posttrans-filetriggers
> /var/lib/rpm/files-awaiting-filetriggers
> root         380  0.0  0.0   3316  2616 pts/0    T    11:31   0:00      \_
> /bin/sh -e /usr/lib/rpm/0ldconfig.filetrigger
> root         383  0.2  0.0   1448     4 pts/0    T    11:31   0:03         
> \_ /sbin/telinit u

Something has stopped the whole thing, that's wrong.

> so, previously /sbin/telinit pointed to sysvinit, but it was also called
> (wrongly?).

Why wrongly?  It was placed there for a reason.

> Probably, it's safer to skip the telinit call if a system wasn't booted with
> sysvinit or systemd.

It's telinit job to handle this.
Comment 2 Stanislav Levin 2021-12-20 19:17:27 MSK
so, you think systemctl should handle this case, right?
Comment 3 Dmitry V. Levin 2021-12-20 19:29:39 MSK
(In reply to Stanislav Levin from comment #2)
> so, you think systemctl should handle this case, right?

If systemd provides telinit, it should behave like telinit, shouldn't it?
By the way, what's acting as init in this container?
Comment 4 Stanislav Levin 2021-12-20 19:38:56 MSK
(Ответ для Dmitry V. Levin на комментарий #3)
> (In reply to Stanislav Levin from comment #2)
> > so, you think systemctl should handle this case, right?
> 
> If systemd provides telinit, it should behave like telinit, shouldn't it?

Could you please reassign the bug to systemd then?

> By the way, what's acting as init in this container?

In provided example /bin/bash is acting as pid 1.
Comment 5 Dmitry V. Levin 2021-12-20 20:00:52 MSK
(In reply to Stanislav Levin from comment #4)
> (Ответ для Dmitry V. Levin на комментарий #3)
> > (In reply to Stanislav Levin from comment #2)
> > > so, you think systemctl should handle this case, right?
> > 
> > If systemd provides telinit, it should behave like telinit, shouldn't it?
> 
> Could you please reassign the bug to systemd then?

Reproduced in hasher:
$ hsh-run --root -- timeout 0.1 strace -eexecve telinit u
execve("/sbin/telinit", ["telinit", "u"], 0x7ffe3d1e4330 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffd32ae6a00 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffda6153f90 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffdb0d58280 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffc03cb3ad0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffc71e01e40 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffd4d03e810 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffc5e59b6b0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffda4b30d80 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffca9b2abc0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffdb60e9560 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffd36c63470 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffe3f4805a0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7fff735174f0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffdb8e0b9e0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7fff1b717550 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffc684f03d0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffcd79f8320 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffef41f7b90 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffff288b820 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffe6e80b3e0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffc88851750 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffea8255220 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffc02a0a380 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffcb67c9ca0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffde790b570 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7fff93985920 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffee96acc40 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffe8fd0d9b0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffea7459c20 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7fff99dc7da0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffd7815cb90 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffd3d49c9c0 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffe7e300e10 /* 11 vars */) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7fff0f39d4a0 /* 11 vars */) = 0
strace: Process 1807312 detached

$ hsh-run --root -- timeout 0.1 strace -bexecve telinit u
execve("/sbin/telinit", ["telinit", "u"], 0x7fffc6764c08 /* 11 vars */) = 0
...
faccessat2(AT_FDCWD, "/run/systemd/system/", F_OK, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/proc/1/root", 0x7ffeaebebd90, 0) = -1 ENOENT (No such file or directory)
prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=4*1024, rlim_max=4*1024}) = 0
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}, NULL) = 0
execve("/sbin/telinit", ["telinit", "u"], 0x7ffeaebec0f0 /* 11 vars */ <detached ...>
Comment 6 Dmitry V. Levin 2021-12-20 21:41:55 MSK
A workaround in rpm for the faulty telinit:
https://git.altlinux.org/people/ldv/packages/?p=rpm.git;a=commitdiff;h=1f2fe8b68b9dcf2a46feb5891f1986ce7bca48e5
Completely untested.
Comment 7 Stanislav Levin 2021-12-21 11:12:48 MSK
(Ответ для Dmitry V. Levin на комментарий #6)
> A workaround in rpm for the faulty telinit:
> https://git.altlinux.org/people/ldv/packages/?p=rpm.git;a=commitdiff;
> h=1f2fe8b68b9dcf2a46feb5891f1986ce7bca48e5
> Completely untested.

This works for my case.