diff options
| author | Mike Pritchard <mpp@FreeBSD.org> | 1996-04-11 05:30:18 +0000 |
|---|---|---|
| committer | Mike Pritchard <mpp@FreeBSD.org> | 1996-04-11 05:30:18 +0000 |
| commit | d33c4953e76ad3c07c4d25c2c1b238fcacedf851 (patch) | |
| tree | 9dc27d26c7e7eef1b966b623e4f61fdf82402545 /usr.bin | |
| parent | 7506b46e076969fde7644bf0bf30e0781219e083 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/chpass/field.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.bin/chpass/field.c b/usr.bin/chpass/field.c index 6229e42ae6ed..73fa4795a2e0 100644 --- a/usr.bin/chpass/field.c +++ b/usr.bin/chpass/field.c @@ -36,6 +36,7 @@ static char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ #include <sys/param.h> +#include <sys/stat.h> #include <ctype.h> #include <err.h> @@ -242,6 +243,7 @@ p_shell(p, pw, ep) ENTRY *ep; { char *t, *ok_shell(); + struct stat sbuf; if (!*p) { pw->pw_shell = _PATH_BSHELL; @@ -264,5 +266,22 @@ p_shell(p, pw, ep) warnx("can't save entry"); return (1); } + if (stat(pw->pw_shell, &sbuf) < 0) { + if (errno == ENOENT) + warnx("WARNING: shell '%s' does not exist", + pw->pw_shell); + else + warn("WARNING: can't stat shell '%s'", pw->pw_shell); + return (0); + } + if (!S_ISREG(sbuf.st_mode)) { + warnx("WARNING: shell '%s' is not a regular file", + pw->pw_shell); + return (0); + } + if ((sbuf.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR)) == 0) { + warnx("WARNING: shell '%s' is not executable", pw->pw_shell); + return (0); + } return (0); } |
