summaryrefslogtreecommitdiff
path: root/imap-send.c
AgeCommit message (Collapse)Author
2013-05-21imap-send: eliminate HMAC deprecation warnings on Mac OS XDavid Aguilar
As of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to OpenSSL ABI instability. Silence the warnings by using Apple's CommonCrypto HMAC replacement functions. [es: reworded commit message; check APPLE_COMMON_CRYPTO instead of abusing COMMON_DIGEST_FOR_OPENSSL] Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-21Merge branch 'ob/imap-send-ssl-verify'Junio C Hamano
Correctly connect to SSL/TLS sites that serve multiple hostnames on a single IP by including Server Name Indication in the client-hello. * ob/imap-send-ssl-verify: imap-send: support Server Name Indication (RFC4366)
2013-02-21imap-send: support Server Name Indication (RFC4366)Junio C Hamano
To talk with some sites that serve multiple names on a single IP address, the client needs to ask for the specific host that it wants to talk to. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20Sync with v1.8.1.4Junio C Hamano
2013-02-20Merge branch 'ob/imap-send-ssl-verify' into maintJunio C Hamano
* ob/imap-send-ssl-verify: imap-send: support subjectAltName as well imap-send: the subject of SSL certificate must match the host imap-send: move #ifdef around
2013-02-20imap-send: support subjectAltName as wellOswald Buddenhagen
Check not only the common name of the certificate subject, but also check the subject alternative DNS names as well, when verifying that the certificate matches that of the host we are trying to talk to. Signed-off-by: Oswald Buddenhagen <ossi@kde.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20imap-send: the subject of SSL certificate must match the hostOswald Buddenhagen
We did not check a valid certificate's subject at all, and would have happily talked with a wrong host after connecting to an incorrect address and getting a valid certificate that does not belong to the host we intended to talk to. Signed-off-by: Oswald Buddenhagen <ossi@kde.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-19imap-send: move #ifdef aroundJunio C Hamano
Instead of adding an early return to the inside of the ssl_socket_connect() function for NO_OPENSSL compilation, split it into a separate stub function. No functional change, but the next change to extend ssl_socket_connect() will become easier to read this way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: simplify logic in lf_to_crlf()Michael Haggerty
* The first character in the string used to be special-cased to get around the fact that msg->buf[i - 1] is not defined for i == 0. Instead, keep track of the previous character in a separate variable, "lastc", initialized in such a way to let the loop handle i == 0 correctly. * Make the two loops over the string look as similar as possible to make it more obvious that the count computed in the first pass agrees with the true length of the new string written in the second pass. As a side effect, this makes it possible to use the "j" counter in place of lfnum and new_len. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: fold struct store into struct imap_storeMichael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove unused field imap_store::uidvalidityMichael Haggerty
I suspect that the existence of both imap_store::uidvalidity and store::uidvalidity was an accident. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: use struct imap_store instead of struct storeMichael Haggerty
In fact, all struct store instances are upcasts of struct imap_store anyway, so stop making the distinction. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove unused field imap_store::trashncMichael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove namespace fields from struct imapMichael Haggerty
They are unused, and their removal means that a bunch of list-related infrastructure can be disposed of. It might be that the "NAMESPACE" response that is now skipped over in get_cmd_result() should never be sent by the server. But somebody would have to check the IMAP protocol and how we interact with the server to be sure. So for now I am leaving that branch of the "if" statement there. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove struct imap argument to parse_imap_list_l()Michael Haggerty
It was always set to NULL. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: inline parse_imap_list() in parse_list()Michael Haggerty
The function is only called from here. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove some unused fields from struct storeMichael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove struct messageMichael Haggerty
It was never used. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove struct store_confMichael Haggerty
It was never used. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15iamp-send.c: remove unused struct imap_store_confMichael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove struct msg_dataMichael Haggerty
Now that its flags member has been deleted, all that is left is a strbuf. So use a strbuf directly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-15imap-send.c: remove msg_data::flags, which was always zeroMichael Haggerty
This removes the need for function imap_make_flags(), so delete it, too. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-02wrap_in_html(): process message in bulk rather than line-by-lineMichael Haggerty
Now that we can xml-quote an arbitrary string in O(N), there is no reason to process the message line by line. This change saves lots of memory allocations and copying. The old code would have created invalid output when there was no body, emitting a closing </pre> without a blank line nor an opening <pre> after the header. The new code simply returns in this situation without doing harm (even though either would not make much sense in the context of imap-send that is meant to send out patches). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-29wrap_in_html(): use strbuf_addstr_xml_quoted()Michael Haggerty
Use the new function to quote characters as they are being added to buf, rather than quoting them in *p and then copying them into buf. This increases code sharing, and changes the algorithm from O(N^2) to O(N) in the number of characters in a line. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-29imap-send: change msg_data from storing (ptr, len) to storing strbufMichael Haggerty
struct msg_data stored (ptr, len) of the data to be included in a message, kept the character data NUL-terminated, etc., much like a strbuf would do. So change it to use a struct strbuf. This makes the code clearer and reduces copying a little bit. A side effect of this change is that the memory for each message is freed after it is used rather than leaked, though that detail is unimportant given that imap-send is a top-level command. By the way, there is a bunch of infrastructure in this file for dealing with IMAP flags, although there is nothing in the code that actually allows any flags to be set. If there is no plan to add support for flags in the future, a bunch of code could be ripped out and "struct msg_data" could be completely replaced with strbuf, but that would be a separate topic. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26imap-send: correctly report errors reading from stdinMichael Haggerty
Previously, read_message() didn't distinguish between an error and eof when reading its input. This could have resulted in incorrect behavior if there was an error: (1) reporting "nothing to send" if no bytes were read or (2) sending an incomplete message if some bytes were read before the error. Change read_message() to return -1 on ferror()s and 0 on success, so that the caller can recognize that an error occurred. (The return value used to be the length of the input read, which was redundant because that is already available as the strbuf length. Change the caller to report errors correctly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26imap-send: store all_msgs as a strbufMichael Haggerty
all_msgs is only used as a glorified string, therefore there is no reason to declare it as a struct msg_data. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-26lf_to_crlf(): NUL-terminate msg_data::dataMichael Haggerty
Through the rest of the file, the data member of struct msg_data is kept NUL-terminated, and that fact is relied upon in a couple of places. Change lf_to_crlf() to preserve this invariant. In fact, there are no execution paths in which lf_to_crlf() is called and then its data member is required to be NUL-terminated, but it is better to be consistent to prevent future confusion. Document the invariant in the struct msg_data definition. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30remove superfluous newlines in error messagesPete Wyckoff
The error handling routines add a newline. Remove the duplicate ones in error messages. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-06Sync with 1.7.6.6Junio C Hamano
* maint-1.7.8: Git 1.7.6.6 imap-send: remove dead code
2012-02-06Sync with 1.7.6.6Junio C Hamano
* maint-1.7.7: Git 1.7.6.6 imap-send: remove dead code
2012-02-06imap-send: remove dead codeJeff King
The imap-send code was adapted from another project, and still contains many unused bits of code. One of these bits contains a type "struct string_list" which bears no resemblence to the "struct string_list" we use elsewhere in git. This causes the compiler to complain if git's string_list ever becomes part of cache.h. Let's just drop the dead code. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-22Merge branch 'jk/git-prompt'Junio C Hamano
* 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
2011-12-20Merge branch 'ab/enable-i18n'Junio C Hamano
* ab/enable-i18n: i18n: add infrastructure for translating Git with gettext Conflicts: Makefile
2011-12-13move git_getpass to its own source fileJeff King
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>
2011-12-13imap-send: don't check return value of git_getpassJeff King
git_getpass will always die() if we weren't able to get input, so there's no point looking for NULL. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-13imap-send: avoid buffer overflowJeff King
We format the password prompt in an 80-character static buffer. It contains the remote host and username, so it's unlikely to overflow (or be exploitable by a remote attacker), but there's no reason not to be careful and use a strbuf. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-06i18n: add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason
Change the skeleton implementation of i18n in Git to one that can show localized strings to users for our C, Shell and Perl programs using either GNU libintl or the Solaris gettext implementation. This new internationalization support is enabled by default. If gettext isn't available, or if Git is compiled with NO_GETTEXT=YesPlease, Git falls back on its current behavior of showing interface messages in English. When using the autoconf script we'll auto-detect if the gettext libraries are installed and act appropriately. This change is somewhat large because as well as adding a C, Shell and Perl i18n interface we're adding a lot of tests for them, and for those tests to work we need a skeleton PO file to actually test translations. A minimal Icelandic translation is included for this purpose. Icelandic includes multi-byte characters which makes it easy to test various edge cases, and it's a language I happen to understand. The rest of the commit message goes into detail about various sub-parts of this commit. = Installation Gettext .mo files will be installed and looked for in the standard $(prefix)/share/locale path. GIT_TEXTDOMAINDIR can also be set to override that, but that's only intended to be used to test Git itself. = Perl Perl code that's to be localized should use the new Git::I18n module. It imports a __ function into the caller's package by default. Instead of using the high level Locale::TextDomain interface I've opted to use the low-level (equivalent to the C interface) Locale::Messages module, which Locale::TextDomain itself uses. Locale::TextDomain does a lot of redundant work we don't need, and some of it would potentially introduce bugs. It tries to set the $TEXTDOMAIN based on package of the caller, and has its own hardcoded paths where it'll search for messages. I found it easier just to completely avoid it rather than try to circumvent its behavior. In any case, this is an issue wholly internal Git::I18N. Its guts can be changed later if that's deemed necessary. See <AANLkTilYD_NyIZMyj9dHtVk-ylVBfvyxpCC7982LWnVd@mail.gmail.com> for a further elaboration on this topic. = Shell Shell code that's to be localized should use the git-sh-i18n library. It's basically just a wrapper for the system's gettext.sh. If gettext.sh isn't available we'll fall back on gettext(1) if it's available. The latter is available without the former on Solaris, which has its own non-GNU gettext implementation. We also need to emulate eval_gettext() there. If neither are present we'll use a dumb printf(1) fall-through wrapper. = About libcharset.h and langinfo.h We use libcharset to query the character set of the current locale if it's available. I.e. we'll use it instead of nl_langinfo if HAVE_LIBCHARSET_H is set. The GNU gettext manual recommends using langinfo.h's nl_langinfo(CODESET) to acquire the current character set, but on systems that have libcharset.h's locale_charset() using the latter is either saner, or the only option on those systems. GNU and Solaris have a nl_langinfo(CODESET), FreeBSD can use either, but MinGW and some others need to use libcharset.h's locale_charset() instead. =Credits This patch is based on work by Jeff Epler <jepler@unpythonic.net> who did the initial Makefile / C work, and a lot of comments from the Git mailing list, including Jonathan Nieder, Jakub Narebski, Johannes Sixt, Erik Faye-Lund, Peter Krefting, Junio C Hamano, Thomas Rast and others. [jc: squashed a small Makefile fix from Ramsay] Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-23Merge branch 'maint' into tj/imap-send-remove-unusedJunio C Hamano
* maint: (18123 commits) documentation fix: git difftool uses diff tools, not merge tools. Git 1.7.7.4 Makefile: add missing header file dependencies notes merge: eliminate OUTPUT macro mailmap: xcalloc mailmap_info name-rev --all: do not even attempt to describe non-commit object Git 1.7.7.3 docs: Update install-doc-quick docs: don't mention --quiet or --exit-code in git-log(1) Git 1.7.7.2 t7511: avoid use of reserved filename on Windows. clone: Quote user supplied path in a single quote pair read-cache.c: fix index memory allocation make the sample pre-commit hook script reject names with newlines, too Reindent closing bracket using tab instead of spaces Git 1.7.7.1 RelNotes/1.7.7.1: setgid bit patch is about fixing "git init" via Makefile setting gitweb: fix regression when filtering out forks Almost ready for 1.7.7.1 pack-objects: don't traverse objects unnecessarily ... Conflicts: imap-send.c
2011-11-23imap-send: Remove unused 'use_namespace' variableThomas Jarosch
Reported by cppcheck Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11sparse: Fix some "Using plain integer as NULL pointer" warningsRamsay Jones
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-22Fix sparse warningsStephen Boyd
Fix warnings from 'make check'. - These files don't include 'builtin.h' causing sparse to complain that cmd_* isn't declared: builtin/clone.c:364, builtin/fetch-pack.c:797, builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78, builtin/merge-index.c:69, builtin/merge-recursive.c:22 builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426 builtin/notes.c:822, builtin/pack-redundant.c:596, builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149, builtin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25, builtin/var.c:75 - These files have symbols which should be marked static since they're only file scope: submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13, submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79, unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123, url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48 - These files redeclare symbols to be different types: builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571, usage.c:49, usage.c:58, usage.c:63, usage.c:72 - These files use a literal integer 0 when they really should use a NULL pointer: daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362 While we're in the area, clean up some unused #includes in builtin files (mostly exec_cmd.h). Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-09imap-send: Fix sprintf usageÆvar Arnfjörð Bjarmason
When composing a command for the imap server, imap-send uses a single nfsnprintf() invocation for brevity instead of dealing separately with the case when there is a message to be sent and the case when there isn’t. The unused argument in the second case, while valid, is confusing for static analyzers and human readers. v1.6.4-rc0~117 (imap-send: add support for IPv6, 2009-05-25) mistakenly used %hu as the format for an int “port”, by analogy with existing usage for the unsigned short “addr.sin_port”.  Use %d instead. Noticed with clang. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-31enums: omit trailing comma for portabilityGary V. Vaughan
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>
2010-04-03Merge branch 'rr/imap-send-unconfuse-from-line'Junio C Hamano
* rr/imap-send-unconfuse-from-line: imap-send: Remove limitation on message body
2010-03-28imap-send: suppress warning about cleartext password with CRAM-MD5Chris Webb
If a CRAM-MD5 challenge-response is used to authenticate to the IMAP server, git imap-send shouldn't warn about the password being sent in the clear. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-24imap-send: Remove limitation on message bodyRamkumar Ramachandra
There is a documented limitation on the body of any email not being able to contain lines starting with "From ". This patch removes that limitation by improving the parser to search for "From", "Date", and "Subject" fields in the email before considering it to be an email. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-20Merge branch 'fl/askpass'Junio C Hamano
* fl/askpass: git-core: Support retrieving passwords with GIT_ASKPASS git-svn: Support retrieving passwords with GIT_ASKPASS
2010-03-05git-core: Support retrieving passwords with GIT_ASKPASSFrank Li
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>
2010-03-03Merge branch 'hm/maint-imap-send-crlf' into maintJunio C Hamano
* hm/maint-imap-send-crlf: git-imap-send: Convert LF to CRLF before storing patch to draft box