diff options
author | 2020-12-21 11:48:38 +0000 | |
---|---|---|
committer | 2020-12-21 11:48:38 +0000 | |
commit | 024609d07fa410bbe5b3744106f66b8db3f47a73 (patch) | |
tree | ab6d6d789eef9f69301a5c4cab35a645a2abde86 | |
parent | Use NI_NUMERICSERV. We don't use the result and it's faster and is a (diff) | |
download | wireguard-openbsd-024609d07fa410bbe5b3744106f66b8db3f47a73.tar.xz wireguard-openbsd-024609d07fa410bbe5b3744106f66b8db3f47a73.zip |
The plumbing already allowed for smtp authentication, hook it up to the -a
flag.
Manpage order feedback jmc@
OK eric@
-rw-r--r-- | usr.sbin/smtpd/smtp.1 | 12 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpc.c | 30 |
2 files changed, 35 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/smtp.1 b/usr.sbin/smtpd/smtp.1 index 3cc03844ed1..f77cddb879c 100644 --- a/usr.sbin/smtpd/smtp.1 +++ b/usr.sbin/smtpd/smtp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: smtp.1,v 1.7 2018/07/04 08:23:43 jmc Exp $ +.\" $OpenBSD: smtp.1,v 1.8 2020/12/21 11:48:38 martijn Exp $ .\" .\" Copyright (c) 2018, Eric Faurot <eric@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 4 2018 $ +.Dd $Mdocdate: December 21 2020 $ .Dt SMTP 1 .Os .Sh NAME @@ -23,6 +23,7 @@ .Sh SYNOPSIS .Nm .Op Fl Chnv +.Op Fl a Ar authfile .Op Fl F Ar from .Op Fl H Ar helo .Op Fl s Ar server @@ -42,6 +43,13 @@ The content is sent unaltered as mail data. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl a Ar authfile +Perform a login before sending the message. +The username and password are read from +.Ar authfile +and need to be on the first and second line respectively. +This option requires a TLS or STARTTLS +.Ar server . .It Fl C Do not require server certificate to be valid. .It Fl F Ar from diff --git a/usr.sbin/smtpd/smtpc.c b/usr.sbin/smtpd/smtpc.c index c23375821cd..8ad9b7c1e29 100644 --- a/usr.sbin/smtpd/smtpc.c +++ b/usr.sbin/smtpd/smtpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpc.c,v 1.11 2020/09/14 18:32:11 millert Exp $ */ +/* $OpenBSD: smtpc.c,v 1.12 2020/12/21 11:48:38 martijn Exp $ */ /* * Copyright (c) 2018 Eric Faurot <eric@openbsd.org> @@ -56,9 +56,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, - "usage: %s [-Chnv] [-F from] [-H helo] [-s server] [-S name] rcpt ...\n", - __progname); + fprintf(stderr, "usage: %s [-Chnv] [-a authfile] [-F from] [-H helo] " + "[-s server] [-S name] rcpt ...\n", __progname); exit(1); } @@ -66,8 +65,12 @@ int main(int argc, char **argv) { char hostname[256]; + FILE *authfile; int ch, i; char *server = "localhost"; + char *authstr = NULL; + size_t alloc = 0; + ssize_t len; struct passwd *pw; log_init(1, 0); @@ -91,7 +94,7 @@ main(int argc, char **argv) memset(&mail, 0, sizeof(mail)); mail.from = pw->pw_name; - while ((ch = getopt(argc, argv, "CF:H:S:hns:v")) != -1) { + while ((ch = getopt(argc, argv, "CF:H:S:a:hns:v")) != -1) { switch (ch) { case 'C': params.tls_verify = 0; @@ -105,6 +108,23 @@ main(int argc, char **argv) case 'S': servname = optarg; break; + case 'a': + if ((authfile = fopen(optarg, "r")) == NULL) + fatal("%s: open", optarg); + if ((len = getline(&authstr, &alloc, authfile)) == -1) + fatal("%s: Failed to read username", optarg); + if (authstr[len - 1] == '\n') + authstr[len - 1] = '\0'; + params.auth_user = authstr; + authstr = NULL; + len = 0; + if ((len = getline(&authstr, &alloc, authfile)) == -1) + fatal("%s: Failed to read password", optarg); + if (authstr[len - 1] == '\n') + authstr[len - 1] = '\0'; + params.auth_pass = authstr; + fclose(authfile); + break; case 'h': usage(); break; |