浏览代码

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 年之前
父节点
当前提交
2f880a047f
共有 1 个文件被更改,包括 10 次插入0 次删除
  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);