vmklive-polkit.sh 1.3 KB

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