]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
avoid very unlikely race due to EEXIST
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 20 Aug 2013 23:15:06 +0000 (18:15 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 20 Aug 2013 23:15:06 +0000 (18:15 -0500)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc_start.c

index e7793046cd667ef420dd0742b25118791af404b9..3a1241032ad6115cf0a9085cdc17b179f84e1411 100644 (file)
@@ -62,11 +62,12 @@ static int ensure_path(char **confpath, const char *path)
        if (path) {
                if (access(path, W_OK)) {
                        fd = creat(path, 0600);
-                       if (fd < 0) {
+                       if (fd < 0 && errno != EEXIST) {
                                SYSERROR("failed to create '%s'", path);
                                goto err;
                        }
-                       close(fd);
+                       if (fd >= 0)
+                               close(fd);
                }
 
                fullpath = realpath(path, NULL);