Add linux idmap support

Use idmap service if available.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2010-08-26 11:43:07 -07:00
parent 266852767f
commit be160928b7
1 changed files with 12 additions and 0 deletions

View File

@ -41,9 +41,11 @@
#include <grp.h> #include <grp.h>
#include <stddef.h> #include <stddef.h>
#include <ucred.h> #include <ucred.h>
#ifdef HAVE_IDMAP
#include <idmap.h> #include <idmap.h>
#include <aclutils.h> #include <aclutils.h>
#include <directory.h> #include <directory.h>
#endif /* HAVE_IDMAP */
#include <sys/dnode.h> #include <sys/dnode.h>
#include <sys/spa.h> #include <sys/spa.h>
@ -2166,6 +2168,7 @@ zfs_prop_get_numeric(zfs_handle_t *zhp, zfs_prop_t prop, uint64_t *value,
return (0); return (0);
} }
#ifdef HAVE_IDMAP
static int static int
idmap_id_to_numeric_domain_rid(uid_t id, boolean_t isuser, idmap_id_to_numeric_domain_rid(uid_t id, boolean_t isuser,
char **domainp, idmap_rid_t *ridp) char **domainp, idmap_rid_t *ridp)
@ -2195,6 +2198,7 @@ out:
idmap_get_destroy(get_hdl); idmap_get_destroy(get_hdl);
return (err); return (err);
} }
#endif /* HAVE_IDMAP */
/* /*
* convert the propname into parameters needed by kernel * convert the propname into parameters needed by kernel
@ -2228,6 +2232,7 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
cp = strchr(propname, '@') + 1; cp = strchr(propname, '@') + 1;
if (strchr(cp, '@')) { if (strchr(cp, '@')) {
#ifdef HAVE_IDMAP
/* /*
* It's a SID name (eg "user@domain") that needs to be * It's a SID name (eg "user@domain") that needs to be
* turned into S-1-domainID-RID. * turned into S-1-domainID-RID.
@ -2250,6 +2255,9 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
return (ENOENT); return (ENOENT);
cp = numericsid; cp = numericsid;
/* will be further decoded below */ /* will be further decoded below */
#else
return (ENOSYS);
#endif /* HAVE_IDMAP */
} }
if (strncmp(cp, "S-1-", 4) == 0) { if (strncmp(cp, "S-1-", 4) == 0) {
@ -2288,6 +2296,7 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
*ridp = gr->gr_gid; *ridp = gr->gr_gid;
} }
} else { } else {
#ifdef HAVE_IDMAP
/* It's a user/group ID (eg "12345"). */ /* It's a user/group ID (eg "12345"). */
uid_t id = strtoul(cp, &end, 10); uid_t id = strtoul(cp, &end, 10);
idmap_rid_t rid; idmap_rid_t rid;
@ -2305,6 +2314,9 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
} else { } else {
*ridp = id; *ridp = id;
} }
#else
return (ENOSYS);
#endif /* HAVE_IDMAP */
} }
ASSERT3P(numericsid, ==, NULL); ASSERT3P(numericsid, ==, NULL);