From 0b219dd56968abc9fd9b499070adb14fbd33f5e4 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Fri, 19 Jan 2001 14:18:43 +0000 Subject: [PATCH] Greatly enhanced the log messages Petidomo writes. Made the existing messages more helpful, added lots of new ones, generally made things real perfect. Remember: Life is BEAUTIFUL. --- hermes.c | 34 ++++++++++++++++++++++++++++------ subscribe.c | 24 +++++++++++++++++------- unsubscribe.c | 30 +++++++++++++++++++----------- 3 files changed, 64 insertions(+), 24 deletions(-) diff --git a/hermes.c b/hermes.c index 00adb6a..90645a9 100644 --- a/hermes.c +++ b/hermes.c @@ -62,17 +62,17 @@ hermes_main(char * incoming_mail, const char * listname) if (MailStruct->Envelope == NULL) { - syslog(LOG_NOTICE, "Received mail without a valid envelope."); + syslog(LOG_ERR, "Received mail without a valid envelope."); return 0; } if (MailStruct->From == NULL) { - syslog(LOG_NOTICE, "Received mail without From: line."); + syslog(LOG_ERR, "Received mail without From: line."); return 0; } if (*MailStruct->Body == '\0') { - syslog(LOG_NOTICE, "Received mail with empty body."); + syslog(LOG_INFO, "Received mail with empty body."); return 0; } @@ -144,8 +144,12 @@ hermes_main(char * incoming_mail, const char * listname) else if (ListConfig->listtype == LIST_CLOSED) { /* Only subscribers may post */ + if (isSubscribed(listname, MailStruct->From, NULL, NULL, TRUE) == FALSE) { + syslog(LOG_NOTICE, "\"%s\" tried to post to closed list \"%s\", but " \ + "he is no subscriber.", MailStruct->From, listname); + fh = vOpenMailer(envelope, owner, NULL); if (fh != NULL) { @@ -174,7 +178,12 @@ hermes_main(char * incoming_mail, const char * listname) { /* Every posting needs an acknowledgement. */ - char* cookie = queue_posting(MailStruct, listname); + char* cookie; + + syslog(LOG_NOTICE, "\"%s\" tried to post to acknowledged list \"%s\"; posting " \ + "has been deferred.", MailStruct->From, listname); + + cookie = queue_posting(MailStruct, listname); fh = vOpenMailer(owner, MailStruct->Envelope, NULL); if (fh != NULL) { @@ -206,7 +215,12 @@ hermes_main(char * incoming_mail, const char * listname) if (g_is_approved) { - int rc = add_address(ListConfig->ack_file, MailStruct->From); + int rc; + + syslog(LOG_NOTICE, "\"%s\" acknowledged a former posting attempt on ack-once list \"%s\"; " \ + "add him to the ack file and let the posting pass.", MailStruct->From, listname); + + rc = add_address(ListConfig->ack_file, MailStruct->From); if (rc < 0) { syslog(LOG_ERR, "Can't add address to ack file."); @@ -225,7 +239,12 @@ hermes_main(char * incoming_mail, const char * listname) } else if (rc == 0) { - char* cookie = queue_posting(MailStruct, listname); + char* cookie; + + syslog(LOG_NOTICE, "\"%s\" tried to post to ack-once list \"%s\", but is posting " \ + "for the first time; posting has been deferred.", MailStruct->From, listname); + + cookie = queue_posting(MailStruct, listname); fh = vOpenMailer(owner, MailStruct->Envelope, NULL); if (fh != NULL) { @@ -251,6 +270,9 @@ hermes_main(char * incoming_mail, const char * listname) } return 0; } + else + syslog(LOG_NOTICE, "\"%s\" tried to post to ack-once list \"%s\" and has been found in " \ + "the ack file; letting posting pass.", MailStruct->From, listname); } } } diff --git a/subscribe.c b/subscribe.c index 14bff6d..f0aff77 100644 --- a/subscribe.c +++ b/subscribe.c @@ -72,7 +72,7 @@ AddAddress(struct Mail * MailStruct, listname = defaultlist; else { - syslog(LOG_NOTICE, "%s: subscribe-command invalid: No list specified.", MailStruct->From); + syslog(LOG_INFO, "%s: subscribe-command invalid: No list specified.", MailStruct->From); fh = vOpenMailer(envelope, originator, NULL); if (fh != NULL) { @@ -117,8 +117,8 @@ AddAddress(struct Mail * MailStruct, { /* Access was unauthorized, notify the originator. */ - syslog(LOG_INFO, "\"%s\" tried to subscribe \"%s\" to list \"%s\", but couldn't " \ - "provide the correct password.", originator, address, listname); + syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" rejected due to lack of " \ + "a correct admin password.", MailStruct->From, address, listname); fh = vOpenMailer(envelope, originator, NULL); if (fh != NULL) @@ -142,8 +142,7 @@ AddAddress(struct Mail * MailStruct, CloseMailer(fh); } else - syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", - originator); + syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); /* Notify the owner. */ @@ -180,6 +179,9 @@ AddAddress(struct Mail * MailStruct, if (isSubscribed(listname, address, NULL, NULL, FALSE) == TRUE) { + syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" rejected because the " \ + "address is already on the list.", MailStruct->From, address, listname); + /* Notify the originator, that the address is already a member. */ @@ -210,8 +212,14 @@ AddAddress(struct Mail * MailStruct, { /* Require confirmation. */ - char* command = text_easy_sprintf("subscribe %s %s", address, listname); - char* cookie = queue_command(MailStruct, command); + char* command; + char* cookie; + + syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" deferred because the " \ + "request must be acknowledged first.", MailStruct->From, address, listname); + + command = text_easy_sprintf("subscribe %s %s", address, listname); + cookie = queue_command(MailStruct, command); /* Send request for confirmation to the user. */ @@ -278,6 +286,8 @@ AddAddress(struct Mail * MailStruct, /* Okay, add the address to the list. */ + syslog(LOG_INFO, "%s: Okay; subscribing address \"%s\" to list \"%s\".", MailStruct->From, address, listname); + fh = fopen(ListConfig->address_file, "a"); if (fh == NULL) { diff --git a/unsubscribe.c b/unsubscribe.c index b706480..d9122b7 100644 --- a/unsubscribe.c +++ b/unsubscribe.c @@ -73,7 +73,7 @@ DeleteAddress(struct Mail * MailStruct, listname = defaultlist; else { - syslog(LOG_NOTICE, "%s: unsubscribe-command invalid: No list specified.", MailStruct->From); + syslog(LOG_INFO, "%s: unsubscribe-command invalid: No list specified.", MailStruct->From); fh = vOpenMailer(envelope, originator, NULL); if (fh != NULL) { @@ -118,8 +118,8 @@ DeleteAddress(struct Mail * MailStruct, { /* Access was unauthorized, notify the originator. */ - syslog(LOG_INFO, "\"%s\" tried to unsubscribe \"%s\" from list \"%s\", but " \ - "couldn't provide the correct password.", originator, address, listname); + syslog(LOG_INFO, "%s: Attempt to unsubscribe \"%s\" from list \"%s\" rejected due to lack of " \ + "a correct admin password.", MailStruct->From, address, listname); fh = vOpenMailer(envelope, originator, NULL); if (fh != NULL) @@ -134,8 +134,7 @@ DeleteAddress(struct Mail * MailStruct, fprintf(fh, "Precedence: junk\n"); fprintf(fh, "Sender: %s\n", envelope); fprintf(fh, "\n"); - buffer = text_easy_sprintf( - "The mailing list \"%s\" is a closed forum and only the maintainer may " \ + buffer = text_easy_sprintf("The mailing list \"%s\" is a closed forum and only the maintainer may " \ "unsubscribe addresses. Your request has been forwarded to the " \ "appropriate person, so please don't send any further mail. You will " \ "be notified as soon as possible.", listname); @@ -144,8 +143,7 @@ DeleteAddress(struct Mail * MailStruct, CloseMailer(fh); } else - syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", - originator); + syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); /* Notify the owner. */ @@ -159,8 +157,7 @@ DeleteAddress(struct Mail * MailStruct, fprintf(fh, "Precedence: junk\n"); fprintf(fh, "Sender: %s\n", envelope); fprintf(fh, "\n"); - buffer = text_easy_sprintf( - "\"%s\" tried to unsubscribe the address \"%s\" from the \"%s\" mailing list, " \ + buffer = text_easy_sprintf("\"%s\" tried to unsubscribe the address \"%s\" from the \"%s\" mailing list, " \ "but couldn't provide the correct password. To unsubscribe him, send the " \ "following commands to the server:", originator, address, listname); text_wordwrap(buffer, 70); @@ -182,6 +179,9 @@ DeleteAddress(struct Mail * MailStruct, if (isSubscribed(listname, address, &list, &p, FALSE) == FALSE) { + syslog(LOG_INFO, "%s: Attempt to unsubscribe \"%s\" from list \"%s\" rejected because the " \ + "address is not on the list.", MailStruct->From, address, listname); + /* Notify the originator, that the address is not subscribed at all. */ @@ -215,8 +215,14 @@ DeleteAddress(struct Mail * MailStruct, { /* Require confirmation. */ - char* command = text_easy_sprintf("unsubscribe %s %s", address, listname); - char* cookie = queue_command(MailStruct, command); + char* command; + char* cookie; + + syslog(LOG_INFO, "%s: Attempt to unsubscribe \"%s\" from list \"%s\" deferred because the " \ + "request must be acknowledged first.", MailStruct->From, address, listname); + + command = text_easy_sprintf("unsubscribe %s %s", address, listname); + cookie = queue_command(MailStruct, command); /* Send request for confirmation to the user. */ @@ -282,6 +288,8 @@ DeleteAddress(struct Mail * MailStruct, return 0; } + syslog(LOG_INFO, "%s: Okay; unsubscribing address \"%s\" from list \"%s\".", MailStruct->From, address, listname); + fh = fopen(ListConfig->address_file, "w"); if (fh == NULL) {