From 511d6dcceb16db0ddd0b6caba9f2a1f03bb5fb60 Mon Sep 17 00:00:00 2001 From: Thomas Duckworth Date: Mon, 6 Jul 2026 03:23:18 +0000 Subject: [PATCH] Implement single-prompt auth, POSIX sh compliance Ensure users are only faced with one polkit prompt when running certain commands, and ensure they use POSIX sh function syntax, not bash, as the shebang is for /bin/sh. --- mkosi.extra/usr/bin/set-up-systemd-extension | 33 +++++++++++-------- mkosi.extra/usr/bin/toggle-developer-mode | 34 ++++++++++++-------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/mkosi.extra/usr/bin/set-up-systemd-extension b/mkosi.extra/usr/bin/set-up-systemd-extension index 32c0702..e2ef8f7 100755 --- a/mkosi.extra/usr/bin/set-up-systemd-extension +++ b/mkosi.extra/usr/bin/set-up-systemd-extension @@ -8,7 +8,7 @@ set -e SYSEXT_BASE_LOCATION="${HOME}/kde/usr/" SYSEXT_LOCATION="${SYSEXT_BASE_LOCATION}/lib/extension-release.d/" -SYSEXT_ROOT_LOCATION=/var/lib/extensions/ +SYSEXT_ROOT_LOCATION="/var/lib/extensions/" echo if [ -f "${SYSEXT_LOCATION}/extension-release.kde" ]; then @@ -18,22 +18,27 @@ else echo "Setting up extension at ${SYSEXT_BASE_LOCATION}..." # Create directory to hold this system extension - mkdir -p ${SYSEXT_LOCATION} - sudo mkdir -p ${SYSEXT_ROOT_LOCATION} - sudo ln -fs "${HOME}/kde" ${SYSEXT_ROOT_LOCATION} + mkdir -p "${SYSEXT_LOCATION}" - # Copy the system os-release file to be an extension-release file that identifies this extension - sudo cp /usr/lib/os-release "${SYSEXT_LOCATION}/extension-release.kde" + # Heredoc into run0 so we only have one auth prompt. + run0 sh < /dev/null + # Heredoc into run0 so we only have one auth prompt. + run0 sh < /dev/null - for ITEM in $PREINSTALLED_DEV_APPS; do - run0 cp "${USR_APPS_LOCATION}${ITEM}" "${OPT_APPS_LOCATION}${ITEM}" 1> /dev/null - run0 sed -i "/NoDisplay=true/d" "${OPT_APPS_LOCATION}${ITEM}" 1> /dev/null - echo "- Enabled ${ITEM}" - done +for ITEM in $PREINSTALLED_DEV_APPS; do + cp "${USR_APPS_LOCATION}\${ITEM}" "${OPT_APPS_LOCATION}\${ITEM}" 1> /dev/null + sed -i "/NoDisplay=true/d" "${OPT_APPS_LOCATION}\${ITEM}" 1> /dev/null + echo "- Enabled \${ITEM}" +done +EOF echo "Refreshing app cache…" kbuildsycoca6 @@ -33,19 +37,23 @@ function enable_dev_apps echo "files were installed in ${OPT_APPS_LOCATION}." } -function disable_dev_apps +disable_dev_apps() { echo "Hiding development apps…" - for ITEM in $PREINSTALLED_DEV_APPS; do - run0 rm "${OPT_APPS_LOCATION}${ITEM}" 1> /dev/null - done + # Heredoc into run0 so we only have one auth prompt. + run0 sh < /dev/null +done + +rmdir --ignore-fail-on-non-empty "$OPT_APPS_LOCATION" 1> /dev/null +EOF echo "Refreshing app cache…" kbuildsycoca6 - run0 rmdir --ignore-fail-on-non-empty "$OPT_APPS_LOCATION" 1> /dev/null - echo "Done; development apps are now hidden." }