Skip to content

libaudit: fix includes for musl once again#491

Merged
stevegrubb merged 1 commit intolinux-audit:masterfrom
LordGrimmauld:musl-compat-basename
Jul 31, 2025
Merged

libaudit: fix includes for musl once again#491
stevegrubb merged 1 commit intolinux-audit:masterfrom
LordGrimmauld:musl-compat-basename

Conversation

@LordGrimmauld
Copy link
Contributor

with glibc, basename is provided by string.h. However, musl exposes basename only in libgen.h.

In glibc libgen.h, there is this warning:

/* Return final component of PATH.

   This is the weird XPG version of this function.  It sometimes will
   modify its argument.  Therefore we normally use the GNU version (in
   <string.h>) and only if this header is included make the XPG
   version available under the real name.  */
extern char *__xpg_basename (char *__path) __THROW;
#define basename	__xpg_basename

This makes that version of basename probably a bad default. As far as i can tell, this is not an issue on musl. Hence, only fall back to libgen.h if basename is not yet defined.

@LordGrimmauld
Copy link
Contributor Author

Alternatively this could become unconditional: Various things already use basename from libgen.h, such as:

#include <libgen.h>

#include <libgen.h>

#include <libgen.h> /* For basename */

So if the verdict is to make it unconditional like in the other places, i am fine with that too. Not my call to make, i tried to be conservative here.

@stevegrubb
Copy link
Contributor

The man page says to include libgen.h. So, I think it can be unconditional.

@LordGrimmauld LordGrimmauld force-pushed the musl-compat-basename branch from c2a75b2 to cc8752f Compare July 31, 2025 18:05
@LordGrimmauld
Copy link
Contributor Author

fair enough, i made it unconditional

@stevegrubb stevegrubb merged commit 979f855 into linux-audit:master Jul 31, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants