Author: jelmer Date: 2007-09-07 16:30:06 +0000 (Fri, 07 Sep 2007) New Revision: 25005
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25005 Log: Avoid pstring. Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/auth/ntlmssp/ntlmssp_server.c Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/SAMBA_4_0/source/auth/ntlmssp/ntlmssp_server.c =================================================================== --- branches/SAMBA_4_0/source/auth/ntlmssp/ntlmssp_server.c 2007-09-07 16:27:57 UTC (rev 25004) +++ branches/SAMBA_4_0/source/auth/ntlmssp/ntlmssp_server.c 2007-09-07 16:30:06 UTC (rev 25005) @@ -25,7 +25,6 @@ #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" #include "lib/crypto/crypto.h" -#include "pstring.h" #include "system/filesys.h" #include "libcli/auth/libcli_auth.h" #include "auth/credentials/credentials.h" @@ -105,61 +104,8 @@ } } -/* - Andrew, please remove these totally bogus calls when you get time -*/ -static BOOL get_myfullname(char *my_name) -{ - pstring hostname; - *hostname = 0; - /* get my host name */ - if (gethostname(hostname, sizeof(hostname)) == -1) { - DEBUG(0,("gethostname failed\n")); - return False; - } - - /* Ensure null termination. */ - hostname[sizeof(hostname)-1] = '\0'; - - if (my_name) - fstrcpy(my_name, hostname); - return True; -} - -static BOOL get_mydomname(char *my_domname) -{ - pstring hostname; - char *p; - - /* arrgh! relies on full name in system */ - - *hostname = 0; - /* get my host name */ - if (gethostname(hostname, sizeof(hostname)) == -1) { - DEBUG(0,("gethostname failed\n")); - return False; - } - - /* Ensure null termination. */ - hostname[sizeof(hostname)-1] = '\0'; - - p = strchr_m(hostname, '.'); - - if (!p) - return False; - - p++; - - if (my_domname) - fstrcpy(my_domname, p); - - return True; -} - - - /** * Next state function for the Negotiate packet * @@ -176,7 +122,8 @@ { struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; DATA_BLOB struct_blob; - fstring dnsname, dnsdomname; + char dnsname[MAXHOSTNAMELEN], dnsdomname[MAXHOSTNAMELEN]; + const char *p; uint32_t neg_flags = 0; uint32_t ntlmssp_command, chal_flags; const uint8_t *cryptkey; @@ -227,14 +174,21 @@ gensec_ntlmssp_state->chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8); gensec_ntlmssp_state->internal_chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8); + dnsname[0] = '\0'; + if (gethostname(dnsname, sizeof(dnsname)) == -1) { + DEBUG(0,("gethostname failed\n")); + return NT_STATUS_UNSUCCESSFUL; + } + /* This should be a 'netbios domain -> DNS domain' mapping */ - dnsdomname[0] = '\0'; - get_mydomname(dnsdomname); - strlower_m(dnsdomname); + p = strchr(dnsname, '.'); + if (p != NULL) { + safe_strcpy(dnsdomname, p+1, sizeof(dnsdomname)); + strlower_m(dnsdomname); + } else { + dnsdomname[0] = '\0'; + } - dnsname[0] = '\0'; - get_myfullname(dnsname); - /* This creates the 'blob' of names that appears at the end of the packet */ if (chal_flags & NTLMSSP_CHAL_TARGET_INFO) {