On Mon, Sep 06, 2021 at 04:53:36PM +1000, Damien Miller wrote:
> this breaks xterm on freshly-installed systems:
> 
> keroppi$ env DISPLAY=:0 xterm
> xterm: unveil
> 
> from ktrace, it looks like it is failing when trying to unveil a
> nonexistent directory:
> 
>  93248 xterm    NAMI  "/home/djm/.cache/fontconfig"
>  93248 xterm    RET   unveil -1 errno 2 No such file or directory
> 
> Maybe it should stat/access the paths first? Or more stuff in skel?

Either add .cache to skel or ignore ENOENT for dirs in home.

I'm wondering if /usr/local/share/fonts/ is also going to be a problem
and if I should extend the ENOENT checks for the system
directories...

Index: main.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/xterm/main.c,v
retrieving revision 1.50
diff -u -p -u -r1.50 main.c
--- main.c      2 Sep 2021 09:31:38 -0000       1.50
+++ main.c      6 Sep 2021 07:37:42 -0000
@@ -2910,18 +2910,18 @@ main(int argc, char *argv[]ENVP_ARG)
                 char homefile[PATH_MAX];
 
                 snprintf(homefile, sizeof homefile, "%s/.fonts", env);
-                if (unveil(homefile, "r") == -1) {
+                if (unveil(homefile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
                 snprintf(homefile, sizeof homefile, "%s/.cache/fontconfig",
                          env);
-                if (unveil(homefile, "r") == -1) {
+                if (unveil(homefile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
                 snprintf(homefile, sizeof homefile, "%s/.icons", env);
-                if (unveil(homefile, "r") == -1) {
+                if (unveil(homefile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
@@ -2930,12 +2930,12 @@ main(int argc, char *argv[]ENVP_ARG)
                 char xdgfile[PATH_MAX];
 
                 snprintf(xdgfile, sizeof xdgfile, "%s/fontconfig", env);
-                if (unveil(xdgfile, "r") == -1) {
+                if (unveil(xdgfile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
                 snprintf(xdgfile, sizeof xdgfile, "%s/icons", env);
-                if (unveil(xdgfile, "r") == -1) {
+                if (unveil(xdgfile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
@@ -2944,12 +2944,12 @@ main(int argc, char *argv[]ENVP_ARG)
                 char xdgfile[PATH_MAX];
 
                 snprintf(xdgfile, sizeof xdgfile, "%s/fontconfig", env);
-                if (unveil(xdgfile, "r") == -1) {
+                if (unveil(xdgfile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
                 snprintf(xdgfile, sizeof xdgfile, "%s/icons", env);
-                if (unveil(xdgfile, "r") == -1) {
+                if (unveil(xdgfile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }
@@ -2958,7 +2958,7 @@ main(int argc, char *argv[]ENVP_ARG)
                 char xdgfile[PATH_MAX];
 
                 snprintf(xdgfile, sizeof xdgfile, "%s/fontconfig", env);
-                if (unveil(xdgfile, "r") == -1) {
+                if (unveil(xdgfile, "r") == -1 && errno != ENOENT) {
                     xtermWarning("unveil\n");
                     exit(1);
                 }

> 
> On Thu, 2 Sep 2021, Theo de Raadt wrote:
> 
> > hurray
> > 
> > Matthieu Herrb <matth...@cvs.openbsd.org> wrote:
> > 
> > > CVSROOT:  /cvs
> > > Module name:      xenocara
> > > Changes by:       matth...@cvs.openbsd.org        2021/09/02 03:31:38
> > > 
> > > Modified files:
> > >   app/xterm      : main.c 
> > > 
> > > Log message:
> > > 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.
> > > 
> > 
> > 

-- 
Matthieu Herrb

Reply via email to