2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Client NDR RPC interface. 2N/A * info cache is used to hold information about domain controllers. 2N/A * Writers: Both DC discovery and failover threads make SRVSVC NetServerGetInfo 2N/A * request to obtain information about the selected DC. On success, 2N/A * ndr_svinfo_update() is called to update the cache. 2N/A * NOTE: this cache is updated every 20 minutes due to the periodic 2N/A * discovery cycle or upon a successful DC failover. 2N/A * Readers: DC Monitor and door service threads that are launched to make 2N/A * non-SRVSVC MS-RPC requests call ndr_svinfo_lookup() to obtain 2N/A * information about the selected DC from the cache. 2N/A * In the future, if our non-SRVSVC MS-RPC clients ever need to talk to 2N/A * remote servers other than domain controllers, then entries for those remote 2N/A * servers can be added by the door service threads which are launched to 2N/A * process the MS-RPC requests. 2N/A/* Bindings to remote MS-RPC services are now serialized on bind_mutex. */ 2N/A * All NDR RPC service initialization is invoked from here. 2N/A * Initialize the RPC client interface: create the server info cache. 2N/A * Terminate the RPC client interface: flush and destroy the server info 2N/A * Returns Kerberos realm from the passed domain name. 2N/A * Realm is obtained from the resolver by comparing the passed domain name with 2N/A * - the resolver domain name or 2N/A * - the first part of the resolver domain name. 2N/A * Caller should free memory allocated to the returned realm. 2N/A * This functions sets up Kerberos credentials for authenticated outbound 2N/A * requests to the domain controller. If the credentials cannot be acquired, 2N/A * smb_kinit() function is called to establish credentials. 2N/A * Returns 0 if username is anonymous, setting cred cache or kinit fails. 2N/A * Returns -1 in case of errors. 2N/A * Setup libsmbfs keychain for authenticating the connection. 2N/A * This call must be made to initialize an RPC client structure and bind 2N/A * to the remote service before any RPCs can be exchanged with that service. 2N/A * The mlsvc_handle_t is a wrapper that is used to associate an RPC handle 2N/A * with the client context for an instance of the interface. The handle 2N/A * is zeroed to ensure that it doesn't look like a valid handle - 2N/A * handle content is provided by the remove service. 2N/A * The client points to this top-level handle so that we know when to 2N/A * unbind and teardown the connection. As each handle is initialized it 2N/A * will inherit a reference to the client context. 2N/A * The server name must be resolvable by the smb/client, which will extract 2N/A * it from the UNC path and use it to open a socket to the server. 2N/A * Using the NetBIOS name may not always work since there is no guarantee 2N/A * that NetBIOS name resolution will be available. 2N/A /* Anonymous connection. */ 2N/A /* Setup Kerberos credentials for libsmbfs */ 2N/A " kerberos setup failed",
2N/A /* Setup Keychain for libsmbfs */ 2N/A "ndr_rpc_bind[tid=%d] %s %s: keychain add failed",
2N/A * Set the default based on the assumption that most 2N/A * servers will be Windows 2000 or later. 2N/A * Don't lookup the svinfo if this is a SRVSVC request 2N/A * because the SRVSVC is used to get the server info. 2N/A * None of the SRVSVC calls depend on the server info. 2N/A * It's rare that the lookup could fail since DC discovery 2N/A * and failover services are responsible for creating 2N/A * entries for the currently selected DC at service startup 2N/A * and the previously selected DC where failures have been 2N/A * reported, respectively. But it could happen when the 2N/A * machine password stored locally no longer matches with 2N/A * what stored in Active Directory. 2N/A errmsg =
"server does not support this named pipe";
2N/A * Check the errno to determine whether the binding failure is caused 2N/A * by the the selected DC being unreachable. 2N/A * Solaris SMB client sets ENODATA upon name->IP resolution failures. 2N/A * Solaris SMB client sets ETIME if the data doesn't arrive before the 2N/A * timeout. See nb_ssn_pollin(). 2N/A * Solaris SMB client sets EPROTO when it fails to send or receive NetBIOS 2N/A * NOTE: this function relies on the errno set by SMB client API to determine 2N/A * whether a remote server is reachable or not. Since the errno(s) are not a 2N/A * committed interface and can, and most likely will change in the future, 2N/A * any changes to the SMB client APIs that are consumed by ndr_rpc_bind() today 2N/A * will need to regression tested the DC failover implementation and the 2N/A * following errno(s) should be updated accordingly. 2N/A * The server parameter is expected to be a fully qualified hostname, hostname, 2N/A * NetBIOS name or an IP address. 2N/A * Unbind and close the pipe to an RPC service. 2N/A * If the heap has been preserved we need to go through an xa release. 2N/A * The heap is preserved during an RPC call because that's where data 2N/A * returned from the server is stored. 2N/A * Otherwise we destroy the heap directly. 2N/A * Call the RPC function identified by opnum. The remote service is 2N/A * identified by the handle, which should have been initialized by 2N/A * If the RPC call is successful (returns 0), the caller must call 2N/A * ndr_rpc_release to release the heap. Otherwise, we release the 2N/A * Always clear the nonull flag to ensure 2N/A * it is not applied to subsequent calls. 2N/A * Some MSRPC services declare an RPC binding handle based on the 2N/A * server's NetBIOS name prefixed (UNC style) by two backslashes. 2N/A * The NetBIOS name is derived from the server's hostname. 2N/A * The services are inconsistent on handle validation by the server. 2N/A * The RPC binding handle may be explicitly declared as a handle 2N/A * in the IDL (as shown below) or it may simply appear as a regular 2N/A * wchar_t parameter to an RPC. 2N/A * typedef [handle] wchar_t *RPC_HANDLE; 2N/A * Outgoing strings should not be null terminated. 2N/A * Return a reference to the server info. 2N/A * Return the RPC server OS level. 2N/A * Get the session key from a bound RPC client handle. 2N/A * The key returned is the 16-byte "user session key" 2N/A * established by the underlying authentication protocol 2N/A * (either Kerberos or NTLM). This key is needed for 2N/A * SAM RPC calls such as SamrSetInformationUser, etc. 2N/A * See [MS-SAMR] sections: 2.2.3.3, 2.2.7.21, 2.2.7.25. 2N/A * The RPC endpoint must be bound when this is called 2N/A * (so that clnt->fid is an open named pipe) 2N/A * Returns zero (success) or an errno. 2N/A * Must be called by RPC clients to free the heap after a successful RPC 2N/A * call, i.e. ndr_rpc_call returned 0. The caller should take a copy 2N/A * of any data returned by the RPC prior to calling this function because 2N/A * returned data is in the heap. 2N/A * Returns true if the handle is null. 2N/A * Otherwise returns false. 2N/A * Returns true if the handle is the top level bind handle. 2N/A * Otherwise returns false. 2N/A * Pass the client reference from parent to child. 2N/A char *s =
"unknown";
2N/A * The following functions provide the client callback interface. 2N/A * If the caller hasn't provided a heap, create one here. 2N/A * This is the entry pointy for an RPC client call exchange with 2N/A * a server, which will result in an SmbTransact request. 2N/A * On success, the receive stream pdu_size indicates the number 2N/A * of bytes received. 2N/A * TBD: handling overflow. 2N/A * This entry point will be invoked if the xa-exchange response contained 2N/A * only the first fragment of a multi-fragment response. The RPC client 2N/A * code will then make repeated xa-read requests to obtain the remaining 2N/A * fragments, which will result in SmbReadX requests. 2N/A * SmbReadX should return the number of bytes received, in which case we 2N/A * expand the PDU size to include the received data, or a negative error 2N/A * Preserve the heap so that the client application has access to data 2N/A * returned from the server after an RPC call. 2N/A * Dispose of the transaction streams. If the heap has not been 2N/A * preserved, we can destroy it here. 2N/A * Dispose of a preserved heap. 2N/A * Lookup platform, type and version information about a server. 2N/A * Adding a new entry or replacing an existing entry for the 2N/A * specified server in the server info cache. 2N/A * Compare the specified server and domain against the server and domain fields 2N/A * of each cache entry, respectively . If we find a cache entry with a matching 2N/A * server name but its corresponding domain information doesn't match, it's 2N/A * likely that the specified domain and the cached domain are stored in 2N/A * different formats. Converts the domain names from the fully-qualified 2N/A * format to NetBIOS format for further comparison. 2N/A * Compare the time here with the remote time on the server 2N/A * and report clock skew.