[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/7] trans: fix the creation of files in fakeroot
From: |
Justus Winter |
Subject: |
[PATCH 5/7] trans: fix the creation of files in fakeroot |
Date: |
Wed, 4 Dec 2013 12:11:54 +0100 |
Previously, fakeroot failed to create files in certain circumstances,
e. g. assuming /tmp is a tmpfs and /tmp/some_file does not exist:
% cd /tmp && fakeroot-hurd /bin/sh -c ':>/tmp/some_file'
/bin/sh: 1: cannot create /tmp/some_file: Is a directory
Fix this by sanitizing the flags value not to contain O_WRITE if we're
not at the last path component.
* trans/fakeroot.c (netfs_S_dir_lookup): Strip O_WRITE from flags when
looking up all but the last path component.
---
trans/fakeroot.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 679e476..b6938dc 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -307,6 +307,10 @@ netfs_S_dir_lookup (struct protid *diruser,
/* We already know about this node. */
mach_port_deallocate (mach_task_self (), idport);
pthread_mutex_lock (&np->lock);
+ if (retry_name[0] != '\0')
+ /* This was not the last component, remove O_WRITE to
+ avoid opening directories with it. */
+ flags &= ~O_WRITE;
err = check_openmodes (np->nn, (flags & (O_RDWR|O_EXEC)), file);
if (!err)
netfs_nref (np);
--
1.7.10.4
- [PATCH 1/7] auth: improve the auth_demuxer function, Justus Winter, 2013/12/04
- [PATCH 3/7] trans: remove unused declaration from fakeroot.c, Justus Winter, 2013/12/04
- [PATCH 4/7] trans: improve the netfs_demuxer function in fakeroot.c, Justus Winter, 2013/12/04
- [PATCH 5/7] trans: fix the creation of files in fakeroot,
Justus Winter <=
- [PATCH 2/7] utils: improve the auth_demuxer function in fakeauth.c, Justus Winter, 2013/12/04
- [PATCH 7/7] trans: make the fakeroot environment more transparent, Justus Winter, 2013/12/04
- [PATCH 6/7] trans: fix transparent reauthentication in fakeroot, Justus Winter, 2013/12/04
- Re: [PATCH 1/7] auth: improve the auth_demuxer function, Samuel Thibault, 2013/12/04