Skip to content

Commit

Permalink
copy_tree: do not block on fifos
Browse files Browse the repository at this point in the history
Fixes regression introduced in faeab50.

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.
  • Loading branch information
ferivoz authored and ikerexxe committed Sep 9, 2022
1 parent f3bdb28 commit 10cd68e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libmisc/copydir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 10cd68e

Please sign in to comment.