--- sbbs/src/sbbs3/upload.cpp 2018/04/24 16:41:23 1.1.1.1 +++ sbbs/src/sbbs3/upload.cpp 2018/04/24 16:43:29 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet file upload-related routines */ -/* $Id: upload.cpp,v 1.1.1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: upload.cpp,v 1.1.1.2 2018/04/24 16:43:29 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -73,14 +73,14 @@ bool sbbs_t::uploadfile(file_t *f) ,useron.alias ,f->name ,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname); - logline("U!",str); + logline(LOG_NOTICE,"U!",str); return(0); } strcpy(tmp,f->name); truncsp(tmp); for(i=0;iext[0]=='*' || !stricmp(tmp+9,cfg.ftest[i]->ext)) { - if(!chk_ar(cfg.ftest[i]->ar,&useron)) + if(!chk_ar(cfg.ftest[i]->ar,&useron,&client)) continue; attr(LIGHTGRAY); bputs(cfg.ftest[i]->workstr); @@ -104,7 +104,7 @@ bool sbbs_t::uploadfile(file_t *f) ,useron.alias ,f->name ,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname,cfg.ftest[i]->ext); - logline("U!",str); + logline(LOG_NOTICE,"U!",str); #if 0 sprintf(str,"Failed test: %s", cmdstr(cfg.ftest[i]->cmd,path,f->desc,NULL)); logline(" ",str); @@ -139,19 +139,19 @@ bool sbbs_t::uploadfile(file_t *f) } } - if((length=flength(path))<=0L) { + if((length=(long)flength(path))==0L) { bprintf(text[FileZeroLength],f->name); remove(path); sprintf(str,"%s attempted to upload %s to %s %s (Zero length)" ,useron.alias ,f->name ,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname); - logline("U!",str); + logline(LOG_NOTICE,"U!",str); return(0); } if(cfg.dir[f->dir]->misc&DIR_DIZ) { for(i=0;iext,tmp+9) && chk_ar(cfg.fextr[i]->ar,&useron)) + if(!stricmp(cfg.fextr[i]->ext,tmp+9) && chk_ar(cfg.fextr[i]->ar,&useron,&client)) break; if(idesc[0]) { strcpy(desc,ext); - strip_exascii(desc); - prep_file_desc(desc); + strip_exascii(desc, desc); + prep_file_desc(desc, desc); for(i=0;desc[i];i++) if(isalnum(desc[i])) break; @@ -266,14 +266,16 @@ bool sbbs_t::upload(uint dirnum) bputs(text[CantUploadHere]); return(false); } - if(!chk_ar(cfg.dir[dirnum]->ul_ar,&useron)) { - bputs(dirnum==cfg.user_dir ? text[CantUploadToUser] : - dirnum==cfg.sysop_dir ? text[CantUploadToSysop] : text[CantUploadHere]); - return(false); - } - if(getfiles(&cfg,dirnum)>=cfg.dir[dirnum]->maxfiles) { - bputs(dirnum==cfg.user_dir ? text[UserDirFull] : text[DirFull]); - return(false); + if(!(useron.exempt&FLAG('U')) && !dir_op(dirnum)) { + if(!chk_ar(cfg.dir[dirnum]->ul_ar,&useron,&client)) { + bputs(dirnum==cfg.user_dir ? text[CantUploadToUser] : + dirnum==cfg.sysop_dir ? text[CantUploadToSysop] : text[CantUploadHere]); + return(false); + } + if(cfg.dir[dirnum]->maxfiles && getfiles(&cfg,dirnum)>=cfg.dir[dirnum]->maxfiles) { + bputs(dirnum==cfg.user_dir ? text[UserDirFull] : text[DirFull]); + return(false); + } } if(sys_status&SS_EVENT && online==ON_REMOTE && !dir_op(dirnum)) @@ -283,13 +285,17 @@ bool sbbs_t::upload(uint dirnum) else strcpy(path,cfg.dir[dirnum]->path); + if(!isdir(path)) { + bprintf(text[DirectoryDoesNotExist], path); + lprintf(LOG_ERR,"File directory does not exist: %s", path); + return(false); + } /* get free disk space */ space=getfreediskspace(path,1024); if(space<(ulong)cfg.min_dspace) { bputs(text[LowDiskSpace]); - sprintf(str,"Diskspace is low: %s (%lu kilobytes)",path,space); - errorlog(str); + lprintf(LOG_ERR,"Diskspace is low: %s (%lu kilobytes)",path,space); if(!dir_op(dirnum)) return(false); } @@ -391,8 +397,8 @@ bool sbbs_t::upload(uint dirnum) } getuserdat(&cfg,&user); if((user.rest&(FLAG('T')|FLAG('D'))) - || !chk_ar(cfg.lib[cfg.dir[cfg.user_dir]->lib]->ar,&user) - || !chk_ar(cfg.dir[cfg.user_dir]->dl_ar,&user)) { + || !chk_ar(cfg.lib[cfg.dir[cfg.user_dir]->lib]->ar,&user,/* client: */NULL) + || !chk_ar(cfg.dir[cfg.user_dir]->dl_ar,&user,/* client: */NULL)) { bprintf(text[UserWontBeAbleToDl],user.alias); } else { bprintf(text[UserAddedToDestList],user.alias); @@ -472,7 +478,7 @@ bool sbbs_t::upload(uint dirnum) strcat(keys,"B"); } for(i=0;iulcmd[0] && chk_ar(cfg.prot[i]->ar,&useron)) { + if(cfg.prot[i]->ulcmd[0] && chk_ar(cfg.prot[i]->ar,&useron,&client)) { sprintf(tmp,"%c",cfg.prot[i]->mnemonic); strcat(keys,tmp); } @@ -500,7 +506,7 @@ bool sbbs_t::upload(uint dirnum) } else { for(i=0;iulcmd[0] && cfg.prot[i]->mnemonic==ch - && chk_ar(cfg.prot[i]->ar,&useron)) + && chk_ar(cfg.prot[i]->ar,&useron,&client)) break; if(i=cfg.dir[dirnum]->maxfiles) { - bputs(text[DirFull]); - break; - } sprintf(str,"%s%s",path,dirent->d_name); if(isdir(str)) continue; @@ -589,11 +591,13 @@ bool sbbs_t::bulkupload(uint dirnum) if(findfile(&cfg,f.dir,str)==0) { strcpy(f.name,str); - f.cdt=flength(spath); + f.cdt=(long)flength(spath); bprintf(text[BulkUploadDescPrompt],f.name,f.cdt/1024); getstr(f.desc,LEN_FDESC,K_LINE); if(sys_status&SS_ABORT) break; + if(strcmp(f.desc,"-")==0) /* don't add this file */ + continue; uploadfile(&f); } } @@ -618,7 +622,7 @@ bool sbbs_t::recvfile(char *fname, char mnemonics(text[ProtocolOrQuit]); strcpy(keys,"Q"); for(i=0;iulcmd[0] && chk_ar(cfg.prot[i]->ar,&useron)) + if(cfg.prot[i]->ulcmd[0] && chk_ar(cfg.prot[i]->ar,&useron,&client)) sprintf(keys+strlen(keys),"%c",cfg.prot[i]->mnemonic); ch=(char)getkeys(keys,0); @@ -627,7 +631,7 @@ bool sbbs_t::recvfile(char *fname, char return(false); } for(i=0;imnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron)) + if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client)) break; if(i