diff options
author | bapt <bapt@FreeBSD.org> | 2012-10-29 17:19:43 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2012-10-29 17:19:43 +0000 |
commit | aa9729007051cf2592b0471e8461a9c622aa6b86 (patch) | |
tree | a603eb4e66df05d0ab9ec7658414b9c46fdc21c1 /lib/libutil/gr_util.c | |
parent | 6169e186fd79ecdd061bf61fd454e5506798c984 (diff) | |
download | FreeBSD-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/gr_util.c')
-rw-r--r-- | lib/libutil/gr_util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c index 0173595..323d3ff 100644 --- a/lib/libutil/gr_util.c +++ b/lib/libutil/gr_util.c @@ -63,6 +63,8 @@ static const char group_line_format[] = "%s:%s:%ju:"; int gr_init(const char *dir, const char *group) { + struct stat st; + if (dir == NULL) { strcpy(group_dir, _PATH_ETC); } else { @@ -88,6 +90,15 @@ gr_init(const char *dir, const char *group) } strcpy(group_file, group); } + + if (stat(group_file, &st) == -1) + return (-1); + + if (S_ISDIR(st.st_mode)) { + errno = EISDIR; + return (-1); + } + initialized = 1; return (0); } |