Bug#864932: gparted fails if PS_FORMAT options are specified

2020-01-30 Thread Nicolas Braud-Santoni
On Fri, Jan 31, 2020 at 02:29:08AM +0100, Nicolas Braud-Santoni wrote:
> Please find enclosed a patch that fixes the issue,
> using pgrep(1) instead of ps(1).

This works better if I recall to attach the patch  >_>'
Subject: gparted: Use pgrep(1) instead of ps(1) and grep(1)

Unlike ps(1), pgrep(1) is not affected by environment variables such as
PS_FORMAT, so it is safe to use without assuming PS_FORMAT is similar-enough
to the default.

Moreover, this is more efficient and less error-prone.
---
 gparted.in | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gparted.in b/gparted.in
index 3f9b0f1..a4e71ff 100755
Origin: vendor
Bug-Debian: https://bugs.debian.org/864932
From: Nicolas Braud-Santoni 
Forwarded: no
Applied-Upstream: no
Last-Update: 2020-01-31

--- a/gparted.in
+++ b/gparted.in
@@ -30,7 +30,7 @@
 #
 #  Only permit one instance of GParted to execute at a time
 #
-if test "z`ps -e | grep gpartedbin`" != "z"; then
+if test -n "$(pgrep gpartedbin)"; then
 	echo "The process gpartedbin is already running."
 	echo "Only one gpartedbin process is permitted."
 	exit 1
@@ -94,7 +94,7 @@ fi
 HAVE_SYSTEMCTL=no
 for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
 	if test -x "$k/systemctl"; then
-		if test "z`ps -e | grep systemd`" != "z"; then
+		if test -n "$(pgrep systemd)"; then
 			HAVE_SYSTEMCTL=yes
 			break
 		fi
@@ -107,7 +107,7 @@ done
 #
 HAVE_UDISKS2_INHIBIT=no
 if test -x "/usr/lib/udisks2/udisks2-inhibit"; then
-	if test "z`ps -e | grep 'udisksd'`" != "z"; then
+	if test -n "$(pgrep udisksd)"; then
 		HAVE_UDISKS2_INHIBIT=yes
 	fi
 fi
@@ -119,7 +119,7 @@ fi
 HAVE_UDISKS=no
 for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
 	if test -x "$k/udisks"; then
-		if test "z`ps -e | grep udisks-daemon`" != "z"; then
+		if test -n "$(pgrep udisks-daemon)"; then
 			HAVE_UDISKS=yes
 			break
 		fi
@@ -133,7 +133,7 @@ done
 HAVE_HAL_LOCK=no
 for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
 	if test -x "$k/hal-lock"; then
-		if test "z`ps -e | grep hald`" != "z"; then
+		if test -n "$(pgrep hald)"; then
 			HAVE_HAL_LOCK=yes
 			break
 		fi


signature.asc
Description: PGP signature


Bug#864932: gparted fails if PS_FORMAT options are specified

2020-01-30 Thread Nicolas Braud-Santoni
Control: tag -1 + patch pending upstream

Hi js,

On Sat, Jun 17, 2017 at 11:37:18AM -0400, js wrote:
> Dear Maintainer,
> 
> I have set PS_FORMAT environment variable to control the output of ps.
> As a result, the following test from the gparted script always fails:
> 
> #
> #  Only permit one instance of GParted to execute at a time
> #
> if test "z`ps -e | grep gpartedbin`" != "z"; then ## 
> env-dependent test
> echo "The process gpartedbin is already running."
>   echo "Only one gpartedbin process is permitted."
>   exit 1
>   fi

This is absolutely correct.

Please find enclosed a patch that fixes the issue,
using pgrep(1) instead of ps(1).

I commited the patch to the packaging repository, so it should be part of the
next upload of gparted, and I am forwarding it upstream.


Best regards,

  nicoo


signature.asc
Description: PGP signature