Bug 3497 - setresuid/setresgid configure check may need _GNU_SOURCE
Summary: setresuid/setresgid configure check may need _GNU_SOURCE
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: 9.1p1
Hardware: amd64 Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_9_2
  Show dependency treegraph
 
Reported: 2022-11-06 15:39 AEDT by Sam James
Modified: 2023-03-17 13:42 AEDT (History)
1 user (show)

See Also:


Attachments
config.log.xz (36.55 KB, application/x-xz)
2022-11-06 15:44 AEDT, Sam James
no flags Details
Add -D_GNU_SOURCE (360 bytes, patch)
2022-11-06 18:51 AEDT, Darren Tucker
no flags Details | Diff
config.log.xz (228 bytes, text/plain)
2022-11-06 19:06 AEDT, Sam James
no flags Details
config.log.xz (36.20 KB, application/x-xz)
2022-11-06 19:07 AEDT, Sam James
no flags Details
Fix setres*id tests to work with clang-16 (1.23 KB, patch)
2022-11-07 10:30 AEDT, Darren Tucker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2022-11-06 15:39:39 AEDT
OpenSSH's configure check for setresuid omits _GNU_SOURCE which, on Linux systems with glibc+gcc at least, is needed to expose setresuid.

```
error: call to undeclared function 'setresuid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
```

Reproduced on master of openssh-portable at 6b17e128879ec6cc32ca2c28b5d894b4aa72e32d but originally hit with 9.1_p1.

It's technically harmless, I think, as OpenSSH provides its own implementation if the system's copy is nonexistent or unsuitable, but it's at least noise when trying to find broader Clang 16 issues (see https://lwn.net/Articles/913505/ etc).
Comment 1 Sam James 2022-11-06 15:44:00 AEDT
Created attachment 3620 [details]
config.log.xz
Comment 2 Sam James 2022-11-06 15:49:23 AEDT
Note my config.log has an issue with openpty too but I've filed https://github.com/openssh/openssh-portable/pull/355 for that as it's a simple case.
Comment 3 Sam James 2022-11-06 15:49:57 AEDT
The original bug remains for setresuid and setresgid.
Comment 4 Darren Tucker 2022-11-06 18:51:11 AEDT
Created attachment 3621 [details]
Add -D_GNU_SOURCE

The way we deal with this on other platforms (eg HPUX) is to add the requisite flag to CPPFLAGS in configure like so.  Does this resolve your issue (after running "autoreconf" to regenerate configure)?
Comment 5 Sam James 2022-11-06 19:06:30 AEDT
Created attachment 3622 [details]
config.log.xz
Comment 6 Sam James 2022-11-06 19:07:18 AEDT
Created attachment 3623 [details]
config.log.xz

It doesn't seem to make any difference (I guess because I don't have audit installed and I've not passed any arg for it).

(I've confirmed -D_GNU_SOURCE appears in the generated configure, it's just that the path isn't taken.)
Comment 7 Darren Tucker 2022-11-07 10:30:12 AEDT
Created attachment 3624 [details]
Fix setres*id tests to work with clang-16

There were two problems: I put _GNU_SOURCE in the wrong place, and the tests themselves did not include unistd.h for the prototypes.  This seems to fix both when compiling with a self-built clang/llvm from git.
Comment 8 Darren Tucker 2022-11-07 10:44:05 AEDT
Patch applied and will be in 9.2p1.  Thanks for the report.
Comment 9 Sam James 2022-11-07 15:39:28 AEDT
Confirmed that works great, thank you!
Comment 10 Damien Miller 2023-03-17 13:42:28 AEDT
OpenSSH 9.3 has been released. Close resolved bugs