Last active
February 26, 2026 07:23
-
-
Save hector-cao/598d34c4d9a80105d3ced73b1c7add79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ┌─────────────────────────────────────────────┐ | |
| │ Client │ | |
| │ │ | |
| │ virsh / virt-manager / custom app │ | |
| │ (running as a UNIX user) │ | |
| └───────────────────────┬─────────────────────┘ | |
| │ | |
| │ connect() | |
| ▼ | |
| ┌─────────────────────────────────────────────┐ | |
| │ UNIX domain socket (FS) │ | |
| │ │ | |
| │ /run/libvirt/libvirt-sock │ | |
| │ /run/libvirt/libvirt-sock-ro │ | |
| │ │ | |
| │ Owner : root │ | |
| │ Group : libvirt │ | |
| │ Mode : 0660 │ | |
| └───────────────────────┬─────────────────────┘ | |
| │ | |
| (kernel permission check) | |
| │ | |
| uid / gid / mode bits | |
| │ | |
| ▼ | |
| ┌─────────────────────────────────────────────┐ | |
| │ systemd socket unit │ | |
| │ │ | |
| │ libvirtd.socket │ | |
| │ libvirtd-ro.socket │ | |
| │ │ | |
| │ SocketGroup=libvirt │ | |
| │ SocketMode=0660 │ | |
| │ │ | |
| │ NOTE: overrides unix_sock_* in │ | |
| │ libvirtd.conf │ | |
| └───────────────────────┬─────────────────────┘ | |
| │ | |
| (connection accepted) | |
| │ | |
| ▼ | |
| ┌─────────────────────────────────────────────┐ | |
| │ libvirtd │ | |
| │ │ | |
| │ Reads /etc/libvirt/libvirtd.conf │ | |
| │ │ | |
| │ auth_unix_rw = "polkit" | "sasl" | "none" │ | |
| │ auth_unix_ro = "polkit" | "sasl" | "none" │ | |
| │ │ | |
| │ Gets peer credentials via SO_PEERCRED │ | |
| │ (uid, gid, pid) │ | |
| └───────────────────────┬─────────────────────┘ | |
| │ | |
| Authentication backend selection | |
| │ | |
| based on libvirtd.conf options | |
| │ | |
| ┌───────────────┴────────────────┐ | |
| │ │ | |
| ▼ ▼ | |
| ┌─────────────────────────────┐ ┌─────────────────────────────┐ | |
| │ polkit │ │ SASL │ | |
| │ │ │ │ | |
| │ auth_unix_rw = "polkit" │ │ auth_unix_rw = "sasl" │ | |
| │ auth_unix_ro = "polkit" │ │ auth_unix_ro = "sasl" │ | |
| │ │ │ │ | |
| │ Action-based authorization │ │ Username / password │ | |
| │ per API call │ │ or Kerberos │ | |
| │ │ │ │ | |
| │ Examples: │ │ Configured via: │ | |
| │ org.libvirt.unix.manage │ │ /etc/sasl2/libvirt.conf │ | |
| │ org.libvirt.unix.monitor │ │ │ | |
| └───────────────┬─────────────┘ └───────────────┬─────────────┘ | |
| │ │ | |
| └───────────────┬─────────────────┘ | |
| │ | |
| ▼ | |
| ┌─────────────────────────────────────────────┐ | |
| │ Authorization result │ | |
| │ │ | |
| │ ✔ API allowed │ | |
| │ ✖ API denied │ | |
| │ │ | |
| │ Decision is PER OPERATION, not per socket │ | |
| └─────────────────────────────────────────────┘ | |
| To make Ubuntu use polkit: | |
| - give broader access to socket file (probably to everyone) | |
| - modify libvirtd.conf to use polkit instead of "none" for the auth backend | |
| - modify/overlay upstream polkit libvirt rules for Ubuntu specificities |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment