Commit b26ef9fe authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Bugfixes and cleanups for the NFSv4 client

name to uid mapper. Includes a fix by Tim Woods to
deal with a caching bug in the case where a user
and a group share the same numerical id and/or name.
parent 066a0e3d
This diff is collapsed.
...@@ -239,10 +239,10 @@ static int ...@@ -239,10 +239,10 @@ static int
encode_attrs(struct xdr_stream *xdr, struct iattr *iap, encode_attrs(struct xdr_stream *xdr, struct iattr *iap,
struct nfs_server *server) struct nfs_server *server)
{ {
char owner_name[256]; char owner_name[IDMAP_NAMESZ];
char owner_group[256]; char owner_group[IDMAP_NAMESZ];
int owner_namelen = sizeof(owner_name); int owner_namelen = 0;
int owner_grouplen = sizeof(owner_group); int owner_grouplen = 0;
uint32_t *p; uint32_t *p;
uint32_t *q; uint32_t *q;
int len; int len;
...@@ -265,9 +265,8 @@ encode_attrs(struct xdr_stream *xdr, struct iattr *iap, ...@@ -265,9 +265,8 @@ encode_attrs(struct xdr_stream *xdr, struct iattr *iap,
if (iap->ia_valid & ATTR_MODE) if (iap->ia_valid & ATTR_MODE)
len += 4; len += 4;
if (iap->ia_valid & ATTR_UID) { if (iap->ia_valid & ATTR_UID) {
status = nfs_idmap_name(server, IDMAP_TYPE_USER, owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name);
iap->ia_uid, owner_name, &owner_namelen); if (owner_namelen < 0) {
if (status < 0) {
printk(KERN_WARNING "nfs: couldn't resolve uid %d to string\n", printk(KERN_WARNING "nfs: couldn't resolve uid %d to string\n",
iap->ia_uid); iap->ia_uid);
/* XXX */ /* XXX */
...@@ -278,9 +277,8 @@ encode_attrs(struct xdr_stream *xdr, struct iattr *iap, ...@@ -278,9 +277,8 @@ encode_attrs(struct xdr_stream *xdr, struct iattr *iap,
len += 4 + (XDR_QUADLEN(owner_namelen) << 2); len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
} }
if (iap->ia_valid & ATTR_GID) { if (iap->ia_valid & ATTR_GID) {
status = nfs_idmap_name(server, IDMAP_TYPE_GROUP, owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group);
iap->ia_gid, owner_group, &owner_grouplen); if (owner_grouplen < 0) {
if (status < 0) {
printk(KERN_WARNING "nfs4: couldn't resolve gid %d to string\n", printk(KERN_WARNING "nfs4: couldn't resolve gid %d to string\n",
iap->ia_gid); iap->ia_gid);
strcpy(owner_group, "nobody"); strcpy(owner_group, "nobody");
...@@ -1475,10 +1473,9 @@ decode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr, ...@@ -1475,10 +1473,9 @@ decode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr,
} }
READ_BUF(dummy32); READ_BUF(dummy32);
len += (XDR_QUADLEN(dummy32) << 2); len += (XDR_QUADLEN(dummy32) << 2);
if ((status = nfs_idmap_id(server, IDMAP_TYPE_USER, if ((status = nfs_map_name_to_uid(server, (char *)p, dummy32,
(char *)p, dummy32, &nfp->uid)) == -1) { &nfp->uid)) < 0) {
dprintk("read_attrs: gss_get_num failed!\n"); dprintk("read_attrs: name-to-uid mapping failed!\n");
/* goto out; */
nfp->uid = -2; nfp->uid = -2;
} }
dprintk("read_attrs: uid=%d\n", (int)nfp->uid); dprintk("read_attrs: uid=%d\n", (int)nfp->uid);
...@@ -1493,11 +1490,10 @@ decode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr, ...@@ -1493,11 +1490,10 @@ decode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr,
} }
READ_BUF(dummy32); READ_BUF(dummy32);
len += (XDR_QUADLEN(dummy32) << 2); len += (XDR_QUADLEN(dummy32) << 2);
if ((status = nfs_idmap_id(server, IDMAP_TYPE_GROUP, if ((status = nfs_map_group_to_gid(server, (char *)p, dummy32,
(char *)p, dummy32, &nfp->gid)) == -1) { &nfp->gid)) < 0) {
dprintk("read_attrs: gss_get_num failed!\n"); dprintk("read_attrs: group-to-gid mapping failed!\n");
nfp->gid = -2; nfp->gid = -2;
/* goto out; */
} }
dprintk("read_attrs: gid=%d\n", (int)nfp->gid); dprintk("read_attrs: gid=%d\n", (int)nfp->gid);
} }
......
...@@ -52,18 +52,21 @@ ...@@ -52,18 +52,21 @@
#define IDMAP_STATUS_SUCCESS 0x08 #define IDMAP_STATUS_SUCCESS 0x08
struct idmap_msg { struct idmap_msg {
u_int8_t im_type; __u8 im_type;
u_int8_t im_conv; __u8 im_conv;
char im_name[IDMAP_NAMESZ]; char im_name[IDMAP_NAMESZ];
u_int32_t im_id; __u32 im_id;
u_int8_t im_status; __u8 im_status;
}; };
#ifdef __KERNEL__ #ifdef __KERNEL__
void *nfs_idmap_new(struct nfs_server *); void *nfs_idmap_new(struct nfs_server *);
void nfs_idmap_delete(struct nfs_server *); void nfs_idmap_delete(struct nfs_server *);
int nfs_idmap_id(struct nfs_server *, u_int8_t, char *, u_int, uid_t *);
int nfs_idmap_name(struct nfs_server *, u_int8_t, uid_t, char *, u_int *); int nfs_map_name_to_uid(struct nfs_server *, const char *, size_t, __u32 *);
int nfs_map_group_to_gid(struct nfs_server *, const char *, size_t, __u32 *);
int nfs_map_uid_to_name(struct nfs_server *, __u32, char *);
int nfs_map_gid_to_group(struct nfs_server *, __u32, char *);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* NFS_IDMAP_H */ #endif /* NFS_IDMAP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment