summaryrefslogtreecommitdiff
path: root/smtp.c
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@users.sourceforge.net>2004-01-13 16:50:40 +0000
committerJosé Fonseca <jrfonseca@users.sourceforge.net>2004-01-13 16:50:40 +0000
commit566c484db7a60a0bdbfc84e9b53651b42a3e3552 (patch)
tree3562b4c30ebc8e2e46978adc26e55c305cd72146 /smtp.c
parent48e245a29e60eed2e2fb9dfdebf4b8c674d7c530 (diff)
Add a 'postconnect' keyword to execute a command after closing a SMTP connection.
Diffstat (limited to 'smtp.c')
-rw-r--r--smtp.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/smtp.c b/smtp.c
index 9fe8aa1..2ca96bb 100644
--- a/smtp.c
+++ b/smtp.c
@@ -62,6 +62,12 @@ void identity_free(identity_t *identity)
if(identity->certificate_passphrase)
free(identity->certificate_passphrase);
+ if(identity->preconnect)
+ free(identity->preconnect);
+
+ if(identity->postconnect)
+ free(identity->postconnect);
+
free(identity);
}
@@ -563,6 +569,43 @@ void smtp_send(message_t *msg)
auth_destroy_context (authctx);
auth_client_exit ();
+ /* Execute post-connect command if one was specified. */
+ if (identity->postconnect)
+ {
+ int ret, exit_status;
+
+ if (verbose)
+ fprintf (stdout, "Executing post-connect command: %s\n", identity->postconnect);
+
+ ret = system (identity->postconnect);
+ exit_status = WEXITSTATUS(ret);
+
+ /* Check whether the child process caught a signal meant for us */
+ if (WIFSIGNALED(ret))
+ {
+ int sig = WTERMSIG(ret);
+
+ if (sig == SIGINT || sig == SIGQUIT)
+ {
+ fprintf (stderr, "Post-connect command received signal %d\n", sig);
+ exit (EX_SOFTWARE);
+ }
+ }
+
+ if (ret == -1)
+ {
+ fputs ("Error executing post-connect command\n", stderr);
+ exit (EX_OSERR);
+ }
+
+ if (exit_status != 0)
+ {
+ fprintf (stderr, "Post-connect command \"%s\" exited with non-zero status %d\n",
+ identity->postconnect, exit_status);
+ exit (EX_SOFTWARE);
+ }
+ }
+
return;
failure: