Openbsd

為什麼我不能修改 OpenBSD 安全級別?

  • October 3, 2017

我剛剛安裝了一個 OpenBSD。我編輯了“vi /etc/rc.securelevel”並將安全級別從 1 設置為 0。保存文件,然後重新啟動。但是在重新啟動後,sysctl 指出安全級別仍然是 1。為什麼?

查看Absolute OpenBSD的特定部分- Michael W. Lucas

安全級別 0

Securelevel 0 僅在系統首次引導時使用。它沒有提供任何特殊功能。但是,當系統進入多使用者模式時,安全性會自動提高到 1。設置securelevel=0in 在 /etc/rc.securelevel功能上等同於設置 securelevel=1

查看 OpenBSD 文件 - securelevel(7)

剪輯:

Securelevel provides convenient means of ``locking down'' a system to a
degree suited to its environment.  It is normally set at boot via the
rc.securelevel(8) script, or the superuser may raise securelevel at any
time by modifying the kern.securelevel sysctl(8) variable.  However, only
init(8) may lower it once the system has entered secure mode.  A kernel
built with option INSECURE in the config file will default to permanently
insecure mode.

看看永久不安全的:

-1 Permanently insecure mode
      -   init(8) will not attempt to raise the securelevel
      -   may only be set with sysctl(8) while the system is insecure
      -   otherwise identical to securelevel 0

現在,查看init(8)手冊頁的相關部分:

The kernel securelevel(7) is normally set to 0 while in single-user mode,
and raised to 1 when the system begins multi-user operations. This action
will not take place if the securelevel is -1, and can be modified via the
/etc/rc.securelevel script.

tl,dr:沒有辦法留在securelevel 0。它將自動提升 1. 為此,您必須使用securelevel -1,這只能通過重建核心以永久方式實現(您真的想要這個嗎?)。請記住:安全級別只能提高。任何需要在安全級別提升之前執行的東西,都應該放在/etc/rc.securelevel.

引用自:https://unix.stackexchange.com/questions/110275