[slock] Add a dummy error handler to prevent X from terminating slock
Petr Šabata
psabata at fedoraproject.org
Mon Jan 23 08:03:47 UTC 2012
commit 7716e489b56b945d70a2c3d29306b03fe2fb4c59
Author: Petr Šabata <contyk at redhat.com>
Date: Mon Jan 23 09:00:29 2012 +0100
Add a dummy error handler to prevent X from terminating slock
slock-0.9-dummy-error-handler.patch | 81 +++++++++++++++++++++++++++++++++++
slock.spec | 7 +++-
2 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/slock-0.9-dummy-error-handler.patch b/slock-0.9-dummy-error-handler.patch
new file mode 100644
index 0000000..58fc1f5
--- /dev/null
+++ b/slock-0.9-dummy-error-handler.patch
@@ -0,0 +1,81 @@
+# HG changeset patch
+# User anselm at garbe.us
+# Date 1327255090 -3600
+# Node ID 0797174221851261d7023091c14eea4cf8ea5bf5
+# Parent d8975fb0640f10fd947ff9be92779156a9f4caaf
+added dummy error handler to prevent X from terminating slock just in case
+
+diff -r d8975fb0640f -r 079717422185 slock.c
+--- a/slock.c Thu Apr 21 08:22:47 2011 +0000
++++ b/slock.c Sun Jan 22 18:58:10 2012 +0100
+@@ -46,7 +46,7 @@
+
+ #ifndef HAVE_BSD_AUTH
+ static const char *
+-get_password(void) { /* only run as root */
++getpw(void) { /* only run as root */
+ const char *rval;
+ struct passwd *pw;
+
+@@ -74,9 +74,9 @@
+
+ static void
+ #ifdef HAVE_BSD_AUTH
+-read_password(Display *dpy)
++readpw(Display *dpy)
+ #else
+-read_password(Display *dpy, const char *pws)
++readpw(Display *dpy, const char *pws)
+ #endif
+ {
+ char buf[32], passwd[256];
+@@ -213,6 +213,11 @@
+ exit(EXIT_FAILURE);
+ }
+
++static int
++xerrordummy(Display *dpy, XErrorEvent *ee) {
++ return 0;
++}
++
+ int
+ main(int argc, char **argv) {
+ #ifndef HAVE_BSD_AUTH
+@@ -224,7 +229,7 @@
+ struct st_lock **locks;
+
+ if((argc == 2) && !strcmp("-v", argv[1]))
+- die("slock-%s, © 2006-2008 Anselm R Garbe", VERSION);
++ die("slock-%s, © 2006-2012 Anselm R Garbe", VERSION);
+ else if(argc != 1)
+ usage();
+
+@@ -232,12 +237,13 @@
+ die("no passwd entry for you");
+
+ #ifndef HAVE_BSD_AUTH
+- pws = get_password();
++ pws = getpw();
+ #endif
+
+ if(!(dpy = XOpenDisplay(0)))
+ die("cannot open display");
+-
++ /* prevent default error handler to take over */
++ XSetErrorHandler(xerrordummy);
+ /* Get the number of screens in display "dpy" and blank them all. */
+ nscreens = ScreenCount(dpy);
+ locks = malloc(sizeof(struct st_lock *) * nscreens);
+@@ -251,9 +257,9 @@
+
+ /* Everything is now blank. Now wait for the correct password. */
+ #ifdef HAVE_BSD_AUTH
+- read_password(dpy);
++ readpw(dpy);
+ #else
+- read_password(dpy, pws);
++ readpw(dpy, pws);
+ #endif
+
+ /* Password ok, unlock everything and quit. */
+
diff --git a/slock.spec b/slock.spec
index 5ce8cb0..58826e7 100644
--- a/slock.spec
+++ b/slock.spec
@@ -1,6 +1,6 @@
Name: slock
Version: 0.9
-Release: 10%{?dist}
+Release: 11%{?dist}
Summary: Simple X display locker
Group: User Interface/X
License: MIT
@@ -11,6 +11,7 @@ Patch0: slock-0.9-flags.patch
Patch101: slock-0.9-dpms-timeout.patch
Patch102: slock-0.9-old-style-multiheaded-setup.patch
Patch103: slock-0.9-passwd-availability-check.patch
+Patch104: slock-0.9-dummy-error-handler.patch
BuildRequires: libX11-devel libXext-devel
@@ -28,6 +29,7 @@ the local pub.
%patch101 -p1 -b .dpms-timeout
%patch102 -p1 -b .multiheaded
%patch103 -p1 -b .passwd
+%patch104 -p1 -b .dummy-err-handler
%build
make %{?_smp_mflags}
@@ -43,6 +45,9 @@ make install PREFIX=%{buildroot}/usr
# binary for light windowmanagers, and it shouldn't appear in applications menu
%changelog
+* Mon Jan 23 2012 Petr Šabata <contyk at redhat.com> - 0.9-11
+- Add a dummy error handler to prevent X from terminating slock (079717422185)
+
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.9-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list