From 4fbec3ee54982501ce88fcb7dfe85408914d90c3 Mon Sep 17 00:00:00 2001 From: drduh Date: Thu, 2 Jul 2015 17:47:32 -0400 Subject: [PATCH] Add license. Update dependencies to include srm. Set secure umask. Remove superfluous main method. --- LICENSE.md | 19 +++++++++++++++++++ README.md | 2 ++ pwd.sh | 41 ++++++++++++++++------------------------- 3 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..750c399 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,19 @@ +Copyright (c) 2015 drduh + +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. \ No newline at end of file diff --git a/README.md b/README.md index c4b74b7..52e8e55 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ This script uses GPG to manage an encrypted text file containing passwords. # Requirements Requires `gpg`. Install with `brew install gpg` or `apt-get install gnupg` or build and install it from [source](https://www.gnupg.org/download/index.html). +Requires `srm`. Install with `apt-get install secure-delete`. Already included in OS X. + # Installation git clone https://github.com/drduh/pwd.sh && cd pwd.sh diff --git a/pwd.sh b/pwd.sh index 0e513b8..cbdeae8 100755 --- a/pwd.sh +++ b/pwd.sh @@ -11,10 +11,10 @@ safe=pwd.sh.safe public=pwd.sh.pub secret=pwd.sh.sec -del=/usr/bin/srm +del=$(which srm) del_opts=("--force --zero") -gpg=/usr/local/bin/gpg +gpg=$(which gpg) gpg_opts=("--no-default-keyring --keyring ./${public} --secret-keyring ./${secret}") name="nobody@pwd.sh" @@ -174,13 +174,13 @@ create_safe () { sanity_check () { # Make sure all necessary programs are installed and files exist. - if [ ! -x ${gpg} ] ; then + if [[ -z ${gpg} && ! -x ${gpg} ]] ; then echo "GnuPG is not available!" exit 127 fi - if [ ! -x ${del} ] ; then - echo "srm/rm is not available!" + if [[ -z ${del} && ! -x ${del} ]] ; then + echo "srm is not available!" exit 127 fi @@ -200,25 +200,16 @@ sanity_check () { } -main () { - # Main function. +sanity_check - sanity_check - - read -p "Read, write, or delete a password? (r/w/d default: r) " action - if [ "${action}" == "w" ] ; then - create_id - write_pass - elif [ "${action}" == "d" ] ; then - read -p "Which Username/ID to delete? " id - write_pass - else - read_pass - fi -} - - -main - -exit 0 +read -p "Read, write, or delete a password? (r/w/d default: r) " action +if [ "${action}" == "w" ] ; then + create_id + write_pass +elif [ "${action}" == "d" ] ; then + read -p "Which Username/ID to delete? " id + write_pass +else + read_pass +fi