Explorar o código

Utilities: Add pledge and unveil protections in arp

brapru %!s(int64=4) %!d(string=hai) anos
pai
achega
3bd6905ea8
Modificáronse 1 ficheiros con 16 adicións e 0 borrados
  1. 16 0
      Userland/Utilities/arp.cpp

+ 16 - 0
Userland/Utilities/arp.cpp

@@ -16,9 +16,25 @@
 #include <netinet/in.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <unistd.h>
 
 int main(int argc, char** argv)
 {
+    if (pledge("stdio rpath tty", nullptr) < 0) {
+        perror("pledge");
+        return 1;
+    }
+
+    if (unveil("/proc/net/arp", "r") < 0) {
+        perror("unveil");
+        return 1;
+    }
+
+    if (unveil(nullptr, nullptr) < 0) {
+        perror("unveil");
+        return 1;
+    }
+
     static bool flag_set;
     static bool flag_delete;
     const char* value_ipv4_address = nullptr;