Last active
December 5, 2022 23:12
-
-
Save denji/bdb54a436015efd938640dc9913e6c63 to your computer and use it in GitHub Desktop.
Allow access to anyone in the libvirt group to run virt-manager without sudo. Tested on Ubuntu 18.04. #Polkit #PolicyKit #pkaction #qemu #kvm #sudo #linux
This file contains 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
# Ubuntu/Debian | |
# New rules files are written in JavaScript unsupported. (need pkaction 0.106+) | |
# /etc/polkit-1/localauthority/50-local.d/libvirt-manage.pkla | |
[libvirt Management Access] | |
Identity=unix-group:libvirt | |
Action=org.libvirt.unix.manage | |
ResultActive=yes | |
ResultInactive=yes | |
ResultAny=yes |
This file contains 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
// CentOS/Fedora/RHEL | |
// /etc/polkit-1/rules.d/80-libvirt.rules | |
// https://libvirt.org/auth.html | |
// https://wiki.archlinux.org/index.php/Polkit | |
// https://gist.github.com/grawity/3886114 | |
// sudo systemctl restart polkit | |
polkit.addRule(function(action, subject) { | |
if (action.id == "org.libvirt.unix.manage" && subject.local && subject.isInGroup("libvirt")) { | |
return polkit.Result.YES; | |
} | |
}); |
This file contains 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
// https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html | |
// sudo systemctl restart polkit | |
// allow user denji | |
polkit.addRule(function(action, subject) { | |
if (action.id == "org.libvirt.unix.manage" && subject.local && subject.user == "denji") { | |
return polkit.Result.YES; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment