From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22163 invoked from network); 16 May 2023 12:18:47 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 16 May 2023 12:18:47 -0000 Received: (qmail 18400 invoked by uid 550); 16 May 2023 12:18:44 -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 9978 invoked from network); 16 May 2023 12:03:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1684238570; bh=7LV/qoOBaAU5QELXv4NJMxFQmDoednu8z1eSjK/kZzA=; h=Date:From:To:Subject:From; b=NmZhyXsurvdHdTI+xVP3zHWcWvyzvyjs+CyutnOvvb4ecJEgC+zfOiDv8/8qbmk5Z ct4ClkE2gf5J4+63844EDhmMzMYfnnvPo0G4zyBCCCc+45nXb6JgwU7YPq94RI8vxH O3GTuZMuQ5J46bUkc/nPrX2v8gogy1YrW+bicll4= X-Riseup-User-ID: CE013BAB0FE89A23BF3461B71EE25FB802E0B0793054F01EAA8847D2A8BB6E9A Date: Tue, 16 May 2023 12:02:39 +0000 From: Samanta Navarro To: musl@lists.openwall.com Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [musl] [PATCH] getusershell: Only return absolute paths Also strip comments to be compatible with other getusershell implementations (glibc, *BSD). Running `chsh -l` of util-linux built with musl is effectively a `cat /etc/shells`. Signed-off-by: Samanta Navarro --- src/legacy/getusershell.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/legacy/getusershell.c b/src/legacy/getusershell.c index 5fecdec2..81e872df 100644 --- a/src/legacy/getusershell.c +++ b/src/legacy/getusershell.c @@ -1,5 +1,6 @@ #define _GNU_SOURCE #include +#include #include static const char defshells[] = "/bin/sh\n/bin/csh\n"; @@ -22,11 +23,12 @@ void setusershell(void) char *getusershell(void) { - ssize_t l; if (!f) setusershell(); if (!f) return 0; - l = getline(&line, &linesize, f); - if (l <= 0) return 0; - if (line[l-1]=='\n') line[l-1]=0; + do { + ssize_t l = getline(&line, &linesize, f); + if (l <= 0) return 0; + } while (line[0] != '/'); + line[strcspn(line, "#\n")] = 0; return line; } -- 2.40.1