Skip to content

Commit 24dcb17

Browse files
maharmstonekdave
authored andcommitted
btrfs-progs: receive: don't use O_NOATIME to open stream for dumping
open() returns EPERM with O_NOATIME if the user isn't root, and the file is owned by a different UID. Normally this isn't a problem as receiving a stream involves BTRFS_IOC_TREE_SEARCH which requires root, but --dump is an unprivileged operation. Pull-request: #1024 Signed-off-by: Mark Harmstone <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent ce35883 commit 24dcb17

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmds/receive.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,12 @@ static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
17831783
tomnt = argv[optind];
17841784

17851785
if (fromfile[0]) {
1786-
receive_fd = open(fromfile, O_RDONLY | O_NOATIME);
1786+
int flags = O_RDONLY;
1787+
1788+
if (!dump)
1789+
flags |= O_NOATIME;
1790+
1791+
receive_fd = open(fromfile, flags);
17871792
if (receive_fd < 0) {
17881793
error("cannot open %s: %m", fromfile);
17891794
goto out;

0 commit comments

Comments
 (0)