From 5d1e28b55f9241e8d57a9d429d686f0fb5b3ff73 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 17 Apr 2018 02:56:17 +0000 Subject: [PATCH] Bug-fix: when exporting FTN netmail from SMB "mail" base, if the netmail included an "old-style" (not MIME-encoded) file attachment (where the file path is in the subject and the FILEATTACH aux-attribute flag is set), the corresponding netmail attribute flag would not be set in the stored msg (*.msg) file. Also simplified the create_netmail() function prototype/usage, removing the "file_attached" argument (use the hdr.auxattr instead). --- src/sbbs3/sbbsecho.c | 60 +++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/sbbs3/sbbsecho.c b/src/sbbs3/sbbsecho.c index 4dcd64fd50..8dec3f906e 100644 --- a/src/sbbs3/sbbsecho.c +++ b/src/sbbs3/sbbsecho.c @@ -1067,8 +1067,7 @@ bool new_pkthdr(fpkthdr_t* hdr, fidoaddr_t orig, fidoaddr_t dest, const nodecfg_ If file is non-zero, will set file attachment bit (for bundles). Returns 0 on success. ******************************************************************************/ -int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, const char *body, fidoaddr_t dest - ,bool file_attached) +int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, const char *body, fidoaddr_t dest) { FILE *fp; char tmp[256]; @@ -1138,7 +1137,7 @@ int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, con hdr.destpoint=dest.point; hdr.attr=(FIDO_PRIVATE|FIDO_KILLSENT|FIDO_LOCAL); - if(file_attached) + if(msg != NULL && (msg->hdr.auxattr&MSG_FILEATTACH)) hdr.attr|=FIDO_FILE; if(nodecfg != NULL) { @@ -1178,7 +1177,7 @@ int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, con fprintf(fp,"\1FLAGS"); if(direct) fprintf(fp," DIR"); - if(file_attached) { + if(hdr.attr&FIDO_FILE) { if(cfg.trunc_bundles) fprintf(fp," TFS"); else @@ -1215,7 +1214,7 @@ int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, con } fputc(FIDO_STORED_MSG_TERMINATOR, fp); lprintf(LOG_INFO, "Created NetMail (%s)%s from %s (%s) to %s (%s), attr: %04hX, subject: %s" - ,getfname(fname), file_attached ? " with attachment" : "" + ,getfname(fname), (hdr.attr&FIDO_FILE) ? " with attachment" : "" ,from, smb_faddrtoa(&faddr, tmp), to, smb_faddrtoa(&dest, NULL), hdr.attr, subject); return fclose(fp); } @@ -1257,7 +1256,7 @@ int file_to_netmail(FILE* infile, const char* title, fidoaddr_t dest, const char } if(ftell(infile)<l) strcat(buf,"\r\nContinued in next message...\r\n"); - if(create_netmail(to, /* msg: */NULL, title, buf, dest, /* attachment: */false) == 0) + if(create_netmail(to, /* msg: */NULL, title, buf, dest) == 0) netmails_created++; } free(buf); @@ -1479,7 +1478,7 @@ void netmail_arealist(enum arealist_type type, fidoaddr_t addr, const char* to) } strListSortAlpha(area_list); if(!strListCount(area_list)) - create_netmail(to,/* msg: */NULL,title,"None.",addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, title, "None.", addr); else { FILE* fp; if((fp=tmpfile())==NULL) { @@ -1808,7 +1807,7 @@ void alter_areas(str_list_t add_area, str_list_t del_area, fidoaddr_t addr, cons } if (to != NULL) { if (!ftell(nmfile)) - create_netmail(to,/* msg: */NULL, "Area Management Request", "No changes made.", addr,/* attachment: */false); + create_netmail(to,/* msg: */NULL, "Area Management Request", "No changes made.", addr); else file_to_netmail(nmfile, "Area Management Request", addr, to); } @@ -1983,7 +1982,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) alter_config(addr,"archive",p); SAFEPRINTF(str, "Compression type changed to: %s", p); lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"Compression Type Change",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "Compression Type Change", str, addr); return true; } @@ -1997,7 +1996,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) sprintf(str,"Your AreaMgr password was already set to '%s'." ,nodecfg->password); lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"AreaMgr Password Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "AreaMgr Password Change Request", str, addr); return true; } if(alter_config(addr,"AreaFixPwd", password)) { @@ -2008,7 +2007,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) SAFECOPY(str,"Error changing AreaMgr password"); } lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"AreaMgr Password Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "AreaMgr Password Change Request", str, addr); return true; } @@ -2022,7 +2021,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) sprintf(str,"Your packet password was already set to '%s'." ,nodecfg->pktpwd); lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"Packet Password Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "Packet Password Change Request", str, addr); return true; } if(alter_config(addr,"PacketPwd", pktpwd)) { @@ -2033,7 +2032,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) SAFECOPY(str,"Error changing packet password"); } lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"Packet Password Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "Packet Password Change Request", str, addr); return true; } @@ -2047,7 +2046,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) sprintf(str,"Your TIC File password was already set to '%s'." ,nodecfg->ticpwd); lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"TIC File Password Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "TIC File Password Change Request", str, addr); return true; } if(alter_config(addr,"TicFilePwd", ticpwd)) { @@ -2058,7 +2057,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) SAFECOPY(str,"Error changing TIC File password"); } lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"TIC File Password Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "TIC File Password Change Request", str, addr); return true; } @@ -2073,7 +2072,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) SAFECOPY(str,"Error changing Notify Setting"); } lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); - create_netmail(to,/* msg: */NULL,"Notification Messages Change Request",str,addr,/* attachment: */false); + create_netmail(to, /* msg: */NULL, "Notification Messages Change Request", str, addr); return true; } @@ -2082,7 +2081,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) export_echomail(NULL, nodecfg, true); create_netmail(to,/* msg: */NULL, "Rescan Areas" ,"All connected areas carried by your hub have been rescanned." - ,addr,/* attachment: */false); + ,addr); return true; } @@ -2101,7 +2100,7 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) } lprintf(LOG_INFO, "AreaFix (for %s) %s", faddrtoa(&addr), str); create_netmail(to,/* msg: */NULL, "Rescan Area" - ,str, addr, /* attachment: */false); + ,str, addr); return true; } @@ -2129,26 +2128,26 @@ bool areafix_command(char* instr, nodecfg_t* nodecfg, const char* to) if(stricmp(instr, "ACTIVE") == 0 || stricmp(instr, "RESUME") == 0) { if(!nodecfg->passive) { create_netmail(to,/* msg: */NULL,"Reconnect Disconnected (paused) Areas" - ,"Your areas are already connected.",addr,/* attachment: */false); + ,"Your areas are already connected.",addr); return true; } nodecfg->passive = false; alter_config(addr,"passive","false"); create_netmail(to,/* msg: */NULL,"Reconnect Disconnected (paused) Areas" - ,"Temporarily disconnected areas have been reconnected.",addr,/* attachment: */false); + ,"Temporarily disconnected areas have been reconnected.",addr); return true; } if(stricmp(instr, "PASSIVE") == 0 || stricmp(instr, "PAUSE") == 0) { if(nodecfg->passive) { create_netmail(to,/* msg: */NULL,"Temporarily Disconnect (pause) Areas" - ,"Your areas are already temporarily disconnected.",addr,/* attachment: */false); + ,"Your areas are already temporarily disconnected.",addr); return true; } nodecfg->passive = true; alter_config(addr,"passive","true"); create_netmail(to,/* msg: */NULL,"Temporarily Disconnect (pause) Areas" - ,"Your areas have been temporarily disconnected.",addr,/* attachment: */false); + ,"Your areas have been temporarily disconnected.",addr); return true; } @@ -2214,13 +2213,13 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const if(nodecfg==NULL || !nodecfg->areafix) { lprintf(LOG_NOTICE,"AreaFix (for %s) Request received, but AreaFix not enabled for this node!", smb_faddrtoa(&addr,NULL)); create_netmail(name,/* msg: */NULL,"Area Management Request" - ,"Your node is not configured for AreaFix, please contact your hub sysop.\r\n",addr,/* attachment: */false); + ,"Your node is not configured for AreaFix, please contact your hub sysop.\r\n",addr); strcat(body,"This node is not configured for AreaFix operations.\r\n"); return(body); } if(stricmp(nodecfg->password,password)) { - create_netmail(name,/* msg: */NULL,"Area Management Request","Invalid Password.",addr,/* attachment: */false); + create_netmail(name,/* msg: */NULL,"Area Management Request","Invalid Password.",addr); sprintf(body+strlen(body), "An invalid password (%s) was supplied in the message subject.\r\n" "The correct Area Manager password for this node is: %s\r\n" ,password @@ -2267,7 +2266,7 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const if(!cmds && !strListCount(add_area) && !strListCount(del_area)) { create_netmail(name,/* msg: */NULL,"Area Management Request" ,"No commands to process.\r\nSend %HELP for help.\r\n" - ,addr,/* attachment: */false); + ,addr); strcat(body, "No valid AreaFix commands were detected.\r\n"); strListFree(&add_area); strListFree(&del_area); @@ -2460,7 +2459,7 @@ int attachment(const char *bundlename, fidoaddr_t dest, enum attachment_mode mod ,/* msg: */NULL ,/* subj: */attach.filename ,(cfg.trunc_bundles) ? "\1FLAGS TFS\r" : "\1FLAGS KFS\r" - ,attach.dest,/* attachment: */false)) + ,attach.dest)) error=1; } fclose(stream); @@ -2565,7 +2564,7 @@ bool pack_bundle(const char *tmp_pkt, fidoaddr_t orig, fidoaddr_t dest) else i=create_netmail(/* To: */NULL,/* msg: */NULL,packet ,(cfg.trunc_bundles) ? "\1FLAGS TFS\r" : "\1FLAGS KFS\r" - ,dest,/* attachment: */false); + ,dest); return i==0; } @@ -4383,7 +4382,7 @@ int import_netmail(const char* path, fmsghdr_t hdr, FILE* fp, const char* inboun "\r======[ End received msg text ]======\r", fmsgbuf); } SAFEPRINTF(subj, "Pong: %s", hdr.subj); - create_netmail(/* to: */hdr.from, /* msg: */NULL, subj, body, addr, /* file_attached: */false); + create_netmail(/* to: */hdr.from, /* msg: */NULL, subj, body, addr); if(body != fmsgbuf) { FREE_AND_NULL(body); } @@ -5100,7 +5099,6 @@ int export_netmail(void) } char* msg_subj = msg.subj; - bool file_attached = false; if((txt=smb_getmsgtxt(email, &msg, GETMSGTXT_BODY_ONLY)) != NULL) { char filename[MAX_PATH+1] = {0}; uint32_t filelen = 0; @@ -5123,7 +5121,7 @@ int export_netmail(void) lprintf(LOG_ERR, "!ERROR %d (%s) writing %u bytes to %s", errno, strerror(errno), filelen, fpath); else { lprintf(LOG_DEBUG, "Decoded MIME attachment stored as: %s", fpath); - file_attached = true; + msg.hdr.auxattr |= MSG_FILEATTACH; msg_subj = fpath; } } @@ -5137,7 +5135,7 @@ int export_netmail(void) continue; } - create_netmail(msg.to, &msg, msg_subj, txt, *(fidoaddr_t*)msg.to_net.addr, file_attached); + create_netmail(msg.to, &msg, msg_subj, txt, *(fidoaddr_t*)msg.to_net.addr); FREE_AND_NULL(txt); if(cfg.delete_netmail || (msg.hdr.netattr&MSG_KILLSENT)) { -- GitLab