From 0533981711c8685f500dc6b3690044869c429914 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Fri, 18 Feb 2005 03:29:32 +0000
Subject: [PATCH] Create tempory transfer files in the (*gasp*) temporary
 directory (instead of data_dir). Use more unique temporary transfer filenames
 (includes the local hostname).

---
 src/sbbs3/ftpsrvr.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/sbbs3/ftpsrvr.c b/src/sbbs3/ftpsrvr.c
index 6264a19cac..5614fc5249 100644
--- a/src/sbbs3/ftpsrvr.c
+++ b/src/sbbs3/ftpsrvr.c
@@ -94,6 +94,7 @@ static DWORD	thread_count=0;
 static time_t	uptime=0;
 static DWORD	served=0;
 static BOOL		terminate_server=FALSE;
+static char		local_hostname[128];
 static char		revision[16];
 static char 	*text[TOTAL_TEXT];
 static link_list_t recycle_semfiles;
@@ -2266,7 +2267,7 @@ static BOOL badlogin(SOCKET sock, ulong* login_attempts)
 
 static char* ftp_tmpfname(char* str, SOCKET sock)
 {
-	sprintf(str,"%sftp%u%u.tx",scfg.data_dir,getpid(),sock);
+	safe_snprintf(str,MAX_PATH,"%sSBBS_FTP.%s.%u.tx",scfg.temp_dir,local_hostname,sock);
 	return(str);
 }
 
@@ -4554,6 +4555,8 @@ void DLLCALL ftp_server(void* arg)
 
 		status("Initializing");
 
+		gethostname(local_hostname,sizeof(local_hostname));
+
 		memset(&scfg, 0, sizeof(scfg));
 
 		lprintf(LOG_INFO,"Synchronet FTP Server Revision %s%s"
@@ -4610,11 +4613,18 @@ void DLLCALL ftp_server(void* arg)
 		if(uptime==0)
 			uptime=time(NULL);	/* this must be done *after* setting the timezone */
 
-		if(startup->temp_dir[0]) {
+		if(startup->temp_dir[0])
 			SAFECOPY(scfg.temp_dir,startup->temp_dir);
-			backslash(scfg.temp_dir);
-		} else
-			prep_dir(scfg.data_dir, scfg.temp_dir, sizeof(scfg.temp_dir));
+		else
+	    	prep_dir(scfg.data_dir, scfg.temp_dir, sizeof(scfg.temp_dir));
+		backslash(scfg.temp_dir);
+		MKDIR(scfg.temp_dir);
+		lprintf(LOG_DEBUG,"Temporary file directory: %s", scfg.temp_dir);
+		if(!isdir(scfg.temp_dir)) {
+			lprintf(LOG_ERR,"!Invalid temp directory: %s", scfg.temp_dir);
+			cleanup(1,__LINE__);
+			return;
+		}
 
 		if(!startup->max_clients) {
 			startup->max_clients=scfg.sys_nodes;
-- 
GitLab