diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-02 06:24:21 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:49 -0500 |
commit | 65e10f6d0ab09ba95c2eb07cac43208692cf670e (patch) | |
tree | 2028f6cdb6ba126ea5134e8b05490a7b2058ae16 /fs | |
parent | b5663898ec3fa7f1a58a9def9592be345bb173c2 (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.h | 8 | ||||
-rw-r--r-- | fs/nfsd/nfs4idmap.c | 26 |
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 *); |
59 | int nfsd_map_uid_to_name(struct svc_rqst *, __u32, char *); | 59 | int nfsd_map_uid_to_name(struct svc_rqst *, kuid_t, char *); |
60 | int nfsd_map_gid_to_name(struct svc_rqst *, __u32, char *); | 60 | int 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 |
627 | nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen, | 627 | nfsd_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 |
634 | nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen, | 640 | nfsd_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 | ||
640 | int | 652 | int |
641 | nfsd_map_uid_to_name(struct svc_rqst *rqstp, __u32 id, char *name) | 653 | nfsd_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 | ||
646 | int | 659 | int |
647 | nfsd_map_gid_to_name(struct svc_rqst *rqstp, __u32 id, char *name) | 660 | nfsd_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 | } |