Fixed mbmsg post

This commit is contained in:
Michiel Broek 2004-06-06 14:55:00 +00:00
parent c9c1288e2c
commit 0c5338827d
4 changed files with 219 additions and 190 deletions

View File

@ -2,6 +2,14 @@ $Id$
v0.61.0 06-Jun-2004.
mbmsg:
With te post command, the right number of commandline options
is checked, if this is wrong the help message is displayed.
If a message is posted in a local area, no echomail.jam is
updated and the mailout semafore is not set.
Added checks in the mbmsg post command if the To parameter has
the correct syntax for netmail and all other areas.
v0.60.0 09-Feb-2004 - 04-Jun-2004

10
TODO
View File

@ -137,16 +137,6 @@ mbfile:
N: It is not possible to import areas that run of cd-roms. Do we still
need cd-rom support with current hd prices?
mbmsg:
N: With the post command if a netmail area is used the netmail area
will cause trouble later, should be blocked to be used on netmail
areas.
N: With the post command check the commandline before doing anything.
N: With post in echomail, if a name name@address is given, the address
part should be stripped.
mbaff:
L: Rewrite filefind search algorithm.

View File

@ -117,6 +117,8 @@ int main(int argc, char **argv)
if (strncasecmp(argv[i], "pa", 2) == 0)
do_pack = TRUE;
if (strncasecmp(argv[i], "po", 2) == 0) {
if ((argc - i) != 6)
Help();
do_post = TRUE;
too = argv[++i];
cmd = xstrcat(cmd, (char *)" \"");

View File

@ -50,7 +50,6 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
time_t tt;
struct tm *t;
if (!do_quiet) {
colour(3, 0);
printf("Post \"%s\" to \"%s\" in area %ld\n", File, To, Area);
@ -62,10 +61,12 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
if ((tp = fopen(File, "r")) == NULL) {
WriteError("$Can't open %s", File);
if (!do_quiet)
printf("Can't open \"%s\"\n", File);
return;
}
sAreas = calloc(128, sizeof(char));
sAreas = calloc(PATH_MAX, sizeof(char));
sprintf(sAreas, "%s//etc/mareas.data", getenv("MBSE_ROOT"));
if ((fp = fopen(sAreas, "r")) == NULL) {
WriteError("$Can't open %s", sAreas);
@ -99,6 +100,31 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
return;
}
/*
* Check the proper syntax in the To parameter, in netmail areas
* it must have a destination address, in all other areas just a
* full name.
*/
if (msgs.Type == NETMAIL) {
if ((strchr(To, '@') == NULL) || (strstr(To, (char *)".n") == NULL) || (strstr(To, (char *)".z") == NULL)) {
WriteError("No address in \"%s\" and area is netmail", To);
if (!do_quiet)
printf("No address in \"%s\" and area is netmail\n", To);
fclose(fp);
fclose(tp);
return;
}
} else {
if ((strchr(To, '@')) || (strstr(To, (char *)".n")) || (strstr(To, (char *)".z"))) {
WriteError("Address present in \"%s\" and area is not netmail", To);
if (!do_quiet)
printf("Address present in \"%s\" and area is not netmail\n", To);
fclose(fp);
fclose(tp);
return;
}
}
if (!Msg_Open(msgs.Base)) {
WriteError("Can't open %s", msgs.Base);
fclose(fp);
@ -184,7 +210,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
break;
}
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "\001MSGID: %s %08lx", aka2str(msgs.Aka), sequencer());
MsgText_Add2(temp);
Msg.MsgIdCRC = upd_crc32(temp, crc, strlen(temp));
@ -230,14 +256,17 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
Msg_UnLock();
Syslog('+', "Posted message %ld", Msg.Id);
if (msgs.Type != LOCALMAIL) {
sprintf(temp, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"), (msgs.Type == ECHOMAIL) ? "echo" : "net");
if ((fp = fopen(temp, "a")) != NULL) {
fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id);
fclose(fp);
}
CreateSema((char *)"mailout");
}
free(temp);
Msg_Close();
CreateSema((char *)"mailout");
return;
}