summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>2001-04-17 01:37:04 +0000
committerlukem <lukem@NetBSD.org>2001-04-17 01:37:04 +0000
commit7ee956fdcc29259f8111e20cefc8b77684181fdb (patch)
treec59f57e8d300e9eb29368c4bb900a97ba7089e12 /libexec
parent24ba541b4e4c06a29d1102ca3ab00001fbeb9cdd (diff)
use own code instead of bother with glob() to do ~ expansion in pathname;
there's no need to support glob wildcards in this case when it's not expanded here in the non-~ case
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpcmd.y45
-rw-r--r--libexec/ftpd/version.h4
2 files changed, 27 insertions, 22 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 731d183bcc2..2ae7a1d8c75 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -1,4 +1,4 @@
-/* $NetBSD: ftpcmd.y,v 1.63 2001/04/17 00:59:58 lukem Exp $ */
+/* $NetBSD: ftpcmd.y,v 1.64 2001/04/17 01:37:04 lukem Exp $ */
/*-
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
@@ -83,7 +83,7 @@
#if 0
static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94";
#else
-__RCSID("$NetBSD: ftpcmd.y,v 1.63 2001/04/17 00:59:58 lukem Exp $");
+__RCSID("$NetBSD: ftpcmd.y,v 1.64 2001/04/17 01:37:04 lukem Exp $");
#endif
#endif /* not lint */
@@ -97,7 +97,6 @@ __RCSID("$NetBSD: ftpcmd.y,v 1.63 2001/04/17 00:59:58 lukem Exp $");
#include <ctype.h>
#include <errno.h>
-#include <glob.h>
#include <pwd.h>
#include <setjmp.h>
#include <signal.h>
@@ -1082,27 +1081,33 @@ pathname
* others.
*/
if (logged_in && $1 && *$1 == '~') {
- glob_t gl;
- int flags = GLOB_BRACE | GLOB_NOCHECK | \
- GLOB_TILDE | GLOB_LIMIT;
+ char *path, *home, *result;
+ size_t len;
+ path = strchr($1 + 1, '/');
+ if (path != NULL)
+ *path++ = '\0';
if ($1[1] == '\0')
- $$ = xstrdup(homedir);
+ home = homedir;
else {
- memset(&gl, 0, sizeof(gl));
- if (glob($1, flags, NULL, &gl) ||
- gl.gl_pathc == 0) {
- reply(550, "%s: Not found",
- $1);
- $$ = NULL;
- } else if (gl.gl_matchc > 1) {
- reply(550,
- "%s: Too many matches", $1);
- $$ = NULL;
- } else
- $$ = xstrdup(gl.gl_pathv[0]);
- globfree(&gl);
+ struct passwd *pw;
+
+ if ((pw = getpwnam($1 + 1)) != NULL)
+ home = pw->pw_dir;
+ else
+ home = $1;
+ }
+ len = strlen(home) + 1;
+ if (path != NULL)
+ len += strlen(path) + 1;
+ if ((result = malloc(len)) == NULL)
+ fatal("Local resource failure: malloc");
+ strlcpy(result, home, len);
+ if (path != NULL) {
+ strlcat(result, "/", len);
+ strlcat(result, path, len);
}
+ $$ = result;
free($1);
} else
$$ = $1;
diff --git a/libexec/ftpd/version.h b/libexec/ftpd/version.h
index 27c9c5ed10c..d2c3577bdf3 100644
--- a/libexec/ftpd/version.h
+++ b/libexec/ftpd/version.h
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.30 2001/04/17 00:59:59 lukem Exp $ */
+/* $NetBSD: version.h,v 1.31 2001/04/17 01:37:04 lukem Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -36,5 +36,5 @@
*/
#ifndef FTPD_VERSION
-#define FTPD_VERSION "NetBSD-ftpd 20010417"
+#define FTPD_VERSION "NetBSD-ftpd 20010417a"
#endif