Thread (5 messages) 5 messages, 3 authors, 2025-02-17

Re: [musl] Re: [shadow-maint/shadow] Add cheap defense mechanisms (PR #1171)

From: Rich Felker <dalias@libc.org>
Date: 2025-02-17 15:00:15

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:
quoted
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).
quoted
Isn't it safe to use constructs like 
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help