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



commit 0a8c322ef8e0fd924fae3395f205d674c3a1590c
Author: Jehan <jehan girinstud io>
Date:   Thu Jun 2 18:17:09 2016 +0200

    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!

 configure.ac           |    6 ++++--
 plug-ins/common/mail.c |   32 +++++++++++++++++++++-----------
 2 files changed, 25 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 518b485..6e9dae2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1838,15 +1838,17 @@ have_sendmail=no
 if test "x$with_sendmail" != "x" && test "x$with_sendmail" != "xno"; then
   if test "x$with_sendmail" = "xyes"; then
       sendmail_path=$PATH:/usr/sbin:/usr/lib
+      AC_DEFINE_UNQUOTED(SENDMAIL, "",
+                         [The MTA used by the mail plug-in.])
   else
       sendmail_path=$with_sendmail
+      AC_DEFINE_UNQUOTED(SENDMAIL, "$with_sendmail",
+                         [The MTA used by the mail plug-in.])
   fi
 
   AC_PATH_PROG(SENDMAIL, sendmail, , $sendmail_path)
   if test "x$SENDMAIL" != "x"; then
     have_email="yes (sendmail)"
-    AC_DEFINE_UNQUOTED(SENDMAIL, "$SENDMAIL",
-                       [The MTA used by the mail plug-in.])
   else
     # Not having sendmail at runtime is not a blocker.
     have_email="needs runtime dependency: sendmail"
diff --git a/plug-ins/common/mail.c b/plug-ins/common/mail.c
index 65ebb51..61ce7be 100644
--- a/plug-ins/common/mail.c
+++ b/plug-ins/common/mail.c
@@ -129,17 +129,22 @@ query (void)
   /* Check if xdg-email or sendmail is installed.
    * TODO: allow setting the location of the executable in preferences.
    */
-#ifdef SENDMAIL && SENDMAIL
-  /* If a directory has been set at build time, we assume that sendmail
-   * can only be in this directory. */
-  email_bin = g_build_path (SENDMAIL, "sendmail", NULL);
-  if (! g_file_test (email_bin, G_FILE_TEST_IS_EXECUTABLE))
+#ifdef SENDMAIL
+  if (strlen (SENDMAIL) == 0)
+    {
+      email_bin = g_find_program_in_path ("sendmail");
+    }
+  else
     {
-      g_free (email_bin);
-      email_bin = NULL;
+      /* If a directory has been set at build time, we assume that sendmail
+       * can only be in this directory. */
+      email_bin = g_build_filename (SENDMAIL, "sendmail", NULL);
+      if (! g_file_test (email_bin, G_FILE_TEST_IS_EXECUTABLE))
+        {
+          g_free (email_bin);
+          email_bin = NULL;
+        }
     }
-#elif defined SENDMAIL
-  email_bin = g_find_program_in_path ("sendmail");
 #else
   email_bin = g_find_program_in_path ("xdg-email");
 #endif
@@ -364,7 +369,7 @@ send_image (const gchar *filename,
                                mail_info.filename, NULL);
   g_rename (tmpname, filepath);
 
-  mailcmd[0] = "xdg-email";
+  mailcmd[0] = g_strdup ("xdg-email");
   mailcmd[1] = "--attach";
   mailcmd[2] = filepath;
   i = 3;
@@ -398,7 +403,11 @@ send_image (const gchar *filename,
 
 #else /* SENDMAIL */
   /* 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[2] = NULL;
 
@@ -450,6 +459,7 @@ cleanup:
     g_free (filepath);
 #endif
 
+  g_free (mailcmd[0]);
   g_free (tmpname);
 
   return status;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]