summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamanta Navarro <ferivoz@riseup.net>2022-09-04 11:58:03 +0000
committerIker Pedrosa <ikerpedrosam@gmail.com>2022-09-09 15:19:12 +0200
commit10cd68e0f04b48363eb32d2c6e168b358fb27810 (patch)
treeb6afe58905dccf6875003abeb540cf2c4a56bb82
parentf3bdb28e57e5e38c1e89347976c7d61a181eec32 (diff)
copy_tree: do not block on fifos
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.
-rw-r--r--libmisc/copydir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libmisc/copydir.c b/libmisc/copydir.c
index b6025f4c..5fb47da0 100644
--- a/libmisc/copydir.c
+++ b/libmisc/copydir.c
@@ -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;