summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pwd_mkdb
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2003-04-13 18:04:07 +0000
committermillert <millert@openbsd.org>2003-04-13 18:04:07 +0000
commitdc91a85a9cf20e5b19b16ac21e524cc9585d2331 (patch)
tree7b6680893f4407dbea12a340dcdf1102a25f6aca /usr.sbin/pwd_mkdb
parentmove the bandwidth keyword from within the bandwidth target up to the (diff)
downloadwireguard-openbsd-dc91a85a9cf20e5b19b16ac21e524cc9585d2331.tar.xz
wireguard-openbsd-dc91a85a9cf20e5b19b16ac21e524cc9585d2331.zip
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/pwd_mkdb')
-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);
}