From: Alejandro Colomar <alx@kernel.org>
To: Rich Felker <dalias@libc.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 16:08:02 +0100 [thread overview]
Message-ID: <bdle6p2ohjckvb7wwwquj27wen65zzzz73eqahbuntfdf7xquu@5yaobuvf6yos> (raw)
In-Reply-To: <20250217143829.GA1827@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]
Hi Rich,
On Mon, Feb 17, 2025 at 09:44:58AM -0500, Rich Felker wrote:
> It's in the latest POSIX and we have supported it for a long time as
> POSIX-future (since 2012/release 0.9.7).
Thanks! That agrees with my own research.
> > > 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.
Makes sense. Thanks!
> 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.
Hmmm, thanks for the idea! This code is old, so we didn't actually
write it; we only added 'e' recently to it. If we need to write new
code, I'll take into consideration doing that as a two-step process,
maybe adding a wrapper around that process.
Have a lovely day!
Alex
> 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.
No problem. Thanks!
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2025-02-17 15:07 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
2025-02-17 15:05 ` Evgeny Grin
2025-02-17 15:08 ` Alejandro Colomar [this message]
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=bdle6p2ohjckvb7wwwquj27wen65zzzz73eqahbuntfdf7xquu@5yaobuvf6yos \
--to=alx@kernel.org \
--cc=dalias@libc.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).