From: Collin Funk <collin.funk1@gmail.com>
To: musl@lists.openwall.com
Subject: [musl] getusershell should ignore comments and empty lines.
Date: Fri, 17 May 2024 20:17:54 -0700 [thread overview]
Message-ID: <625e06f9-10ca-4ad3-86e2-6f6edf585ec9@gmail.com> (raw)
Hello Musl maintainers,
The getusershell function behaves differently from Glibc and FreeBSD.
I believe that it should follow those implementations by ignoring
comments and empty lines.
I wrote a test for Gnulib that catches this issue. You may find it
helpful for testing [1].
On FreeBSD I have the following etc/shells:
==============================================
# List of acceptable shells for chpass(1).
# ftpd(8) will not allow users to connect who are not using
# one of these shells.
/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
/usr/local/bin/rbash
/usr/local/libexec/git-core/git-shell
==============================================
And I run the following in a Gnulib checkout:
$ rm -rf testdir1 && ./gnulib-tool --create-testdir --dir testdir1 getusershell
$ cd testdir1
$ ./configure
$ make
$ ./gltests/test-getusershell
/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
/usr/local/bin/rbash
/usr/local/libexec/git-core/git-shell
GNU libc behaves the same way. I have not checked the other BSDs but I
assume they use the same code derived from 4.3BSD or 4.4BSD.
Using an Alpine Linux virtual machine with Musl Version 1.2.4_git20230717
and a few packages installed I have the default /etc/shells:
==============================================
# valid login shells
/bin/sh
/bin/ash
/bin/bash
==============================================
Using the same commands listed earlier I run:
$ ./gltests/test-getusershell
test-getusershell.c:54: assertion 'ptr[0] != '#'' failed
Aborted
And after adding an empty line before the comment:
$ ./gltests/test-getusershell
test-getusershell.c:55: assertion 'ptr[0] != '\0'' failed
Aborted
Let me know if you have any questions. The FreeBSD shells(5) man page
is pretty good and might be helpful [2]. Here is a link to their
implementation incase that helps too [3].
Collin
[1] https://git.savannah.gnu.org/cgit/gnulib.git/tree/tests/test-getusershell.c
[2] https://man.freebsd.org/cgi/man.cgi?query=shells&sektion=5&manpath=freebsd-release
[3] https://github.com/freebsd/freebsd-src/blob/main/lib/libc/gen/getusershell.c
next reply other threads:[~2024-05-18 3:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-18 3:17 Collin Funk [this message]
2024-05-23 13:21 ` Rich Felker
2024-05-23 13:45 ` Leah Neukirchen
2024-05-23 13:59 ` Collin Funk
2024-05-23 14:47 ` Rich Felker
2024-05-23 15:27 ` Rich Felker
2024-05-25 0:16 ` Collin Funk
2024-06-22 1:06 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=625e06f9-10ca-4ad3-86e2-6f6edf585ec9@gmail.com \
--to=collin.funk1@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).