diff options
-rw-r--r-- | LICENSE | 18 | ||||
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | slock.c | 14 |
3 files changed, 17 insertions, 19 deletions
@@ -6,16 +6,16 @@ Permission is hereby granted, free of charge, to any person obtaining a | |||
6 | copy of this software and associated documentation files (the "Software"), | 6 | copy of this software and associated documentation files (the "Software"), |
7 | to deal in the Software without restriction, including without limitation | 7 | to deal in the Software without restriction, including without limitation |
8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, | 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 | and/or sell copies of the Software, and to permit persons to whom the | 9 | and/or sell copies of the Software, and to permit persons to whom the |
10 | Software is furnished to do so, subject to the following conditions: | 10 | Software is furnished to do so, subject to the following conditions: |
11 | 11 | ||
12 | The above copyright notice and this permission notice shall be included in | 12 | The above copyright notice and this permission notice shall be included in |
13 | all copies or substantial portions of the Software. | 13 | all copies or substantial portions of the Software. |
14 | 14 | ||
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | DEALINGS IN THE SOFTWARE. | 21 | DEALINGS IN THE SOFTWARE. |
@@ -13,8 +13,8 @@ Installation | |||
13 | Edit config.mk to match your local setup (slock is installed into | 13 | Edit config.mk to match your local setup (slock is installed into |
14 | the /usr/local namespace by default). | 14 | the /usr/local namespace by default). |
15 | 15 | ||
16 | Afterwards enter the following command to build and install slock (if | 16 | Afterwards enter the following command to build and install slock |
17 | necessary as root): | 17 | (if necessary as root): |
18 | 18 | ||
19 | make clean install | 19 | make clean install |
20 | 20 | ||
@@ -23,7 +23,7 @@ | |||
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | void | 25 | void |
26 | eprint(const char *errstr, ...) { | 26 | die(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; |