mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Alejandro Colomar <alx@kernel.org>
Cc: libc-help@sourceware.org, linux-man@vger.kernel.org,
	Karlson2k <k2k@narod.ru>,
	Tobias Stoeckmann <tobias@stoeckmann.org>,
	Serge Hallyn <serge@hallyn.com>,
	Iker Pedrosa <ipedrosa@redhat.com>,
	musl@lists.openwall.com
Subject: Re: [musl] Re: [shadow-maint/shadow] Add cheap defense mechanisms (PR #1171)
Date: Mon, 17 Feb 2025 09:44:58 -0500	[thread overview]
Message-ID: <20250217143829.GA1827@brightrain.aerifal.cx> (raw)
In-Reply-To: <p6zqecnj4czocoksbicabvp3ec4sgicejct6nhuq4mccisemig@2i3dhnffkav5>

On Mon, Feb 17, 2025 at 10:42:06AM +0100, Alejandro Colomar wrote:
> Hi,
> 
> On Sun, Feb 16, 2025 at 06:15:18PM -0800, Karlson2k wrote:
> > Karlson2k left a comment (shadow-maint/shadow#1171)
> > 
> > Doesn't use of glibc extensions break functioning with non-glibc, like musl?
> 
> Hmmm, I didn't know musl doesn't support this.  It would be interesting
> to get them to support it.  I've CCd several interested parties in this
> email.

It's in the latest POSIX and we have supported it for a long time as
POSIX-future (since 2012/release 0.9.7).

> > Isn't it safe to use constructs like 
> > ``` C
> > shadow = fopen (SGROUP_FILE, "re");
> > if (NULL == shadow )
> >   shadow = fopen (SGROUP_FILE, "r");
> > ```
> > ?

Unfortunately this doesn't work because it's UB to pass any modes but
the standards-specified ones.

In any case use of fopen is just gratuitously bad for software that
targets POSIX. The right way to do things is a two-step open+fdopen.
This avoids needing to depend on new features to open and lets you use
all the modern open flags, openat if needed, etc.

Rich


P.S. Had to omit shadow-utils <~hallyn/shadow@lists.sr.ht> from CC
because my mail software rejects / in an address... gotta fix that.
Apologies.

  parent reply	other threads:[~2025-02-17 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <shadow-maint/shadow/pull/1171@github.com>
     [not found] ` <shadow-maint/shadow/pull/1171/c2661802270@github.com>
2025-02-17  9:42   ` Alejandro Colomar
2025-02-17 13:43     ` Alejandro Colomar
2025-02-17 14:44     ` Rich Felker [this message]
2025-02-17 15:05       ` Evgeny Grin
2025-02-17 15:08       ` Alejandro Colomar

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=20250217143829.GA1827@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=alx@kernel.org \
    --cc=ipedrosa@redhat.com \
    --cc=k2k@narod.ru \
    --cc=libc-help@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=musl@lists.openwall.com \
    --cc=serge@hallyn.com \
    --cc=tobias@stoeckmann.org \
    /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).