need status codes from cli_net_req_chal() and cli_net_auth2().
[kai/samba.git] / source3 / rpc_client / cli_login.c
index 4520607898004dee84c0233c318d80a701ef923d..06a31a607e0b20a7511209904f0dc736e5e42704 100644 (file)
@@ -29,11 +29,15 @@ extern int DEBUGLEVEL;
 Initialize domain session credentials.
 ****************************************************************************/
 
-BOOL cli_nt_setup_creds(struct cli_state *cli, uint16 fnum, unsigned char mach_pwd[16])
+uint32 cli_nt_setup_creds(struct cli_state *cli, uint16 fnum,
+                               const char* trust_acct,
+                               const char* srv_name,
+                               unsigned char trust_pwd[16],
+                               uint16 sec_chan)
 {
   DOM_CHAL clnt_chal;
   DOM_CHAL srv_chal;
-
+       uint32 ret;
   UTIME zerotime;
 
   /******************* Request Challenge ********************/
@@ -41,16 +45,17 @@ BOOL cli_nt_setup_creds(struct cli_state *cli, uint16 fnum, unsigned char mach_p
   generate_random_buffer( clnt_chal.data, 8, False);
        
   /* send a client challenge; receive a server challenge */
-  if (!cli_net_req_chal(cli, fnum, &clnt_chal, &srv_chal))
+  ret = cli_net_req_chal(cli, fnum, srv_name, &clnt_chal, &srv_chal);
+  if (ret != 0)
   {
     DEBUG(0,("cli_nt_setup_creds: request challenge failed\n"));
-    return False;
+    return ret;
   }
 
   /**************** Long-term Session key **************/
 
   /* calculate the session key */
-  cred_session_key(&clnt_chal, &srv_chal, (char *)mach_pwd, cli->sess_key);
+  cred_session_key(&clnt_chal, &srv_chal, (char *)trust_pwd, cli->sess_key);
   bzero(cli->sess_key+8, 8);
 
   /******************* Authenticate 2 ********************/
@@ -64,34 +69,36 @@ BOOL cli_nt_setup_creds(struct cli_state *cli, uint16 fnum, unsigned char mach_p
    * Receive an auth-2 challenge response and check it.
    */
 
-  if (!cli_net_auth2(cli, fnum, SEC_CHAN_WKSTA, 0x000001ff, &srv_chal))
+  ret = cli_net_auth2(cli, fnum, trust_acct, srv_name,
+                      sec_chan, 0x000001ff, &srv_chal);
+  if (ret != 0x0)
   {
     DEBUG(0,("cli_nt_setup_creds: auth2 challenge failed\n"));
-    return False;
   }
 
-  return True;
+  return ret;
 }
 
 /****************************************************************************
  Set machine password.
  ****************************************************************************/
 
-BOOL cli_nt_srv_pwset(struct cli_state *cli, uint16 fnum, unsigned char *new_hashof_mach_pwd)
+BOOL cli_nt_srv_pwset(struct cli_state *cli, uint16 fnum,
+                     unsigned char *new_hashof_trust_pwd, uint16 sec_chan)
 {
   unsigned char processed_new_pwd[16];
 
   DEBUG(5,("cli_nt_srv_pwset: %d\n", __LINE__));
 
 #ifdef DEBUG_PASSWORD
-  dump_data(6, new_hashof_mach_pwd, 16);
+  dump_data(6, new_hashof_trust_pwd, 16);
 #endif
 
   /* Process the new password. */
-  cred_hash3( processed_new_pwd, new_hashof_mach_pwd, cli->sess_key, 1);
+  cred_hash3( processed_new_pwd, new_hashof_trust_pwd, cli->sess_key, 1);
 
   /* send client srv_pwset challenge */
-  return cli_net_srv_pwset(cli, fnum, processed_new_pwd);
+  return cli_net_srv_pwset(cli, fnum, processed_new_pwd, sec_chan);
 }
 
 /****************************************************************************