-
Notifications
You must be signed in to change notification settings - Fork 0
feat: unattended GPG signing for TUI agents #25
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
Changes from all commits
c389a9c
d33178d
643e236
d72edbf
c3911a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
| # chezmoi template: enable gpg-sign-preset systemd user service | ||
| # Trigger: {{ if (stat (joinPath .chezmoi.sourceDir "dot_config/systemd/user/gpg-sign-preset.service")) }}changed{{ end }} | ||
| set -euo pipefail | ||
|
|
||
| if command -v systemctl >/dev/null 2>&1; then | ||
| systemctl --user daemon-reload | ||
| systemctl --user enable --now gpg-sign-preset.service | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,5 @@ runtime/ | |
| .aeos/ | ||
| *.log | ||
| node_modules/* | ||
| private_* | ||
| SESSION_STATE.md | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [Unit] | ||
| Description=Preset GPG signing passphrase into gpg-agent | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=%h/.local/bin/gpg-sign-preset | ||
|
|
||
| [Install] | ||
| WantedBy=default.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pinentry-program /usr/bin/pinentry-curses | ||
|
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.
For macOS installs supported by this dotfiles repo, applying this writes a Linux-specific Useful? React with 👍 / 👎. |
||
| allow-preset-passphrase | ||
| pinentry-timeout 30 | ||
| default-cache-ttl 86400 | ||
| max-cache-ttl 34560000 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env bash | ||
| # chezmoi template: preset GPG signing passphrase into gpg-agent | ||
| set -euo pipefail | ||
|
|
||
| key="{{ .gpg_signing_key }}" | ||
| [ -n "$key" ] || exit 0 | ||
|
|
||
| gpg_preset_passphrase="" | ||
| command -v gpg-preset-passphrase >/dev/null 2>&1 && gpg_preset_passphrase="gpg-preset-passphrase" || { libexec=$(gpgconf --list-dirs libexecdir 2>/dev/null); [ -x "$libexec/gpg-preset-passphrase" ] && gpg_preset_passphrase="$libexec/gpg-preset-passphrase"; } | ||
| [ -n "$gpg_preset_passphrase" ] || exit 0 | ||
|
|
||
| command -v secret-tool >/dev/null 2>&1 || exit 0 | ||
|
|
||
| grip="$(gpg --batch --with-colons --with-keygrip -K "$key" 2>/dev/null | awk -F: -v key="$key" '$1=="fpr" && $10 ~ key{f=1; next} f && $1=="grp"{print $10; exit}')" | ||
| [ -n "$grip" ] || exit 0 | ||
|
|
||
| pass="$(secret-tool lookup service gpg-signing key "$key" 2>/dev/null)" || exit 0 | ||
| printf '%s' "$pass" | "$gpg_preset_passphrase" --preset "$grip" 2>/dev/null || true |
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.
In non-systemd user sessions such as devcontainers or headless SSH sessions where
systemctlis installed but no user manager is running, this command fails (systemctl --user daemon-reloadreturnsFailed to connect to bus: No medium foundin the current container). Because the script hasset -e,chezmoi applyaborts before completing; the binary check needs to also verify a usable user bus or tolerate this failure.Useful? React with 👍 / 👎.