diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2021-09-02 09:31:39 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2021-09-02 09:31:39 +0000 |
commit | 71e61894e81ddcf7dd4afcb1c918697d36d90a39 (patch) | |
tree | cf9d083d96c7ac3141b43acc50942197d8878dc4 /app/xterm | |
parent | 6d84d2b88a64c494777b62018f735008f710d184 (diff) |
Unveil paths needed by xterm at run-time. work with tb@ and deraadt@
Only in (default) case where there are no exec-formatted or
exec-selected resources set. In those case the commands and their
arguments could be anywhere.
Diffstat (limited to 'app/xterm')
-rw-r--r-- | app/xterm/main.c | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/app/xterm/main.c b/app/xterm/main.c index f1ac75576..ceede6f31 100644 --- a/app/xterm/main.c +++ b/app/xterm/main.c @@ -2905,11 +2905,80 @@ main(int argc, char *argv[]ENVP_ARG) exit(1); } } else { + char *env; + if ((env = getenv("HOME"))) { + char homefile[PATH_MAX]; + + snprintf(homefile, sizeof homefile, "%s/.fonts", env); + if (unveil(homefile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + snprintf(homefile, sizeof homefile, "%s/.cache/fontconfig", + env); + if (unveil(homefile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + snprintf(homefile, sizeof homefile, "%s/.icons", env); + if (unveil(homefile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + } + if ((env = getenv("XDG_CONFIG_HOME"))) { + char xdgfile[PATH_MAX]; + + snprintf(xdgfile, sizeof xdgfile, "%s/fontconfig", env); + if (unveil(xdgfile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + snprintf(xdgfile, sizeof xdgfile, "%s/icons", env); + if (unveil(xdgfile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + } + if ((env = getenv("XDG_DATA_HOME"))) { + char xdgfile[PATH_MAX]; + + snprintf(xdgfile, sizeof xdgfile, "%s/fontconfig", env); + if (unveil(xdgfile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + snprintf(xdgfile, sizeof xdgfile, "%s/icons", env); + if (unveil(xdgfile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + } + if ((env = getenv("XDG_CACHE_HOME"))) { + char xdgfile[PATH_MAX]; + + snprintf(xdgfile, sizeof xdgfile, "%s/fontconfig", env); + if (unveil(xdgfile, "r") == -1) { + xtermWarning("unveil\n"); + exit(1); + } + } + if ((unveil("/usr/X11R6", "r") == -1) || + (unveil("/usr/local/share/fonts", "r") == -1) || + (unveil("/var/cache/fontconfig", "r") == -1) || + (unveil("/usr/local/share/icons", "r") == -1) || + (unveil("/usr/local/lib/X11/icons", "r") == -1) || + (unveil(etc_utmp, "w") == -1) || + (unveil(etc_wtmp, "w") == -1)) { + xtermWarning("unveil\n"); + exit(1); + } + if (pledge("stdio rpath wpath id proc tty", NULL) == -1) { xtermWarning("pledge\n"); exit(1); - } - } + } + } } for (;;) { |