1. 07 10月, 2020 1 次提交
    • Đ
      t5534: split stdout and stderr redirection · 2cd6e1d5
      Đoàn Trần Công Danh 提交于
      On atomic pushing failure with GnuPG, we expect a very specific output
      in stdout due to `--porcelain` switch.
      
      On such failure, we also write down some helpful hint into stderr
      in order to help user understand what happens and how to continue from
      those failures.
      
      On a lot of system, those hint (in stderr) will be flushed first,
      then those messages in stdout will be flushed. In such systems, the
      current test code is fine as is.
      
      However, we don't have such guarantee, (at least) there're some real
      systems that writes those stream interleaved. On such systems, we may
      see the stderr stream written in the middle of stdout stream.
      
      Let's split those stream redirection. By splitting those stream,
      the output stream will contain exactly what we want to compare,
      thus, saving us a "sed" invocation.
      
      While we're at it, change the `test_i18ncmp` to `test_cmp` because we
      will never translate those messages (because of `--porcelain`).
      Signed-off-by: NĐoàn Trần Công Danh <congdanhqx@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2cd6e1d5
  2. 20 9月, 2020 1 次提交
    • H
      send-pack: run GPG after atomic push checking · a4f324a4
      Han Xin 提交于
      The refs update commands can be sent to the server side in two different
      ways: GPG-signed or unsigned.  We should run these two operations in the
      same "Finally, tell the other end!" code block, but they are seperated
      by the "Clear the status for each ref" code block.  This will result in
      a slight performance loss, because the failed atomic push will still
      perform unnecessary preparations for shallow advertise and GPG-signed
      commands buffers, and user may have to be bothered by the (possible) GPG
      passphrase input when there is nothing to sign.
      
      Add a new test case to t5534 to ensure GPG will not be called when the
      GPG-signed atomic push fails.
      Signed-off-by: NHan Xin <hanxin.hx@alibaba-inc.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a4f324a4
  3. 20 7月, 2018 1 次提交
  4. 08 8月, 2017 2 次提交
    • M
      config: make git_{config,parse}_maybe_bool equivalent · 46667418
      Martin Ågren 提交于
      Both of these act on a string `value` which they parse as a boolean. The
      "parse"-variant was introduced as a replacement for the "config"-variant
      which for historical reasons takes an unused argument `name`. That it
      was intended as a replacement is not obvious from commit 9a549d43
      ("config.c: rename git_config_maybe_bool_text and export it as
      git_parse_maybe_bool", 2015-08-19), but that is what the background on
      the mailing list suggests [1].
      
      However, these two functions do not parse `value` in exactly the same
      way. In particular, git_config_maybe_bool accepts integers (0 for false,
      non-0 for true). This means there are two slightly different definitions
      of "maybe_bool" in the code-base, and that every time a call to
      git_config_maybe_bool is changed to use git_parse_maybe_bool, it risks
      breaking someone's workflow.
      
      Move the implementation of "config" into "parse" and make the latter a
      trivial wrapper.
      
      This also fixes the only user of git_parse_maybe_bool, `git push
      --signed=..`.
      
      [1] https://public-inbox.org/git/xmqq7fotd71o.fsf@gitster.dls.corp.google.com/Signed-off-by: NMartin Ågren <martin.agren@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      46667418
    • M
      t5334: document that git push --signed=1 does not work · c4b71a77
      Martin Ågren 提交于
      When accepting booleans as command-line or config options throughout
      Git, there are several documented synonyms for true and false.
      However, one particular user is slightly broken: `git push --signed=..`
      does not understand the integer synonyms for true and false.
      
      This is hardly wanted. The --signed option has a different notion of
      boolean than all other arguments and config options, including the
      config option corresponding to it, push.gpgSign.
      
      Add a test documenting the failure to handle --signed=1.
      Signed-off-by: NMartin Ågren <martin.agren@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c4b71a77
  5. 06 7月, 2017 1 次提交
    • J
      t5534: fix misleading grep invocation · 8722947e
      Johannes Schindelin 提交于
      It seems to be a little-known feature of `grep` (and it certainly came
      as a surprise to this here developer who believed to know the Unix tools
      pretty well) that multiple patterns can be passed in the same
      command-line argument simply by separating them by newlines. Watch, and
      learn:
      
      	$ printf '1\n2\n3\n' | grep "$(printf '1\n3\n')"
      	1
      	3
      
      That behavior also extends to patterns passed via `-e`, and it is not
      modified by passing the option `-E` (but trying this with -P issues the
      error "grep: the -P option only supports a single pattern").
      
      It seems that there are more old Unix hands who are surprised by this
      behavior, as grep invocations of the form
      
      	grep "$(git rev-parse A B) C" file
      
      were introduced in a85b377d (push: the beginning of "git push
      --signed", 2014-09-12), and later faithfully copy-edited in b9459019
      (push: heed user.signingkey for signed pushes, 2014-10-22).
      
      Please note that the output of `git rev-parse A B` separates the object
      IDs via *newlines*, not via spaces, and those newlines are preserved
      because the interpolation is enclosed in double quotes.
      
      As a consequence, these tests try to validate that the file contains
      either A's object ID, or B's object ID followed by C, or both. Clearly,
      however, what the test wanted to see is that there is a line that
      contains all of them.
      
      This is clearly unintended, and the grep invocations in question really
      match too many lines.
      
      Fix the test by avoiding the newlines in the patterns.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8722947e
  6. 10 5月, 2017 1 次提交
    • J
      receive-pack: verify push options in cert · cbaf82cc
      Jonathan Tan 提交于
      In commit f6a4e61f ("push: accept push options", 2016-07-14), send-pack
      was taught to include push options both within the signed cert (if the
      push is a signed push) and outside the signed cert; however,
      receive-pack ignores push options within the cert, only handling push
      options outside the cert.
      
      Teach receive-pack, in the case that push options are provided for a
      signed push, to verify that the push options both within the cert and
      outside the cert are consistent.
      
      This sets in stone the requirement that send-pack redundantly send its
      push options in 2 places, but I think that this is better than the
      alternatives. Sending push options only within the cert is
      backwards-incompatible with existing Git servers (which read push
      options only from outside the cert), and sending push options only
      outside the cert means that the push options are not signed for.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cbaf82cc
  7. 25 10月, 2014 1 次提交
  8. 18 9月, 2014 1 次提交
    • J
      signed push: fortify against replay attacks · b89363e4
      Junio C Hamano 提交于
      In order to prevent a valid push certificate for pushing into an
      repository from getting replayed in a different push operation, send
      a nonce string from the receive-pack process and have the signer
      include it in the push certificate.  The receiving end uses an HMAC
      hash of the path to the repository it serves and the current time
      stamp, hashed with a secret seed (the secret seed does not have to
      be per-repository but can be defined in /etc/gitconfig) to generate
      the nonce, in order to ensure that a random third party cannot forge
      a nonce that looks like it originated from it.
      
      The original nonce is exported as GIT_PUSH_CERT_NONCE for the hooks
      to examine and match against the value on the "nonce" header in the
      certificate to notice a replay, but returned "nonce" header in the
      push certificate is examined by receive-pack and the result is
      exported as GIT_PUSH_CERT_NONCE_STATUS, whose value would be "OK"
      if the nonce recorded in the certificate matches what we expect, so
      that the hooks can more easily check.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b89363e4
  9. 16 9月, 2014 3 次提交
    • J
      send-pack: send feature request on push-cert packet · 20a7558f
      Junio C Hamano 提交于
      We would want to update the interim protocol so that we do not send
      the usual update commands when the push certificate feature is in
      use, as the same information is in the certificate.  Once that
      happens, the push-cert packet may become the only protocol command,
      but then there is no packet to put the feature request behind, like
      we always did.
      
      As we have prepared the receiving end that understands the push-cert
      feature to accept the feature request on the first protocol packet
      (other than "shallow ", which was an unfortunate historical mistake
      that has to come before everything else), we can give the feature
      request on the push-cert packet instead of the first update protocol
      packet, in preparation for the next step to actually update to the
      final protocol.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      20a7558f
    • J
      receive-pack: GPG-validate push certificates · d05b9618
      Junio C Hamano 提交于
      Reusing the GPG signature check helpers we already have, verify
      the signature in receive-pack and give the results to the hooks
      via GIT_PUSH_CERT_{SIGNER,KEY,STATUS} environment variables.
      
      Policy decisions, such as accepting or rejecting a good signature by
      a key that is not fully trusted, is left to the hook and kept
      outside of the core.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d05b9618
    • J
      push: the beginning of "git push --signed" · a85b377d
      Junio C Hamano 提交于
      While signed tags and commits assert that the objects thusly signed
      came from you, who signed these objects, there is not a good way to
      assert that you wanted to have a particular object at the tip of a
      particular branch.  My signing v2.0.1 tag only means I want to call
      the version v2.0.1, and it does not mean I want to push it out to my
      'master' branch---it is likely that I only want it in 'maint', so
      the signature on the object alone is insufficient.
      
      The only assurance to you that 'maint' points at what I wanted to
      place there comes from your trust on the hosting site and my
      authentication with it, which cannot easily audited later.
      
      Introduce a mechanism that allows you to sign a "push certificate"
      (for the lack of better name) every time you push, asserting that
      what object you are pushing to update which ref that used to point
      at what other object.  Think of it as a cryptographic protection for
      ref updates, similar to signed tags/commits but working on an
      orthogonal axis.
      
      The basic flow based on this mechanism goes like this:
      
       1. You push out your work with "git push --signed".
      
       2. The sending side learns where the remote refs are as usual,
          together with what protocol extension the receiving end
          supports.  If the receiving end does not advertise the protocol
          extension "push-cert", an attempt to "git push --signed" fails.
      
          Otherwise, a text file, that looks like the following, is
          prepared in core:
      
      	certificate version 0.1
      	pusher Junio C Hamano <gitster@pobox.com> 1315427886 -0700
      
      	7339ca65... 21580ecb... refs/heads/master
      	3793ac56... 12850bec... refs/heads/next
      
          The file begins with a few header lines, which may grow as we
          gain more experience.  The 'pusher' header records the name of
          the signer (the value of user.signingkey configuration variable,
          falling back to GIT_COMMITTER_{NAME|EMAIL}) and the time of the
          certificate generation.  After the header, a blank line follows,
          followed by a copy of the protocol message lines.
      
          Each line shows the old and the new object name at the tip of
          the ref this push tries to update, in the way identical to how
          the underlying "git push" protocol exchange tells the ref
          updates to the receiving end (by recording the "old" object
          name, the push certificate also protects against replaying).  It
          is expected that new command packet types other than the
          old-new-refname kind will be included in push certificate in the
          same way as would appear in the plain vanilla command packets in
          unsigned pushes.
      
          The user then is asked to sign this push certificate using GPG,
          formatted in a way similar to how signed tag objects are signed,
          and the result is sent to the other side (i.e. receive-pack).
      
          In the protocol exchange, this step comes immediately before the
          sender tells what the result of the push should be, which in
          turn comes before it sends the pack data.
      
       3. When the receiving end sees a push certificate, the certificate
          is written out as a blob.  The pre-receive hook can learn about
          the certificate by checking GIT_PUSH_CERT environment variable,
          which, if present, tells the object name of this blob, and make
          the decision to allow or reject this push.  Additionally, the
          post-receive hook can also look at the certificate, which may be
          a good place to log all the received certificates for later
          audits.
      
      Because a push certificate carry the same information as the usual
      command packets in the protocol exchange, we can omit the latter
      when a push certificate is in use and reduce the protocol overhead.
      This however is not included in this patch to make it easier to
      review (in other words, the series at this step should never be
      released without the remainder of the series, as it implements an
      interim protocol that will be incompatible with the final one).
      As such, the documentation update for the protocol is left out of
      this step.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a85b377d