* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/kmod.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <libcfs/libcfs.h>
-#include <libcfs/lucache.h>
#include <obd.h>
#include <obd_class.h>
#include <obd_support.h>
RETURN(-EACCES);
}
- if (req->rq_auth_mapped_uid == INVALID_UID) {
+ if (!uid_valid(make_kuid(&init_user_ns, req->rq_auth_mapped_uid))) {
CDEBUG(D_SEC, "invalid authorized mapped uid, please check "
"/etc/lustre/idmap.conf!\n");
RETURN(-EACCES);
if (!exp_connect_rmtclient(info->mti_exp))
return;
- if (body->valid & OBD_MD_FLUID) {
- uid_t uid = lustre_idmap_lookup_uid(uc, idmap, 1, body->uid);
+ if (body->mbo_valid & OBD_MD_FLUID) {
+ uid_t uid;
- if (uid == CFS_IDMAP_NOTFOUND) {
- uid = NOBODY_UID;
- if (body->valid & OBD_MD_FLMODE)
- body->mode = (body->mode & ~S_IRWXU) |
- ((body->mode & S_IRWXO) << 6);
- }
+ uid = lustre_idmap_lookup_uid(uc, idmap, 1, body->mbo_uid);
- body->uid = uid;
- }
+ if (uid == CFS_IDMAP_NOTFOUND) {
+ uid = NOBODY_UID;
+ if (body->mbo_valid & OBD_MD_FLMODE)
+ body->mbo_mode = (body->mbo_mode & ~S_IRWXU) |
+ ((body->mbo_mode & S_IRWXO) << 6);
+ }
+
+ body->mbo_uid = uid;
+ }
- if (body->valid & OBD_MD_FLGID) {
- gid_t gid = lustre_idmap_lookup_gid(uc, idmap, 1, body->gid);
+ if (body->mbo_valid & OBD_MD_FLGID) {
+ gid_t gid;
- if (gid == CFS_IDMAP_NOTFOUND) {
- gid = NOBODY_GID;
- if (body->valid & OBD_MD_FLMODE)
- body->mode = (body->mode & ~S_IRWXG) |
- ((body->mode & S_IRWXO) << 3);
- }
+ gid = lustre_idmap_lookup_gid(uc, idmap, 1, body->mbo_gid);
+
+ if (gid == CFS_IDMAP_NOTFOUND) {
+ gid = NOBODY_GID;
+ if (body->mbo_valid & OBD_MD_FLMODE)
+ body->mbo_mode = (body->mbo_mode & ~S_IRWXG) |
+ ((body->mbo_mode & S_IRWXO) << 3);
+ }
- body->gid = gid;
+ body->mbo_gid = gid;
}
}