plug-ins: if --with-sendmail is set with a value, use it. (2)

I should always test my patches thoroughly! Commit 912fcec was not
working as planned. This is!
This commit is contained in:
Jehan 2016-06-02 18:17:09 +02:00
parent 8bd53dc09f
commit 0a8c322ef8
2 changed files with 25 additions and 13 deletions

View file

@ -1838,15 +1838,17 @@ have_sendmail=no
if test "x$with_sendmail" != "x" && test "x$with_sendmail" != "xno"; then if test "x$with_sendmail" != "x" && test "x$with_sendmail" != "xno"; then
if test "x$with_sendmail" = "xyes"; then if test "x$with_sendmail" = "xyes"; then
sendmail_path=$PATH:/usr/sbin:/usr/lib sendmail_path=$PATH:/usr/sbin:/usr/lib
AC_DEFINE_UNQUOTED(SENDMAIL, "",
[The MTA used by the mail plug-in.])
else else
sendmail_path=$with_sendmail sendmail_path=$with_sendmail
AC_DEFINE_UNQUOTED(SENDMAIL, "$with_sendmail",
[The MTA used by the mail plug-in.])
fi fi
AC_PATH_PROG(SENDMAIL, sendmail, , $sendmail_path) AC_PATH_PROG(SENDMAIL, sendmail, , $sendmail_path)
if test "x$SENDMAIL" != "x"; then if test "x$SENDMAIL" != "x"; then
have_email="yes (sendmail)" have_email="yes (sendmail)"
AC_DEFINE_UNQUOTED(SENDMAIL, "$SENDMAIL",
[The MTA used by the mail plug-in.])
else else
# Not having sendmail at runtime is not a blocker. # Not having sendmail at runtime is not a blocker.
have_email="needs runtime dependency: sendmail" have_email="needs runtime dependency: sendmail"

View file

@ -129,17 +129,22 @@ query (void)
/* Check if xdg-email or sendmail is installed. /* Check if xdg-email or sendmail is installed.
* TODO: allow setting the location of the executable in preferences. * TODO: allow setting the location of the executable in preferences.
*/ */
#ifdef SENDMAIL && SENDMAIL #ifdef SENDMAIL
if (strlen (SENDMAIL) == 0)
{
email_bin = g_find_program_in_path ("sendmail");
}
else
{
/* If a directory has been set at build time, we assume that sendmail /* If a directory has been set at build time, we assume that sendmail
* can only be in this directory. */ * can only be in this directory. */
email_bin = g_build_path (SENDMAIL, "sendmail", NULL); email_bin = g_build_filename (SENDMAIL, "sendmail", NULL);
if (! g_file_test (email_bin, G_FILE_TEST_IS_EXECUTABLE)) if (! g_file_test (email_bin, G_FILE_TEST_IS_EXECUTABLE))
{ {
g_free (email_bin); g_free (email_bin);
email_bin = NULL; email_bin = NULL;
} }
#elif defined SENDMAIL }
email_bin = g_find_program_in_path ("sendmail");
#else #else
email_bin = g_find_program_in_path ("xdg-email"); email_bin = g_find_program_in_path ("xdg-email");
#endif #endif
@ -364,7 +369,7 @@ send_image (const gchar *filename,
mail_info.filename, NULL); mail_info.filename, NULL);
g_rename (tmpname, filepath); g_rename (tmpname, filepath);
mailcmd[0] = "xdg-email"; mailcmd[0] = g_strdup ("xdg-email");
mailcmd[1] = "--attach"; mailcmd[1] = "--attach";
mailcmd[2] = filepath; mailcmd[2] = filepath;
i = 3; i = 3;
@ -398,7 +403,11 @@ send_image (const gchar *filename,
#else /* SENDMAIL */ #else /* SENDMAIL */
/* construct the "sendmail user@location" line */ /* construct the "sendmail user@location" line */
mailcmd[0] = "sendmail"; if (strlen (SENDMAIL) == 0)
mailcmd[0] = g_strdup ("sendmail");
else
mailcmd[0] = g_build_filename (SENDMAIL, "sendmail", NULL);
mailcmd[1] = mail_info.receipt; mailcmd[1] = mail_info.receipt;
mailcmd[2] = NULL; mailcmd[2] = NULL;
@ -450,6 +459,7 @@ cleanup:
g_free (filepath); g_free (filepath);
#endif #endif
g_free (mailcmd[0]);
g_free (tmpname); g_free (tmpname);
return status; return status;