Last active
September 5, 2021 01:45
-
-
Save HikariKnight/701e3bb1a10a97a8fefdebf3c4067ecf to your computer and use it in GitHub Desktop.
A "pkexec" replacement for use in wsl2 until microsoft fixes policykit in wsl2 (DO NOT USE FOR PRODUCTION)
This file contains hidden or 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
#!/bin/bash | |
# Dependencies: zenity | |
# | |
# Installation: download the file, name it "pkexec" and make it executable, then put it in /usr/local/bin | |
# This should in theory auto "fix" programs like synaptic which launches using pkexec from its desktop file. | |
# | |
# THIS SCRIPT IS NOT A PROPER REPLACEMENT, SENDING THE PASSWORD THROUGH SUDOS STDIN IS NOT SECURE! | |
# THIS IS MEANT AS A TEMPORARY WORKAROUND, DO NOT USE IN PRODUCTION! | |
exec sudo -HSkp '' -- $@ <<<$(zenity --password --title=Authentication) 2>/dev/null | |
# Explaination of the parameters | |
# -HSkp '' = * (H) use roots home folder (avoids breaking your home folder) | |
# * (S) accept password from stdin | |
# * (k) invalidate previous sudo timestamp, forcing requiring password | |
# * (p '') blank out the password prompt (as you will not be interacting with this) | |
# | |
# -- = end of sudo parameters | |
# | |
# $@ = all parameters passed to "pkexec" | |
# | |
# <<<$(zenity --password --title=Authentication) = get the output from the zenity dialog and give it to the sudo STDIN | |
# | |
# 2>/dev/null = send all output to the void |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment