...
 
Commits (1)
......@@ -6125,15 +6125,11 @@ void DLLCALL ftp_server(void* arg)
SAFECOPY(scfg.temp_dir,"../temp");
prep_dir(scfg.ctrl_dir, scfg.temp_dir, sizeof(scfg.temp_dir));
if(!md(scfg.temp_dir)) {
lprintf(LOG_CRIT,"!ERROR %d (%s) creating directory: %s", errno, strerror(errno), scfg.temp_dir);
cleanup(1,__LINE__);
break;
}
lprintf(LOG_DEBUG,"Temporary file directory: %s", scfg.temp_dir);
if(!isdir(scfg.temp_dir)) {
lprintf(LOG_CRIT,"!Invalid temp directory: %s", scfg.temp_dir);
cleanup(1,__LINE__);
break;
}
if(!startup->max_clients) {
startup->max_clients=scfg.sys_nodes;
......
......@@ -326,9 +326,10 @@ void DLLCALL free_text(char* text[])
/****************************************************************************/
/* If the directory 'path' doesn't exist, create it. */
/****************************************************************************/
BOOL md(char *inpath)
BOOL md(const char* inpath)
{
char path[MAX_PATH+1];
char* p;
if(inpath[0]==0)
return(FALSE);
......@@ -336,19 +337,18 @@ BOOL md(char *inpath)
SAFECOPY(path,inpath);
/* Remove trailing '.' if present */
if(path[strlen(path)-1]=='.')
path[strlen(path)-1]=0;
p = lastchar(path);
if(*p=='.')
*p = '\0';
/* Remove trailing slash if present */
if(path[strlen(path)-1]=='\\' || path[strlen(path)-1]=='/')
path[strlen(path)-1]=0;
p = lastchar(path);
if(*p == '\\' || *p == '/')
*p = '\0';
if(!isdir(path)) {
/* lprintf("Creating directory: %s",path); */
if(mkpath(path)) {
lprintf(LOG_WARNING,"!ERROR %d (%s) creating directory: %s", errno, strerror(errno), path);
return(FALSE);
}
if(mkpath(path) != 0)
return FALSE;
}
return(TRUE);
......
......@@ -6085,6 +6085,7 @@ void DLLCALL mail_server(void* arg)
SAFECOPY(scfg.temp_dir,"../temp");
prep_dir(scfg.ctrl_dir, scfg.temp_dir, sizeof(scfg.temp_dir));
if(!md(scfg.temp_dir)) {
lprintf(LOG_CRIT, "!ERROR %d (%s) creating directory: %s", errno, strerror(errno), scfg.temp_dir);
cleanup(1);
return;
}
......
......@@ -3312,7 +3312,8 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
else
SAFECOPY(cfg.temp_dir,"../temp");
prep_dir(cfg.ctrl_dir, cfg.temp_dir, sizeof(cfg.temp_dir));
md(cfg.temp_dir);
if(!md(cfg.temp_dir))
lprintf(LOG_CRIT,"!ERROR %d (%s) creating directory: %s", errno, strerror(errno), cfg.temp_dir);
if(sd==INVALID_SOCKET) { /* events thread */
if(startup->first_node==1)
SAFEPRINTF(path,"%sevent",cfg.temp_dir);
......@@ -3540,7 +3541,10 @@ bool sbbs_t::init()
return(false);
}
md(cfg.temp_dir);
if(!md(cfg.temp_dir)) {
lprintf(LOG_CRIT,"!ERROR %d (%s) creating directory: %s", errno, strerror(errno), cfg.temp_dir);
return false;
}
/* Shared NODE files */
SAFEPRINTF2(str,"%s%s",cfg.ctrl_dir,"node.dab");
......@@ -5119,8 +5123,13 @@ void DLLCALL bbs_thread(void* arg)
/* Create missing node directories and dsts.dab files */
lprintf(LOG_INFO,"Verifying/creating node directories");
for(i=0;i<=scfg.sys_nodes;i++) {
if(i)
md(scfg.node_path[i-1]);
if(i) {
if(!md(scfg.node_path[i-1])) {
lprintf(LOG_CRIT,"!ERROR %d (%s) creating directory: %s", errno, strerror(errno), scfg.node_path[i-1]);
cleanup(1);
return;
}
}
SAFEPRINTF(str,"%sdsts.dab",i ? scfg.node_path[i-1] : scfg.ctrl_dir);
if(flength(str)<DSTSDABLEN) {
if((file=sopen(str,O_WRONLY|O_CREAT|O_APPEND, SH_DENYNO, DEFFILEMODE))==-1) {
......
......@@ -1259,6 +1259,8 @@ extern "C" {
DLLEXPORT void DLLCALL free_text(char* text[]);
DLLEXPORT ushort DLLCALL sys_timezone(scfg_t* cfg);
DLLEXPORT char * DLLCALL prep_dir(const char* base, char* dir, size_t buflen);
DLLEXPORT BOOL DLLCALL md(const char *path);
/* scfgsave.c */
DLLEXPORT BOOL DLLCALL save_cfg(scfg_t* cfg, int backup_level);
......@@ -1502,7 +1504,6 @@ int pstrcmp(const char **str1, const char **str2); /* Compares pointers to poi
int strsame(const char *str1, const char *str2); /* Compares number of same chars */
/* load_cfg.c */
BOOL md(char *path);
char* prep_code(char *str, const char* prefix);
#ifdef SBBS /* These aren't exported */
......
......@@ -1838,6 +1838,7 @@ void DLLCALL services_thread(void* arg)
SAFECOPY(scfg.temp_dir,"../temp");
prep_dir(scfg.ctrl_dir, scfg.temp_dir, sizeof(scfg.temp_dir));
if(!md(scfg.temp_dir)) {
lprintf(LOG_CRIT, "!ERROR %d (%s) creating directory: %s", errno, strerror(errno), scfg.temp_dir);
cleanup(1);
return;
}
......
......@@ -7034,6 +7034,7 @@ void DLLCALL web_server(void* arg)
SAFECOPY(scfg.temp_dir,"../temp");
prep_dir(startup->ctrl_dir, scfg.temp_dir, sizeof(scfg.temp_dir));
if(!md(scfg.temp_dir)) {
lprintf(LOG_CRIT, "!ERROR %d (%s) creating directory: %s", errno, strerror(errno), scfg.temp_dir);
cleanup(1);
return;
}
......