2018-04-12 15:24:46 -04:00
|
|
|
#!/bin/bash
|
|
|
|
# From https://github.com/tasket/Qubes-VM-hardening
|
2023-05-01 13:28:02 -04:00
|
|
|
# installer version 0.9.4
|
2018-04-12 15:24:46 -04:00
|
|
|
|
|
|
|
set -e
|
|
|
|
[ `id -u` -eq 0 ] || exit
|
2019-07-17 09:14:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
if [ ! -e /etc/sudoers.d/qubes ]; then
|
|
|
|
echo "The 'qubes-core-agent-passwordless-root' package does not appear"
|
2019-07-18 05:23:21 -04:00
|
|
|
echo "to be present or configured; sudo autoconfiguration skipped."
|
2019-07-17 09:14:37 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-04-12 15:24:46 -04:00
|
|
|
if [ ! -e /etc/debian_version ]; then
|
2019-07-17 09:14:37 -04:00
|
|
|
echo "Debian-based template required for sudo autoconfiguration.
|
2019-07-18 05:23:21 -04:00
|
|
|
See https://qubes-os.org/doc/vm-sudo for manual instructions."
|
2019-07-17 09:14:37 -04:00
|
|
|
exit 1
|
2018-04-12 15:24:46 -04:00
|
|
|
fi
|
|
|
|
|
2019-08-27 21:13:20 -04:00
|
|
|
|
|
|
|
if [ "$1" = "--force" ]; then
|
|
|
|
force=1
|
|
|
|
else
|
|
|
|
force=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q '^auth .* dom0\squbes\.VMAuth' /etc/pam.d/common-auth && [ $force = 0 ]; then
|
|
|
|
echo "System appears already configured for sudo prompts."
|
|
|
|
echo "To force re-configuration run 'configure-sudo-prompt --force'."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2018-04-12 15:24:46 -04:00
|
|
|
echo -e "\n--+ Enable yes/no authentication prompt for sudo +--
|
|
|
|
Warning: Before opting for this change a backup or clone
|
|
|
|
should me made of this template!"
|
2019-08-27 21:13:20 -04:00
|
|
|
if [ $force = 0 ]; then
|
|
|
|
read -p "Configure sudo authentication prompt now? (y/n): " answer
|
|
|
|
fi
|
|
|
|
if [[ $answer == @(y|Y) ]] || [ $force = 1 ]; then
|
2018-04-12 15:24:46 -04:00
|
|
|
|
2019-07-18 05:23:21 -04:00
|
|
|
mv -fb /etc/pam.d/common-auth /etc/pam.d/common-auth~
|
2018-04-12 15:24:46 -04:00
|
|
|
cat >/etc/pam.d/common-auth <<_EOF
|
|
|
|
auth [success=1 default=ignore] pam_exec.so seteuid /usr/lib/qubes/qrexec-client-vm dom0 qubes.VMAuth /bin/grep -q ^1$
|
|
|
|
auth requisite pam_deny.so
|
|
|
|
auth required pam_permit.so
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
|
|
|
|
# sed -i 's/^user ALL=(ALL) NOPASSWD: ALL/user ALL=(ALL) ALL/' /etc/sudoers.d/qubes
|
|
|
|
sed -i 's/^user/#user/' /etc/sudoers.d/qubes
|
|
|
|
echo 'user ALL=(ALL) ALL' >>/etc/sudoers.d/qubes
|
|
|
|
|
|
|
|
sed -ri 's/^(auth[[:space:]]sufficient[[:space:]]pam_permit.so)/#\1/' /etc/pam.d/su
|
|
|
|
|
|
|
|
mv -f /etc/polkit-1/rules.d/00-qubes-allow-all.rules \
|
2019-07-18 05:23:21 -04:00
|
|
|
/etc/polkit-1/rulesd_00-qubes-allow-all.rules.bak || true
|
2018-04-12 15:24:46 -04:00
|
|
|
mv -f /etc/polkit-1/localauthority/50-local.d/qubes-allow-all.pkla \
|
2019-07-18 05:23:21 -04:00
|
|
|
/etc/polkit-1/localauthority_50-locald_qubes-allow-all.pkla.bak || true
|
2018-04-12 15:24:46 -04:00
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
|
|
|
|
echo '
|
|
|
|
Next.... Enable auth prompts in dom0 with the following commands:
|
|
|
|
[user@dom0 ~]$ sudo su -
|
|
|
|
[root@dom0 /]# echo "/usr/bin/echo 1" >/etc/qubes-rpc/qubes.VMAuth
|
2023-05-01 13:28:02 -04:00
|
|
|
[root@dom0 /]# chmod +x /etc/qubes-rpc/qubes.VMAuth
|
|
|
|
[root@dom0 /]# echo "@anyvm dom0 ask,default_target=dom0" \
|
2018-04-12 15:24:46 -04:00
|
|
|
>/etc/qubes-rpc/policy/qubes.VMAuth
|
|
|
|
|
|
|
|
'
|
|
|
|
fi
|