[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#968096: reportbug: Can't detect OpenRC as init



Package: reportbug
Version: 7.7.0
Severity: normal

Dear Maintainer,

Currently reportbug does not detect openrc as init system. (The same seems to 
apply to s6, but I never used s6).
What makes this a bit more complicated is, that it is possible to use openrc 
as 
a service manager and supervisor, but something else — eg sysv-init — as the 
actual init-system.
Or use openrc as init, but leave (some or all) process supervision to s6
  https://github.com/OpenRC/openrc/blob/master/s6-guide.md
.

I've attached patches that afaik should allow OpenRC to be correctly detected 
in 
a "normal" setup and also added a patch to check the name of the actual pid 1 
process, which should work for an openrc+sysv configuration.
I'm not sure what to do with openrc+s6 (and I never used both in conjunction) 
or
if this even matters.

Regards
Nils König

(Below information generated with patched reportbug; see attached patches)

-- Package-specific info:

-- System Information:
Debian Release: 10.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable'), (10, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.7.12-pc3+fs (SMP w/16 CPU threads)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not 
set
Shell: /bin/sh linked to /usr/bin/dash
Init: openrc (via /run/openrc)
PID 1: openrc-init
LSM: AppArmor: enabled

Versions of packages reportbug depends on:
ii  apt                1.8.2.1
ii  python3            3.7.3-1
ii  python3-reportbug  7.7.0+openrc+pid1
ii  sensible-utils     0.0.12

reportbug recommends no packages.

Versions of packages reportbug suggests:
pn  claws-mail                                            <none>
pn  debconf-utils                                         <none>
ii  debsums                                               2.2.3
pn  default-mta | postfix | exim4 | mail-transport-agent  <none>
pn  dlocate                                               <none>
pn  emacs-bin-common                                      <none>
ii  file                                                  1:5.35-4+deb10u1
ii  gnupg                                                 2.2.12-1+deb10u1
pn  python3-urwid                                         <none>
pn  reportbug-gtk                                         <none>
ii  xdg-utils                                             1.1.3-1+deb10u1

Versions of packages python3-reportbug depends on:
ii  apt                1.8.2.1
ii  file               1:5.35-4+deb10u1
ii  python3            3.7.3-1
ii  python3-apt        1.8.4.1
ii  python3-debian     0.1.35
ii  python3-debianbts  3.0.2
ii  python3-requests   2.21.0-1
ii  sensible-utils     0.0.12

python3-reportbug suggests no packages.

-- no debconf information


From eee54657ee872be51dcb4aced65d96d2b22818cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nils=20K=C3=B6nig?= <nkoe@gylk.de>
Date: Sat, 8 Aug 2020 01:02:12 +0200
Subject: [PATCH 1/2] reportbug/utils.py: Detect OpenRC as init

OPenRC's init is shipped as /sbin/openrc-init, but its mere
prescence does not indicate if OpenRC is actually used.
Therefore attempt to detect OpenRC by checking for its run-folder.
The caveat is, that openrc may be used as the service manager, but not
as the actual pid1 init system.
---
 reportbug/utils.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/reportbug/utils.py b/reportbug/utils.py
index a1c68b3..beb4828 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -1207,6 +1207,8 @@ def get_init_system():
         init = 'upstart (via init_is_upstart())'
     elif os.path.isfile('/run/runit.stopit'):
         init = 'runit (via /run/runit.stopit)'
+    elif os.path.isdir('/run/openrc'):
+        init = 'openrc (via /run/openrc)'
     elif os.path.isfile('/sbin/init') and not os.path.islink('/sbin/init'):
         init = 'sysvinit (via /sbin/init)'
 
-- 
2.20.1

From 292891d9e85b1339c1e0364d1f83dfbaba0dba8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nils=20K=C3=B6nig?= <nkoe@gylk.de>
Date: Sat, 8 Aug 2020 01:12:12 +0200
Subject: [PATCH 2/2] reportbug/bugreport.py, reportbug/utils.py: Check PID 1
 name

It is possible to create setups, in which service-management and
pid1-init are done by different programms, eg openrc with sysv-init.
To have better chances at correctly identifying these setups, check the
PID 1 command name.
---
 reportbug/bugreport.py |  3 +++
 reportbug/utils.py     | 13 +++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/reportbug/bugreport.py b/reportbug/bugreport.py
index 920e045..d334852 100644
--- a/reportbug/bugreport.py
+++ b/reportbug/bugreport.py
@@ -83,6 +83,7 @@ class bugreport(object):
         debinfo = ''
         shellpath = utils.realpath('/bin/sh')
         init = utils.get_init_system()
+        pid1 = utils.get_pid1_name()
         lsminfo = utils.get_lsm_info()
         taint_flags = utils.get_kernel_taint_flags()
 
@@ -190,6 +191,8 @@ class bugreport(object):
             debinfo += 'Shell: /bin/sh linked to %s\n' % shellpath
         if init:
             debinfo += 'Init: %s\n' % init
+        if pid1:
+            debinfo += 'PID 1: %s\n' % pid1
         if lsminfo:
             debinfo += 'LSM: %s\n' % lsminfo
 
diff --git a/reportbug/utils.py b/reportbug/utils.py
index beb4828..feeb093 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -1214,6 +1214,19 @@ def get_init_system():
 
     return init
 
+def get_pid1_name():
+    """Get command name of pid-1.
+    This may help in some init+service configurations"""
+
+    pid1 = 'unable to detect'
+
+    if os.path.isfile('/proc/1/comm') and os.access('/proc/1/comm', os.R_OK):
+        pfile = open('/proc/1/comm')
+        pid1 = pfile.read().rstrip('\n')
+        pfile.close()
+
+    return pid1
+
 def get_lsm_info():
     """Determines the linux security module enabled on the current machine
 
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature


Reply to: