void-packages/srcpkgs/xbps-casper/files/scripts/casper-bottom/44polkit-void

61 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/bin/sh
PREREQ=""
DESCRIPTION="Modifying PolicyKit grants for '$USERNAME' user"
[ -r /scripts/functions ] && . /scripts/functions
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Check that polkit is installed.
if [ ! -x ${rootmnt}/usr/libexec/polkitd ]; then
exit 0
fi
log_begin_msg "$DESCRIPTION"
# configure PolicyKit in live session
mkdir -m0755 -p ${rootmnt}/etc/PolicyKit
cat << EOF > ${rootmnt}/etc/PolicyKit/PolicyKit.conf
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">
<!-- See the manual page PolicyKit.conf(5) for file format -->
<config version="0.1">
<match user="root">
<return result="yes"/>
</match>
<!-- don't ask password for user in live session -->
<match user="$USERNAME">
<return result="yes"/>
</match>
<define_admin_auth group="admin"/>
</config>
EOF
mkdir -m0750 -p ${rootmnt}/var/lib/polkit-1/localauthority/10-vendor.d
cat << EOF > ${rootmnt}/var/lib/polkit-1/localauthority/10-vendor.d/10-live-cd.pkla
# Policy to allow the livecd user to bypass policykit
[Live CD user permissions]
Identity=unix-user:$USERNAME
Action=*
ResultAny=no
ResultInactive=no
ResultActive=yes
EOF
log_end_msg