X-Original-To: alpine-aports@lists.alpinelinux.org Received: from sender153-mail.zoho.com (sender153-mail.zoho.com [74.201.84.153]) by lists.alpinelinux.org (Postfix) with ESMTP id 985C45C4528 for ; Sun, 4 Dec 2016 01:14:10 +0000 (GMT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id; b=eRpMvGE65AkCM5C+81FN+1P2jxbMtLRwW3xPzcoT1xh1HAm7CiWY+OzUcyjAqR1y6kBXW9K9M1kb hxh5VQxQ9NFL8f00kd7FUelaoYV4PRmJa8EoucbNZnGy9gFHAZBs Received: from localhost (89-74-198-11.dynamic.chello.pl [89.74.198.11]) by mx.zohomail.com with SMTPS id 1480814030954869.5677820808469; Sat, 3 Dec 2016 17:13:50 -0800 (PST) From: Przemyslaw Pawelczyk To: ncopa@alpinelinux.org Cc: alpine-aports@lists.alpinelinux.org, timo.teras@iki.fi Subject: [alpine-aports] [PATCH] main/gparted: Use reliable way of detecting gpartedbin process existence. Date: Sun, 4 Dec 2016 02:13:42 +0100 Message-Id: <20161204011342.8865-1-przemoc@zoho.com> X-Mailer: git-send-email 2.8.3 X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: Otherwise gparted won't start saying that gpartedbin is already running. Problem has been spotted on AL 3.4.6 by Thijs de Vries and reported on IRC channel (#alpine-linux). Patch should be applied also on 3.4-stable w/ obvious adaptations (preserving 3.4-stable's pkgver, bumping pkgrel, fixing collisions in source and *sums) and less obvious one (removing prepare() function, because otherwise patch won't be applied). --- main/gparted/APKBUILD | 12 ++++-- ...Use-reliable-way-of-detecting-gpartedbin-.patch | 46 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 main/gparted/gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch diff --git a/main/gparted/APKBUILD b/main/gparted/APKBUILD index 4d874a625925..25688bb8c809 100644 --- a/main/gparted/APKBUILD +++ b/main/gparted/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa pkgname=gparted pkgver=0.26.1 -pkgrel=1 +pkgrel=2 pkgdesc="a graphical partition editor for creating, reorganizing, and deleting disk partitions" url="http://gparted.sourceforge.net/" arch="all" @@ -12,6 +12,7 @@ install= subpackages="$pkgname-doc $pkgname-lang" source="http://downloads.sourceforge.net/project/gparted/gparted/gparted-$pkgver/gparted-$pkgver.tar.gz musl-fix-sscanf.patch + gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch " builddir="$srcdir"/$pkgname-$pkgver @@ -37,8 +38,11 @@ package() { } md5sums="b9c5f6b5ffd37400bd4bf5929e9b1781 gparted-0.26.1.tar.gz -c8a5842bf213ef02eeb85d95e3237372 musl-fix-sscanf.patch" +c8a5842bf213ef02eeb85d95e3237372 musl-fix-sscanf.patch +09068679d98cea2c6f185beb1e7022b8 gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch" sha256sums="2f54b642d25aef5ccdd9f06671c16350c005834df5c3eb13a9b7f33246372dc1 gparted-0.26.1.tar.gz -427c07a7b15deacaec7754960d883da8811b82272dd655cad27c6071269e8822 musl-fix-sscanf.patch" +427c07a7b15deacaec7754960d883da8811b82272dd655cad27c6071269e8822 musl-fix-sscanf.patch +9cb5c75de4b5c8dae243947d1fa370bc88a59a3e3473cf51adad471d1d16576d gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch" sha512sums="cba792751f8e984cbb4e1e0baaa97d0022ba47bd400312734ed5ae4a1bea07bc46ed522ca19a84b74ad503387fc9bd9d9cd85cdd647ba2ec028b39f8da502b67 gparted-0.26.1.tar.gz -aaa3f771e100d89c756c63e206090ada1c316b6028cb4ca79142a82fab7a29b54ac7229e06098eb5265bce32219a2df28f9f79c11d60d0f41ee9e538bb1f8641 musl-fix-sscanf.patch" +aaa3f771e100d89c756c63e206090ada1c316b6028cb4ca79142a82fab7a29b54ac7229e06098eb5265bce32219a2df28f9f79c11d60d0f41ee9e538bb1f8641 musl-fix-sscanf.patch +3d867650e4804b0c958e000cf08b17dce9e172477d06e93c75aa44baf0421cabd92b20b6ba9c384aeddf63ece1dec8c2675cf35eca25b1e331cda356cb459640 gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch" diff --git a/main/gparted/gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch b/main/gparted/gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch new file mode 100644 index 000000000000..d9e935b2ee29 --- /dev/null +++ b/main/gparted/gparted.in-Use-reliable-way-of-detecting-gpartedbin-.patch @@ -0,0 +1,46 @@ +From 640709cd2eeb5037b871e6d96ffc186779bcf387 Mon Sep 17 00:00:00 2001 +From: Przemyslaw Pawelczyk +Date: Sun, 4 Dec 2016 01:55:43 +0100 +Subject: [PATCH] gparted.in: Use reliable way of detecting gpartedbin process + existence. + +Grepping ps output had only one advantage, it's using tools available in +any POSIX system. pidof looks for exact process name, regardless of +the path used to call the binary (which is not true for pgrep). +pidof is provided by busybox, procps-ng, sysvinit-tools or as a +stand-alone package on some systems. + +We cannot guarantee that if gpartedbin is running there, then it's +really gpartedbin and not something else renamed to it. +We could try to detect if it is at least gpartedbin from a known +location by checking $(readlink /proc/$PID/exe), but it wouldn't prevent +user from running its own compiled gpartedbin from other location. + +ps, pgrep or pidof are simply not the right tools to prevent running +more than one instance of the program. If such feature is really +needed, then it should be built into the program to make it truly +reliable (assuming correct implementation, obviously). +Alternatively, if the program always run via one and only one +supervisor, then the supervisor should be able to do the right job, +because only parent process can reliably tell when it created the child, +or when the child process execed into given binary or died. +--- + gparted.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gparted.in b/gparted.in +index c435bac..625e50f 100755 +--- 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 pidof -s gpartedbin >/dev/null; then + echo "The process gpartedbin is already running." + echo "Only one gpartedbin process is permitted." + exit 1 +-- +2.8.3 + -- 2.8.3 --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---