{"thread":{"id":"55149","subject":"git-send-email: smtpserver in $HOME","startedAt":"2021-02-15T14:08:23Z","lastAt":"2021-02-18T16:41:52Z","messageCount":13,"participants":["Jan “Khardix” Staněk","Junio C Hamano","Jeff King","Chris Torek","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"416914","messageId":"CAG+K25Pk0+sOAYuWS2OF7CXLXJLjGMKyBB_SOLpoO5RFiktN5g@mail.gmail.com","threadId":"55149","inReplyTo":null,"subject":"git-send-email: smtpserver in $HOME","fromName":"Jan “Khardix” Staněk","fromEmail":"khardix@gmail.com","sentAt":"2021-02-15T14:07:30Z","receivedAt":"2021-02-15T14:08:23Z","isPatch":false,"sender":{"key":"khardix@gmail.com","avatar":"https://gravatar.com/avatar/e62cb9bd3c97b87b2170976e45eb77eab2e10e6bafcd19dcd2affb54e5f00d40?d=mp&s=160"},"body":"Hi all,\nI ran into a bit of an issue when attempting to configure sendemail.\nI use a GMail integration tool [1]\nwhich is installed into my $HOME directory (~/.local/bin/gmi),\nand I would like to use it as `smtpserver`.\n\n[1]: https://github.com/gauteh/lieer\n\nHowever, I also use different machines with different login/usernames,\nwhich means the above is not so simple.\nBasically I would have to keep login-specific configuration files\nwith appropriate absolute path to the tool \"hardcoded\" in.\nSince I like to keep my configuration in git\nand synced across my machines,\nthat is a state I do not like very much.\n\nWould it be feasible to treat the `smtpserver` as path option\nand expand `~`/`~user` paths?\nWould it break anything\n(i.e., is `~` a valid character for beginning of a hostname)?\n\nAny other thoughts on this? Am I missing anything obvious? :)\n\nThanks in advance for any considerations and replies.\n--\nJan Staněk – Khardix\n"},{"id":"416999","messageId":"xmqqo8gksqr4.fsf@gitster.c.googlers.com","threadId":"55149","inReplyTo":"CAG+K25Pk0+sOAYuWS2OF7CXLXJLjGMKyBB_SOLpoO5RFiktN5g@mail.gmail.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-16T02:14:39Z","receivedAt":"2021-02-16T02:15:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan “Khardix” Staněk  <khardix@gmail.com> writes:\n\n> Would it be feasible to treat the `smtpserver` as path option\n> and expand `~`/`~user` paths?\n> Would it break anything\n> (i.e., is `~` a valid character for beginning of a hostname)?\n\nI haven't given too much thought, but offhand do not think of a\nreason why a change like the attached would break things.\n\n\n\n git-send-email.perl | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git c/git-send-email.perl w/git-send-email.perl\nindex 1f425c0809..ff58ac5046 100755\n--- c/git-send-email.perl\n+++ w/git-send-email.perl\n@@ -1006,6 +1006,8 @@ sub expand_one_alias {\n \t\t}\n \t}\n \t$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n+} elsif ($smtp_server =~ /^~/) {\n+\t$smtp_server = glob($smtp_server);\n }\n \n if ($compose && $compose > 0) {\n"},{"id":"417044","messageId":"CAG+K25NbifB9k9ugU5ZjLAOKxLyfEZcphfZXNS9_Whi6gZcBLA@mail.gmail.com","threadId":"55149","inReplyTo":"xmqqo8gksqr4.fsf@gitster.c.googlers.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Jan “Khardix” Staněk","fromEmail":"khardix@gmail.com","sentAt":"2021-02-16T12:49:20Z","receivedAt":"2021-02-16T12:50:08Z","isPatch":false,"sender":{"key":"khardix@gmail.com","avatar":"https://gravatar.com/avatar/e62cb9bd3c97b87b2170976e45eb77eab2e10e6bafcd19dcd2affb54e5f00d40?d=mp&s=160"},"body":"On 2021-02-15, Junio C Hamano wrote:\n> I haven't given too much thought, but offhand do not think of a\n> reason why a change like the attached would break things.\n\nSeems reasonable, but I figured I rather ask beforehand.\n\n>  git-send-email.perl | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git c/git-send-email.perl w/git-send-email.perl\n> index 1f425c0809..ff58ac5046 100755\n> --- c/git-send-email.perl\n> +++ w/git-send-email.perl\n> @@ -1006,6 +1006,8 @@ sub expand_one_alias {\n>  \t\t}\n>  \t}\n>  \t$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n> +} elsif ($smtp_server =~ /^~/) {\n> +\t$smtp_server = glob($smtp_server);\n>  }\n\nThis introduces a special case just for handling $smtp_server…\nI was thinking something in the way of the following:\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 1f425c0809..84c07daf6d 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -268,7 +268,6 @@ sub do_edit {\n );\n\n my %config_settings = (\n-    \"smtpserver\" => \\$smtp_server,\n     \"smtpserverport\" => \\$smtp_server_port,\n     \"smtpserveroption\" => \\@smtp_server_options,\n     \"smtpuser\" => \\$smtp_authuser,\n@@ -294,6 +293,7 @@ sub do_edit {\n\n my %config_path_settings = (\n     \"aliasesfile\" => \\@alias_files,\n+    \"smtpserver\" => \\$smtp_server,\n     \"smtpsslcertpath\" => \\$smtp_ssl_cert_path,\n );\n\nThis turns the smtpserver option into a \"path setting\",\nwhich does the user expansion.\nMy concern was that if there is a SMTP server actually named\ni.e. `~someone.example.org`, this change would break that.\nOf course, the question is if something like that\nis possible or supported…\n\nI have not yet allocated enough time to figure out how to run\nand/or modify the test suite, so I do not know if this would actually\nbreak something. I will try to do that in the near future.\n--\nJan Staněk – Khardix\n"},{"id":"417065","messageId":"YCvotU6KVruFuf9/@coredump.intra.peff.net","threadId":"55149","inReplyTo":"xmqqo8gksqr4.fsf@gitster.c.googlers.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-16T15:45:57Z","receivedAt":"2021-02-16T15:46:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 15, 2021 at 06:14:39PM -0800, Junio C Hamano wrote:\n\n> Jan “Khardix” Staněk  <khardix@gmail.com> writes:\n> \n> > Would it be feasible to treat the `smtpserver` as path option\n> > and expand `~`/`~user` paths?\n> > Would it break anything\n> > (i.e., is `~` a valid character for beginning of a hostname)?\n> \n> I haven't given too much thought, but offhand do not think of a\n> reason why a change like the attached would break things.\n\nI agree it's unlikely to break anything.\n\nStill, it seems a bit unusual for an executed program to handle tilde\nlike this. The usual mechanism is for us to run it with the shell and\nexpect to find it in $PATH.\n\nIt looks like there's some weirdness here, though; $smtp_server may be a\nhostname, and it looks like we use \"/\" to distinguish a file path. I\nwonder if allowing \"!my-sendmail\" would be more consistent with other\nparts of Git (not to mention more flexible).\n\n-Peff\n"},{"id":"417090","messageId":"xmqq7dn7rgi4.fsf@gitster.c.googlers.com","threadId":"55149","inReplyTo":"CAG+K25NbifB9k9ugU5ZjLAOKxLyfEZcphfZXNS9_Whi6gZcBLA@mail.gmail.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-16T18:53:39Z","receivedAt":"2021-02-16T18:54:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan “Khardix” Staněk  <khardix@gmail.com> writes:\n\n> On 2021-02-15, Junio C Hamano wrote:\n>> I haven't given too much thought, but offhand do not think of a\n>> reason why a change like the attached would break things.\n>\n> Seems reasonable, but I figured I rather ask beforehand.\n>\n>>  git-send-email.perl | 2 ++\n>>  1 file changed, 2 insertions(+)\n>>\n>> diff --git c/git-send-email.perl w/git-send-email.perl\n>> index 1f425c0809..ff58ac5046 100755\n>> --- c/git-send-email.perl\n>> +++ w/git-send-email.perl\n>> @@ -1006,6 +1006,8 @@ sub expand_one_alias {\n>>  \t\t}\n>>  \t}\n>>  \t$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n>> +} elsif ($smtp_server =~ /^~/) {\n>> +\t$smtp_server = glob($smtp_server);\n>>  }\n>\n> This introduces a special case just for handling $smtp_server…\n\nYes, and that was very much deliberate, as I think\n\n\tgit send-email --smtp-server=~/bin/my-phoney-sendmail\n\nwon't be affected by %config_path_settings.  $smtp_ssl_cert_path has\nthe same problem already, and I didn't want to make things worse (I\nthink %config_path_settings is a mistake---it is fine to have a list\nof variables that can use ~tilde expansion, but I do not see why it\nmakes sense to allow the ~tilde expansion when the value came from\nconfigureation files, and not from the command line).\n\n> My concern was that if there is a SMTP server actually named\n> i.e. `~someone.example.org`, this change would break that.\n\nCan tilde appear in a valid DNS name?  I doubt it.\n"},{"id":"417092","messageId":"xmqq35xvrgbg.fsf@gitster.c.googlers.com","threadId":"55149","inReplyTo":"YCvotU6KVruFuf9/@coredump.intra.peff.net","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-16T18:57:39Z","receivedAt":"2021-02-16T18:58:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Still, it seems a bit unusual for an executed program to handle tilde\n> like this. The usual mechanism is for us to run it with the shell and\n> expect to find it in $PATH.\n\nYes, the user should be able to deal with the $PATH.\n\n> It looks like there's some weirdness here, though; $smtp_server may be a\n> hostname, and it looks like we use \"/\" to distinguish a file path. I\n> wonder if allowing \"!my-sendmail\" would be more consistent with other\n> parts of Git (not to mention more flexible).\n\nI am not sure '!' prefix fits well here.\n\nWhen cloning from something (that is not yet known as an entity that\nwe must go over the network), we do an equivalent of \"test -f\" (for\nbundles) and \"test -d\" (for local repositories), and I think the use\nof \"does it refer to a local file\" here matches it as a precedent.\n\nI do find it sloppy that the check uses file_name_is_absolute() that\nonly checks the shape of the string, without seeing if it actually\nexists and is an executable file, though.\n\nThanks.\n"},{"id":"417094","messageId":"YCwXf1CA0Xyw/B88@coredump.intra.peff.net","threadId":"55149","inReplyTo":"xmqq35xvrgbg.fsf@gitster.c.googlers.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-16T19:05:35Z","receivedAt":"2021-02-16T19:06:51Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 16, 2021 at 10:57:39AM -0800, Junio C Hamano wrote:\n\n> > It looks like there's some weirdness here, though; $smtp_server may be a\n> > hostname, and it looks like we use \"/\" to distinguish a file path. I\n> > wonder if allowing \"!my-sendmail\" would be more consistent with other\n> > parts of Git (not to mention more flexible).\n> \n> I am not sure '!' prefix fits well here.\n\nWhy not? It matches alias config, credential config, and perhaps others\nas \"treat this as a shell command\".\n\nAnd like a leading \"/\", it would not be likely to be confused with an\nactual hostname.\n\n> When cloning from something (that is not yet known as an entity that\n> we must go over the network), we do an equivalent of \"test -f\" (for\n> bundles) and \"test -d\" (for local repositories), and I think the use\n> of \"does it refer to a local file\" here matches it as a precedent.\n\nSure, but you cannot say \"does it refer to a local file\" for a\nnon-absolute path. And that is the source of the problem, IMHO: there is\nno way to signal \"this is a command I expect to be executed\" except by\nusing an absolute path.\n\nOr do you mean that we should see if $smtp_server exists in the PATH,\nand if so prefer it over a network hostname?\n\n> I do find it sloppy that the check uses file_name_is_absolute() that\n> only checks the shape of the string, without seeing if it actually\n> exists and is an executable file, though.\n\nYes, though that comes with its own problems: you mean to say \"foo\", but\ndue to a typo or missing program it is not found, and so you hit \"foo\"\non the network. Probably not the end of the world, but unexpected, I\nwould say. That's why I'd prefer having a syntactic marker that\nindicates what you mean.\n\n(I'd prefer to just have $smtp_program or similar as that signal\ninstead, but it doesn't seem worth trying to retrofit it now).\n\n-Peff\n"},{"id":"417095","messageId":"xmqqy2fnq0vx.fsf@gitster.c.googlers.com","threadId":"55149","inReplyTo":"YCwXf1CA0Xyw/B88@coredump.intra.peff.net","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-16T19:16:18Z","receivedAt":"2021-02-16T19:17:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Sure, but you cannot say \"does it refer to a local file\" for a\n> non-absolute path.\n\nHmph, why not?  I would expect that this would work as a valid way\n\n\t$ git send-email --smtp-server=./my-phoney-smtp\n\nto test a server substitute (perhaps for testing).  The only reason\nwhy it does not is because file_name_is_absolute() check would not\nlike it.\n\n> And that is the source of the problem, IMHO: there is\n> no way to signal \"this is a command I expect to be executed\" except by\n> using an absolute path.\n\nYes.\n\n> Or do you mean that we should see if $smtp_server exists in the PATH,\n> and if so prefer it over a network hostname?\n\nWe can certainly go in that direction, too.  A new --smtp-program option\nwould be a cleaner way to solve it, though, as you said elsewhere.\n"},{"id":"417096","messageId":"YCwbsKIKNHTMJJHQ@coredump.intra.peff.net","threadId":"55149","inReplyTo":"xmqqy2fnq0vx.fsf@gitster.c.googlers.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-16T19:23:28Z","receivedAt":"2021-02-16T19:24:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 16, 2021 at 11:16:18AM -0800, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > Sure, but you cannot say \"does it refer to a local file\" for a\n> > non-absolute path.\n> \n> Hmph, why not?  I would expect that this would work as a valid way\n> \n> \t$ git send-email --smtp-server=./my-phoney-smtp\n> \n> to test a server substitute (perhaps for testing).  The only reason\n> why it does not is because file_name_is_absolute() check would not\n> like it.\n\nAh, sure. But you cannot say \"my-phoney-smtp\" and find it in the PATH,\nbecause it is syntactically indistinguishable from a host with the same\nname.\n\n-Peff\n"},{"id":"417112","messageId":"CAG+K25NC3H7L5TpxmR_kCvmqR8GPdCEdTt740F34ON4TWoPCpg@mail.gmail.com","threadId":"55149","inReplyTo":"xmqq7dn7rgi4.fsf@gitster.c.googlers.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Jan “Khardix” Staněk","fromEmail":"khardix@gmail.com","sentAt":"2021-02-16T22:14:20Z","receivedAt":"2021-02-16T22:15:19Z","isPatch":false,"sender":{"key":"khardix@gmail.com","avatar":"https://gravatar.com/avatar/e62cb9bd3c97b87b2170976e45eb77eab2e10e6bafcd19dcd2affb54e5f00d40?d=mp&s=160"},"body":"On 2021-02-16, Junio C Hamano wrote:\n> Jan “Khardix” Staněk  <khardix@gmail.com> writes:\n> > This introduces a special case just for handling $smtp_server…\n>\n> Yes, and that was very much deliberate, as I think\n>\n> \tgit send-email --smtp-server=~/bin/my-phoney-sendmail\n>\n> won't be affected by %config_path_settings.  $smtp_ssl_cert_path has\n> the same problem already, and I didn't want to make things worse (I\n> think %config_path_settings is a mistake---it is fine to have a list\n> of variables that can use ~tilde expansion, but I do not see why it\n> makes sense to allow the ~tilde expansion when the value came from\n> configureation files, and not from the command line).\n\nWell, unless I'm missing something, shouldn't the tilde above be\nexpanded by the shell before actually being passed as argument?\n\n$ echo simulate --smtp-server=~/bin/my-phoney-sendmail\nsimulate --smtp-server=/home/khardix/bin/my-phoney-sendmail\n\nI assumed that only the config values are handled specially\nbecause only they need that – the CLI is handled by shell in advance.\nNever played with $smtp_ssl_cert_path though,\nso if there are known problems, just ignore me\n– or better, point me to the relevant issue/discussion,\nif you can be bothered :) Thanks.\n\n> > My concern was that if there is a SMTP server actually named\n> > i.e. `~someone.example.org`, this change would break that.\n>\n> Can tilde appear in a valid DNS name?  I doubt it.\n\nSo I actually did my homework and skimmed through the relevant RFCs\n(RFC952 and RFC1123); as it turns out, no, it cannot\n– only ASCII alphanumerics, '-' and '.' are valid characters.\n--\nJan Staněk – Khardix\n"},{"id":"417115","messageId":"CAG+K25NhVdM6f2sXG3bDODH2ZEBXyfPuoXYtHoeC1X2YFOwnRQ@mail.gmail.com","threadId":"55149","inReplyTo":"YCwXf1CA0Xyw/B88@coredump.intra.peff.net","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Jan “Khardix” Staněk","fromEmail":"khardix@gmail.com","sentAt":"2021-02-16T22:31:00Z","receivedAt":"2021-02-16T22:31:44Z","isPatch":false,"sender":{"key":"khardix@gmail.com","avatar":"https://gravatar.com/avatar/e62cb9bd3c97b87b2170976e45eb77eab2e10e6bafcd19dcd2affb54e5f00d40?d=mp&s=160"},"body":"On 2021-02-16, Jeff King wrote:\n> … It matches alias config, credential config, and perhaps others\n> as \"treat this as a shell command\".\n\nI will have to take closer look at the '!' prefix in other git parts,\nbut I like that approach.\n\n> (I'd prefer to just have $smtp_program or similar as that signal\n> instead, but it doesn't seem worth trying to retrofit it now).\n\nThat would also be my preference, but it would be a larger change\nand I'm not currently confident enough to go this route.\n\nFrom the points and ideas raised (and btw, thanks a lot for those),\nthe easiest one seems to be treating $smtp_server as path options,\nthe cleanest one a new $smtp_program options,\nand the middle ground being adding support for '!' prefix.\nUnless someone beats me to it, I will try to throw together a patch,\naiming for now for the '!' prefix and falling back to path option\n– as this is potentially my first contribution here,\nI'll see how it goes.\n--\nJan Staněk – Khardix\n"},{"id":"417290","messageId":"CAPx1Gvf1pXCp9YVQSQ1_-w3-A8qYZD7tsFV80njsXD-+Jap6Xw@mail.gmail.com","threadId":"55149","inReplyTo":"CAG+K25NC3H7L5TpxmR_kCvmqR8GPdCEdTt740F34ON4TWoPCpg@mail.gmail.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Chris Torek","fromEmail":"chris.torek@gmail.com","sentAt":"2021-02-18T10:18:25Z","receivedAt":"2021-02-18T12:24:52Z","isPatch":false,"sender":{"key":"chris.torek@gmail.com","avatar":"https://avatars.githubusercontent.com/u/16826774?v=4"},"body":"Just a small point here:\n\nOn Tue, Feb 16, 2021 at 2:17 PM Jan “Khardix” Staněk <khardix@gmail.com> wrote:\n> Well, unless I'm missing something, shouldn't the tilde above be\n> expanded by the shell before actually being passed as argument?\n\nMaybe.  Some shells do and some don't:\n\n$ echo foo=~/foo\nfoo=~/foo\n\nbash$ echo foo=~/foo\nfoo=/home/torek/foo\n\nfor instance.\n\n> So I actually did my homework and skimmed through the relevant RFCs\n> (RFC952 and RFC1123); as it turns out, no, it cannot\n> – only ASCII alphanumerics, '-' and '.' are valid characters.\n\nRight: tilde and slash are both verboten. (Underscore is too, but\nthat one does get used and some programs allow it.)\n\nChris\n"},{"id":"417308","messageId":"878s7lzg6m.fsf@igel.home","threadId":"55149","inReplyTo":"CAPx1Gvf1pXCp9YVQSQ1_-w3-A8qYZD7tsFV80njsXD-+Jap6Xw@mail.gmail.com","subject":"Re: git-send-email: smtpserver in $HOME","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2021-02-18T12:57:53Z","receivedAt":"2021-02-18T16:41:52Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Feb 18 2021, Chris Torek wrote:\n\n> Just a small point here:\n>\n> On Tue, Feb 16, 2021 at 2:17 PM Jan “Khardix” Staněk <khardix@gmail.com> wrote:\n>> Well, unless I'm missing something, shouldn't the tilde above be\n>> expanded by the shell before actually being passed as argument?\n>\n> Maybe.  Some shells do and some don't:\n>\n> $ echo foo=~/foo\n> foo=~/foo\n>\n> bash$ echo foo=~/foo\n> foo=/home/torek/foo\n\nBut:\n\n$ echo --foo=~/foo\n--foo=~/foo\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"}]}