Xinqi Bao's Git
projects
/
slock.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
ede2935
)
added dummy error handler to prevent X from terminating slock just in case
author
[email protected]
<unknown>
Sun, 22 Jan 2012 17:58:10 +0000
(18:58 +0100)
committer
[email protected]
<unknown>
Sun, 22 Jan 2012 17:58:10 +0000
(18:58 +0100)
slock.c
patch
|
blob
|
history
diff --git
a/slock.c
b/slock.c
index
be10f5d
..
2dce109
100644
(file)
--- a/
slock.c
+++ b/
slock.c
@@
-46,7
+46,7
@@
die(const char *errstr, ...) {
#ifndef HAVE_BSD_AUTH
static const char *
#ifndef HAVE_BSD_AUTH
static const char *
-get
_password
(void) { /* only run as root */
+get
pw
(void) { /* only run as root */
const char *rval;
struct passwd *pw;
const char *rval;
struct passwd *pw;
@@
-74,9
+74,9
@@
get_password(void) { /* only run as root */
static void
#ifdef HAVE_BSD_AUTH
static void
#ifdef HAVE_BSD_AUTH
-read
_password
(Display *dpy)
+read
pw
(Display *dpy)
#else
#else
-read
_password
(Display *dpy, const char *pws)
+read
pw
(Display *dpy, const char *pws)
#endif
{
char buf[32], passwd[256];
#endif
{
char buf[32], passwd[256];
@@
-213,6
+213,11
@@
usage(void) {
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
+static int
+xerrordummy(Display *dpy, XErrorEvent *ee) {
+ return 0;
+}
+
int
main(int argc, char **argv) {
#ifndef HAVE_BSD_AUTH
int
main(int argc, char **argv) {
#ifndef HAVE_BSD_AUTH
@@
-224,7
+229,7
@@
main(int argc, char **argv) {
struct st_lock **locks;
if((argc == 2) && !strcmp("-v", argv[1]))
struct st_lock **locks;
if((argc == 2) && !strcmp("-v", argv[1]))
- die("slock-%s, © 2006-20
08
Anselm R Garbe", VERSION);
+ die("slock-%s, © 2006-20
12
Anselm R Garbe", VERSION);
else if(argc != 1)
usage();
else if(argc != 1)
usage();
@@
-232,12
+237,13
@@
main(int argc, char **argv) {
die("no passwd entry for you");
#ifndef HAVE_BSD_AUTH
die("no passwd entry for you");
#ifndef HAVE_BSD_AUTH
- pws = get
_password
();
+ pws = get
pw
();
#endif
if(!(dpy = XOpenDisplay(0)))
die("cannot open display");
#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);
/* 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
@@
main(int argc, char **argv) {
/* Everything is now blank. Now wait for the correct password. */
#ifdef HAVE_BSD_AUTH
/* Everything is now blank. Now wait for the correct password. */
#ifdef HAVE_BSD_AUTH
- read
_password
(dpy);
+ read
pw
(dpy);
#else
#else
- read
_password
(dpy, pws);
+ read
pw
(dpy, pws);
#endif
/* Password ok, unlock everything and quit. */
#endif
/* Password ok, unlock everything and quit. */