Bug 365934 - KWayland can't build under strict POSIX systems: uid_t, gid_t undeclared
Summary: KWayland can't build under strict POSIX systems: uid_t, gid_t undeclared
Status: RESOLVED FIXED
Alias: None
Product: kwayland
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.5.5
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: Martin Flöser
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-21 10:17 UTC by A. Wilcox (awilfox)
Modified: 2016-08-03 06:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Add #include <sys/types.h> to clientconnection.h (331 bytes, patch)
2016-07-21 10:17 UTC, A. Wilcox (awilfox)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description A. Wilcox (awilfox) 2016-07-21 10:17:17 UTC
uid_t, gid_t, and pid_t are defined in either <unistd.h> or <sys/types.h> under POSIX.

This becomes relevant on strictly compliant systems such as the musl libc, and will continue to be a problem in the future as more C libraries clean up their headers.  I have personally chosen to #include <sys/types.h> in clientconnection.h, but <unistd.h> is also valid.

Reproducible: Always

Steps to Reproduce:
1. Use a strictly conformant POSIX system (such as musl libc).
2. Attempt to build KWayland.

Actual Results:  
/usr/src/kde-frameworks/kwayland-5.5.5/work/kwayland-5.5.5/src/server/clientconnection.h:100:5: error: ‘uid_t’ does not name a type
     uid_t userId() const;
     ^
/usr/src/kde-frameworks/kwayland-5.5.5/work/kwayland-5.5.5/src/server/clientconnection.h:109:5: error: ‘gid_t’ does not name a type
     gid_t groupId() const;
     ^

Expected Results:  
Successful build.
Comment 1 A. Wilcox (awilfox) 2016-07-21 10:17:44 UTC
Created attachment 100229 [details]
Add #include <sys/types.h> to clientconnection.h
Comment 2 Martin Flöser 2016-07-21 11:31:20 UTC
Is that also going to work with e.g. FreeBSD. The last time I had integrated a fix for more "strict" compilers, it broke on BSDs. So I'm sceptical ;-)
Comment 3 A. Wilcox (awilfox) 2016-07-22 00:37:00 UTC
I appreciate your scepticism, however, I can't really test this patch on FreeBSD...

root@renton:~/kwayland-5.5.5/build # uname -a
FreeBSD renton.foxkit.us 10.2-RELEASE-p9 FreeBSD 10.2-RELEASE-p9 #0: Thu Jan 14 01:32:46 UTC 2016     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
root@renton:~/kwayland-5.5.5/build # gmake
[  1%] Automatic moc for target KF5WaylandClient
[  1%] Built target KF5WaylandClient_automoc
[  1%] Building CXX object src/client/CMakeFiles/KF5WaylandClient.dir/fakeinput.cpp.o
/root/kwayland-5.5.5/src/client/fakeinput.cpp:27:10: fatal error: 'linux/input.h' file not found
#include <linux/input.h>
         ^
1 error generated.
Comment 4 Elizabeth Myers 2016-07-28 00:41:40 UTC
If I may throw my hat into the ring, the synopsis for the manual page for getpid(2) on Linux and FreeBSD both say that you should include both sys/types.h and unistd.h.

Also, regarding BSD compatibility, I think it goes without saying even a non-programmer can tell including a linux/*.h header makes your code inherently incompatible :p. Input injection (which I presume is the goal here) is probably possible on FreeBSD in some way, but I am not entirely sure how to achieve it without research.

In any case, assuming there is legitimate desire for BSD support, I believe sys/types.h is required on BSD for uid_t and gid_t (though the manpage for getpgid(2) implies pid_t should be found in unistd.h on BSD).
Comment 5 Martin Flöser 2016-08-03 06:40:04 UTC
This was already fixed in May with 1d531e997bfc1b0d30fdded7a01473570eda1de5.