send-email: explicitly disable authentication

It can be necessary to disable SMTP authentication by a mechanism other than sendemail.smtpuser being undefined. For example, if the user has sendemail.smtpuser set globally but wants to disable authentication locally in one repository. --smtp-auth and sendemail.smtpauth now understand the value 'none' which means to disable authentication completely, even if an authentication user is specified. The value 'none' is lower case to avoid conflicts with any RFC 4422 authentication mechanisms. The user may also specify the command line argument --no-smtp-auth as a shorthand for --smtp-auth=none Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Joshua Watt committed Oct 22, 2018 at 22:24 UTC 8dd9b3f85a1806ab2aaf0fc4bf20fa17d499a0b0
2 files changed +12 -3
Documentation/git-send-email.txt
+6 -1
@@ -190,7 +190,9 @@ $ git send-email --smtp-auth="PLAIN LOGIN GSSAPI" ...
190 If at least one of the specified mechanisms matches the ones advertised by the
191 SMTP server and if it is supported by the utilized SASL library, the mechanism
192 is used for authentication. If neither 'sendemail.smtpAuth' nor `--smtp-auth`
193 -is specified, all mechanisms supported by the SASL library can be used.
193 +is specified, all mechanisms supported by the SASL library can be used. The
194 +special value 'none' maybe specified to completely disable authentication
195 +independently of `--smtp-user`
196
197 --smtp-pass[=<password>]::
198 Password for SMTP-AUTH. The argument is optional: If no
@@ -204,6 +206,9 @@ or on the command line. If a username has been specified (with
206 specified (with `--smtp-pass` or `sendemail.smtpPass`), then
207 a password is obtained using 'git-credential'.
208
209 +--no-smtp-auth::
210 + Disable SMTP authentication. Short hand for `--smtp-auth=none`
211 +
212 --smtp-server=<host>::
213 If set, specifies the outgoing SMTP server to use (e.g.
214 `smtp.example.com` or a raw IP address). Alternatively it can
git-send-email.perl
+6 -2
@@ -82,8 +82,11 @@ git send-email --dump-aliases
82 Pass an empty string to disable certificate
83 verification.
84 --smtp-domain <str> * The domain name sent to HELO/EHLO handshake
85 - --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms.
85 + --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms, or
86 + "none" to disable authentication.
87 This setting forces to use one of the listed mechanisms.
88 + --no-smtp-auth Disable SMTP authentication. Shorthand for
89 + `--smtp-auth=none`
90 --smtp-debug <0|1> * Disable, enable Net::SMTP debug.
91
92 --batch-size <int> * send max <int> message per connection.
@@ -341,6 +344,7 @@ $rc = GetOptions(
344 "smtp-debug:i" => \$debug_net_smtp,
345 "smtp-domain:s" => \$smtp_domain,
346 "smtp-auth=s" => \$smtp_auth,
347 + "no-smtp-auth" => sub {$smtp_auth = 'none'},
348 "identity=s" => \$identity,
349 "annotate!" => \$annotate,
350 "no-annotate" => sub {$annotate = 0},
@@ -1241,7 +1245,7 @@ sub smtp_host_string {
1245 # (smtp_user was not specified), and 0 otherwise.
1246
1247 sub smtp_auth_maybe {
1244 - if (!defined $smtp_authuser || $auth) {
1248 + if (!defined $smtp_authuser || $auth || (defined $smtp_auth && $smtp_auth eq "none")) {
1249 return 1;
1250 }
1251