Re: [BUG] having 'plink' anywhere in the GIT_SSH environment variables sets putty = true
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Apr 22, 2015, 21:19 UTC
- Message-ID
- <20150422211915.GB827497@vauxhall.crustytoothpaste.net>
- In-Reply-To
- <20150422202910.GB26917@peff.net>
On Wed, Apr 22, 2015 at 04:29:10PM -0400, Jeff King wrote:
Show 26 quoted lines
> I think you want something like:
>
> diff --git a/connect.c b/connect.c
> index 9ae991a..58aad56 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -568,7 +568,8 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
> conn->argv = arg = xcalloc(7, sizeof(*arg));
> if (protocol == PROTO_SSH) {
> const char *ssh = getenv("GIT_SSH");
> - int putty = ssh && strcasestr(ssh, "plink");
> + int putty = ssh && (ends_with(ssh, "plink") ||
> + ends_with("plink.exe"));
> if (!ssh) ssh = "ssh";
>
> *arg++ = ssh;
>
> though that is not quite enough (we do not have a case-insensitive
> version of "ends_with"). I'm also not sure if matching just "plink" and
> "plink.exe" at the end of the string is enough (I'm just guessing that
> was the original reason for using strstr in the first place).
>
> Note that I don't think just switching the strcasestr to look for
> "plink.exe" is right. For one thing, it just punts on the problem (it
> can still happen, it's just less likely to trigger). But for another,
> you can have plink (without ".exe") on Linux systems.Perhaps it would be worthwhile to check instead if the text "plink" is the beginning of string or is preceded by a path separator. That would give us a bit more confidence that the user is looking for plink, but would still allow people to use "plink-0.63" if they like.
-- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187