nfsd4: name->id mapping should fail with BADOWNER not BADNAME
authorJ. Bruce Fields <bfields@redhat.com>
Tue, 4 Jan 2011 23:02:15 +0000 (18:02 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 4 Jan 2011 23:21:36 +0000 (18:21 -0500)
According to rfc 3530 BADNAME is for strings that represent paths;
BADOWNER is for user/group names that don't map.

And the too-long name should probably be BADOWNER as well; it's
effectively the same as if we couldn't map it.

Cc: stable@kernel.org
Reported-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Reported-by: Simon Kirby <sim@hostway.ca>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4idmap.c
fs/nfsd/nfsd.h
fs/nfsd/nfsproc.c

index f0695e815f0ec9e53a2e9934392ac820d36e442e..844960fd039534ecd8e3525db4d4ffb2be0a09ec 100644 (file)
@@ -524,13 +524,13 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen
        int ret;
 
        if (namelen + 1 > sizeof(key.name))
-               return -EINVAL;
+               return -ESRCH; /* nfserr_badowner */
        memcpy(key.name, name, namelen);
        key.name[namelen] = '\0';
        strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
        ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item);
        if (ret == -ENOENT)
-               ret = -ESRCH; /* nfserr_badname */
+               ret = -ESRCH; /* nfserr_badowner */
        if (ret)
                return ret;
        *id = item->id;
index 6b641cf2c19ac59a6f65326c40038e2549c6df83..7ecfa2420307c24c1e2331189b2e1ff534928c87 100644 (file)
@@ -158,6 +158,7 @@ void                nfsd_lockd_shutdown(void);
 #define        nfserr_attrnotsupp      cpu_to_be32(NFSERR_ATTRNOTSUPP)
 #define        nfserr_bad_xdr          cpu_to_be32(NFSERR_BAD_XDR)
 #define        nfserr_openmode         cpu_to_be32(NFSERR_OPENMODE)
+#define        nfserr_badowner         cpu_to_be32(NFSERR_BADOWNER)
 #define        nfserr_locks_held       cpu_to_be32(NFSERR_LOCKS_HELD)
 #define        nfserr_op_illegal       cpu_to_be32(NFSERR_OP_ILLEGAL)
 #define        nfserr_grace            cpu_to_be32(NFSERR_GRACE)
index fd608a27a8d5fa4e410c944505d50ce776050325..8f05dcd0bf853d1c678865f0186add192155a63e 100644 (file)
@@ -738,7 +738,7 @@ nfserrno (int errno)
                { nfserr_jukebox, -EAGAIN },
                { nfserr_jukebox, -EWOULDBLOCK },
                { nfserr_jukebox, -ENOMEM },
-               { nfserr_badname, -ESRCH },
+               { nfserr_badowner, -ESRCH },
                { nfserr_io, -ETXTBSY },
                { nfserr_notsupp, -EOPNOTSUPP },
                { nfserr_toosmall, -ETOOSMALL },