polkit.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
  3. # ex: ts=8 sw=4 sts=4 et filetype=sh
  4. type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
  5. USERNAME=$(getarg live.user)
  6. [ -z "$USERNAME" ] && USERNAME=anon
  7. # Check that polkit is installed.
  8. if [ ! -x ${NEWROOT}/usr/libexec/polkitd ]; then
  9. exit 0
  10. fi
  11. # configure PolicyKit in live session
  12. mkdir -m0755 -p ${NEWROOT}/etc/PolicyKit
  13. cat << EOF > ${NEWROOT}/etc/PolicyKit/PolicyKit.conf
  14. <?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
  15. <!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
  16. "http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">
  17. <!-- See the manual page PolicyKit.conf(5) for file format -->
  18. <config version="0.1">
  19. <match user="root">
  20. <return result="yes"/>
  21. </match>
  22. <!-- don't ask password for user in live session -->
  23. <match user="$USERNAME">
  24. <return result="yes"/>
  25. </match>
  26. <define_admin_auth group="admin"/>
  27. </config>
  28. EOF
  29. mkdir -m0750 -p ${NEWROOT}/var/lib/polkit-1/localauthority/10-vendor.d
  30. cat << EOF > ${NEWROOT}/var/lib/polkit-1/localauthority/10-vendor.d/10-live-cd.pkla
  31. # Policy to allow the livecd user to bypass policykit
  32. [Live CD user permissions]
  33. Identity=unix-user:$USERNAME
  34. Action=*
  35. ResultAny=no
  36. ResultInactive=no
  37. ResultActive=yes
  38. EOF