[pass] [PASS][PATCH] Renamed filelock for clarity. (new feature passmenu multi-clip)

Marcos Alano marcoshalano at gmail.com
Wed Jul 20 00:45:03 CEST 2016


Could be a file instead of a folder.

On Tue, Jul 19, 2016, 19:36 mitfree <lists at ampling.com> wrote:

> Hi,
>
> This is my third patch to passmenu; the last was on May 14th, 2016.
>
> If you install this patch, passmenu lock will have a '.lock' extension.
> My first email on May 8th, 2016 better explains why I'm using a file
> lock and adding a multiclip feature in the first place. This file lock
> business is just an empty folder which holds the pid of passmenu in the
> filename. It's a safe (cross platform) way to prevent two passmenu sessions
> from running at the same time. I'm aiming for a more consistent user
> experience.
>
> I hope you find this update to be as stable as I found the last patch.
> I'm testing on Linux. I would particularly welcome feedback from others.
>
> For those who like github:
>
> https://github.com/ampling/pass/blob/passmenu_multi-clip/contrib/dmenu/passmenu
>
>
> From dacf9f38ba38b86b79420d2cc3b25ff0191ed9b2 Mon Sep 17 00:00:00 2001
> From: ampling <ampling at users.noreply.github.com>
> Date: Tue, 19 Jul 2016 16:11:10 -0400
> Subject: [PATCH] Renamed filelock for clarity.
>
> ---
>  contrib/dmenu/passmenu | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
> index 40dfe97..e1835d2 100755
> --- a/contrib/dmenu/passmenu
> +++ b/contrib/dmenu/passmenu
> @@ -26,8 +26,8 @@ _finish () {
>    [[ True == $cleanup ]] &&
>    printf "$before" | base64 -d | xclip -sel "$X_SELECTION" -i
>    [[ True = "$cleanup" ]] &&
> -  if compgen -G "/tmp/passmenulock.1000*" >/dev/null 2>&1 ;then
> -    rmdir /tmp/passmenulock.*.*."$$" >/dev/null 2>&1
> +  if compgen -G "/tmp/passmenu.1000*" >/dev/null 2>&1 ;then
> +    rmdir /tmp/passmenu.*.*."$$".lock >/dev/null 2>&1
>    fi
>    exit
>  }
> @@ -47,22 +47,23 @@ trap _finish EXIT
>  ## Clearing old filelock(s).
>  umask 077
>  stalelock=( "${stalelock:-''}" )
> -stalelock=( "$(find '/tmp' -maxdepth 1 -name "passmenulock."$userID".*"
> -user $(whoami) -print0  -quit)" ) &&
> +stalelock=( "$(find '/tmp' -maxdepth 1 -name "passmenu."$userID".*" -user
> $(whoami) -print0  -quit -type d)" ) &&
>  if test -n "$stalelock" ;then
> +  stalename=${stalelock%.*}
>    report=( "$(ps -u $(id -u $(whoami)) aux | grep "bash" |
>    grep "passmenu" | grep -v "$$")" )
> -  stalePID=( "$(printf $stalelock |
> -  sed -e "s/\/tmp\/passmenulock\.[0-9]\{1,6\}\?\..*\.//g")" )
> +  stalePID=( "$(printf $stalename |
> +  sed -e "s/\/tmp\/passmenu\.[0-9]\{1,6\}\?\..*\.//g")" )
>    if [[ "$report" == *"$stalePID"* ]] ;then
>      kill "$stalePID" || exit 1
>    else
> -    rmdir /tmp/passmenulock."$userID".* >/dev/null 2>&1 ||
> +    rmdir /tmp/passmenu."$userID".* >/dev/null 2>&1 ||
>      { echo ":: Unable to clear old filelock"; exit 1; }
>    fi
>  fi
>
>  ## Adding a new filelock
> -( mktemp -d "/tmp/passmenulock."$userID".XXXXXXXXXX"."$$" >/dev/null 2>&1
> && cleanup=True ||
> +( mktemp -d "/tmp/passmenu."$userID".XXXXXXXXXX"."$$".lock >/dev/null
> 2>&1 && cleanup=True ||
>    { echo >&2 ":: Unable to make a filelock."; exit 1; } )
>
>  cleanup=True
> --
> 2.9.0
>
>
>
>
>
> --
> At your service,
> mitfree
> https://ampling.com
>
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/password-store
>
-- 

Marcos H. Alano

Sent from my Android
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160719/80e963b7/attachment.html>


More information about the Password-Store mailing list