shellcheck / shellcheck (push) Failing after 19s
Adapted from Omarchy (github.com/omacom/omarchy) for Arch with GNOME: - A pacman hook stops a full upgrade run without update (pacman -Syu, yay -Syu), which would skip the snapshot and update's checks. update and install.sh set COREDESKTOP_ALLOW_PACMAN=1, which the hook finds on pacman or any process above it; you can set it too. - When the Arch upgrade stops on files no package owns, update lists them and asks to move them to /var/lib/coredesktop/replaced and try again, putting back what the retry didn't replace. When packages conflict, it runs pacman again so you can choose. - update and install keep the computer from sleeping until they finish. - system/hardware.sh (install, and a migration): the Wi-Fi country from the time zone, thermald and intel-lpmd on Intel laptops, and Wi-Fi 6 on Intel BE200/BE211 cards, whose driver gets Wi-Fi 7 wrong. - configure security-key and configure fingerprint: touch a FIDO2 key or a finger instead of typing your password for sudo and polkit, falling back to the password. Each shows only when the hardware is there. The fingerprint skips to the password with the lid shut. - webapp: put a website in the app grid as its own app window. - Taildrop: Files' Scripts > Send with Tailscale, and a user service that saves files sent here to Downloads, started when configure tailscale joins. - A NetworkManager dispatcher script pauses a Tailscale exit node while you sign in to a captive portal, and resumes it once online. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.1 KiB
Bash
Executable File
57 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Add and remove an auth line at the top of a PAM service's stack, for signing
|
|
# in to sudo and polkit (the password prompts of GNOME's apps and settings)
|
|
# with a security key or a fingerprint. Each line is "sufficient": when the key
|
|
# or finger isn't there, it falls through to the password, as before.
|
|
|
|
# For the tests
|
|
PAM_DIR="${PAM_DIR:-/etc/pam.d}"
|
|
PAM_VENDOR_DIR="${PAM_VENDOR_DIR:-/usr/lib/pam.d}"
|
|
|
|
# The services to sign in to this way (used by the items that source this)
|
|
# shellcheck disable=SC2034
|
|
PAM_SERVICES=(sudo polkit-1)
|
|
|
|
# True if service $1's stack uses module $2 (pam_u2f.so)
|
|
pam_has() {
|
|
grep -qE "^[^#]*[[:space:]]$2([[:space:]]|$)" "$PAM_DIR/$1" 2> /dev/null
|
|
}
|
|
|
|
# Make sure service $1 has its own file in PAM_DIR. polkit's comes in
|
|
# PAM_VENDOR_DIR, and a file in PAM_DIR replaces it.
|
|
pam_own_file() {
|
|
[ -f "$PAM_DIR/$1" ] && return 0
|
|
[ -f "$PAM_VENDOR_DIR/$1" ] || { echo "There's no PAM file for $1."; return 1; }
|
|
sudo cp "$PAM_VENDOR_DIR/$1" "$PAM_DIR/$1"
|
|
}
|
|
|
|
# pam_add SERVICE MODULE LINE...: put the lines just before the first auth line
|
|
# of SERVICE's stack, unless it already uses MODULE
|
|
pam_add() {
|
|
local service="$1" module="$2" file
|
|
shift 2
|
|
file="$PAM_DIR/$service"
|
|
pam_has "$service" "$module" && return 0
|
|
pam_own_file "$service" || return 1
|
|
grep -qE '^[[:space:]]*-?auth[[:space:]]' "$file" || { echo "$file has no auth lines."; return 1; }
|
|
# awk writes the new file, then it replaces the old one in one step, so sudo
|
|
# never sees a half-written file
|
|
PAM_LINES="$(printf '%s\n' "$@")" awk '
|
|
!done && /^[[:space:]]*-?auth[[:space:]]/ { print ENVIRON["PAM_LINES"]; done = 1 }
|
|
{ print }
|
|
' "$file" | sudo tee "$file.coredesktop" > /dev/null \
|
|
&& sudo chmod 644 "$file.coredesktop" \
|
|
&& sudo mv -f "$file.coredesktop" "$file"
|
|
}
|
|
|
|
# pam_remove SERVICE PATTERN: remove the lines matching PATTERN (an extended
|
|
# regular expression) from SERVICE's stack
|
|
pam_remove() {
|
|
local file="$PAM_DIR/$1"
|
|
[ -f "$file" ] && grep -qE "$2" "$file" || return 0
|
|
grep -vE "$2" "$file" | sudo tee "$file.coredesktop" > /dev/null \
|
|
&& sudo chmod 644 "$file.coredesktop" \
|
|
&& sudo mv -f "$file.coredesktop" "$file"
|
|
}
|