summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2009-03-05 20:53:13 +0000
committermillert <millert@openbsd.org>2009-03-05 20:53:13 +0000
commita0bffbc09a0fa49c771e89883ec0e8829c2b45c5 (patch)
tree2e02c6a8d54ab14975c743dcd580de209d19e2a7
parentMake ELF platforms generate ELF core dumps. Somewhat based on code from (diff)
downloadwireguard-openbsd-a0bffbc09a0fa49c771e89883ec0e8829c2b45c5.tar.xz
wireguard-openbsd-a0bffbc09a0fa49c771e89883ec0e8829c2b45c5.zip
Call endusershell() at the end of ok_shell(), making a copy of the
(possibly) expanded shell as needed. OK deraadt@
-rw-r--r--usr.bin/chpass/chpass.h4
-rw-r--r--usr.bin/chpass/edit.c6
-rw-r--r--usr.bin/chpass/field.c13
-rw-r--r--usr.bin/chpass/util.c17
4 files changed, 21 insertions, 19 deletions
diff --git a/usr.bin/chpass/chpass.h b/usr.bin/chpass/chpass.h
index 59a55707255..833f73552f8 100644
--- a/usr.bin/chpass/chpass.h
+++ b/usr.bin/chpass/chpass.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: chpass.h,v 1.9 2003/06/25 22:41:35 deraadt Exp $ */
+/* $OpenBSD: chpass.h,v 1.10 2009/03/05 20:53:13 millert Exp $ */
/* $NetBSD: chpass.h,v 1.4 1996/05/15 21:50:44 jtc Exp $ */
/*
@@ -59,7 +59,7 @@ extern uid_t uid;
int atot(char *, time_t *);
void display(char *, int, struct passwd *);
int edit(char *, struct passwd *);
-char *ok_shell(char *);
+int ok_shell(char *, char **);
int p_change(char *, struct passwd *, ENTRY *);
int p_class(char *, struct passwd *, ENTRY *);
int p_expire(char *, struct passwd *, ENTRY *);
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c
index 49ef819de56..6476164d6ad 100644
--- a/usr.bin/chpass/edit.c
+++ b/usr.bin/chpass/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.31 2007/11/17 16:47:21 millert Exp $ */
+/* $OpenBSD: edit.c,v 1.32 2009/03/05 20:53:13 millert Exp $ */
/* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: edit.c,v 1.31 2007/11/17 16:47:21 millert Exp $";
+static char rcsid[] = "$OpenBSD: edit.c,v 1.32 2009/03/05 20:53:13 millert Exp $";
#endif
#endif /* not lint */
@@ -110,7 +110,7 @@ display(char *tempname, int fd, struct passwd *pw)
*pw->pw_shell ? pw->pw_shell : _PATH_BSHELL);
}
/* Only admin can change "restricted" shells. */
- else if (ok_shell(pw->pw_shell))
+ else if (ok_shell(pw->pw_shell, NULL))
/*
* Make shell a restricted field. Ugly with a
* necklace, but there's not much else to do.
diff --git a/usr.bin/chpass/field.c b/usr.bin/chpass/field.c
index 50c2942b93e..6078d7cbb23 100644
--- a/usr.bin/chpass/field.c
+++ b/usr.bin/chpass/field.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: field.c,v 1.9 2006/03/31 00:29:13 deraadt Exp $ */
+/* $OpenBSD: field.c,v 1.10 2009/03/05 20:53:13 millert Exp $ */
/* $NetBSD: field.c,v 1.3 1995/03/26 04:55:28 glass Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: field.c,v 1.9 2006/03/31 00:29:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: field.c,v 1.10 2009/03/05 20:53:13 millert Exp $";
#endif
#endif /* not lint */
@@ -220,18 +220,17 @@ p_shell(char *p, struct passwd *pw, ENTRY *ep)
return (0);
}
/* only admin can change from or to "restricted" shells */
- if (uid && pw->pw_shell && !ok_shell(pw->pw_shell)) {
+ if (uid && pw->pw_shell && !ok_shell(pw->pw_shell, NULL)) {
warnx("%s: current shell non-standard", pw->pw_shell);
return (1);
}
- if (!(t = ok_shell(p))) {
+ if (!ok_shell(p, &t)) {
if (uid) {
warnx("%s: non-standard shell", p);
return (1);
}
- } else
- p = t;
- if (!(pw->pw_shell = strdup(p))) {
+ }
+ if (!(pw->pw_shell = t)) {
warnx("can't save entry");
return (1);
}
diff --git a/usr.bin/chpass/util.c b/usr.bin/chpass/util.c
index bd7006510e4..64c13d1d848 100644
--- a/usr.bin/chpass/util.c
+++ b/usr.bin/chpass/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.10 2008/12/16 05:25:55 guenther Exp $ */
+/* $OpenBSD: util.c,v 1.11 2009/03/05 20:53:13 millert Exp $ */
/* $NetBSD: util.c,v 1.4 1995/03/26 04:55:35 glass Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: util.c,v 1.10 2008/12/16 05:25:55 guenther Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.11 2009/03/05 20:53:13 millert Exp $";
#endif
#endif /* not lint */
@@ -87,18 +87,21 @@ atot(char *p, time_t *store)
return (0);
}
-char *
-ok_shell(char *name)
+int
+ok_shell(char *name, char **out)
{
char *p, *sh;
setusershell();
while ((sh = getusershell()) != NULL) {
if (!strcmp(name, sh))
- return (name);
+ break;
/* allow just shell name, but use "real" path */
if ((p = strrchr(sh, '/')) && strcmp(name, p + 1) == 0)
- return (sh);
+ break;
}
- return (NULL);
+ if (sh && out)
+ *out = strdup(sh);
+ endusershell();
+ return (sh != NULL);
}