From 4af2926283b305f1b34575e9a039d671c29efaee Mon Sep 17 00:00:00 2001 From: itojun Date: Fri, 25 Oct 2002 01:45:37 +0000 Subject: [PATCH] Turns out that our implementation of STAT wasn't RFC 959 compliant. This version is now RFC 959 compliant, using a patch adapted from one sent in by david.leonard@eecs.uq.edu.au openbsd libexec/ftpd/ftpd.c revision 1.69. (see RFC959 page 36) --- libexec/ftpd/cmds.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libexec/ftpd/cmds.c b/libexec/ftpd/cmds.c index 5212961bcd44..c6254b4f4f61 100644 --- a/libexec/ftpd/cmds.c +++ b/libexec/ftpd/cmds.c @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.18 2002/10/12 08:35:16 darrenr Exp $ */ +/* $NetBSD: cmds.c,v 1.19 2002/10/25 01:45:37 itojun Exp $ */ /* * Copyright (c) 1999-2001 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ #include #ifndef lint -__RCSID("$NetBSD: cmds.c,v 1.18 2002/10/12 08:35:16 darrenr Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.19 2002/10/25 01:45:37 itojun Exp $"); #endif /* not lint */ #include @@ -117,6 +117,7 @@ __RCSID("$NetBSD: cmds.c,v 1.18 2002/10/12 08:35:16 darrenr Exp $"); #include #include #include +#include #ifdef KERBEROS5 #include @@ -506,12 +507,14 @@ statfilecmd(const char *filename) { FILE *fin; int c; + int atstart; char *argv[] = { INTERNAL_LS, "-lgA", "", NULL }; argv[2] = (char *)filename; fin = ftpd_popen(argv, "r", STDOUT_FILENO); reply(-211, "status of %s:", filename); /* XXX: use fgetln() or fparseln() here? */ + atstart = 1; while ((c = getc(fin)) != EOF) { if (c == '\n') { if (ferror(stdout)){ @@ -527,7 +530,10 @@ statfilecmd(const char *filename) } CPUTC('\r', stdout); } + if (atstart && isdigit(c)) + CPUTC(' ', stdout); CPUTC(c, stdout); + atstart = (c == '\n'); } (void) ftpd_pclose(fin); reply(211, "End of Status");