diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-02-22 18:44:31 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-03-11 15:39:26 -0500 |
commit | f0b851689a5da2354f19bcbbac30cd2cab45c4a1 (patch) | |
tree | 3084bdb2c1ceb99888952371c2b19b66064889df /fs/nfs/idmap.c | |
parent | 5cf36cfdc8caa2724738ad0842c5c3dd02f309dc (diff) |
NFSv4: Send unmapped uid/gids to the server if the idmapper fails
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/idmap.c')
-rw-r--r-- | fs/nfs/idmap.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index cbe6e2fa8cef..8518573c3ffc 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c | |||
@@ -52,6 +52,11 @@ static int nfs_map_string_to_numeric(const char *name, size_t namelen, __u32 *re | |||
52 | return 1; | 52 | return 1; |
53 | } | 53 | } |
54 | 54 | ||
55 | static int nfs_map_numeric_to_string(__u32 id, char *buf, size_t buflen) | ||
56 | { | ||
57 | return snprintf(buf, buflen, "%u", id); | ||
58 | } | ||
59 | |||
55 | #ifdef CONFIG_NFS_USE_NEW_IDMAPPER | 60 | #ifdef CONFIG_NFS_USE_NEW_IDMAPPER |
56 | 61 | ||
57 | #include <linux/slab.h> | 62 | #include <linux/slab.h> |
@@ -252,11 +257,20 @@ int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namele | |||
252 | 257 | ||
253 | int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) | 258 | int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) |
254 | { | 259 | { |
255 | return nfs_idmap_lookup_name(uid, "user", buf, buflen); | 260 | int ret; |
261 | ret = nfs_idmap_lookup_name(uid, "user", buf, buflen); | ||
262 | if (ret < 0) | ||
263 | ret = nfs_map_numeric_to_string(uid, buf, buflen); | ||
264 | return ret; | ||
256 | } | 265 | } |
257 | int nfs_map_gid_to_group(struct nfs_client *clp, __u32 gid, char *buf, size_t buflen) | 266 | int nfs_map_gid_to_group(struct nfs_client *clp, __u32 gid, char *buf, size_t buflen) |
258 | { | 267 | { |
259 | return nfs_idmap_lookup_name(gid, "group", buf, buflen); | 268 | int ret; |
269 | |||
270 | ret = nfs_idmap_lookup_name(gid, "group", buf, buflen); | ||
271 | if (ret < 0) | ||
272 | ret = nfs_map_numeric_to_string(gid, buf, buflen); | ||
273 | return ret; | ||
260 | } | 274 | } |
261 | 275 | ||
262 | #else /* CONFIG_NFS_USE_NEW_IDMAPPER not defined */ | 276 | #else /* CONFIG_NFS_USE_NEW_IDMAPPER not defined */ |
@@ -736,14 +750,22 @@ int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namele | |||
736 | int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) | 750 | int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) |
737 | { | 751 | { |
738 | struct idmap *idmap = clp->cl_idmap; | 752 | struct idmap *idmap = clp->cl_idmap; |
753 | int ret; | ||
739 | 754 | ||
740 | return nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf); | 755 | ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf); |
756 | if (ret < 0) | ||
757 | ret = nfs_map_numeric_to_string(uid, buf, buflen); | ||
758 | return ret; | ||
741 | } | 759 | } |
742 | int nfs_map_gid_to_group(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) | 760 | int nfs_map_gid_to_group(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) |
743 | { | 761 | { |
744 | struct idmap *idmap = clp->cl_idmap; | 762 | struct idmap *idmap = clp->cl_idmap; |
763 | int ret; | ||
745 | 764 | ||
746 | return nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf); | 765 | ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf); |
766 | if (ret < 0) | ||
767 | ret = nfs_map_numeric_to_string(uid, buf, buflen); | ||
768 | return ret; | ||
747 | } | 769 | } |
748 | 770 | ||
749 | #endif /* CONFIG_NFS_USE_NEW_IDMAPPER */ | 771 | #endif /* CONFIG_NFS_USE_NEW_IDMAPPER */ |