Forráskód Böngészése

Browser: Use pledge()

This is the first complex app to use pledge(), and it was extremely
easy to get it working.

The main trickiness comes from the RPC sockets that get set up inside
the GApplication constructor. Since it wants to unlink any old RPC
socket with the same filename and change the file mode of the new
socket, it needs both "cpath" and "fattr".

Once the GApplication has been constructed, it seems we can safely
drop those promises. Pretty cool!
Andreas Kling 5 éve
szülő
commit
2f880a047f
1 módosított fájl, 10 hozzáadás és 0 törlés
  1. 10 0
      Applications/Browser/main.cpp

+ 10 - 0
Applications/Browser/main.cpp

@@ -30,8 +30,18 @@ static const char* home_url = "file:///home/anon/www/welcome.html";
 
 int main(int argc, char** argv)
 {
+    if (pledge("stdio dns unix shared_buffer cpath rpath fattr", nullptr) < 0) {
+        perror("pledge");
+        return 1;
+    }
+
     GApplication app(argc, argv);
 
+    if (pledge("stdio dns unix shared_buffer rpath", nullptr) < 0) {
+        perror("pledge");
+        return 1;
+    }
+
     auto window = GWindow::construct();
     window->set_rect(100, 100, 640, 480);