Skip to content

Commit de4bd29

Browse files
committed
Backup script and gpg conf, release version 2
1 parent 93640f8 commit de4bd29

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ It uses GnuPG to symmetrically (i.e., using a master password) encrypt and decry
66

77
# Release notes
88

9-
## Version 1 (2015)
10-
11-
The original release which has been available for general use and review since July 2015. There are no known bugs nor security vulnerabilities identified in this stable version of pwd.sh. Compatible on Linux, OpenBSD, macOS.
9+
## Version 2 (2020)
1210

13-
## Version 2b (2019)
14-
15-
The second release of pwd.sh features several security and reliability improvements, and is an optional upgrade. Currently in beta testing. Compatible on Linux, OpenBSD, macOS.
11+
The second release of pwd.sh features many security and reliability improvements, and is a recommended upgrade. Compatible on Linux, OpenBSD, macOS.
1612

1713
Changelist:
14+
1815
* Passwords are now encrypted as individual files, rather than all encrypted as a single flat file.
1916
* Individual password filenames are random, mapped to usernames in an encrypted index file.
2017
* Index and password files are now "immutable" using chmod while pwd.sh is not running.
@@ -26,6 +23,10 @@ Changelist:
2623
* Removed option: read all passwords; no use case for having a single command.
2724
* Removed option: suppress generated password output; should be read from safe to verify save.
2825

26+
## Version 1 (2015)
27+
28+
The original release which has been available for general use and review since July 2015. There are no known bugs nor security vulnerabilities identified in this stable version of pwd.sh. Compatible on Linux, OpenBSD, macOS.
29+
2930
# Use
3031

3132
```console

pwd.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ umask 077
1212
now=$(date +%s)
1313
copy="$(command -v xclip || command -v pbcopy)"
1414
gpg="$(command -v gpg || command -v gpg2)"
15+
gpgconf="${HOME}/.gnupg/gpg.conf"
1516
backuptar="${PWDSH_BACKUP:=pwd.$(hostname).$(date +%F).tar}"
1617
safeix="${PWDSH_INDEX:=pwd.index}"
1718
safedir="${PWDSH_SAFE:=safe}"
18-
timeout=30
19+
script="$(basename $BASH_SOURCE)"
20+
timeout=10
1921

2022
fail () {
2123
# Print an error message and exit.
@@ -122,7 +124,7 @@ write_pass () {
122124
encrypt "${password}" "${safeix}.${now}" - || \
123125
fail "Failed to put ${safeix}.${now}"
124126

125-
mv -v "${safeix}.${now}" "${safeix}"
127+
mv "${safeix}.${now}" "${safeix}"
126128
}
127129

128130
list_entry () {
@@ -141,8 +143,12 @@ backup () {
141143
# Archive encrypted index and safe directory.
142144

143145
if [[ -f "${safeix}" && -d "${safedir}" ]] ; then \
144-
tar cfv "${backuptar}" "${safeix}" "${safedir}"
146+
cp "${gpgconf}" "gpg.conf.${now}"
147+
tar cfv "${backuptar}" \
148+
"${safeix}" "${safedir}" "gpg.conf.${now}" "${script}"
149+
rm "gpg.conf.${now}"
145150
else fail "Nothing to archive" ; fi
151+
146152
printf "\nArchived %s\n" "${backuptar}" ; \
147153
}
148154

@@ -216,6 +222,8 @@ if [[ -z ${gpg} && ! -x ${gpg} ]] ; then fail "GnuPG is not available" ; fi
216222

217223
if [[ -z ${copy} && ! -x ${copy} ]] ; then fail "Clipboard is not available" ; fi
218224

225+
if [[ ! -f ${gpgconf} ]] ; then fail "GnuPG config is not available" ; fi
226+
219227
if [[ ! -d "${safedir}" ]] ; then mkdir -p "${safedir}" ; fi
220228

221229
chmod -R 0600 "${safeix}" 2>/dev/null

0 commit comments

Comments
 (0)