Skip to content
Permalink
Browse files
upstream: Ignore comments at the end of config lines in ssh_config,
similar to what we already do for sshd_config.  bz#2320, with & ok djm@

OpenBSD-Commit-ID: bdbf9fc5bc72b1a14266f5f61723ed57307a6db4
  • Loading branch information
daztucker authored and djmdjm committed Dec 4, 2020
1 parent b755264 commit 2bcbf67
Showing 1 changed file with 9 additions and 2 deletions.
@@ -1,4 +1,4 @@
/* $OpenBSD: readconf.c,v 1.342 2020/11/15 22:34:58 djm Exp $ */
/* $OpenBSD: readconf.c,v 1.343 2020/11/30 05:36:39 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1899,7 +1899,7 @@ read_config_file_depth(const char *filename, struct passwd *pw,
int flags, int *activep, int *want_final_pass, int depth)
{
FILE *f;
char *line = NULL;
char *cp, *line = NULL;
size_t linesize = 0;
int linenum;
int bad_options = 0;
@@ -1930,6 +1930,13 @@ read_config_file_depth(const char *filename, struct passwd *pw,
while (getline(&line, &linesize, f) != -1) {
/* Update line number counter. */
linenum++;
/*
* Trim out comments and strip whitespace.
* NB - preserve newlines, they are needed to reproduce
* line numbers later for error messages.
*/
if ((cp = strchr(line, '#')) != NULL)
*cp = '\0';
if (process_config_line_depth(options, pw, host, original_host,
line, filename, linenum, activep, flags, want_final_pass,
depth) != 0)

2 comments on commit 2bcbf67

@TomekOrzechowski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just upgraded Fedora 33 to Fedora 34, and along with this openssh 8.4 to openssh 8.5
And some of ssh config stopped working.
My case:
[torzechowski@fedora ~]$ grep '#' -i .ssh/config | tail -1
User torzechowski#10.2.128.32

For me it's a regression. And looking at the code I see no way for workaround - no quoting or escaping, because config line is simply chopped at hash sign.

@TomekOrzechowski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.