|
Message-ID: <cca07bee-bbc7-449c-92b5-767d7b56c8e1@gmail.com> Date: Thu, 23 May 2024 06:59:42 -0700 From: Collin Funk <collin.funk1@...il.com> To: Leah Neukirchen <leah@...u.org>, Rich Felker <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: getusershell should ignore comments and empty lines. Hi Rich and Leah, On 5/23/24 6:45 AM, Leah Neukirchen wrote: >> "A hash mark (``#'') indicates the beginning of a comment; >> subsequent characters up to the end of the line are not >> interpreted by the routines which search the file." >> >> This isn't very clear whether # is only a comment on the beginning of >> a line (after potential whitespace?) or whether # appearing in a line >> with a shell pathname is a comment or part of the pathname. If it's a >> comment, it's not clear if whitespace before it is part of the shell >> pathname -- e.g. does "/bin/sh # best shell" define "/bin/sh" or >> "/bin/sh " as the shell pathname? >> >> It sounds like nobody ever thought about whitespace, quoting, or >> rigorous comment syntax here... > > True: > > OpenBSD drops the rest of the line with "#" and ignores lines not > starting with a "/". > > glibc drops the rest of the line with "#", elides spaces after the > entry, and skips everything before the first "/" (quite bold). I noticed the glibc behavior as well, but I thought the BSDs did it too. Like this: 'bin/bash' -> '/bash' which is interesting. :) I think the general algorithm is read a single line. Find the first '/' character and then begin at the next character. Then continue until the end of line or other whitespace character. Perhaps the others felt that was awkward and changed it, I am not sure. I think it would be nice to ignore lines starting with '#' though and empty lines. That should cover 99% of cases. Most distributions, including Alpine Linux, come with an '/etc/shells' like this: =================== # Some commentary redirecting to a man page or other documentation. /bin/sh /bin/bash /usr/bin/sh /usr/bin/bash =================== I doubt anyone changes it from that simple format. Collin
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.