summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-04-13 18:04:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-04-13 18:04:08 +0000
commitc9f083a779e13823592d0d8545d3f1f871246411 (patch)
treeb4d674a6ce95a8582b5ac4ff35655fddd93bfa27 /usr.sbin
parent1f32a7a62d60c316a28a16c6b78ec0421686569a (diff)
Clarify the -d option and allow the passwd file argument to not be
a fully qualified pathname if -d was specified (since we take the basename in that case anyway). deraadt@ OK
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.815
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c15
2 files changed, 20 insertions, 10 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.8 b/usr.sbin/pwd_mkdb/pwd_mkdb.8
index 9d36183562b..a2294a65a26 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.8
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pwd_mkdb.8,v 1.14 2001/08/16 18:22:04 millert Exp $
+.\" $OpenBSD: pwd_mkdb.8,v 1.15 2003/04/13 18:04:07 millert Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -84,6 +84,19 @@ flag.
.It Fl d Ar directory
Operate in a base directory other than the default of
.Pa /etc .
+All absolute paths (including
+.Ar file )
+will be made relative to
+.Ar directory .
+Any directories specified as a part of
+.Ar file
+will be stripped off.
+This option is used to create password databases in directories
+other than
+.Pa etc ;
+for instance in a
+.Xr chroot 8
+jail.
.It Fl u Ar username
Only update the record for the specified user. Utilities that
operate on a single user can use this option to avoid the
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index be7860d3f56..62d1874274a 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwd_mkdb.c,v 1.33 2003/03/28 16:58:39 millert Exp $ */
+/* $OpenBSD: pwd_mkdb.c,v 1.34 2003/04/13 18:04:07 millert Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -45,7 +45,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "from: @(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94";
#else
-static char *rcsid = "$OpenBSD: pwd_mkdb.c,v 1.33 2003/03/28 16:58:39 millert Exp $";
+static char *rcsid = "$OpenBSD: pwd_mkdb.c,v 1.34 2003/04/13 18:04:07 millert Exp $";
#endif
#endif /* not lint */
@@ -172,7 +172,7 @@ main(argc, argv)
/* We don't care what the user wants. */
(void)umask(0);
- if (**argv != '/')
+ if (**argv != '/' && basedir == NULL)
errx(1, "%s must be specified as an absolute path", *argv);
if ((pname = strdup(changedir(*argv, basedir))) == NULL)
@@ -494,12 +494,9 @@ changedir(path, dir)
if (!dir)
return (path);
- p = strrchr(path, '/');
- strlcpy(fixed, dir, sizeof fixed);
- if (p) {
- strlcat(fixed, "/", sizeof fixed);
- strlcat(fixed, p + 1, sizeof fixed);
- }
+ if ((p = strrchr(path, '/')) != NULL)
+ path = p + 1;
+ snprintf(fixed, sizeof(fixed), "%s/%s", dir, path);
return (fixed);
}