aboutsummaryrefslogtreecommitdiff
path: root/connect.c
Commit message (Collapse)AuthorAge
* Merge branch 'hv/remote-end-hung-up'Junio C Hamano2012-07-04
|\ | | | | | | | | | | | | | | | | | | | | | | When we get disconnected while expecting a response from the remote side because authentication failed, we issued an error message "The remote side hung up unexpectedly." Give hint that it may be a permission problem in the message when we can reasonably suspect it. * hv/remote-end-hung-up: remove the impression of unexpectedness when access is denied
| * remove the impression of unexpectedness when access is deniedHeiko Voigt2012-06-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a server accessed through ssh is denying access git will currently issue the message "fatal: The remote end hung up unexpectedly" as the last line. This sounds as if something really ugly just happened. Since this is a quite typical situation in which users regularly get we do not say that if it happens at the beginning when reading the remote heads. If its in the very first beginning of reading the remote heads it is very likely an authentication error or a missing repository. If it happens later during reading the remote heads we still indicate that it happened during this initial contact phase. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | git: Wrong parsing of ssh urls with IPv6 literals ignores portRené Scharfe2012-06-13
| | | | | | | | | | | | | | | | | | | | | | | | If we encounter an address part shaped like "[HOST]:PORT", we skip the opening bracket and replace the closing one with a NUL. The variable host then points to HOST and we've cut off the PORT part. Thus, when we go looking for it using host a bit later, we can't find it. Start at end instead, which either points to the colon, if present, or is equal to host. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | server_supports(): parse feature list more carefullyJunio C Hamano2012-01-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have been carefully choosing feature names used in the protocol extensions so that the vocabulary does not contain a word that is a substring of another word, so it is not a real problem, but we have recently added "quiet" feature word, which would mean we cannot later add some other word with "quiet" (e.g. "quiet-push"), which is awkward. Let's make sure that we can eventually be able to do so by teaching the clients and servers that feature words consist of non whitespace letters. This parser also allows us to later add features with parameters e.g. "feature=1.5" (parameter values need to be quoted for whitespaces, but we will worry about the detauls when we do introduce them). Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jk/git-prompt'Junio C Hamano2011-12-22
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * jk/git-prompt: contrib: add credential helper for OS X Keychain Makefile: OS X has /dev/tty Makefile: linux has /dev/tty credential: use git_prompt instead of git_getpass prompt: use git_terminal_prompt add generic terminal prompt function refactor git_getpass into generic prompt function move git_getpass to its own source file imap-send: don't check return value of git_getpass imap-send: avoid buffer overflow Conflicts: Makefile
| * | move git_getpass to its own source fileJeff King2011-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is currently in connect.c, but really has nothing to do with the git protocol itself. Let's make a new source file all about prompting the user, which will make it cleaner to refactor. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'ew/keepalive'Junio C Hamano2011-12-19
|\ \ \ | | | | | | | | | | | | | | | | * ew/keepalive: enable SO_KEEPALIVE for connected TCP sockets
| * | | enable SO_KEEPALIVE for connected TCP socketsEric Wong2011-12-05
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sockets may never receive notification of some link errors, causing "git fetch" or similar processes to hang forever. Enabling keepalive messages allows hung processes to error out after a few minutes/hours depending on the keepalive settings of the system. This is a problem noticed when running non-interactive cronjobs to mirror repositories using "git fetch". Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | Merge branch 'dz/connect-error-report' into maintJunio C Hamano2011-09-11
| |\ \ | | | | | | | | | | | | | | | | * dz/connect-error-report: Do not log unless all connect() attempts fail
* | | | connect.c: drop path_match functionJeff King2011-12-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function was used for comparing local and remote ref names during fetch (which makes it a candidate for "most confusingly named function of the year"). It no longer has any callers, so let's get rid of it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | drop "match" parameter from get_remote_headsJeff King2011-12-13
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The get_remote_heads function reads the list of remote refs during git protocol session. It dates all the way back to def88e9 (Commit first cut at "git-fetch-pack", 2005-07-04). At that time, the idea was to come up with a list of refs we were interested in, and then filter the list as we got it from the remote side. Later, 1baaae5 (Make maximal use of the remote refs, 2005-10-28) stopped filtering at the get_remote_heads layer, letting us use the non-matching refs to find common history. As a result, all callers now simply pass an empty match list (and any future callers will want to do the same). So let's drop these now-useless parameters. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Change check_ref_format() to take a flags argumentMichael Haggerty2011-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change check_ref_format() to take a flags argument that indicates what is acceptable in the reference name (analogous to "git check-ref-format"'s "--allow-onelevel" and "--refspec-pattern"). This is more convenient for callers and also fixes a failure in the test suite (and likely elsewhere in the code) by enabling "onelevel" and "refspec-pattern" to be allowed independently of each other. Also rename check_ref_format() to check_refname_format() to make it obvious that it deals with refnames rather than references themselves. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | connect: only log if all attempts failed (ipv4)Erik Faye-Lund2011-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 63a995b (Do not log unless all connect() attempts fail), a mechanism to only log connection errors if all attempts failed was introduced for the IPv6 code-path, but not for the IPv4 one. Introduce a matching mechanism so IPv4-users also benefit from this noise-reduction. Move the call to socket after filling in sa, to make it more apparent that errno can't change in between. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'maint' into ef/ipv4-connect-error-reportJunio C Hamano2011-08-01
|\ \ \ | |/ / | | / | |/ |/| * maint: connect: correctly number ipv6 network adapter
| * connect: correctly number ipv6 network adapterErik Faye-Lund2011-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | In ba50532, the variable 'cnt' was added to both the IPv6 and the IPv4 version of git_tcp_connect_sock, intended to identify which network adapter the connection failed on. But in the IPv6 version, the variable was never increased, leaving it constantly at zero. This behaviour isn't very useful, so let's fix it by increasing the variable at every loop-iteration. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Do not log unless all connect() attempts failDave Zarzycki2011-07-14
|/ | | | | | | | | IPv6 hosts are often unreachable on the primarily IPv4 Internet and therefore we shouldn't print an error if there are still other hosts we can try to connect() to. This helps "git fetch --quiet" stay quiet. Signed-off-by: Dave Zarzycki <zarzycki@apple.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jk/git-connection-deadlock-fix'Junio C Hamano2011-05-19
|\ | | | | | | | | | | | | | | | | | | | | * jk/git-connection-deadlock-fix: test core.gitproxy configuration send-pack: avoid deadlock on git:// push with failed pack-objects connect: let callers know if connection is a socket connect: treat generic proxy processes like ssh processes Conflicts: connect.c
| * connect: let callers know if connection is a socketJeff King2011-05-16
| | | | | | | | | | | | | | | | | | | | | | | | They might care because they want to do a half-duplex close. With pipes, that means simply closing the output descriptor; with a socket, you must actually call shutdown. Instead of exposing the magic no_fork child_process struct, let's encapsulate the test in a function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * connect: treat generic proxy processes like ssh processesJeff King2011-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The git_connect function returns two ends of a pipe for talking with a remote, plus a struct child_process representing the other end of the pipe. If we have a direct socket connection, then this points to a special "no_fork" child process. The code path for doing git-over-pipes or git-over-ssh sets up this child process to point to the child git command or the ssh process. When we call finish_connect eventually, we check wait() on the command and report its return value. The code path for git://, on the other hand, always sets it to no_fork. In the case of a direct TCP connection, this makes sense; we have no child process. But in the case of a proxy command (configured by core.gitproxy), we do have a child process, but we throw away its pid, and therefore ignore its return code. Instead, let's keep that information in the proxy case, and respect its return code, which can help catch some errors (though depending on your proxy command, it will be errors reported by the proxy command itself, and not propagated from git commands. Still, it is probably better to propagate such errors than to ignore them). It also means that the child_process field can reliably be used to determine whether the returned descriptors are actually a full-duplex socket, which means we should be using shutdown() instead of a simple close. Signed-off-by: Jeff King <peff@peff.net> Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Make sure that git_getpass() never returns NULLJohannes Schindelin2010-09-30
| | | | | | | | | | | | | | | | | | The result of git_getpass() is used without checking for NULL, so let's just die() instead of returning NULL. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Allow core.askpass to override SSH_ASKPASS.Knut Franke2010-08-31
| | | | | | | | | | | | | | | | Modify handling of the 'core.askpass' option so that it has the same effect as GIT_ASKPASS also if SSH_ASKPASS is set. Signed-off-by: Knut Franke <k.franke@science-computing.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Add a new option 'core.askpass'.Anselm Kruis2010-08-31
| | | | | | | | | | | | | | | | Setting this option has the same effect as setting the environment variable 'GIT_ASKPASS'. Signed-off-by: Knut Franke <k.franke@science-computing.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'gv/portable'Junio C Hamano2010-06-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gv/portable: test-lib: use DIFF definition from GIT-BUILD-OPTIONS build: propagate $DIFF to scripts Makefile: Tru64 portability fix Makefile: HP-UX 10.20 portability fixes Makefile: HPUX11 portability fixes Makefile: SunOS 5.6 portability fix inline declaration does not work on AIX Allow disabling "inline" Some platforms lack socklen_t type Make NO_{INET_NTOP,INET_PTON} configured independently Makefile: some platforms do not have hstrerror anywhere git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition test_cmp: do not use "diff -u" on platforms that lack one fixup: do not unconditionally disable "diff -u" tests: use "test_cmp", not "diff", when verifying the result Do not use "diff" found on PATH while building and installing enums: omit trailing comma for portability Makefile: -lpthread may still be necessary when libc has only pthread stubs Rewrite dynamic structure initializations to runtime assignment Makefile: pass CPPFLAGS through to fllow customization Conflicts: Makefile wt-status.h
| * | enums: omit trailing comma for portabilityGary V. Vaughan2010-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX 5.1 fails to compile git. enum style is inconsistent already, with some enums declared on one line, some over 3 lines with the enum values all on the middle line, sometimes with 1 enum value per line... and independently of that the trailing comma is sometimes present and other times absent, often mixing with/without trailing comma styles in a single file, and sometimes in consecutive enum declarations. Clearly, omitting the comma is the more portable style, and this patch changes all enum declarations to use the portable omitted dangling comma style consistently. Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | decode file:// and ssh:// URLsJeff King2010-05-24
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | We generally treat these as equivalent to "/path/to/repo" and "host:path_to_repo" respectively. However, they are URLs and as such may be percent-encoded. The current code simply uses them as-is without any decoding. With this patch, we will now percent-decode any file:// or ssh:// url (or ssh+git, git+ssh, etc) at the transport layer. We continue to treat plain paths and "host:path" syntax literally. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'fl/askpass'Junio C Hamano2010-03-20
|\ \ | | | | | | | | | | | | | | | * fl/askpass: git-core: Support retrieving passwords with GIT_ASKPASS git-svn: Support retrieving passwords with GIT_ASKPASS
| * | git-core: Support retrieving passwords with GIT_ASKPASSFrank Li2010-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git tries to read a password from the terminal in imap-send and when talking to a http server that requires authentication. When a GUI is driving git, however, the end user is not paying attention to the terminal (there may not even be a terminal). GUI would appear to hang forever. Fix this problem by allowing a password-retrieving command to be specified in GIT_ASKPASS Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'gb/maint-submodule-env'Junio C Hamano2010-03-07
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gb/maint-submodule-env: is_submodule_modified(): clear environment properly submodules: ensure clean environment when operating in a submodule shell setup: clear_local_git_env() function rev-parse: --local-env-vars option Refactor list of of repo-local env vars
| * | | Refactor list of of repo-local env varsGiuseppe Bilotta2010-02-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the list of GIT_* environment variables that are local to a repository into a static list in environment.c, as it is also useful elsewhere. Also add the missing GIT_CONFIG variable to the list. Make it easy to use the list both by NULL-termination and by size; the latter (excluding the terminating NULL) is stored in the local_repo_env_size define. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'ml/connect-refactor'Junio C Hamano2010-03-02
|\ \ \ \ | |_|/ / |/| | | | | | | | | | | * ml/connect-refactor: connect.c: move duplicated code to a new function 'get_host_and_port'
| * | | connect.c: move duplicated code to a new function 'get_host_and_port'Michael Lukashov2010-02-17
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following functions: git_tcp_connect_sock (IPV6 version) git_tcp_connect_sock (no IPV6 version), git_proxy_connect have common block of code. Move it to a new function 'get_host_and_port' Signed-off-by: Michael Lukashov <michael.lukashov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Typofixes outside documentation areaJunio C Hamano2010-02-03
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | begining -> beginning canonicalizations -> canonicalization comand -> command dewrapping -> unwrapping dirtyness -> dirtiness DISCLAMER -> DISCLAIMER explicitely -> explicitly feeded -> fed impiled -> implied madatory -> mandatory mimick -> mimic preceeding -> preceding reqeuest -> request substition -> substitution Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'il/maint-colon-address'Junio C Hamano2010-01-27
|\ \ | | | | | | | | | | | | | | | * il/maint-colon-address: Allow use of []-wrapped addresses in git:// Support addresses with ':' in git-daemon
| * | Allow use of []-wrapped addresses in git://Ilari Liusvaara2010-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow using "["<host>"]":<port> and "["<host>"]" notations in git:// host addresses. This is needed to be able to connect to addresses that contain ':' (e.g. numeric IPv6 addresses). Also send the host header []-wrapped so it can actually be parsed by remote end. Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | git_connect: use use_shell instead of explicit "sh", "-c"Johannes Sixt2010-01-25
| |/ |/| | | | | | | | | | | | | This is a followup to ac0ba18 (run-command: convert simple callsites to use_shell, 2009-12-30), for consistency. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'cc/replace'Junio C Hamano2009-11-23
|\ \ | | | | | | | | | | | | | | | | | | * cc/replace: Documentation: talk a little bit about GIT_NO_REPLACE_OBJECTS Documentation: fix typos and spelling in replace documentation replace: use a GIT_NO_REPLACE_OBJECTS env variable
| * | replace: use a GIT_NO_REPLACE_OBJECTS env variableChristian Couder2009-11-20
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | This has the same effect as --no-replace-objects option; git ignores the replace refs. When --no-replace-objects option is passed to git, this environment variable is set to "1" and exported to subprocesses in order to propagate the same setting. It is useful for example for scripts, as the git commands used in them can now be aware that they must not read replace refs. Tested-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Move "get_ack()" back to fetch-packShawn O. Pearce2009-10-30
|/ | | | | | | | | | | | In 41cb7488 Linus moved this function to connect.c for reuse inside of the git-clone-pack command. That was 2005, but in 2006 Junio retired git-clone-pack in commit efc7fa53. Since then the only caller has been fetch-pack. Since this ACK/NAK exchange is only used by the fetch-pack/upload-pack protocol we should move it back to be a private detail of fetch-pack. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Style fixes, add a space after if/for/while.Brian Gianforcaro2009-08-31
| | | | | | | | | The majority of code in core git appears to use a single space after if/for/while. This is an attempt to bring more code to this standard. These are entirely cosmetic changes. Signed-off-by: Brian Gianforcaro <b.gianfo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix various sparse warnings in the git source codeLinus Torvalds2009-06-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a few remaining ones, but this fixes the trivial ones. It boils down to two main issues that sparse complains about: - warning: Using plain integer as NULL pointer Sparse doesn't like you using '0' instead of 'NULL'. For various good reasons, not the least of which is just the visual confusion. A NULL pointer is not an integer, and that whole "0 works as NULL" is a historical accident and not very pretty. A few of these remain: zlib is a total mess, and Z_NULL is just a 0. I didn't touch those. - warning: symbol 'xyz' was not declared. Should it be static? Sparse wants to see declarations for any functions you export. A lack of a declaration tends to mean that you should either add one, or you should mark the function 'static' to show that it's in file scope. A few of these remain: I only did the ones that should obviously just be made static. That 'wt_status_submodule_summary' one is debatable. It has a few related flags (like 'wt_status_use_color') which _are_ declared, and are used by builtin-commit.c. So maybe we'd like to export it at some point, but it's not declared now, and not used outside of that file, so 'static' it is in this patch. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'sp/msysgit'Junio C Hamano2009-06-13
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * sp/msysgit: compat/ has subdirectories: do not omit them in 'make clean' Fix typo in nedmalloc warning fix MinGW: Teach Makefile to detect msysgit and apply specific settings Fix warnings in nedmalloc when compiling with GCC 4.4.0 Add custom memory allocator to MinGW and MacOS builds MinGW readdir reimplementation to support d_type connect.c: Support PuTTY plink and TortoisePlink as SSH on Windows git: browsing paths with spaces when using the start command MinGW: fix warning about implicit declaration of _getch() test-chmtime: work around Windows limitation Work around a regression in Windows 7, causing erase_in_line() to crash sometimes Quiet make: do not leave Windows behind MinGW: GCC >= 4 does not need SNPRINTF_SIZE_CORR anymore Conflicts: Makefile
| * connect.c: Support PuTTY plink and TortoisePlink as SSH on WindowsEdward Z. Yang2009-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenSSH uses -p to specify custom ports, while PuTTY plink and TortoisePlink use -P. Git now detects if plink is in GIT_SSH and modify its flags as necessary. We call plink with -batch, so that it will error out with an error message instead of waiting for user input. As reported in msysGit issue 96, plink wants to interact with the user asking if a host key should be accepted, but this just blocks the terminal, since plink tries to get the answer from stdin. However, stdin is already connected to Git that wants to send input to the remote command. But we do not pass -batch to TortoisePlink, because TortoisePlink uses a GUI to communicate with the user, and it does not understand -batch. Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com> Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | daemon: Strictly parse the "extra arg" part of the commandShawn O. Pearce2009-06-06
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 1.4.4.5 (49ba83fb67 "Add virtualization support to git-daemon") git daemon enters an infinite loop and never terminates if a client hides any extra arguments in the initial request line which is not exactly "\0host=blah\0". Since that change, a client must never insert additional extra arguments, or attempt to use any argument other than "host=", as any daemon will get stuck parsing the request line and will never complete the request. Since the client can't tell if the daemon is patched or not, it is not possible to know if additional extra args might actually be able to be safely requested. If we ever need to extend the git daemon protocol to support a new feature, we may have to do something like this to the exchange: # If both support git:// v2 # C: 000cgit://v2 S: 0010ok host user C: 0018host git.kernel.org C: 0027git-upload-pack /pub/linux-2.6.git S: ...git-upload-pack header... # If client supports git:// v2, server does not: # C: 000cgit://v2 S: <EOF> C: 003bgit-upload-pack /pub/linux-2.6.git\0host=git.kernel.org\0 S: ...git-upload-pack header... This requires the client to create two TCP connections to talk to an older git daemon, however all daemons since the introduction of daemon.c will safely reject the unknown "git://v2" command request, so the client can quite easily determine the server supports an older protocol. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* connect: replace inet_ntop with getnameinfoBenjamin Kramer2009-04-25
| | | | | | | | | | | | inet_ntop is not protocol independent. getnameinfo(3) is part of POSIX and is available when getaddrinfo(3) is. This code is only compiled when NO_IPV6 isn't defined. The old method was buggy anyway, not every ipv6 address was converted properly because the buffer (addr) was too small. Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Remove unused assignmentsBenjamin Kramer2009-03-14
| | | | | | | | | | | | | | | | | These variables were always overwritten or the assigned value was unused: builtin-diff-tree.c::cmd_diff_tree(): nr_sha1 builtin-for-each-ref.c::opt_parse_sort(): sort_tail builtin-mailinfo.c::decode_header_bq(): in builtin-shortlog.c::insert_one_record(): len connect.c::git_connect(): path imap-send.c::v_issue_imap_cmd(): n pretty.c::pp_user_info(): filler remote::parse_refspec_internal(): llen Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* connect.c: remove a few globals by using git_config callback dataErik Faye-Lund2009-03-10
| | | | | | | | | | | | | | Since ef90d6d (Provide git_config with a callback-data parameter, 2008-05-14), git_config() takes a callback data pointer that can be used to pass extra parameters to the parsing function. The codepath to parse configuration variables related to git proxy predates this facility and used a pair of file scope static variables instead. This patch removes the need for these global variables by passing the name of the host we are trying to access as the callback data. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* remove trailing LF in die() messagesAlexander Potashev2009-01-05
| | | | | | | | LF at the end of format strings given to die() is redundant because die already adds one on its own. Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* connect.c: stricter port validation, silence compiler warningRené Scharfe2008-12-21
| | | | | | | | | | In addition to checking if the provided port is numeric, also check that the string isn't empty and that the port number is within the valid range. Incidentally, this silences a compiler warning about ignoring strtol's return value. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* connect.c: add a way for git-daemon to pass an error back to clientTom Preston-Werner2008-11-02
| | | | | | | | | | | | | | | | | | | The current behavior of git-daemon is to simply close the connection on any error condition. This leaves the client without any information as to the cause of the failed fetch/push/etc. This patch allows get_remote_heads to accept a line prefixed with "ERR" that it can display to the user in an informative fashion. Once clients can understand this ERR line, git-daemon can be made to properly report "repository not found", "permission denied", or other errors. Example S: ERR No matching repository. C: fatal: remote error: No matching repository. Signed-off-by: Tom Preston-Werner <tom@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* make alloc_ref_from_str() the new alloc_ref()René Scharfe2008-10-18
| | | | | | | | | | | With all calls to alloc_ref() gone, we can remove it and then we're free to give alloc_ref_from_str() the shorter name. It's a much nicer interface, as the callers always need to have a name string when they allocate a ref anyway and don't need to calculate and pass its length+1 any more. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>