summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbutil/view.c11
-rw-r--r--usr/src/lib/libsmbfs/smb/ctx.c3
-rw-r--r--usr/src/lib/libsmbfs/smb/getaddr.c27
-rw-r--r--usr/src/lib/libsmbfs/smb/negprot.c24
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_smb.c20
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c32
6 files changed, 61 insertions, 56 deletions
diff --git a/usr/src/cmd/fs.d/smbclnt/smbutil/view.c b/usr/src/cmd/fs.d/smbclnt/smbutil/view.c
index 365e5b6f37..baad53b00c 100644
--- a/usr/src/cmd/fs.d/smbclnt/smbutil/view.c
+++ b/usr/src/cmd/fs.d/smbclnt/smbutil/view.c
@@ -33,8 +33,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -131,12 +130,11 @@ again:
/*
* Have IPC$ tcon, now list shares.
+ * This prints its own errors.
*/
error = enum_shares(ctx);
- if (error) {
- smb_error("cannot list shares", error);
+ if (error)
return (error);
- }
smb_ctx_free(ctx);
return (0);
@@ -172,7 +170,8 @@ enum_shares(smb_ctx_t *ctx)
*/
error = smb_netshareenum(ctx, &entries, &total, &share_info);
if (error) {
- smb_error(gettext("unable to list resources"), error);
+ smb_error(gettext("//%s failed to list shares"),
+ error, ctx->ct_fullserver);
return (error);
}
print_shares(entries, total, share_info);
diff --git a/usr/src/lib/libsmbfs/smb/ctx.c b/usr/src/lib/libsmbfs/smb/ctx.c
index be97571321..a4620bc457 100644
--- a/usr/src/lib/libsmbfs/smb/ctx.c
+++ b/usr/src/lib/libsmbfs/smb/ctx.c
@@ -1101,7 +1101,8 @@ smb_ctx_resolve(struct smb_ctx *ctx)
if (error) {
const char *ais = gai_strerror(error);
smb_error(dgettext(TEXT_DOMAIN,
- "can't get server address, %s"), 0, ais);
+ "can't resolve name\"%s\", %s"),
+ 0, ctx->ct_fullserver, ais);
return (ENODATA);
}
assert(ctx->ct_addrinfo != NULL);
diff --git a/usr/src/lib/libsmbfs/smb/getaddr.c b/usr/src/lib/libsmbfs/smb/getaddr.c
index 2847d858cb..67e61567a1 100644
--- a/usr/src/lib/libsmbfs/smb/getaddr.c
+++ b/usr/src/lib/libsmbfs/smb/getaddr.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -142,8 +141,6 @@ smb_ctx_getaddr(struct smb_ctx *ctx)
/*
* Default the server name we'll use in the
* protocol (i.e. NTLM, tree connect).
- * If we get a canonical name, we'll
- * overwrite this below.
*/
strlcpy(ctx->ct_srvname, ctx->ct_fullserver,
sizeof (ctx->ct_srvname));
@@ -159,25 +156,6 @@ smb_ctx_getaddr(struct smb_ctx *ctx)
hints.ai_socktype = SOCK_STREAM;
gaierr = getaddrinfo(srvaddr_str, NULL, &hints, &res);
if (gaierr == 0) {
-#if 1
- /*
- * XXX Temporarily work-around CR 6831339:
- * getaddrinfo() sets ai_canonname incorrectly
- */
- char tmphost[256];
- gaierr2 = getnameinfo(res->ai_addr, res->ai_addrlen,
- tmphost, sizeof (tmphost),
- NULL, 0, NI_NAMEREQD);
- if (gaierr2 == 0) {
- DPRINT("cname: %s", tmphost);
- strlcpy(ctx->ct_srvname, tmphost,
- sizeof (ctx->ct_srvname));
- }
-#else
- if (res->ai_canonname)
- strlcpy(ctx->ct_srvname, res->ai_canonname,
- sizeof (ctx->ct_srvname));
-#endif
ctx->ct_addrinfo = res;
return (0);
}
@@ -186,9 +164,6 @@ smb_ctx_getaddr(struct smb_ctx *ctx)
* If regular IP name lookup failed, try NetBIOS,
* but only if given a valid NetBIOS name and if
* NetBIOS name lookup is enabled.
- *
- * Note: we only have ssn_srvname if the full name
- * was also a valid NetBIOS name.
*/
if (nbc->nb_flags & NBCF_NS_ENABLE) {
gaierr2 = nbns_getaddrinfo(ctx->ct_fullserver, nbc, &res);
diff --git a/usr/src/lib/libsmbfs/smb/negprot.c b/usr/src/lib/libsmbfs/smb/negprot.c
index cd6e2866df..9345cd8c47 100644
--- a/usr/src/lib/libsmbfs/smb/negprot.c
+++ b/usr/src/lib/libsmbfs/smb/negprot.c
@@ -31,8 +31,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -111,13 +110,17 @@ smb_negprot(struct smb_ctx *ctx, struct mbdata *oblob)
/*
* Initialize: vc_hflags and vc_hflags2.
* Note: ctx->ct_hflags* are copied into the
- * (per request) rqp->rq_hflags* by smb_rq_init,
- * so changing them after that call will not
- * affect THIS request.
+ * (per request) rqp->rq_hflags* by smb_rq_init.
+ *
+ * Like Windows, set FLAGS2_UNICODE in our first request,
+ * even though technically we don't yet know whether the
+ * server supports Unicode. Will clear this flag below
+ * if we find out it doesn't. Need to do this because
+ * some servers reject all non-Unicode requests.
*/
ctx->ct_hflags = SMB_FLAGS_CASELESS;
- ctx->ct_hflags2 = (SMB_FLAGS2_ERR_STATUS |
- SMB_FLAGS2_KNOWS_LONG_NAMES);
+ ctx->ct_hflags2 = SMB_FLAGS2_KNOWS_LONG_NAMES |
+ SMB_FLAGS2_ERR_STATUS | SMB_FLAGS2_UNICODE;
/*
* Sould we offer extended security?
@@ -276,11 +279,12 @@ smb_negprot(struct smb_ctx *ctx, struct mbdata *oblob)
}
DPRINT("Security signatures: %d", will_sign);
- if (sv->sv_caps & SMB_CAP_UNICODE) {
+ /* See comment above re. FLAGS2_UNICODE */
+ if (sv->sv_caps & SMB_CAP_UNICODE)
ctx->ct_vcflags |= SMBV_UNICODE;
- ctx->ct_hflags2 |= SMB_FLAGS2_UNICODE;
+ else
+ ctx->ct_hflags2 &= ~SMB_FLAGS2_UNICODE;
- }
if ((sv->sv_caps & SMB_CAP_STATUS32) == 0) {
/*
* They don't do NT error codes.
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_smb.c b/usr/src/uts/common/fs/smbclnt/netsmb/smb_smb.c
index 5fa43ece4b..09410ecd8f 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_smb.c
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_smb.c
@@ -33,8 +33,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -126,6 +125,7 @@ smb_smb_treeconnect(struct smb_share *ssp, struct smb_cred *scred)
unc_name = kmem_alloc(unc_len, KM_SLEEP);
(void) snprintf(unc_name, unc_len, "\\\\%s\\%s",
vcp->vc_srvname, ssp->ss_name);
+ SMBSDEBUG("unc_name: \"%s\"", unc_name);
/*
* The password is now pre-computed in the
@@ -178,21 +178,33 @@ smb_smb_treeconnect(struct smb_share *ssp, struct smb_cred *scred)
rqp->sr_flags |= SMBR_NOINTR_RECV;
error = smb_rq_simple(rqp);
SMBSDEBUG("%d\n", error);
- if (error)
+ if (error) {
+ /*
+ * If we get the server name wrong, i.e. due to
+ * mis-configured name services, this will be
+ * NT_STATUS_DUPLICATE_NAME. Log this error.
+ */
+ SMBERROR("(%s) failed, status=0x%x",
+ unc_name, rqp->sr_error);
goto out;
+ }
/*
* Parse the TCON response
*/
smb_rq_getreply(rqp, &mdp);
md_get_uint8(mdp, &wc);
- if (wc != 3) {
+ if (wc != 3 && wc != 7) {
error = EBADRPC;
goto out;
}
md_get_uint16le(mdp, NULL); /* AndX cmd */
md_get_uint16le(mdp, NULL); /* AndX off */
md_get_uint16le(mdp, &options); /* option bits (DFS, search) */
+ if (wc == 7) {
+ md_get_uint32le(mdp, NULL); /* MaximalShareAccessRights */
+ md_get_uint32le(mdp, NULL); /* GuestMaximalShareAcc... */
+ }
error = md_get_uint16le(mdp, &bcnt); /* byte count */
if (error)
goto out;
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c b/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c
index a83f027b50..e29a96631a 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c
@@ -191,6 +191,19 @@ m_dumpm(mblk_t *m)
#define ETIME ETIMEDOUT
#endif
+/*
+ * Log any un-handled NT or DOS errors we encounter.
+ * Make these log NOTICE in a debug build to ensure
+ * they get noticed during tests. In the field these
+ * are unimportant, so just fire a Dtrace probe.
+ */
+static int unknown_err_logpri =
+#ifdef DEBUG
+ CE_NOTE;
+#else
+ CE_CONT;
+#endif
+
typedef struct nt2errno {
unsigned int nterr;
int errno;
@@ -219,6 +232,7 @@ static const nt2errno_t nt2errno[] = {
{NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY},
{NT_STATUS_DISK_FULL, ENOSPC},
{NT_STATUS_DLL_NOT_FOUND, ELIBACC},
+ {NT_STATUS_DUPLICATE_NAME, EINVAL},
{NT_STATUS_END_OF_FILE, ENODATA},
{NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR},
{NT_STATUS_FILE_LOCK_CONFLICT, EAGAIN},
@@ -255,9 +269,9 @@ static const nt2errno_t nt2errno[] = {
{NT_STATUS_NONEXISTENT_SECTOR, ESPIPE},
{NT_STATUS_NONE_MAPPED, EINVAL},
{NT_STATUS_NOT_A_DIRECTORY, ENOTDIR},
- {NT_STATUS_NOT_IMPLEMENTED, ENOSYS},
+ {NT_STATUS_NOT_IMPLEMENTED, ENOTSUP},
{NT_STATUS_NOT_MAPPED_VIEW, EINVAL},
- {NT_STATUS_NOT_SUPPORTED, ENOSYS},
+ {NT_STATUS_NOT_SUPPORTED, ENOTSUP},
{NT_STATUS_NO_MEDIA, ENOMEDIUM},
{NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM},
{NT_STATUS_NO_MEMORY, ENOMEM},
@@ -277,7 +291,7 @@ static const nt2errno_t nt2errno[] = {
{NT_STATUS_PIPE_BUSY, EPIPE},
{NT_STATUS_PIPE_CONNECTED, EISCONN},
{NT_STATUS_PIPE_DISCONNECTED, EPIPE},
- {NT_STATUS_PIPE_NOT_AVAILABLE, ENOSYS},
+ {NT_STATUS_PIPE_NOT_AVAILABLE, EBUSY},
{NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED},
{NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE},
{NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH},
@@ -844,7 +858,8 @@ smb_maperr32(uint32_t nterr)
for (nt2e = nt2errno; nt2e->errno; nt2e++)
if (nt2e->nterr == nterr)
return (nt2e->errno);
- SMBERROR("no direct map for 32 bit server error (0x%x)\n", nterr);
+ smb_errmsg(unknown_err_logpri, "smb_maperr32",
+ "No direct map for 32 bit server error (0x%x)\n", nterr);
/* ok, then try mapping to dos to unix */
for (nt2d = nt2doserr; nt2d->nterr; nt2d++)
@@ -973,13 +988,12 @@ smb_maperror(int eclass, int eno)
case ERRdata:
case ERRgeneral:
return (EIO);
- default:
- SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno);
- return (EIO);
}
}
- SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno);
- return (EBADRPC);
+
+ smb_errmsg(unknown_err_logpri, "smb_maperror",
+ "Unknown DOS error %d/%d\n", eclass, eno);
+ return (EIO);
}
#if defined(NOICONVSUPPORT) || defined(lint)