From 435a3c073fc200c1e0a9e4aad6abbd3a6e74e688 Mon Sep 17 00:00:00 2001 From: jonathan vanasco Date: Mon, 25 Apr 2016 12:53:36 -0400 Subject: [PATCH 01/94] added `blackbox_listadmins`, which just displays active admins via `cat "$BB_ADMINS"` --- README.md | 1 + bin/blackbox_listadmins | 18 ++++++++++++++++++ tools/mk_deb_fpmdir.stack_blackbox.txt | 1 + tools/mk_macports.vcs_blackbox.txt | 1 + tools/mk_rpm_fpmdir.stack_blackbox.txt | 1 + 5 files changed, 22 insertions(+) create mode 100755 bin/blackbox_listadmins diff --git a/README.md b/README.md index c1c2f14..2533e1f 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Commands: | `blackbox_postdeploy` | Decrypt all managed files (batch) | | `blackbox_addadmin` | Add someone to the list of people that can encrypt/decrypt secrets | | `blackbox_removeadmin` | Remove someone from the list of people that can encrypt/decrypt secrets | +| `blackbox_listadmins` | Display the list of people that can encrypt/decrypt secrets | | `blackbox_shred_all_files` | Safely delete any decrypted files | | `blackbox_update_all_files` | Decrypt then re-encrypt all files. Useful after keys are changed | | `blackbox_whatsnew` | show what has changed in the last commit for a given file | diff --git a/bin/blackbox_listadmins b/bin/blackbox_listadmins new file mode 100755 index 0000000..33ec995 --- /dev/null +++ b/bin/blackbox_listadmins @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# +# blackbox_listadmins -- List active admins for keyring +# + +# Example: +# blackbox_listadmins +# + +set -e +source "${0%/*}/_blackbox_common.sh" + +fail_if_not_in_repo + + +# simply display the contents of the admins file +cat "$BB_ADMINS" diff --git a/tools/mk_deb_fpmdir.stack_blackbox.txt b/tools/mk_deb_fpmdir.stack_blackbox.txt index 1cdde07..a17577d 100644 --- a/tools/mk_deb_fpmdir.stack_blackbox.txt +++ b/tools/mk_deb_fpmdir.stack_blackbox.txt @@ -9,6 +9,7 @@ exec /usr/bin/blackbox_edit ../bin/blackbox_edit exec /usr/bin/blackbox_edit_end ../bin/blackbox_edit_end exec /usr/bin/blackbox_edit_start ../bin/blackbox_edit_start exec /usr/bin/blackbox_initialize ../bin/blackbox_initialize +exec /usr/bin/blackbox_listadmins ../bin/blackbox_listadmins exec /usr/bin/blackbox_list_files ../bin/blackbox_list_files exec /usr/bin/blackbox_postdeploy ../bin/blackbox_postdeploy exec /usr/bin/blackbox_register_new_file ../bin/blackbox_register_new_file diff --git a/tools/mk_macports.vcs_blackbox.txt b/tools/mk_macports.vcs_blackbox.txt index 8fa0001..e0c1c51 100644 --- a/tools/mk_macports.vcs_blackbox.txt +++ b/tools/mk_macports.vcs_blackbox.txt @@ -9,6 +9,7 @@ exec bin/blackbox_edit ../bin/blackbox_edit exec bin/blackbox_edit_end ../bin/blackbox_edit_end exec bin/blackbox_edit_start ../bin/blackbox_edit_start exec bin/blackbox_initialize ../bin/blackbox_initialize +exec bin/blackbox_listadmins ../bin/blackbox_listadmins exec bin/blackbox_list_files ../bin/blackbox_list_files exec bin/blackbox_postdeploy ../bin/blackbox_postdeploy exec bin/blackbox_register_new_file ../bin/blackbox_register_new_file diff --git a/tools/mk_rpm_fpmdir.stack_blackbox.txt b/tools/mk_rpm_fpmdir.stack_blackbox.txt index dd88283..341b7a6 100644 --- a/tools/mk_rpm_fpmdir.stack_blackbox.txt +++ b/tools/mk_rpm_fpmdir.stack_blackbox.txt @@ -11,6 +11,7 @@ exec /usr/blackbox/bin/blackbox_edit ../bin/blackbox_edit exec /usr/blackbox/bin/blackbox_edit_end ../bin/blackbox_edit_end exec /usr/blackbox/bin/blackbox_edit_start ../bin/blackbox_edit_start exec /usr/blackbox/bin/blackbox_initialize ../bin/blackbox_initialize +exec /usr/blackbox/bin/blackbox_listadmins ../bin/blackbox_listadmins exec /usr/blackbox/bin/blackbox_list_files ../bin/blackbox_list_files exec /usr/blackbox/bin/blackbox_postdeploy ../bin/blackbox_postdeploy exec /usr/blackbox/bin/blackbox_register_new_file ../bin/blackbox_register_new_file From c3f7e12890dd1f9a94b93356ab5c041aafa86d7e Mon Sep 17 00:00:00 2001 From: Yves Dorfsman Date: Fri, 20 May 2016 15:08:46 -0600 Subject: [PATCH 02/94] Use PKGNAME variable defined above. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 92104b2..42659a4 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL=/bin/sh PKGNAME=stack_blackbox BASEDIR?=~ -OUTPUTDIR?="$(BASEDIR)/debbuild-${PACKAGENAME}" +OUTPUTDIR?="$(BASEDIR)/debbuild-${PKGNAME}" all: @echo 'Menu:' From 1ae578b7cfef2607334b860f291edcc3ea742705 Mon Sep 17 00:00:00 2001 From: Yves Dorfsman Date: Fri, 20 May 2016 16:15:15 -0600 Subject: [PATCH 03/94] Tilde doesn't get expanded when in between quotes. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 42659a4..7719474 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL=/bin/sh PKGNAME=stack_blackbox -BASEDIR?=~ +BASEDIR?=$(HOME) OUTPUTDIR?="$(BASEDIR)/debbuild-${PKGNAME}" all: From 2be3ddaddf0516d57dbad99a9a8f11940e98efcb Mon Sep 17 00:00:00 2001 From: Amos Shapira Date: Sun, 22 May 2016 11:45:41 +1000 Subject: [PATCH 04/94] Added instructions to make "git diff" work Added a paragraph about configuring `git` to decrypt files for diff/log --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 5142cb4..cf2b2cc 100644 --- a/README.md +++ b/README.md @@ -616,6 +616,23 @@ Any files that were temporarily copied in the first step so as to not be overwri (Thanks to @chishaku for finding a solution to this problem!) +### Configure git to show diffs in encrypted files + +It's possible to tell Git to decrypt versions of the file before running them through `git diff` or `git log`. To achieve this do: + +- Add the following to `.gitattributes` at the top of the git repository: +``` +*.gpg diff=blackbox +``` + +- Add the following to `.git/config`: +``` +[diff "blackbox"] + textconv = gpg --use-agent -q --batch --decrypt +```` + +And now commands like `git log -p file.gpg` will show a nice log of the changes in the encrypted file. + Some common errors: =================== From 21c0b682138a8cebf1201b9d3654ddd326364df9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 26 May 2016 11:54:14 -0400 Subject: [PATCH 05/94] Check return value contents Closes #156 --- bin/blackbox_register_new_file | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/blackbox_register_new_file b/bin/blackbox_register_new_file index 08befcc..288b8ae 100755 --- a/bin/blackbox_register_new_file +++ b/bin/blackbox_register_new_file @@ -36,7 +36,7 @@ function register_new_file() { echo "========== UPDATING REPO:" shred_file "$unencrypted_file" - if "$SECRETSEXPOSED" ; then + if [[ "$SECRETSEXPOSED" == "true" ]] ; then vcs_remove "$unencrypted_file" vcs_add "$encrypted_file" fi From 4fe27a04c940677203fc0803c4ae23fd31a14bd5 Mon Sep 17 00:00:00 2001 From: Jon Bardin Date: Wed, 31 Aug 2016 06:29:54 -0700 Subject: [PATCH 06/94] Allow parallel shredding of files (#167) * to log which files were shredded * allow parallel shredding of files ot lower time to shred --- bin/blackbox_shred_all_files | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/blackbox_shred_all_files b/bin/blackbox_shred_all_files index 53e76de..07bb56e 100755 --- a/bin/blackbox_shred_all_files +++ b/bin/blackbox_shred_all_files @@ -21,13 +21,23 @@ source "${0%/*}/_blackbox_common.sh" change_to_vcs_root echo '========== FILES BEING SHREDDED:' -while IFS= read <&99 -r unencrypted_file; do - unencrypted_file=$(get_unencrypted_filename "$unencrypted_file") + +exported_internal_shred_file() { + source "$1/_blackbox_common.sh" + unencrypted_file=$(get_unencrypted_filename "$2") encrypted_file=$(get_encrypted_filename "$unencrypted_file") if [[ -f "$unencrypted_file" ]]; then echo " $unencrypted_file" shred_file "$unencrypted_file" fi -done 99<"$BB_FILES" +} + +export -f exported_internal_shred_file + +DEREFERENCED_BIN_DIR="${0%/*}" +MAX_PARALLEL_SHRED=10 + +export IFS= +xargs -I{} -n 1 -P $MAX_PARALLEL_SHRED bash -c "exported_internal_shred_file $DEREFERENCED_BIN_DIR {}" $DEREFERENCED_BIN_DIR/fake <"$BB_FILES" echo '========== DONE.' From 31cf5066840d4dd130a23866aae56a66b6179c8e Mon Sep 17 00:00:00 2001 From: Dave Jachimiak Date: Fri, 23 Sep 2016 09:26:22 -0400 Subject: [PATCH 07/94] ignore backup files and secring.gpg in $BLACKBOXDATA (#169) --- bin/blackbox_initialize | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/blackbox_initialize b/bin/blackbox_initialize index 96786b5..4855e9f 100755 --- a/bin/blackbox_initialize +++ b/bin/blackbox_initialize @@ -27,7 +27,7 @@ fi change_to_vcs_root echo VCS_TYPE: $VCS_TYPE -vcs_ignore keyrings/live/pubring.gpg~ keyrings/live/pubring.kbx~ keyrings/live/secring.gpg +vcs_ignore "${BLACKBOXDATA}/pubring.gpg~" "${BLACKBOXDATA}/pubring.kbx~" "${BLACKBOXDATA}/secring.gpg" # Make directories mkdir -p "${KEYRINGDIR}" From 598896ef48cf634492801373ae2571d6dbaf4692 Mon Sep 17 00:00:00 2001 From: Jason Price Date: Thu, 6 Oct 2016 11:26:43 -0400 Subject: [PATCH 08/94] Add list admins commandline tool. (#170) * adding a list_admins command * updating README and V2 ideas to include list_admins * fix documentation misses * add list_admins to the toolchain --- README.md | 1 + Version2-Ideas.md | 1 + bin/blackbox_list_admins | 8 ++++++++ tools/mk_deb_fpmdir.stack_blackbox.txt | 1 + tools/mk_macports.vcs_blackbox.txt | 1 + tools/mk_rpm_fpmdir.stack_blackbox.txt | 1 + 6 files changed, 13 insertions(+) create mode 100755 bin/blackbox_list_admins diff --git a/README.md b/README.md index cf2b2cc..35e407f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Commands: | `blackbox_register_new_file ` | Encrypt a file for the first time | | `blackbox_deregister_file ` | Remove a file from blackbox | | `blackbox_list_files` | List the files maintained by blackbox | +| `blackbox_list_admins` | List admins currently authorized for blackbox | | `blackbox_decrypt_all_files` | Decrypt all managed files (INTERACTIVE) | | `blackbox_postdeploy` | Decrypt all managed files (batch) | | `blackbox_addadmin ` | Add someone to the list of people that can encrypt/decrypt secrets | diff --git a/Version2-Ideas.md b/Version2-Ideas.md index 86cf7ab..a3533ce 100644 --- a/Version2-Ideas.md +++ b/Version2-Ideas.md @@ -30,6 +30,7 @@ There should be one program, with subcommands that have names that make more sen * `blackbox cat <...>` * `blackbox diff <...>` * `blackbox list_files` +* `blackbox list_admins` * `blackbox shred_all` * `blackbox update_all` * `blackbox whatsnew` diff --git a/bin/blackbox_list_admins b/bin/blackbox_list_admins new file mode 100755 index 0000000..b90d7cc --- /dev/null +++ b/bin/blackbox_list_admins @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# +# blackbox_list_admins -- List authorized admins +# +set -e +source "${0%/*}/_blackbox_common.sh" +cat "$BB_ADMINS_FILE" diff --git a/tools/mk_deb_fpmdir.stack_blackbox.txt b/tools/mk_deb_fpmdir.stack_blackbox.txt index 1cdde07..f2a2392 100644 --- a/tools/mk_deb_fpmdir.stack_blackbox.txt +++ b/tools/mk_deb_fpmdir.stack_blackbox.txt @@ -10,6 +10,7 @@ exec /usr/bin/blackbox_edit_end ../bin/blackbox_edit_end exec /usr/bin/blackbox_edit_start ../bin/blackbox_edit_start exec /usr/bin/blackbox_initialize ../bin/blackbox_initialize exec /usr/bin/blackbox_list_files ../bin/blackbox_list_files +exec /usr/bin/blackbox_list_admins ../bin/blackbox_list_admins exec /usr/bin/blackbox_postdeploy ../bin/blackbox_postdeploy exec /usr/bin/blackbox_register_new_file ../bin/blackbox_register_new_file exec /usr/bin/blackbox_removeadmin ../bin/blackbox_removeadmin diff --git a/tools/mk_macports.vcs_blackbox.txt b/tools/mk_macports.vcs_blackbox.txt index 8fa0001..74dd8de 100644 --- a/tools/mk_macports.vcs_blackbox.txt +++ b/tools/mk_macports.vcs_blackbox.txt @@ -10,6 +10,7 @@ exec bin/blackbox_edit_end ../bin/blackbox_edit_end exec bin/blackbox_edit_start ../bin/blackbox_edit_start exec bin/blackbox_initialize ../bin/blackbox_initialize exec bin/blackbox_list_files ../bin/blackbox_list_files +exec bin/blackbox_list_admins ../bin/blackbox_list_admins exec bin/blackbox_postdeploy ../bin/blackbox_postdeploy exec bin/blackbox_register_new_file ../bin/blackbox_register_new_file exec bin/blackbox_removeadmin ../bin/blackbox_removeadmin diff --git a/tools/mk_rpm_fpmdir.stack_blackbox.txt b/tools/mk_rpm_fpmdir.stack_blackbox.txt index dd88283..2604ae0 100644 --- a/tools/mk_rpm_fpmdir.stack_blackbox.txt +++ b/tools/mk_rpm_fpmdir.stack_blackbox.txt @@ -12,6 +12,7 @@ exec /usr/blackbox/bin/blackbox_edit_end ../bin/blackbox_edit_end exec /usr/blackbox/bin/blackbox_edit_start ../bin/blackbox_edit_start exec /usr/blackbox/bin/blackbox_initialize ../bin/blackbox_initialize exec /usr/blackbox/bin/blackbox_list_files ../bin/blackbox_list_files +exec /usr/blackbox/bin/blackbox_list_admins ../bin/blackbox_list_admins exec /usr/blackbox/bin/blackbox_postdeploy ../bin/blackbox_postdeploy exec /usr/blackbox/bin/blackbox_register_new_file ../bin/blackbox_register_new_file exec /usr/blackbox/bin/blackbox_removeadmin ../bin/blackbox_removeadmin From fba77f092a954b8977bc2533146e6238516fd458 Mon Sep 17 00:00:00 2001 From: Tino Breddin Date: Tue, 8 Nov 2016 19:49:42 +0100 Subject: [PATCH 09/94] Add FreeBSD support (#172) --- bin/_blackbox_common.sh | 4 ++-- bin/_stack_lib.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index e39663a..3d061fc 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -374,7 +374,7 @@ function file_contains_line() { function md5sum_file() { # Portably generate the MD5 hash of file $1. case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) md5 -r "$1" | awk '{ print $1 }' ;; Linux | CYGWIN* | MINGW* ) @@ -390,7 +390,7 @@ function md5sum_file() { function cp_permissions() { # Copy the perms of $1 onto $2 .. end. case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) chmod $( stat -f '%p' "$1" ) "${@:2}" ;; Linux | CYGWIN* | MINGW* ) diff --git a/bin/_stack_lib.sh b/bin/_stack_lib.sh index 24a9759..d2edd36 100755 --- a/bin/_stack_lib.sh +++ b/bin/_stack_lib.sh @@ -53,7 +53,7 @@ function create_self_deleting_tempfile() { local filename case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) : "${TMPDIR:=/tmp}" ; filename=$(mktemp -t _stacklib_.XXXXXXXX ) ;; @@ -74,7 +74,7 @@ function create_self_deleting_tempdir() { local filename case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) : "${TMPDIR:=/tmp}" ; filename=$(mktemp -d -t _stacklib_.XXXXXXXX ) ;; @@ -98,7 +98,7 @@ function make_self_deleting_tempfile() { local name case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) : "${TMPDIR:=/tmp}" ; name=$(mktemp -t _stacklib_.XXXXXXXX ) ;; @@ -120,7 +120,7 @@ function make_tempdir() { local name case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) : "${TMPDIR:=/tmp}" ; name=$(mktemp -d -t _stacklib_.XXXXXXXX ) ;; @@ -157,7 +157,7 @@ function fail_if_not_running_as_root() { function fail_if_in_root_directory() { # Verify nobody has tricked us into being in "/". case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) if [[ $(stat -f'%i' / ) == $(stat -f'%i' . ) ]] ; then echo 'SECURITY ALERT: The current directory is the root directory.' echo 'Exiting...' From 1b7c8c880b92f08aa5dcf97536dc6daf910dfc64 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Tue, 22 Nov 2016 10:43:08 -0800 Subject: [PATCH 10/94] Remove the key from the keyring when removing an admin (#173) Thanks for the submission! --- bin/blackbox_removeadmin | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/blackbox_removeadmin b/bin/blackbox_removeadmin index 6249721..9034977 100755 --- a/bin/blackbox_removeadmin +++ b/bin/blackbox_removeadmin @@ -20,8 +20,15 @@ KEYNAME="$1" # Remove the email address from the BB_ADMINS file. remove_line "$BB_ADMINS" "$KEYNAME" + +# remove the admin key from the pubring +$GPG --no-permission-warning --homedir="$KEYRINGDIR" --delete-key "$KEYNAME" +pubring_path=$(get_pubring_path) +vcs_add "$pubring_path" "$KEYRINGDIR/trustdb.gpg" "$BB_ADMINS" + + # Make a suggestion: echo echo echo 'NEXT STEP: Check these into the repo. Probably with a command like...' -echo $VCS_TYPE commit -m\'REMOVED ADMIN: $KEYNAME\' "$BLACKBOXDATA/$BB_ADMINS_FILE" +echo $VCS_TYPE commit -m\'REMOVED ADMIN: $KEYNAME\' "$BLACKBOXDATA/trustdb.gpg" "$BLACKBOXDATA/$BB_ADMINS_FILE" From 818db985064ef1ae587b33de7a844e31d0e0f1d9 Mon Sep 17 00:00:00 2001 From: Ben Watson Date: Mon, 12 Dec 2016 14:07:33 +0000 Subject: [PATCH 11/94] Requiring a file to be entered to finish editing (#175) * Requiring a file to be entered to finish editing Running blackbox_edit_end without an argument doesn't currently print out a warning that no files are being changed. A developer in my team who was new to Blackbox committed a decrypted file (and made no changes to the GPG file) as they didn't realise the command hadn't worked. The check I've added should help to avoid these errors. * Adding argument check to start editing --- bin/blackbox_edit_end | 5 +++++ bin/blackbox_edit_start | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/bin/blackbox_edit_end b/bin/blackbox_edit_end index 618d13a..14f4609 100755 --- a/bin/blackbox_edit_end +++ b/bin/blackbox_edit_end @@ -9,6 +9,11 @@ source "${0%/*}/_blackbox_common.sh" next_steps=() +if [ $# -eq 0 ]; then + echo >&2 "Please provide at least one file for which editing has finished" + exit 1 +fi + for param in "$@" ; do unencrypted_file=$(get_unencrypted_filename "$param") diff --git a/bin/blackbox_edit_start b/bin/blackbox_edit_start index 79df67f..6f61e13 100755 --- a/bin/blackbox_edit_start +++ b/bin/blackbox_edit_start @@ -7,6 +7,11 @@ set -e source "${0%/*}/_blackbox_common.sh" +if [ $# -eq 0 ]; then + echo >&2 "Please provide at least one file to start editing" + exit 1 +fi + for param in "$@" ; do unencrypted_file=$(get_unencrypted_filename "$param") From bd0fcd181cdc583c1b04e21eb53f0dbfceee2817 Mon Sep 17 00:00:00 2001 From: Tino Breddin Date: Fri, 20 Jan 2017 23:12:57 +0100 Subject: [PATCH 12/94] [FreeBSD] Fix use of chmod (#180) LGTM Thanks for the fix! --- bin/_blackbox_common.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 3d061fc..45a3f0f 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -390,9 +390,12 @@ function md5sum_file() { function cp_permissions() { # Copy the perms of $1 onto $2 .. end. case $(uname -s) in - Darwin | FreeBSD ) + Darwin ) chmod $( stat -f '%p' "$1" ) "${@:2}" ;; + FreeBSD ) + chmod $( stat -f '%p' "$1" | sed -e "s/^100//" ) "${@:2}" + ;; Linux | CYGWIN* | MINGW* ) chmod --reference "$1" "${@:2}" ;; From e91344d404ceb0adf1e38172a8fe34d4d17eea80 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 16 Feb 2017 15:41:59 -0500 Subject: [PATCH 13/94] Add a CHANGELOG.md --- CHANGELOG.md | 3 +++ RELEASE_ENGINEERING.md | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9610a6d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +Release v1.20170127 + +* Starting CHANGELOG. diff --git a/RELEASE_ENGINEERING.md b/RELEASE_ENGINEERING.md index 163ae04..6310d15 100644 --- a/RELEASE_ENGINEERING.md +++ b/RELEASE_ENGINEERING.md @@ -27,7 +27,23 @@ Stable Releases Marking the software to be "stable": -Step 1. Tag it. +Step 1. Update CHANGELOG.md + +Use "git log" to see what has changed and update CHANGELOG.md. + +For a new release, add: + +``` + echo Release v1.$(date +%Y%m%d) +``` + +Commit with: + +``` +git commit -m'Update CHANGELOG.md' CHANGELOG.md +``` + +Step 2. Tag it. ``` git pull @@ -37,7 +53,7 @@ git tag stable git push origin tag stable ``` -Step 2. Mark your calendar 1 week from today to check to see if this should be promoted to production. +Step 3. Mark your calendar 1 week from today to check to see if this should be promoted to production. Production Releases =================== From 9bee252e244b253864e9fb983f1e885c7055339c Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 20 Feb 2017 10:53:55 -0500 Subject: [PATCH 14/94] README.md: Add info about our new mailing list. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 35e407f..23ce872 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Safely store secrets in a VCS repo (i.e. Git, Mercurial, Subversion or Perforce) A slide presentation about an older release [is on SlideShare](http://www.slideshare.net/TomLimoncelli/the-blackbox-project-sfae). +Join our mailing list: [https://groups.google.com/d/forum/blackbox-project](https://groups.google.com/d/forum/blackbox-project) + Table of Contents ================= @@ -666,6 +668,10 @@ How to submit bugs or ask questions? We welcome questions, bug reports and feedback! +The best place to start is to join the [blackbox-project mailing list](https://groups.google.com/d/forum/blackbox-project) and ask there. + +Bugs are tracked here in Github. Please feel free to files bugs yourself: + - https://github.com/StackExchange/blackbox/issues Developer Info From 2d1410599d589cc6c09f0002bcab759a3f81fff8 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 20 Feb 2017 16:46:39 +0000 Subject: [PATCH 15/94] Fixing "make confidence" (HT to https://github.com/painhardcore/blackbox/commit/98b928c0e80e2d1911f2db5a558cd5b93375f1da) --- tools/confidence_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index a2f1656..85dbd93 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -31,6 +31,7 @@ function become_alice() { export GPG_AGENT_INFO="$GPG_AGENT_INFO_ALICE" echo BECOMING ALICE: GNUPGHOME="$GNUPGHOME AGENT=$GPG_AGENT_INFO" mkdir -p .git ; touch .git/config + git init git config user.name "Alice Example" git config user.email alice@example.com } @@ -46,7 +47,6 @@ function become_bob() { PHASE 'Alice creates a repo. She creates secret.txt.' become_alice -git init echo 'this is my secret' >secret.txt From 5df0d21be6f1d7dd155c5eb12658a75ea8750192 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 20 Feb 2017 12:15:05 -0500 Subject: [PATCH 16/94] make_tempdir must create shorter paths. --- bin/_stack_lib.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/_stack_lib.sh b/bin/_stack_lib.sh index d2edd36..b51b138 100755 --- a/bin/_stack_lib.sh +++ b/bin/_stack_lib.sh @@ -122,7 +122,10 @@ function make_tempdir() { case $(uname -s) in Darwin | FreeBSD ) : "${TMPDIR:=/tmp}" ; - name=$(mktemp -d -t _stacklib_.XXXXXXXX ) + # The full path to the temp directory must be short. + # This is used by blackbox's testing suite to make a fake GNUPGHOME, + # which needs to fit within sockaddr_un.sun_path (see unix(7)). + name=$(mktemp -d -t SO ) ;; Linux | CYGWIN* | MINGW* ) name=$(mktemp -d) From cf984c26ee226e2783988ea398f6ae7813dad909 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 22 Feb 2017 19:31:55 +0000 Subject: [PATCH 17/94] "make test" should be an alias for "make confidence". --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7719474..1d973ee 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ all: @echo ' make update Update any generated files' @echo ' make packages Make RPM packages' @echo ' make packages-deb Make DEB packages' + @echo ' make test Run tests' @echo ' make install (incomplete)' install: @@ -122,6 +123,7 @@ clean: # # System Test: # +test: confidence confidence: @if [ -e ~/.gnupg ]; then echo ERROR: '~/.gnupg should not exist. If it does, bugs may polute your .gnupg configuration. If the code has no bugs everything will be fine. Do you feel lucky?'; false ; fi @if which >/dev/null gpg-agent ; then pkill gpg-agent ; rm -rf /tmp/tmp.* ; fi From 44c993429346c5fff3ba053cfbb5b99adc150321 Mon Sep 17 00:00:00 2001 From: Graham Lyons Date: Fri, 10 Mar 2017 13:20:43 +0000 Subject: [PATCH 18/94] Use the `rm` command with `-P` as a shred fallback (#179) * Use the `rm` command with `-P` as a shred fallback The newer versions of OSX (Sierra) have neither `shred` nor `srm`. They do have `rm` with the `-P` option, so we can fall back to that before resorting to plain old `rm`. * Add double-quotes and braces to the shell variable. We should treat the variable as a string, and we should also be safe when interpolating it. --- bin/_blackbox_common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 45a3f0f..f6346ee 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -277,6 +277,9 @@ function shred_file() { #NOTE: srm by default uses 35-pass Gutmann algorithm CMD=srm OPT=-f + elif _F=$(mktemp); rm -P "${_F}" >/dev/null 2>/dev/null ; then + CMD=rm + OPT=-Pf else echo "shred_file: WARNING: No secure deletion utility (shred or srm) present; using insecure rm" CMD=rm From 2f2289b5e31f21dc13e2ca316713a1dcd5be9590 Mon Sep 17 00:00:00 2001 From: William Belle Date: Fri, 24 Mar 2017 14:04:25 +0100 Subject: [PATCH 19/94] Fix typo on README (#187) Thanks! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23ce872..c5e4e2c 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ OBVIOUSLY we don't want secret things like SSL private keys and passwords to be NOT SO OBVIOUSLY when we store "secrets" in a VCS repo like Git or Mercurial, suddenly we are less able to share our code with other people. Communication between subteams of an organization is hurt. You can't collaborate as well. Either you find yourself emailing individual files around (yuck!), making a special repo with just the files needed by your collaborators (yuck!!), or just deciding that collaboration isn't worth all that effort (yuck!!!). -The ability to be open and transparent about our code, with the exception of a few specific files, is key to the kind of collaboration that DevOps and modern IT practitioniers need to do. +The ability to be open and transparent about our code, with the exception of a few specific files, is key to the kind of collaboration that DevOps and modern IT practitioners need to do. Installation Instructions: ========================== From 87282901224327e9a7270863c4d554a30edeb3aa Mon Sep 17 00:00:00 2001 From: Simon Gate Date: Wed, 26 Apr 2017 14:34:20 +0200 Subject: [PATCH 20/94] Don't complain about GPG_AGENT_INFO if using newer gpg-agent (#189) --- bin/_blackbox_common.sh | 17 ++++++ bin/_stack_lib.sh | 106 +++++++++++++++++++++++++++++++++ bin/blackbox_decrypt_all_files | 6 +- bin/blackbox_diff | 8 +-- bin/blackbox_update_all_files | 8 +-- bin/blackbox_whatsnew | 8 +-- 6 files changed, 128 insertions(+), 25 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index f6346ee..6ee410c 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -646,3 +646,20 @@ function vcs_notice_generic_file() { echo "WARNING: If so, manually update the ignore file" fi } + +function gpg_agent_version_check() { + if ! hash 'gpg-agent' &> /dev/null; then + return 1 + fi + local gpg_agent_version=$(gpg-agent --version | head -1 | awk '{ print $3 }' | tr -d '\n') + semverLT $gpg_agent_version "2.1.0" +} + +function gpg_agent_notice() { + if [[ $(gpg_agent_version_check) == '0' && -z $GPG_AGENT_INFO ]];then + echo 'WARNING: You probably want to run gpg-agent as' + echo 'you will be asked for your passphrase many times.' + echo 'Example: $ eval $(gpg-agent --daemon)' + read -r -p 'Press CTRL-C now to stop. ENTER to continue: ' + fi +} diff --git a/bin/_stack_lib.sh b/bin/_stack_lib.sh index b51b138..8ca801a 100755 --- a/bin/_stack_lib.sh +++ b/bin/_stack_lib.sh @@ -180,3 +180,109 @@ function fail_if_in_root_directory() { ;; esac } + +function semverParseInto() { + local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' + #MAJOR + eval $2=`echo $1 | sed -e "s#$RE#\1#"` + #MINOR + eval $3=`echo $1 | sed -e "s#$RE#\2#"` + #MINOR + eval $4=`echo $1 | sed -e "s#$RE#\3#"` + #SPECIAL + eval $5=`echo $1 | sed -e "s#$RE#\4#"` +} + +function semverEQ() { + local MAJOR_A=0 + local MINOR_A=0 + local PATCH_A=0 + local SPECIAL_A=0 + + local MAJOR_B=0 + local MINOR_B=0 + local PATCH_B=0 + local SPECIAL_B=0 + + semverParseInto $1 MAJOR_A MINOR_A PATCH_A SPECIAL_A + semverParseInto $2 MAJOR_B MINOR_B PATCH_B SPECIAL_B + + if [ $MAJOR_A -ne $MAJOR_B ]; then + return 1 + fi + + if [ $MINOR_A -ne $MINOR_B ]; then + return 1 + fi + + if [ $PATCH_A -ne $PATCH_B ]; then + return 1 + fi + + if [[ "_$SPECIAL_A" != "_$SPECIAL_B" ]]; then + return 1 + fi + + + return 0 + +} + +function semverLT() { + local MAJOR_A=0 + local MINOR_A=0 + local PATCH_A=0 + local SPECIAL_A=0 + + local MAJOR_B=0 + local MINOR_B=0 + local PATCH_B=0 + local SPECIAL_B=0 + + semverParseInto $1 MAJOR_A MINOR_A PATCH_A SPECIAL_A + semverParseInto $2 MAJOR_B MINOR_B PATCH_B SPECIAL_B + + if [ $MAJOR_A -lt $MAJOR_B ]; then + return 0 + fi + + if [[ $MAJOR_A -le $MAJOR_B && $MINOR_A -lt $MINOR_B ]]; then + return 0 + fi + + if [[ $MAJOR_A -le $MAJOR_B && $MINOR_A -le $MINOR_B && $PATCH_A -lt $PATCH_B ]]; then + return 0 + fi + + if [[ "_$SPECIAL_A" == "_" ]] && [[ "_$SPECIAL_B" == "_" ]] ; then + return 1 + fi + if [[ "_$SPECIAL_A" == "_" ]] && [[ "_$SPECIAL_B" != "_" ]] ; then + return 1 + fi + if [[ "_$SPECIAL_A" != "_" ]] && [[ "_$SPECIAL_B" == "_" ]] ; then + return 0 + fi + + if [[ "_$SPECIAL_A" < "_$SPECIAL_B" ]]; then + return 0 + fi + + return 1 + +} + +function semverGT() { + semverEQ $1 $2 + local EQ=$? + + semverLT $1 $2 + local LT=$? + + if [ $EQ -ne 0 ] && [ $LT -ne 0 ]; then + return 0 + else + return 1 + fi +} + diff --git a/bin/blackbox_decrypt_all_files b/bin/blackbox_decrypt_all_files index 667c9d3..479bb54 100755 --- a/bin/blackbox_decrypt_all_files +++ b/bin/blackbox_decrypt_all_files @@ -14,9 +14,7 @@ export PATH=/usr/bin:/bin:"$PATH" set -e +source "${0%/*}/_blackbox_common.sh" -if [[ -z $GPG_AGENT_INFO ]]; then - eval $(gpg-agent --daemon) -fi - +gpg_agent_notice exec blackbox_postdeploy "$@" diff --git a/bin/blackbox_diff b/bin/blackbox_diff index f83355d..078cddc 100755 --- a/bin/blackbox_diff +++ b/bin/blackbox_diff @@ -7,13 +7,7 @@ set -e source "${0%/*}/_blackbox_common.sh" -if [[ -z $GPG_AGENT_INFO ]]; then - echo 'WARNING: You probably want to run gpg-agent as' - echo 'you will be asked for your passphrase many times.' - echo 'Example: $ eval $(gpg-agent --daemon)' - read -r -p 'Press CTRL-C now to stop. ENTER to continue: ' -fi - +gpg_agent_notice prepare_keychain modified_files=() diff --git a/bin/blackbox_update_all_files b/bin/blackbox_update_all_files index 564f002..d469a63 100755 --- a/bin/blackbox_update_all_files +++ b/bin/blackbox_update_all_files @@ -7,13 +7,7 @@ set -e source "${0%/*}/_blackbox_common.sh" -if [[ -z $GPG_AGENT_INFO ]]; then - echo 'WARNING: You probably want to run gpg-agent as' - echo 'you will be asked for your passphrase many times.' - echo 'Example: $ eval $(gpg-agent --daemon)' - read -r -p 'Press CTRL-C now to stop. ENTER to continue: ' -fi - +gpg_agent_notice disclose_admins prepare_keychain diff --git a/bin/blackbox_whatsnew b/bin/blackbox_whatsnew index d0fdee0..9f85390 100755 --- a/bin/blackbox_whatsnew +++ b/bin/blackbox_whatsnew @@ -14,13 +14,7 @@ then fi fail_if_not_in_repo - -if [[ -z $GPG_AGENT_INFO ]]; then - echo 'WARNING: You probably want to run gpg-agent as' - echo 'you will be asked for your passphrase many times.' - echo 'Example: $ eval $(gpg-agent --daemon)' - read -r -p 'Press CTRL-C now to stop. ENTER to continue: ' -fi +gpg_agent_notice COLUMNS=`tput cols` FILE=$1 From be425ed76ceb95caa6536692ceebba6ea7e2b96e Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 2 May 2017 20:03:07 +0930 Subject: [PATCH 21/94] shred_file() outputs warning message to stderr. (#192) --- bin/_blackbox_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 6ee410c..3249599 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -281,7 +281,7 @@ function shred_file() { CMD=rm OPT=-Pf else - echo "shred_file: WARNING: No secure deletion utility (shred or srm) present; using insecure rm" + echo "shred_file: WARNING: No secure deletion utility (shred or srm) present; using insecure rm" >&2 CMD=rm OPT=-f fi From 53ed9d601acf1d92a5a4134c04db0eb1683306a8 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 9 Mar 2017 11:11:34 -0500 Subject: [PATCH 22/94] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9610a6d..c123c0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ Release v1.20170127 * Starting CHANGELOG. + + +Release v1.20170309 + +* "make test" is an alias for "make confidence" +* macOS: make_tempdir must create shorter paths +* Fix "make confidence" for newer version of Git +* README.md: Add info about our new mailing list From 49892c307ca79f49adb85039682b5bab629c491a Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 4 May 2017 10:23:10 -0400 Subject: [PATCH 23/94] Sync mk_rpm_fpmdir from master --- tools/mk_rpm_fpmdir | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mk_rpm_fpmdir b/tools/mk_rpm_fpmdir index e6233f0..75ee91a 100755 --- a/tools/mk_rpm_fpmdir +++ b/tools/mk_rpm_fpmdir @@ -107,7 +107,7 @@ cat "$@" | while read -a arr ; do fi if $GO_COMPILE && [[ $SRC == "cmd/"* || $SRC == *"/cmd/"* ]]; then echo "========== BUILD© $SRC" - ( cd $(dirname "$SRC" ) && go get -d && go build -a ) + ( cd $(dirname "$SRC" ) && go get -d && go build ) PKGARCH=native else echo "========== COPY $SRC" From 849ec3138b7049c3a062b85056eed191b6698ca2 Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackoverflow.com" Date: Sat, 13 May 2017 11:11:39 -0400 Subject: [PATCH 24/94] blackbox_removeadmin: Disable gpg's confirmation. --- bin/blackbox_removeadmin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/blackbox_removeadmin b/bin/blackbox_removeadmin index 9034977..335353d 100755 --- a/bin/blackbox_removeadmin +++ b/bin/blackbox_removeadmin @@ -22,7 +22,7 @@ remove_line "$BB_ADMINS" "$KEYNAME" # remove the admin key from the pubring -$GPG --no-permission-warning --homedir="$KEYRINGDIR" --delete-key "$KEYNAME" +$GPG --no-permission-warning --homedir="$KEYRINGDIR" --batch --yes --delete-key "$KEYNAME" pubring_path=$(get_pubring_path) vcs_add "$pubring_path" "$KEYRINGDIR/trustdb.gpg" "$BB_ADMINS" From 9c6f13fb8071548b6bd8789a61a9053cec571b95 Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackoverflow.com" Date: Sat, 13 May 2017 11:12:05 -0400 Subject: [PATCH 25/94] blackbox_shred_all_files: BUGFIX: Does not shred files with spaces. --- bin/blackbox_shred_all_files | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/blackbox_shred_all_files b/bin/blackbox_shred_all_files index 07bb56e..c0c9afb 100755 --- a/bin/blackbox_shred_all_files +++ b/bin/blackbox_shred_all_files @@ -24,11 +24,12 @@ echo '========== FILES BEING SHREDDED:' exported_internal_shred_file() { source "$1/_blackbox_common.sh" - unencrypted_file=$(get_unencrypted_filename "$2") - encrypted_file=$(get_encrypted_filename "$unencrypted_file") + unencrypted_file="$2" if [[ -f "$unencrypted_file" ]]; then - echo " $unencrypted_file" + echo " SHRED: $unencrypted_file" shred_file "$unencrypted_file" + else + echo "NOT FOUND: $unencrypted_file" fi } @@ -38,6 +39,6 @@ DEREFERENCED_BIN_DIR="${0%/*}" MAX_PARALLEL_SHRED=10 export IFS= -xargs -I{} -n 1 -P $MAX_PARALLEL_SHRED bash -c "exported_internal_shred_file $DEREFERENCED_BIN_DIR {}" $DEREFERENCED_BIN_DIR/fake <"$BB_FILES" +tr '\n' '\0' <"$BB_FILES" | xargs -0 -I{} -n 1 -P $MAX_PARALLEL_SHRED bash -c "exported_internal_shred_file $DEREFERENCED_BIN_DIR \"{}\"" $DEREFERENCED_BIN_DIR/fake echo '========== DONE.' From eaa6d06b3e5ac4dfa2c31b8c0fea145ac7658d9e Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackoverflow.com" Date: Sat, 13 May 2017 11:12:53 -0400 Subject: [PATCH 26/94] tools/confidence_test.sh: Handle gpg 2.1's new pubring filename. --- tools/confidence_test.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 85dbd93..6619ec0 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -82,7 +82,7 @@ git commit -m'INITIALIZE BLACKBOX' keyrings .gitignore PHASE 'and adds herself as an admin.' blackbox_addadmin alice@example.com -git commit -m'NEW ADMIN: alice@example.com' keyrings/live/pubring.gpg keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt +git commit -m'NEW ADMIN: alice@example.com' keyrings/live/pubring.??? keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt PHASE 'Bob arrives.' @@ -110,13 +110,13 @@ gpg --no-permission-warning --batch --gen-key "$gpgconfig" echo '========== Bob enrolls himself too.' blackbox_addadmin bob@example.com -git commit -m'NEW ADMIN: alice@example.com' keyrings/live/pubring.gpg keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt +git commit -m'NEW ADMIN: alice@example.com' keyrings/live/pubring.??? keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt PHASE 'Alice does the second part to enroll bob.' become_alice PHASE 'She enrolls bob.' -gpg --import keyrings/live/pubring.gpg +gpg --import $(get_pubring_path) # TODO(tlim) That --import can be eliminated... maybe? PHASE 'She enrolls secrets.txt.' @@ -187,7 +187,7 @@ become_bob PHASE 'Bob makes sure he has all new keys.' -gpg --import keyrings/live/pubring.gpg +gpg --import keyrings/live/pubring.??? # Pick a GID to use: # This users's default group: @@ -314,6 +314,7 @@ PHASE 'Bob shreds all exposed files.' assert_file_exists 'my/path/to/relsecrets.txt' assert_file_exists 'secret.txt' blackbox_shred_all_files +which blackbox_shred_all_files assert_file_missing '!important!.txt' assert_file_missing '#andpounds.txt' assert_file_missing 'mistake.txt' From 50ac1697c3100764382a86ba3953f66fb632ae85 Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackoverflow.com" Date: Sun, 14 May 2017 17:52:27 -0400 Subject: [PATCH 27/94] tools/confidence_test.sh: now works with gnupg-2.0 again --- bin/blackbox_removeadmin | 2 +- tools/test_functions.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/blackbox_removeadmin b/bin/blackbox_removeadmin index 335353d..ddd1fb3 100755 --- a/bin/blackbox_removeadmin +++ b/bin/blackbox_removeadmin @@ -22,7 +22,7 @@ remove_line "$BB_ADMINS" "$KEYNAME" # remove the admin key from the pubring -$GPG --no-permission-warning --homedir="$KEYRINGDIR" --batch --yes --delete-key "$KEYNAME" +$GPG --no-permission-warning --homedir="$KEYRINGDIR" --batch --yes --delete-key "$KEYNAME" || true pubring_path=$(get_pubring_path) vcs_add "$pubring_path" "$KEYRINGDIR/trustdb.gpg" "$BB_ADMINS" diff --git a/tools/test_functions.sh b/tools/test_functions.sh index a0177ec..cff230e 100755 --- a/tools/test_functions.sh +++ b/tools/test_functions.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +# NB: This is copied from _blackbox_common.sh +function get_pubring_path() { + : "${KEYRINGDIR:=keyrings/live}" ; + if [[ -f "${KEYRINGDIR}/pubring.gpg" ]]; then + echo "${KEYRINGDIR}/pubring.gpg" + else + echo "${KEYRINGDIR}/pubring.kbx" + fi +} + function PHASE() { echo '********************' echo '********************' From 4bc97049abb07fcc11cee6ca71daf9375d8137da Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackoverflow.com" Date: Sun, 14 May 2017 18:48:59 -0400 Subject: [PATCH 28/94] tools/confidence_test.sh: now works with gnupg-2.0 and gnupg-2.1 --- bin/_blackbox_common.sh | 9 ++++++++- tools/confidence_test.sh | 9 ++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 3249599..c227136 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -163,8 +163,15 @@ function get_encrypted_filename() { # Prepare keychain for use. function prepare_keychain() { + local keyringasc echo '========== Importing keychain: START' >&2 - $GPG --import "$(get_pubring_path)" 2>&1 | egrep -v 'not changed$' >&2 + # Works with gpg 2.0 + #$GPG --import "$(get_pubring_path)" 2>&1 | egrep -v 'not changed$' >&2 + # Works with gpg 2.0 and 2.1 + # NB: We must export the keys to a format that can be imported. + make_self_deleting_tempfile keyringasc + $GPG --export --keyring "$(get_pubring_path)" >"$keyringasc" + $GPG --import "$keyringasc" echo '========== Importing keychain: DONE' >&2 } diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 6619ec0..1f25be9 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -116,8 +116,8 @@ PHASE 'Alice does the second part to enroll bob.' become_alice PHASE 'She enrolls bob.' -gpg --import $(get_pubring_path) -# TODO(tlim) That --import can be eliminated... maybe? +#gpg --import $(get_pubring_path) +## TODO(tlim) That --import can be eliminated... maybe? PHASE 'She enrolls secrets.txt.' blackbox_register_new_file secret.txt @@ -185,9 +185,8 @@ assert_file_md5hash secret.txt "d3e6bbdfc76fae7fd0a921f3408db1d1" PHASE 'appears.' become_bob -PHASE 'Bob makes sure he has all new keys.' - -gpg --import keyrings/live/pubring.??? +#PHASE 'Bob makes sure he has all new keys.' +#gpg --import keyrings/live/pubring.??? # Pick a GID to use: # This users's default group: From 1a22f77c824c32e9f571c72360dce00784894577 Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackoverflow.com" Date: Mon, 15 May 2017 07:50:30 -0400 Subject: [PATCH 29/94] Improve FreeBSD compatibility --- tools/confidence_test.sh | 2 +- tools/test_functions.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 1f25be9..4e69eb7 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -192,7 +192,7 @@ become_bob # This users's default group: DEFAULT_GID_NUM=$(id -g) # Pick a group that is not the default group: -TEST_GID_NUM=$(id -G | fmt -1 | grep -xv "$(id -u)" | grep -xv "$(id -g)" | head -1) +TEST_GID_NUM=$(id -G | fmt -1 | sort -rn | grep -xv "$(id -u)" | grep -xv "$(id -g)" | head -1) echo "DEFAULT_GID_NUM=$DEFAULT_GID_NUM" echo "TEST_GID_NUM=$TEST_GID_NUM" diff --git a/tools/test_functions.sh b/tools/test_functions.sh index cff230e..fda223e 100755 --- a/tools/test_functions.sh +++ b/tools/test_functions.sh @@ -21,7 +21,7 @@ function PHASE() { function md5sum_file() { # Portably generate the MD5 hash of file $1. case $(uname -s) in - Darwin ) + Darwin | FreeBSD ) md5 -r "$1" | awk '{ print $1 }' ;; Linux ) From 7649c9f00b14390e08fb90a4318378058c2d0a3c Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 15 May 2017 11:10:01 -0400 Subject: [PATCH 30/94] Fix https://github.com/StackExchange/blackbox/issues/193 Add unit tests to tools/confidence_test.sh to verify admin operations work. --- bin/blackbox_list_admins | 2 +- tools/confidence_test.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/blackbox_list_admins b/bin/blackbox_list_admins index b90d7cc..465e0a4 100755 --- a/bin/blackbox_list_admins +++ b/bin/blackbox_list_admins @@ -5,4 +5,4 @@ # set -e source "${0%/*}/_blackbox_common.sh" -cat "$BB_ADMINS_FILE" +cat "$BB_ADMINS" diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 4e69eb7..d816e73 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -84,6 +84,10 @@ PHASE 'and adds herself as an admin.' blackbox_addadmin alice@example.com git commit -m'NEW ADMIN: alice@example.com' keyrings/live/pubring.??? keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt +make_self_deleting_tempfile adminlist1 +blackbox_list_admins >"$adminlist1" +assert_file_md5hash "$adminlist1" "aa1db827772e1d51d453b844394b7617" + PHASE 'Bob arrives.' @@ -112,6 +116,10 @@ echo '========== Bob enrolls himself too.' blackbox_addadmin bob@example.com git commit -m'NEW ADMIN: alice@example.com' keyrings/live/pubring.??? keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt +make_self_deleting_tempfile adminlist2 +blackbox_list_admins >"$adminlist2" +assert_file_md5hash "$adminlist2" "0b82b0b3c96e6e5dd5faf60493fe5cf7" + PHASE 'Alice does the second part to enroll bob.' become_alice @@ -217,6 +225,10 @@ PHASE 'Bob removes Alice.' blackbox_removeadmin alice@example.com assert_line_not_exists 'alice@example.com' keyrings/live/blackbox-admins.txt +make_self_deleting_tempfile adminlist3 +blackbox_list_admins >"$adminlist3" +assert_file_md5hash "$adminlist3" "aadbfafd76ea66ff40dbfd239a69067f" + PHASE 'Bob reencrypts files so alice can not access them.' blackbox_update_all_files @@ -391,6 +403,10 @@ fi # Cleanup: blackbox_removeadmin abba@notarealuser.com +make_self_deleting_tempfile adminlist4 +blackbox_list_admins >"$adminlist4" +assert_file_md5hash "$adminlist4" "aadbfafd76ea66ff40dbfd239a69067f" + # TODO: Create a new directory. "git clone" the repo into it. From 09a62cb1d2c49d151628d5423abedb8e361b8d47 Mon Sep 17 00:00:00 2001 From: Robert Taylor Date: Mon, 29 May 2017 23:00:06 +0100 Subject: [PATCH 31/94] Fixing `physical_directory_of` function for cases when target directory lives in root. (#194) --- bin/_blackbox_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index c227136..5feba0e 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -28,7 +28,7 @@ source "${0%/*}"/_stack_lib.sh function physical_directory_of() { local d=$(dirname "$1") local f=$(basename "$1") - (cd "$d" && echo "$(pwd -P)/$f" ) + (cd "$d" && echo "$(pwd -P | sed 's/\/$//')/$f" ) } # Set REPOBASE to the top of the repository From d78faf59d0fc6dca67bf4c60d24a4afacf8bfd20 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 29 May 2017 19:09:36 -0400 Subject: [PATCH 32/94] tools/confidence_test.sh: Set pinentry program to pinentry-tty --- tools/confidence_test.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index d816e73..5e10d11 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../bin -export PATH="${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin" +export PATH="${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin:${blackbox_home}" set -e . _stack_lib.sh @@ -19,10 +19,15 @@ cd "$test_repository" make_self_deleting_tempdir fake_alice_home make_self_deleting_tempdir fake_bob_home export GNUPGHOME="$fake_alice_home" +#echo 'pinentry-program' "$(which pinentry-insecure-fake)" >> "$GNUPGHOME/gpg-agent.conf" +echo 'pinentry-program' "$(which pinentry-tty)" >> "$GNUPGHOME/gpg-agent.conf" +#pinentry-program "${blackbox_home}/pinentry-fake-insecure" eval "$(gpg-agent --homedir "$fake_alice_home" --daemon)" GPG_AGENT_INFO_ALICE="$GPG_AGENT_INFO" export GNUPGHOME="$fake_bob_home" +#echo 'pinentry-program' "$(which pinentry-insecure-fake)" >> "$GNUPGHOME/gpg-agent.conf" +echo 'pinentry-program' "$(which pinentry-tty)" >> "$GNUPGHOME/gpg-agent.conf" eval "$(gpg-agent --homedir "$fake_bob_home" --daemon)" GPG_AGENT_INFO_BOB="$GPG_AGENT_INFO" From 48cc17ac0a7622c3bacc109e34ed8d5ff58a3690 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 29 May 2017 19:31:26 -0400 Subject: [PATCH 33/94] "make test" now uses "expect" to not prompt for passwords. --- Makefile | 3 +-- tools/auto_system_test | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 tools/auto_system_test diff --git a/Makefile b/Makefile index 1d973ee..645cf86 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,6 @@ test: confidence confidence: @if [ -e ~/.gnupg ]; then echo ERROR: '~/.gnupg should not exist. If it does, bugs may polute your .gnupg configuration. If the code has no bugs everything will be fine. Do you feel lucky?'; false ; fi @if which >/dev/null gpg-agent ; then pkill gpg-agent ; rm -rf /tmp/tmp.* ; fi - @export PATH="$(PWD)/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin:$(PATH)" ; tools/confidence_test.sh - tools/confidence_test.sh + @export PATH="$(PWD)/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin:$(PATH)" ; tools/auto_system_test @if which >/dev/null gpg-agent ; then pkill gpg-agent ; fi @if [ -e ~/.gnupg ]; then echo ERROR: '~/.gnupg was created which means the scripts might be poluting GnuPG configuration. Fix this bug.'; false ; fi diff --git a/tools/auto_system_test b/tools/auto_system_test new file mode 100755 index 0000000..eefc38c --- /dev/null +++ b/tools/auto_system_test @@ -0,0 +1,14 @@ +#!/usr/bin/env expect + +spawn tools/confidence_test.sh + +set times 0; +while { $times < 300 } { + expect { + "my password is the lowercase letter a" { set pw "a\n" ; exp_continue } + "my password is the lowercase letter b" { set pw "b\n" ; exp_continue } + "Passphrase:" { send $pw ; exp_continue } + eof { break } + } + set times [ expr $times+1]; +} From 7029e44453c46013d5673fabeeafec2109df2501 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 29 May 2017 19:37:56 -0400 Subject: [PATCH 34/94] tools/confidence_test.sh: "export LANG=C.UTF-8" to be safe. --- tools/confidence_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 5e10d11..156e68d 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -3,6 +3,8 @@ blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../bin export PATH="${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin:${blackbox_home}" +export LANG=C.UTF-8 + set -e . _stack_lib.sh . tools/test_functions.sh From 800fe098a6977d96fb56185692ab7b227ef55c17 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 29 May 2017 19:39:01 -0400 Subject: [PATCH 35/94] "gpg --export" should export LANG=C.UTF-8 to be safe. --- bin/_blackbox_common.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 5feba0e..b245eb5 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -170,6 +170,7 @@ function prepare_keychain() { # Works with gpg 2.0 and 2.1 # NB: We must export the keys to a format that can be imported. make_self_deleting_tempfile keyringasc + export LANG="C.UTF-8" $GPG --export --keyring "$(get_pubring_path)" >"$keyringasc" $GPG --import "$keyringasc" echo '========== Importing keychain: DONE' >&2 From 9006c04c6693f9f0788a83aaf4e31060c80a13c7 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 1 Jun 2017 09:48:13 -0400 Subject: [PATCH 36/94] tools/auto_system_test: Add comments. --- tools/auto_system_test | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/auto_system_test b/tools/auto_system_test index eefc38c..61e9fb0 100755 --- a/tools/auto_system_test +++ b/tools/auto_system_test @@ -1,13 +1,24 @@ #!/usr/bin/env expect +# Run the confidence test non-interactively. Since the script +# asks for passphrases, we use "expect" to simulate keyboard data entry. + +# Run the test: spawn tools/confidence_test.sh +# As we run the confidence test, respond with the right password. +# We do this for up to 300 times to prevent an infinite loop. + set times 0; while { $times < 300 } { expect { + # The script outputs what the password will be, and we save + # that info in $pw any time we see the text. "my password is the lowercase letter a" { set pw "a\n" ; exp_continue } "my password is the lowercase letter b" { set pw "b\n" ; exp_continue } + # If the passphrase is requested, send it. "Passphrase:" { send $pw ; exp_continue } + # If we reach EOF, exit this loop. eof { break } } set times [ expr $times+1]; From 7c4fa4f4bed91a1324b95001fb7cb9c646fc1291 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 1 Jun 2017 09:48:25 -0400 Subject: [PATCH 37/94] tools/confidence_test.sh: Add explicit test for external tools. --- tools/confidence_test.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 156e68d..0e9b8f2 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -3,7 +3,25 @@ blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../bin export PATH="${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin:${blackbox_home}" -export LANG=C.UTF-8 +export LANG=C.UTF-8 # Required ro "gpg --export" to work properly. + +# This script requires many utilities, some are not +# required by the usual blackbox scripts. Test to make +# sure we have them all. +e=false +for i in blackbox_addadmin blackbox_list_admins blackbox_register_new_file \ + cat git gpg gpg-agent mkdir pinentry pinentry-tty rm tar which ; do + if ! which >/dev/null 2>&1 $i ; then + echo ERROR: Command not in PATH: $i + e=true + fi +done +if $e ; then + echo 'Exiting. Please install the above commands.' + echo 'This script requires many utilities not required by blackbox itself.' + echo PATH="$PATH" + exit 1 +fi set -e . _stack_lib.sh From 25fd63f7924c0cd8f7f048e3d6696d9e43cf0a89 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sun, 11 Jun 2017 08:34:57 -0400 Subject: [PATCH 38/94] Update CHANGELOG.md --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c123c0c..2eb1ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,3 +9,18 @@ Release v1.20170309 * macOS: make_tempdir must create shorter paths * Fix "make confidence" for newer version of Git * README.md: Add info about our new mailing list + +Release v1.20170611 + +* confidence_test.sh verifies external tools exist +* confidence_test.sh more reliable for non-UTF8 users +* "make test" no longer prompts for passwords +* blackbox works better when target directory lives in root (#194) +* Add confidence_test.sh tests for admin operations +* blackbox_list_admins fails (#193) +* confidence_test.sh works better on FreeBSD +* tools/confidence_test.sh: now works with gnupg-2.0 and gnupg-2.1 +* Blackbox now officially supports both gnupg-2.0 and gnupg-2.1 +* blackbox_shred_all_files: BUGFIX: Does not shred files with spaces +* blackbox_removeadmin: disable gpg's confirmation +* Sync mk_rpm_fpmdir from master From 99662833686aa8cab2f527481c2a37067bceb2b0 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 16 Jun 2017 08:16:07 -0400 Subject: [PATCH 39/94] Blackbox should work with Windows better WRT crlf. --- README.md | 110 ++++++++++++++++++++++++++-------------- bin/blackbox_initialize | 11 ++++ 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index c5e4e2c..546927e 100644 --- a/README.md +++ b/README.md @@ -14,24 +14,25 @@ Table of Contents - [Table of Contents](#table-of-contents) - [Overview](#overview) - [Why is this important?](#why-is-this-important) -- [Installation Instructions:](#installation-instructions) -- [Commands:](#commands) -- [Compatibility:](#compatibility) +- [Installation Instructions](#installation-instructions) +- [Commands](#commands) +- [Compatibility](#compatibility) - [How is the encryption done?](#how-is-the-encryption-done) - [What does this look like to the typical user?](#what-does-this-look-like-to-the-typical-user) - [How to use the secrets with Puppet?](#how-to-use-the-secrets-with-puppet) - - [Entire files:](#entire-files) - - [Small strings:](#small-strings) + - [Entire files](#entire-files) + - [Small strings](#small-strings) - [How to enroll a new file into the system?](#how-to-enroll-a-new-file-into-the-system) - [How to remove a file from the system?](#how-to-remove-a-file-from-the-system) - [How to indoctrinate a new user into the system?](#how-to-indoctrinate-a-new-user-into-the-system) - [How to remove a user from the system?](#how-to-remove-a-user-from-the-system) - [Enabling Blackbox For a Repo](#enabling-blackbox-for-a-repo) - [Set up automated users or “role accounts”](#set-up-automated-users-or-role-accounts) -- [Replace expired keys:](#replace-expired-keys) -- [Some common errors:](#some-common-errors) +- [Replace expired keys](#replace-expired-keys) +- [Some common errors](#some-common-errors) +- [Using Blackbox on Windows](#using-blackbox-on-windows) - [Using Blackbox without a repo](#using-blackbox-without-a-repo) -- [Some Subversion gotchas:](#some-subversion-gotchas) +- [Some Subversion gotchas](#some-subversion-gotchas) - [How to submit bugs or ask questions?](#how-to-submit-bugs-or-ask-questions) - [Developer Info](#developer-info) - [Alternatives](#alternatives) @@ -60,8 +61,8 @@ NOT SO OBVIOUSLY when we store "secrets" in a VCS repo like Git or Mercurial, su The ability to be open and transparent about our code, with the exception of a few specific files, is key to the kind of collaboration that DevOps and modern IT practitioners need to do. -Installation Instructions: -========================== +Installation Instructions +========================= - *The MacPorts Way*: `sudo port install vcs_blackbox` - *The Homebrew Way*: `brew install blackbox` @@ -72,8 +73,8 @@ Installation Instructions: - *The Antigen Way*: Add `antigen bundle StackExchange/blackbox` to your .zshrc - *The Zgen Way*: Add `zgen load StackExchange/blackbox` to your .zshrc where you're loading your other plugins. -Commands: -========= +Commands +======== | Name: | Description: | |-------------------------------------|-------------------------------------------------------------------------| @@ -95,8 +96,8 @@ Commands: | `blackbox_update_all_files` | Decrypt then re-encrypt all files. Useful after keys are changed | | `blackbox_whatsnew ` | show what has changed in the last commit for a given file | -Compatibility: -============== +Compatibility +============= Blackbox automatically determines which VCS you are using and does the right thing. It has a plug-in architecture to make it easy to extend to work with other systems. It has been tested to work with many operating systems. @@ -109,33 +110,64 @@ Blackbox automatically determines which VCS you are using and does the right thi - Operating system - CentOS / RedHat - MacOS X - - Cygwin (Thanks, Ben Drasin!) + - Cygwin (Thanks, Ben Drasin!) **See Note Below** - MinGW (git bash on windows) **See Note Below** To add or fix support for a VCS system, look for code at the end of `bin/_blackbox_common.sh` To add or fix support for a new operating system, look for the case statements in `bin/_blackbox_common.sh` and `bin/_stack_lib.sh` and maybe `tools/confidence_test.sh` -Note: Cywin support requires the following packages: +Using Blackbox on Windows +========================= -- Normal operation: - - gnupg - - git or mercurial or subversion or perforce (as appropriate) -- Development (if you will be adding code and want to run the confidence test) - - procps - - make - - git (the confidence test currently only tests git) +Blackbox can be used with Cygwin or MinGW. + +### Protect the line endings + +Blackbox assumes that `blackbox-admins.txt` and `blackbox-files.txt` will have +LF line endings. Windows users should be careful to configure Git or other systems +to not convert or "fix" those files. + +If you use Git, add the following lines to your `.gitattributes` file: + + **/blackbox-admins.txt text eol=lf + **/blackbox-files.txt text eol=lf + +The latest version of `blackbox_initialize` will create a `.gitattributes` file in the `$BLACKBOXDATA` +directory (usually `keyrings/live`) for you. + +### Cygwin + +Cygwin support requires the following packages: + +Normal operation: + +- gnupg +- git or mercurial or subversion or perforce (as appropriate) + +Development (if you will be adding code and want to run the confidence test) + +- procps +- make +- git (the confidence test currently only tests git) + +### MinGW + +MinGW (comes with Git for Windows) support requires the following: + +Normal operation: + +- [Git for Windows](https://git-scm.com/) (not tested with Mercurial) + - Git Bash MINTTY returns a MinGW console. So when you install make sure you pick `MINTTY` instead of windows console. You'll be executing blackbox from the Git Bash prompt. + - You need at least version 2.8.1 of Git for Windows. +- [GnuWin32](https://sourceforge.net/projects/getgnuwin32/files/) - needed for various tools not least of which is mktemp which is used by blackbox + - after downloading the install just provides you with some batch files. Because of prior issues at sourceforge and to make sure you get the latest version of each package the batch files handle the brunt of the work of getting the correct packages and installing them for you. + - from a **windows command prompt** run `download.bat` once it has completed run `install.bat` then add the path for those tools to your PATH (ex: `PATH=%PATH%;c:\GnuWin32\bin`) + +Development: + +- unknown (if you develop Blackbox under MinGW, please let us know if any additional packages are required to run `make test`) -Note: MinGW (comes with Git for Windows) support requires the following additional installations -- Normal operation: - - [Git for Windows](https://git-scm.com/) (not tested with Mercurial) - - Git Bash MINTTY returns a MinGW console. So when you install make sure you pick `MINTTY` instead of windows console. You'll be executing blackbox from the Git Bash prompt. - - You need at least version 2.8.1 of Git for Windows. - - [GnuWin32](https://sourceforge.net/projects/getgnuwin32/files/) - needed for various tools not least of which is mktemp which is used by blackbox - - after downloading the install just provides you with some batch files. Because of prior issues at sourceforge and to make sure you get the latest version of each package the batch files handle the brunt of the work of getting the correct packages and installing them for you. - - from a **windows command prompt** run `download.bat` once it has completed run `install.bat` then add the path for those tools to your PATH (ex: `PATH=%PATH%;c:\GnuWin32\bin`) -- Development: - - unknown How is the encryption done? =========================== @@ -568,8 +600,8 @@ rm -rf /tmp/NEWMASTER Also shred any other temporary files you may have made. -Replace expired keys: -===================== +Replace expired keys +==================== If any one admin's key expires, you can no longer encrypt files. You will need to replace the key and re-encrypt. @@ -636,8 +668,8 @@ It's possible to tell Git to decrypt versions of the file before running them th And now commands like `git log -p file.gpg` will show a nice log of the changes in the encrypted file. -Some common errors: -=================== +Some common errors +================== `gpg: filename: skipped: No public key` -- Usually this means there is an item in `keyrings/live/blackbox-admins.txt` that is not the name of the key. Either something invalid was inserted (like a filename instead of a username) or a user has left the organization and their key was removed from the keychain, but their name wasn't removed from the blackbox-admins.txt file. @@ -656,8 +688,8 @@ The following commands have been tested outside a repo: - `blackbox_edit_start` - `blackbox_edit_end` -Some Subversion gotchas: -======================== +Some Subversion gotchas +======================= The current implementation will store the blackbox in `/keyrings` at the root of the entire repo. this will create an issue between environments that have different roots (ie, checking out `/` on development vs `/releases/foo` in production). To get around this, you can `export BLACKBOX_REPOBASE=/path/to/repo` and set a specific base for your repo. diff --git a/bin/blackbox_initialize b/bin/blackbox_initialize index 4855e9f..6ba50a3 100755 --- a/bin/blackbox_initialize +++ b/bin/blackbox_initialize @@ -35,6 +35,17 @@ vcs_add "${KEYRINGDIR}" touch "$BLACKBOXDATA/$BB_ADMINS_FILE" "$BLACKBOXDATA/$BB_FILES_FILE" vcs_add "$BLACKBOXDATA/$BB_ADMINS_FILE" "$BLACKBOXDATA/$BB_FILES_FILE" +if [[ $VCS_TYPE = "git" ]]; then + + # Set .gitattributes so that Windows users don't break the admin files. + FILE="$BLACKBOXDATA/.gitattributes" + LINE='blackbox-admins.txt text eol=lf' + grep -qF "$LINE" "$FILE" || echo "$LINE" >> "$FILE" + LINE='blackbox-files.txt text eol=lf' + grep -qF "$LINE" "$FILE" || echo "$LINE" >> "$FILE" + +fi + if [[ $VCS_TYPE = "svn" ]]; then echo echo From 9468ea69ec4f08919ca0cb65bbab218fe5f2fe22 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 16 Jun 2017 12:04:08 -0400 Subject: [PATCH 40/94] Improve info about expired GPG keys. --- README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 546927e..cab527f 100644 --- a/README.md +++ b/README.md @@ -600,18 +600,27 @@ rm -rf /tmp/NEWMASTER Also shred any other temporary files you may have made. -Replace expired keys -==================== +Replacing expired keys +====================== -If any one admin's key expires, you can no longer encrypt files. You will need to replace the key and re-encrypt. - -- Step 0: You see this error: +If someone's key has already expired, blackbox will stop +encrypting. You see this error: ``` $ blackbox_edit_end modified_file.txt --> Error: can't re-encrypt because a key has expired. ``` +You can also detect keys that are about to expire by issuing this command and manually reviewing the "expired:" dates: + + gpg --homedir=keyrings/live --list-keys + +or... list UIDs that will expire within 1 month from today: (Warning: this also lists keys without an expiration date) + + gpg --homedir=keyrings/live --list-keys --with-colons --fixed-list-mode | grep ^uid | awk -F: '$6 < '$(( $(date +%s) + 2592000)) + +Here's how to replace the key: + - Step 1. Administrator removes expired user: Warning: This process will erase any unencrypted files that you were in the process of editing. Copy them elsewhere and restore the changes when done. From c91b29be12809f6cd17b98affd400be6fadfc5dd Mon Sep 17 00:00:00 2001 From: Jinn Koriech Date: Tue, 4 Jul 2017 15:32:48 +0100 Subject: [PATCH 41/94] Silence 'not changed' output during keychain import (#200) Previously the keychain import appears to have redirected stderr to stdout, silenced lines that indicate a key has 'not changed' then send the output back to stdout. This behaviour has been carried over to the new GnuPG-2.1 compatible implementation. --- bin/_blackbox_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index b245eb5..ffc60ca 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -172,7 +172,7 @@ function prepare_keychain() { make_self_deleting_tempfile keyringasc export LANG="C.UTF-8" $GPG --export --keyring "$(get_pubring_path)" >"$keyringasc" - $GPG --import "$keyringasc" + $GPG --import "$keyringasc" 2>&1 | egrep -v 'not changed$' >&2 echo '========== Importing keychain: DONE' >&2 } From a3032aec07fcf429d35326ae3e6e0d23b9a6d4dc Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 14 Jul 2017 14:38:00 -0400 Subject: [PATCH 42/94] NEW: .gitattributes Set Unix-only files to eol=lf --- .gitattributes | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0ddce6a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +bin/** text eol=lf +tools/** text eol=lf +Makefile text eol=lf +Portfile text eol=lf +blackbox.plugin.zsh text eol=lf From ced82815cfa85c25fef4984b43e77e9baddfb90a Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Tue, 8 Aug 2017 09:56:23 -0400 Subject: [PATCH 43/94] Improve tip about storing GPG keys --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cab527f..6e5963c 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,7 @@ If you don't already have a GPG key, here's how to generate one: gpg --gen-key ``` -Pick defaults for encryption settings, 0 expiration. Pick a VERY GOOD passphrase. Store the private key securely. Tip: Store it on a secure machine, or one with little or no internet access, with full-disk-encryption, etc. Your employer problably has rules about how to store such things. +Pick defaults for encryption settings, 0 expiration. Pick a VERY GOOD passphrase. Store a backup of the private key someplace secure. For example, keep the backup copy on a USB drive that is locked in safe. Or, at least put it on a machine secure machine with little or no internet access, full-disk-encryption, etc. Your employer problably has rules about how to store such things. Now that you have a GPG key, add yourself as an admin: From b483f65c0ba5b599c5043b8b0875016db405586f Mon Sep 17 00:00:00 2001 From: Patrick Sanders Date: Thu, 17 Aug 2017 11:57:04 -0400 Subject: [PATCH 44/94] direct repobase message to stderr (#204) --- bin/_blackbox_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index ffc60ca..3f721f3 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -63,7 +63,7 @@ export REPOBASE=$(physical_directory_of "$REPOBASE") # after determining what we believe to be the answer. if [[ -n "$BLACKBOX_REPOBASE" ]]; then - echo "Using custom repobase: $BLACKBOX_REPOBASE" + echo "Using custom repobase: $BLACKBOX_REPOBASE" >&2 export REPOBASE="$BLACKBOX_REPOBASE" fi From 4528796279d9ab3f83260a8cf603d154f129f31d Mon Sep 17 00:00:00 2001 From: BHC Date: Tue, 22 Aug 2017 18:29:15 +0100 Subject: [PATCH 45/94] Update license year (#205) to 2017 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index dc32fd7..f7a72c7 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2016 Stack Exchange, Inc. +Copyright (c) 2014-2017 Stack Exchange, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 0ec0cd3762cd661c9e0b9832eb544211c1766f7c Mon Sep 17 00:00:00 2001 From: Paul Romero Date: Thu, 24 Aug 2017 12:23:09 +0100 Subject: [PATCH 46/94] Formatting improvements (#208) Converted raw URLs to links --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6e5963c..5bc6789 100644 --- a/README.md +++ b/README.md @@ -745,11 +745,11 @@ Alternatives Here are other open source packages that do something similar to Blackbox. If you like them better than Blackbox, please use them. -- git-crypt: https://www.agwa.name/projects/git-crypt/ -- Pass: http://www.zx2c4.com/projects/password-store/ -- Transcrypt: https://github.com/elasticdog/transcrypt -- Keyringer: https://keyringer.pw/ -- git-secret: https://github.com/sobolevn/git-secret +- [git-crypt](https://www.agwa.name/projects/git-crypt/) +- [Pass](http://www.zx2c4.com/projects/password-store/) +- [Transcrypt](https://github.com/elasticdog/transcrypt) +- [Keyringer](https://keyringer.pw/) +- [git-secret](https://github.com/sobolevn/git-secret) git-crypt has the best git integration. Once set up it is nearly transparent to the users. However it only works with git. From c60ca184f31d00a6c10cf38115681fa6ba1094db Mon Sep 17 00:00:00 2001 From: Jessica Evans <31384125+jessicalinux@users.noreply.github.com> Date: Mon, 28 Aug 2017 12:24:27 +0100 Subject: [PATCH 47/94] Made LICENSE link (#210) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bc6789..866249f 100644 --- a/README.md +++ b/README.md @@ -756,4 +756,4 @@ git-crypt has the best git integration. Once set up it is nearly transparent to License ======= -This content is released under the MIT License. See the LICENSE.txt file. +This content is released under the MIT License. See the [LICENSE.txt](LICENSE.txt) file. From 0626efa7e8e8a46ef69dd54ec1fc1fe4302e02fb Mon Sep 17 00:00:00 2001 From: James Gregory Date: Fri, 1 Sep 2017 22:01:20 +1000 Subject: [PATCH 48/94] Fixed Alpine compatibility (chmod) (#212) --- bin/_blackbox_common.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 3f721f3..fcc37d8 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -408,8 +408,12 @@ function cp_permissions() { chmod $( stat -f '%p' "$1" | sed -e "s/^100//" ) "${@:2}" ;; Linux | CYGWIN* | MINGW* ) - chmod --reference "$1" "${@:2}" - ;; + if [[ -e /etc/alpine-release ]]; then + chmod $( stat -c '%a' "$1" ) "${@:2}" + else + chmod --reference "$1" "${@:2}" + fi + ;; * ) echo 'ERROR: Unknown OS. Exiting. (cp_permissions)' exit 1 From 2e894ea86f889b0490e4ad7f100fe3d86cb5eba1 Mon Sep 17 00:00:00 2001 From: Aymeric Beaumet Date: Fri, 15 Sep 2017 17:15:12 +0200 Subject: [PATCH 49/94] Run the tests on a CI (#215) * Add CircleCI and make tests pass on ubuntu:16.04 * Add badge to readme * Add debian stable to CircleCI * Fix pkill on CircleCI debian --- .circleci/config.yml | 56 ++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- tools/confidence_test.sh | 2 +- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..65fff28 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,56 @@ +version: 2 + +workflows: + version: 2 + ci: + jobs: + - debian + - ubuntu + +jobs: + + debian: + docker: + - image: debian:9.1 + steps: + - checkout + - run: + name: 'Installing' + command: | + apt-get update -y + apt-get install -y build-essential expect git gnupg2 pinentry-tty procps rpm ruby-dev + gem install fpm + - run: + name: 'Cleaning' + command: | + rm -rf ~/.gpnupg + make clean + - run: + name: 'Testing' + command: | + GPG=gpg2 make test + make packages-deb + make packages-rpm + + ubuntu: + docker: + - image: ubuntu:16.04 + steps: + - checkout + - run: + name: 'Installing' + command: | + apt-get update -y + apt-get install -y build-essential expect git gnupg2 pinentry-tty procps rpm ruby-dev + gem install fpm + - run: + name: 'Cleaning' + command: | + rm -rf ~/.gpnupg + make clean + - run: + name: 'Testing' + command: | + GPG=gpg2 make test + make packages-deb + make packages-rpm \ No newline at end of file diff --git a/README.md b/README.md index 866249f..a82c982 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -BlackBox +BlackBox ![CircleCI](https://circleci.com/gh/StackExchange/blackbox.svg?style=shield) ======== Safely store secrets in a VCS repo (i.e. Git, Mercurial, Subversion or Perforce). These commands make it easy for you to Gnu Privacy Guard (GPG) encrypt specific files in a repo so they are "encrypted at rest" in your repository. However, the scripts make it easy to decrypt them when you need to view or edit them, and decrypt them for use in production. Originally written for Puppet, BlackBox now works with any Git or Mercurial repository. diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 0e9b8f2..abca0a7 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -225,7 +225,7 @@ become_bob # This users's default group: DEFAULT_GID_NUM=$(id -g) # Pick a group that is not the default group: -TEST_GID_NUM=$(id -G | fmt -1 | sort -rn | grep -xv "$(id -u)" | grep -xv "$(id -g)" | head -1) +TEST_GID_NUM=$(grep -v "$DEFAULT_GID_NUM" /etc/group | cut -d: -f3 | sort -rn | head -1) echo "DEFAULT_GID_NUM=$DEFAULT_GID_NUM" echo "TEST_GID_NUM=$TEST_GID_NUM" From 3cbfb2ba8c8682e415869d867ca9c05a96596167 Mon Sep 17 00:00:00 2001 From: Aymeric Beaumet Date: Fri, 15 Sep 2017 17:40:39 +0200 Subject: [PATCH 50/94] Update readme with CircleCI link (#216) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a82c982..40d08f2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -BlackBox ![CircleCI](https://circleci.com/gh/StackExchange/blackbox.svg?style=shield) +BlackBox [![CircleCI](https://circleci.com/gh/StackExchange/blackbox.svg?style=shield)](https://circleci.com/gh/StackExchange/workflows/blackbox) ======== Safely store secrets in a VCS repo (i.e. Git, Mercurial, Subversion or Perforce). These commands make it easy for you to Gnu Privacy Guard (GPG) encrypt specific files in a repo so they are "encrypted at rest" in your repository. However, the scripts make it easy to decrypt them when you need to view or edit them, and decrypt them for use in production. Originally written for Puppet, BlackBox now works with any Git or Mercurial repository. From 53cc02e419aff6497c4bebe480e4f70d6995d52c Mon Sep 17 00:00:00 2001 From: Paul Romero Date: Fri, 15 Sep 2017 17:00:30 +0100 Subject: [PATCH 51/94] Corrected English in README (#209) Nonsensical English corrected --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40d08f2..90f2bb7 100644 --- a/README.md +++ b/README.md @@ -711,7 +711,7 @@ We welcome questions, bug reports and feedback! The best place to start is to join the [blackbox-project mailing list](https://groups.google.com/d/forum/blackbox-project) and ask there. -Bugs are tracked here in Github. Please feel free to files bugs yourself: +Bugs are tracked here in Github. Please feel free to report bugs yourself: - https://github.com/StackExchange/blackbox/issues From 57b5f59ca75589363c378475fbd96584941d6a65 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sat, 16 Sep 2017 10:40:12 -0400 Subject: [PATCH 52/94] Fixing circleci --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 65fff28..afd4d30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 workflows: version: 2 - ci: + build_and_test: jobs: - debian - ubuntu @@ -53,4 +53,4 @@ jobs: command: | GPG=gpg2 make test make packages-deb - make packages-rpm \ No newline at end of file + make packages-rpm From 318e21b4c8bcbbfa0f3d112c6fe09911f4263b8e Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sat, 16 Sep 2017 10:54:11 -0400 Subject: [PATCH 53/94] Add CircleCI badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 90f2bb7..cad8d5b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ A slide presentation about an older release [is on SlideShare](http://www.slides Join our mailing list: [https://groups.google.com/d/forum/blackbox-project](https://groups.google.com/d/forum/blackbox-project) +[![CircleCI](https://circleci.com/gh/StackExchange/blackbox.svg?style=svg)](https://circleci.com/gh/StackExchange/blackbox) + Table of Contents ================= From ca99a1ebb41eaa0ad489ad2121da2fb3ea500efa Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sat, 16 Sep 2017 11:07:51 -0400 Subject: [PATCH 54/94] Revert redundant circleci badge --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index cad8d5b..90f2bb7 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ A slide presentation about an older release [is on SlideShare](http://www.slides Join our mailing list: [https://groups.google.com/d/forum/blackbox-project](https://groups.google.com/d/forum/blackbox-project) -[![CircleCI](https://circleci.com/gh/StackExchange/blackbox.svg?style=svg)](https://circleci.com/gh/StackExchange/blackbox) - Table of Contents ================= From 103106e08fce643b4ec62fccc7b1adf9ee44c517 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sun, 17 Sep 2017 17:39:14 -0400 Subject: [PATCH 55/94] "make clean" should be idempotent. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 645cf86..2c3c14c 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ uninstall-stow: update: tools/mk_deb_fpmdir.stack_blackbox.txt tools/mk_macports.vcs_blackbox.txt clean: - rm tools/mk_deb_fpmdir.stack_blackbox.txt tools/mk_macports.vcs_blackbox.txt + rm -f tools/mk_deb_fpmdir.stack_blackbox.txt tools/mk_macports.vcs_blackbox.txt # # System Test: From 60e782a09e291a15da426b32ef36fdab9d2196d7 Mon Sep 17 00:00:00 2001 From: Aymeric Beaumet Date: Mon, 18 Sep 2017 00:13:36 +0200 Subject: [PATCH 56/94] Store keys in .blackbox directory (#218) --- README.md | 40 ++++++++++++++++++++-------------------- bin/_blackbox_common.sh | 19 ++++++++++++++++--- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 90f2bb7..8a62589 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ If you use Git, add the following lines to your `.gitattributes` file: **/blackbox-files.txt text eol=lf The latest version of `blackbox_initialize` will create a `.gitattributes` file in the `$BLACKBOXDATA` -directory (usually `keyrings/live`) for you. +directory (usually `.blackbox`) for you. ### Cygwin @@ -293,7 +293,7 @@ blackbox_deregister_file path/to/file.name.key How to indoctrinate a new user into the system? =============================================== -`keyrings/live/blackbox-admins.txt` is a file that lists which users are able to decrypt files. (More pedantically, it is a list of the GnuPG key names that the file is encrypted for.) +`.blackbox/blackbox-admins.txt` is a file that lists which users are able to decrypt files. (More pedantically, it is a list of the GnuPG key names that the file is encrypted for.) To join the list of people that can edit the file requires three steps; You create a GPG key and add it to the key ring. Then, someone that already has access adds you to the system. Lastly, you should test your access. @@ -322,7 +322,7 @@ blackbox_addadmin tal@example.com When the command completes successfully, instructions on how to commit these changes will be output. Run the command as given to commit the changes. It will look like this: ``` -git commit -m'NEW ADMIN: tal@example.com' keyrings/live/pubring.gpg keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt +git commit -m'NEW ADMIN: tal@example.com' .blackbox/pubring.gpg .blackbox/trustdb.gpg .blackbox/blackbox-admins.txt ``` Then push it to the repo: @@ -346,7 +346,7 @@ Ask someone that already has access to re-encrypt the data files. This gives you Pre-check: Verify the new keys look good. ``` -$ gpg --homedir=keyrings/live --list-keys +$ gpg --homedir=.blackbox --list-keys ``` For example, examine the key name (email address) to make sure it conforms to corporate standards. @@ -354,7 +354,7 @@ For example, examine the key name (email address) to make sure it conforms to co Import the keychain into your personal keychain and reencrypt: ``` -gpg --import keyrings/live/pubring.gpg +gpg --import .blackbox/pubring.gpg blackbox_update_all_files ``` @@ -391,9 +391,9 @@ When the command completes, you will be given a reminder to check in the change Note that their keys will still be in the key ring, but they will go unused. If you'd like to clean up the keyring, use the normal GPG commands and check in the file. ``` -gpg --homedir=keyrings/live --list-keys -gpg --homedir=keyrings/live --delete-key olduser@example.com -git commit -m'Cleaned olduser@example.com from keyring' keyrings/live/* +gpg --homedir=.blackbox --list-keys +gpg --homedir=.blackbox --delete-key olduser@example.com +git commit -m'Cleaned olduser@example.com from keyring' .blackbox/* ``` The key ring only has public keys. There are no secret keys to delete. @@ -540,12 +540,12 @@ cd ~/.gnupg && tar xpvf /tmp/keys.tar Back on SECUREHOST, import the pubkey into the repository. ``` -$ cd keyrings/live +$ cd .blackbox $ gpg --homedir . --import /tmp/NEWMASTER/pubkey.txt ``` --> -Back on SECUREHOST, add the new email address to keyrings/live/blackbox-admins.txt: +Back on SECUREHOST, add the new email address to .blackbox/blackbox-admins.txt: ``` cd /path/to/the/repo @@ -555,14 +555,14 @@ blackbox_addadmin $KEYNAME /tmp/NEWMASTER Verify that secring.gpg is a zero-length file. If it isn't, you have somehow added a private key to the keyring. Start over. ``` -$ cd keyrings/live +$ cd .blackbox $ ls -l secring.gpg ``` Commit the recent changes: ``` -$ cd keyrings/live +$ cd .blackbox git commit -m"Adding key for KEYNAME" pubring.gpg trustdb.gpg blackbox-admins.txt ``` @@ -579,7 +579,7 @@ On NEWMASTER, import the keys and decrypt the files: ``` sudo -u svc_sadeploy bash # Become the role account. -gpg --import /etc/puppet/keyrings/live/pubring.gpg +gpg --import /etc/puppet/.blackbox/pubring.gpg export PATH=$PATH:/path/to/blackbox/bin blackbox_postdeploy sudo -u puppet cat /etc/puppet/hieradata/blackbox.yaml # or any encrypted file. @@ -613,11 +613,11 @@ $ blackbox_edit_end modified_file.txt You can also detect keys that are about to expire by issuing this command and manually reviewing the "expired:" dates: - gpg --homedir=keyrings/live --list-keys + gpg --homedir=.blackbox --list-keys or... list UIDs that will expire within 1 month from today: (Warning: this also lists keys without an expiration date) - gpg --homedir=keyrings/live --list-keys --with-colons --fixed-list-mode | grep ^uid | awk -F: '$6 < '$(( $(date +%s) + 2592000)) + gpg --homedir=.blackbox --list-keys --with-colons --fixed-list-mode | grep ^uid | awk -F: '$6 < '$(( $(date +%s) + 2592000)) Here's how to replace the key: @@ -630,8 +630,8 @@ blackbox_removeadmin expired_user@example.com # This next command overwrites any changed unencrypted files. See warning above. blackbox_update_all_files git commit -m "Re-encrypt all files" -gpg --homedir=keyrings/live --delete-key expired_user@example.com -git commit -m 'Cleaned expired_user@example.com from keyring' keyrings/live/* +gpg --homedir=.blackbox --delete-key expired_user@example.com +git commit -m 'Cleaned expired_user@example.com from keyring' .blackbox/* git push ``` @@ -640,7 +640,7 @@ git push ``` git pull blackbox_addadmin updated_user@example.com -git commit -m'NEW ADMIN: updated_user@example.com keyrings/live/pubring.gpg keyrings/live/trustdb.gpg keyrings/live/blackbox-admins.txt +git commit -m'NEW ADMIN: updated_user@example.com .blackbox/pubring.gpg .blackbox/trustdb.gpg .blackbox/blackbox-admins.txt git push ``` @@ -648,7 +648,7 @@ git push ``` git pull -gpg --import keyrings/live/pubring.gpg +gpg --import .blackbox/pubring.gpg blackbox_update_all_files git commit -m "Re-encrypt all files" git push @@ -680,7 +680,7 @@ And now commands like `git log -p file.gpg` will show a nice log of the changes Some common errors ================== -`gpg: filename: skipped: No public key` -- Usually this means there is an item in `keyrings/live/blackbox-admins.txt` that is not the name of the key. Either something invalid was inserted (like a filename instead of a username) or a user has left the organization and their key was removed from the keychain, but their name wasn't removed from the blackbox-admins.txt file. +`gpg: filename: skipped: No public key` -- Usually this means there is an item in `.blackbox/blackbox-admins.txt` that is not the name of the key. Either something invalid was inserted (like a filename instead of a username) or a user has left the organization and their key was removed from the keychain, but their name wasn't removed from the blackbox-admins.txt file. `gpg: decryption failed: No secret key` -- Usually means you forgot to re-encrypt the file with the new key. diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index fcc37d8..08671e5 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -15,9 +15,12 @@ source "${0%/*}"/_stack_lib.sh # Where are we? : "${BLACKBOX_HOME:="$(cd "${0%/*}" ; pwd)"}" ; -# Where in the VCS repo should the blackbox data be found? -: "${BLACKBOXDATA:=keyrings/live}" ; # If BLACKBOXDATA not set, set it. - +# What are the candidates for the blackbox data directory? +declare -a BLACKBOXDATA_CANDIDATES +BLACKBOXDATA_CANDIDATES=( + 'keyrings/live' + '.blackbox' +) # If $EDITOR is not set, set it to "vi": : "${EDITOR:=vi}" ; @@ -67,6 +70,16 @@ if [[ -n "$BLACKBOX_REPOBASE" ]]; then export REPOBASE="$BLACKBOX_REPOBASE" fi +if [ -z "$BLACKBOXDATA" ] ; then + BLACKBOXDATA="${BLACKBOXDATA_CANDIDATES[0]}" + for candidate in ${BLACKBOXDATA_CANDIDATES[@]} ; do + if [ -d "$REPOBASE/$candidate" ] ; then + BLACKBOXDATA="$candidate" + break + fi + done +fi + KEYRINGDIR="$REPOBASE/$BLACKBOXDATA" BB_ADMINS_FILE="blackbox-admins.txt" BB_ADMINS="${KEYRINGDIR}/${BB_ADMINS_FILE}" From 972abfc03f46a8ebfaab4928120af35070ab6bb2 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 18 Sep 2017 17:31:02 -0400 Subject: [PATCH 57/94] CI --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a62589..cfc9591 100644 --- a/README.md +++ b/README.md @@ -756,4 +756,5 @@ git-crypt has the best git integration. Once set up it is nearly transparent to License ======= -This content is released under the MIT License. See the [LICENSE.txt](LICENSE.txt) file. +This content is released under the MIT License. +See the [LICENSE.txt](LICENSE.txt) file. From 043b66dc50d8c0aeb06326ef0a4af05bef73b36a Mon Sep 17 00:00:00 2001 From: Jon Bardin Date: Tue, 7 Nov 2017 07:52:34 -0800 Subject: [PATCH 58/94] Fixes issue were .gitignore is not included in the commit when you register new file (#206) * this should fix the .gitignore not be including in the commit when registering a new file --- bin/blackbox_register_new_file | 2 +- bin/blackbox_shred_all_files | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/blackbox_register_new_file b/bin/blackbox_register_new_file index 288b8ae..0a49aad 100755 --- a/bin/blackbox_register_new_file +++ b/bin/blackbox_register_new_file @@ -44,7 +44,7 @@ function register_new_file() { vcs_ignore "$unencrypted_file" echo 'NOTE: "already tracked!" messages are safe to ignore.' vcs_add "$BB_FILES" "$encrypted_file" - vcs_commit "registered in blackbox: ${unencrypted_file}" "$BB_FILES" "$encrypted_file" + vcs_commit "registered in blackbox: ${unencrypted_file}" "$BB_FILES" "$encrypted_file" "$(vcs_ignore_file_path)" } for target in "$@"; do diff --git a/bin/blackbox_shred_all_files b/bin/blackbox_shred_all_files index c0c9afb..668c657 100755 --- a/bin/blackbox_shred_all_files +++ b/bin/blackbox_shred_all_files @@ -24,6 +24,7 @@ echo '========== FILES BEING SHREDDED:' exported_internal_shred_file() { source "$1/_blackbox_common.sh" + #unencrypted_file=$(get_unencrypted_filename "$2") unencrypted_file="$2" if [[ -f "$unencrypted_file" ]]; then echo " SHRED: $unencrypted_file" From 9ff5892ddfdfb5181a47ad1bad70e0387e6e7db1 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Tue, 7 Nov 2017 10:57:08 -0500 Subject: [PATCH 59/94] .gitattributes not created in some situations Replaces https://github.com/StackExchange/blackbox/pull/146 --- bin/blackbox_initialize | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/blackbox_initialize b/bin/blackbox_initialize index 6ba50a3..4f1a0b2 100755 --- a/bin/blackbox_initialize +++ b/bin/blackbox_initialize @@ -39,6 +39,7 @@ if [[ $VCS_TYPE = "git" ]]; then # Set .gitattributes so that Windows users don't break the admin files. FILE="$BLACKBOXDATA/.gitattributes" + touch "$FILE" LINE='blackbox-admins.txt text eol=lf' grep -qF "$LINE" "$FILE" || echo "$LINE" >> "$FILE" LINE='blackbox-files.txt text eol=lf' From 3fda14fd233ee3d5db897adf4a4e75df4e342249 Mon Sep 17 00:00:00 2001 From: Jinn Koriech Date: Sat, 11 Nov 2017 09:34:59 +0000 Subject: [PATCH 60/94] Exclude our default keyring from import By default GPG will continue to perform actions against our default keyring. During the keychain import stage this results in the export of both the keyring for the repository we're working on, plus our own default keyring. The import phase then continues to import all these exported keys, which include the entries from our default keyring, for which all those entries already exist. If you have a lot of keys in your default keyring this takes a long time, and can be noisy due to validation, yet offers absolutely no value. To avoid all this overhead we only need to pass the `--no-default-keyring` option to GPG during this export phase. The result will still be what we're expecting - i.e. that all entries from the repository pubring are imported into our default keyring. --- bin/_blackbox_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 08671e5..2b4c940 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -184,7 +184,7 @@ function prepare_keychain() { # NB: We must export the keys to a format that can be imported. make_self_deleting_tempfile keyringasc export LANG="C.UTF-8" - $GPG --export --keyring "$(get_pubring_path)" >"$keyringasc" + $GPG --export --no-default-keyring --keyring "$(get_pubring_path)" >"$keyringasc" $GPG --import "$keyringasc" 2>&1 | egrep -v 'not changed$' >&2 echo '========== Importing keychain: DONE' >&2 } From 6a9bc745f1165c4ed98e4980f43b9f219ece381f Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Sun, 10 Dec 2017 12:15:36 +0000 Subject: [PATCH 61/94] Improve formatting link --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index cfc9591..44ca6a0 100644 --- a/README.md +++ b/README.md @@ -711,9 +711,7 @@ We welcome questions, bug reports and feedback! The best place to start is to join the [blackbox-project mailing list](https://groups.google.com/d/forum/blackbox-project) and ask there. -Bugs are tracked here in Github. Please feel free to report bugs yourself: - -- https://github.com/StackExchange/blackbox/issues +Bugs are tracked here in Github. Please feel free to [report bugs](https://github.com/StackExchange/blackbox/issues) yourself. Developer Info ============== From 0f0d8133928317ee0da2365466ac1f2a567197e4 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Tue, 12 Dec 2017 19:38:35 +0000 Subject: [PATCH 62/94] docs: Fix spacing (#225) tiny spacing correction --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44ca6a0..f26ebeb 100644 --- a/README.md +++ b/README.md @@ -684,7 +684,7 @@ Some common errors `gpg: decryption failed: No secret key` -- Usually means you forgot to re-encrypt the file with the new key. -`Error: can't re-encrypt because a key has expired.` -- A user's key has expired and can't be used to encrypt any more. Follow the[Replace expired keys](#replace-expired-keys) tip. +`Error: can't re-encrypt because a key has expired.` -- A user's key has expired and can't be used to encrypt any more. Follow the [Replace expired keys](#replace-expired-keys) tip. Using Blackbox without a repo ============================= From 7f085fc32ce62220116c95cb2b00691b7bc26724 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Thu, 14 Dec 2017 11:01:19 +0000 Subject: [PATCH 63/94] Spelling (#226) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f26ebeb..2cf6c43 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ Development: How is the encryption done? =========================== -GPG has many different ways to encrypt a file. BlackBox uses the mode that lets you specify a list of keys that can decrypt the messsage. +GPG has many different ways to encrypt a file. BlackBox uses the mode that lets you specify a list of keys that can decrypt the message. If you have 5 people ("admins") that should be able to access the secrets, each creates a GPG key and adds their public key to the keychain. The GPG command used to encrypt the file lists all 5 key names, and therefore any 1 key can decrypt the file. From eb4ad38548cae50ec33f9faaf11d28e1dd19b074 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Thu, 14 Dec 2017 22:30:16 +0000 Subject: [PATCH 64/94] Misspelling (#227) --- Version2-Ideas.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version2-Ideas.md b/Version2-Ideas.md index a3533ce..1cc7776 100644 --- a/Version2-Ideas.md +++ b/Version2-Ideas.md @@ -2,7 +2,7 @@ I'm writing this to solicit feedback and encourage discussion. -Here are my thoughts on a "verison 2" of blackbox. This is where +Here are my thoughts on a "version 2" of blackbox. This is where I list ideas that would require major changes to the system. They might break backwards compatibility, though usually not. From 8e0e96be5ed10bc0a3f8a8e93308792fe5bb1b13 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Thu, 14 Dec 2017 22:31:34 +0000 Subject: [PATCH 65/94] Doc: fix typos (#228) And another one :) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cf6c43..af6c531 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,7 @@ If you don't already have a GPG key, here's how to generate one: gpg --gen-key ``` -Pick defaults for encryption settings, 0 expiration. Pick a VERY GOOD passphrase. Store a backup of the private key someplace secure. For example, keep the backup copy on a USB drive that is locked in safe. Or, at least put it on a machine secure machine with little or no internet access, full-disk-encryption, etc. Your employer problably has rules about how to store such things. +Pick defaults for encryption settings, 0 expiration. Pick a VERY GOOD passphrase. Store a backup of the private key someplace secure. For example, keep the backup copy on a USB drive that is locked in safe. Or, at least put it on a machine secure machine with little or no internet access, full-disk-encryption, etc. Your employer probably has rules about how to store such things. Now that you have a GPG key, add yourself as an admin: From 242c34955ef4996c3445633db41d210922151512 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Fri, 15 Dec 2017 02:08:44 +0000 Subject: [PATCH 66/94] Spelling (#229) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af6c531..96282df 100644 --- a/README.md +++ b/README.md @@ -587,7 +587,7 @@ sudo -u puppet cat /etc/puppet/hieradata/blackbox.yaml # or any encrypted file. ProTip: If you get "gpg: decryption failed: No secret key" then you forgot to re-encrypt blackbox.yaml with the new key. -On SECUREHOST, securerly delete your files: +On SECUREHOST, securely delete your files: ``` cd /tmp/NEWMASTER From 3203a7aa10b0cbe1e55c8cd8e4d8333c32b8ecea Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Fri, 15 Dec 2017 12:35:20 +0000 Subject: [PATCH 67/94] Spelling --- Version2-Ideas.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version2-Ideas.md b/Version2-Ideas.md index 1cc7776..cd71bb2 100644 --- a/Version2-Ideas.md +++ b/Version2-Ideas.md @@ -75,7 +75,7 @@ Backwards compatibility: This would add a "none" VCS, not remove any existing fu `bash` is fairly universal. It even exists on Windows. However it is not the right language for large systems. Writing the acceptance tests is quite a bear. Managing ".gitignore" files in bash is impossible and the current implementation fails in many cases. -`python` is my second favorite langauge. It would make the code cleaner and more testable. However it is not installed everywhere. I would also want to write it in Python3 (why start a new project in Python2?) but sadly Python3 is less common. It is a chicken vs. egg situation. +`python` is my second favorite language. It would make the code cleaner and more testable. However it is not installed everywhere. I would also want to write it in Python3 (why start a new project in Python2?) but sadly Python3 is less common. It is a chicken vs. egg situation. `go` is my favorite language. I could probably rewrite this in go in a weekend. However, now the code is compiled, not interpreted. Therefore we lose the ability to just "git clone" and have the tools you want. Not everyone has a Go compiler installed on every machine. From 90c34b5e0c9371bc14ca5d2eb655a1b755943abe Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Fri, 15 Dec 2017 21:46:47 +0000 Subject: [PATCH 68/94] BlackBox vs Blackbox or blackbox consistency --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 96282df..c077dee 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,12 @@ Table of Contents - [How to remove a file from the system?](#how-to-remove-a-file-from-the-system) - [How to indoctrinate a new user into the system?](#how-to-indoctrinate-a-new-user-into-the-system) - [How to remove a user from the system?](#how-to-remove-a-user-from-the-system) -- [Enabling Blackbox For a Repo](#enabling-blackbox-for-a-repo) +- [Enabling BlackBox For a Repo](#enabling-blackbox-for-a-repo) - [Set up automated users or “role accounts”](#set-up-automated-users-or-role-accounts) - [Replace expired keys](#replace-expired-keys) - [Some common errors](#some-common-errors) -- [Using Blackbox on Windows](#using-blackbox-on-windows) -- [Using Blackbox without a repo](#using-blackbox-without-a-repo) +- [Using BlackBox on Windows](#using-blackbox-on-windows) +- [Using BlackBox without a repo](#using-blackbox-without-a-repo) - [Some Subversion gotchas](#some-subversion-gotchas) - [How to submit bugs or ask questions?](#how-to-submit-bugs-or-ask-questions) - [Developer Info](#developer-info) @@ -99,7 +99,7 @@ Commands Compatibility ============= -Blackbox automatically determines which VCS you are using and does the right thing. It has a plug-in architecture to make it easy to extend to work with other systems. It has been tested to work with many operating systems. +BlackBox automatically determines which VCS you are using and does the right thing. It has a plug-in architecture to make it easy to extend to work with other systems. It has been tested to work with many operating systems. - Version Control systems - `git` -- The Git @@ -117,14 +117,14 @@ To add or fix support for a VCS system, look for code at the end of `bin/_blackb To add or fix support for a new operating system, look for the case statements in `bin/_blackbox_common.sh` and `bin/_stack_lib.sh` and maybe `tools/confidence_test.sh` -Using Blackbox on Windows +Using BlackBox on Windows ========================= -Blackbox can be used with Cygwin or MinGW. +BlackBox can be used with Cygwin or MinGW. ### Protect the line endings -Blackbox assumes that `blackbox-admins.txt` and `blackbox-files.txt` will have +BlackBox assumes that `blackbox-admins.txt` and `blackbox-files.txt` will have LF line endings. Windows users should be careful to configure Git or other systems to not convert or "fix" those files. @@ -400,7 +400,7 @@ The key ring only has public keys. There are no secret keys to delete. Remember that this person did have access to all the secrets at one time. They could have made a copy. Therefore, to be completely secure, you should change all passwords, generate new SSL keys, and so on just like when anyone that had privileged access leaves an organization. -Enabling Blackbox For a Repo +Enabling BlackBox For a Repo ============================ Overview: @@ -734,14 +734,14 @@ This runs through a number of system tests. It creates a repo, encrypts files, d Please submit tests with code changes: -The best way to change Blackbox is via Test Driven Development. First add a test to `tools/confidence.sh`. This test should fail, and demonstrate the need for the change you are about to make. Then fix the bug or add the feature you want. When you are done, `make confidence` should pass all tests. The PR you submit should include your code as well as the new test. This way the confidence tests accumulate as the system grows as we know future changes don't break old features. +The best way to change BlackBox is via Test Driven Development. First add a test to `tools/confidence.sh`. This test should fail, and demonstrate the need for the change you are about to make. Then fix the bug or add the feature you want. When you are done, `make confidence` should pass all tests. The PR you submit should include your code as well as the new test. This way the confidence tests accumulate as the system grows as we know future changes don't break old features. Note: The tests currently assume "git" and have been tested only on CentOS, Mac OS X, and Cygwin. Patches welcome! Alternatives ============ -Here are other open source packages that do something similar to Blackbox. If you like them better than Blackbox, please use them. +Here are other open source packages that do something similar to BlackBox. If you like them better than BlackBox, please use them. - [git-crypt](https://www.agwa.name/projects/git-crypt/) - [Pass](http://www.zx2c4.com/projects/password-store/) From b70a215c616a061047e624fb9c8b51d1ce806e73 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Fri, 15 Dec 2017 21:48:26 +0000 Subject: [PATCH 69/94] "BlackBox" vs "blackbox" --- Version2-Ideas.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Version2-Ideas.md b/Version2-Ideas.md index cd71bb2..b538d29 100644 --- a/Version2-Ideas.md +++ b/Version2-Ideas.md @@ -1,12 +1,12 @@ -# Ideas for blackbox Version 2 +# Ideas for BlackBox Version 2 I'm writing this to solicit feedback and encourage discussion. -Here are my thoughts on a "version 2" of blackbox. This is where +Here are my thoughts on a "version 2" of BlackBox. This is where I list ideas that would require major changes to the system. They might break backwards compatibility, though usually not. -Blackbox grew from a few simple shell scripts used at StackOverflow.com +BlackBox grew from a few simple shell scripts used at StackOverflow.com to a larger system used by dozens (hundreds?) of organizations. Not all the design decisions were "forward looking". @@ -94,4 +94,4 @@ However, I've never used it so I don't have any idea whether git-crypt is any be Of course, git-crypt doesn't work with SVN, HG, or any other VCS. Is blackbox's strong point the fact that it support so many VCS systems? To be honest, it originally only supported HG and GIT because I was at a company that used HG but then changed to GIT. Supporting anything else was thanks to contributors. Heck, HG support hasn't even been tested recently (by me) since we've gone all git where I work. -How important is this to blackbox users? +How important is this to BlackBox users? From 0028fa49fbe4b7a7347967b55413132709b9e53f Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Fri, 15 Dec 2017 21:49:48 +0000 Subject: [PATCH 70/94] BlackBox vs Blackbox --- RELEASE_ENGINEERING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_ENGINEERING.md b/RELEASE_ENGINEERING.md index 6310d15..0bf6c66 100644 --- a/RELEASE_ENGINEERING.md +++ b/RELEASE_ENGINEERING.md @@ -17,7 +17,7 @@ There are 3 branches/tags: - **tag stable:** Stable enough for use by most people. - **tag production:** Burned in long enough that we are confident it can be widely adopted. -If you are packaging Blackbox for distribution, you should track the *tag production*. You might also want to provide a separate package that tracks *tag stable:* for early adopters. +If you are packaging BlackBox for distribution, you should track the *tag production*. You might also want to provide a separate package that tracks *tag stable:* for early adopters. Build Tasks =========== From 058d765a075ae8e293249846a35cae47b0da2610 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Sun, 31 Dec 2017 16:17:44 +0000 Subject: [PATCH 71/94] Update license year --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index f7a72c7..9706178 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2017 Stack Exchange, Inc. +Copyright (c) 2014-2018 Stack Exchange, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 0c4cdace10b265664db578cbf3b8796796ebfede Mon Sep 17 00:00:00 2001 From: Pim Snel Date: Fri, 5 Jan 2018 14:05:57 +0100 Subject: [PATCH 72/94] Fix problems when gpg2 is installed next to gpg (#237) * implement fixes from https://stackoverflow.com/questions/44247308/blackbox-gpg-decrypt-fails-dont-know-ctb-00 * fix problems when working with gpg2 next to gpg. Add's readme section * fix anchor --- README.md | 14 ++++++++++++++ bin/_blackbox_common.sh | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c077dee..7094204 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Table of Contents - [Using BlackBox on Windows](#using-blackbox-on-windows) - [Using BlackBox without a repo](#using-blackbox-without-a-repo) - [Some Subversion gotchas](#some-subversion-gotchas) +- [Using Blackbox when gpg2 is installed next to gpg](#using-blackbox-when-gpg2-is-installed-next-to-gpg) - [How to submit bugs or ask questions?](#how-to-submit-bugs-or-ask-questions) - [Developer Info](#developer-info) - [Alternatives](#alternatives) @@ -704,6 +705,19 @@ The current implementation will store the blackbox in `/keyrings` at the root of This was originally written for git and supports a two-phase commit, in which `commit` is a local commit and "push" sends the change upstream to the version control server when something is registered or deregistered with the system. The current implementation will immediately `commit` a file (to the upstream subversion server) when you execute a `blackbox_*` command. +Using Blackbox when gpg2 is installed next to gpg +================================================= + +In some situations, team members or automated roles need to install gpg +2.x next to the system gpg version 1.x. to catch up with the teams gpg +version. On Ubuntu 16. you can ```apt-get install gnupg2``` which +installes the binary gpg2. If you want to use this gpg2 binany run every +blackbox command with GPG=gpg2. E.g.: + +``` +GPG=gpg2 blackbox_postdeploy +``` + How to submit bugs or ask questions? ==================================== diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 2b4c940..6d98786 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -184,8 +184,15 @@ function prepare_keychain() { # NB: We must export the keys to a format that can be imported. make_self_deleting_tempfile keyringasc export LANG="C.UTF-8" - $GPG --export --no-default-keyring --keyring "$(get_pubring_path)" >"$keyringasc" - $GPG --import "$keyringasc" 2>&1 | egrep -v 'not changed$' >&2 + + #if gpg2 is installed next to gpg like on ubuntu 16 + if [[ "$GPG" != "gpg2" ]]; then + $GPG --export --no-default-keyring --keyring "$(get_pubring_path)" >"$keyringasc" + $GPG --import "$keyringasc" 2>&1 | egrep -v 'not changed$' >&2 + else + $GPG --keyring "$(get_pubring_path)" --export | $GPG --import + fi + echo '========== Importing keychain: DONE' >&2 } From 34c132b713e0bf147b3150001ca0587a5b358d36 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Sat, 6 Jan 2018 15:13:35 +0000 Subject: [PATCH 73/94] Corrections on new section --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7094204..abc99a6 100644 --- a/README.md +++ b/README.md @@ -709,10 +709,12 @@ Using Blackbox when gpg2 is installed next to gpg ================================================= In some situations, team members or automated roles need to install gpg -2.x next to the system gpg version 1.x. to catch up with the teams gpg -version. On Ubuntu 16. you can ```apt-get install gnupg2``` which -installes the binary gpg2. If you want to use this gpg2 binany run every -blackbox command with GPG=gpg2. E.g.: +2.x alongside the system gpg version 1.x to catch up with the team's gpg +version. On Ubuntu 16, you can ```apt-get install gnupg2``` which +installs the binary gpg2. If you want to use this gpg2 binary, run every +blackbox command with GPG=gpg2. + +For example: ``` GPG=gpg2 blackbox_postdeploy From cbfce0b9f0af5e7dc5c0633198648daf17ae92f8 Mon Sep 17 00:00:00 2001 From: Ben Holden-Crowther Date: Sun, 7 Jan 2018 18:42:07 +0000 Subject: [PATCH 74/94] quick corrections --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index abc99a6..9952897 100644 --- a/README.md +++ b/README.md @@ -701,7 +701,7 @@ The following commands have been tested outside a repo: Some Subversion gotchas ======================= -The current implementation will store the blackbox in `/keyrings` at the root of the entire repo. this will create an issue between environments that have different roots (ie, checking out `/` on development vs `/releases/foo` in production). To get around this, you can `export BLACKBOX_REPOBASE=/path/to/repo` and set a specific base for your repo. +The current implementation will store the blackbox in `/keyrings` at the root of the entire repo. This will create an issue between environments that have different roots (i.e. checking out `/` on development vs `/releases/foo` in production). To get around this, you can `export BLACKBOX_REPOBASE=/path/to/repo` and set a specific base for your repo. This was originally written for git and supports a two-phase commit, in which `commit` is a local commit and "push" sends the change upstream to the version control server when something is registered or deregistered with the system. The current implementation will immediately `commit` a file (to the upstream subversion server) when you execute a `blackbox_*` command. From 5162cb1cac20c947e58620abcce167a30714ebc0 Mon Sep 17 00:00:00 2001 From: Kwok-kuen Cheung Date: Tue, 6 Feb 2018 19:08:29 +0800 Subject: [PATCH 75/94] Fix replacing-expired-keys link in README (#241) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9952897..d1ac026 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Table of Contents - [How to remove a user from the system?](#how-to-remove-a-user-from-the-system) - [Enabling BlackBox For a Repo](#enabling-blackbox-for-a-repo) - [Set up automated users or “role accounts”](#set-up-automated-users-or-role-accounts) -- [Replace expired keys](#replace-expired-keys) +- [Replacing expired keys](#replacing-expired-keys) - [Some common errors](#some-common-errors) - [Using BlackBox on Windows](#using-blackbox-on-windows) - [Using BlackBox without a repo](#using-blackbox-without-a-repo) From b9e456019b5206e25d4c3ccc86f4113b7f9ff7ef Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 12 Feb 2018 08:06:55 -0500 Subject: [PATCH 76/94] Add missing library: libffi-dev --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index afd4d30..6552ddc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ jobs: name: 'Installing' command: | apt-get update -y - apt-get install -y build-essential expect git gnupg2 pinentry-tty procps rpm ruby-dev + apt-get install -y build-essential expect git gnupg2 pinentry-tty procps rpm ruby-dev libffi-dev gem install fpm - run: name: 'Cleaning' @@ -41,7 +41,7 @@ jobs: name: 'Installing' command: | apt-get update -y - apt-get install -y build-essential expect git gnupg2 pinentry-tty procps rpm ruby-dev + apt-get install -y build-essential expect git gnupg2 pinentry-tty procps rpm ruby-dev libffi-dev gem install fpm - run: name: 'Cleaning' From 6efbd24c58cf9bd7b64e321da2feedb474014fa6 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 22 Feb 2018 13:46:42 -0500 Subject: [PATCH 77/94] Improve installation instructions (#244) * Clarify manual-install -> symlinks-install --- Makefile | 24 ++++++++++++++++-------- README.md | 9 +++++---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 2c3c14c..7c46181 100644 --- a/Makefile +++ b/Makefile @@ -6,15 +6,18 @@ OUTPUTDIR?="$(BASEDIR)/debbuild-${PKGNAME}" all: @echo 'Menu:' - @echo ' make update Update any generated files' - @echo ' make packages Make RPM packages' - @echo ' make packages-deb Make DEB packages' - @echo ' make test Run tests' - @echo ' make install (incomplete)' + @echo ' make update Update any generated files' + @echo ' make packages-rpm Make RPM packages' + @echo ' make packages-deb Make DEB packages' + @echo ' make symlinks-install Make symlinks in /usr/local/bin/' + @echo ' make copy-install Copy "bin" files to /usr/local/bin/' + @echo ' make usrlocal-uninstall Remove blackbox files from /usr/local/bin/' + @echo ' make test Run tests' install: @echo 'To install, copy the files from bin to somewhere in your PATH.' - @echo 'Or, if you use RPMs, "make packages" and install the result.' + @echo 'The README.md document gives more details.' + @echo 'Or run "make" (with no options) for more info.' # The default package type is RPM. packages: packages-rpm @@ -51,12 +54,17 @@ unlock-rpm: # # Manual install # -manual-install: +symlinks-install: @echo 'Symlinking files from ./bin to /usr/local/bin' @cd bin && for f in `find . -type f -iname "*" ! -iname "Makefile"`; do ln -fs `pwd`/$$f /usr/local/bin/$$f; done @echo 'Done.' -manual-uninstall: +copy-install: + @echo 'Copying files from ./bin to /usr/local/bin' + @cd bin && for f in `find . -type f -iname "*" ! -iname "Makefile"`; do cp `pwd`/$$f /usr/local/bin/$$f; done + @echo 'Done.' + +usrlocal-uninstall: @echo 'Removing blackbox files from /usr/local/bin' @cd bin && for f in `find . -type f -iname "*" ! -iname "Makefile"`; do rm /usr/local/bin/$$f; done @echo 'Done.' diff --git a/README.md b/README.md index d1ac026..0318959 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,13 @@ The ability to be open and transparent about our code, with the exception of a f Installation Instructions ========================= +- *The hard way (manual*: Copy all the files in "bin" to your "bin". +- *The hard way (automatic)*: `make copy-install` will copy the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`). +- *The symlinks way*: `make synlinks-install` will make symlinks of the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`) (useful when doing development) - *The MacPorts Way*: `sudo port install vcs_blackbox` - *The Homebrew Way*: `brew install blackbox` -- *The RPM way*: Check out the repo and make an RPM via `make packages-rpm`; now you can distribute the RPM via local methods. -- *The Debian/Ubuntu way*: Check out the repo and install [fpm](https://github.com/jordansissel/fpm). Now you can make a DEB `make packages-deb` that can be distributed via local methods. -- *The hard way*: Copy all the files in "bin" to your "bin". -- *The manual way*: `make manual-install` to install. `make manual-uninstall` to uninstall. +- *The RPM way*: Check out the repo and make an RPM via `make packages-rpm`; now you can distribute the RPM via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) +- *The Debian/Ubuntu way*: Check out the repo and make a DEB via `make packages-deb`; now you can distribute the DEB via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) - *The Antigen Way*: Add `antigen bundle StackExchange/blackbox` to your .zshrc - *The Zgen Way*: Add `zgen load StackExchange/blackbox` to your .zshrc where you're loading your other plugins. From 906ecd0f8247016a10ca6e8426cd8445b122885d Mon Sep 17 00:00:00 2001 From: jciskey Date: Mon, 12 Mar 2018 05:45:32 -0500 Subject: [PATCH 78/94] Fix typo (#246) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0318959..c98be9e 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Installation Instructions - *The hard way (manual*: Copy all the files in "bin" to your "bin". - *The hard way (automatic)*: `make copy-install` will copy the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`). -- *The symlinks way*: `make synlinks-install` will make symlinks of the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`) (useful when doing development) +- *The symlinks way*: `make symlinks-install` will make symlinks of the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`) (useful when doing development) - *The MacPorts Way*: `sudo port install vcs_blackbox` - *The Homebrew Way*: `brew install blackbox` - *The RPM way*: Check out the repo and make an RPM via `make packages-rpm`; now you can distribute the RPM via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) From 7cebec9450bced4907865759edd51f72c7291d66 Mon Sep 17 00:00:00 2001 From: Ben Tullis Date: Wed, 11 Apr 2018 11:06:14 +0100 Subject: [PATCH 79/94] Ensure that git commits the changes to pubring.gpg when running blackbox_removeadmin This relates to https://github.com/StackExchange/blackbox/issues/247 where it has been observed that the blackbox_removeadmin script prompts the user to run an incorrect command after running blackbox_removeadmin. This commit simply adds pubring.gpg to the list of files to be committed. --- bin/blackbox_removeadmin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/blackbox_removeadmin b/bin/blackbox_removeadmin index ddd1fb3..3a36e5e 100755 --- a/bin/blackbox_removeadmin +++ b/bin/blackbox_removeadmin @@ -31,4 +31,4 @@ vcs_add "$pubring_path" "$KEYRINGDIR/trustdb.gpg" "$BB_ADMINS" echo echo echo 'NEXT STEP: Check these into the repo. Probably with a command like...' -echo $VCS_TYPE commit -m\'REMOVED ADMIN: $KEYNAME\' "$BLACKBOXDATA/trustdb.gpg" "$BLACKBOXDATA/$BB_ADMINS_FILE" +echo $VCS_TYPE commit -m\'REMOVED ADMIN: $KEYNAME\' "$BLACKBOXDATA/$(basename ${pubring_path})" "$BLACKBOXDATA/trustdb.gpg" "$BLACKBOXDATA/$BB_ADMINS_FILE" From 17d1a1a98b484184ac6ba0a34480d278f0b4d07d Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 30 Apr 2018 13:49:52 -0400 Subject: [PATCH 80/94] Fix whitespace. --- RELEASE_ENGINEERING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_ENGINEERING.md b/RELEASE_ENGINEERING.md index 0bf6c66..a3cb28e 100644 --- a/RELEASE_ENGINEERING.md +++ b/RELEASE_ENGINEERING.md @@ -99,6 +99,7 @@ Submit the diff file as a bug as instructed. The instructions should look like t Step 3: Watch for the update to happen. + Updating MacPorts (manual) ========================== From 07546c6205b61985b2e5c976383bd05f244a1ed2 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 31 May 2018 17:01:24 -0400 Subject: [PATCH 81/94] Whitespace --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c98be9e..7294ae4 100644 --- a/README.md +++ b/README.md @@ -768,6 +768,7 @@ Here are other open source packages that do something similar to BlackBox. If yo git-crypt has the best git integration. Once set up it is nearly transparent to the users. However it only works with git. + License ======= From 69c0360a99b2a3ee5a8baebe186af95c2c053999 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 15 Jun 2018 09:22:05 -0400 Subject: [PATCH 82/94] Clarify .blackbox vs keyrings/live in README.md --- README.md | 194 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 118 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 7294ae4..80210f1 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Table of Contents - [Alternatives](#alternatives) - [License](#license) - Overview ======== @@ -65,15 +64,15 @@ The ability to be open and transparent about our code, with the exception of a f Installation Instructions ========================= -- *The hard way (manual*: Copy all the files in "bin" to your "bin". -- *The hard way (automatic)*: `make copy-install` will copy the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`). -- *The symlinks way*: `make symlinks-install` will make symlinks of the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`) (useful when doing development) -- *The MacPorts Way*: `sudo port install vcs_blackbox` -- *The Homebrew Way*: `brew install blackbox` -- *The RPM way*: Check out the repo and make an RPM via `make packages-rpm`; now you can distribute the RPM via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) -- *The Debian/Ubuntu way*: Check out the repo and make a DEB via `make packages-deb`; now you can distribute the DEB via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) -- *The Antigen Way*: Add `antigen bundle StackExchange/blackbox` to your .zshrc -- *The Zgen Way*: Add `zgen load StackExchange/blackbox` to your .zshrc where you're loading your other plugins. +- *The hard way (manual*: Copy all the files in "bin" to your "bin". +- *The hard way (automatic)*: `make copy-install` will copy the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`). +- *The symlinks way*: `make symlinks-install` will make symlinks of the bin files into /usr/local/bin (uninstall with `make usrlocal-uninstall`) (useful when doing development) +- *The MacPorts Way*: `sudo port install vcs_blackbox` +- *The Homebrew Way*: `brew install blackbox` +- *The RPM way*: Check out the repo and make an RPM via `make packages-rpm`; now you can distribute the RPM via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) +- *The Debian/Ubuntu way*: Check out the repo and make a DEB via `make packages-deb`; now you can distribute the DEB via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) +- *The Antigen Way*: Add `antigen bundle StackExchange/blackbox` to your .zshrc +- *The Zgen Way*: Add `zgen load StackExchange/blackbox` to your .zshrc where you're loading your other plugins. Commands ======== @@ -103,17 +102,17 @@ Compatibility BlackBox automatically determines which VCS you are using and does the right thing. It has a plug-in architecture to make it easy to extend to work with other systems. It has been tested to work with many operating systems. -- Version Control systems - - `git` -- The Git - - `hg` -- Mercurial - - `svn` -- SubVersion (Thanks, Ben Drasin!) - - `p4` -- Perforce - - none -- The files can be decrypted outside of a repo if the keyrings directory is intact -- Operating system - - CentOS / RedHat - - MacOS X - - Cygwin (Thanks, Ben Drasin!) **See Note Below** - - MinGW (git bash on windows) **See Note Below** +- Version Control systems + - `git` -- The Git + - `hg` -- Mercurial + - `svn` -- SubVersion (Thanks, Ben Drasin!) + - `p4` -- Perforce + - none -- The files can be decrypted outside of a repo if the `.blackbox` directory is intact +- Operating system + - CentOS / RedHat + - MacOS X + - Cygwin (Thanks, Ben Drasin!) **See Note Below** + - MinGW (git bash on windows) **See Note Below** To add or fix support for a VCS system, look for code at the end of `bin/_blackbox_common.sh` @@ -144,14 +143,14 @@ Cygwin support requires the following packages: Normal operation: -- gnupg -- git or mercurial or subversion or perforce (as appropriate) +- gnupg +- git or mercurial or subversion or perforce (as appropriate) Development (if you will be adding code and want to run the confidence test) -- procps -- make -- git (the confidence test currently only tests git) +- procps +- make +- git (the confidence test currently only tests git) ### MinGW @@ -159,17 +158,16 @@ MinGW (comes with Git for Windows) support requires the following: Normal operation: -- [Git for Windows](https://git-scm.com/) (not tested with Mercurial) - - Git Bash MINTTY returns a MinGW console. So when you install make sure you pick `MINTTY` instead of windows console. You'll be executing blackbox from the Git Bash prompt. - - You need at least version 2.8.1 of Git for Windows. -- [GnuWin32](https://sourceforge.net/projects/getgnuwin32/files/) - needed for various tools not least of which is mktemp which is used by blackbox - - after downloading the install just provides you with some batch files. Because of prior issues at sourceforge and to make sure you get the latest version of each package the batch files handle the brunt of the work of getting the correct packages and installing them for you. - - from a **windows command prompt** run `download.bat` once it has completed run `install.bat` then add the path for those tools to your PATH (ex: `PATH=%PATH%;c:\GnuWin32\bin`) +- [Git for Windows](https://git-scm.com/) (not tested with Mercurial) + - Git Bash MINTTY returns a MinGW console. So when you install make sure you pick `MINTTY` instead of windows console. You'll be executing blackbox from the Git Bash prompt. + - You need at least version 2.8.1 of Git for Windows. +- [GnuWin32](https://sourceforge.net/projects/getgnuwin32/files/) - needed for various tools not least of which is mktemp which is used by blackbox + - after downloading the install just provides you with some batch files. Because of prior issues at sourceforge and to make sure you get the latest version of each package the batch files handle the brunt of the work of getting the correct packages and installing them for you. + - from a **windows command prompt** run `download.bat` once it has completed run `install.bat` then add the path for those tools to your PATH (ex: `PATH=%PATH%;c:\GnuWin32\bin`) -Development: - -- unknown (if you develop Blackbox under MinGW, please let us know if any additional packages are required to run `make test`) +Development: +- unknown (if you develop Blackbox under MinGW, please let us know if any additional packages are required to run `make test`) How is the encryption done? =========================== @@ -188,20 +186,20 @@ To remove someone's access, remove that admin's key name (i.e. email address) fr *If you use Puppet, why didn't you just use hiera-eyaml?* There are 4 reasons: -1. This works with any Git or Mercurial repo, even if you aren't using Puppet. -2. hiera-eyaml decrypts "on demand" which means your Puppet Master now uses a lot of CPU to decrypt keys every time it is contacted. It slows down your master, which, in my case, is already slow enough. -3. This works with binary files, without having to ASCIIify them and paste them into a YAML file. Have you tried to do this with a cert that is 10K long and changes every few weeks? Ick. -4. hiera-eyaml didn't exist when I wrote this. +1. This works with any Git or Mercurial repo, even if you aren't using Puppet. +2. hiera-eyaml decrypts "on demand" which means your Puppet Master now uses a lot of CPU to decrypt keys every time it is contacted. It slows down your master, which, in my case, is already slow enough. +3. This works with binary files, without having to ASCIIify them and paste them into a YAML file. Have you tried to do this with a cert that is 10K long and changes every few weeks? Ick. +4. hiera-eyaml didn't exist when I wrote this. What does this look like to the typical user? ============================================= -- If you need to, start the GPG Agent: `eval $(gpg-agent --daemon)` -- Decrypt the file so it is editable: `blackbox_edit_start FILENAME` -- (You will need to enter your GPG passphrase.) -- Edit FILENAME as you desire: `vim FILENAME` -- Re-encrypt the file: `blackbox_edit_end FILENAME` -- Commit the changes. `git commit -a` or `hg commit` +- If you need to, start the GPG Agent: `eval $(gpg-agent --daemon)` +- Decrypt the file so it is editable: `blackbox_edit_start FILENAME` +- (You will need to enter your GPG passphrase.) +- Edit FILENAME as you desire: `vim FILENAME` +- Re-encrypt the file: `blackbox_edit_end FILENAME` +- Commit the changes. `git commit -a` or `hg commit` Wait... it can be even easier than that! Run `blackbox_edit FILENAME`, and it'll decrypt the file in a temp file and call `$EDITOR` on it, re-encrypting again after the editor is closed. @@ -262,8 +260,8 @@ The variable `$the_password` will contain "my secret password" and can be used a How to enroll a new file into the system? ========================================= -- If you need to, start the GPG Agent: `eval $(gpg-agent --daemon)` -- Add the file to the system: +- If you need to, start the GPG Agent: `eval $(gpg-agent --daemon)` +- Add the file to the system: ``` blackbox_register_new_file path/to/file.name.key @@ -295,6 +293,8 @@ blackbox_deregister_file path/to/file.name.key How to indoctrinate a new user into the system? =============================================== +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" + `.blackbox/blackbox-admins.txt` is a file that lists which users are able to decrypt files. (More pedantically, it is a list of the GnuPG key names that the file is encrypted for.) To join the list of people that can edit the file requires three steps; You create a GPG key and add it to the key ring. Then, someone that already has access adds you to the system. Lastly, you should test your access. @@ -348,7 +348,7 @@ Ask someone that already has access to re-encrypt the data files. This gives you Pre-check: Verify the new keys look good. ``` -$ gpg --homedir=.blackbox --list-keys +gpg --homedir=.blackbox --list-keys ``` For example, examine the key name (email address) to make sure it conforms to corporate standards. @@ -392,16 +392,48 @@ When the command completes, you will be given a reminder to check in the change Note that their keys will still be in the key ring, but they will go unused. If you'd like to clean up the keyring, use the normal GPG commands and check in the file. +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" + ``` gpg --homedir=.blackbox --list-keys gpg --homedir=.blackbox --delete-key olduser@example.com git commit -m'Cleaned olduser@example.com from keyring' .blackbox/* ``` +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" + The key ring only has public keys. There are no secret keys to delete. Remember that this person did have access to all the secrets at one time. They could have made a copy. Therefore, to be completely secure, you should change all passwords, generate new SSL keys, and so on just like when anyone that had privileged access leaves an organization. +Where is the configuration stored? .blackbox vs. keyrings/live +============================================================== + +Blackbox stores its configuration data in the `.blackbox` subdirectory. Older +repos use `keyrings/live`. For backwards compatibility either will work. + +All documentation refers to `.blackbox`. + +You can convert an old repo by simply renaming the directory: + +``` +mv keyrings/live .blackbox +rmdir keyrings +``` + +There is no technical reason to convert old repos except that it is less +confusing to users. + +This change was made in commit 60e782a0, release v1.20180615. + +The details: + +- First Blackbox checks `$BLACKBOXDATA`. If this environment variable is set, this is the directory that will be used. If it lists a directory that does not exist, Blackbox will print an error and exit. +- If `$BLACKBOXDATA` is not set: (which is the typical use case) + - Blackbox will first try `keyrings/live` and use it if it exists. + - Otherwise the default `.blackbox` will be used. If `.blackbox` does not exist, Blackbox will print an error and exit. + + Enabling BlackBox For a Repo ============================ @@ -409,10 +441,12 @@ Overview: To add "blackbox" to a git or mercurial repo, you'll need to do the following: -1. Run the initialize script. This adds a few files to your repo in a directory called "keyrings". -2. For the first user, create a GPG key and add it to the key ring. -3. Encrypt the files you want to be "secret". -4. For any automated user (one that must be able to decrypt without a passphrase), create a GPG key and create a subkey with an empty passphrase. +1. Run the initialize script. This adds a few files to your repo in a directory called ".blackbox". +2. For the first user, create a GPG key and add it to the key ring. +3. Encrypt the files you want to be "secret". +4. For any automated user (one that must be able to decrypt without a passphrase), create a GPG key and create a subkey with an empty passphrase. + +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" ### Run the initialize script. @@ -463,6 +497,8 @@ Set up automated users or "role accounts" i.e. This is how a Puppet Master can have access to the unencrypted data. +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" + An automated user (a "role account") is one that that must be able to decrypt without a passphrase. In general you'll want to do this for the user that pulls the files from the repo to the master. This may be automated with Jenkins CI or other CI system. GPG keys have to have a passphrase. However, passphrases are optional on subkeys. Therefore, we will create a key with a passphrase then create a subkey without a passphrase. Since the subkey is very powerful, it should be created on a very secure machine. @@ -475,9 +511,9 @@ ProTip: If asked to generate entropy, consider running this on the same machine For the rest of this doc, you'll need to make the following substitutions: -- ROLEUSER: svc_deployacct or whatever your role account's name is. -- NEWMASTER: the machine this role account exists on. -- SECUREHOST: The machine you use to create the keys. +- ROLEUSER: svc_deployacct or whatever your role account's name is. +- NEWMASTER: the machine this role account exists on. +- SECUREHOST: The machine you use to create the keys. NOTE: This should be more automated/scripted. Patches welcome. @@ -525,9 +561,9 @@ Command> save Now securely export this directory to NEWMASTER: ``` -$ gpg --homedir . --export -a svc_sadeploy >/tmp/NEWMASTER/pubkey.txt -$ tar cvf /tmp/keys.tar . -$ rsync -avP /tmp/keys.tar NEWMASTER:/tmp/. +gpg --homedir . --export -a svc_sadeploy >/tmp/NEWMASTER/pubkey.txt +tar cvf /tmp/keys.tar . +rsync -avP /tmp/keys.tar NEWMASTER:/tmp/. ``` On NEWMASTER, receive the new GnuPG config: @@ -557,14 +593,14 @@ blackbox_addadmin $KEYNAME /tmp/NEWMASTER Verify that secring.gpg is a zero-length file. If it isn't, you have somehow added a private key to the keyring. Start over. ``` -$ cd .blackbox -$ ls -l secring.gpg +cd .blackbox +ls -l secring.gpg ``` Commit the recent changes: ``` -$ cd .blackbox +cd .blackbox git commit -m"Adding key for KEYNAME" pubring.gpg trustdb.gpg blackbox-admins.txt ``` @@ -613,6 +649,8 @@ $ blackbox_edit_end modified_file.txt --> Error: can't re-encrypt because a key has expired. ``` +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" + You can also detect keys that are about to expire by issuing this command and manually reviewing the "expired:" dates: gpg --homedir=.blackbox --list-keys @@ -623,7 +661,7 @@ or... list UIDs that will expire within 1 month from today: (Warning: this also Here's how to replace the key: -- Step 1. Administrator removes expired user: +- Step 1. Administrator removes expired user: Warning: This process will erase any unencrypted files that you were in the process of editing. Copy them elsewhere and restore the changes when done. @@ -637,7 +675,7 @@ git commit -m 'Cleaned expired_user@example.com from keyring' .blackbox/* git push ``` -- Step 2. Expired user adds an updated key: +- Step 2. Expired user adds an updated key: ``` git pull @@ -646,17 +684,17 @@ git commit -m'NEW ADMIN: updated_user@example.com .blackbox/pubring.gpg .blackbo git push ``` -- Step 3. Administrator re-encrypts all files with the updated key of the expired user: +- Step 3. Administrator re-encrypts all files with the updated key of the expired user: ``` git pull gpg --import .blackbox/pubring.gpg -blackbox_update_all_files +blackbox_update_all_files git commit -m "Re-encrypt all files" git push ``` -- Step 4: Clean up: +- Step 4: Clean up: Any files that were temporarily copied in the first step so as to not be overwritten can now be copied back and re-encrypted with the `blackbox_edit_end` command. @@ -667,11 +705,13 @@ Any files that were temporarily copied in the first step so as to not be overwri It's possible to tell Git to decrypt versions of the file before running them through `git diff` or `git log`. To achieve this do: - Add the following to `.gitattributes` at the top of the git repository: + ``` *.gpg diff=blackbox ``` - Add the following to `.git/config`: + ``` [diff "blackbox"] textconv = gpg --use-agent -q --batch --decrypt @@ -688,16 +728,18 @@ Some common errors `Error: can't re-encrypt because a key has expired.` -- A user's key has expired and can't be used to encrypt any more. Follow the [Replace expired keys](#replace-expired-keys) tip. +FYI: Your repo may use `keyrings/live` instead of `.blackbox`. See "Where is the configuration stored?" + Using Blackbox without a repo ============================= -If the files are copied out of a repo they can still be decrypted and edited. Obviously edits, changes to keys, and such will be lost if they are made outside the repo. Also note that commands are most likely to only work if run from the base directory (i.e. the parent to the keyrings directory). +If the files are copied out of a repo they can still be decrypted and edited. Obviously edits, changes to keys, and such will be lost if they are made outside the repo. Also note that commands are most likely to only work if run from the base directory (i.e. the parent to the .blackbox directory). The following commands have been tested outside a repo: -- `blackbox_postdeploy` -- `blackbox_edit_start` -- `blackbox_edit_end` +- `blackbox_postdeploy` +- `blackbox_edit_start` +- `blackbox_edit_end` Some Subversion gotchas ======================= @@ -713,7 +755,7 @@ In some situations, team members or automated roles need to install gpg 2.x alongside the system gpg version 1.x to catch up with the team's gpg version. On Ubuntu 16, you can ```apt-get install gnupg2``` which installs the binary gpg2. If you want to use this gpg2 binary, run every -blackbox command with GPG=gpg2. +blackbox command with GPG=gpg2. For example: @@ -760,11 +802,11 @@ Alternatives Here are other open source packages that do something similar to BlackBox. If you like them better than BlackBox, please use them. -- [git-crypt](https://www.agwa.name/projects/git-crypt/) -- [Pass](http://www.zx2c4.com/projects/password-store/) -- [Transcrypt](https://github.com/elasticdog/transcrypt) -- [Keyringer](https://keyringer.pw/) -- [git-secret](https://github.com/sobolevn/git-secret) +- [git-crypt](https://www.agwa.name/projects/git-crypt/) +- [Pass](http://www.zx2c4.com/projects/password-store/) +- [Transcrypt](https://github.com/elasticdog/transcrypt) +- [Keyringer](https://keyringer.pw/) +- [git-secret](https://github.com/sobolevn/git-secret) git-crypt has the best git integration. Once set up it is nearly transparent to the users. However it only works with git. From a7f5e717eb6d079de70db5f0c9aa13e747d0d81e Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 15 Jun 2018 09:37:05 -0400 Subject: [PATCH 83/94] Update CHANGELOG.md --- CHANGELOG.md | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb1ede..19f9ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,36 @@ -Release v1.20170127 - -* Starting CHANGELOG. +Release v1.20180615 +* Standardize on .blackbox for config. Use keyrings/live for backwards compatibility. +* Store keys in .blackbox directory (#218) +* Suggest committing changes to pubring.gpg when running blackbox_removeadmin (#248) +* Fix typo (#246) +* Improve installation instructions (#244) +* Fix replacing-expired-keys link in README (#241) +* Fix problems when gpg2 is installed next to gpg (#237) +* Many documentation corrections, updates, etc. +* Exclude default keyring from import (#223) +* .gitattributes not always updated (PR#146) +* Fix bugs related to updating .gitattributes (PR#146) +* Update readme with CircleCI link (#216) +* Run the tests on a CI (#215) +* Fixed Alpine compatibility (chmod) (#212) +* direct repobase message to stderr (#204) +* Improve Windows compatibility +* NEW: .gitattributes Set Unix-only files to eol=lf +* Silence 'not changed' output during keychain import (#200) +* Improve FreeBSD compatibility +* shred_file() outputs warning message to stderr. (#192) +* Don't complain about GPG_AGENT_INFO if using newer gpg-agent (#189) +* [FreeBSD] Fix use of chmod (#180) +* Requiring a file to be entered to finish editing (#175) +* Remove the key from the keyring when removing an admin (#173) +* Add FreeBSD support (#172) +* Add list admins commandline tool. (#170) +ignore backup files and secring.gpg in $BLACKBOXDATA (#169) +Allow parallel shredding of files (#167) +* Add/improve Mingw support +* Make "make confidence" less fragile +* And a lot, lot more. Release v1.20170309 @@ -24,3 +53,7 @@ Release v1.20170611 * blackbox_shred_all_files: BUGFIX: Does not shred files with spaces * blackbox_removeadmin: disable gpg's confirmation * Sync mk_rpm_fpmdir from master + +Release v1.20170127 + +* Starting CHANGELOG. From 1988a883a0d88a7f281a59f6714c767f41b61c40 Mon Sep 17 00:00:00 2001 From: Ben Limmer Date: Fri, 15 Jun 2018 18:04:07 -0600 Subject: [PATCH 84/94] Restore `make manual-install` with warning. (#258) --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 7c46181..0f955d7 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,13 @@ symlinks-install: @cd bin && for f in `find . -type f -iname "*" ! -iname "Makefile"`; do ln -fs `pwd`/$$f /usr/local/bin/$$f; done @echo 'Done.' +manual-install: + @echo '***************************************************************' + @echo '* DEPRECATED *' + @echo '* `make manual-install` is now called `make symlinks-install` *' + @echo '***************************************************************' + $(MAKE) symlinks-install + copy-install: @echo 'Copying files from ./bin to /usr/local/bin' @cd bin && for f in `find . -type f -iname "*" ! -iname "Makefile"`; do cp `pwd`/$$f /usr/local/bin/$$f; done From d268a9e16a6911ee9c23ce3a20eeb50433cc9ff9 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 18 Jun 2018 21:17:11 -0400 Subject: [PATCH 85/94] Release v1.20180615 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19f9ca3..e115ad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +Release v1.20180618 + +* Restore `make manual-install` with warning. (#258) + Release v1.20180615 * Standardize on .blackbox for config. Use keyrings/live for backwards compatibility. From 918632436ae2bcc929d1b7f68d4b0975a2ac7d5a Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 5 Jul 2018 10:31:14 -0400 Subject: [PATCH 86/94] Reformat README.md --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 80210f1..fe38dc1 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,18 @@ Rather than one GPG passphrase for all the files, each person with access has th Automated processes often need access to all the decrypted files. This is easy too. For example, suppose Git is being used for Puppet files. The master needs access to the decrypted version of all the files. Simply set up a GPG key for the Puppet master (or the role account that pushes new files to the Puppet master) and have that user run `blackbox_postdeploy` after any files are updated. -Getting started is easy. Just `cd` into a Git, Mercurial, Subversion or Perforce repository and run `blackbox_initialize`. After that, if a file is to be encrypted, run `blackbox_register_new_file` and you are done. Add and remove keys with `blackbox_addadmin` and `blackbox_removeadmin`. To view and/or edit a file, run `blackbox_edit`; this will decrypt the file and open with whatever is specified by your $EDITOR environment variable. When you close the editor the file will automatically be encrypted again and the temporary plaintext file will be shredded. If you need to leave the file decrypted while you update you can use the`blackbox_edit_start` to decrypt the file and `blackbox_edit_end` when you want to "put it back in the box." +Getting started is looks like this. +First, `cd` into a Git, Mercurial, Subversion +or Perforce repository and run `blackbox_initialize`. After that, +if a file is to be encrypted, run `blackbox_register_new_file` and +you are done. Add and remove keys with `blackbox_addadmin` and +`blackbox_removeadmin`. To view and/or edit a file, run `blackbox_edit`; +this will decrypt the file and open with whatever is specified by +your $EDITOR environment variable. When you close the editor the +file will automatically be encrypted again and the temporary plaintext +file will be shredded. If you need to leave the file decrypted while +you update you can use the`blackbox_edit_start` to decrypt the file +and `blackbox_edit_end` when you want to "put it back in the box." Why is this important? ====================== From 0b8c3df70b193c28c2d5a050735adace3fb60531 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 5 Jul 2018 08:26:19 -0700 Subject: [PATCH 87/94] Linked setting up of GPG key (#260) --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe38dc1..48c5c0d 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,11 @@ Rather than one GPG passphrase for all the files, each person with access has th Automated processes often need access to all the decrypted files. This is easy too. For example, suppose Git is being used for Puppet files. The master needs access to the decrypted version of all the files. Simply set up a GPG key for the Puppet master (or the role account that pushes new files to the Puppet master) and have that user run `blackbox_postdeploy` after any files are updated. Getting started is looks like this. -First, `cd` into a Git, Mercurial, Subversion +First, if you don't have a GPG key, set it up using instructions +such as: +[Set up GPG key](https://help.github.com/articles/generating-a-new-gpg-key/). +Now you are ready to go. +`cd` into a Git, Mercurial, Subversion or Perforce repository and run `blackbox_initialize`. After that, if a file is to be encrypted, run `blackbox_register_new_file` and you are done. Add and remove keys with `blackbox_addadmin` and From ebaa22a981b32f5164cb464c3f57786d2070d379 Mon Sep 17 00:00:00 2001 From: Ben Creasy Date: Tue, 10 Jul 2018 10:44:34 -0700 Subject: [PATCH 88/94] add nix method of install (#261) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 48c5c0d..a798f33 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Installation Instructions - *The Debian/Ubuntu way*: Check out the repo and make a DEB via `make packages-deb`; now you can distribute the DEB via local methods. (Requires [fpm](https://github.com/jordansissel/fpm).) - *The Antigen Way*: Add `antigen bundle StackExchange/blackbox` to your .zshrc - *The Zgen Way*: Add `zgen load StackExchange/blackbox` to your .zshrc where you're loading your other plugins. +- *The Nix Way*: `nix-env -i blackbox` Commands ======== From 74de17a4f63695d702550533992b488cbe760f8c Mon Sep 17 00:00:00 2001 From: winter0mute Date: Thu, 26 Jul 2018 16:24:32 +0200 Subject: [PATCH 89/94] Add blackbox_less. (#263) * Add blackbox_view and use PAGER (default to less) --- README.md | 1 + bin/blackbox_view | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 bin/blackbox_view diff --git a/README.md b/README.md index a798f33..7618b02 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Commands | `blackbox_edit_start ` | Decrypt a file so it can be updated | | `blackbox_edit_end ` | Encrypt a file after blackbox_edit_start was used | | `blackbox_cat ` | Decrypt and view the contents of a file | +| `blackbox_view ` | Like blackbox_cat but pipes to `less` or $PAGER | | `blackbox_diff` | Diff decrypted files against their original crypted version | | `blackbox_initialize` | Enable blackbox for a GIT or HG repo | | `blackbox_register_new_file ` | Encrypt a file for the first time | diff --git a/bin/blackbox_view b/bin/blackbox_view new file mode 100755 index 0000000..8f5a619 --- /dev/null +++ b/bin/blackbox_view @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# +# blackbox_view -- Decrypt a file, view it, shred it +# +set -e +source "${0%/*}/_blackbox_common.sh" + +for param in "$@" ; do + shreddable=0 + unencrypted_file=$(get_unencrypted_filename "$param") + if [[ ! -e "$unencrypted_file" ]]; then + "${BLACKBOX_HOME}/blackbox_edit_start" "$param" + shreddable=1 + fi + ${PAGER:-less} "$unencrypted_file" + if [[ $shreddable = 1 ]]; then + shred_file "$unencrypted_file" + fi +done From dc9fa326f468953d735d692dd42de74a16ee9163 Mon Sep 17 00:00:00 2001 From: r-savu Date: Mon, 13 Aug 2018 16:39:15 +0200 Subject: [PATCH 90/94] Improved compatibility: change"/bin/[x]" to "/usr/bin/env [x]" (#265) changed paths of the form "/bin/[x]" into "/usr/bin/env [x]" (#265) --- bin/_blackbox_common.sh | 2 +- blackbox.plugin.zsh | 2 +- tools/profile.d-usrblackbox-test.sh | 2 +- tools/test_functions.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 6d98786..1597495 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -140,7 +140,7 @@ function fail_if_not_on_cryptlist() { if ! is_on_cryptlist "$name" ; then echo "ERROR: $name not found in $BB_FILES" >&2 - echo "PWD=$(/bin/pwd)" >&2 + echo "PWD=$(/usr/bin/env pwd)" >&2 echo 'Exiting...' >&2 exit 1 fi diff --git a/blackbox.plugin.zsh b/blackbox.plugin.zsh index a1017ab..affa570 100755 --- a/blackbox.plugin.zsh +++ b/blackbox.plugin.zsh @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/usr/bin/env zsh # The MIT License (MIT) # Copyright (c) 2014 Stack Exchange, Inc. diff --git a/tools/profile.d-usrblackbox-test.sh b/tools/profile.d-usrblackbox-test.sh index 991787d..9e5dfb4 100755 --- a/tools/profile.d-usrblackbox-test.sh +++ b/tools/profile.d-usrblackbox-test.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Test profile.d-usrblackbox.sh diff --git a/tools/test_functions.sh b/tools/test_functions.sh index fda223e..68786fa 100755 --- a/tools/test_functions.sh +++ b/tools/test_functions.sh @@ -47,7 +47,7 @@ function assert_file_missing() { function assert_file_exists() { if [[ ! -e "$1" ]]; then echo "ASSERT FAILED: ${1} should exist." - echo "PWD=$(/bin/pwd -P)" + echo "PWD=$(/usr/bin/env pwd -P)" #echo "LS START" #ls -la #echo "LS END" From 9d305233caba57737391beb6400e79965f10dea1 Mon Sep 17 00:00:00 2001 From: Tobias Dubois Date: Thu, 27 Sep 2018 13:31:03 +0200 Subject: [PATCH 91/94] Add blackbox_decrypt_file (#270) Add a command for decrypting single files. It is currently just an alias for blackbox_edit_start. It is meant to be a more obvious command for decrypting a single file without editing it. Fixes #268 --- README.md | 1 + bin/blackbox_decrypt_file | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100755 bin/blackbox_decrypt_file diff --git a/README.md b/README.md index 7618b02..4d59e41 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Commands | `blackbox_deregister_file ` | Remove a file from blackbox | | `blackbox_list_files` | List the files maintained by blackbox | | `blackbox_list_admins` | List admins currently authorized for blackbox | +| `blackbox_decrypt_file ` | Decrypt a file | | `blackbox_decrypt_all_files` | Decrypt all managed files (INTERACTIVE) | | `blackbox_postdeploy` | Decrypt all managed files (batch) | | `blackbox_addadmin ` | Add someone to the list of people that can encrypt/decrypt secrets | diff --git a/bin/blackbox_decrypt_file b/bin/blackbox_decrypt_file new file mode 100755 index 0000000..2538381 --- /dev/null +++ b/bin/blackbox_decrypt_file @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# +# blackbox_decrypt_file -- Decrypt one or more blackbox files. +# + +set -e +source "${0%/*}/_blackbox_common.sh" + +if [ $# -eq 0 ]; then + echo >&2 "Please provide at least one file to decrypt" + exit 1 +fi + +"${BLACKBOX_HOME}/blackbox_edit_start" "$@" From 17ce90125b6acebde772db6b8afe45b2d74ff5e5 Mon Sep 17 00:00:00 2001 From: Kamil Wilczek Date: Wed, 3 Oct 2018 15:09:11 +0200 Subject: [PATCH 92/94] .blackbox is now the default config directory for new repos. (#272) - _blackbox_common.sh sets the default Blackbox directory for the new repositories using the first entry of the BLACKBOX_CANDIDATES array. This small change sets the first entry to the new .blackbox dir (instead of the keyring/live) --- bin/_blackbox_common.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 1597495..de5e1ab 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -16,10 +16,13 @@ source "${0%/*}"/_stack_lib.sh : "${BLACKBOX_HOME:="$(cd "${0%/*}" ; pwd)"}" ; # What are the candidates for the blackbox data directory? +# +# The order of candidates matter. The first entry of the array +# sets the default Blackbox directory for all new repositories. declare -a BLACKBOXDATA_CANDIDATES BLACKBOXDATA_CANDIDATES=( - 'keyrings/live' '.blackbox' + 'keyrings/live' ) # If $EDITOR is not set, set it to "vi": From ab1430b74d7849c18b4a1bc09d84235130804517 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 3 Oct 2018 10:46:07 -0400 Subject: [PATCH 93/94] Testing: Fix confidence test. --- tools/confidence_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index abca0a7..0a69fbb 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -5,6 +5,9 @@ export PATH="${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/ export LANG=C.UTF-8 # Required ro "gpg --export" to work properly. +# TODO(tlim): The tests are hardcoded to this directory. This should be fixed. +export BLACKBOXDATA=keyrings/live + # This script requires many utilities, some are not # required by the usual blackbox scripts. Test to make # sure we have them all. From d6f997e8dff8bbb1c085824391189de59c9446c7 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Fri, 7 Dec 2018 13:49:38 -0500 Subject: [PATCH 94/94] README.md: Minor fixes --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4d59e41..5c4060e 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,14 @@ Table of Contents - [How to use the secrets with Puppet?](#how-to-use-the-secrets-with-puppet) - [Entire files](#entire-files) - [Small strings](#small-strings) -- [How to enroll a new file into the system?](#how-to-enroll-a-new-file-into-the-system) -- [How to remove a file from the system?](#how-to-remove-a-file-from-the-system) -- [How to indoctrinate a new user into the system?](#how-to-indoctrinate-a-new-user-into-the-system) -- [How to remove a user from the system?](#how-to-remove-a-user-from-the-system) -- [Enabling BlackBox For a Repo](#enabling-blackbox-for-a-repo) +- File Management + - [How to enroll a new file into the system?](#how-to-enroll-a-new-file-into-the-system) + - [How to remove a file from the system?](#how-to-remove-a-file-from-the-system) +- User Management + - [How to indoctrinate a new user into the system?](#how-to-indoctrinate-a-new-user-into-the-system) + - [How to remove a user from the system?](#how-to-remove-a-user-from-the-system) +- Repo Management + - [Enabling BlackBox For a Repo](#enabling-blackbox-for-a-repo) - [Set up automated users or “role accounts”](#set-up-automated-users-or-role-accounts) - [Replacing expired keys](#replacing-expired-keys) - [Some common errors](#some-common-errors) @@ -366,6 +369,7 @@ Ask someone that already has access to re-encrypt the data files. This gives you Pre-check: Verify the new keys look good. ``` +git pull # Or whatever is required for your system gpg --homedir=.blackbox --list-keys ```