Fix rc.log missing shutdown messages in some cases#1009
Conversation
|
"This was tested [...] on a live Alpine to work as expected and tested on some *BSD systems" Please add this information to the commit message as well. |
…) file system by preventing localmount from unmouting corresponding file system to early thus keeping rc.log file writable. Second attempt. Tested on live Gentoo and Alpine systems including system boots in various configuration and rc_logger, rc_log_path values. Partially tested on FreeBSD and GhostBSD for comparability where possible. Closes: OpenRC#977
Here we go. |
| if [ ! -f "${_log_file}" ]; then | ||
| touch "${_log_file}" || unset _log_file | ||
| fi |
There was a problem hiding this comment.
could we skip this whole block if the file doesn't exist? e.g.
if yesno ${rc_logger:-NO} || [ -f "${_log_file=:${rc_log_path:-/var/log/rc.log}}" ]
local rc_log_mntpnt="$(df ${_log_file} 2>/dev/null | awk 'NR==2 { print $6 }')"
if [ "$rc_log_mntpnt" != '/' ]; then
no_umounts_r="$no_umounts_r|${rc_log_mntpnt}"
fi
fi
There was a problem hiding this comment.
Unfortunately, touching is needed for the df to work correctly. The highlighted block addresses the "corner" case when user enables logging for the first time and the log file is missing. df will not work for the missing file therefore all messages during shutdown process will be lost, to circumvent this rare case I introduced the touch and an extra safety unset measure. On the next boot log file will be created and everything will start to work as expected. This covers all cases when log file is missing. Block removal will make user lose shutdown messages from current "session". I found this during live tests (as mentioned before). Originally I had something as suggested, but I believe this is pretty important to support such condition, especially the solution is pretty easy and short.
There was a problem hiding this comment.
I did my home work very well as I understand the responsibility if this PR is accepted and rolls out to all Gentoo and Alpine systems :)
There was a problem hiding this comment.
i forgot live logs go to tmpfs before going to the log file dir (and i have no idea why we do that, concurrent openrc.1 instances isn't really a thing we support)
hmm
Fix rc.log missing shutdown messages if located on separate (non-root) file system by preventing localmount from unmouting corresponding file system to early thus keeping rc.log file writable. Second attempt. Tested on live Gentoo and Alpine systems including system boots in various configuration and rc_logger, rc_log_path values. Partially tested on FreeBSD and GhostBSD for comparability where possible.
Closes: #977