From b94dc7d8ab946d9f664768d65dc4797de2e69c0d Mon Sep 17 00:00:00 2001 From: Kanako the Gay Date: Tue, 21 May 2024 18:04:53 -0700 Subject: [PATCH] Podman detection --- etc/rc.conf | 1 + init.d/binfmt.in | 2 +- init.d/cgroups.in | 2 +- init.d/consolefont.in | 2 +- init.d/devfs.in | 2 +- init.d/dmesg.in | 2 +- init.d/fsck.in | 2 +- init.d/hostname.in | 2 +- init.d/hwclock.in | 2 +- init.d/keymaps.in | 2 +- init.d/localmount.in | 2 +- init.d/modules.in | 2 +- init.d/mount-ro.in | 2 +- init.d/net-online.in | 2 +- init.d/netmount.in | 2 +- init.d/numlock.in | 2 +- init.d/procfs.in | 2 +- init.d/root.in | 2 +- init.d/save-keymaps.in | 2 +- init.d/save-termencoding.in | 2 +- init.d/seedrng.in | 2 +- init.d/swap.in | 2 +- init.d/swclock.in | 2 +- init.d/sysfs.in | 2 +- init.d/termencoding.in | 2 +- init.d/urandom.in | 2 +- man/openrc-run.8 | 2 ++ sh/rc-functions.sh | 2 +- src/librc/librc.c | 4 ++++ src/librc/rc.h.in | 1 + 30 files changed, 34 insertions(+), 26 deletions(-) diff --git a/etc/rc.conf b/etc/rc.conf index d359eb9ef..ca0f92075 100644 --- a/etc/rc.conf +++ b/etc/rc.conf @@ -168,6 +168,7 @@ # # "" - nothing special # "docker" - Docker container manager (Linux) +# "podman" - Podman container manager (Linux) # "jail" - Jail (DragonflyBSD or FreeBSD) # "lxc" - Linux Containers # "openvz" - Linux OpenVZ diff --git a/init.d/binfmt.in b/init.d/binfmt.in index ecf9b8a64..cfb88d1b1 100644 --- a/init.d/binfmt.in +++ b/init.d/binfmt.in @@ -15,7 +15,7 @@ depend() { after clock procfs use modules devfs - keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/cgroups.in b/init.d/cgroups.in index ac1f5cc85..2ee3f25c2 100644 --- a/init.d/cgroups.in +++ b/init.d/cgroups.in @@ -15,7 +15,7 @@ description="Mount the control groups." depend() { - keyword -docker -prefix -systemd-nspawn -vserver + keyword -docker -podman -prefix -systemd-nspawn -vserver after sysfs } diff --git a/init.d/consolefont.in b/init.d/consolefont.in index 8c96af50b..3e84ae4a6 100644 --- a/init.d/consolefont.in +++ b/init.d/consolefont.in @@ -15,7 +15,7 @@ depend() { need termencoding after hotplug bootmisc modules - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } start() diff --git a/init.d/devfs.in b/init.d/devfs.in index 0cc3ba033..ca751e3d4 100644 --- a/init.d/devfs.in +++ b/init.d/devfs.in @@ -15,7 +15,7 @@ depend() { provide dev-mount before dev - keyword -docker -prefix -systemd-nspawn -vserver + keyword -docker -podman -prefix -systemd-nspawn -vserver } mount_dev() diff --git a/init.d/dmesg.in b/init.d/dmesg.in index e80d140af..116b4f177 100644 --- a/init.d/dmesg.in +++ b/init.d/dmesg.in @@ -14,7 +14,7 @@ description="Set the dmesg level for a cleaner boot" depend() { before dev modules - keyword -docker -lxc -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/fsck.in b/init.d/fsck.in index 008b1bca6..82f22e99a 100644 --- a/init.d/fsck.in +++ b/init.d/fsck.in @@ -17,7 +17,7 @@ depend() { after clock use dev clock modules - keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -timeout -vserver -uml + keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -timeout -vserver -uml } _abort() { diff --git a/init.d/hostname.in b/init.d/hostname.in index 3d70a2f34..fc949336e 100644 --- a/init.d/hostname.in +++ b/init.d/hostname.in @@ -14,7 +14,7 @@ description="Sets the hostname of the machine." depend() { after clock - keyword -docker -lxc -prefix -systemd-nspawn + keyword -docker -podman -lxc -prefix -systemd-nspawn } start() diff --git a/init.d/hwclock.in b/init.d/hwclock.in index aa765cce4..02c6758be 100644 --- a/init.d/hwclock.in +++ b/init.d/hwclock.in @@ -34,7 +34,7 @@ depend() if yesno $clock_adjfile; then use root fi - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } setupopts() diff --git a/init.d/keymaps.in b/init.d/keymaps.in index fa7f1958a..da60e0ac6 100644 --- a/init.d/keymaps.in +++ b/init.d/keymaps.in @@ -15,7 +15,7 @@ depend() { need termencoding after devfs - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } start() diff --git a/init.d/localmount.in b/init.d/localmount.in index 8a66eb8d9..e336164dd 100644 --- a/init.d/localmount.in +++ b/init.d/localmount.in @@ -16,7 +16,7 @@ depend() need fsck root use lvm modules after clock lvm modules - keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver + keyword -docker -podman -jail -lxc -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/modules.in b/init.d/modules.in index 9a0646077..ce4df24e8 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -15,7 +15,7 @@ depend() { use isapnp provide modules-load - keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver } find_modfiles() diff --git a/init.d/mount-ro.in b/init.d/mount-ro.in index 05c828dac..fba65c817 100644 --- a/init.d/mount-ro.in +++ b/init.d/mount-ro.in @@ -14,7 +14,7 @@ description="Re-mount filesystems read-only for a clean reboot." depend() { after killprocs savecache - keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/net-online.in b/init.d/net-online.in index 7f753aaea..6703b3e8f 100644 --- a/init.d/net-online.in +++ b/init.d/net-online.in @@ -16,7 +16,7 @@ depend() after modules net need sysfs provide network-online - keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver + keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver } get_interfaces() diff --git a/init.d/netmount.in b/init.d/netmount.in index 2296e91c9..d89fa6395 100644 --- a/init.d/netmount.in +++ b/init.d/netmount.in @@ -26,7 +26,7 @@ depend() use afc-client amd openvpn use dns use root - keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver + keyword -docker -podman -jail -lxc -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/numlock.in b/init.d/numlock.in index 7be58c994..44bda928f 100644 --- a/init.d/numlock.in +++ b/init.d/numlock.in @@ -15,7 +15,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} depend() { - keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver } _setleds() diff --git a/init.d/procfs.in b/init.d/procfs.in index 024edaf09..35f6fd7ba 100644 --- a/init.d/procfs.in +++ b/init.d/procfs.in @@ -16,7 +16,7 @@ depend() after clock use devfs want modules - keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/root.in b/init.d/root.in index 2f7d82f26..0a059a2fb 100644 --- a/init.d/root.in +++ b/init.d/root.in @@ -15,7 +15,7 @@ depend() { after clock need fsck - keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/save-keymaps.in b/init.d/save-keymaps.in index 2c3b33271..12e6f5c18 100644 --- a/init.d/save-keymaps.in +++ b/init.d/save-keymaps.in @@ -13,7 +13,7 @@ depend() { need termencoding after bootmisc clock keymaps - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } start() diff --git a/init.d/save-termencoding.in b/init.d/save-termencoding.in index bf08de39e..adb115d8d 100644 --- a/init.d/save-termencoding.in +++ b/init.d/save-termencoding.in @@ -14,7 +14,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} depend() { - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu use root after bootmisc clock termencoding } diff --git a/init.d/seedrng.in b/init.d/seedrng.in index 15dd3f54a..b1c9f07e1 100644 --- a/init.d/seedrng.in +++ b/init.d/seedrng.in @@ -15,7 +15,7 @@ depend() { after clock need localmount - keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn + keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn provide urandom } diff --git a/init.d/swap.in b/init.d/swap.in index 40c3dbaf5..9bff39985 100644 --- a/init.d/swap.in +++ b/init.d/swap.in @@ -13,7 +13,7 @@ depend() { after clock root before localmount - keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver + keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -vserver } start() diff --git a/init.d/swclock.in b/init.d/swclock.in index 63c052d1e..44c7e12b9 100644 --- a/init.d/swclock.in +++ b/init.d/swclock.in @@ -15,7 +15,7 @@ swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}" depend() { provide clock - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } # swclock is an OpenRC built in diff --git a/init.d/sysfs.in b/init.d/sysfs.in index 37745ff27..7ef06142e 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -15,7 +15,7 @@ sysfs_opts=nodev,noexec,nosuid depend() { - keyword -docker -lxc -prefix -systemd-nspawn -vserver + keyword -docker -podman -lxc -prefix -systemd-nspawn -vserver } mount_sys() diff --git a/init.d/termencoding.in b/init.d/termencoding.in index 783df525b..c03e245ec 100644 --- a/init.d/termencoding.in +++ b/init.d/termencoding.in @@ -16,7 +16,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} depend() { - keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu + keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu after devfs } diff --git a/init.d/urandom.in b/init.d/urandom.in index 82020853c..e7cb0e446 100644 --- a/init.d/urandom.in +++ b/init.d/urandom.in @@ -16,7 +16,7 @@ depend() { after clock need localmount - keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn + keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn } save_seed() diff --git a/man/openrc-run.8 b/man/openrc-run.8 index 0c977f963..552fcb91f 100644 --- a/man/openrc-run.8 +++ b/man/openrc-run.8 @@ -318,6 +318,8 @@ Same as -jail, but for Xen DOM0 systems. Same as -jail, but for Xen DOMU systems. .It Dv -docker Same as -jail, but for docker systems. +.It Dv -podman +Same as -jail, but for podman systems. .It Dv -containers Same as -jail, but for all relevant container types on the operating system. diff --git a/sh/rc-functions.sh b/sh/rc-functions.sh index 81d065b84..43f75a90d 100644 --- a/sh/rc-functions.sh +++ b/sh/rc-functions.sh @@ -100,7 +100,7 @@ _get_containers() { c="-jail" ;; Linux) - c="-docker -lxc -openvz -rkt -systemd-nspawn -uml -vserver" + c="-docker -podman -lxc -openvz -rkt -systemd-nspawn -uml -vserver" ;; esac echo $c diff --git a/src/librc/librc.c b/src/librc/librc.c index 118726dfd..97445aad9 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -287,6 +287,8 @@ detect_container(const char *systype RC_UNUSED) return RC_SYS_SYSTEMD_NSPAWN; if (strcmp(systype, RC_SYS_DOCKER) == 0) return RC_SYS_DOCKER; + if (strcmp(systype, RC_SYS_PODMAN) == 0) + return RC_SYS_PODMAN; } if (file_regex("/proc/cpuinfo", "UML")) return RC_SYS_UML; @@ -306,6 +308,8 @@ detect_container(const char *systype RC_UNUSED) return RC_SYS_SYSTEMD_NSPAWN; else if (exists("/.dockerenv")) return RC_SYS_DOCKER; + else if (exists("/run/.containerenv")) + return RC_SYS_PODMAN; /* old test, I'm not sure when this was valid. */ else if (file_regex("/proc/1/environ", "container=docker")) return RC_SYS_DOCKER; diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index 69d9d0e47..d90943b65 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -319,6 +319,7 @@ bool rc_service_daemons_crashed(const char *); * OpenRC can support some special sub system types, normally virtualization. * Some services cannot work in these systems, or we do something else. */ #define RC_SYS_DOCKER "DOCKER" +#define RC_SYS_PODMAN "PODMAN" #define RC_SYS_JAIL "JAIL" #define RC_SYS_NONE "" #define RC_SYS_OPENVZ "OPENVZ"