aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-01-29 18:56:17 +0100
committerJakob Unterwurzacher2017-01-29 18:56:17 +0100
commitc8fb6199715316099cb9e675c447612f70e44151 (patch)
tree9c482901802c2596c862ed98e653261cdce324d3
parent1273d7edae3ce72b15dc0d18b5fcc80fd8d3ae15 (diff)
contrib: add ctlsock helper scripts
l---------contrib/ctlsock-decrypt.bash1
-rwxr-xr-xcontrib/ctlsock-encrypt.bash34
2 files changed, 35 insertions, 0 deletions
diff --git a/contrib/ctlsock-decrypt.bash b/contrib/ctlsock-decrypt.bash
new file mode 120000
index 0000000..b95ace8
--- /dev/null
+++ b/contrib/ctlsock-decrypt.bash
@@ -0,0 +1 @@
+ctlsock-encrypt.bash \ No newline at end of file
diff --git a/contrib/ctlsock-encrypt.bash b/contrib/ctlsock-encrypt.bash
new file mode 100755
index 0000000..60a88e7
--- /dev/null
+++ b/contrib/ctlsock-encrypt.bash
@@ -0,0 +1,34 @@
+#!/bin/bash -eu
+#
+# Interactively encrypt file names and paths by querying a gocryptfs
+# control socket.
+#
+# Dependencies:
+# Debian: apt-get install jq netcat-openbsd
+# Fedora: dnf install jq nmap-ncat
+MYNAME=$(basename $0)
+if [[ $# -ne 1 || $1 == "-h" ]] ; then
+ echo "Usage: $MYNAME SOCKET"
+ exit 1
+fi
+SOCK=$1
+# Bail out early (before even prompting the user) if the socket does
+# not exist
+if [[ ! -S $SOCK ]] ; then
+ echo "'$SOCK' is not a socket" >&2
+ exit 1
+fi
+OPERATION=EncryptPath
+if [[ $MYNAME == "ctlsock-decrypt.bash" ]] ; then
+ OPERATION=DecryptPath
+fi
+while true ; do
+ echo -n "Input path : "
+ read IN
+ echo -n "Transformed path: "
+ JSON=$(echo "{\"$OPERATION\":\"$IN\"}" | nc -U $SOCK)
+ ENCRYPTED=$(echo $JSON | jq -r '.Result')
+ echo $ENCRYPTED
+ echo "Complete reply : $JSON"
+ echo
+done