From 2bba642ea588faa134ac8f7c78b3313bf6fe8072 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 23 Jul 1998 08:13:39 +0000 Subject: add replydirname() from netbsd; fixes 257 directory replies; problem noted by kstailey --- libexec/ftpd/ftpd.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'libexec') diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index c13fb1b799d..816fba20299 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.48 1998/07/13 02:11:15 millert Exp $ */ +/* $OpenBSD: ftpd.c,v 1.49 1998/07/23 08:13:38 deraadt Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -218,6 +218,7 @@ static int guniquefd __P((char *, char **)); static void lostconn __P((int)); static void sigquit __P((int)); static int receive_data __P((FILE *, FILE *)); +static void replydirname __P((const char *, const char *)); static void send_data __P((FILE *, FILE *, off_t, off_t, int)); static struct passwd * sgetpwnam __P((char *)); @@ -1675,6 +1676,22 @@ cwd(path) } } +void +replydirname(name, message) + const char *name, *message; +{ + char npath[MAXPATHLEN]; + int i; + + for (i = 0; *name != '\0' && i < sizeof(npath) - 1; i++, name++) { + npath[i] = *name; + if (*name == '"') + npath[++i] = '"'; + } + npath[i] = '\0'; + reply(257, "\"%s\" %s", npath, message); +} + void makedir(name) char *name; @@ -1684,7 +1701,7 @@ makedir(name) if (mkdir(name, 0777) < 0) perror_reply(550, name); else - reply(257, "MKD command successful."); + replydirname(name, "directory created."); } void @@ -1707,7 +1724,7 @@ pwd() if (getwd(path) == (char *)NULL) reply(550, "%s.", path); else - reply(257, "\"%s\" is current directory.", path); + replydirname(path, "is current directory."); } char * -- cgit v1.2.3