I've found that msmtp crashes when '--passwordeval' parameter is used.  This is
due to the parameters argument being set as "optional" in msmtp.c. Only one 
value to
change to fix it.

Besides, there is sadly no '--password' parameter available. This is useful for
using msmtp from an external program such as mutt, while not saving the password
in any clear file. So I added support for the '--password' parameter.  Quite
simple in fact, and seems to work pretty well.

You'll find the whole patch attached.

Cheers

Pierre
diff -aur msmtp-1.4.28/src/msmtp.c msmtp-1.4.28-patch/src/msmtp.c
--- msmtp-1.4.28/src/msmtp.c    2012-05-01 16:58:26.000000000 +0100
+++ msmtp-1.4.28-patch/src/msmtp.c      2012-07-02 13:49:11.002259302 +0100
@@ -2457,27 +2457,28 @@
 #define LONGONLYOPT_TIMEOUT                     4
 #define LONGONLYOPT_AUTH                        5
 #define LONGONLYOPT_USER                        6
-#define LONGONLYOPT_PASSWORDEVAL                7
-#define LONGONLYOPT_TLS                         8
-#define LONGONLYOPT_TLS_STARTTLS                9
-#define LONGONLYOPT_TLS_TRUST_FILE              10
-#define LONGONLYOPT_TLS_CRL_FILE                11
-#define LONGONLYOPT_TLS_FINGERPRINT             12
-#define LONGONLYOPT_TLS_KEY_FILE                13
-#define LONGONLYOPT_TLS_CERT_FILE               14
-#define LONGONLYOPT_TLS_CERTCHECK               15
-#define LONGONLYOPT_TLS_FORCE_SSLV3             16
-#define LONGONLYOPT_TLS_MIN_DH_PRIME_BITS       17
-#define LONGONLYOPT_TLS_PRIORITIES              18
-#define LONGONLYOPT_PROTOCOL                    19
-#define LONGONLYOPT_DOMAIN                      20
-#define LONGONLYOPT_KEEPBCC                     21
-#define LONGONLYOPT_RMQS                        22
-#define LONGONLYOPT_SYSLOG                      23
-#define LONGONLYOPT_MAILDOMAIN                  24
-#define LONGONLYOPT_AUTO_FROM                   25
-#define LONGONLYOPT_READ_ENVELOPE_FROM          26
-#define LONGONLYOPT_ALIASES                     27
+#define LONGONLYOPT_PASSWORD                    7
+#define LONGONLYOPT_PASSWORDEVAL                8
+#define LONGONLYOPT_TLS                         9
+#define LONGONLYOPT_TLS_STARTTLS                10
+#define LONGONLYOPT_TLS_TRUST_FILE              11
+#define LONGONLYOPT_TLS_CRL_FILE                12
+#define LONGONLYOPT_TLS_FINGERPRINT             13
+#define LONGONLYOPT_TLS_KEY_FILE                14
+#define LONGONLYOPT_TLS_CERT_FILE               15
+#define LONGONLYOPT_TLS_CERTCHECK               16
+#define LONGONLYOPT_TLS_FORCE_SSLV3             17
+#define LONGONLYOPT_TLS_MIN_DH_PRIME_BITS       18
+#define LONGONLYOPT_TLS_PRIORITIES              19
+#define LONGONLYOPT_PROTOCOL                    20
+#define LONGONLYOPT_DOMAIN                      21
+#define LONGONLYOPT_KEEPBCC                     22
+#define LONGONLYOPT_RMQS                        23
+#define LONGONLYOPT_SYSLOG                      24
+#define LONGONLYOPT_MAILDOMAIN                  25
+#define LONGONLYOPT_AUTO_FROM                   26
+#define LONGONLYOPT_READ_ENVELOPE_FROM          27
+#define LONGONLYOPT_ALIASES                     28
 
 int msmtp_cmdline(msmtp_cmdline_conf_t *conf, int argc, char *argv[])
 {
@@ -2504,7 +2505,8 @@
             LONGONLYOPT_MAILDOMAIN },
         { "auth",                  optional_argument, 0, LONGONLYOPT_AUTH },
         { "user",                  required_argument, 0, LONGONLYOPT_USER },
-        { "passwordeval",          optional_argument, 0, 
LONGONLYOPT_PASSWORDEVAL },
+        { "passwordeval",          required_argument, 0, 
LONGONLYOPT_PASSWORDEVAL },
+        { "password",              required_argument, 0, LONGONLYOPT_PASSWORD 
},
         { "tls",                   optional_argument, 0, LONGONLYOPT_TLS },
         { "tls-starttls",          optional_argument, 0,
             LONGONLYOPT_TLS_STARTTLS },
@@ -2781,6 +2783,13 @@
                 conf->cmdline_account->mask |= ACC_USERNAME;
                 break;
 
+            case LONGONLYOPT_PASSWORD:
+                free(conf->cmdline_account->password);
+                conf->cmdline_account->password =
+                    (*optarg == '\0') ? NULL : xstrdup(optarg);
+                conf->cmdline_account->mask |= ACC_PASSWORD;
+                break;
+
             case LONGONLYOPT_PASSWORDEVAL:
                 free(conf->cmdline_account->passwordeval);
                 conf->cmdline_account->passwordeval =
@@ -3725,6 +3734,7 @@
             goto exit;
         }
     }
+
     if (account->port == 0)
     {
         if (account->protocol == SMTP_PROTO_SMTP)
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
msmtp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/msmtp-users

Reply via email to