diff --git a/ChangeLog b/ChangeLog index 54f059f0..ee7d8c94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -197,6 +197,8 @@ v0.33.20 10-Feb-2002 When a virus scanner is started, de mbtask connection timeout is set to one hour. Changed the confusing No Touch setting in tic areas to Touch. + When a file to be attached doesn't exist, a error message is + logged and the attach is treaded as an error. mbmsg: When creating non-existend message bases, the path is created diff --git a/TODO b/TODO index ec412cfd..4b69b6b9 100644 --- a/TODO +++ b/TODO @@ -69,6 +69,8 @@ mbfido: N: The first file received in a not yet created tic area is refused after the area is created: node xxx not connected to area xxx. + N: Doesn't erase netmail.jam and/or echomail.jam after a full mailscan. + mbcico: L: Implement modem connect response translation for ISDN lines, i.e. make the CAUSE responses human readable. see McMail for this diff --git a/lib/attach.c b/lib/attach.c index 0a1e71f5..6eb07f3d 100644 --- a/lib/attach.c +++ b/lib/attach.c @@ -39,74 +39,81 @@ int attach(faddr noden, char *ofile, int mode, char flavor) { - FILE *fp; - char *flofile; + FILE *fp; + char *flofile; + int rc; - if (ofile == NULL) - return FALSE; + if (ofile == NULL) + return FALSE; - flofile = calloc(PATH_MAX, sizeof(char)); - sprintf(flofile, "%s", floname(&noden, flavor)); + if ((rc = file_exist(ofile, R_OK))) { + WriteError("attach: file %s failed, %s", ofile, strerror(rc)); + return FALSE; + } - /* - * Check if outbound directory exists and - * create if it doesn't exist. - */ - mkdirs(ofile, 0770); + flofile = calloc(PATH_MAX, sizeof(char)); + sprintf(flofile, "%s", floname(&noden, flavor)); - /* - * Attach file to .flo - * - * Note that mbcico when connected to a node opens the file "r+", - * locks it with fcntl(F_SETLK), F_RDLCK, whence=0, start=0L, len=0L. - * It seems that this lock is released after the files in the .flo - * files are send. I don't know what will happen if we add entries - * to the .flo files, this must be tested! - */ - if ((fp = fopen(flofile, "a+")) == NULL) { - WriteError("$Can't open %s", flofile); - WriteError("May be locked by mbcico"); - free(flofile); - return FALSE; - } + /* + * Check if outbound directory exists and + * create if it doesn't exist. + */ + mkdirs(ofile, 0770); - switch (mode) { - case LEAVE: - if (strlen(CFG.dospath)) { - if (CFG.leavecase) - fprintf(fp, "%s\r\n", Unix2Dos(ofile)); - else - fprintf(fp, "%s\r\n", tu(Unix2Dos(ofile))); - } else { - fprintf(fp, "%s\r\n", ofile); - } - break; - case KFS: - if (strlen(CFG.dospath)) { - if (CFG.leavecase) - fprintf(fp, "^%s\r\n", Unix2Dos(ofile)); - else - fprintf(fp, "^%s\r\n", tu(Unix2Dos(ofile))); - } else { - fprintf(fp, "^%s\r\n", ofile); - } - break; - - case TFS: - if (strlen(CFG.dospath)) { - if (CFG.leavecase) - fprintf(fp, "#%s\r\n", Unix2Dos(ofile)); - else - fprintf(fp, "#%s\r\n", tu(Unix2Dos(ofile))); - } else { - fprintf(fp, "#%s\r\n", ofile); - } - break; - } - - fclose(fp); + /* + * Attach file to .flo + * + * Note that mbcico when connected to a node opens the file "r+", + * locks it with fcntl(F_SETLK), F_RDLCK, whence=0, start=0L, len=0L. + * It seems that this lock is released after the files in the .flo + * files are send. I don't know what will happen if we add entries + * to the .flo files, this must be tested! + */ + if ((fp = fopen(flofile, "a+")) == NULL) { + WriteError("$Can't open %s", flofile); + WriteError("May be locked by mbcico"); free(flofile); - return TRUE; + return FALSE; + } + + switch (mode) { + case LEAVE: + if (strlen(CFG.dospath)) { + if (CFG.leavecase) + fprintf(fp, "%s\r\n", Unix2Dos(ofile)); + else + fprintf(fp, "%s\r\n", tu(Unix2Dos(ofile))); + } else { + fprintf(fp, "%s\r\n", ofile); + } + break; + + case KFS: + if (strlen(CFG.dospath)) { + if (CFG.leavecase) + fprintf(fp, "^%s\r\n", Unix2Dos(ofile)); + else + fprintf(fp, "^%s\r\n", tu(Unix2Dos(ofile))); + } else { + fprintf(fp, "^%s\r\n", ofile); + } + break; + + case TFS: + if (strlen(CFG.dospath)) { + if (CFG.leavecase) + fprintf(fp, "#%s\r\n", Unix2Dos(ofile)); + else + fprintf(fp, "#%s\r\n", tu(Unix2Dos(ofile))); + } else { + fprintf(fp, "#%s\r\n", ofile); + } + break; + } + + fclose(fp); + free(flofile); + return TRUE; }