summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-08-19 10:14:43 +0200
committerErich Eckner <git@eckner.net>2016-08-19 10:14:43 +0200
commit2fdaecf3451e3f2a64e71092ccb57aae936340d5 (patch)
tree7144e09caf6cd1e66ef0039a35be666466671a5d
downloadpasswort-tresor-2fdaecf3451e3f2a64e71092ccb57aae936340d5.tar.xz
Initial commit
-rw-r--r--.gitignore4
-rw-r--r--Makefile53
-rw-r--r--encedit.1.in53
-rwxr-xr-xencedit.in52
-rw-r--r--greppw.1.in53
-rwxr-xr-xgreppw.in29
6 files changed, 244 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..588bed4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+encedit
+encedit.1
+greppw
+greppw.1
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..004ce0c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,53 @@
+#
+# passwort-tresor - wrapper for gpg to store passwords (and other text)
+#
+# Copyright (c) 2016 Erich Eckner <opensource at eckner dot net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
+#
+
+DESTDIR =
+ETCDIR = /etc
+BINDIR = /usr/bin
+MANDIR = /usr/share/man
+
+VERSION = 0.0
+
+all: encedit encedit.1 greppw greppw.1
+
+%: %.in
+ sed "s/#VERSION#/$(VERSION)/; s@#BINDIR#@$(BINDIR)@; s@#ETCDIR#@$(ETCDIR)@" $< > $@
+
+.PHONY: install dist clean
+
+install: all
+ install -D -m0755 encedit $(DESTDIR)$(BINDIR)/encedit
+ install -D -m0644 encedit.1 $(DESTDIR)$(MANDIR)/man1/encedit.1
+ install -D -m0755 greppw $(DESTDIR)$(BINDIR)/greppw
+ install -D -m0644 greppw.1 $(DESTDIR)$(MANDIR)/man1/greppw.1
+ install -D -m0644 passwort-tresor.konf $(DESTDIR)$(ETCDIR)/passwort-tresor.konf
+
+clean:
+ rm -f encedit encedit.1 greppw greppw.1
+
+dist: clean
+ git status --porcelain 2> /dev/null | grep -q "\S" && (git add .; git commit -m"neue Version: $(VERSION)") || true
+ ! git tag -d v$(VERSION) 2> /dev/null
+ git tag v$(VERSION)
+ git push
+ git push --tags
+
+# End of file
diff --git a/encedit.1.in b/encedit.1.in
new file mode 100644
index 0000000..bdfb929
--- /dev/null
+++ b/encedit.1.in
@@ -0,0 +1,53 @@
+.TH sendmailadvanced 1 "" "sendmailadvanced #VERSION#" ""
+.SH NAME
+sendmailadvanced \- wrapper for sendmail which encrypts and generates stamps
+.SH SYNOPSIS
+\fBsendmailadvanced [options]\fP
+.SH DESCRIPTION
+\fBsendmailadvanced\fP encrypts emails and generates stamps either in situ or in a pipe. For that it uses \fBhashcash\fP and \fBgnupg\fP.
+.SH OPTIONS
+.TP
+.B "\-h, \-\-hook"
+Activate specified hook.
+.TP
+.B "\-i, \-\-inline"
+Enhance email file in situ.
+\fB\-\-inline \-\fP has the same effect as option \fB\-t\fP.
+Conflicts with \fB\-t, \-\-no\-inline\fP.
+.TP
+.B "\-t, \-\-no\-inline"
+Enhance email from stdin to stdout.
+Conflicts with \fB\-i, \-\-inline\fP.
+.TP
+.B "\-e, \-\-[no\-]encrypt"
+Do (not) encrypt.
+.TP
+.B "\-s, \-\-[no\-]stamp"
+Do (not) stamp.
+.SH CONFIGURATION
+The configfile \fB#ETCDIR#/sendmailadvanced.conf\fP is a bash script, which defines the following variables and routines:
+.TP
+.B "gpg_recipient"
+default recipient to encrypt to
+.TP
+.B "hashcash_bits"
+stamp value
+.TP
+.B "body_header_hook"
+routine printing things to put into head of (body of) email.
+Parameter \fB$1\fP was given on the console via \fB--hook $1\fP.
+.TP
+.B "body_footer_hook"
+routine printing things to put into foot of email.
+Parameter \fB$1\fP was given on the console via \fB--hook $1\fP.
+.SH FILES
+.TP
+.B "#BINDIR#/sendmailadvanced"
+program file
+.TP
+.B "#ETCDIR#/sendmailadvanced.conf"
+contains configuration
+.SH AUTHOR
+.nf
+Erich Eckner <opensource at eckner dot net>
+.fi
diff --git a/encedit.in b/encedit.in
new file mode 100755
index 0000000..a295add
--- /dev/null
+++ b/encedit.in
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+. #ETCDIR#/passwort-tresor.konf
+
+if [ "$1" == "" ]
+then
+ s=$(dialog --stdout --fselect /mnt/141.35.50.159_home/Dokumente/todolist.gpg 14 70)
+ [ "$s" == "" ] && exit 1
+ if [ "$(basename $s)" != "$(basename $s .gpg).gpg" ]
+ then
+ echo "File must end on \".gpg\", \"$s\" does not!"
+ exit 1
+ fi
+else
+ s="$1"
+ if [ $(basename $s) != $(basename $s .gpg).gpg ]
+ then
+ echo "Usage: etea encrypted.gpg"
+ echo " or: etea"
+ exit 1
+ fi
+fi
+
+if [ "$(dirname $s)" == "/mnt/141.35.50.159_home/Dokumente" ]
+then
+ sha512sum -c ~/.sums/$(basename $s .gpg).512 || dialog --msgbox "Die Prüfsumme stimmt nicht!" 14 70
+fi
+
+i=0
+while [ -e /tmp/efile.$i ] || [ -e /tmp/emsg.$i ] || [ -e /tmp/ecrpt.$i ]
+do
+ i=$[$i+1]
+done
+
+gpg -o /tmp/efile.$i -d $s 2> /tmp/emsg.$i || exit 1
+if [ ! $(grep -c "Good signature from \"Erich Eckner \([^\"]*\)\?<erich@eckner.net>\"" /tmp/emsg.$i) -eq 1 ] || [ ! $(grep -c "Signature made .* using RSA key ID 0AEEC90755DA7B5A" /tmp/emsg.$i) -eq 1 ]
+then
+ dialog --textbox /tmp/emsg.$i 14 70
+fi
+touch /tmp/emsg.$i
+tea /tmp/efile.$i || exit 1
+if [ ! $(ls -1t /tmp/efile.$i /tmp/emsg.$i | wc -l) -eq 2 ] || [ ! $(ls -1t /tmp/efile.$i /tmp/emsg.$i | head -n1) == "/tmp/emsg.$i" ]
+then
+ gpg -o /tmp/ecrpt.$i -r erich@eckner.net -e -s /tmp/efile.$i || exit 1
+ mv /tmp/ecrpt.$i $s 2> /dev/null || exit 1
+ if [ "$(dirname $s)" == "/mnt/141.35.50.159_home/Dokumente" ]
+ then
+ sha512sum $s > ~/.sums/$(basename $s .gpg).512
+ fi
+fi
+rm /tmp/efile.$i
+rm /tmp/emsg.$i
diff --git a/greppw.1.in b/greppw.1.in
new file mode 100644
index 0000000..bdfb929
--- /dev/null
+++ b/greppw.1.in
@@ -0,0 +1,53 @@
+.TH sendmailadvanced 1 "" "sendmailadvanced #VERSION#" ""
+.SH NAME
+sendmailadvanced \- wrapper for sendmail which encrypts and generates stamps
+.SH SYNOPSIS
+\fBsendmailadvanced [options]\fP
+.SH DESCRIPTION
+\fBsendmailadvanced\fP encrypts emails and generates stamps either in situ or in a pipe. For that it uses \fBhashcash\fP and \fBgnupg\fP.
+.SH OPTIONS
+.TP
+.B "\-h, \-\-hook"
+Activate specified hook.
+.TP
+.B "\-i, \-\-inline"
+Enhance email file in situ.
+\fB\-\-inline \-\fP has the same effect as option \fB\-t\fP.
+Conflicts with \fB\-t, \-\-no\-inline\fP.
+.TP
+.B "\-t, \-\-no\-inline"
+Enhance email from stdin to stdout.
+Conflicts with \fB\-i, \-\-inline\fP.
+.TP
+.B "\-e, \-\-[no\-]encrypt"
+Do (not) encrypt.
+.TP
+.B "\-s, \-\-[no\-]stamp"
+Do (not) stamp.
+.SH CONFIGURATION
+The configfile \fB#ETCDIR#/sendmailadvanced.conf\fP is a bash script, which defines the following variables and routines:
+.TP
+.B "gpg_recipient"
+default recipient to encrypt to
+.TP
+.B "hashcash_bits"
+stamp value
+.TP
+.B "body_header_hook"
+routine printing things to put into head of (body of) email.
+Parameter \fB$1\fP was given on the console via \fB--hook $1\fP.
+.TP
+.B "body_footer_hook"
+routine printing things to put into foot of email.
+Parameter \fB$1\fP was given on the console via \fB--hook $1\fP.
+.SH FILES
+.TP
+.B "#BINDIR#/sendmailadvanced"
+program file
+.TP
+.B "#ETCDIR#/sendmailadvanced.conf"
+contains configuration
+.SH AUTHOR
+.nf
+Erich Eckner <opensource at eckner dot net>
+.fi
diff --git a/greppw.in b/greppw.in
new file mode 100755
index 0000000..e0b3b03
--- /dev/null
+++ b/greppw.in
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+. #ETCDIR#/passwort-tresor.konf
+
+echo "Dienst: "
+read dienst
+
+tmpMsg=$(mktemp /tmp/emsg.XXXXXX)
+
+text="$(ssh 141.35.50.159 "cat ~/Dokumente/pws.gpg" | gpg -o - -d - 2> ${tmpMsg})"
+
+if [ ! $(grep -c "Good signature from \"Erich Eckner \([^\"]*\)\?<erich@eckner.net>\"" ${tmpMsg}) -eq 1 ] || [ ! $(grep -c "Signature made .* using RSA key ID 0AEEC90755DA7B5A" ${tmpMsg}) -eq 1 ]
+then
+ dialog --textbox ${tmpMsg} 14 70
+fi
+
+rm -f ${tmpMsg}
+
+[ $(echo -e "${text}" | grep -c "${dienst}") -gt 1 ] && dienst="^${dienst}"
+[ $(echo -e "${text}" | grep -c "${dienst}") -gt 1 ] && dienst="${dienst}:\$"
+[ $(echo -e "${text}" | grep -c "${dienst}") -eq 1 ] || exit 1
+
+text="$(echo "${text}" | grep -2 "${dienst}" | tail -n2)"
+echo "${text}" | head -n1 | xclip -i
+echo -n "."
+read dienst
+echo "${text}" | tail -n1 | xclip -i
+echo -n "."
+read dienst