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