Splat .message file if it exists when user cd's to a directory
authormillert <millert@openbsd.org>
Tue, 25 Mar 1997 22:47:08 +0000 (22:47 +0000)
committermillert <millert@openbsd.org>
Tue, 25 Mar 1997 22:47:08 +0000 (22:47 +0000)
like wu-ftpd.  Based on changes from Oliver.

libexec/ftpd/ftpd.c
libexec/ftpd/pathnames.h

index 9d32bbe..879f47a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ftpd.c,v 1.32 1997/01/23 06:49:11 deraadt Exp $       */
+/*     $OpenBSD: ftpd.c,v 1.33 1997/03/25 22:47:10 millert Exp $       */
 /*     $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $        */
 
 /*
@@ -1623,11 +1623,24 @@ void
 cwd(path)
        char *path;
 {
+       FILE *message;
 
        if (chdir(path) < 0)
                perror_reply(550, path);
-       else
+       else {
+               if ((message = fopen(_PATH_CWDMESG, "r")) != NULL) {
+                       char *cp, line[LINE_MAX];
+
+                       while (fgets(line, sizeof(line), message) != NULL) {
+                               if ((cp = strchr(line, '\n')) != NULL)
+                                       *cp = '\0';
+                               lreply(250, "%s", line);
+                       }
+                       (void) fflush(stdout);
+                       (void) fclose(message);
+               }
                ack("CWD");
+       }
 }
 
 void
index 99d7c8b..345062e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pathnames.h,v 1.2 1996/07/28 22:42:46 downsj Exp $    */
+/*     $OpenBSD: pathnames.h,v 1.3 1997/03/25 22:47:08 millert Exp $   */
 /*     $NetBSD: pathnames.h,v 1.5 1995/04/11 02:44:59 cgd Exp $        */
 
 /*
@@ -43,3 +43,4 @@
 #define        _PATH_FTPWELCOME        "/etc/ftpwelcome"
 #define        _PATH_FTPLOGINMESG      "/etc/motd"
 #define _PATH_FTPDSTATFILE     "/var/log/ftpd"
+#define _PATH_CWDMESG          ".message"