diff options
-rw-r--r-- | libtrivfs/fsys-getroot.c | 16 |
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; |