summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2018-07-23 14:58:44 +0000
committerIan Lepore <ian@FreeBSD.org>2018-07-23 14:58:44 +0000
commit6da8ae1fefae4690a06e473d8a5a6bd262495e46 (patch)
treee780953225c029576bb7ae83475d55dd7ef6e19d
parenta97b359809759494438052dd4984a4f77b4bfd5d (diff)
downloadpw-darwin-6da8ae1fefae4690a06e473d8a5a6bd262495e46.tar.gz
pw-darwin-6da8ae1fefae4690a06e473d8a5a6bd262495e46.tar.zst
pw-darwin-6da8ae1fefae4690a06e473d8a5a6bd262495e46.zip
Revert r336625 until I figure out why it worked with simple testing but
reportedly fails the kyua tests and causes other real-world problems. Reported by: cy@ asomers@
-rw-r--r--pw/pw_vpw.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/pw/pw_vpw.c b/pw/pw_vpw.c
index 4517a74..ea87f71 100644
--- a/pw/pw_vpw.c
+++ b/pw/pw_vpw.c
@@ -39,13 +39,10 @@ static const char rcsid[] =
#include <string.h>
#include <stdlib.h>
#include <err.h>
-#include <unistd.h>
#include "pwupd.h"
static FILE * pwd_fp = NULL;
-static int pwd_scanflag;
-static const char *pwd_filename;
void
vendpwent(void)
@@ -74,18 +71,7 @@ vnextpwent(char const *nam, uid_t uid, int doclose)
line = NULL;
linecap = 0;
- if (pwd_fp == NULL) {
- if (geteuid() == 0) {
- pwd_filename = _MASTERPASSWD;
- pwd_scanflag = PWSCAN_MASTER;
- } else {
- pwd_filename = _PASSWD;
- pwd_scanflag = 0;
- }
- pwd_fp = fopen(getpwpath(pwd_filename), "r");
- }
-
- if (pwd_fp != NULL) {
+ if (pwd_fp != NULL || (pwd_fp = fopen(getpwpath(_MASTERPASSWD), "r")) != NULL) {
while ((linelen = getline(&line, &linecap, pwd_fp)) > 0) {
/* Skip comments and empty lines */
if (*line == '\n' || *line == '#')
@@ -93,10 +79,10 @@ vnextpwent(char const *nam, uid_t uid, int doclose)
/* trim latest \n */
if (line[linelen - 1 ] == '\n')
line[linelen - 1] = '\0';
- pw = pw_scan(line, pwd_scanflag);
+ pw = pw_scan(line, PWSCAN_MASTER);
if (pw == NULL)
errx(EXIT_FAILURE, "Invalid user entry in '%s':"
- " '%s'", getpwpath(pwd_filename), line);
+ " '%s'", getpwpath(_MASTERPASSWD), line);
if (uid != (uid_t)-1) {
if (uid == pw->pw_uid)
break;
@@ -113,18 +99,6 @@ vnextpwent(char const *nam, uid_t uid, int doclose)
}
free(line);
- /*
- * If we read the non-master passwd, some fields may not have been
- * populated. Clean them up so that the output looks the same as that
- * generated using getpwnam() which also inits them to these values.
- */
- if (!(pw->pw_fields & _PWF_CLASS))
- pw->pw_class = "";
- if (!(pw->pw_fields & _PWF_CHANGE))
- pw->pw_change = 0;
- if (!(pw->pw_fields & _PWF_EXPIRE))
- pw->pw_expire = 0;
-
return (pw);
}