aboutsummaryrefslogtreecommitdiff
path: root/libtrivfs/priv.h
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-04-25 01:38:45 +0200
committerJustus Winter <justus@gnupg.org>2016-04-26 14:49:46 +0200
commit94ce9fa4c443ec9a0e6ecc92cb6b07534c321c75 (patch)
treec648e34b5b21eed772bb1d8920b30ac59f34d04b /libtrivfs/priv.h
parentd67a86c9690c2a9984ca6e9f3c376956495897f4 (diff)
downloadhurd-94ce9fa4c443ec9a0e6ecc92cb6b07534c321c75.tar.gz
hurd-94ce9fa4c443ec9a0e6ecc92cb6b07534c321c75.tar.bz2
hurd-94ce9fa4c443ec9a0e6ecc92cb6b07534c321c75.zip
libtrivfs: fix notion of privileged user
Set 'is_root' if the node has been opened by the root user (this was the old behavior) or if it has been opened by the user the translator is executing under. This fixes the irritating bug that an unprivileged user cannot control her own trivfs-based translators. It does not change how privileged trivfs translators work. * libtrivfs/io-reauthenticate.c (trivfs_S_io_reauthenticate): Use the new function to compute 'isroot'. * libtrivfs/io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. * libtrivfs/open.c (trivfs_open): Likewise. * libtrivfs/priv.h (_is_privileged): New function. * libtrivfs/trivfs.h (struct peropen): Clarify what 'isroot' means.
Diffstat (limited to 'libtrivfs/priv.h')
-rw-r--r--libtrivfs/priv.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/libtrivfs/priv.h b/libtrivfs/priv.h
index d92fe336..4bdd4f77 100644
--- a/libtrivfs/priv.h
+++ b/libtrivfs/priv.h
@@ -21,6 +21,15 @@
#include <mach.h>
#include <hurd.h>
#include <hurd/ports.h>
+#include <idvec.h>
+#include <unistd.h>
#include "trivfs.h"
+/* Returns true if UIDS contains either 0 or our user id. */
+static inline int
+_is_privileged (struct idvec *uids)
+{
+ return idvec_contains (uids, 0) || idvec_contains (uids, getuid ());
+}
+
#endif