summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-04-14 22:24:55 +0000
committerdes <des@FreeBSD.org>2002-04-14 22:24:55 +0000
commit06b809501b152a7f2bf3d9ad135051c200f36375 (patch)
tree99cf5a83e5407834eccbe049705b8e3422414ecd
parent916765bbc4f80a30a3119b80038db10873e7f870 (diff)
downloadFreeBSD-src-06b809501b152a7f2bf3d9ad135051c200f36375.zip
FreeBSD-src-06b809501b152a7f2bf3d9ad135051c200f36375.tar.gz
(ab)use unused bits in the pw_fields member of struct passwd to record
the source of the data contained in the structure. Sponsored by: DARPA, NAI Labs
-rw-r--r--include/pwd.h5
-rw-r--r--lib/libc/gen/getpwent.c14
2 files changed, 17 insertions, 2 deletions
diff --git a/include/pwd.h b/include/pwd.h
index 04961ac..8634a7f 100644
--- a/include/pwd.h
+++ b/include/pwd.h
@@ -96,6 +96,11 @@ struct passwd {
#define _PWF_SHELL _PWF(8)
#define _PWF_EXPIRE _PWF(9)
+#define _PWF_SOURCE 0x3000
+#define _PWF_FILES 0x1000
+#define _PWF_NIS 0x2000
+#define _PWF_HESIOD 0x3000
+
#include <sys/cdefs.h>
__BEGIN_DECLS
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index d68050b..235aa2b 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -408,6 +408,10 @@ _local_getpw(rv, cb_data, ap)
(void)(_pw_db->close)(_pw_db);
_pw_db = (DB *)NULL;
}
+ if (rval == 0) {
+ _pw_passwd.pw_fields &= ~_PWF_SOURCE;
+ _pw_passwd.pw_fields |= _PWF_FILES;
+ }
return (rval);
}
@@ -481,8 +485,11 @@ _dns_getpw(rv, cb_data, ap)
if (search == _PW_KEYBYNUM)
goto nextdnsbynum; /* skip dogdy entries */
r = NS_UNAVAIL;
- } else
+ } else {
+ _pw_passwd.pw_fields &= ~_PWF_SOURCE;
+ _pw_passwd.pw_fields |= _PWF_HESIOD;
r = NS_SUCCESS;
+ }
cleanup_dns_getpw:
hesiod_end(context);
return (r);
@@ -589,8 +596,11 @@ _nis_getpw(rv, cb_data, ap)
strncpy(line, data, sizeof(line));
line[sizeof(line) - 1] = '\0';
free(data);
- if (! __pwparse(&_pw_passwd, line))
+ if (! __pwparse(&_pw_passwd, line)) {
+ _pw_passwd.pw_fields &= ~_PWF_SOURCE;
+ _pw_passwd.pw_fields |= _PWF_NIS;
return NS_SUCCESS;
+ }
}
/* NOTREACHED */
} /* _nis_getpw */
OpenPOWER on IntegriCloud