logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0004-Use-external-string-to-cap-function.patch (2145B)


  1. From 1939348d3a1e8238464cd4c52743b04fa52ebed1 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Tue, 4 Jul 2023 19:20:51 -0700
  4. Subject: [PATCH] Use external string-to-cap function
  5. ---
  6. bubblewrap.c | 15 ++++++++++-----
  7. 1 file changed, 10 insertions(+), 5 deletions(-)
  8. diff --git a/bubblewrap.c b/bubblewrap.c
  9. index 608009d..71c8bd0 100644
  10. --- a/bubblewrap.c
  11. +++ b/bubblewrap.c
  12. @@ -30,8 +30,8 @@
  13. #include <sys/eventfd.h>
  14. #include <sys/fsuid.h>
  15. #include <sys/signalfd.h>
  16. -#include <sys/capability.h>
  17. #include <sys/prctl.h>
  18. +#include <linux/capability.h>
  19. #include <linux/sched.h>
  20. #include <linux/seccomp.h>
  21. #include <linux/filter.h>
  22. @@ -44,6 +44,9 @@
  23. #define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace */
  24. #endif
  25. +int capset(void *, void *);
  26. +int capget(void *, void *);
  27. +int cap_from_name(const char *);
  28. /* We limit the size of a tmpfs to half the architecture's address space,
  29. * to avoid hitting arbitrary limits in the kernel.
  30. @@ -2358,7 +2361,7 @@ parse_args_recurse (int *argcp,
  31. }
  32. else if (strcmp (arg, "--cap-add") == 0)
  33. {
  34. - cap_value_t cap;
  35. + int cap;
  36. if (argc < 2)
  37. die ("--cap-add takes an argument");
  38. @@ -2370,7 +2373,8 @@ parse_args_recurse (int *argcp,
  39. }
  40. else
  41. {
  42. - if (cap_from_name (argv[1], &cap) < 0)
  43. + cap = cap_from_name (argv[1]);
  44. + if (cap < 0)
  45. die ("unknown cap: %s", argv[1]);
  46. if (cap < 32)
  47. @@ -2384,7 +2388,7 @@ parse_args_recurse (int *argcp,
  48. }
  49. else if (strcmp (arg, "--cap-drop") == 0)
  50. {
  51. - cap_value_t cap;
  52. + int cap;
  53. if (argc < 2)
  54. die ("--cap-drop takes an argument");
  55. @@ -2396,7 +2400,8 @@ parse_args_recurse (int *argcp,
  56. }
  57. else
  58. {
  59. - if (cap_from_name (argv[1], &cap) < 0)
  60. + cap = cap_from_name (argv[1]);
  61. + if (cap < 0)
  62. die ("unknown cap: %s", argv[1]);
  63. if (cap < 32)
  64. --
  65. 2.37.3