summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-01-23 00:40:43 +0000
committerdelphij <delphij@FreeBSD.org>2015-01-23 00:40:43 +0000
commit9eb8a0d403b717f81791344ea4f2e20deb46da4d (patch)
tree987a3ad392e45a380aee9f106b96f872eb1ad121 /cddl
parentcbce4fcc9a8dada96a50ac9ad3871fcc6eede7f6 (diff)
downloadFreeBSD-src-9eb8a0d403b717f81791344ea4f2e20deb46da4d.zip
FreeBSD-src-9eb8a0d403b717f81791344ea4f2e20deb46da4d.tar.gz
MFC r275579: MFV r275537:
Illumos issue: 5316 allow smbadm join to use RPC (Due to our lack of smbsrv this is mostly no-op on FreeBSD)
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs_main.c15
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c52
2 files changed, 48 insertions, 19 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
index baac993..f883186 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
@@ -68,6 +68,7 @@
#ifdef sun
#include <aclutils.h>
#include <directory.h>
+#include <idmap.h>
#endif
#include "zfs_iter.h"
@@ -2390,10 +2391,9 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
/* SMB */
char sid[ZFS_MAXNAMELEN + 32];
uid_t id;
- uint64_t classes;
#ifdef sun
int err;
- directory_error_t e;
+ int flag = IDMAP_REQ_FLG_USE_CACHE;
#endif
smbentity = B_TRUE;
@@ -2416,10 +2416,13 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
if (err == 0) {
rid = id;
if (!cb->cb_sid2posix) {
- e = directory_name_from_sid(NULL, sid, &name,
- &classes);
- if (e != NULL)
- directory_error_free(e);
+ if (type == USTYPE_SMB_USR) {
+ (void) idmap_getwinnamebyuid(rid, flag,
+ &name, NULL);
+ } else {
+ (void) idmap_getwinnamebygid(rid, flag,
+ &name, NULL);
+ }
if (name == NULL)
name = sid;
}
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
index bf6bfd4..343f258 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
@@ -2609,7 +2609,7 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
boolean_t isuser;
domain[0] = '\0';
-
+ *ridp = 0;
/* Figure out the property type ({user|group}{quota|space}) */
for (type = 0; type < ZFS_NUM_USERQUOTA_PROPS; type++) {
if (strncmp(propname, zfs_userquota_prop_prefixes[type],
@@ -2631,23 +2631,46 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
* It's a SID name (eg "user@domain") that needs to be
* turned into S-1-domainID-RID.
*/
- directory_error_t e;
+ int flag = 0;
+ idmap_stat stat, map_stat;
+ uid_t pid;
+ idmap_rid_t rid;
+ idmap_get_handle_t *gh = NULL;
+
+ stat = idmap_get_create(&gh);
+ if (stat != IDMAP_SUCCESS) {
+ idmap_get_destroy(gh);
+ return (ENOMEM);
+ }
if (zoned && getzoneid() == GLOBAL_ZONEID)
return (ENOENT);
if (isuser) {
- e = directory_sid_from_user_name(NULL,
- cp, &numericsid);
+ stat = idmap_getuidbywinname(cp, NULL, flag, &pid);
+ if (stat < 0)
+ return (ENOENT);
+ stat = idmap_get_sidbyuid(gh, pid, flag, &numericsid,
+ &rid, &map_stat);
} else {
- e = directory_sid_from_group_name(NULL,
- cp, &numericsid);
+ stat = idmap_getgidbywinname(cp, NULL, flag, &pid);
+ if (stat < 0)
+ return (ENOENT);
+ stat = idmap_get_sidbygid(gh, pid, flag, &numericsid,
+ &rid, &map_stat);
+ }
+ if (stat < 0) {
+ idmap_get_destroy(gh);
+ return (ENOENT);
}
- if (e != NULL) {
- directory_error_free(e);
+ stat = idmap_get_mappings(gh);
+ idmap_get_destroy(gh);
+
+ if (stat < 0) {
return (ENOENT);
}
if (numericsid == NULL)
return (ENOENT);
cp = numericsid;
+ *ridp = rid;
/* will be further decoded below */
#else /* !sun */
return (ENOENT);
@@ -2657,12 +2680,15 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
if (strncmp(cp, "S-1-", 4) == 0) {
/* It's a numeric SID (eg "S-1-234-567-89") */
(void) strlcpy(domain, cp, domainlen);
- cp = strrchr(domain, '-');
- *cp = '\0';
- cp++;
-
errno = 0;
- *ridp = strtoull(cp, &end, 10);
+ if (*ridp == 0) {
+ cp = strrchr(domain, '-');
+ *cp = '\0';
+ cp++;
+ *ridp = strtoull(cp, &end, 10);
+ } else {
+ end = "";
+ }
if (numericsid) {
free(numericsid);
numericsid = NULL;
OpenPOWER on IntegriCloud