Skip to content

Commit

Permalink
Use pledge(2)
Browse files Browse the repository at this point in the history
Drop "proc exec" and other promises never needed as early as possible.
More delicate unveil(2) bits come next.
  • Loading branch information
klemensn committed Aug 6, 2023
1 parent bf9fdb7 commit cff2767
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion security/web-eid-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GH_PROJECT = web-eid-app
GH_TAGNAME = v2.3.1
DISTFILES = ${GH_DISTFILE}
PKGNAME-main = ${PKGNAME:S/app/native/}
REVISION-main = 0
REVISION-main = 1
PKGNAME-chrome = ${PKGNAME:S/app/chrome/}
REVISION-chrome = 0

Expand Down Expand Up @@ -52,6 +52,7 @@ HOMEPAGE = https://web-eid.eu/
# -std=gnu++17
COMPILER = base-clang ports-gcc

# uses pledge()
WANTLIB-main += ${COMPILER_LIBCXX} GL Qt6Core Qt6Gui Qt6Network Qt6Widgets
WANTLIB-main += c crypto m pcsclite

Expand Down
39 changes: 39 additions & 0 deletions security/web-eid-app/patches/patch-src_app_main_cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Use pledge(2) after QApplication[0] initialisation (uses shmget(2) not
covered by pledge) and before execution, covering both CLI and GUI mode.

Index: src/app/main.cpp
--- src/app/main.cpp.orig
+++ src/app/main.cpp
@@ -24,6 +24,10 @@
#include "controller.hpp"
#include "logging.hpp"

+#ifdef Q_OS_OPENBSD
+#include <unistd.h>
+#endif // Q_OS_OPENBSD
+
#include <QTimer>

int main(int argc, char* argv[])
@@ -32,6 +36,21 @@ int main(int argc, char* argv[])
Q_INIT_RESOURCE(translations);

Application app(argc, argv, QStringLiteral("web-eid"));
+
+#ifdef Q_OS_OPENBSD
+ // "rpath cpath wpath" Qt owns web-eid's config and log directories
+ // "inet dns" web-eid talks to the internet
+ // "fattr flock ps" Qt locks file access, sysctl(2) KERN_PROC_PID from QLockFile
+ // "unix" web-eid and Qt communicate with PCSC and D-Bus
+ // "prot_exec" Qt dlopen(3) libqsvg.so
+ //
+ // src/controller/application.cpp Application::isDarkTheme() has code under
+ // '#elif 0' (the only QProcess occurence in web-eid) that would need "proc exec".
+ if (pledge("stdio rpath cpath wpath inet fattr flock unix dns prot_exec ps", NULL) == -1) {
+ std::cerr << "pledge: " << strerror(errno) << std::endl;
+ return -1;
+ }
+#endif // Q_OS_OPENBSD

try {
Controller controller(app.parseArgs());

0 comments on commit cff2767

Please sign in to comment.