diff options
author | Keyur Desai <Keyur.Desai@Sun.COM> | 2010-04-02 15:07:12 -0600 |
---|---|---|
committer | Keyur Desai <Keyur.Desai@Sun.COM> | 2010-04-02 15:07:12 -0600 |
commit | c586600796766c83eb9485c446886fd9ed2359a9 (patch) | |
tree | be38c992d2fa6b7489bce2b0e6e81ad8dba9d3c2 /usr/src/cmd/smbsrv | |
parent | a23420cf95f05ac67f2c299116a3225581e519d1 (diff) | |
download | illumos-gate-c586600796766c83eb9485c446886fd9ed2359a9.tar.gz |
6932404 Autohome share does not show up when using sharemgr show -vp
6875358 NDR support for Serialization Types
6811350 Autohome wildcard rule fails with mixed case (or upper case) user name
6932967 Add local group manipulation functions to SAMR service
6801203 libidmap should not link with bunch of libraries
6928764 Diagnostic noise on "idmap get-namemap" and "idmap set-namemap"
6885923 idmapd loops infinitely, leaking memory
6936722 Sparc : Unable to destroy zpool, sharemgr locks up.
6937163 smbd door operations should initialize XDR decode data
6937814 Memory corruption while running stress test
6913525 smb_ads_decode_host_ip doesn't step over IPv6 address
6939430 queryfileinfo should only use vnodetopath for directory nodes
6938318 Unable to save files with Save As
--HG--
rename : usr/src/lib/libidmap/common/namemaps.c => usr/src/cmd/idmap/idmap/namemaps.c
rename : usr/src/lib/libidmap/common/idmap_priv.h => usr/src/cmd/idmap/idmap/namemaps.h
Diffstat (limited to 'usr/src/cmd/smbsrv')
-rw-r--r-- | usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c | 53 | ||||
-rw-r--r-- | usr/src/cmd/smbsrv/smbd/smbd_logon.c | 17 | ||||
-rw-r--r-- | usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c | 15 |
3 files changed, 67 insertions, 18 deletions
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c b/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c index 7dc3eef535..e936029edc 100644 --- a/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c +++ b/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/list.h> @@ -45,10 +44,13 @@ #include <smbsrv/libsmbns.h> #include "smbd.h" +#define SMBD_ARG_MAGIC 0x53415247 /* 'SARG' */ + /* * Parameter for door operations. */ typedef struct smbd_arg { + uint32_t magic; list_node_t lnd; smb_doorhdr_t hdr; const char *opname; @@ -56,6 +58,8 @@ typedef struct smbd_arg { size_t datalen; char *rbuf; size_t rsize; + boolean_t response_ready; + boolean_t response_abort; uint32_t status; } smbd_arg_t; @@ -254,7 +258,6 @@ smbd_door_dispatch(void *cookie, char *argp, size_t arg_size, door_desc_t *dp, hdr->dh_door_rc = SMB_DOP_SUCCESS; else hdr->dh_door_rc = SMB_DOP_NOT_CALLED; - } else { (void) smbd_door_dispatch_op(&dop_arg); } @@ -318,6 +321,7 @@ smbd_door_dispatch_async(smbd_arg_t *req_arg) } (void) mutex_lock(&smbd_doorsvc.sd_mutex); + arg->magic = SMBD_ARG_MAGIC; list_insert_tail(&smbd_doorsvc.sd_async_list, arg); ++smbd_doorsvc.sd_async_count; (void) mutex_unlock(&smbd_doorsvc.sd_mutex); @@ -346,9 +350,13 @@ static void smbd_door_release_async(smbd_arg_t *arg) { if (arg != NULL) { + assert(arg->magic == SMBD_ARG_MAGIC); + arg->magic = (uint32_t)~SMBD_ARG_MAGIC; + list_remove(&smbd_doorsvc.sd_async_list, arg); --smbd_doorsvc.sd_async_count; free(arg->data); + arg->data = NULL; free(arg); } } @@ -358,6 +366,10 @@ smbd_door_release_async(smbd_arg_t *arg) * - synchronous calls are invoked by direct function call * - asynchronous calls are invoked from a launched thread * + * If the kernel has attempted to collect a response before the op + * has completed, the arg will have been marked as response_abort + * and we can discard the response data and release the arg. + * * We send a notification when asynchronous (ASYNC) door calls * from the kernel (SYSSPACE) have completed. */ @@ -385,6 +397,17 @@ smbd_door_dispatch_op(void *thread_arg) if ((hdr->dh_flags & SMB_DF_SYSSPACE) && (hdr->dh_flags & SMB_DF_ASYNC)) { assert(hdr->dh_op != SMB_DR_ASYNC_RESPONSE); + + (void) mutex_lock(&smbd_doorsvc.sd_mutex); + if (arg->response_abort) { + free(arg->rbuf); + arg->rbuf = NULL; + smbd_door_release_async(arg); + } else { + arg->response_ready = B_TRUE; + } + (void) mutex_unlock(&smbd_doorsvc.sd_mutex); + (void) smb_kmod_event_notify(hdr->dh_txid); } @@ -484,6 +507,10 @@ smbd_dop_null(smbd_arg_t *arg) * Async response handler: setup the rbuf and rsize for the specified * transaction. This function is used by the kernel to collect the * response half of an asynchronous door call. + * + * If a door client attempts to collect a response before the op has + * completed (!response_ready), mark the arg as response_abort and + * set an error. The response will be discarded when the op completes. */ static int smbd_dop_async_response(smbd_arg_t *rsp_arg) @@ -495,7 +522,17 @@ smbd_dop_async_response(smbd_arg_t *rsp_arg) arg = list_head(arg_list); while (arg != NULL) { + assert(arg->magic == SMBD_ARG_MAGIC); + if (arg->hdr.dh_txid == rsp_arg->hdr.dh_txid) { + if (!arg->response_ready) { + arg->response_abort = B_TRUE; + rsp_arg->hdr.dh_door_rc = SMB_DOP_NOT_CALLED; + syslog(LOG_NOTICE, "doorsvc[%s]: %u not ready", + arg->opname, arg->hdr.dh_txid); + break; + } + rsp_arg->rbuf = arg->rbuf; rsp_arg->rsize = arg->rsize; arg->rbuf = NULL; @@ -514,7 +551,7 @@ smbd_dop_async_response(smbd_arg_t *rsp_arg) static int smbd_dop_user_nonauth_logon(smbd_arg_t *arg) { - uint32_t sid; + uint32_t sid = 0; if (smb_common_decode(arg->data, arg->datalen, xdr_uint32_t, &sid) != 0) @@ -527,7 +564,7 @@ smbd_dop_user_nonauth_logon(smbd_arg_t *arg) static int smbd_dop_user_auth_logoff(smbd_arg_t *arg) { - uint32_t sid; + uint32_t sid = 0; if (smb_common_decode(arg->data, arg->datalen, xdr_uint32_t, &sid) != 0) @@ -574,6 +611,8 @@ smbd_dop_lookup_name(smbd_arg_t *arg) lsa_account_t acct; char buf[MAXNAMELEN]; + bzero(&acct, sizeof (lsa_account_t)); + if (smb_common_decode(arg->data, arg->datalen, lsa_account_xdr, &acct) != 0) return (SMB_DOP_DECODE_ERROR); @@ -617,6 +656,8 @@ smbd_dop_lookup_sid(smbd_arg_t *arg) lsa_account_t acct; smb_sid_t *sid; + bzero(&acct, sizeof (lsa_account_t)); + if (smb_common_decode(arg->data, arg->datalen, lsa_account_xdr, &acct) != 0) return (SMB_DOP_DECODE_ERROR); @@ -653,6 +694,8 @@ smbd_dop_join(smbd_arg_t *arg) smb_joininfo_t jdi; uint32_t status; + bzero(&jdi, sizeof (smb_joininfo_t)); + if (smb_common_decode(arg->data, arg->datalen, smb_joininfo_xdr, &jdi) != 0) return (SMB_DOP_DECODE_ERROR); diff --git a/usr/src/cmd/smbsrv/smbd/smbd_logon.c b/usr/src/cmd/smbsrv/smbd/smbd_logon.c index 97f9e47b51..fe27e9cd7f 100644 --- a/usr/src/cmd/smbsrv/smbd/smbd_logon.c +++ b/usr/src/cmd/smbsrv/smbd/smbd_logon.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -36,6 +35,9 @@ #include <bsm/adt.h> #include <bsm/adt_event.h> #include <bsm/audit_uevents.h> +#include <pwd.h> +#include <nss_dbdefs.h> +#include <sys/idmap.h> #include "smbd.h" @@ -212,11 +214,20 @@ smbd_user_auth_logoff(uint32_t audit_sid) smb_audit_t *entry; adt_session_data_t *ah; adt_event_data_t *event; + struct passwd pw; + char buf[NSS_LINELEN_PASSWD]; if ((entry = smbd_audit_unlink(audit_sid)) == NULL) return; - smb_autohome_remove(entry->sa_username); + if (IDMAP_ID_IS_EPHEMERAL(entry->sa_uid)) { + smb_autohome_remove(entry->sa_username); + } else { + if (getpwuid_r(entry->sa_uid, &pw, buf, sizeof (buf)) == NULL) + return; + + smb_autohome_remove(pw.pw_name); + } ah = entry->sa_handle; diff --git a/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c b/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c index 5ec93bd59f..3792e23853 100644 --- a/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c +++ b/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -257,16 +256,12 @@ smbd_share_dispatch(void *cookie, char *ptr, size_t size, door_desc_t *dp, case SMB_SHROP_ENUM: esi.es_bufsize = smb_dr_get_ushort(dec_ctx); - esi.es_username = smb_dr_get_string(dec_ctx); - if ((dec_status = smb_dr_decode_finish(dec_ctx)) != 0) { - smb_dr_free_string(esi.es_username); + esi.es_posix_uid = smb_dr_get_uint32(dec_ctx); + if ((dec_status = smb_dr_decode_finish(dec_ctx)) != 0) goto decode_error; - } rc = smbd_share_enum(&esi); - smb_dr_free_string(esi.es_username); - smb_dr_put_int32(enc_ctx, SMB_SHARE_DSUCCESS); smb_dr_put_uint32(enc_ctx, rc); if (rc == NERR_Success) { @@ -380,7 +375,7 @@ smbd_share_enum(smb_enumshare_info_t *esi) continue; if ((si->shr_flags & SMB_SHRF_AUTOHOME) && !autohome_added) { - if (strcasecmp(esi->es_username, si->shr_name) == 0) + if (esi->es_posix_uid == si->shr_uid) autohome_added = B_TRUE; else continue; @@ -417,7 +412,7 @@ smbd_share_enum(smb_enumshare_info_t *esi) continue; if ((si->shr_flags & SMB_SHRF_AUTOHOME) && !autohome_added) { - if (strcasecmp(esi->es_username, si->shr_name) == 0) + if (esi->es_posix_uid == si->shr_uid) autohome_added = B_TRUE; else continue; |