5316 allow smbadm join to use RPC
Reviewed by: Bayard Bell <bayard.bell@nexenta.com> Reviewed by: Dan McDonald <danmcd@nexenta.com> Reviewed by: Thomas Keiser <thomas.keiser@nexenta.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Robert Mustacchi <rm@joyent.com> Author: Gordon Ross <gwr@nexenta.com> illumos/illumos-gate@1ed6b69a5c
This commit is contained in:
parent
3d7f2224b8
commit
e9b500ac47
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/illumos/dist/; revision=275537
@ -63,6 +63,7 @@
|
||||
#include <libuutil.h>
|
||||
#include <aclutils.h>
|
||||
#include <directory.h>
|
||||
#include <idmap.h>
|
||||
|
||||
#include "zfs_iter.h"
|
||||
#include "zfs_util.h"
|
||||
@ -2372,9 +2373,8 @@ 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;
|
||||
int err;
|
||||
directory_error_t e;
|
||||
int flag = IDMAP_REQ_FLG_USE_CACHE;
|
||||
|
||||
smbentity = B_TRUE;
|
||||
|
||||
@ -2391,10 +2391,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;
|
||||
}
|
||||
|
@ -2557,7 +2557,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],
|
||||
@ -2578,35 +2578,61 @@ 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 (e != NULL) {
|
||||
directory_error_free(e);
|
||||
if (stat < 0) {
|
||||
idmap_get_destroy(gh);
|
||||
return (ENOENT);
|
||||
}
|
||||
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 */
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user