Skip to content

Commit

Permalink
hw/usb/dev-mtp: create directories with a+x mode mask
Browse files Browse the repository at this point in the history
Current code creates directories with mode 0644. Even the creator
can't create files in the new directory. Set all x mode flags in
variable mask and clear all x mode flags in function open() to
preserve the current open mode.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20220122140619.7514-1-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
Volker Rümelin authored and kraxel committed Mar 4, 2022
1 parent 42c9391 commit 7c204e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/usb/dev-mtp.c
Expand Up @@ -1607,7 +1607,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t handle)
usb_mtp_object_lookup(s, s->dataset.parent_handle);
char *path = NULL;
uint64_t rc;
mode_t mask = 0644;
mode_t mask = 0755;
int ret = 0;

assert(d != NULL);
Expand Down Expand Up @@ -1635,7 +1635,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t handle)
}

d->fd = open(path, O_CREAT | O_WRONLY |
O_CLOEXEC | O_NOFOLLOW, mask);
O_CLOEXEC | O_NOFOLLOW, mask & 0666);
if (d->fd == -1) {
ret = 1;
goto done;
Expand Down

0 comments on commit 7c204e9

Please sign in to comment.