[hackers] [slock] added dummy error handler to prevent X from terminating slock just in case || anselm
changeset: 43:079717422185
tag: tip
user: anselm_AT_garbe.us
date: Sun Jan 22 18:58:10 2012 +0100
files: slock.c
description:
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
_AT_@ -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;
_AT_@ -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];
_AT_@ -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
_AT_@ -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();
_AT_@ -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);
_AT_@ -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. */
Received on Sun Jan 22 2012 - 17:57:43 CET
This archive was generated by hypermail 2.3.0
: Sun Jan 22 2012 - 18:00:07 CET