Sign in to sudo and polkit with a security key or fingerprint
Ports configure security-key and configure fingerprint from CoreDesktop's 9dc5eb1: 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. lib/pam.sh is CoreDesktop's, but also takes Ubuntu's "@include common-auth" as the start of a stack's auth part, which is how sudo's and polkit's begin. Only those two stacks change, not common-auth, which pam-auth-update owns and every sign-in includes. libpam-fprintd's pam-auth-update profile is off by default, so installing it changes no sign-in by itself. The login and lock screens keep asking for the password, unlike on GNOME. Smoketest: 70-sign-in, on copies of Ubuntu's sudo and polkit stacks. TEST.md: with a real key and reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,9 +54,8 @@ Since `4a4a3bd`, to look at:
|
|||||||
`53c6c8b` (the install path). Hiding the connector's settings from
|
`53c6c8b` (the install path). Hiding the connector's settings from
|
||||||
agents is done.
|
agents is done.
|
||||||
- [ ] `9dc5eb1` Upgrade safeguards, hardware setup, sign-in options and Taildrop.
|
- [ ] `9dc5eb1` Upgrade safeguards, hardware setup, sign-in options and Taildrop.
|
||||||
To port: `configure security-key` and `configure fingerprint` (through
|
Sign-in options (security key, fingerprint) are done.
|
||||||
`pam-auth-update` and fprintd on Pop!_OS, not by editing PAM files),
|
To port: Taildrop's service that saves files sent here to Downloads (COSMIC Files
|
||||||
Taildrop's service that saves files sent here to Downloads (COSMIC Files
|
|
||||||
has no Scripts menu for sending), keeping the computer awake during
|
has no Scripts menu for sending), keeping the computer awake during
|
||||||
`update`, and the captive portal script that pauses a Tailscale exit
|
`update`, and the captive portal script that pauses a Tailscale exit
|
||||||
node. Arch only: the pacman guard, unowned files, `hardware.sh`
|
node. Arch only: the pacman guard, unowned files, `hardware.sh`
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ Each item installs what it needs the first time you set it up, after asking.
|
|||||||
- An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden SSH agent or your keyring's, so the server has to accept one of them (it can't ask for a password).
|
- An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden SSH agent or your keyring's, so the server has to accept one of them (it can't ask for a password).
|
||||||
- "Remove one" unmounts it and takes it back out.
|
- "Remove one" unmounts it and takes it back out.
|
||||||
- **Agent sandbox**, if WinBoat is set up: the sandbox hides WinBoat's settings (~/.winboat) from agents, since they include your Windows password. To let agents read them, run `configure sandbox` and switch it; switch it again to hide them.
|
- **Agent sandbox**, if WinBoat is set up: the sandbox hides WinBoat's settings (~/.winboat) from agents, since they include your Windows password. To let agents read them, run `configure sandbox` and switch it; switch it again to hide them.
|
||||||
|
- **Security key**, if one is plugged in: a FIDO2 key (YubiKey, Nitrokey, SoloKey, ...) to touch instead of typing your password for sudo and the password prompts of COSMIC's apps and settings (polkit). Without the key, they ask for your password as before. It installs `libpam-u2f`, `pamu2fcfg` and `fido2-tools`. Run it again to add a spare key, or to stop using keys.
|
||||||
|
- **Fingerprint**, if this computer has a fingerprint reader: the same, with your fingerprint. It installs `fprintd` and enrolls your right index finger, unless you've enrolled one already. With the laptop's lid shut, it goes straight to your password. The login and lock screens still ask for your password. Run it again to stop.
|
||||||
|
|
||||||
|
Both add a line at the top of `/etc/pam.d/sudo` and `/etc/pam.d/polkit-1` (a copy of `/usr/lib/pam.d/polkit-1`), not to `common-auth`, which every sign-in uses. `/etc/pam.d/sudo` is a file the `sudo-common` package owns, so if an update to it changes the file, apt keeps yours or asks. Security keys are in `/etc/u2f_mappings`, and the lid check is `/usr/local/lib/federated-connector/lid-closed`.
|
||||||
|
|
||||||
### When your Core password changes
|
### When your Core password changes
|
||||||
|
|
||||||
@@ -161,6 +165,8 @@ Each file in `configure.d/` is one item. It sets `TITLE` and `DESCRIPTION` and d
|
|||||||
- `sidebar.sh` and `cosmic-favorites`: the Files sidebar
|
- `sidebar.sh` and `cosmic-favorites`: the Files sidebar
|
||||||
- `json.sh`: editing JSON settings files
|
- `json.sh`: editing JSON settings files
|
||||||
- `mdns.sh`: finding things on the network with Avahi
|
- `mdns.sh`: finding things on the network with Avahi
|
||||||
|
- `tailnet.sh`: finding the computers on the Core's Tailscale network
|
||||||
|
- `pam.sh`: adding sign-in methods to sudo and polkit
|
||||||
- `agents.sh`: the agents' real commands and srt
|
- `agents.sh`: the agents' real commands and srt
|
||||||
- `tools.sh`: Node.js and srt
|
- `tools.sh`: Node.js and srt
|
||||||
|
|
||||||
@@ -178,4 +184,5 @@ Each file in `configure.d/` is one item. It sets `TITLE` and `DESCRIPTION` and d
|
|||||||
- davfs2 mounts need Ubuntu's setuid `mount.davfs` and the `davfs2` group, where Arch uses the `network` group.
|
- davfs2 mounts need Ubuntu's setuid `mount.davfs` and the `davfs2` group, where Arch uses the `network` group.
|
||||||
- Languages come from mise's apt repository, and nothing is installed with it up front. CoreDesktop's `update` upgrades them; here, run `mise upgrade`.
|
- Languages come from mise's apt repository, and nothing is installed with it up front. CoreDesktop's `update` upgrades them; here, run `mise upgrade`.
|
||||||
- The agents are installed by `configure agents`, and srt runs on its own Node.js. On Ubuntu, bubblewrap may need an AppArmor profile.
|
- The agents are installed by `configure agents`, and srt runs on its own Node.js. On Ubuntu, bubblewrap may need an AppArmor profile.
|
||||||
|
- A fingerprint works for sudo and polkit, but not the login and lock screens: COSMIC's greeter signs in through `common-auth`, which this leaves alone. CoreDesktop's works on GNOME's login and lock screens too.
|
||||||
- `update` updates only Federated Connector; Pop!_OS updates the rest.
|
- `update` updates only Federated Connector; Pop!_OS updates the rest.
|
||||||
|
|||||||
@@ -89,6 +89,16 @@ Once it's packaged for Pop!_OS (see [PLAN.md](PLAN.md)):
|
|||||||
- [ ] A network printer found by `configure printers` prints a test page from
|
- [ ] A network printer found by `configure printers` prints a test page from
|
||||||
a GTK app's print dialog
|
a GTK app's print dialog
|
||||||
|
|
||||||
|
### Security key and fingerprint
|
||||||
|
|
||||||
|
- [ ] With a FIDO2 key plugged in, `configure security-key` registers it;
|
||||||
|
`sudo true` in a new terminal asks for a touch, and without the key, the
|
||||||
|
password. A COSMIC Settings password prompt does the same.
|
||||||
|
- [ ] On a laptop with a reader, `configure fingerprint` enrolls a finger and
|
||||||
|
`sudo true` takes it; with the lid shut (on an external display), it asks
|
||||||
|
for the password straight away
|
||||||
|
- [ ] Running each again and stopping puts `/etc/pam.d/sudo` back as it was
|
||||||
|
|
||||||
### AI agents and the sandbox
|
### AI agents and the sandbox
|
||||||
|
|
||||||
- [ ] Each agent installs and signs in, and runs in the sandbox
|
- [ ] Each agent installs and signs in, and runs in the sandbox
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# configure reads TITLE and DESCRIPTION
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
TITLE="Security key"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DESCRIPTION="Touch a security key instead of typing your password for sudo"
|
||||||
|
|
||||||
|
source "$CONNECTOR/configure.d/lib/pam.sh"
|
||||||
|
|
||||||
|
# Root's, so nothing running as you can add a key of its own. One line per
|
||||||
|
# user: user:key:key...
|
||||||
|
U2F_MAPPINGS="${U2F_MAPPINGS:-/etc/u2f_mappings}"
|
||||||
|
# pam_u2f checks keys against the computer's name unless told otherwise, so
|
||||||
|
# renaming the computer would lock every key out. Use a name that stays.
|
||||||
|
U2F_ORIGIN="pam://federated-connector"
|
||||||
|
U2F_LINE="auth sufficient pam_u2f.so cue origin=$U2F_ORIGIN appid=$U2F_ORIGIN authfile=$U2F_MAPPINGS"
|
||||||
|
# pam_u2f, pamu2fcfg to register a key, and fido2-token to find one
|
||||||
|
U2F_PACKAGES=(libpam-u2f pamu2fcfg fido2-tools)
|
||||||
|
# For the tests
|
||||||
|
HIDRAW="${HIDRAW:-/sys/class/hidraw}"
|
||||||
|
|
||||||
|
# A FIDO2 key is a USB HID device whose report descriptor starts its usage page
|
||||||
|
# 0xF1D0 (bytes 06 d0 f1), which is how libfido2 finds them too
|
||||||
|
key_plugged_in() {
|
||||||
|
local descriptor
|
||||||
|
for descriptor in "$HIDRAW"/*/device/report_descriptor; do
|
||||||
|
[ -r "$descriptor" ] || continue
|
||||||
|
od -An -tx1 -v "$descriptor" | tr -d ' \n' | grep -q '06d0f1' && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
key_registered() {
|
||||||
|
grep -q "^$USER:" "$U2F_MAPPINGS" 2> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shown when a key is plugged in, or one is set up already
|
||||||
|
is_installed() {
|
||||||
|
key_registered || pam_has sudo pam_u2f.so || key_plugged_in
|
||||||
|
}
|
||||||
|
|
||||||
|
is_configured() {
|
||||||
|
key_registered && pam_has sudo pam_u2f.so
|
||||||
|
}
|
||||||
|
|
||||||
|
register_key() {
|
||||||
|
local credential
|
||||||
|
pkg_ensure "Security keys" "${U2F_PACKAGES[@]}" || return 1
|
||||||
|
if [ -z "$(fido2-token -L 2> /dev/null)" ]; then
|
||||||
|
echo "No security key found. Plug it in (and unlock it, if it needs that), then run: configure security-key"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "Touch your security key when it blinks (enter its PIN first if it asks)."
|
||||||
|
credential="$(pamu2fcfg -n -o "$U2F_ORIGIN" -i "$U2F_ORIGIN")" || { echo "The key wasn't registered."; return 1; }
|
||||||
|
credential="${credential#:}"
|
||||||
|
[ -n "$credential" ] || { echo "The key wasn't registered."; return 1; }
|
||||||
|
|
||||||
|
if key_registered; then
|
||||||
|
sudo sed -i "s|^$USER:.*|&:$credential|" "$U2F_MAPPINGS" || return 1
|
||||||
|
else
|
||||||
|
echo "$USER:$credential" | sudo tee -a "$U2F_MAPPINGS" > /dev/null || return 1
|
||||||
|
fi
|
||||||
|
sudo chmod 644 "$U2F_MAPPINGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
use_keys() {
|
||||||
|
local service
|
||||||
|
for service in "${PAM_SERVICES[@]}"; do
|
||||||
|
pam_add "$service" pam_u2f.so "$U2F_LINE" || return 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_using_keys() {
|
||||||
|
local service
|
||||||
|
for service in "${PAM_SERVICES[@]}"; do
|
||||||
|
pam_remove "$service" '[[:space:]]pam_u2f\.so([[:space:]]|$)' || return 1
|
||||||
|
done
|
||||||
|
if [ -f "$U2F_MAPPINGS" ]; then
|
||||||
|
sudo sed -i "/^$USER:/d" "$U2F_MAPPINGS" || return 1
|
||||||
|
fi
|
||||||
|
echo "sudo and the password prompts ask for your password only."
|
||||||
|
}
|
||||||
|
|
||||||
|
run_configure() {
|
||||||
|
local choice
|
||||||
|
if is_configured; then
|
||||||
|
echo "sudo and the password prompts take a touch of your security key."
|
||||||
|
echo
|
||||||
|
echo " 1) Add another key"
|
||||||
|
echo " 2) Stop using security keys"
|
||||||
|
echo " q) Leave it as it is"
|
||||||
|
echo
|
||||||
|
read -rp "Choose: " choice
|
||||||
|
case "$choice" in
|
||||||
|
1) ;;
|
||||||
|
2) stop_using_keys; return ;;
|
||||||
|
*) return 0 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
register_key || return 1
|
||||||
|
use_keys || return 1
|
||||||
|
echo "Done. sudo and the password prompts now ask you to touch your key. Without it,"
|
||||||
|
echo "they ask for your password, as before. To add a spare key: configure security-key"
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# configure reads TITLE and DESCRIPTION
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
TITLE="Fingerprint"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DESCRIPTION="Use your fingerprint instead of typing your password for sudo"
|
||||||
|
|
||||||
|
source "$CONNECTOR/configure.d/lib/pam.sh"
|
||||||
|
|
||||||
|
# With the lid shut the reader can't be touched, and sudo would wait for it to
|
||||||
|
# time out. This skips the fingerprint then, straight to the password.
|
||||||
|
LID_CLOSED="${LID_CLOSED:-/usr/local/lib/federated-connector/lid-closed}"
|
||||||
|
FPRINT_LINES=(
|
||||||
|
"auth [success=1 default=ignore] pam_exec.so quiet $LID_CLOSED"
|
||||||
|
"auth sufficient pam_fprintd.so"
|
||||||
|
)
|
||||||
|
# fprintd and its PAM module. The module's pam-auth-update profile is off
|
||||||
|
# unless you turn it on, so installing it changes no sign-in by itself.
|
||||||
|
FPRINT_PACKAGES=(fprintd libpam-fprintd)
|
||||||
|
# For the tests
|
||||||
|
USB_DEVICES="${USB_DEVICES:-/sys/bus/usb/devices}"
|
||||||
|
|
||||||
|
# Vendors whose USB devices are fingerprint readers (Goodix, Validity,
|
||||||
|
# Synaptics, AuthenTec, Upek, LighTuning), adapted from Omarchy. Elan and FPC
|
||||||
|
# readers name themselves instead.
|
||||||
|
FPRINT_VENDORS=" 27c6 138a 06cb 08ff 1c7a 147e "
|
||||||
|
|
||||||
|
# libfprint drives a reader from userspace, so no kernel driver claims it. The
|
||||||
|
# same vendors' touchpads and cameras have one (usbfs is libusb's own).
|
||||||
|
has_kernel_driver() {
|
||||||
|
local interface driver
|
||||||
|
for interface in "$1"/*:*; do
|
||||||
|
[ -e "$interface/driver" ] || continue
|
||||||
|
driver="$(readlink -f "$interface/driver")"
|
||||||
|
[ "${driver##*/}" = usbfs ] || return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
reader_present() {
|
||||||
|
local device product vendor
|
||||||
|
for device in "$USB_DEVICES"/*; do
|
||||||
|
if [ -r "$device/product" ]; then
|
||||||
|
product="$(< "$device/product")"
|
||||||
|
product="${product,,}"
|
||||||
|
[[ "$product" == *fingerprint* || "$product" == *biometric* \
|
||||||
|
|| "$product" == *elan:arm-m4* || "$product" == "fpc "* ]] && return 0
|
||||||
|
fi
|
||||||
|
if [ -r "$device/idVendor" ]; then
|
||||||
|
vendor="$(< "$device/idVendor")"
|
||||||
|
[[ "$FPRINT_VENDORS" == *" $vendor "* ]] && ! has_kernel_driver "$device" && return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fingers_enrolled() {
|
||||||
|
fprintd-list "$USER" 2> /dev/null | grep -qE '^[[:space:]]*- #[0-9]+:'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shown on computers with a reader
|
||||||
|
is_installed() {
|
||||||
|
pam_has sudo pam_fprintd.so || reader_present
|
||||||
|
}
|
||||||
|
|
||||||
|
is_configured() {
|
||||||
|
pam_has sudo pam_fprintd.so && fingers_enrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
install_lid_check() {
|
||||||
|
sudo install -d -m 755 "$(dirname "$LID_CLOSED")" || return 1
|
||||||
|
sudo tee "$LID_CLOSED" > /dev/null << 'EOF' || return 1
|
||||||
|
#!/bin/sh
|
||||||
|
# Federated Connector: true when the laptop's lid is shut, so PAM skips the
|
||||||
|
# fingerprint reader, which can't be touched then (configure fingerprint)
|
||||||
|
for state in /proc/acpi/button/lid/*/state; do
|
||||||
|
grep -q closed "$state" 2> /dev/null && exit 0
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
sudo chmod 755 "$LID_CLOSED"
|
||||||
|
}
|
||||||
|
|
||||||
|
use_fingerprint() {
|
||||||
|
local service
|
||||||
|
install_lid_check || return 1
|
||||||
|
for service in "${PAM_SERVICES[@]}"; do
|
||||||
|
pam_add "$service" pam_fprintd.so "${FPRINT_LINES[@]}" || return 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_using_fingerprint() {
|
||||||
|
local service
|
||||||
|
for service in "${PAM_SERVICES[@]}"; do
|
||||||
|
pam_remove "$service" "[[:space:]](pam_fprintd\.so|${LID_CLOSED//./\\.})([[:space:]]|$)" || return 1
|
||||||
|
done
|
||||||
|
echo "sudo and the password prompts ask for your password only. Your enrolled fingers"
|
||||||
|
echo "stay in fprintd; to delete them: fprintd-delete $USER"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_configure() {
|
||||||
|
local choice
|
||||||
|
if is_configured; then
|
||||||
|
echo "sudo and the password prompts take your fingerprint. To add a finger:"
|
||||||
|
echo "fprintd-enroll -f left-index-finger (or another), and to list them: fprintd-list $USER"
|
||||||
|
echo
|
||||||
|
echo " 1) Stop using your fingerprint for sudo and the password prompts"
|
||||||
|
echo " q) Leave it as it is"
|
||||||
|
echo
|
||||||
|
read -rp "Choose: " choice
|
||||||
|
[ "$choice" = 1 ] && stop_using_fingerprint
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
pkg_ensure "Fingerprints" "${FPRINT_PACKAGES[@]}" || return 1
|
||||||
|
# Enrolled already, e.g. with fprintd-enroll
|
||||||
|
if ! fingers_enrolled; then
|
||||||
|
echo "Touch the fingerprint reader with your right index finger, again and again until"
|
||||||
|
echo "it says it's done."
|
||||||
|
fprintd-enroll "$USER" || { echo "Your finger wasn't enrolled."; return 1; }
|
||||||
|
fi
|
||||||
|
use_fingerprint || return 1
|
||||||
|
echo "Done. sudo and the password prompts take your fingerprint, and your password as"
|
||||||
|
echo "before. The login and lock screens still ask for your password."
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#!/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 COSMIC'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.
|
||||||
|
#
|
||||||
|
# Only these two services change, not common-auth, which pam-auth-update owns
|
||||||
|
# and every service (the login screen, su, sshd) includes.
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
# The first line of a stack's auth part: an auth line, or Ubuntu's
|
||||||
|
# "@include common-auth", which is how sudo's and polkit's start
|
||||||
|
PAM_AUTH_START='^[[:space:]]*(-?auth[[:space:]]|@include[[:space:]]+common-auth([[:space:]]|$))'
|
||||||
|
|
||||||
|
# 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 "$PAM_AUTH_START" "$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 -v start="$PAM_AUTH_START" '
|
||||||
|
!done && $0 ~ start { print ENVIRON["PAM_LINES"]; done = 1 }
|
||||||
|
{ print }
|
||||||
|
' "$file" | sudo tee "$file.federated-connector" > /dev/null \
|
||||||
|
&& sudo chmod 644 "$file.federated-connector" \
|
||||||
|
&& sudo mv -f "$file.federated-connector" "$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.federated-connector" > /dev/null \
|
||||||
|
&& sudo chmod 644 "$file.federated-connector" \
|
||||||
|
&& sudo mv -f "$file.federated-connector" "$file"
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ Each run writes its logs to `smoketest/results/<time>/`, one per scenario, and p
|
|||||||
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
|
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
|
||||||
| `55-hermes-homeserver` | Hermes' gateway reaches only a Matrix server you've allowed: a server in Hermes' settings is to do until `configure hermes` allows it, a wildcard or escape codes never count, and `configure agents` carries over the server an old drop-in allowed. `edit_json` fills an empty file from its default. |
|
| `55-hermes-homeserver` | Hermes' gateway reaches only a Matrix server you've allowed: a server in Hermes' settings is to do until `configure hermes` allows it, a wildcard or escape codes never count, and `configure agents` carries over the server an old drop-in allowed. `edit_json` fills an empty file from its default. |
|
||||||
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
|
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
|
||||||
|
| `70-sign-in` | `configure security-key` and `configure fingerprint` on copies of Ubuntu's sudo and polkit stacks, which start with `@include common-auth`: the line goes just before it, polkit gets its own copy and the vendor's is left alone, adding twice adds once, and stopping puts sudo back as it was. A FIDO2 key is found by its HID descriptor, a reader by its vendor (unless a driver claims it, like a touchpad) or its name. |
|
||||||
|
|
||||||
## What still needs Pop!_OS
|
## What still needs Pop!_OS
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# Scenarios set what the runner and items read
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DESCRIPTION="Security key and fingerprint: PAM lines for sudo and polkit, and finding the hardware"
|
||||||
|
TIER=quick
|
||||||
|
|
||||||
|
scenario() {
|
||||||
|
local sudo_before polkit_before
|
||||||
|
# Everything here is in $HOME, so nothing needs root
|
||||||
|
sudo() { "$@"; }
|
||||||
|
# Copies of Ubuntu's sudo and polkit stacks, which start with @include
|
||||||
|
export PAM_DIR="$HOME/pam.d" PAM_VENDOR_DIR="$HOME/lib-pam.d"
|
||||||
|
mkdir -p "$PAM_DIR" "$PAM_VENDOR_DIR"
|
||||||
|
cat > "$PAM_DIR/sudo" << 'EOF'
|
||||||
|
#%PAM-1.0
|
||||||
|
|
||||||
|
# Set up user limits from /etc/security/limits.conf.
|
||||||
|
session required pam_limits.so
|
||||||
|
|
||||||
|
session required pam_env.so readenv=1 user_readenv=0
|
||||||
|
session required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
|
||||||
|
|
||||||
|
@include common-auth
|
||||||
|
@include common-account
|
||||||
|
@include common-session-noninteractive
|
||||||
|
EOF
|
||||||
|
cat > "$PAM_VENDOR_DIR/polkit-1" << 'EOF'
|
||||||
|
#%PAM-1.0
|
||||||
|
|
||||||
|
@include common-auth
|
||||||
|
@include common-account
|
||||||
|
@include common-password
|
||||||
|
session required pam_env.so readenv=1 user_readenv=0
|
||||||
|
@include common-session-noninteractive
|
||||||
|
EOF
|
||||||
|
sudo_before="$(cat "$PAM_DIR/sudo")"
|
||||||
|
polkit_before="$(cat "$PAM_VENDOR_DIR/polkit-1")"
|
||||||
|
|
||||||
|
step "Security key"
|
||||||
|
export U2F_MAPPINGS="$HOME/u2f_mappings" HIDRAW="$HOME/hidraw"
|
||||||
|
source "$CONNECTOR/configure.d/70-security-key.sh"
|
||||||
|
check_not "not shown without a key" is_installed
|
||||||
|
mkdir -p "$HIDRAW/hidraw0/device" "$HIDRAW/hidraw1/device"
|
||||||
|
printf '\x05\x01\x09\x06' > "$HIDRAW/hidraw0/device/report_descriptor"
|
||||||
|
check_not "a keyboard isn't a key" key_plugged_in
|
||||||
|
printf '\x06\xd0\xf1\x09\x01' > "$HIDRAW/hidraw1/device/report_descriptor"
|
||||||
|
check "a FIDO2 key is" key_plugged_in
|
||||||
|
check "shown with one plugged in" is_installed
|
||||||
|
|
||||||
|
check "use_keys" use_keys
|
||||||
|
check "sudo takes the key" pam_has sudo pam_u2f.so
|
||||||
|
check_eq "just before common-auth" "@include common-auth" \
|
||||||
|
"$(grep -A1 pam_u2f.so "$PAM_DIR/sudo" | tail -n 1)"
|
||||||
|
check "polkit gets its own copy, which takes the key" pam_has polkit-1 pam_u2f.so
|
||||||
|
check_eq "the vendor's copy is left alone" "$polkit_before" "$(cat "$PAM_VENDOR_DIR/polkit-1")"
|
||||||
|
check_not "not done without a registered key" is_configured
|
||||||
|
echo "$USER:credential" > "$U2F_MAPPINGS"
|
||||||
|
check "done with one" is_configured
|
||||||
|
use_keys
|
||||||
|
check_eq "use_keys again adds nothing" 1 "$(grep -c pam_u2f.so "$PAM_DIR/sudo")"
|
||||||
|
stop_using_keys > /dev/null
|
||||||
|
check_eq "stop_using_keys puts sudo back as it was" "$sudo_before" "$(cat "$PAM_DIR/sudo")"
|
||||||
|
check_not "and polkit" pam_has polkit-1 pam_u2f.so
|
||||||
|
check_not "and forgets your keys" key_registered
|
||||||
|
|
||||||
|
step "Fingerprint"
|
||||||
|
export USB_DEVICES="$HOME/usb" LID_CLOSED="$HOME/lid-closed"
|
||||||
|
source "$CONNECTOR/configure.d/71-fingerprint.sh"
|
||||||
|
mkdir -p "$USB_DEVICES/1-1" "$USB_DEVICES/1-2/1-2:1.0" "$HOME/drivers/usbhid"
|
||||||
|
echo "USB Keyboard" > "$USB_DEVICES/1-1/product"
|
||||||
|
# A Synaptics touchpad: the vendor makes readers too, but a driver claims it
|
||||||
|
echo 06cb > "$USB_DEVICES/1-2/idVendor"
|
||||||
|
ln -s "$HOME/drivers/usbhid" "$USB_DEVICES/1-2/1-2:1.0/driver"
|
||||||
|
check_not "not shown without a reader" is_installed
|
||||||
|
mkdir -p "$USB_DEVICES/1-3"
|
||||||
|
echo 27c6 > "$USB_DEVICES/1-3/idVendor"
|
||||||
|
check "a Goodix reader, which no driver claims, is found" reader_present
|
||||||
|
rm -rf "$USB_DEVICES/1-3"
|
||||||
|
mkdir -p "$USB_DEVICES/1-4"
|
||||||
|
echo "ELAN:ARM-M4" > "$USB_DEVICES/1-4/product"
|
||||||
|
check "and an Elan one, by its name" reader_present
|
||||||
|
|
||||||
|
check "use_fingerprint" use_fingerprint
|
||||||
|
check "the lid check is installed" test -x "$LID_CLOSED"
|
||||||
|
check_eq "it skips the reader when the lid check succeeds" \
|
||||||
|
"auth [success=1 default=ignore] pam_exec.so quiet $LID_CLOSED" \
|
||||||
|
"$(grep -B1 pam_fprintd.so "$PAM_DIR/sudo" | head -n 1)"
|
||||||
|
check "polkit takes it" pam_has polkit-1 pam_fprintd.so
|
||||||
|
stop_using_fingerprint > /dev/null
|
||||||
|
check_eq "stop_using_fingerprint puts sudo back as it was" "$sudo_before" "$(cat "$PAM_DIR/sudo")"
|
||||||
|
check_not "and polkit" grep -q "pam_fprintd\|lid-closed" "$PAM_DIR/polkit-1"
|
||||||
|
|
||||||
|
rm -rf "$PAM_DIR" "$PAM_VENDOR_DIR" "$HIDRAW" "$USB_DEVICES" "$HOME/drivers" "$U2F_MAPPINGS" "$LID_CLOSED"
|
||||||
|
unset PAM_DIR PAM_VENDOR_DIR U2F_MAPPINGS HIDRAW USB_DEVICES LID_CLOSED
|
||||||
|
unset -f sudo
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user