Ignore:
Timestamp:
Mar 12, 2008, 9:08:18 AM (18 years ago)
Author:
Paul Smedley
Message:

Update source to 3.0.28a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/rpc_client/cli_pipe.c

    r1 r124  
    18071807        if (!NT_STATUS_IS_OK(nt_status)) {
    18081808                DEBUG(0,("rpc_finish_auth3_bind: NTLMSSP update using server blob failed.\n"));
     1809                data_blob_free(&server_response);
    18091810                return nt_status;
    18101811        }
     
    23642365        }
    23652366
    2366         DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to machine %s and"
    2367                 "bound NTLMSSP as user %s\\%s.\n",
     2367        DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to "
     2368                "machine %s and bound NTLMSSP as user %s\\%s.\n",
    23682369                result->pipe_name, cli->desthost,
    23692370                domain, username ));
     
    24242425
    24252426/****************************************************************************
    2426  Open a netlogon pipe and get the schannel session key.
    2427  Now exposed to external callers.
     2427  Get a the schannel session key out of an already opened netlogon pipe.
    24282428 ****************************************************************************/
    2429 
    2430 struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
    2431                                                         const char *domain,
    2432                                                         uint32 *pneg_flags,
    2433                                                         NTSTATUS *perr)
    2434 {
    2435         struct rpc_pipe_client *netlogon_pipe = NULL;
     2429static BOOL get_schannel_session_key_common(struct rpc_pipe_client *netlogon_pipe,
     2430                                            struct cli_state *cli,
     2431                                            const char *domain,
     2432                                            uint32 *pneg_flags,
     2433                                            NTSTATUS *perr)
     2434{
    24362435        uint32 sec_chan_type = 0;
    24372436        unsigned char machine_pwd[16];
    2438         fstring machine_account;
    2439 
    2440         netlogon_pipe = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, perr);
    2441         if (!netlogon_pipe) {
    2442                 return NULL;
    2443         }
     2437        const char *machine_account;
    24442438
    24452439        /* Get the machine account credentials from secrets.tdb. */
    2446         if (!get_trust_pw(domain, machine_pwd, &sec_chan_type)) {
     2440        if (!get_trust_pw_hash(domain, machine_pwd, &machine_account,
     2441                               &sec_chan_type))
     2442        {
    24472443                DEBUG(0, ("get_schannel_session_key: could not fetch "
    24482444                        "trust account password for domain '%s'\n",
    24492445                        domain));
    2450                 cli_rpc_pipe_close(netlogon_pipe);
    24512446                *perr = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
    2452                 return NULL;
    2453         }
    2454 
    2455         /* A DC should use DOMAIN$ as its account name.
    2456            A member server can only use it's machine name since it
    2457            does not have an account in a trusted domain.
    2458 
    2459            We don't check the domain against lp_workgroup() here since
    2460            'net ads join' has to continue to work with only the realm
    2461            specified in smb.conf.  -- jerry */
    2462 
    2463         if ( IS_DC && !strequal(domain, lp_workgroup()) && lp_allow_trusted_domains()) {
    2464                 fstrcpy( machine_account, lp_workgroup() );
    2465         } else {
    2466                 fstrcpy(machine_account, global_myname());
    2467         }
     2447                return False;
     2448        }
    24682449
    24692450        *perr = rpccli_netlogon_setup_creds(netlogon_pipe,
     
    24772458
    24782459        if (!NT_STATUS_IS_OK(*perr)) {
    2479                 DEBUG(3,("get_schannel_session_key: rpccli_netlogon_setup_creds "
     2460                DEBUG(3,("get_schannel_session_key_common: rpccli_netlogon_setup_creds "
    24802461                        "failed with result %s to server %s, domain %s, machine account %s.\n",
    24812462                        nt_errstr(*perr), cli->desthost, domain, machine_account ));
    2482                 cli_rpc_pipe_close(netlogon_pipe);
    2483                 return NULL;
     2463                return False;
    24842464        }
    24852465
     
    24872467                DEBUG(3, ("get_schannel_session_key: Server %s did not offer schannel\n",
    24882468                        cli->desthost));
     2469                *perr = NT_STATUS_INVALID_NETWORK_RESPONSE;
     2470                return False;
     2471        }
     2472
     2473        return True;
     2474}
     2475
     2476/****************************************************************************
     2477 Open a netlogon pipe and get the schannel session key.
     2478 Now exposed to external callers.
     2479 ****************************************************************************/
     2480
     2481
     2482struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
     2483                                                        const char *domain,
     2484                                                        uint32 *pneg_flags,
     2485                                                        NTSTATUS *perr)
     2486{
     2487        struct rpc_pipe_client *netlogon_pipe = NULL;
     2488
     2489        netlogon_pipe = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, perr);
     2490        if (!netlogon_pipe) {
     2491                return NULL;
     2492        }
     2493
     2494        if (!get_schannel_session_key_common(netlogon_pipe, cli, domain,
     2495                                             pneg_flags, perr))
     2496        {
    24892497                cli_rpc_pipe_close(netlogon_pipe);
    2490                 *perr = NT_STATUS_INVALID_NETWORK_RESPONSE;
    24912498                return NULL;
    24922499        }
     
    25602567{
    25612568        struct rpc_pipe_client *netlogon_pipe = NULL;
    2562         uint32 sec_chan_type = 0;
    2563         unsigned char machine_pwd[16];
    2564         fstring machine_account;
    25652569
    25662570        netlogon_pipe = cli_rpc_pipe_open_spnego_ntlmssp(cli, PI_NETLOGON, PIPE_AUTH_LEVEL_PRIVACY, domain, username, password, perr);
     
    25692573        }
    25702574
    2571         /* Get the machine account credentials from secrets.tdb. */
    2572         if (!get_trust_pw(domain, machine_pwd, &sec_chan_type)) {
    2573                 DEBUG(0, ("get_schannel_session_key_auth_ntlmssp: could not fetch "
    2574                         "trust account password for domain '%s'\n",
    2575                         domain));
     2575        if (!get_schannel_session_key_common(netlogon_pipe, cli, domain,
     2576                                             pneg_flags, perr))
     2577        {
    25762578                cli_rpc_pipe_close(netlogon_pipe);
    2577                 *perr = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
    2578                 return NULL;
    2579         }
    2580 
    2581         /* if we are a DC and this is a trusted domain, then we need to use our
    2582            domain name in the net_req_auth2() request */
    2583 
    2584         if ( IS_DC && !strequal(domain, lp_workgroup()) && lp_allow_trusted_domains()) {
    2585                 fstrcpy( machine_account, lp_workgroup() );
    2586         } else {
    2587                 /* Hmmm. Is this correct for trusted domains when we're a member server ? JRA. */
    2588                 if (strequal(domain, lp_workgroup())) {
    2589                         fstrcpy(machine_account, global_myname());
    2590                 } else {
    2591                         fstrcpy(machine_account, domain);
    2592                 }
    2593         }
    2594 
    2595         *perr = rpccli_netlogon_setup_creds(netlogon_pipe,
    2596                                         cli->desthost,     /* server name */
    2597                                         domain,            /* domain */
    2598                                         global_myname(),   /* client name */
    2599                                         machine_account,   /* machine account name */
    2600                                         machine_pwd,
    2601                                         sec_chan_type,
    2602                                         pneg_flags);
    2603 
    2604         if (!NT_STATUS_IS_OK(*perr)) {
    2605                 DEBUG(3,("get_schannel_session_key_auth_ntlmssp: rpccli_netlogon_setup_creds "
    2606                         "failed with result %s\n",
    2607                         nt_errstr(*perr) ));
    2608                 cli_rpc_pipe_close(netlogon_pipe);
    2609                 return NULL;
    2610         }
    2611 
    2612         if (((*pneg_flags) & NETLOGON_NEG_SCHANNEL) == 0) {
    2613                 DEBUG(3, ("get_schannel_session_key_auth_ntlmssp: Server %s did not offer schannel\n",
    2614                         cli->desthost));
    2615                 cli_rpc_pipe_close(netlogon_pipe);
    2616                 *perr = NT_STATUS_INVALID_NETWORK_RESPONSE;
    26172579                return NULL;
    26182580        }
     
    26352597                                                NTSTATUS *perr)
    26362598{
    2637         uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;
     2599        uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;
    26382600        struct rpc_pipe_client *netlogon_pipe = NULL;
    26392601        struct rpc_pipe_client *result = NULL;
     
    26692631                                                NTSTATUS *perr)
    26702632{
    2671         uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;
     2633        uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;
    26722634        struct rpc_pipe_client *netlogon_pipe = NULL;
    26732635        struct rpc_pipe_client *result = NULL;
Note: See TracChangeset for help on using the changeset viewer.