diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-08-11 18:18:36 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-11 18:21:40 -0700 |
commit | d51bc877f40d2acbf5b83895f636186c87463ab1 (patch) | |
tree | a3dcf26bcd3f05994df22cd359b2b4ac6503da55 /test/util/capability_util.h | |
parent | a50596874a4971167f97a05181363e91292a2885 (diff) |
Run packet socket tests on Fuchsia
+ Do not check for CAP_NET_RAW on Fuchsia
Fuchsia does not support capabilities the same way Linux does. Instead
emulate the check for CAP_NET_RAW by checking if a packet socket may
be created.
Bug: https://fxbug.dev/79016, https://fxbug.dev/81592
PiperOrigin-RevId: 390263666
Diffstat (limited to 'test/util/capability_util.h')
-rw-r--r-- | test/util/capability_util.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/util/capability_util.h b/test/util/capability_util.h index f5d622e2d..318a43feb 100644 --- a/test/util/capability_util.h +++ b/test/util/capability_util.h @@ -18,11 +18,29 @@ #define GVISOR_TEST_UTIL_CAPABILITY_UTIL_H_ #if defined(__Fuchsia__) -#include "test/util/fuchsia_capability_util.h" +// Nothing to include. #elif defined(__linux__) #include "test/util/linux_capability_util.h" #else #error "Unhandled platform" #endif +namespace gvisor { +namespace testing { + +// HaveRawIPSocketCapability returns whether or not the process has access to +// raw IP sockets. +// +// Returns an error when raw IP socket access cannot be determined. +PosixErrorOr<bool> HaveRawIPSocketCapability(); + +// HavePacketSocketCapability returns whether or not the process has access to +// packet sockets. +// +// Returns an error when packet socket access cannot be determined. +PosixErrorOr<bool> HavePacketSocketCapability(); + +} // namespace testing +} // namespace gvisor + #endif // GVISOR_TEST_UTIL_CAPABILITY_UTIL_H_ |