Converted cli_net_auth2() and cli_nt_setup_creds() to return NTSTATUS.
authorTim Potter <tpot@samba.org>
Tue, 18 Sep 2001 02:49:35 +0000 (02:49 +0000)
committerTim Potter <tpot@samba.org>
Tue, 18 Sep 2001 02:49:35 +0000 (02:49 +0000)
(This used to be commit e0bdcbc5994345fdc76f7590dba7bce5f0127d58)

source3/libsmb/domain_client_validate.c
source3/rpc_client/cli_login.c
source3/rpc_client/cli_netlogon.c
source3/rpc_client/cli_trust.c
source3/rpcclient/cmd_netlogon.c

index 90c15fd1f75c29054ba681ccde8156b26148cd06..5a8ae372ea073f3f28492abefbe241b4f3daaa0b 100644 (file)
@@ -37,6 +37,7 @@ static BOOL connect_to_domain_password_server(struct cli_state *pcli,
 {
        struct in_addr dest_ip;
        fstring remote_machine;
+        NTSTATUS result;
 
        if(cli_initialise(pcli) == NULL) {
                DEBUG(0,("connect_to_domain_password_server: unable to initialize client connection.\n"));
@@ -154,9 +155,11 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(pcli)));
                return False;
        }
 
-       if (cli_nt_setup_creds(pcli, trust_passwd) == False) {
+       result = cli_nt_setup_creds(pcli, trust_passwd);
+
+        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(0,("connect_to_domain_password_server: unable to setup the PDC credentials to machine \
-%s. Error was : %s.\n", remote_machine, cli_errstr(pcli)));
+%s. Error was : %s.\n", remote_machine, get_nt_error_msg(result)));
                cli_nt_session_close(pcli);
                cli_ulogoff(pcli);
                cli_shutdown(pcli);
index de0c9ac62a9a402f89308d407e83df3071dc4270..790fddd7c3fb54af530c981aad70a2b8a716a319 100644 (file)
@@ -31,8 +31,9 @@ extern pstring global_myname;
 Initialize domain session credentials.
 ****************************************************************************/
 
-BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16])
+NTSTATUS cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16])
 {
+  NTSTATUS result;
   DOM_CHAL clnt_chal;
   DOM_CHAL srv_chal;
 
@@ -46,7 +47,7 @@ BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16])
   if (!cli_net_req_chal(cli, &clnt_chal, &srv_chal))
   {
     DEBUG(0,("cli_nt_setup_creds: request challenge failed\n"));
-    return False;
+    return NT_STATUS_UNSUCCESSFUL;
   }
 
   /**************** Long-term Session key **************/
@@ -66,14 +67,16 @@ BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16])
    * Receive an auth-2 challenge response and check it.
    */
 
-  if (!cli_net_auth2(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ?
-                     SEC_CHAN_WKSTA : SEC_CHAN_BDC, 0x000001ff, &srv_chal))
+  result = cli_net_auth2(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ?
+                         SEC_CHAN_WKSTA : SEC_CHAN_BDC, 0x000001ff, &srv_chal);
+  
+  if (!NT_STATUS_IS_OK(result))
   {
     DEBUG(0,("cli_nt_setup_creds: auth2 challenge failed\n"));
-    return False;
+    return result;
   }
 
-  return True;
+  return NT_STATUS_OK;
 }
 
 /****************************************************************************
index b1f4fe0257d03c718f3172f65f9d2ec132e94481..324f5dc90f49e765fb6eb684c56b558fd9afbf42 100644 (file)
@@ -118,13 +118,14 @@ Ensure that the server credential returned matches the session key
 encrypt of the server challenge originally received. JRA.
 ****************************************************************************/
 
-BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan, 
-                   uint32 neg_flags, DOM_CHAL *srv_chal)
+NTSTATUS cli_net_auth2(struct cli_state *cli, uint16 sec_chan, 
+                       uint32 neg_flags, DOM_CHAL *srv_chal)
 {
   prs_struct rbuf;
   prs_struct buf; 
   NET_Q_AUTH_2 q_a;
   BOOL ok = False;
+  NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
 
   prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
   prs_init(&rbuf, 0,    cli->mem_ctx, UNMARSHALL);
@@ -144,7 +145,7 @@ BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan,
     DEBUG(0,("cli_net_auth2: Error : failed to marshall NET_Q_AUTH_2 struct.\n"));
     prs_mem_free(&buf);
     prs_mem_free(&rbuf);
-    return False;
+    return result;
   }
 
   /* send the data on \PIPE\ */
@@ -153,11 +154,12 @@ BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan,
     NET_R_AUTH_2 r_a;
 
     ok = net_io_r_auth_2("", &r_a, &rbuf, 0);
-               
-    if (ok && !NT_STATUS_IS_OK(r_a.status))
+    result = r_a.status;
+
+    if (ok && !NT_STATUS_IS_OK(result))
     {
       /* report error code */
-      DEBUG(0,("cli_net_auth2: Error %s\n", get_nt_error_msg(r_a.status)));
+      DEBUG(0,("cli_net_auth2: Error %s\n", get_nt_error_msg(result)));
       ok = False;
     }
 
@@ -200,7 +202,7 @@ password ?).\n", cli->desthost ));
   prs_mem_free(&buf);
   prs_mem_free(&rbuf);
 
-  return ok;
+  return result;
 }
 
 /****************************************************************************
index eed6ba7b2beb6e6d77c4387c993f53cc22ed2997..d7faf4975f6eedb45ed60eedbe8b44bd29ae4a15 100644 (file)
@@ -35,6 +35,7 @@ static BOOL modify_trust_password( char *domain, char *remote_machine,
                           unsigned char new_trust_passwd_hash[16])
 {
   struct cli_state cli;
+  NTSTATUS result;
 
   ZERO_STRUCT(cli);
   if(cli_initialise(&cli) == NULL) {
@@ -131,9 +132,11 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli)));
     return False;
   } 
   
-  if(cli_nt_setup_creds(&cli, orig_trust_passwd_hash) == False) {
+  result = cli_nt_setup_creds(&cli, orig_trust_passwd_hash);
+
+  if (!NT_STATUS_IS_OK(result)) {
     DEBUG(0,("modify_trust_password: unable to setup the PDC credentials to machine \
-%s. Error was : %s.\n", remote_machine, cli_errstr(&cli)));
+%s. Error was : %s.\n", remote_machine, get_nt_error_msg(result)));
     cli_nt_session_close(&cli);
     cli_ulogoff(&cli);
     cli_shutdown(&cli);
index 41bf8883a21fb3e8eff6fe05ec088c74a2558592..3adae373ffaa5c969ca89f50834a550f8b6816d6 100644 (file)
@@ -212,7 +212,9 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, int argc,
                goto done;
        }        
 
-        if (!cli_nt_setup_creds(cli, trust_passwd)) {
+        result = cli_nt_setup_creds(cli, trust_passwd);
+
+        if (!NT_STATUS_IS_OK(result)) {
                 DEBUG(0, ("Error initialising session creds\n"));
                 goto done;
         }
@@ -285,7 +287,9 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, int argc,
                goto done;
        }        
 
-        if (!cli_nt_setup_creds(cli, trust_passwd)) {
+        result = cli_nt_setup_creds(cli, trust_passwd);
+
+        if (!NT_STATUS_IS_OK(result)) {
                 DEBUG(0, ("Error initialising session creds\n"));
                 goto done;
         }