[Bug 216168] New: updwtmp(3) doesn't mention need for _GNU_SOURCE for updwtmpx

bugzilla-daemon
2022-06-24T02:43:03Z

Bug ID: 216168
Summary: updwtmp(3) doesn't mention need for _GNU_SOURCE for
updwtmpx
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: man-pages
Assignee: documentation_man-pages@kernel-bugs.osdl.org
Reporter: sam@gentoo.org
Regression: No

I think utmpxh's updwtmpx might need _GNU_SOURCE to be defined to be usable?

Noticed when investigating a warning when building gdm 42.0:
```
../gdm-42.0/daemon/gdm-session-record.c:200:9: error: implicit declaration of
function ‘updwtmpx’; did you mean ‘updwtmp’?
[-Werror=implicit-function-declaration]
updwtmpx (GDM_NEW_SESSION_RECORDS_FILE, &session_record);
```

... but:
```
#if defined(HAVE_UTMPX_H)
#include <utmpx.h>
#endif

#if defined(HAVE_UTMP_H)
#include <utmp.h>
#endif
```

And config.h, set by Meson, contains HAVE_UTMPX_H, HAVE_UTMP_H, HAVE_UPDWTMP,
HAVE_UPDWTMPX.

From looking at glibc-2.35's /usr/include/utmpx.h, I think it might need
_GNU_SOURCE? It's guarded by __USE_GNU within glibc headers:
```
[..]
#ifdef __USE_GNU
/* Change name of the utmpx file to be examined.

This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int utmpxname (const char *__file);
[...]
/* Append entry UTMP to the wtmpx-like file WTMPX_FILE.

This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern void updwtmpx (const char *__wtmpx_file,
const struct utmpx *__utmpx);
[...]
```

Aside: a friend points out that NetBSD needs NETBSD_SOURCE defined for it too: