Xenomai rootless and fixes#4240
Conversation
0856518 to
80527c8
Compare
| static int is_current_user_in_gid(gid_t target_gid) { | ||
| int ngroups = getgroups(0, NULL); |
There was a problem hiding this comment.
Why is the return type not bool?
There was a problem hiding this comment.
is_current_user_in_gid() has -1 on failure, 0 on not member, 1 on member.
It's a bit a mess in rtapi_app_main.cc with the return values. Sometimes 1 is pass, sometimes 0 and sometimes it is bool.
The detect_* functions return 1 on success. For example handle_command() and all commands have -1 on failure, 0 on success.
It would probably make sense to change all detect_* and related functions to bool?
There was a problem hiding this comment.
But you are using it like:
bool isInGid = is_current_user_in_gid(gid) > 0;If this is supposed to distinguish between "user in gid", "user not in gid" or "error condition", then you should actually use the return value to distinguish the cases. However, you add this function and convert its return value to bool. You are not doing anything to distinguish error from not and treat errors like "user not in gid". That is fine by me... But then, my question stands: why is the return value not bool?
There was a problem hiding this comment.
f5316b6 changes all return values to bool in the detect_* code. I think this makes more sense.
is_current_user_in_gid() should never fail so the perror() handling should be enough. According to the man page, a wrong address or wrong size is the only reason and this is verified before. So out of memory is the only remaining reason.
If this fails, everything beaks and there are many error messages. So better abort here.
This allows to run without setuid given the correct group membership and Xenomai access configuration
These functions are used only in if(detect_*) so return type bool makes more sense.
14c9d9f to
f5316b6
Compare
This PR has 3 commits:
This needs libevl >= 59-1 from https://github.com/hdiethelm/xenomai4-linuxcnc where the udev rules are installed. Of course, this can also be done manually. The rules are here: https://github.com/hdiethelm/xenomai4-linuxcnc/blob/lfs/libevl-debian/udev/90-libevl.rules
Tested and works both with Xenomai3 / Xenomai4 EVL.