Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log runlevel changes to console (during boot) #413

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Cropi
Copy link
Contributor

@Cropi Cropi commented Oct 29, 2024

Audit may initiate runlevel changes in several scenarios, such as when available disk space for audit logs becomes critically low. In these situations, audit can halt the system during boot, but without clear evidence indicating that audit was responsible for the shutdown. With the patch applied, audit will write to /dev/console when doing runlevel changes.

This comes in handy during boot, so sysadmins can track down the root cause of the shutdown much faster.

Audit may initiate runlevel changes in several scenarios,
such as when available disk space for audit logs becomes
critically low. In these situations, audit can halt the
system during boot, but without clear evidence indicating
that audit was responsible for the shutdown. With the patch
applied, audit will write to /dev/console when doing runlevel
changes.
@stevegrubb
Copy link
Contributor

The printf function attribute should be added to the function prototype. Look at audit_msg for an example. Also, normally we send messages after we perform the action in case the change fails. (There were cases in the past where something with init changed and it was unable to change to single user mode.) For halt, you have to send it before.

If runlevel is not HALT, we will wait until initd returns an
exit code. After that we can display to console if it succeeded.
@Cropi Cropi changed the title Log runlevel changes to console (during boot) [DRAFT]Log runlevel changes to console (during boot) Oct 31, 2024
During boot and auditd initialization, auditd is not
fully initialized and operational. This means that when
calling init_event(), we can't notify the parent process
that initialization is complete. However, if space_left_action
is set to SINGLE, we must avoid switching to that runlevel (during boot).
Before entering the SINGLE runlevel, it requires auditd to finish
initialization. But auditd will not start properly or signal
the init system that it has started, as it is blocked by
the attempt to switch to single-user mode, resulting in a
deadlock.
@Cropi
Copy link
Contributor Author

Cropi commented Nov 4, 2024

I put some comments under https://github.com/linux-audit/audit-userspace/pull/413/files#diff-561528b72c0692af52f6b4c90aae3f9ee3732c5837f448cddd68871a91cf6649R191. I was playing with options such as space_left_action= SINGLE and HALT. In case of SINGLE, I ended up in a deadlock. It's risky to call check_space_left during boot when auditd is not yet fully initialized.

@Cropi Cropi changed the title [DRAFT]Log runlevel changes to console (during boot) Log runlevel changes to console (during boot) Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants