diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-11-12 22:27:53 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-11-12 22:27:53 +0000 |
commit | bcd9ef6b1872f72a7932f3a2554348ec81e7e42d (patch) | |
tree | c9fb97c7dc6e9f7ab2ae2901274bca2100194ecf /pw/pw.c | |
parent | cf28a17818058981489f2d7b9146b87ffd2b5049 (diff) | |
download | pw-darwin-bcd9ef6b1872f72a7932f3a2554348ec81e7e42d.tar.gz pw-darwin-bcd9ef6b1872f72a7932f3a2554348ec81e7e42d.tar.zst pw-darwin-bcd9ef6b1872f72a7932f3a2554348ec81e7e42d.zip |
Fix wrong message when using pw -V with a non existent directory
Add a regression test about it
PR: 194971
Submitted by: Freddy DISSAUX <bugzilla@dsx.bsdsx.fr>
Diffstat (limited to 'pw/pw.c')
-rw-r--r-- | pw/pw.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -98,6 +98,7 @@ main(int argc, char *argv[]) int which = -1; char *config = NULL; struct userconf *cnf; + struct stat st; static const char *opts[W_NUM][M_NUM] = { @@ -143,6 +144,13 @@ main(int argc, char *argv[]) if (argv[1][1] == 'V') { optarg = &argv[1][2]; if (*optarg == '\0') { + if (stat(argv[2], &st) != 0) + errx(EX_OSFILE, \ + "no such directory `%s'", + argv[2]); + if (!S_ISDIR(st.st_mode)) + errx(EX_OSFILE, "`%s' not a " + "directory", argv[2]); optarg = argv[2]; ++argv; --argc; |