summaryrefslogtreecommitdiff
path: root/trans
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2015-10-12 01:50:34 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-10-12 01:50:34 +0200
commita6185e280c1e9ca17e9bd24eff169671fe28fb1b (patch)
treee9e7c5ab82f95d5167cac062dec4b2e0643d2a70 /trans
parent1fa0cec1b643483918933b5d6a419e77d6e16c6d (diff)
Make dir_lookup create files with user permissions enabled
So we will always be able to re-open them. * trans/fakeroot.c (netfs_S_dir_lookup): Call real_from_fake_mode() on modes before calling the underlying filesystem's dir_lookup.
Diffstat (limited to 'trans')
-rw-r--r--trans/fakeroot.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 76fc9010..6962810b 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -247,6 +247,17 @@ check_openmodes (struct netnode *nn, int newmodes, file_t file)
return err;
}
+/* Return the mode that the real underlying file should have if the
+ fake mode is being set to MODE. We always give ourselves read and
+ write permission so that we can open the file as root would be able
+ to. We give ourselves execute permission iff any execute bit is
+ set in the fake mode. */
+static inline mode_t
+real_from_fake_mode (mode_t mode)
+{
+ return mode | S_IREAD | S_IWRITE | (((mode << 3) | (mode << 6)) & S_IEXEC);
+}
+
/* This is called by netfs_S_fsys_getroot. */
error_t
netfs_check_open_permissions (struct iouser *user, struct node *np,
@@ -283,7 +294,7 @@ netfs_S_dir_lookup (struct protid *diruser,
redo_lookup:
err = dir_lookup (dir, filename,
flags & (O_NOLINK|O_RDWR|O_EXEC|O_CREAT|O_EXCL|O_NONBLOCK),
- mode, do_retry, retry_name, &file);
+ real_from_fake_mode (mode), do_retry, retry_name, &file);
if (dir != netfs_node_netnode (dnp)->file)
mach_port_deallocate (mach_task_self (), dir);
if (err)
@@ -525,17 +536,6 @@ netfs_attempt_chauthor (struct iouser *cred, struct node *np, uid_t author)
return 0;
}
-/* Return the mode that the real underlying file should have if the
- fake mode is being set to MODE. We always give ourselves read and
- write permission so that we can open the file as root would be able
- to. We give ourselves execute permission iff any execute bit is
- set in the fake mode. */
-static inline mode_t
-real_from_fake_mode (mode_t mode)
-{
- return mode | S_IREAD | S_IWRITE | (((mode << 3) | (mode << 6)) & S_IEXEC);
-}
-
/* This should attempt a chmod call for the user specified by CRED on
locked node NODE, to change the mode to MODE. Unlike the normal Unix
and Hurd meaning of chmod, this function is also used to attempt to