2023-08-29 04:24:26 -04:00
|
|
|
#ifndef _HAPROXY_LINUXCAP_H
|
|
|
|
|
#define _HAPROXY_LINUXCAP_H
|
2024-05-31 12:01:07 -04:00
|
|
|
#include <syscall.h>
|
|
|
|
|
#include <linux/capability.h>
|
2023-08-29 04:24:26 -04:00
|
|
|
|
2024-06-21 12:11:46 -04:00
|
|
|
#define CAPS_TO_ULLONG(low, high) (((ullong)high << 32) | (ullong)low)
|
|
|
|
|
|
2024-05-31 12:01:07 -04:00
|
|
|
/* for haproxy process itself, allocate this 8 byte-size struct only once in
|
|
|
|
|
* .data and makes it accessible from other compile-units, because we always
|
|
|
|
|
* fill it with the same values and because we could use it to collect
|
|
|
|
|
* capabilities for post_mortem debug info.
|
|
|
|
|
*/
|
|
|
|
|
extern struct __user_cap_header_struct cap_hdr_haproxy;
|
|
|
|
|
|
|
|
|
|
/* provided by sys/capability.h on some distros, declared here, as could be used
|
|
|
|
|
* in debug.c, in order to collect info about process capabilities before
|
|
|
|
|
* applying its configuration and at runtime.
|
|
|
|
|
*/
|
|
|
|
|
static inline int capget(cap_user_header_t hdrp, const cap_user_data_t datap)
|
|
|
|
|
{
|
|
|
|
|
return syscall(SYS_capget, hdrp, datap);
|
|
|
|
|
}
|
2023-08-29 04:24:26 -04:00
|
|
|
int prepare_caps_for_setuid(int from_uid, int to_uid);
|
|
|
|
|
int finalize_caps_after_setuid(int from_uid, int to_uid);
|
2024-11-21 11:24:37 -05:00
|
|
|
int prepare_caps_from_permitted_set(int from_uid, int to_uid);
|
2023-08-29 04:24:26 -04:00
|
|
|
|
|
|
|
|
#endif /* _HAPROXY_LINUXCAP_H */
|