]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
open_without_symlink: Don't SYSERROR on something else than ELOOP
authorChristian Brauner <christian.brauner@mailbox.org>
Wed, 23 Mar 2016 15:37:09 +0000 (16:37 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 17 Nov 2016 22:59:42 +0000 (17:59 -0500)
The open_without_symlink routine has been specifically created to prevent
mounts with synlinks as source or destination. Keep SYSERROR'ing in that
particular scenario, but leave error handling to calling functions for the
other ones - e.g. optional bind mount when the source dir doesn't exist
throws a nasty error.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
src/lxc/utils.c

index 3d4d6ad0688fea45954999881a0e7754428a4002..911fa05a6f34e8e20efa9c9f2193a463380ef999 100644 (file)
@@ -1313,8 +1313,6 @@ static int open_without_symlink(const char *target, const char *prefix_skip)
                        errno = saved_errno;
                        if (errno == ELOOP)
                                SYSERROR("%s in %s was a symbolic link!", nextpath, target);
-                       else
-                               SYSERROR("Error examining %s in %s", nextpath, target);
                        goto out;
                }
        }
@@ -1359,8 +1357,11 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
 
        destfd = open_without_symlink(dest, rootfs);
        if (destfd < 0) {
-               if (srcfd != -1)
+               if (srcfd != -1) {
+                       saved_errno = errno;
                        close(srcfd);
+                       errno = saved_errno;
+               }
                return destfd;
        }