]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
copy_tree: do not block on fifos
authorSamanta Navarro <ferivoz@riseup.net>
Sun, 4 Sep 2022 11:58:03 +0000 (11:58 +0000)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 9 Sep 2022 13:19:12 +0000 (15:19 +0200)
Fixes regression introduced in faeab50e710131816b261de66141524898c2c487.

If a directory contains fifos, then openat blocks until the other side
of the fifo is connected as well.

This means that users can prevent "usermod -m" from completing if their
home directories contain at least one fifo.

libmisc/copydir.c

index b6025f4c7db8e32e39d7f423e9b554e716ce0c52..5fb47da01e4b1f733854b430f7cfdd7fc0845fbe 100644 (file)
@@ -126,12 +126,12 @@ static int perm_copy_path(const struct path_info *src,
 {
        int src_fd, dst_fd, ret;
 
-       src_fd = openat(src->dirfd, src->name, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+       src_fd = openat(src->dirfd, src->name, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC);
        if (src_fd < 0) {
                return -1;
        }
 
-       dst_fd = openat(dst->dirfd, dst->name, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+       dst_fd = openat(dst->dirfd, dst->name, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC);
        if (dst_fd < 0) {
                (void) close (src_fd);
                return -1;
@@ -152,12 +152,12 @@ static int attr_copy_path(const struct path_info *src,
 {
        int src_fd, dst_fd, ret;
 
-       src_fd = openat(src->dirfd, src->name, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+       src_fd = openat(src->dirfd, src->name, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC);
        if (src_fd < 0) {
                return -1;
        }
 
-       dst_fd = openat(dst->dirfd, dst->name, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+       dst_fd = openat(dst->dirfd, dst->name, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC);
        if (dst_fd < 0) {
                (void) close (src_fd);
                return -1;