1diff -Naurb a/ssmtp.c b/ssmtp.c
2--- a/ssmtp.c 2009-11-23 10:55:11.000000000 +0100
3+++ b/ssmtp.c 2017-03-25 03:00:26.508283016 +0100
4@@ -57,6 +57,7 @@
5 char arpadate[ARPADATE_LENGTH];
6 char *auth_user = (char)NULL;
7 char *auth_pass = (char)NULL;
8+char *auth_passfile = (char)NULL;
9 char *auth_method = (char)NULL; /* Mechanism for SMTP authentication */
10 char *mail_domain = (char)NULL;
11 char *from = (char)NULL; /* Use this as the From: address */
12@@ -1053,6 +1054,15 @@
13 log_event(LOG_INFO, "Set AuthPass=\"%s\"\n", auth_pass);
14 }
15 }
16+ else if(strcasecmp(p, "AuthPassFile") == 0 && !auth_passfile) {
17+ if((auth_passfile = strdup(q)) == (char *)NULL) {
18+ die("parse_config() -- strdup() failed");
19+ }
20+
21+ if(log_level > 0) {
22+ log_event(LOG_INFO, "Set AuthPassFile=\"%s\"\n", auth_passfile);
23+ }
24+ }
25 else if(strcasecmp(p, "AuthMethod") == 0 && !auth_method) {
26 if((auth_method = strdup(q)) == (char *)NULL) {
27 die("parse_config() -- strdup() failed");
28@@ -1415,6 +1425,8 @@
29 struct passwd *pw;
30 int i, sock;
31 uid_t uid;
32+ FILE *fp;
33+ char pass_buf[BUF_SZ+1];
34 bool_t minus_v_save, leadingdot, linestart = True;
35 int timeout = 0;
36 int bufsize = sizeof(b)-1;
37@@ -1433,6 +1445,17 @@
38 log_event(LOG_INFO, "%s not found", config_file);
39 }
40
41+ if(auth_passfile != (char *)NULL) {
42+ if((fp = fopen(auth_passfile, "r")) == (FILE *)NULL) {
43+ die("Could not open the AuthPassFile %s", auth_passfile);
44+ }
45+ if (fgets(pass_buf, BUF_SZ, fp) == NULL) {
46+ die("Error while reading a line from the AuthPassFile %s, or it is empty", auth_passfile);
47+ }
48+ fclose(fp);
49+ auth_pass = strdup(pass_buf);
50+ }
51+
52 if((p = strtok(pw->pw_gecos, ";,"))) {
53 if((gecos = strdup(p)) == (char *)NULL) {
54 die("ssmtp() -- strdup() failed");
55diff -Naurb a/ssmtp.conf.5 b/ssmtp.conf.5
56--- a/ssmtp.conf.5 2008-02-29 03:50:15.000000000 +0100
57+++ b/ssmtp.conf.5 2017-03-25 01:45:52.890165426 +0100
58@@ -61,6 +61,11 @@
59 .Pp
60 .It Cm AuthPass
61 The password to use for SMTP AUTH.
62+It is recommended to use AuthPassFile which also takes precedence over AuthPass.
63+.Pp
64+.It Cm AuthPassFile
65+A file that should contain the password to use for SMTP AUTH.
66+This takes precedence over AuthPass.
67 .Pp
68 .It Cm AuthMethod
69 The authorization method to use.