0003-libcap-cap_file.c-fix-build-with-old-kernel-headers.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From ace694e9574eb38e07cfe0db235434eb40003f47 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Mon, 14 Mar 2016 22:39:15 +0100
  4. Subject: [PATCH] libcap/cap_file.c: fix build with old kernel headers
  5. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  6. ---
  7. libcap/cap_file.c | 27 +++++++++++++++++++++++++++
  8. 1 file changed, 27 insertions(+)
  9. diff --git a/libcap/cap_file.c b/libcap/cap_file.c
  10. index 40756ea..e3d54dd 100644
  11. --- a/libcap/cap_file.c
  12. +++ b/libcap/cap_file.c
  13. @@ -23,6 +23,33 @@ extern int fsetxattr(int, const char *, const void *, size_t, int);
  14. extern int removexattr(const char *, const char *);
  15. extern int fremovexattr(int, const char *);
  16. +
  17. +/*
  18. + * Old kernels (before 2.6.36) were defining XATTR_NAME_CAPS in
  19. + * <linux/capability.h>, but using XATTR_SECURITY_PREFIX and
  20. + * XATTR_CAPS_SUFFIX which were defined in the kernel-only part of
  21. + * <linux/xattr.h>.
  22. + *
  23. + * In kernel 2.6.36 (commit af4f136056c984b0aa67feed7d3170b958370b2f),
  24. + * the XATTR_NAME_CAPS definition was moved to the kernel-only part of
  25. + * <linux/xattr.h>. It's only in kernel 3.0 (commit
  26. + * 1dbe39424a43e56a6c9aed12661192af51dcdb9f) that <linux/xattr.h> was
  27. + * fixed to expose XATTR_NAME_CAPS and the related definitions to
  28. + * userspace.
  29. + *
  30. + * In order to cope with kernels < 3.0, we define here the appropriate
  31. + * values, which we assume haven't changed over history.
  32. + */
  33. +#ifndef XATTR_CAPS_SUFFIX
  34. +#define XATTR_CAPS_SUFFIX "capability"
  35. +#endif
  36. +#ifndef XATTR_SECURITY_PREFIX
  37. +#define XATTR_SECURITY_PREFIX "security."
  38. +#endif
  39. +#ifndef XATTR_NAME_CAPS
  40. +#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
  41. +#endif
  42. +
  43. #include "libcap.h"
  44. #ifdef VFS_CAP_U32
  45. --
  46. 2.6.4