jail: relax /etc/resolv.conf creation
authorDaniel Golle <daniel@makrotopia.org>
Thu, 26 Nov 2020 00:26:43 +0000 (00:26 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 27 Nov 2020 01:06:09 +0000 (01:06 +0000)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/jail.c

index f548b7a964bbd7eba369a16b3f737cfebb210ae8..5f1ca6fa2d6e1c63ce8ffb9da0984531ceed2c54 100644 (file)
@@ -315,15 +315,15 @@ static int mount_overlay(char *jail_root, char *overlaydir) {
 
        fd = creat(upperresolvconf, 0644);
        if (fd == -1) {
-               ERROR("creat(%s) failed: %m\n", upperresolvconf);
-               goto upper_resolvconf_printf;
+               if (errno != EEXIST)
+                       ERROR("creat(%s) failed: %m\n", upperresolvconf);
+       } else {
+               close(fd);
        }
-       close(fd);
-
        DEBUG("mount -t overlay %s %s (%s)\n", jail_root, jail_root, optsstr);
 
        if (mount(jail_root, jail_root, "overlay", MS_NOATIME, optsstr))
-               goto opts_printf;
+               goto upper_resolvconf_printf;
 
        ret = 0;