From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id EDEA8214DC for ; Sat, 18 May 2024 05:18:12 +0200 (CEST) Received: (qmail 1343 invoked by uid 550); 18 May 2024 03:18:05 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1305 invoked from network); 18 May 2024 03:18:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716002276; x=1716607076; darn=lists.openwall.com; h=content-transfer-encoding:subject:to:from:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=okqk4H0dvzOTecDI4yizeUC9P+FCxABoq5oAPjdWpo4=; b=UbEFb6DVmpDU+joTIFXu4OiZlciHAe/I3UTAu50vk1A0Z7ir1Z/ciOBEnGQiULtnUK rw2StfSkw/xOw+c/UIB6dloGgBtY76pCmzMqJV0MYZx37jHOQCJR7oyv7Y0MtQuuNgW9 QrhzuDV2KRKo+Wi6peY2DdiAjvIUZcv8EKAFQwnXM3r6R0kIO97g4odNLpsoB8Aupwb/ p7/uYbA3wr9a0k94D00pMs4coDnl9lwpYUobhS6z8rksMSTrIiw+9NrkvEBR3Hox2GIE UJ9Nl9EY9y9dYhKYVp+din0P6uOBCgu7fongTr+Bm/ucBsWvta9q/EOk/CWqFxZ8QeCS 1/hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716002276; x=1716607076; h=content-transfer-encoding:subject:to:from:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=okqk4H0dvzOTecDI4yizeUC9P+FCxABoq5oAPjdWpo4=; b=u+susMbLsS9TO1XwBuprXiO9ra4VOJMtUy2ZVzt9cz03rht/Tk1gkGN1BNDsMofChN BN/slcUpvy+c9MkP2+GgClgPjwSElrndhJDdvVSOh0SSJoceH2Tlr7pTZtYUQ5C4i5nE nxPMXo9pdK5CiTqVJ4O0M7JnDvpl7lOBS9TsNTUwFre8SuSJvNfb8SYX5Lht3R/bULI9 xgg/NFcbrIXIlf8Y10clIltpEGrlp34Y2fR8nAF4cxbbY/AyP+FGXrRnGqrKsICL3wqv PZ4m73cUH9JrKZybwrLvOheGVWvTmFHE1SG/SukggZfCV6L69HO7ytE8AXrZHstuFF0b c92w== X-Gm-Message-State: AOJu0Yz+tB9i/AGH4zPDPedMOW2VvGjv/y9ATJNQlGm9btnHYQbd69IR RO6P917eRJ7HCyP2+gq+Eesqqhrk9Eh1IyWC1anIf3Md/TvBaT14/6cqGg== X-Google-Smtp-Source: AGHT+IFI/t1Z28jaTRurK/DJIA5J2Vgm0i+GrevQguqJhrJN/GOGMfzL/uCFCNNNHEfLyMfYyKsmaQ== X-Received: by 2002:a17:902:fc45:b0:1eb:1d30:64b5 with SMTP id d9443c01a7336-1ef43d170ddmr300727705ad.19.1716002276079; Fri, 17 May 2024 20:17:56 -0700 (PDT) Message-ID: <625e06f9-10ca-4ad3-86e2-6f6edf585ec9@gmail.com> Date: Fri, 17 May 2024 20:17:54 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Collin Funk To: musl@lists.openwall.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [musl] getusershell should ignore comments and empty lines. 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