fix selinux policy for reboots

This commit is contained in:
2026-11-21 09:48:46 +01:00
parent f6e76f8635
commit ca92d3f564
2 changed files with 9 additions and 8 deletions
+7 -7
View File
@@ -52,6 +52,13 @@ def fork_and_reboot(report_success=True):
else: else:
exit_code=1 exit_code=1
# reboot the systemd way on supported platforms
if os.path.exists('/proc/1/comm'):
with open('/proc/1/comm', 'r') as f:
if f.readline().strip() == 'systemd':
os.execl('/usr/bin/systemctl', 'systemctl', 'reboot', '--no-block', '--when=+1m')
log.error("Failed to execl?")
sys.exit(1)
try: try:
pid = os.fork() pid = os.fork()
if pid != 0: if pid != 0:
@@ -72,13 +79,6 @@ def fork_and_reboot(report_success=True):
log.error("Fork #2 failed when going for reboot: {}".format(err)) log.error("Fork #2 failed when going for reboot: {}".format(err))
sys.exit(1) sys.exit(1)
# reboot the systemd way on supported platforms
if os.path.exists('/proc/1/comm'):
with open('/proc/1/comm', 'r') as f:
if f.readline().strip() == 'systemd':
os.execl('/usr/bin/systemctl', 'systemctl', 'reboot', '--no-block', '--when=+1m')
log.error("Failed to execl?")
sys.exit(1)
sys.stdout.flush() sys.stdout.flush()
+2 -1
View File
@@ -43,6 +43,7 @@ kernel_read_vm_overcommit_sysctl(sau_t)
manage_fifo_files_pattern(sau_t, sau_t, sau_t) manage_fifo_files_pattern(sau_t, sau_t, sau_t)
corecmd_exec_shell(sau_t) corecmd_exec_shell(sau_t)
logging_send_syslog_msg(sau_t) logging_send_syslog_msg(sau_t)
allow sau_t self:process { sigkill };
# Identify running services and their open files # Identify running services and their open files
kernel_list_all_proc(sau_t) kernel_list_all_proc(sau_t)
@@ -76,7 +77,7 @@ systemd_exec_systemctl(sau_t)
init_admin(sau_t) init_admin(sau_t)
dbus_system_bus_client(sau_t) dbus_system_bus_client(sau_t)
dbus_system_bus_receive_file_handle(sau_t, sau_t) dbus_system_bus_receive_file_handle(sau_t, sau_t)
allow sau_t systemd_logind_t:dbus send_msg; systemd_dbus_chat_logind(sau_t)
# Run portage # Run portage
optional_policy(` optional_policy(`