aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-02-02 06:24:21 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-13 09:15:49 -0500
commit65e10f6d0ab09ba95c2eb07cac43208692cf670e (patch)
tree2028f6cdb6ba126ea5134e8b05490a7b2058ae16 /fs
parentb5663898ec3fa7f1a58a9def9592be345bb173c2 (diff)
nfsd: Convert idmap to use kuids and kgids
Convert nfsd_map_name_to_uid to return a kuid_t value. Convert nfsd_map_name_to_gid to return a kgid_t value. Convert nfsd_map_uid_to_name to take a kuid_t parameter. Convert nfsd_map_gid_to_name to take a kgid_t paramater. Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/idmap.h8
-rw-r--r--fs/nfsd/nfs4idmap.c26
2 files changed, 24 insertions, 10 deletions
diff --git a/fs/nfsd/idmap.h b/fs/nfsd/idmap.h
index 9d513efc01ba..bf95f6b817a4 100644
--- a/fs/nfsd/idmap.h
+++ b/fs/nfsd/idmap.h
@@ -54,9 +54,9 @@ static inline void nfsd_idmap_shutdown(struct net *net)
54} 54}
55#endif 55#endif
56 56
57__be32 nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *); 57__be32 nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, kuid_t *);
58__be32 nfsd_map_name_to_gid(struct svc_rqst *, const char *, size_t, __u32 *); 58__be32 nfsd_map_name_to_gid(struct svc_rqst *, const char *, size_t, kgid_t *);
59int nfsd_map_uid_to_name(struct svc_rqst *, __u32, char *); 59int nfsd_map_uid_to_name(struct svc_rqst *, kuid_t, char *);
60int nfsd_map_gid_to_name(struct svc_rqst *, __u32, char *); 60int nfsd_map_gid_to_name(struct svc_rqst *, kgid_t, char *);
61 61
62#endif /* LINUX_NFSD_IDMAP_H */ 62#endif /* LINUX_NFSD_IDMAP_H */
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 7e84dfa23d83..0ce12346df9c 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -625,26 +625,40 @@ do_id_to_name(struct svc_rqst *rqstp, int type, u32 id, char *name)
625 625
626__be32 626__be32
627nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen, 627nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
628 __u32 *id) 628 kuid_t *uid)
629{ 629{
630 return do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, id); 630 __be32 status;
631 u32 id = -1;
632 status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id);
633 *uid = make_kuid(&init_user_ns, id);
634 if (!uid_valid(*uid))
635 status = nfserr_badowner;
636 return status;
631} 637}
632 638
633__be32 639__be32
634nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen, 640nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
635 __u32 *id) 641 kgid_t *gid)
636{ 642{
637 return do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, id); 643 __be32 status;
644 u32 id = -1;
645 status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id);
646 *gid = make_kgid(&init_user_ns, id);
647 if (!gid_valid(*gid))
648 status = nfserr_badowner;
649 return status;
638} 650}
639 651
640int 652int
641nfsd_map_uid_to_name(struct svc_rqst *rqstp, __u32 id, char *name) 653nfsd_map_uid_to_name(struct svc_rqst *rqstp, kuid_t uid, char *name)
642{ 654{
655 u32 id = from_kuid(&init_user_ns, uid);
643 return do_id_to_name(rqstp, IDMAP_TYPE_USER, id, name); 656 return do_id_to_name(rqstp, IDMAP_TYPE_USER, id, name);
644} 657}
645 658
646int 659int
647nfsd_map_gid_to_name(struct svc_rqst *rqstp, __u32 id, char *name) 660nfsd_map_gid_to_name(struct svc_rqst *rqstp, kgid_t gid, char *name)
648{ 661{
662 u32 id = from_kgid(&init_user_ns, gid);
649 return do_id_to_name(rqstp, IDMAP_TYPE_GROUP, id, name); 663 return do_id_to_name(rqstp, IDMAP_TYPE_GROUP, id, name);
650} 664}