Browse Source

MenuApplets: Use unveil()

The Clock and Audio applets really only need ("/res", "r") for LibGUI.

The CPUGraph applet also needs ("/proc/all", "r") for reading the CPU
usage data. Somewhat surprisingly, this also adds ("/etc/passwd", "r")
since CProcessStatisticsReader does username lookups.
Andreas Kling 5 years ago
parent
commit
5dd5d5ca4e
3 changed files with 34 additions and 0 deletions
  1. 7 0
      MenuApplets/Audio/main.cpp
  2. 20 0
      MenuApplets/CPUGraph/main.cpp
  3. 7 0
      MenuApplets/Clock/main.cpp

+ 7 - 0
MenuApplets/Audio/main.cpp

@@ -96,6 +96,13 @@ int main(int argc, char** argv)
     window->set_main_widget(widget);
     window->show();
 
+    if (unveil("/res", "r") < 0) {
+        perror("unveil");
+        return 1;
+    }
+
+    unveil(nullptr, nullptr);
+
     if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
         perror("pledge");
         return 1;

+ 20 - 0
MenuApplets/CPUGraph/main.cpp

@@ -117,5 +117,25 @@ int main(int argc, char** argv)
     auto widget = GraphWidget::construct();
     window->set_main_widget(widget);
     window->show();
+
+    if (unveil("/res", "r") < 0) {
+        perror("unveil");
+        return 1;
+    }
+
+    // FIXME: This is required by CProcessStatisticsReader.
+    //        It would be good if we didn't depend on that.
+    if (unveil("/etc/passwd", "r") < 0) {
+        perror("unveil");
+        return 1;
+    }
+
+    if (unveil("/proc/all", "r") < 0) {
+        perror("unveil");
+        return 1;
+    }
+
+    unveil(nullptr, nullptr);
+
     return app.exec();
 }

+ 7 - 0
MenuApplets/Clock/main.cpp

@@ -111,5 +111,12 @@ int main(int argc, char** argv)
     window->set_main_widget(widget);
     window->show();
 
+    if (unveil("/res", "r") < 0) {
+        perror("unveil");
+        return 1;
+    }
+
+    unveil(nullptr, nullptr);
+
     return app.exec();
 }