ubuntu 인스톨 후 재부팅시 password 요구하는 현상

 



Ubuntu 20.04.4 server iso에 autoinstall을 이용해서 ubuntu-desktop 패키지를 포함했다.
설치완료 후 GUI 환경으로 로그인하고 reboot를 시도하자 패스워드를 물어본다.
신기한건 OS 설치완료 후 1시간쯤 지나고 나서는 패스워드를 물어보지 않는다. 왜 그럴까

polkit-1

시스템 툴에 관한 권한을 관리한다.

만약 유저가 어떤 package를 설치하려고 시도하면, package manager는 polkit에게 그래도 되는지 물어보고 polkit이 정의한 규칙에 따라 비밀번호를 요구할지 등을 결정한다.

/etc/polkit-1 또는 /usr/share/polkit-1 directory에 rule과 action들이 파일들로 저장되어있다.

같은 내용에 대해서는 etc 디렉토리 내용이 우선한다

polkit policy

/usr/share/polkit-1/actions/org.freedesktop.login1.policy 파일 내용 중 아래와 같은 내용이 있다.

<action id="org.freedesktop.login1.reboot-ignore-inhibit">
                <description gettext-domain="systemd">Reboot the system while an application asked to inhibit it</description>
                <message gettext-domain="systemd">Authentication is required for rebooting the system while an application asked to inhibit it.</message>
                <defaults>
                        <allow_any>auth_admin_keep</allow_any>
                        <allow_inactive>auth_admin_keep</allow_inactive>
                        <allow_active>auth_admin_keep</allow_active>
                </defaults>
                <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.reboot</annotate>
        </action>


GUI화면에서 reboot를 시도할때 ubuntu-desktop 패키지에 관련된 application(?)이 reboot를 시도하는 것이고 위내용의 policy를 따른것 같다.

ResultActive가 auth_self 로 되어있으면 Identity에 명시된 유저의 비밀번호 입력을 요구한다

ResultActive는 active session에 대한 규칙이고 ResultInactive는 inactive session에 관한 규칙이다.

auth log

reboot에 패스워드를 요구하는 당시 /var/log/auth.log 내용 중에 다음 내용이 있다.

May 19 02:46:29 lunit polkitd(authority=local): Operator of unix-session:2 FAILED to authenticate to gain authorization for action org.freedesktop.login1.reboot-ignore-inhibit for system-bus-name::1.87 [/usr/libexec/gnome-session-binary --systemd-service --session=ubuntu] (owned by unix-user:lunit)

polkit 정책 관련된 내용으로 보인다

systemd-inhibit --list

os 설치 직후 재부팅 시도시 패스워드를 요구할때와 한시간 뒤 요구하지 않을때 systemd-inhibit --list 결과를 비교해봤다.

재부팅 시도시 패스워드를 물어볼 당시 systemd-inhibit --list의 결과

파란색으로 지운부분의 user id는 OS 설치할때 입력했던 id였다.



1시간 뒤 재부팅 시도시 패스워드 안 물어볼때

부팅시 입력하는 user id가 보이지 않는다



결론(추측)

GUI에서 재부팅 시도를 하면 desktop 관련된 session이 시스템에 reboot를 요청하고 polkit 정책에 따라 session의 authentication을 요구하는 듯하다.

systemd-inhibit —list 결과를 봤을때, OS 설치직후 백그라운드에서 뭔가 셋업작업이 한동안 진행이 되고 있고 그동안 OS 설치할때 로그인했던 유저가 session 의 owner이고 reboot를 시도해서 유저의 패스워드를 요구한 상황인듯하다.

한시간뒤 백그라운드 작업이 완료되고 나서는 reboot을 시도하는 session의 주체가 더이상 유저가 아니라 gdm이거나 다른 어떤 패스워드가 없는 owner이기 때문에 패스워드를 요구하게 되지 않게 된게 아닐까


polkit 관련 내용 메모

  • /etc/polkit-1/localauthority/50-local.d/ 이 새로운 규칙을 정의할 수도 있다.
sudo vim /etc/polkit-1/localauthority/50-local.d/allow_all_users_to_shutdown.pkla


  • 아래 내용은 예시.
[Allow all users to shutdown]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop-multiple-users
ResultInactive=no
ResultActive=yes


  • identity는 어느 유저에게 적용할 rule일지 결정한다. jihoon 대신 * 을 입력하면 모든 유저에게 적용한다.

  • 아래처럼 여러 유저를 입력할 수도 있다.

unix-user:jihoon;unix-group:examplegroup


  • 위처럼 입력하면 유저 jihoon 뿐 아니라 examplegroup 그룹 전체에 적용한다.
  • action에는 허용할 내용.
  • pkaction 명령어를 이용하면 어떤 action들을 정의할수 있는지 확인할 수 있다.
  • 아래 명령을 통해서 action에 관한 상세내용을 확인할 수 있다.
# pkaction --verbose --action-id [pkactiond에서 확인한 action 이름]
$ pkaction --verbose --action-id org.freedesktop.NetworkManager.settings.modify.system
org.freedesktop.NetworkManager.settings.modify.system:
  description:       Modify network connections for all users
  message:           System policy prevents modification of network settings for all users
  vendor:            NetworkManager
  vendor_url:        <http://www.gnome.org/projects/NetworkManager>
  icon:              nm-icon
  implicit any:      auth_admin_keep
  implicit inactive: auth_admin_keep
  implicit active:   auth_admin_keep


  • 위 결과를 보면 org.freedesktop.NetworkManager.settings.modify.system 는 NetworkManager를 통해 네트워크 설정을 바꾸는 것을 모든 유저에게 허용하고 있다는 것을 알수 있다.

댓글 쓰기

0 댓글