NetBSD Problem Report #1040

From gnats  Thu May 11 02:30:52 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id CAA10840 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Thu, 11 May 1995 02:30:51 -0700
Message-Id: <199505110619.CAA11496@zyro.herd.hks.net>
Date: Thu, 11 May 1995 02:19:15 -0400
From: Leslie Todd Masco <cactus@hks.net>
Reply-To: cactus@hks.net
To: gnats-bugs@NetBSD.ORG
Subject: Feature addition to ftpd
X-Send-Pr-Version: 3.2

>Number:         1040
>Category:       misc
>Synopsis:       Feature addition to ftpd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu May 11 02:35:03 +0000 1995
>Closed-Date:    Sat Jun 14 10:28:08 +0000 1997
>Last-Modified:  Sat Jun 14 10:28:58 +0000 1997
>Originator:     Leslie Todd Masco
>Release:        May 12, 1995
>Organization:
	HKS, Inc.
>Environment:
	All
System: NetBSD zyro.herd.hks.net 1.0A NetBSD 1.0A (HERD) #1: Mon May 1 19:19:44 EDT 1995 root@zyro.herd.hks.net:/export/netbsd/sup/allsrc/src/sys/arch/pmax/compile/HERD pmax


>Description:
	Feature to mimck wu-ftpd's printing of .message files and notification
	of README* files and the interval since modification of same.
>How-To-Repeat:
	n/a
>Fix:

*** ftpd.c.orig	Thu May 11 01:03:22 1995
--- ftpd.c	Thu May 11 02:08:49 1995
***************
*** 82,87 ****
--- 82,88 ----
  #include <syslog.h>
  #include <time.h>
  #include <unistd.h>
+ #include <tzfile.h>

  #include "pathnames.h"
  #include "extern.h"
***************
*** 92,98 ****
  #include <varargs.h>
  #endif

! static char version[] = "Version 6.00";

  extern	off_t restart_point;
  extern	char cbuf[];
--- 93,99 ----
  #include <varargs.h>
  #endif

! static char version[] = "Version 6.01";

  extern	off_t restart_point;
  extern	char cbuf[];
***************
*** 187,192 ****
--- 188,194 ----
  static struct passwd *
  		 sgetpwnam __P((char *));
  static char	*sgetsave __P((char *));
+ static void    checkftpdir __P((int));

  static char *
  curdir()
***************
*** 643,648 ****
--- 645,651 ----
  		(void) fclose(fd);
  	}
  	if (guest) {
+ 	        checkftpdir(230);
  		reply(230, "Guest login ok, access restrictions apply.");
  #ifdef HASSETPROCTITLE
  		snprintf(proctitle, sizeof(proctitle),
***************
*** 655,660 ****
--- 658,664 ----
  			syslog(LOG_INFO, "ANONYMOUS FTP LOGIN FROM %s, %s",
  			    remotehost, passwd);
  	} else {
+                 checkftpdir(230);
  		reply(230, "User %s logged in.", pw->pw_name);
  #ifdef HASSETPROCTITLE
  		snprintf(proctitle, sizeof(proctitle),
***************
*** 1292,1302 ****
  cwd(path)
  	char *path;
  {
! 
! 	if (chdir(path) < 0)
! 		perror_reply(550, path);
! 	else
! 		ack("CWD");
  }

  void
--- 1296,1361 ----
  cwd(path)
  	char *path;
  {
!   if (chdir(path) < 0)
!     perror_reply(550, path);
!   else {
!     checkftpdir(250);
!     ack("CWD");
!   }
! }
! 
! void checkftpdir(protocol_code)
! int protocol_code;
! {
!   FILE *fd;
!   DIR *dd;
!   char line[LINE_MAX], date[LINE_MAX], *cp;
!   struct dirent *de;
!   struct stat sb;
!   time_t now, interval;
! 
!   if ((fd = fopen(".message", "r")) != NULL) {
!     while (fgets(line, sizeof(line), fd) != NULL) {
!       if ((cp = strchr(line, '\n')) != NULL)
! 	*cp = '\0';
!       lreply(protocol_code, "%s", line);
!     }
!     lreply(protocol_code, "%s", "");
!     (void) fflush(stdout);
!     (void) fclose(fd);
!     /* reply(protocol_code,) is done in ack("CWD") */
!   }
!   
!   /* Find each file beginning with "README" and notify the user of its
!      existence and mtime. */
!   
!   if ((dd = opendir(".")) != NULL) {
!     while ((de = readdir(dd)) != NULL) {
!       if ((de->d_namlen > 4) && (strncmp(de->d_name, "README",6) == NULL)) {
! 	sprintf(line,"Please read the file %s",de->d_name);
! 	lreply(protocol_code, "%s", line);
! 
! 	if (stat(de->d_name,&sb) == 0) {
! 	  sprintf(date,"%s", ctime((time_t *)&(sb.st_mtimespec.ts_sec)));
! 
! 	  /* Cut off final \n from ctime() */
! 
! 	  date[strlen(date)-1] = '\0';
! 	  sprintf(line,"  it was last modified on %s ",date);
! 	  if (time(&now) != ((time_t) -1)) {
! 	    interval = now - sb.st_mtimespec.ts_sec;
! 	    if (interval > SECSPERDAY)
! 	      sprintf(date,"- %d days ago", interval / SECSPERDAY);
! 	    else
! 	      sprintf(date,"- within the last day.");
! 	    strcat(line, date);
! 	  }
! 	  lreply(protocol_code, "%s", line);
! 	}
!       }
!     }
!     (void)closedir(dd);
!   }
  }

  void

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: lukem 
State-Changed-When: Sat Jun 14 03:28:08 PDT 1997 
State-Changed-Why:  
This functionality was added as part of the /etc/ftpd.conf stuff just added. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.