Guest User

Untitled

a guest
Oct 4th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1. #define _DEFAULT_SOURCE         /* for setgroups(2) */
  2.  
  3. #include <Python.h>
  4.  
  5. /*
  6.  * Verify that Python.h defined _GNU_SOURCE, which is required for setresuid(2)
  7.  * and setresgid(2).  Defining it before including Python.h will cause a
  8.  * diagnostic:
  9.  *
  10.  *  warning: "_GNU_SOURCE" redefined
  11.  *
  12.  * So we rely on Python.h to define it, but verify that it actually did so.
  13.  */
  14.  
  15. #ifndef _GNU_SOURCE         /* setresuid(2) & setresgid(2) */
  16. #error  Python.h did not define _GNU_SOURCE
  17. #endif
  18.  
  19. #include <grp.h>
  20. #include <sys/capability.h>
  21. #include <sys/prctl.h>
  22. #include <sys/types.h>
  23.  
  24. #include <errno.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27.  
  28. /*
  29.  * Verify that we've got the GNU-specific version of strerror_r(3)
  30.  */
  31.  
  32. #pragma GCC diagnostic push
  33. #pragma GCC diagnostic ignored "-Wunused-variable"
  34. #pragma GCC diagnostic error "-Wincompatible-pointer-types"
  35. __attribute__((unused))
  36. static inline void check_for_gnu_strerror_r(void)
  37. {
  38.     /*
  39.     * If this causes an 'incompatible pointer type' error, strerror_r is
  40.     * the XSI-compliant version; we need the GNU-specific version.  See
  41.     * strerror_r(3).
  42.     */
  43.     char *(*foo)(int, char *, size_t) = strerror_r;
  44. }
  45. #pragma GCC diagnostic pop
Advertisement
Add Comment
Please, Sign In to add comment