diff options
author | root <root@artemis.panaceas.org> | 2015-12-25 15:00:15 +0000 |
---|---|---|
committer | root <root@artemis.panaceas.org> | 2015-12-25 15:00:15 +0000 |
commit | ddd86436f4e3643c04b797f858dab95d5f2e4de9 (patch) | |
tree | bfe7a780cf9a2f4fc33aec32c82e625e79dece1f /compat/user_namespace.c | |
download | backports-3.10.19-1-master.tar.gz backports-3.10.19-1-master.tar.bz2 backports-3.10.19-1-master.zip |
Diffstat (limited to 'compat/user_namespace.c')
-rw-r--r-- | compat/user_namespace.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/compat/user_namespace.c b/compat/user_namespace.c new file mode 100644 index 0000000..288efc0 --- /dev/null +++ b/compat/user_namespace.c @@ -0,0 +1,69 @@ +/* + * Copyright 2012 Luis R. Rodriguez <mcgrof@do-not-panic.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Compatibility file for Linux wireless for kernels backporting + * user_namespace.c + */ + +#include <linux/module.h> +#include <linux/highuid.h> +#include <linux/uidgid.h> +#include <linux/user_namespace.h> + +#ifdef CONFIG_USER_NS + +kuid_t make_kuid(struct user_namespace *ns, uid_t uid) +{ + /* Map the uid to a global kernel uid */ + return KUIDT_INIT(uid); +} +EXPORT_SYMBOL_GPL(make_kuid); + +uid_t from_kuid(struct user_namespace *targ, kuid_t kuid) +{ + /* Map the uid from a global kernel uid */ + return __kuid_val(kuid); +} +EXPORT_SYMBOL_GPL(from_kuid); + +uid_t from_kuid_munged(struct user_namespace *targ, kuid_t kuid) +{ + uid_t uid; + uid = from_kuid(targ, kuid); + + if (uid == (uid_t) -1) + uid = overflowuid; + return uid; +} +EXPORT_SYMBOL_GPL(from_kuid_munged); + +kgid_t make_kgid(struct user_namespace *ns, gid_t gid) +{ + /* Map the gid to a global kernel gid */ + return KGIDT_INIT(gid); +} +EXPORT_SYMBOL_GPL(make_kgid); + +gid_t from_kgid(struct user_namespace *targ, kgid_t kgid) +{ + /* Map the gid from a global kernel gid */ + return __kgid_val(kgid); +} +EXPORT_SYMBOL_GPL(from_kgid); + +gid_t from_kgid_munged(struct user_namespace *targ, kgid_t kgid) +{ + gid_t gid; + gid = from_kgid(targ, kgid); + + if (gid == (gid_t) -1) + gid = overflowgid; + return gid; +} +EXPORT_SYMBOL_GPL(from_kgid_munged); + +#endif /* CONFIG_USER_NS */ |