~ob/slock

8745098fa440ef3bf1d8e173dcd91514b34600c6 — sin 7 years ago 9db14b1
Only check errno if getpwuid() fails

Checking errno otherwise is unspecified.
1 files changed, 6 insertions(+), 4 deletions(-)

M slock.c
M slock.c => slock.c +6 -4
@@ 67,10 67,12 @@ getpw(void) { /* only run as root */

	errno = 0;
	pw = getpwuid(getuid());
	if (errno)
		die("slock: getpwuid: %s\n", strerror(errno));
	else if (!pw)
		die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
	if (!pw) {
		if (errno)
			die("slock: getpwuid: %s\n", strerror(errno));
		else
			die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
	}
	endpwent();
	rval =  pw->pw_passwd;