aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFRIGN <dev@frign.de>2016-09-11 23:10:57 +0200
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-09-23 18:51:40 +0200
commit9a617db716641da8489e2062e04098220954bffe (patch)
tree5560787afa51a04bb2592a2ba90e2b3fbd7db232
parentb00f444a4ea0d9ffa5cd7dcda71c97cdf05d322e (diff)
Rename getpw() and pws to gethash() and hash
-rw-r--r--slock.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/slock.c b/slock.c
index f423f8c..f799174 100644
--- a/slock.c
+++ b/slock.c
@@ -85,9 +85,9 @@ dontkillme(void)
85#endif 85#endif
86 86
87static const char * 87static const char *
88getpw(void) 88gethash(void)
89{ 89{
90 const char *rval; 90 const char *hash;
91 struct passwd *pw; 91 struct passwd *pw;
92 92
93 /* Check if the current user has a password entry */ 93 /* Check if the current user has a password entry */
@@ -98,35 +98,35 @@ getpw(void)
98 else 98 else
99 die("slock: cannot retrieve password entry\n"); 99 die("slock: cannot retrieve password entry\n");
100 } 100 }
101 rval = pw->pw_passwd; 101 hash = pw->pw_passwd;
102 102
103#if HAVE_SHADOW_H 103#if HAVE_SHADOW_H
104 if (rval[0] == 'x' && rval[1] == '\0') { 104 if (hash[0] == 'x' && hash[1] == '\0') {
105 struct spwd *sp; 105 struct spwd *sp;
106 if (!(sp = getspnam(getenv("USER")))) 106 if (!(sp = getspnam(getenv("USER"))))
107 die("slock: getspnam: cannot retrieve shadow entry (make sure to suid or sgid slock)\n"); 107 die("slock: getspnam: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
108 rval = sp->sp_pwdp; 108 hash = sp->sp_pwdp;
109 } 109 }
110#else 110#else
111 if (rval[0] == '*' && rval[1] == '\0') { 111 if (hash[0] == '*' && hash[1] == '\0') {
112#ifdef __OpenBSD__ 112#ifdef __OpenBSD__
113 if (!(pw = getpwnam_shadow(getenv("USER")))) 113 if (!(pw = getpwnam_shadow(getenv("USER"))))
114 die("slock: getpwnam_shadow: cannot retrieve shadow entry (make sure to suid or sgid slock)\n"); 114 die("slock: getpwnam_shadow: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
115 rval = pw->pw_passwd; 115 hash = pw->pw_passwd;
116#else 116#else
117 die("slock: getpwuid: cannot retrieve shadow entry (make sure to suid or sgid slock)\n"); 117 die("slock: getpwuid: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
118#endif /* __OpenBSD__ */ 118#endif /* __OpenBSD__ */
119 } 119 }
120#endif /* HAVE_SHADOW_H */ 120#endif /* HAVE_SHADOW_H */
121 121
122 return rval; 122 return hash;
123} 123}
124 124
125static void 125static void
126readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, 126readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
127 const char *pws) 127 const char *hash)
128{ 128{
129 char buf[32], passwd[256], *encrypted; 129 char buf[32], passwd[256], *inputhash;
130 int num, screen, running, failure; 130 int num, screen, running, failure;
131 unsigned int len, color; 131 unsigned int len, color;
132 KeySym ksym; 132 KeySym ksym;
@@ -161,10 +161,10 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
161 case XK_Return: 161 case XK_Return:
162 passwd[len] = 0; 162 passwd[len] = 0;
163 errno = 0; 163 errno = 0;
164 if (!(encrypted = crypt(passwd, pws))) 164 if (!(inputhash = crypt(passwd, hash)))
165 fprintf(stderr, "slock: crypt: %s\n", strerror(errno)); 165 fprintf(stderr, "slock: crypt: %s\n", strerror(errno));
166 else 166 else
167 running = !!strcmp(encrypted, pws); 167 running = !!strcmp(inputhash, hash);
168 if (running) { 168 if (running) {
169 XBell(dpy, 100); 169 XBell(dpy, 100);
170 failure = True; 170 failure = True;
@@ -292,7 +292,7 @@ main(int argc, char **argv) {
292 struct group *grp; 292 struct group *grp;
293 uid_t duid; 293 uid_t duid;
294 gid_t dgid; 294 gid_t dgid;
295 const char *pws; 295 const char *hash;
296 Display *dpy; 296 Display *dpy;
297 int s, nlocks, nscreens; 297 int s, nlocks, nscreens;
298 298
@@ -320,8 +320,8 @@ main(int argc, char **argv) {
320 dontkillme(); 320 dontkillme();
321#endif 321#endif
322 322
323 pws = getpw(); 323 hash = gethash();
324 if (strlen(pws) < 2) 324 if (strlen(hash) < 2)
325 die("slock: failed to get user password hash.\n"); 325 die("slock: failed to get user password hash.\n");
326 326
327 if (!(dpy = XOpenDisplay(NULL))) 327 if (!(dpy = XOpenDisplay(NULL)))
@@ -370,7 +370,7 @@ main(int argc, char **argv) {
370 } 370 }
371 371
372 /* everything is now blank. Wait for the correct password */ 372 /* everything is now blank. Wait for the correct password */
373 readpw(dpy, &rr, locks, nscreens, pws); 373 readpw(dpy, &rr, locks, nscreens, hash);
374 374
375 return 0; 375 return 0;
376} 376}