summaryrefslogtreecommitdiff
path: root/libtrivfs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-29 21:03:08 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-29 21:10:11 +0200
commitd18ea50ec00210680b80359cb182a0175374d5e1 (patch)
treebb82d72d064ba66a1e300173bcdfac3eb3b71ca5 /libtrivfs
parentb04364bcdcd1a209cb3e2762e09a42247bcde5f0 (diff)
Fix root operations on trivfs-translated nodes
* libtrivfs/fsys-getroot.c: When `uids` contain 0, make a verbatim copy of the real node instead of making an auth-restricted copy.
Diffstat (limited to 'libtrivfs')
-rw-r--r--libtrivfs/fsys-getroot.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libtrivfs/fsys-getroot.c b/libtrivfs/fsys-getroot.c
index 2bc11f52..c44e5358 100644
--- a/libtrivfs/fsys-getroot.c
+++ b/libtrivfs/fsys-getroot.c
@@ -69,8 +69,20 @@ trivfs_S_fsys_getroot (struct trivfs_control *cntl,
flags &= O_HURD;
flags &= ~(O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS);
- err = io_restrict_auth (cntl->underlying,
- &new_realnode, uids, nuids, gids, ngids);
+ struct idvec idvec = {
+ .ids = uids,
+ .num = nuids,
+ .alloced = nuids,
+ };
+
+ if (idvec_contains (&idvec, 0))
+ /* Root should be given all our rights. */
+ err = io_duplicate (cntl->underlying, &new_realnode);
+ else
+ /* Non-root, restrict rights. */
+ err = io_restrict_auth (cntl->underlying,
+ &new_realnode, uids, nuids, gids, ngids);
+
if (err)
return err;