llvm-project
llvm-project copied to clipboard
[libc] Implement `capget` and `capset` syscall wrappers
Implement https://man7.org/linux/man-pages/man2/capset.2.html wrappers. The manpage mentioned that it was not provided by glibc but MUSL implement them as an extension:
https://github.com/bminor/musl/blob/f314e133929b6379eccc632bef32eaebb66a7335/src/linux/cap.c#L8
This is helpful in #79645.
@SchrodingerZhu hello! Could you give me a few pointers on where the code has to be placed? I can implement the wrappers, but I am unable to judge where to place them.
sys/capability.h may be a good place to go. I am little bit concerned that we may conflict with libcap. @nickdesaulniers
ah, that man page says:
The portable interfaces are cap_set_proc(3) and cap_get_proc(3); if possible, you should use those interfaces in applications;
Perhaps it would be better to implement those instead.
Perhaps it would be better to implement those instead.
In sys/capability.h, if I am not wrong?
I have a small doubt here. Neither glibc nor musl implement cap_set_proc() and cap_get_proc(), and musl only implements capget() and capset() just because of the simplicity of their implementation. As libcap already implements all of the capability functionality, would this not cause conflicts? One can simply link to libcap.
@SchrodingerZhu @nickdesaulniers?
Yeah, the more I look into these APIs, the less interested I am in having implementations for them.
Perhaps we can instead rethink the use of SYS_capget in libc/test/src/sys/mman/linux/mlock_test.cpp ?
@nickdesaulniers capget may be useful to have. For example, sched related tests may also want to check capabilities.