From d18ea50ec00210680b80359cb182a0175374d5e1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 29 Apr 2016 21:03:08 +0200 Subject: 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. --- libtrivfs/fsys-getroot.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libtrivfs') 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; -- cgit v1.2.3