From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 4/7] push -s: send signed push certificate
Date: Thu, 8 Sep 2011 13:01:39 -0700 [thread overview]
Message-ID: <1315512102-19022-5-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1315512102-19022-1-git-send-email-gitster@pobox.com>
And this uses the GPG interface to sign the push certificate. The format
of the signed certificate is very similar to a signed tag, in that the
result is a concatenation of the payload, immediately followed by a
detached signature.
This places the same constraint as an annotated tag on the push
certificate payload; it has to be a text file and the final line
must not be an incomplete line.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/send-pack.c | 29 ++++++++++++-----------------
1 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 7f4778c..f715324 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -8,6 +8,7 @@
#include "send-pack.h"
#include "quote.h"
#include "transport.h"
+#include "gpg-interface.h"
static const char send_pack_usage[] =
"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
@@ -237,25 +238,18 @@ static int sideband_demux(int in, int out, void *data)
return ret;
}
-static void sign_push_certificate(struct strbuf *cert)
+/*
+ * Take the contents of cert->buf, and have the user GPG sign it, and
+ * read it back in the strbuf.
+ */
+static int sign_push_certificate(struct strbuf *cert)
{
/*
- * Here, take the contents of cert->buf, and have the user GPG
- * sign it, and read it back in the strbuf.
- *
- * You may want to append some extra info to cert before giving
- * it to GPG, possibly via a hook.
- *
- * Here we upcase them just to demonstrate that the codepath
- * is being exercised.
+ * You may want to append some extra info to cert before
+ * giving it to GPG, possibly via a hook, here.
*/
- char *cp;
- for (cp = cert->buf; *cp; cp++) {
- int ch = *cp;
- if ('a' <= ch && ch <= 'z')
- *cp = toupper(ch);
- }
- return;
+
+ return sign_buffer(cert, git_committer_info(IDENT_NO_DATE));
}
int send_pack(struct send_pack_args *args,
@@ -369,7 +363,8 @@ int send_pack(struct send_pack_args *args,
if (signed_push && cmds_sent) {
char *cp, *ep;
- sign_push_certificate(&push_cert);
+ if (sign_push_certificate(&push_cert))
+ return error(_("failed to sign push certificate"));
strbuf_reset(&req_buf);
for (cp = push_cert.buf; *cp; cp = ep) {
ep = strchrnul(cp, '\n');
--
1.7.7.rc0.188.g3793ac
next prev parent reply other threads:[~2011-09-08 22:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-08 20:01 [PATCH v2 0/7] "push -s" Junio C Hamano
2011-09-08 20:01 ` [PATCH v2 1/7] send-pack: typofix error message Junio C Hamano
2011-09-08 20:01 ` [PATCH v2 2/7] Split GPG interface into its own helper library Junio C Hamano
2011-09-08 20:01 ` [PATCH v2 3/7] push -s: skeleton Junio C Hamano
2011-09-08 20:01 ` Junio C Hamano [this message]
2011-09-08 20:01 ` [PATCH v2 5/7] push -s: receiving end Junio C Hamano
2011-09-08 20:01 ` [PATCH v2 6/7] refactor run_receive_hook() Junio C Hamano
2011-09-08 20:01 ` [PATCH v2 7/7] push -s: support pre-receive-signature hook Junio C Hamano
2011-09-09 20:41 ` [PATCH v3 0/4] Signed push Junio C Hamano
2011-09-09 20:41 ` [PATCH v3 1/4] send-pack: typofix error message Junio C Hamano
2011-09-09 20:41 ` [PATCH v3 2/4] Split GPG interface into its own helper library Junio C Hamano
2011-09-09 20:41 ` [PATCH v3 3/4] rename "match_refs()" to "match_push_refs()" Junio C Hamano
2011-09-09 20:41 ` [PATCH v3 4/4] push -s: signed push Junio C Hamano
2011-09-09 21:16 ` [PATCH v3.1 " Junio C Hamano
2011-09-10 5:19 ` [PATCH v3 0/4] Signed push Junio C Hamano
2011-09-10 15:17 ` Sverre Rabbelier
2011-09-10 16:30 ` Junio C Hamano
2011-09-10 19:22 ` Ted Ts'o
2011-09-11 1:42 ` Junio C Hamano
2011-09-11 8:53 ` Sverre Rabbelier
2011-09-11 15:51 ` Ted Ts'o
2011-09-10 20:05 ` Robin H. Johnson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315512102-19022-5-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).