-
Notifications
You must be signed in to change notification settings - Fork 167
prefer pkexec over sudo in PINCE.sh #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8cd0e47
prefer pkexec over sudo
notwithering 8a8b226
Merge branch 'master' into pkexec
notwithering b3ccc08
clean up auto-escalation
notwithering 9feb9fc
self escalate appimage in package.sh
notwithering a05a28b
Merge branch 'korcankaraokcu:master' into pkexec
notwithering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,30 @@ if [ ! -d "${SCRIPTDIR}/.venv/bin" ]; then | |
| echo "Please run \"sh install.sh\" first!" | ||
| exit 1 | ||
| fi | ||
| . ${SCRIPTDIR}/.venv/bin/activate | ||
|
|
||
| # Preserve env vars to keep settings like theme preferences. | ||
| # Debian/Ubuntu does not preserve PATH through sudo even with -E for security reasons | ||
| # so we need to force PATH preservation with venv activated user's PATH. | ||
| sudo -E --preserve-env=PATH PYTHONDONTWRITEBYTECODE=1 ${SCRIPTDIR}/.venv/bin/python3 ${SCRIPTDIR}/PINCE.py | ||
| . ${SCRIPTDIR}/.venv/PINCE/bin/activate | ||
| PYTHON="${SCRIPTDIR}/.venv/bin/python3" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You named these I'd recommend using |
||
| SCRIPT="${SCRIPTDIR}/PINCE.py" | ||
|
|
||
| export PYTHONDONTWRITEBYTECODE=1 | ||
|
|
||
| if type pkexec &> /dev/null; then | ||
| # Preserve env vars to keep settings like theme preferences. | ||
| # Pkexec does not support passing all of env via a flag like `-E` so we need to | ||
| # rebuild the env and then pass it through. | ||
| ENV=() | ||
| while IFS='=' read -r key value; do | ||
| [ -z "$key" ] && continue | ||
| value="${value//\\/\\\\}" | ||
| value="${value//\"/\\\"}" | ||
| ENV+=("$key=$value") | ||
| done < <(env) | ||
|
|
||
| pkexec env "${ENV[@]}" "$PYTHON" "$SCRIPT" | ||
| elif type sudo &> /dev/null; then | ||
| # Debian/Ubuntu does not preserve PATH through sudo even with -E for security reasons | ||
| # so we need to force PATH preservation with venv activated user's PATH. | ||
| sudo -E --preserve-env=PATH,PYTHONDONTWRITEBYTECODE "$PINCE_PYTHON" "$PINCE_PATH" | ||
| else | ||
| echo "No supported privilege escalation utility found; please rerun this script as root." | ||
| fi | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong and makes an error with
sh PINCE.sh.We don't have the PINCE folder inside venv anymore. You can just restore the old line you replaced as that one was fine.