[slock] Prevent multiple slock instances
Petr Šabata
psabata at fedoraproject.org
Fri Aug 3 08:23:07 UTC 2012
commit 8f99b361f7631d8270a732af05551dc9b1abafd2
Author: Petr Šabata <contyk at redhat.com>
Date: Fri Aug 3 10:21:23 2012 +0200
Prevent multiple slock instances
slock-0.9-dpms-timeout.patch | 57 -----
slock-0.9-dummy-error-handler.patch | 81 --------
slock-0.9-old-style-multiheaded-setup.patch | 297 ---------------------------
slock-0.9-passwd-availability-check.patch | 21 --
slock-1.0-multislock.patch | 51 +++++
slock-1.0-pwlen.patch | 21 ++
slock.spec | 9 +-
7 files changed, 80 insertions(+), 457 deletions(-)
---
diff --git a/slock-1.0-multislock.patch b/slock-1.0-multislock.patch
new file mode 100644
index 0000000..aff9af3
--- /dev/null
+++ b/slock-1.0-multislock.patch
@@ -0,0 +1,51 @@
+
+# HG changeset patch
+# User garbeam at gmail.com
+# Date 1343937258 -7200
+# Node ID 859881ad34711bf1187c040472d36fe114815f9d
+# Parent 639240c84cb217348cf342a1f53d74ef6c567b5a
+applied andres' multi-slock fix, thanks for spotting this issue
+
+diff -r 639240c84cb2 -r 859881ad3471 slock.c
+--- a/slock.c Sun Apr 15 11:58:16 2012 +0200
++++ b/slock.c Thu Aug 02 21:54:18 2012 +0200
+@@ -1,3 +1,4 @@
++
+ /* See LICENSE file for license details. */
+ #define _XOPEN_SOURCE 500
+ #if HAVE_SHADOW_H
+@@ -211,9 +212,9 @@
+ break;
+ usleep(1000);
+ }
+- running = (len > 0);
+ }
+
++ running &= (len > 0);
+ if(!running) {
+ unlockscreen(dpy, lock);
+ lock = NULL;
+@@ -257,10 +258,20 @@
+ locks = malloc(sizeof(Lock *) * nscreens);
+ if(locks == NULL)
+ die("slock: malloc: %s", strerror(errno));
+- for(screen = 0; screen < nscreens; screen++)
+- locks[screen] = lockscreen(dpy, screen);
++ int nlocks = 0;
++ for(screen = 0; screen < nscreens; screen++) {
++ if ( (locks[screen] = lockscreen(dpy, screen)) != NULL)
++ nlocks++;
++ }
+ XSync(dpy, False);
+
++ /* Did we actually manage to lock something? */
++ if (nlocks == 0) { // nothing to protect
++ free(locks);
++ XCloseDisplay(dpy);
++ return 1;
++ }
++
+ /* Everything is now blank. Now wait for the correct password. */
+ #ifdef HAVE_BSD_AUTH
+ readpw(dpy);
+
diff --git a/slock-1.0-pwlen.patch b/slock-1.0-pwlen.patch
new file mode 100644
index 0000000..8bde29c
--- /dev/null
+++ b/slock-1.0-pwlen.patch
@@ -0,0 +1,21 @@
+
+# HG changeset patch
+# User anselm at garbe.us
+# Date 1334483896 -7200
+# Node ID 639240c84cb217348cf342a1f53d74ef6c567b5a
+# Parent 0eade055cef0f34bf8d1340166d0bdd80d33b27c
+added Ben's password placeholder entry kludge
+
+diff -r 0eade055cef0 -r 639240c84cb2 slock.c
+--- a/slock.c Sat Mar 17 18:03:25 2012 +0100
++++ b/slock.c Sun Apr 15 11:58:16 2012 +0200
+@@ -56,7 +56,7 @@
+ rval = pw->pw_passwd;
+
+ #if HAVE_SHADOW_H
+- {
++ if (strlen(rval) >= 1) { /* kludge, assumes pw placeholder entry has len >= 1 */
+ struct spwd *sp;
+ sp = getspnam(getenv("USER"));
+ if(!sp)
+
diff --git a/slock.spec b/slock.spec
index ac82516..ac638b0 100644
--- a/slock.spec
+++ b/slock.spec
@@ -1,6 +1,6 @@
Name: slock
Version: 1.0
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Simple X display locker
Group: User Interface/X
License: MIT
@@ -8,6 +8,8 @@ URL: http://tools.suckless.org/%{name}
Source0: http://dl.suckless.org/tools/%{name}-%{version}.tar.gz
Patch0: slock-1.0-dualcolor.patch
Patch1: slock-1.0-config.patch
+Patch2: slock-1.0-pwlen.patch
+Patch3: slock-1.0-multislock.patch
BuildRequires: libX11-devel libXext-devel
%description
@@ -19,6 +21,8 @@ are out with friends or fetching some food from the local pub.
%setup -q
%patch0 -p1 -b .dualcolor
%patch1 -p1 -b .config
+%patch2 -p1 -b .pwlen
+%patch3 -p1 -b .multislock
%build
make %{?_smp_mflags}
@@ -33,6 +37,9 @@ make install PREFIX=%{buildroot}/usr
# binary for light windowmanagers, and it shouldn't appear in applications menu
%changelog
+* Fri Aug 03 2012 Petr Šabata <contyk at redhat.com> - 1.0-4
+- Prevent multiple instances of slock (859881ad3471)
+
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
More information about the scm-commits
mailing list