Line data Source code
1 : /* 2 : * lwan - web server 3 : * Copyright (c) 2018 L. A. F. Pereira <l@tia.mat.br> 4 : * 5 : * This program is free software; you can redistribute it and/or 6 : * modify it under the terms of the GNU General Public License 7 : * as published by the Free Software Foundation; either version 2 8 : * of the License, or any later version. 9 : * 10 : * This program is distributed in the hope that it will be useful, 11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 : * GNU General Public License for more details. 14 : * 15 : * You should have received a copy of the GNU General Public License 16 : * along with this program; if not, write to the Free Software 17 : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 : * USA. 19 : */ 20 : 21 : #ifndef __MISSING_CAPABILITY_H__ 22 : #define __MISSING_CAPABILITY_H__ 23 : 24 : #if defined(__linux__) && defined(LWAN_HAVE_LINUX_CAPABILITY) 25 : 26 : #include_next <linux/capability.h> 27 : #include <stdio.h> 28 : #include <sys/syscall.h> 29 : #include <unistd.h> 30 : 31 87 : static inline int capset(struct __user_cap_header_struct *header, 32 : struct __user_cap_data_struct *data) 33 : { 34 : #if defined(SYS_capset) 35 87 : return (int)syscall(SYS_capset, header, data); 36 : #else 37 : return 0; 38 : #endif 39 : } 40 : 41 : #else 42 : struct __user_cap_data_struct { 43 : unsigned int effective, permitted, inheritable; 44 : }; 45 : 46 : struct __user_cap_header_struct { 47 : #define _LINUX_CAPABILITY_VERSION_1 0 48 : unsigned int version; 49 : int pid; 50 : }; 51 : 52 : int capset(struct __user_cap_header_struct *header, 53 : struct __user_cap_data_struct *data); 54 : 55 : #endif 56 : 57 : #endif /* __MISSING_CAPABILITY_H__ */