From: silvio@port1024.net
To: git@vger.kernel.org
Cc: Silvio F <silvio.fricke@gmail.com>
Subject: [[PATCH v2]] git-send-email: Added the ability to query the number of smtp password questions
Date: Sun, 10 Nov 2013 12:56:53 +0100 [thread overview]
Message-ID: <1384084613-12260-2-git-send-email-silvio@port1024.net> (raw)
In-Reply-To: <1384084613-12260-1-git-send-email-silvio@port1024.net>
From: Silvio F <silvio.fricke@gmail.com>
With this patch "git-send-mail" ask a configurable number of questions to
input the smtp password. Without this patch we have only one trial.
Signed-off-by: Silvio F <silvio.fricke@gmail.com>
---
Documentation/git-send-email.txt | 4 ++++
git-send-email.perl | 32 +++++++++++++++++++++-----------
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index f0e57a5..ac993d6 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -364,6 +364,10 @@ sendemail.confirm::
one of 'always', 'never', 'cc', 'compose', or 'auto'. See '--confirm'
in the previous section for the meaning of these values.
+sendmail.askpasswordcount::
+ Number of times the smtp password can be entered before sending mail is
+ aborted. Default is 1.
+
EXAMPLE
-------
Use gmail as the smtp server
diff --git a/git-send-email.perl b/git-send-email.perl
index 3782c3b..aeb2e6d 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -203,6 +203,7 @@ my ($validate, $confirm);
my (@suppress_cc);
my ($auto_8bit_encoding);
my ($compose_encoding);
+my ($askpasswordcount) = 1;
my ($debug_net_smtp) = 0; # Net::SMTP, see send_message()
@@ -237,6 +238,7 @@ my %config_settings = (
"from" => \$sender,
"assume8bitencoding" => \$auto_8bit_encoding,
"composeencoding" => \$compose_encoding,
+ "askpasswordcount" => \$askpasswordcount
);
my %config_path_settings = (
@@ -360,6 +362,10 @@ sub read_config {
}
}
+ if ($askpasswordcount < 1) {
+ $askpasswordcount = 1;
+ }
+
if (!defined $smtp_encryption) {
my $enc = Git::config(@repo, "$prefix.smtpencryption");
if (defined $enc) {
@@ -1069,17 +1075,21 @@ sub smtp_auth_maybe {
# TODO: Authentication may fail not because credentials were
# invalid but due to other reasons, in which we should not
# reject credentials.
- $auth = Git::credential({
- 'protocol' => 'smtp',
- 'host' => smtp_host_string(),
- 'username' => $smtp_authuser,
- # if there's no password, "git credential fill" will
- # give us one, otherwise it'll just pass this one.
- 'password' => $smtp_authpass
- }, sub {
- my $cred = shift;
- return !!$smtp->auth($cred->{'username'}, $cred->{'password'});
- });
+ for my $i (1 .. $askpasswordcount) {
+ $auth = Git::credential({
+ 'protocol' => 'smtp',
+ 'host' => smtp_host_string(),
+ 'username' => $smtp_authuser,
+ # if there's no password, "git credential fill" will
+ # give us one, otherwise it'll just pass this one.
+ 'password' => $smtp_authpass
+ }, sub {
+ my $cred = shift;
+ return !!$smtp->auth($cred->{'username'}, $cred->{'password'});
+ });
+
+ last if ($auth);
+ }
return $auth;
}
--
1.8.4.2
next prev parent reply other threads:[~2013-11-10 11:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-09 10:21 [PATCH] git-send-email: Added the ability to query the number of smtp password questions silvio
2013-11-10 11:56 ` [PATCH v2] git-send-mail: ask smtp password several times silvio
2013-11-10 11:56 ` silvio [this message]
2013-11-12 17:57 ` [[PATCH v2]] git-send-email: Added the ability to query the number of smtp password questions Junio C Hamano
2013-11-12 20:38 ` Jeff King
2013-11-12 21:23 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384084613-12260-2-git-send-email-silvio@port1024.net \
--to=silvio@port1024.net \
--cc=git@vger.kernel.org \
--cc=silvio.fricke@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).