aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE18
-rw-r--r--README4
-rw-r--r--slock.c14
3 files changed, 17 insertions, 19 deletions
diff --git a/LICENSE b/LICENSE
index 490492c..faf1c09 100644
--- a/LICENSE
+++ b/LICENSE
@@ -6,16 +6,16 @@ Permission is hereby granted, free of charge, to any person obtaining a
6copy of this software and associated documentation files (the "Software"), 6copy of this software and associated documentation files (the "Software"),
7to deal in the Software without restriction, including without limitation 7to deal in the Software without restriction, including without limitation
8the rights to use, copy, modify, merge, publish, distribute, sublicense, 8the rights to use, copy, modify, merge, publish, distribute, sublicense,
9and/or sell copies of the Software, and to permit persons to whom the 9and/or sell copies of the Software, and to permit persons to whom the
10Software is furnished to do so, subject to the following conditions: 10Software is furnished to do so, subject to the following conditions:
11 11
12The above copyright notice and this permission notice shall be included in 12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software. 13all copies or substantial portions of the Software.
14 14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21DEALINGS IN THE SOFTWARE. 21DEALINGS IN THE SOFTWARE.
diff --git a/README b/README
index 5940337..a81290d 100644
--- a/README
+++ b/README
@@ -13,8 +13,8 @@ Installation
13Edit config.mk to match your local setup (slock is installed into 13Edit config.mk to match your local setup (slock is installed into
14the /usr/local namespace by default). 14the /usr/local namespace by default).
15 15
16Afterwards enter the following command to build and install slock (if 16Afterwards enter the following command to build and install slock
17necessary as root): 17(if necessary as root):
18 18
19 make clean install 19 make clean install
20 20
diff --git a/slock.c b/slock.c
index 40f1fbe..d576c0b 100644
--- a/slock.c
+++ b/slock.c
@@ -23,7 +23,7 @@
23#endif 23#endif
24 24
25void 25void
26eprint(const char *errstr, ...) { 26die(const char *errstr, ...) {
27 va_list ap; 27 va_list ap;
28 28
29 va_start(ap, errstr); 29 va_start(ap, errstr);
@@ -39,7 +39,7 @@ get_password() { /* only run as root */
39 struct passwd *pw; 39 struct passwd *pw;
40 40
41 if(geteuid() != 0) 41 if(geteuid() != 0)
42 eprint("slock: cannot retrieve password entry (make sure to suid slock)\n"); 42 die("slock: cannot retrieve password entry (make sure to suid slock)\n");
43 pw = getpwuid(getuid()); 43 pw = getpwuid(getuid());
44 endpwent(); 44 endpwent();
45 rval = pw->pw_passwd; 45 rval = pw->pw_passwd;
@@ -55,7 +55,7 @@ get_password() { /* only run as root */
55 55
56 /* drop privileges */ 56 /* drop privileges */
57 if(setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) 57 if(setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0)
58 eprint("slock: cannot drop privileges\n"); 58 die("slock: cannot drop privileges\n");
59 return rval; 59 return rval;
60} 60}
61#endif 61#endif
@@ -81,16 +81,16 @@ main(int argc, char **argv) {
81 XSetWindowAttributes wa; 81 XSetWindowAttributes wa;
82 82
83 if((argc == 2) && !strcmp("-v", argv[1])) 83 if((argc == 2) && !strcmp("-v", argv[1]))
84 eprint("slock-"VERSION", © 2006-2008 Anselm R Garbe\n"); 84 die("slock-"VERSION", © 2006-2008 Anselm R Garbe\n");
85 else if(argc != 1) 85 else if(argc != 1)
86 eprint("usage: slock [-v]\n"); 86 die("usage: slock [-v]\n");
87 87
88#ifndef HAVE_BSD_AUTH 88#ifndef HAVE_BSD_AUTH
89 pws = get_password(); 89 pws = get_password();
90#endif 90#endif
91 91
92 if(!(dpy = XOpenDisplay(0))) 92 if(!(dpy = XOpenDisplay(0)))
93 eprint("slock: cannot open display\n"); 93 die("slock: cannot open display\n");
94 screen = DefaultScreen(dpy); 94 screen = DefaultScreen(dpy);
95 root = RootWindow(dpy, screen); 95 root = RootWindow(dpy, screen);
96 96
@@ -144,13 +144,11 @@ main(int argc, char **argv) {
144 switch(ksym) { 144 switch(ksym) {
145 case XK_Return: 145 case XK_Return:
146 passwd[len] = 0; 146 passwd[len] = 0;
147
148#ifdef HAVE_BSD_AUTH 147#ifdef HAVE_BSD_AUTH
149 running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd); 148 running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd);
150#else 149#else
151 running = strcmp(crypt(passwd, pws), pws); 150 running = strcmp(crypt(passwd, pws), pws);
152#endif 151#endif
153
154 if (running != 0) 152 if (running != 0)
155 XBell(dpy, 100); 153 XBell(dpy, 100);
156 len = 0; 154 len = 0;