From d0c47f20a0f5abf8d4c73b8aebca5fb884904d07 Mon Sep 17 00:00:00 2001 From: semarie Date: Wed, 25 Nov 2015 08:56:50 +0000 Subject: [PATCH] add pledge promise "exec" for few cases in xterm in particular if the user use `exec-formatted' or `exec-selectable' actions in key binding. problem reported by jirib at devio dot us. --- app/xterm/main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/xterm/main.c b/app/xterm/main.c index 3601813d7..5fa530644 100644 --- a/app/xterm/main.c +++ b/app/xterm/main.c @@ -2599,9 +2599,22 @@ main(int argc, char *argv[]ENVP_ARG) RequestMaximize(term, True); #endif - if (pledge("stdio rpath wpath cpath id proc tty", NULL) == -1) { - xtermWarning("pledge\n"); - exit(1); + { + String data = NULL; + getKeymapResources(term, "vt100", "VT100", XtRString, &data, sizeof(data)); + if (data && + (strstr(data, "exec-formatted") || strstr(data, "exec-selectable"))) { + + if (pledge("stdio rpath wpath cpath id proc exec tty", NULL) == -1) { + xtermWarning("pledge\n"); + exit(1); + } + } else { + if (pledge("stdio rpath wpath cpath id proc tty", NULL) == -1) { + xtermWarning("pledge\n"); + exit(1); + } + } } for (;;) {