0014-core-adbd-adb.c-open-code-capset.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 850fd3f4a0384ebe492a466a9b1149060619aacb Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sun, 14 Jul 2024 12:57:22 +0200
  4. Subject: [PATCH] core/adbd/adb.c: open code capset()
  5. capset() is apparently implemented by C libraries (at least glibc and
  6. musl), but not exposed through a header as an official public API.
  7. In addition capset(2) says:
  8. Note: glibc provides no wrappers for these system calls,
  9. necessitating the use of syscall(2)
  10. The lack of a header with a prototype for capset() was not causing any
  11. problem so far, but GCC 14.x has become stricter on implicit
  12. declarations, causing the build to fail with:
  13. core/adbd/adb.c:1296:9: error: implicit declaration of function 'capset' [-Wimplicit-function-declaration]
  14. So fix that by open-coding it using syscall() as suggested by the man
  15. page.
  16. Upstream: N/A, we're too far from upstream
  17. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  18. ---
  19. core/adbd/adb.c | 3 ++-
  20. 1 file changed, 2 insertions(+), 1 deletion(-)
  21. diff --git a/core/adbd/adb.c b/core/adbd/adb.c
  22. index 7fe6445..98b1de1 100644
  23. --- a/core/adbd/adb.c
  24. +++ b/core/adbd/adb.c
  25. @@ -41,6 +41,7 @@
  26. #if !ADB_HOST
  27. #include "android_filesystem_config.h"
  28. #include <linux/capability.h>
  29. +#include <sys/syscall.h>
  30. #include <linux/prctl.h>
  31. #include <sys/mount.h>
  32. #else
  33. @@ -1293,7 +1294,7 @@ int adb_main(int is_daemon, int server_port)
  34. header.pid = 0;
  35. cap[CAP_TO_INDEX(CAP_SYS_BOOT)].effective |= CAP_TO_MASK(CAP_SYS_BOOT);
  36. cap[CAP_TO_INDEX(CAP_SYS_BOOT)].permitted |= CAP_TO_MASK(CAP_SYS_BOOT);
  37. - capset(&header, cap);
  38. + syscall(SYS_capset, &header, cap);
  39. D("Local port disabled\n");
  40. } else {
  41. --
  42. 2.47.0