2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Mapping of UID/GIDs to name and vice versa.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002, 2003 The Regents of the University of
|
|
|
|
* Michigan. All rights reserved.
|
|
|
|
*
|
|
|
|
* Marius Aamodt Eriksen <marius@umich.edu>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/seq_file.h>
|
2009-12-03 18:29:12 +00:00
|
|
|
#include <linux/sched.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2012-04-11 13:32:51 +00:00
|
|
|
#include <linux/sunrpc/svc_xprt.h>
|
2011-12-07 09:57:56 +00:00
|
|
|
#include <net/net_namespace.h>
|
2011-01-04 22:37:15 +00:00
|
|
|
#include "idmap.h"
|
2011-01-04 22:53:52 +00:00
|
|
|
#include "nfsd.h"
|
2012-04-11 13:32:51 +00:00
|
|
|
#include "netns.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-03-22 20:07:18 +00:00
|
|
|
/*
|
|
|
|
* Turn off idmapping when using AUTH_SYS.
|
|
|
|
*/
|
|
|
|
static bool nfs4_disable_idmapping = true;
|
|
|
|
module_param(nfs4_disable_idmapping, bool, 0644);
|
|
|
|
MODULE_PARM_DESC(nfs4_disable_idmapping,
|
|
|
|
"Turn off server's NFSv4 idmapping when using 'sec=sys'");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Cache entry
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX we know that IDMAP_NAMESZ < PAGE_SIZE, but it's ugly to rely on
|
|
|
|
* that.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IDMAP_TYPE_USER 0
|
|
|
|
#define IDMAP_TYPE_GROUP 1
|
|
|
|
|
|
|
|
struct ent {
|
|
|
|
struct cache_head h;
|
|
|
|
int type; /* User / Group */
|
2013-02-02 11:54:35 +00:00
|
|
|
u32 id;
|
2005-04-16 22:20:36 +00:00
|
|
|
char name[IDMAP_NAMESZ];
|
|
|
|
char authname[IDMAP_NAMESZ];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Common entry handling */
|
|
|
|
|
|
|
|
#define ENT_HASHBITS 8
|
|
|
|
#define ENT_HASHMAX (1 << ENT_HASHBITS)
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
static void
|
|
|
|
ent_init(struct cache_head *cnew, struct cache_head *citm)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-03-27 09:15:06 +00:00
|
|
|
struct ent *new = container_of(cnew, struct ent, h);
|
|
|
|
struct ent *itm = container_of(citm, struct ent, h);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
new->id = itm->id;
|
|
|
|
new->type = itm->type;
|
|
|
|
|
|
|
|
strlcpy(new->name, itm->name, sizeof(new->name));
|
|
|
|
strlcpy(new->authname, itm->authname, sizeof(new->name));
|
|
|
|
}
|
|
|
|
|
2005-06-24 05:04:03 +00:00
|
|
|
static void
|
2006-03-27 09:15:09 +00:00
|
|
|
ent_put(struct kref *ref)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-03-27 09:15:09 +00:00
|
|
|
struct ent *map = container_of(ref, struct ent, h.ref);
|
|
|
|
kfree(map);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
static struct cache_head *
|
|
|
|
ent_alloc(void)
|
|
|
|
{
|
|
|
|
struct ent *e = kmalloc(sizeof(*e), GFP_KERNEL);
|
|
|
|
if (e)
|
|
|
|
return &e->h;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ID -> Name cache
|
|
|
|
*/
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
idtoname_hash(struct ent *ent)
|
|
|
|
{
|
|
|
|
uint32_t hash;
|
|
|
|
|
|
|
|
hash = hash_str(ent->authname, ENT_HASHBITS);
|
|
|
|
hash = hash_long(hash ^ ent->id, ENT_HASHBITS);
|
|
|
|
|
|
|
|
/* Flip LSB for user/group */
|
|
|
|
if (ent->type == IDMAP_TYPE_GROUP)
|
|
|
|
hash ^= 1;
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
|
|
|
|
int *blen)
|
|
|
|
{
|
|
|
|
struct ent *ent = container_of(ch, struct ent, h);
|
|
|
|
char idstr[11];
|
|
|
|
|
|
|
|
qword_add(bpp, blen, ent->authname);
|
2007-07-31 07:37:52 +00:00
|
|
|
snprintf(idstr, sizeof(idstr), "%u", ent->id);
|
2005-04-16 22:20:36 +00:00
|
|
|
qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
|
|
|
|
qword_add(bpp, blen, idstr);
|
|
|
|
|
|
|
|
(*bpp)[-1] = '\n';
|
|
|
|
}
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
static int
|
|
|
|
idtoname_match(struct cache_head *ca, struct cache_head *cb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-03-27 09:15:06 +00:00
|
|
|
struct ent *a = container_of(ca, struct ent, h);
|
|
|
|
struct ent *b = container_of(cb, struct ent, h);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return (a->id == b->id && a->type == b->type &&
|
|
|
|
strcmp(a->authname, b->authname) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
idtoname_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
|
|
|
|
{
|
|
|
|
struct ent *ent;
|
|
|
|
|
|
|
|
if (h == NULL) {
|
|
|
|
seq_puts(m, "#domain type id [name]\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ent = container_of(h, struct ent, h);
|
2007-07-31 07:37:52 +00:00
|
|
|
seq_printf(m, "%s %s %u", ent->authname,
|
2005-04-16 22:20:36 +00:00
|
|
|
ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
|
|
|
|
ent->id);
|
|
|
|
if (test_bit(CACHE_VALID, &h->flags))
|
|
|
|
seq_printf(m, " %s", ent->name);
|
|
|
|
seq_printf(m, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-09 19:14:26 +00:00
|
|
|
warn_no_idmapd(struct cache_detail *detail, int has_died)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
printk("nfsd: nfsv4 idmapping failing: has idmapd %s?\n",
|
2009-08-09 19:14:26 +00:00
|
|
|
has_died ? "died" : "not been started");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int idtoname_parse(struct cache_detail *, char *, int);
|
2012-03-29 15:34:16 +00:00
|
|
|
static struct ent *idtoname_lookup(struct cache_detail *, struct ent *);
|
|
|
|
static struct ent *idtoname_update(struct cache_detail *, struct ent *,
|
|
|
|
struct ent *);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-04-11 13:32:51 +00:00
|
|
|
static struct cache_detail idtoname_cache_template = {
|
2005-09-06 22:17:08 +00:00
|
|
|
.owner = THIS_MODULE,
|
2005-04-16 22:20:36 +00:00
|
|
|
.hash_size = ENT_HASHMAX,
|
|
|
|
.name = "nfs4.idtoname",
|
|
|
|
.cache_put = ent_put,
|
2013-02-04 11:02:45 +00:00
|
|
|
.cache_request = idtoname_request,
|
2005-04-16 22:20:36 +00:00
|
|
|
.cache_parse = idtoname_parse,
|
|
|
|
.cache_show = idtoname_show,
|
|
|
|
.warn_no_listener = warn_no_idmapd,
|
2006-03-27 09:15:06 +00:00
|
|
|
.match = idtoname_match,
|
|
|
|
.init = ent_init,
|
|
|
|
.update = ent_init,
|
|
|
|
.alloc = ent_alloc,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-02-20 20:49:00 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
|
|
|
|
{
|
|
|
|
struct ent ent, *res;
|
|
|
|
char *buf1, *bp;
|
2007-07-27 20:36:45 +00:00
|
|
|
int len;
|
2005-04-16 22:20:36 +00:00
|
|
|
int error = -EINVAL;
|
|
|
|
|
|
|
|
if (buf[buflen - 1] != '\n')
|
|
|
|
return (-EINVAL);
|
|
|
|
buf[buflen - 1]= '\0';
|
|
|
|
|
|
|
|
buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
|
|
|
if (buf1 == NULL)
|
|
|
|
return (-ENOMEM);
|
|
|
|
|
|
|
|
memset(&ent, 0, sizeof(ent));
|
|
|
|
|
|
|
|
/* Authentication name */
|
|
|
|
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
|
|
|
|
goto out;
|
|
|
|
memcpy(ent.authname, buf1, sizeof(ent.authname));
|
|
|
|
|
|
|
|
/* Type */
|
|
|
|
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
|
|
|
|
goto out;
|
|
|
|
ent.type = strcmp(buf1, "user") == 0 ?
|
|
|
|
IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;
|
|
|
|
|
|
|
|
/* ID */
|
|
|
|
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
|
|
|
|
goto out;
|
|
|
|
ent.id = simple_strtoul(buf1, &bp, 10);
|
|
|
|
if (bp == buf1)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* expiry */
|
|
|
|
ent.h.expiry_time = get_expiry(&buf);
|
|
|
|
if (ent.h.expiry_time == 0)
|
|
|
|
goto out;
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
error = -ENOMEM;
|
2012-03-29 15:34:16 +00:00
|
|
|
res = idtoname_lookup(cd, &ent);
|
2006-03-27 09:15:06 +00:00
|
|
|
if (!res)
|
|
|
|
goto out;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Name */
|
2007-07-27 20:36:45 +00:00
|
|
|
error = -EINVAL;
|
|
|
|
len = qword_get(&buf, buf1, PAGE_SIZE);
|
|
|
|
if (len < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
2007-07-27 20:36:45 +00:00
|
|
|
if (len == 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
set_bit(CACHE_NEGATIVE, &ent.h.flags);
|
2007-10-26 17:32:50 +00:00
|
|
|
else if (len >= IDMAP_NAMESZ)
|
|
|
|
goto out;
|
|
|
|
else
|
2005-04-16 22:20:36 +00:00
|
|
|
memcpy(ent.name, buf1, sizeof(ent.name));
|
|
|
|
error = -ENOMEM;
|
2012-03-29 15:34:16 +00:00
|
|
|
res = idtoname_update(cd, &ent, res);
|
2006-03-27 09:15:06 +00:00
|
|
|
if (res == NULL)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
|
2012-03-29 15:34:16 +00:00
|
|
|
cache_put(&res->h, cd);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
error = 0;
|
|
|
|
out:
|
|
|
|
kfree(buf1);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
|
|
|
|
static struct ent *
|
2012-03-29 15:34:16 +00:00
|
|
|
idtoname_lookup(struct cache_detail *cd, struct ent *item)
|
2006-03-27 09:15:06 +00:00
|
|
|
{
|
2012-03-29 15:34:16 +00:00
|
|
|
struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
|
2006-03-27 09:15:06 +00:00
|
|
|
idtoname_hash(item));
|
|
|
|
if (ch)
|
|
|
|
return container_of(ch, struct ent, h);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ent *
|
2012-03-29 15:34:16 +00:00
|
|
|
idtoname_update(struct cache_detail *cd, struct ent *new, struct ent *old)
|
2006-03-27 09:15:06 +00:00
|
|
|
{
|
2012-03-29 15:34:16 +00:00
|
|
|
struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
|
2006-03-27 09:15:06 +00:00
|
|
|
idtoname_hash(new));
|
|
|
|
if (ch)
|
|
|
|
return container_of(ch, struct ent, h);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Name -> ID cache
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
nametoid_hash(struct ent *ent)
|
|
|
|
{
|
|
|
|
return hash_str(ent->name, ENT_HASHBITS);
|
|
|
|
}
|
|
|
|
|
2005-06-24 05:04:03 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
nametoid_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
|
|
|
|
int *blen)
|
|
|
|
{
|
|
|
|
struct ent *ent = container_of(ch, struct ent, h);
|
|
|
|
|
|
|
|
qword_add(bpp, blen, ent->authname);
|
|
|
|
qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
|
|
|
|
qword_add(bpp, blen, ent->name);
|
|
|
|
|
|
|
|
(*bpp)[-1] = '\n';
|
|
|
|
}
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
static int
|
|
|
|
nametoid_match(struct cache_head *ca, struct cache_head *cb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-03-27 09:15:06 +00:00
|
|
|
struct ent *a = container_of(ca, struct ent, h);
|
|
|
|
struct ent *b = container_of(cb, struct ent, h);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return (a->type == b->type && strcmp(a->name, b->name) == 0 &&
|
|
|
|
strcmp(a->authname, b->authname) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
nametoid_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
|
|
|
|
{
|
|
|
|
struct ent *ent;
|
|
|
|
|
|
|
|
if (h == NULL) {
|
|
|
|
seq_puts(m, "#domain type name [id]\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ent = container_of(h, struct ent, h);
|
|
|
|
seq_printf(m, "%s %s %s", ent->authname,
|
|
|
|
ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
|
|
|
|
ent->name);
|
|
|
|
if (test_bit(CACHE_VALID, &h->flags))
|
2007-07-31 07:37:52 +00:00
|
|
|
seq_printf(m, " %u", ent->id);
|
2005-04-16 22:20:36 +00:00
|
|
|
seq_printf(m, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:34:16 +00:00
|
|
|
static struct ent *nametoid_lookup(struct cache_detail *, struct ent *);
|
|
|
|
static struct ent *nametoid_update(struct cache_detail *, struct ent *,
|
|
|
|
struct ent *);
|
2005-06-24 05:04:03 +00:00
|
|
|
static int nametoid_parse(struct cache_detail *, char *, int);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-04-11 13:32:58 +00:00
|
|
|
static struct cache_detail nametoid_cache_template = {
|
2005-09-06 22:17:08 +00:00
|
|
|
.owner = THIS_MODULE,
|
2005-04-16 22:20:36 +00:00
|
|
|
.hash_size = ENT_HASHMAX,
|
|
|
|
.name = "nfs4.nametoid",
|
|
|
|
.cache_put = ent_put,
|
2013-02-04 11:02:45 +00:00
|
|
|
.cache_request = nametoid_request,
|
2005-04-16 22:20:36 +00:00
|
|
|
.cache_parse = nametoid_parse,
|
|
|
|
.cache_show = nametoid_show,
|
|
|
|
.warn_no_listener = warn_no_idmapd,
|
2006-03-27 09:15:06 +00:00
|
|
|
.match = nametoid_match,
|
|
|
|
.init = ent_init,
|
|
|
|
.update = ent_init,
|
|
|
|
.alloc = ent_alloc,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2005-06-24 05:04:03 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
|
|
|
|
{
|
|
|
|
struct ent ent, *res;
|
|
|
|
char *buf1;
|
|
|
|
int error = -EINVAL;
|
|
|
|
|
|
|
|
if (buf[buflen - 1] != '\n')
|
|
|
|
return (-EINVAL);
|
|
|
|
buf[buflen - 1]= '\0';
|
|
|
|
|
|
|
|
buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
|
|
|
if (buf1 == NULL)
|
|
|
|
return (-ENOMEM);
|
|
|
|
|
|
|
|
memset(&ent, 0, sizeof(ent));
|
|
|
|
|
|
|
|
/* Authentication name */
|
|
|
|
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
|
|
|
|
goto out;
|
|
|
|
memcpy(ent.authname, buf1, sizeof(ent.authname));
|
|
|
|
|
|
|
|
/* Type */
|
|
|
|
if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
|
|
|
|
goto out;
|
|
|
|
ent.type = strcmp(buf1, "user") == 0 ?
|
|
|
|
IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;
|
|
|
|
|
|
|
|
/* Name */
|
|
|
|
error = qword_get(&buf, buf1, PAGE_SIZE);
|
|
|
|
if (error <= 0 || error >= IDMAP_NAMESZ)
|
|
|
|
goto out;
|
|
|
|
memcpy(ent.name, buf1, sizeof(ent.name));
|
|
|
|
|
|
|
|
/* expiry */
|
|
|
|
ent.h.expiry_time = get_expiry(&buf);
|
|
|
|
if (ent.h.expiry_time == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* ID */
|
|
|
|
error = get_int(&buf, &ent.id);
|
|
|
|
if (error == -EINVAL)
|
|
|
|
goto out;
|
|
|
|
if (error == -ENOENT)
|
|
|
|
set_bit(CACHE_NEGATIVE, &ent.h.flags);
|
|
|
|
|
|
|
|
error = -ENOMEM;
|
2012-03-29 15:34:16 +00:00
|
|
|
res = nametoid_lookup(cd, &ent);
|
2006-03-27 09:15:06 +00:00
|
|
|
if (res == NULL)
|
|
|
|
goto out;
|
2012-03-29 15:34:16 +00:00
|
|
|
res = nametoid_update(cd, &ent, res);
|
2006-03-27 09:15:06 +00:00
|
|
|
if (res == NULL)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
|
2012-03-29 15:34:16 +00:00
|
|
|
cache_put(&res->h, cd);
|
2005-04-16 22:20:36 +00:00
|
|
|
error = 0;
|
|
|
|
out:
|
|
|
|
kfree(buf1);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2006-03-27 09:15:06 +00:00
|
|
|
|
|
|
|
static struct ent *
|
2012-03-29 15:34:16 +00:00
|
|
|
nametoid_lookup(struct cache_detail *cd, struct ent *item)
|
2006-03-27 09:15:06 +00:00
|
|
|
{
|
2012-03-29 15:34:16 +00:00
|
|
|
struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
|
2006-03-27 09:15:06 +00:00
|
|
|
nametoid_hash(item));
|
|
|
|
if (ch)
|
|
|
|
return container_of(ch, struct ent, h);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ent *
|
2012-03-29 15:34:16 +00:00
|
|
|
nametoid_update(struct cache_detail *cd, struct ent *new, struct ent *old)
|
2006-03-27 09:15:06 +00:00
|
|
|
{
|
2012-03-29 15:34:16 +00:00
|
|
|
struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
|
2006-03-27 09:15:06 +00:00
|
|
|
nametoid_hash(new));
|
|
|
|
if (ch)
|
|
|
|
return container_of(ch, struct ent, h);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Exported API
|
|
|
|
*/
|
|
|
|
|
2007-11-08 22:20:34 +00:00
|
|
|
int
|
2012-04-11 13:32:44 +00:00
|
|
|
nfsd_idmap_init(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-11-08 22:20:34 +00:00
|
|
|
int rv;
|
2012-04-11 13:32:51 +00:00
|
|
|
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
|
2007-11-08 22:20:34 +00:00
|
|
|
|
2012-04-11 13:32:51 +00:00
|
|
|
nn->idtoname_cache = cache_create_net(&idtoname_cache_template, net);
|
|
|
|
if (IS_ERR(nn->idtoname_cache))
|
|
|
|
return PTR_ERR(nn->idtoname_cache);
|
|
|
|
rv = cache_register_net(nn->idtoname_cache, net);
|
2007-11-08 22:20:34 +00:00
|
|
|
if (rv)
|
2012-04-11 13:32:51 +00:00
|
|
|
goto destroy_idtoname_cache;
|
2012-04-11 13:32:58 +00:00
|
|
|
nn->nametoid_cache = cache_create_net(&nametoid_cache_template, net);
|
|
|
|
if (IS_ERR(nn->nametoid_cache)) {
|
2012-08-25 19:57:04 +00:00
|
|
|
rv = PTR_ERR(nn->nametoid_cache);
|
2012-04-11 13:32:51 +00:00
|
|
|
goto unregister_idtoname_cache;
|
2012-04-11 13:32:58 +00:00
|
|
|
}
|
|
|
|
rv = cache_register_net(nn->nametoid_cache, net);
|
|
|
|
if (rv)
|
|
|
|
goto destroy_nametoid_cache;
|
2012-04-11 13:32:51 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-04-11 13:32:58 +00:00
|
|
|
destroy_nametoid_cache:
|
|
|
|
cache_destroy_net(nn->nametoid_cache, net);
|
2012-04-11 13:32:51 +00:00
|
|
|
unregister_idtoname_cache:
|
|
|
|
cache_unregister_net(nn->idtoname_cache, net);
|
|
|
|
destroy_idtoname_cache:
|
|
|
|
cache_destroy_net(nn->idtoname_cache, net);
|
2007-11-08 22:20:34 +00:00
|
|
|
return rv;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-04-11 13:32:44 +00:00
|
|
|
nfsd_idmap_shutdown(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-04-11 13:32:51 +00:00
|
|
|
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
|
|
|
|
|
|
|
|
cache_unregister_net(nn->idtoname_cache, net);
|
2012-04-11 13:32:58 +00:00
|
|
|
cache_unregister_net(nn->nametoid_cache, net);
|
2012-04-11 13:32:51 +00:00
|
|
|
cache_destroy_net(nn->idtoname_cache, net);
|
2012-04-11 13:32:58 +00:00
|
|
|
cache_destroy_net(nn->nametoid_cache, net);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
idmap_lookup(struct svc_rqst *rqstp,
|
2012-03-29 15:34:16 +00:00
|
|
|
struct ent *(*lookup_fn)(struct cache_detail *, struct ent *),
|
|
|
|
struct ent *key, struct cache_detail *detail, struct ent **item)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2012-03-29 15:34:16 +00:00
|
|
|
*item = lookup_fn(detail, key);
|
2010-08-12 07:04:06 +00:00
|
|
|
if (!*item)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
2010-08-12 07:04:06 +00:00
|
|
|
retry:
|
|
|
|
ret = cache_check(detail, &(*item)->h, &rqstp->rq_chandle);
|
|
|
|
|
|
|
|
if (ret == -ETIMEDOUT) {
|
|
|
|
struct ent *prev_item = *item;
|
2012-03-29 15:34:16 +00:00
|
|
|
*item = lookup_fn(detail, key);
|
2010-08-12 07:04:06 +00:00
|
|
|
if (*item != prev_item)
|
|
|
|
goto retry;
|
|
|
|
cache_put(&(*item)->h, detail);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
knfsd: nfsd: set rq_client to ip-address-determined-domain
We want it to be possible for users to restrict exports both by IP address and
by pseudoflavor. The pseudoflavor information has previously been passed
using special auth_domains stored in the rq_client field. After the preceding
patch that stored the pseudoflavor in rq_pflavor, that's now superfluous; so
now we use rq_client for the ip information, as auth_null and auth_unix do.
However, we keep around the special auth_domain in the rq_gssclient field for
backwards compatibility purposes, so we can still do upcalls using the old
"gss/pseudoflavor" auth_domain if upcalls using the unix domain to give us an
appropriate export. This allows us to continue supporting old mountd.
In fact, for this first patch, we always use the "gss/pseudoflavor"
auth_domain (and only it) if it is available; thus rq_client is ignored in the
auth_gss case, and this patch on its own makes no change in behavior; that
will be left to later patches.
Note on idmap: I'm almost tempted to just replace the auth_domain in the idmap
upcall by a dummy value--no version of idmapd has ever used it, and it's
unlikely anyone really wants to perform idmapping differently depending on the
where the client is (they may want to perform *credential* mapping
differently, but that's a different matter--the idmapper just handles id's
used in getattr and setattr). But I'm updating the idmapd code anyway, just
out of general backwards-compatibility paranoia.
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-17 11:04:46 +00:00
|
|
|
static char *
|
|
|
|
rqst_authname(struct svc_rqst *rqstp)
|
|
|
|
{
|
|
|
|
struct auth_domain *clp;
|
|
|
|
|
|
|
|
clp = rqstp->rq_gssclient ? rqstp->rq_gssclient : rqstp->rq_client;
|
|
|
|
return clp->name;
|
|
|
|
}
|
|
|
|
|
2011-01-04 22:53:52 +00:00
|
|
|
static __be32
|
2005-04-16 22:20:36 +00:00
|
|
|
idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen,
|
2013-02-02 11:54:35 +00:00
|
|
|
u32 *id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ent *item, key = {
|
|
|
|
.type = type,
|
|
|
|
};
|
|
|
|
int ret;
|
2012-07-25 12:57:06 +00:00
|
|
|
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (namelen + 1 > sizeof(key.name))
|
2011-01-04 22:53:52 +00:00
|
|
|
return nfserr_badowner;
|
2005-04-16 22:20:36 +00:00
|
|
|
memcpy(key.name, name, namelen);
|
|
|
|
key.name[namelen] = '\0';
|
knfsd: nfsd: set rq_client to ip-address-determined-domain
We want it to be possible for users to restrict exports both by IP address and
by pseudoflavor. The pseudoflavor information has previously been passed
using special auth_domains stored in the rq_client field. After the preceding
patch that stored the pseudoflavor in rq_pflavor, that's now superfluous; so
now we use rq_client for the ip information, as auth_null and auth_unix do.
However, we keep around the special auth_domain in the rq_gssclient field for
backwards compatibility purposes, so we can still do upcalls using the old
"gss/pseudoflavor" auth_domain if upcalls using the unix domain to give us an
appropriate export. This allows us to continue supporting old mountd.
In fact, for this first patch, we always use the "gss/pseudoflavor"
auth_domain (and only it) if it is available; thus rq_client is ignored in the
auth_gss case, and this patch on its own makes no change in behavior; that
will be left to later patches.
Note on idmap: I'm almost tempted to just replace the auth_domain in the idmap
upcall by a dummy value--no version of idmapd has ever used it, and it's
unlikely anyone really wants to perform idmapping differently depending on the
where the client is (they may want to perform *credential* mapping
differently, but that's a different matter--the idmapper just handles id's
used in getattr and setattr). But I'm updating the idmapd code anyway, just
out of general backwards-compatibility paranoia.
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-17 11:04:46 +00:00
|
|
|
strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
|
2012-04-11 13:32:58 +00:00
|
|
|
ret = idmap_lookup(rqstp, nametoid_lookup, &key, nn->nametoid_cache, &item);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret == -ENOENT)
|
2011-01-04 22:53:52 +00:00
|
|
|
return nfserr_badowner;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret)
|
2011-01-04 22:53:52 +00:00
|
|
|
return nfserrno(ret);
|
2005-04-16 22:20:36 +00:00
|
|
|
*id = item->id;
|
2012-04-11 13:32:58 +00:00
|
|
|
cache_put(&item->h, nn->nametoid_cache);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-28 01:32:25 +00:00
|
|
|
static __be32 encode_ascii_id(struct xdr_stream *xdr, u32 id)
|
2014-01-08 14:49:01 +00:00
|
|
|
{
|
|
|
|
char buf[11];
|
|
|
|
int len;
|
2013-08-28 01:32:25 +00:00
|
|
|
__be32 *p;
|
2014-01-08 14:49:01 +00:00
|
|
|
|
|
|
|
len = sprintf(buf, "%u", id);
|
2013-08-28 01:32:25 +00:00
|
|
|
p = xdr_reserve_space(xdr, len + 4);
|
|
|
|
if (!p)
|
2014-01-08 14:49:01 +00:00
|
|
|
return nfserr_resource;
|
2013-08-28 01:32:25 +00:00
|
|
|
p = xdr_encode_opaque(p, buf, len);
|
2014-01-08 14:49:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-28 01:32:25 +00:00
|
|
|
static __be32 idmap_id_to_name(struct xdr_stream *xdr,
|
|
|
|
struct svc_rqst *rqstp, int type, u32 id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ent *item, key = {
|
|
|
|
.id = id,
|
|
|
|
.type = type,
|
|
|
|
};
|
2013-08-28 01:32:25 +00:00
|
|
|
__be32 *p;
|
2005-04-16 22:20:36 +00:00
|
|
|
int ret;
|
2012-07-25 12:57:06 +00:00
|
|
|
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
knfsd: nfsd: set rq_client to ip-address-determined-domain
We want it to be possible for users to restrict exports both by IP address and
by pseudoflavor. The pseudoflavor information has previously been passed
using special auth_domains stored in the rq_client field. After the preceding
patch that stored the pseudoflavor in rq_pflavor, that's now superfluous; so
now we use rq_client for the ip information, as auth_null and auth_unix do.
However, we keep around the special auth_domain in the rq_gssclient field for
backwards compatibility purposes, so we can still do upcalls using the old
"gss/pseudoflavor" auth_domain if upcalls using the unix domain to give us an
appropriate export. This allows us to continue supporting old mountd.
In fact, for this first patch, we always use the "gss/pseudoflavor"
auth_domain (and only it) if it is available; thus rq_client is ignored in the
auth_gss case, and this patch on its own makes no change in behavior; that
will be left to later patches.
Note on idmap: I'm almost tempted to just replace the auth_domain in the idmap
upcall by a dummy value--no version of idmapd has ever used it, and it's
unlikely anyone really wants to perform idmapping differently depending on the
where the client is (they may want to perform *credential* mapping
differently, but that's a different matter--the idmapper just handles id's
used in getattr and setattr). But I'm updating the idmapd code anyway, just
out of general backwards-compatibility paranoia.
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-17 11:04:46 +00:00
|
|
|
strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
|
2012-04-11 13:32:51 +00:00
|
|
|
ret = idmap_lookup(rqstp, idtoname_lookup, &key, nn->idtoname_cache, &item);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret == -ENOENT)
|
2013-08-28 01:32:25 +00:00
|
|
|
return encode_ascii_id(xdr, id);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret)
|
2014-01-08 14:49:01 +00:00
|
|
|
return nfserrno(ret);
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = strlen(item->name);
|
2014-01-08 14:49:01 +00:00
|
|
|
WARN_ON_ONCE(ret > IDMAP_NAMESZ);
|
2013-08-28 01:32:25 +00:00
|
|
|
p = xdr_reserve_space(xdr, ret + 4);
|
|
|
|
if (!p)
|
2014-01-08 14:49:01 +00:00
|
|
|
return nfserr_resource;
|
2013-08-28 01:32:25 +00:00
|
|
|
p = xdr_encode_opaque(p, item->name, ret);
|
2012-04-11 13:32:51 +00:00
|
|
|
cache_put(&item->h, nn->idtoname_cache);
|
2014-01-08 14:49:01 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-03-22 20:07:18 +00:00
|
|
|
static bool
|
2013-02-02 11:54:35 +00:00
|
|
|
numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
|
2012-03-22 20:07:18 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char buf[11];
|
|
|
|
|
|
|
|
if (namelen + 1 > sizeof(buf))
|
|
|
|
/* too long to represent a 32-bit id: */
|
|
|
|
return false;
|
|
|
|
/* Just to make sure it's null-terminated: */
|
|
|
|
memcpy(buf, name, namelen);
|
|
|
|
buf[namelen] = '\0';
|
2012-09-09 15:25:47 +00:00
|
|
|
ret = kstrtouint(buf, 10, id);
|
2012-03-22 20:07:18 +00:00
|
|
|
return ret == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __be32
|
2013-02-02 11:54:35 +00:00
|
|
|
do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
|
2012-03-22 20:07:18 +00:00
|
|
|
{
|
2012-05-15 02:06:49 +00:00
|
|
|
if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
|
2012-03-22 20:07:18 +00:00
|
|
|
if (numeric_name_to_id(rqstp, type, name, namelen, id))
|
|
|
|
return 0;
|
|
|
|
/*
|
|
|
|
* otherwise, fall through and try idmapping, for
|
|
|
|
* backwards compatibility with clients sending names:
|
|
|
|
*/
|
|
|
|
return idmap_name_to_id(rqstp, type, name, namelen, id);
|
|
|
|
}
|
|
|
|
|
2013-08-28 01:32:25 +00:00
|
|
|
static __be32 encode_name_from_id(struct xdr_stream *xdr,
|
|
|
|
struct svc_rqst *rqstp, int type, u32 id)
|
2012-03-22 20:07:18 +00:00
|
|
|
{
|
2012-05-15 02:06:49 +00:00
|
|
|
if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
|
2013-08-28 01:32:25 +00:00
|
|
|
return encode_ascii_id(xdr, id);
|
|
|
|
return idmap_id_to_name(xdr, rqstp, type, id);
|
2012-03-22 20:07:18 +00:00
|
|
|
}
|
|
|
|
|
2011-01-04 22:53:52 +00:00
|
|
|
__be32
|
2005-04-16 22:20:36 +00:00
|
|
|
nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
|
2013-02-02 11:24:21 +00:00
|
|
|
kuid_t *uid)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-02-02 11:24:21 +00:00
|
|
|
__be32 status;
|
|
|
|
u32 id = -1;
|
|
|
|
status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id);
|
|
|
|
*uid = make_kuid(&init_user_ns, id);
|
|
|
|
if (!uid_valid(*uid))
|
|
|
|
status = nfserr_badowner;
|
|
|
|
return status;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-01-04 22:53:52 +00:00
|
|
|
__be32
|
2005-04-16 22:20:36 +00:00
|
|
|
nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
|
2013-02-02 11:24:21 +00:00
|
|
|
kgid_t *gid)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-02-02 11:24:21 +00:00
|
|
|
__be32 status;
|
|
|
|
u32 id = -1;
|
|
|
|
status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id);
|
|
|
|
*gid = make_kgid(&init_user_ns, id);
|
|
|
|
if (!gid_valid(*gid))
|
|
|
|
status = nfserr_badowner;
|
|
|
|
return status;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 01:32:25 +00:00
|
|
|
__be32 nfsd4_encode_user(struct xdr_stream *xdr, struct svc_rqst *rqstp,
|
|
|
|
kuid_t uid)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-02-02 11:24:21 +00:00
|
|
|
u32 id = from_kuid(&init_user_ns, uid);
|
2013-08-28 01:32:25 +00:00
|
|
|
return encode_name_from_id(xdr, rqstp, IDMAP_TYPE_USER, id);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 01:32:25 +00:00
|
|
|
__be32 nfsd4_encode_group(struct xdr_stream *xdr, struct svc_rqst *rqstp,
|
|
|
|
kgid_t gid)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-02-02 11:24:21 +00:00
|
|
|
u32 id = from_kgid(&init_user_ns, gid);
|
2013-08-28 01:32:25 +00:00
|
|
|
return encode_name_from_id(xdr, rqstp, IDMAP_TYPE_GROUP, id);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|