prs_init and smb_io_* functions

Mayers, Philip J p.mayers at ic.ac.uk
Sun Nov 26 18:57:52 GMT 2000


Ugh, Samba's internals are *horrible*... ;o)

Could someone give me a quick overview of the prs_* functions and the
smb_io_* functions, and their intended usage pattern. The reason I ask is
that I'm using the following code in the extended-security negotiation:

int process_extsec_blob(void* blob, int length)
{
  RPC_AUTH_VERIFIER authv;
  prs_struct ps;

  prs_init(&ps, 0, 4, NULL, UNMARSHALL);
  prs_give_memory(&ps, blob, length, False);
  if (!smb_io_rpc_auth_verifier("ntlmssp_verf", &authv, &ps, 0)) {
    return -1;
  }

  /* Make sure authv.signature == "NTLMSSP\0" here */

  switch(authv.msg_type) {
    case 1:
      {
        RPC_AUTH_NTLMSSP_NEG neginfo;

        if (!extsec_ready) {
          DEBUG(0, ("NTLMSSP Negotiate message at inappropriate time\n"));
          return -2;
        }

        if (!smb_io_rpc_auth_ntlmssp_neg("ntlmssp_neg", &neginfo, &ps, 0)) {
          DEBUG(0, ("Unable to unmarshall NTLMSSP neg packet\n"));
          return -3;
        }

        /* Process the packet here */
      }

    case 1:
      {
        RPC_AUTH_NTLMSSP_RESP repsinfo;

        if (extsec_ready) {
          DEBUG(0, ("NTLMSSP Response message at inappropriate time\n"));
          return -2;
        }

        if (!smb_io_rpc_auth_ntlmssp_resp("ntlmssp_reps", &neginfo, &ps, 0))
{
          DEBUG(0, ("Unable to unmarshall NTLMSSP resp packet\n"));
          return -3;
        }
      }
    }
  }
}

Am I doing things right? The blob pointer is a pointer into the
smb_buf(inbuf) of the SMB packet - provided I supply a False to the
prs_give_memory call, that's OK, right? The related question is I need to
MARSHELL an challenge packet into the SMB outbuf - is it OK to do that,
provided I give the right length for the memory. When I'm done, how do I get
the *actual* length of the parsed-out data?

Finally, how can I return NT status code 0xC0000016 - the "ERROR" macro
seems to depend on the NT status code bit being set in the Flgs2 of the SMB
outbuf, so I just set that flag, right?

Regards,
Phil

+----------------------------------+
| Phil Mayers, Network Support     |
| Centre for Computing Services    |
| Imperial College                 |
+----------------------------------+  




More information about the samba-technical mailing list