diff options
-rw-r--r-- | slock.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -46,7 +46,7 @@ die(const char *errstr, ...) { | |||
46 | 46 | ||
47 | #ifndef HAVE_BSD_AUTH | 47 | #ifndef HAVE_BSD_AUTH |
48 | static const char * | 48 | static const char * |
49 | get_password(void) { /* only run as root */ | 49 | getpw(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 | ||
75 | static void | 75 | static void |
76 | #ifdef HAVE_BSD_AUTH | 76 | #ifdef HAVE_BSD_AUTH |
77 | read_password(Display *dpy) | 77 | readpw(Display *dpy) |
78 | #else | 78 | #else |
79 | read_password(Display *dpy, const char *pws) | 79 | readpw(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 | ||
216 | static int | ||
217 | xerrordummy(Display *dpy, XErrorEvent *ee) { | ||
218 | return 0; | ||
219 | } | ||
220 | |||
216 | int | 221 | int |
217 | main(int argc, char **argv) { | 222 | main(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. */ |