1. 28 Jul, 2014 1 commit
    • René Scharfe's avatar
      unix-sockets: use strbuf_getcwd() · d13a0a97
      René Scharfe authored
      Instead of using a PATH_MAX-sized buffer, which can be too small on some
      file systems, use strbuf_getcwd(), which handles any path getcwd()
      returns.  Also preserve the errno set by strbuf_getcwd() instead of
      setting it to ENAMETOOLONG; that way a more appropriate error message
      can be shown based on the actual reason for failing.
      Signed-off-by: default avatarRene Scharfe <l.s.r@web.de>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  2. 21 Jul, 2014 1 commit
  3. 12 Jan, 2012 1 commit
    • Jonathan Nieder's avatar
      unix-socket: do not let close() or chdir() clobber errno during cleanup · 06121a0a
      Jonathan Nieder authored
      unix_stream_connect and unix_stream_listen return -1 on error, with
      errno set by the failing underlying call to allow the caller to write
      a useful diagnosis.
      Unfortunately the error path involves a few system calls itself, such
      as close(), that can themselves touch errno.
      This is not as worrisome as it might sound.  If close() fails, this
      just means substituting one meaningful error message for another,
      which is perfectly fine.  However, when the call _succeeds_, it is
      allowed to (and sometimes might) clobber errno along the way with some
      undefined value, so it is good higiene to save errno and restore it
      immediately before returning to the caller.  Do so.
      Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  4. 10 Jan, 2012 1 commit
    • Jeff King's avatar
      unix-socket: handle long socket pathnames · 1eb10f40
      Jeff King authored
      On many systems, the sockaddr_un.sun_path field is quite
      small. Even on Linux, it is only 108 characters. A user of
      the credential-cache daemon can easily surpass this,
      especially if their home directory is in a deep directory
      tree (since the default location expands ~/.git-credentials).
      We can hack around this in the unix-socket.[ch] code by
      doing a chdir() to the enclosing directory, feeding the
      relative basename to the socket functions, and then
      restoring the working directory.
      This introduces several new possible error cases for
      creating a socket, including an irrecoverable one in the
      case that we can't restore the working directory. In the
      case of the credential-cache code, we could perhaps get away
      with simply chdir()-ing to the socket directory and never
      coming back. However, I'd rather do it at the lower level
      for a few reasons:
        1. It keeps the hackery behind an opaque interface instead
           of polluting the main program logic.
        2. A hack in credential-cache won't help any unix-socket
           users who come along later.
        3. The chdir trickery isn't that likely to fail (basically
           it's only a problem if your cwd is missing or goes away
           while you're running).  And because we only enable the
           hack when we get a too-long name, it can only fail in
           cases that would have failed under the previous code
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  5. 12 Dec, 2011 1 commit
    • Jeff King's avatar
      credentials: add "cache" helper · e2770979
      Jeff King authored
      If you access repositories over smart-http using http
      authentication, then it can be annoying to have git ask you
      for your password repeatedly. We cache credentials in
      memory, of course, but git is composed of many small
      programs. Having to input your password for each one can be
      This patch introduces a credential helper that will cache
      passwords in memory for a short period of time.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>