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 995F922216 for ; Thu, 23 May 2024 15:59:57 +0200 (CEST) Received: (qmail 22264 invoked by uid 550); 23 May 2024 13:59:53 -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 22225 invoked from network); 23 May 2024 13:59:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716472784; x=1717077584; darn=lists.openwall.com; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=H9fFMW6rj+QDELiMAkqkXh3+NM2ZFncaT+tGOyTYAd8=; b=c5yc6VCMBwedpInsr3YxyuW/DHSaeSW0t/9bottN+MJc0J6rJOHhF6qXTaVSwoU2ml e2JFxeS7Yzgba/9JRklZi9FUYV6/Zou+JAEJPrrVKreq+Uali7Sn9qlpFKo9IiN1WgVz IZWJEQu2fGBlDqb5Xoeer/d6dpfUNhnIS9DRu5/eNDQf+WBKI1g2Wlfjm+bFwyH+y5Hh 1IYZ4w/cip/9RSB8/26hO1ufJ+LjCj8EHDx0NeBQIQBls57KQzUueIkSEXlw7X6p/k4b nO3DXyKLACcG/7+EMk0xH7bCm4ct1poWXilQhUd4MuqeaJ/tfSkyuYaXPAkoFgc5DKIG bXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716472784; x=1717077584; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H9fFMW6rj+QDELiMAkqkXh3+NM2ZFncaT+tGOyTYAd8=; b=K6c0QwEX8DiRoBZUIvsnC4dwDSHiL2+v8eykQCHsCVpqcLbHICCTHT7xrKCk7EY6OV 9k4hY18Mjt+WRvvcSirVKtCu/45Ubw6Wc9DqQ9r/8/o65iXXK59/EfItuzVkl80MndRE ND18BWP3iekOksSmNwbkup3yndbRpxo9GuGvxzOWOsAhWKkkxaQZ9jN2J+6oNm5e4Lc1 Wqz1SMXgSUS87lyM1yoir9TaLWNZ8SPiv9MzkXUkWyqF7ngiiM+f3HJ+4teFejp1GjAS WeQFyh65b4rqFrO567Jv2wZvAIZFpLI534rGiuLvHCT8MXrfOTzPYKhije9XFgZ6/Uj2 G3jg== X-Gm-Message-State: AOJu0Yz4QWfgE83bP3HT9+CnG5/fgUkkYTxql1YrKJD1oECtNgbt9zta zJ9Fu1/ZeiN1E5RZCHaac1dLGZNZ+gvstLm/ejITKx684VoGKvqt X-Google-Smtp-Source: AGHT+IESUMY0lf4KA73QNjWMCJJojvfNCOJTcEAAFY881owKausb/S90/A3d4LKgMZ8JU8YPcfcKBA== X-Received: by 2002:a17:902:6505:b0:1f3:2c60:1716 with SMTP id d9443c01a7336-1f32c6017d8mr37255585ad.40.1716472783918; Thu, 23 May 2024 06:59:43 -0700 (PDT) Message-ID: Date: Thu, 23 May 2024 06:59:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Leah Neukirchen , Rich Felker Cc: musl@lists.openwall.com References: <625e06f9-10ca-4ad3-86e2-6f6edf585ec9@gmail.com> <20240523132117.GZ10433@brightrain.aerifal.cx> <87pltc63rt.fsf@vuxu.org> Content-Language: en-US From: Collin Funk In-Reply-To: <87pltc63rt.fsf@vuxu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [musl] 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