From e724923eb44faa561995cebb6fe76c1874442eba Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Thu, 2 Jan 2020 21:14:32 -0800 Subject: [PATCH] bin: Work around permission bug in op --- bin/op | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/op b/bin/op index b49a6cb..4c0b8a3 100755 --- a/bin/op +++ b/bin/op @@ -2,11 +2,24 @@ set -euo pipefail +# The 1password-cli (op) seems to have a bug where it doesn't create this +# tempdir with user write privileges, making it impossible to sign in. +# So we'll create and chown it every time. +OP_RUNTIME_DIR="/tmp/com.agilebits.op.$(id -u)" + +if [ -d "${OP_RUNTIME_DIR}" ]; then + chmod u+x "${OP_RUNTIME_DIR}" +else + # With `-p` the mode setting only applies to the deepest directory. + # + # shellcheck disable=SC2174 + mkdir -m 700 -p "${OP_RUNTIME_DIR}" +fi + OP_SESSION_DIR="${XDG_RUNTIME_DIR}/op" OP_SESSION_FILE="${OP_SESSION_DIR}/session_token" -# With `-p` the mode setting only applies to the deepest directory. This is -# exactly what I want here. +# With `-p` the mode setting only applies to the deepest directory. # # shellcheck disable=SC2174 [ -d "${OP_SESSION_DIR}" ] || mkdir -m 700 -p "${OP_SESSION_DIR}"