summaryrefslogtreecommitdiff
path: root/src/basic/macro.h
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2015-07-23 09:53:47 +0200
committerDavid Herrmann <dh.herrmann@googlemail.com>2015-07-23 09:53:47 +0200
commit8cd4eb791aa80e8f9c9d1c4625b411dbe4119b27 (patch)
tree44439c355abd08b8634d5f127a01e87b0f9252dd /src/basic/macro.h
parente25aa3453b01820b56f3d4844535607677c3937a (diff)
parent35914919a46ee2b123f4b36b27a2b9d9addc60ef (diff)
Merge pull request #537 from poettering/nss-mymachines-userns
Hook up container userns with nss-mymachines
Diffstat (limited to 'src/basic/macro.h')
-rw-r--r--src/basic/macro.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h
index ea01d701d2..627d768b76 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <inttypes.h>
+#include <stdbool.h>
#define _printf_(a,b) __attribute__ ((format (printf, a, b)))
#define _alloc_(...) __attribute__ ((alloc_size(__VA_ARGS__)))
@@ -461,6 +462,18 @@ do { \
#define GID_INVALID ((gid_t) -1)
#define MODE_INVALID ((mode_t) -1)
+static inline bool UID_IS_INVALID(uid_t uid) {
+ /* We consider both the old 16bit -1 user and the newer 32bit
+ * -1 user invalid, since they are or used to be incompatible
+ * with syscalls such as setresuid() or chown(). */
+
+ return uid == (uid_t) ((uint32_t) -1) || uid == (uid_t) ((uint16_t) -1);
+}
+
+static inline bool GID_IS_INVALID(gid_t gid) {
+ return gid == (gid_t) ((uint32_t) -1) || gid == (gid_t) ((uint16_t) -1);
+}
+
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
static inline void func##p(type *p) { \
if (*p) \