From a38962782f0a88e5f8c4ae4a9a903d570ba9469d Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Mon, 19 Aug 2024 23:21:26 -0300 Subject: [PATCH] Add libexec/portzap/utils/get-umask --- libexec/portzap/commands/portzap-install | 3 ++- libexec/portzap/utils/get-umask | 6 ++++++ libexec/portzap/utils/git/run | 6 ++++-- libexec/portzap/utils/install/run | 6 ++++-- share/portzap/CHANGELOG | 4 ++++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 libexec/portzap/utils/get-umask diff --git a/libexec/portzap/commands/portzap-install b/libexec/portzap/commands/portzap-install index 0e4e331..bbca9f0 100755 --- a/libexec/portzap/commands/portzap-install +++ b/libexec/portzap/commands/portzap-install @@ -6,6 +6,7 @@ set -e localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap git="${libexec}"/utils/git/run +mask=$("${libexec}"/utils/get-umask) gitdir=$1 installdir=$2 revfile=$3 @@ -33,7 +34,7 @@ if [ -e "${revfile}" ]; then else ## # install from scratch - umask u=rwX,g=rX,o= + umask "${mask}" "${libexec}"/utils/install/run -d "${installdir}" find -s . \ -maxdepth 1 \ diff --git a/libexec/portzap/utils/get-umask b/libexec/portzap/utils/get-umask new file mode 100644 index 0000000..c7ac963 --- /dev/null +++ b/libexec/portzap/utils/get-umask @@ -0,0 +1,6 @@ +#!/bin/sh +set -e + +## +# main +echo "u=rwX,g=rX,o=" diff --git a/libexec/portzap/utils/git/run b/libexec/portzap/utils/git/run index 92da168..ed23c4c 100644 --- a/libexec/portzap/utils/git/run +++ b/libexec/portzap/utils/git/run @@ -3,11 +3,13 @@ set -e ## # variables +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} +libexec="${localbase}"/libexec/portzap git=$(which git) -mode=u=rwX,g=rX,o= +mask=$("${libexec}"/utils/get-umask) ## # main doas -n \ -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${*}" + /bin/sh -c "umask ${mask}; ${git} ${*}" diff --git a/libexec/portzap/utils/install/run b/libexec/portzap/utils/install/run index 166fb34..5ca1c65 100755 --- a/libexec/portzap/utils/install/run +++ b/libexec/portzap/utils/install/run @@ -3,12 +3,14 @@ set -e ## # variables -mode=u=rwX,g=rX,o= +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} +libexec="${localbase}"/libexec/portzap +mask=$("${libexec}"/utils/get-umask) ## # main install -o root \ -g _portzap \ - -m "${mode}" \ + -m "${mask}" \ -v \ "${@}" diff --git a/share/portzap/CHANGELOG b/share/portzap/CHANGELOG index 111c614..4763853 100644 --- a/share/portzap/CHANGELOG +++ b/share/portzap/CHANGELOG @@ -1,5 +1,9 @@ * vNEXT +** Add 'libexec/portzap/utils/get-umask' +Add a single source of truth for the mask given to umask +by git and portzap-install + ** Break up 'portzap-install' into multiple files 'libexec/portzap/utils/install/' contains files that cover both a fresh install and applying an update