aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranselm@garbe.us <unknown>2012-01-22 18:58:10 +0100
committeranselm@garbe.us <unknown>2012-01-22 18:58:10 +0100
commit5a5c581285e86fe53c9602c7e0fb7e19ec742391 (patch)
treecafadbcc768bbe9c77fdc3d5b0c676642574a1b3
parentede2935e10fdab76994676d5052b571907612199 (diff)
added dummy error handler to prevent X from terminating slock just in case
-rw-r--r--slock.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/slock.c b/slock.c
index be10f5d..2dce109 100644
--- a/slock.c
+++ b/slock.c
@@ -46,7 +46,7 @@ die(const char *errstr, ...) {
46 46
47#ifndef HAVE_BSD_AUTH 47#ifndef HAVE_BSD_AUTH
48static const char * 48static const char *
49get_password(void) { /* only run as root */ 49getpw(void) { /* only run as root */
50 const char *rval; 50 const char *rval;
51 struct passwd *pw; 51 struct passwd *pw;
52 52
@@ -74,9 +74,9 @@ get_password(void) { /* only run as root */
74 74
75static void 75static void
76#ifdef HAVE_BSD_AUTH 76#ifdef HAVE_BSD_AUTH
77read_password(Display *dpy) 77readpw(Display *dpy)
78#else 78#else
79read_password(Display *dpy, const char *pws) 79readpw(Display *dpy, const char *pws)
80#endif 80#endif
81{ 81{
82 char buf[32], passwd[256]; 82 char buf[32], passwd[256];
@@ -213,6 +213,11 @@ usage(void) {
213 exit(EXIT_FAILURE); 213 exit(EXIT_FAILURE);
214} 214}
215 215
216static int
217xerrordummy(Display *dpy, XErrorEvent *ee) {
218 return 0;
219}
220
216int 221int
217main(int argc, char **argv) { 222main(int argc, char **argv) {
218#ifndef HAVE_BSD_AUTH 223#ifndef HAVE_BSD_AUTH
@@ -224,7 +229,7 @@ main(int argc, char **argv) {
224 struct st_lock **locks; 229 struct st_lock **locks;
225 230
226 if((argc == 2) && !strcmp("-v", argv[1])) 231 if((argc == 2) && !strcmp("-v", argv[1]))
227 die("slock-%s, © 2006-2008 Anselm R Garbe", VERSION); 232 die("slock-%s, © 2006-2012 Anselm R Garbe", VERSION);
228 else if(argc != 1) 233 else if(argc != 1)
229 usage(); 234 usage();
230 235
@@ -232,12 +237,13 @@ main(int argc, char **argv) {
232 die("no passwd entry for you"); 237 die("no passwd entry for you");
233 238
234#ifndef HAVE_BSD_AUTH 239#ifndef HAVE_BSD_AUTH
235 pws = get_password(); 240 pws = getpw();
236#endif 241#endif
237 242
238 if(!(dpy = XOpenDisplay(0))) 243 if(!(dpy = XOpenDisplay(0)))
239 die("cannot open display"); 244 die("cannot open display");
240 245 /* prevent default error handler to take over */
246 XSetErrorHandler(xerrordummy);
241 /* Get the number of screens in display "dpy" and blank them all. */ 247 /* Get the number of screens in display "dpy" and blank them all. */
242 nscreens = ScreenCount(dpy); 248 nscreens = ScreenCount(dpy);
243 locks = malloc(sizeof(struct st_lock *) * nscreens); 249 locks = malloc(sizeof(struct st_lock *) * nscreens);
@@ -251,9 +257,9 @@ main(int argc, char **argv) {
251 257
252 /* Everything is now blank. Now wait for the correct password. */ 258 /* Everything is now blank. Now wait for the correct password. */
253#ifdef HAVE_BSD_AUTH 259#ifdef HAVE_BSD_AUTH
254 read_password(dpy); 260 readpw(dpy);
255#else 261#else
256 read_password(dpy, pws); 262 readpw(dpy, pws);
257#endif 263#endif
258 264
259 /* Password ok, unlock everything and quit. */ 265 /* Password ok, unlock everything and quit. */