diff options
author | Tommi Rantala <tommi.t.rantala@nokia.com> | 2019-08-05 14:01:58 +0300 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-08-14 18:22:09 +0200 |
commit | e57cd3fb886d3f298ac3756dcd96d4b142af06a0 (patch) | |
tree | 6d296d29f5634314a0719d0c3dda8194f3d06c07 /src | |
parent | 15e19aa1fc388485a5b4c33417189bff4dc3d883 (diff) | |
download | systemd-e57cd3fb886d3f298ac3756dcd96d4b142af06a0.tar.gz |
update-utmp: fix assertion failure if rescue.target, multi-user.target and graphical.target are all inactive
If rescue.target, multi-user.target and graphical.target are all
inactive, get_current_runlevel() is not able to determine current
runlevel, and returns with zero. This zero runlevel value results to
assertion failure in utmp_put_runlevel().
# systemctl stop rescue.target multi-user.target graphical.target
# systemctl start systemd-update-utmp-runlevel.service
systemd[1]: Stopped target Graphical Interface.
systemd[1]: Stopped target Multi-User System.
systemd[1]: Starting Update UTMP about System Runlevel Changes...
systemd-update-utmp[67]: Assertion 'runlevel > 0' failed at src/shared/utmp-wtmp.c:275, function utmp_put_runlevel(). Aborting.
systemd[1]: systemd-update-utmp-runlevel.service: Main process exited, code=dumped, status=6/ABRT
systemd[1]: systemd-update-utmp-runlevel.service: Failed with result 'core-dump'.
systemd[1]: Failed to start Update UTMP about System Runlevel Changes.
Let's just print a warning in this case and skip the utmp update, to
avoid systemd-update-utmp-runlevel.service failures.
Diffstat (limited to 'src')
-rw-r--r-- | src/update-utmp/update-utmp.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index bfc78b9739..56fb937647 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -191,6 +191,9 @@ static int on_runlevel(Context *c) { if (runlevel < 0) return runlevel; + if (runlevel == 0) + return log_warning("Failed to get new runlevel, utmp update skipped."); + if (previous == runlevel) return 0; |