Bug 216168 - updwtmp(3) doesn't mention need for _GNU_SOURCE for updwtmpx
Summary: updwtmp(3) doesn't mention need for _GNU_SOURCE for updwtmpx
Status: RESOLVED DOCUMENTED
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-24 02:42 UTC by Sam James
Modified: 2022-07-03 18:27 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Sam James 2022-06-24 02:42:55 UTC
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: https://github.com/NetBSD/src/blob/6c9d506c6146a69f3807ce59b4c063792ef32829/include/utmpx.h#L143.
Comment 1 Sam James 2022-06-24 02:45:59 UTC
FWIW, Gnulib indeed (as the man page hints) that it is a glibc extension: https://www.gnu.org/software/gnulib/manual/gnulib.html#updwtmpx.
Comment 2 Sam James 2022-06-24 05:09:35 UTC
Sent patch to ML: https://marc.info/?l=linux-man&m=165603977710424&w=2.

Suppose the commit message should be more detailed but I'll wait for someone to tell me if this is even right first :)
Comment 3 Alejandro Colomar 2022-07-03 18:27:34 UTC
Hi Sam,

Sorry for the delay; I read your posts, but didn't have much time to reply.  Yes, normally I'd ask for a more detailed commit message, but since it is very obvious to me that it's correct from this bugzilla report (and also from the glibc code), and there's a link to this issue in the commit, I think it's OK as is the patch.

Thanks!

Alex

Note You need to log in before you can comment on or make changes to this bug.