summaryrefslogtreecommitdiffstats
path: root/lib/libutil/pw_util.c
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2012-10-29 17:19:43 +0000
committerbapt <bapt@FreeBSD.org>2012-10-29 17:19:43 +0000
commitaa9729007051cf2592b0471e8461a9c622aa6b86 (patch)
treea603eb4e66df05d0ab9ec7658414b9c46fdc21c1 /lib/libutil/pw_util.c
parent6169e186fd79ecdd061bf61fd454e5506798c984 (diff)
downloadFreeBSD-src-aa9729007051cf2592b0471e8461a9c622aa6b86.zip
FreeBSD-src-aa9729007051cf2592b0471e8461a9c622aa6b86.tar.gz
make pw_init and gr_init fail if the specified master password or group file is
a directory. MFC after: 1 month
Diffstat (limited to 'lib/libutil/pw_util.c')
-rw-r--r--lib/libutil/pw_util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index 4bf3001..6013e6d 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -96,6 +96,7 @@ pw_init(const char *dir, const char *master)
#if 0
struct rlimit rlim;
#endif
+ struct stat st;
if (dir == NULL) {
strcpy(passwd_dir, _PATH_ETC);
@@ -123,6 +124,14 @@ pw_init(const char *dir, const char *master)
strcpy(masterpasswd, master);
}
+ if (stat(masterpasswd, &st) == -1)
+ return (-1);
+
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return (-1);
+ }
+
/*
* The code that follows is extremely disruptive to the calling
* process, and is therefore disabled until someone can conceive
OpenPOWER on IntegriCloud