aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-08-16 01:52:17 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-08-16 02:09:13 +1200
commit6cadd05d39ab05e8aaa7fd1b2f91a6b8c80f9f14 (patch)
tree1955e1cbcfb80701470c734d4f8467bee1b97b18
downloadparcimini-6cadd05d39ab05e8aaa7fd1b2f91a6b8c80f9f14.tar.gz
parcimini-6cadd05d39ab05e8aaa7fd1b2f91a6b8c80f9f14.zip
First versionv0.1.0
-rw-r--r--.gitignore1
-rw-r--r--LICENSE7
-rw-r--r--Makefile17
-rw-r--r--README.md17
-rw-r--r--VERSION1
-rw-r--r--parcimini.bash48
-rw-r--r--parcimini.service8
7 files changed, 99 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5a6b807
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/parcimini
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8606667
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright 2019 Tom Ryder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b8144fe
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+.POSIX:
+.PHONY: all install clean
+.SUFFIXES:
+.SUFFIXES: .bash
+PREFIX = /usr/local
+BASH = /bin/bash
+ALL = parcimini
+.bash:
+ $(BASH) -c :
+ awk -v bash=$(BASH) 'NR == 1 { print "#!" bash } 1' $< > $@
+ chmod +x ./$@
+all: $(ALL)
+install: $(ALL)
+ mkdir -p -- $(PREFIX)/bin
+ cp -- parcimini $(PREFIX)/bin
+clean:
+ rm -f -- $(ALL)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..cc1601b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+Parcimini
+=========
+
+Refresh GnuPG keyring slowly, in random order, with random waits between each
+refresh, looping indefinitely. Intended as an incompatible alternative for
+[parcimonie](https://github.com/EtiennePerot/parcimonie.sh).
+
+You will almost certainly want `use-tor` in your `dirmngr.conf` for this to be
+useful at all.
+
+License
+-------
+
+Copyright (c) [Tom Ryder][1]. Distributed under an [MIT License][2].
+
+[1]: https://sanctum.geek.nz/
+[2]: https://www.opensource.org/licenses/MIT
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..6e8bf73
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1.0
diff --git a/parcimini.bash b/parcimini.bash
new file mode 100644
index 0000000..11c7207
--- /dev/null
+++ b/parcimini.bash
@@ -0,0 +1,48 @@
+self=parcimini
+
+# Base interval between key retrievals from first arg; default 20 mins
+interval=${1:-1200}
+
+# Check we have gpg2 and shuf, neither of which are POSIX
+hash gpg2 || exit
+hash shuf || exit
+
+# Make a temporary file for the key listings, delete on exit
+trap 'rm -f "$list"' EXIT
+list=$(mktemp) || exit
+
+# Define a function to retrieve all keychain fingerprints
+key_ids() {
+ gpg2 --batch --no-tty --list-keys --with-colons |
+ awk 'BEGIN { FS = ":" }
+$1 == "pub" { pub = 1 ; next }
+$1 == "fpr" && pub { pub = 0 ; key_ids[$(NF-1)]++ }
+END { for (key_id in key_ids) print key_id }'
+}
+
+# Log process start
+printf >&2 '%s: Started; base interval %u seconds.\n' \
+ "$self" "$interval"
+
+# While we're able to write the key list to the file, refresh all of them
+while key_ids > "$list" ; do
+ printf >&2 '%s: Beginning new round; %u key IDs found.\n' \
+ "$self" "$(sed '$=;d' "$list")"
+
+ # Shuffle list and read each ID
+ shuf "$list" |
+ while read -r key_id ; do
+
+ # Sleep for a random interval
+ spell=$((RANDOM % interval + 1))
+ printf >&2 '%s: Sleeping for %u seconds...\n' \
+ "$self" "$spell"
+ sleep "$spell"
+
+ # Retrieve key
+ printf >&2 '%s: Retrieving key %s...\n' \
+ "$self" "$key_id"
+ gpg2 --batch --no-tty --recv-key "$key_id"
+
+ done
+done
diff --git a/parcimini.service b/parcimini.service
new file mode 100644
index 0000000..3de1530
--- /dev/null
+++ b/parcimini.service
@@ -0,0 +1,8 @@
+[Service]
+ExecStart=/usr/local/bin/parcimini
+Restart=always
+PrivateTmp=true
+NoNewPrivileges=true
+
+[Install]
+WantedBy=default.target