Bug 53886 - /usr/sbin/univention-management-console-web-server --no-daemon fails with systemd
/usr/sbin/univention-management-console-web-server --no-daemon fails with sys...
Status: NEW
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
: systemd
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-10-08 16:27 CEST by Philipp Hahn
Modified: 2023-06-09 17:04 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.046
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2021092721000177
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2021-10-08 16:27:58 CEST
In MultiProcess mode there are several univention-management-console-web-server@1820?.service units. By default they invoke
> ExecStart=/usr/sbin/univention-management-console-web-server start --port=%i

which redirects STDOUD/STDERR/debug-output to /var/log/univention/management-console-web-server.log
In multi-process mode this is hard to read as multiple daemons append(or overwrite each other?) to that file.

systemd introduces journald, which is there to collect STDOUT and STDERR of daemones, which gives each daemon a separate data sink. UMC-web-server already has an option "--no-daemon", which can be used to prevent it from forking and re-directing the log output. But this option does not work with systemd as systemd closes STDIN/-OUT/-ERR, so /dev/std{in,out,err} do not exists and /proc/self/fd/{0,1,2} are closed respectively replaces by the 3 newly opened files/sockets. This leads to the following traceback:

Okt 08 15:59:40 m34 ls[3243]: /bin/ls: Zugriff auf '/dev/std*' nicht möglich: Datei oder Verzeichnis nicht gefunden
Okt 08 15:59:40 m34 ls[3243]: /proc/self/fd/:
Okt 08 15:59:40 m34 ls[3243]: insgesamt 0
Okt 08 15:59:40 m34 ls[3243]: lr-x------ 1 root root 64 Okt  8 15:59 0 -> /dev/null
Okt 08 15:59:40 m34 ls[3243]: lrwx------ 1 root root 64 Okt  8 15:59 1 -> socket:[30332]
Okt 08 15:59:40 m34 ls[3243]: lrwx------ 1 root root 64 Okt  8 15:59 2 -> socket:[30332]

Be aware that STDOUT and STDERR are *UNIX sockets* instead of files an opening them with open() will fail:

Okt 08 15:59:40 m34 ls[3243]: lr-x------ 1 root root 64 Okt  8 15:59 3 -> /proc/3243/fd
Okt 08 15:59:40 m34 systemd[1]: Started LSB: Univention Management Console Web Server.
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]: Could not open logfile "/dev/stderr"
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]: Traceback (most recent call last):
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]:   File "/usr/sbin/univention-management-console-web-server", line
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]:     http_daemon = UMC_HTTP_Daemon()
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]:   File "/usr/sbin/univention-management-console-web-server", line
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]:     DaemonRunner.__init__(self, self)
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]:   File "/usr/lib/python2.7/dist-packages/daemon/runner.py", line 
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]:     self.daemon_context.stdout = open(app.stdout_path, 'w+t')
Okt 08 15:59:41 m34 univention-management-console-web-server[3245]: IOError: [Errno 6] No such device or address: '/dev/stdout'

# cat /etc/systemd/system/univention-management-console-web-server.service.d/override.conf
[Service]
Type=simple
ExecStartPre=-/bin/ls -l /dev/std* /proc/self/fd/
ExecStart=
ExecStart=/usr/sbin/univention-management-console-web-server -n

# ucr search --brief ^umc/server/
umc/server/autostart: yes
umc/server/debug/level: 4
umc/server/disable-security-restrictions: <empty>
umc/server/dispatch-interval: <empty>
umc/server/processes: 3
umc/server/ssl/ciphers: <empty>
umc/server/upload/max: 2048
umc/server/upload/min_free_space: 51200

With --no-daemon "python-daemonize" should be skipped completely and UMC-web-server should not fiddle with STDIN/-OUT/-ERR at all.
Be aware that univention.debug.init("/dev/stderr",…) is used as well, which also fails in that case.

For UCS 4.4: Fix --no-daemon
For UCS 5.0: Convert to systemd

PS: For UCS-5.0-0 there was the plan to also use systemd in non-multiprocess-mode, but this is still pending accoridng to @fbest
Comment 1 Florian Best univentionstaff 2021-10-08 16:38:59 CEST
(In reply to Philipp Hahn from comment #0)
> In MultiProcess mode there are several
> univention-management-console-web-server@1820?.service units. By default
> they invoke
> > ExecStart=/usr/sbin/univention-management-console-web-server start --port=%i
> 
> which redirects STDOUD/STDERR/debug-output to
> /var/log/univention/management-console-web-server.log
> In multi-process mode this is hard to read as multiple daemons append(or
> overwrite each other?) to that file.
yes, that's why in multiprocessing mode each log line is prefixed with the pid.
Comment 2 Florian Best univentionstaff 2023-06-09 17:04:21 CEST
We have to re-evaluate this after Bug #43633.
UMC meanwhile is a systemd service, which is started in foreground but still logs to a specific logfile.

Interesting would also be if we can redirect the logs of the module sub-proceses into a specific journald-stream, so that we can filter stream only for certain modules.