r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[vlendec/samba-autobuild/.git] / source3 / auth / auth_compat.c
index eadfb0392b174a95eda91e2facc980a6081fac20..9035f8917ae5cf521cac3581ee70c3ff9ecef3a6 100644 (file)
@@ -5,7 +5,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 
+extern struct auth_context *negprot_global_auth_context;
+extern BOOL global_encrypted_passwords_negotiated;
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_AUTH
+
 /****************************************************************************
- COMPATABILITY INTERFACES:
+ COMPATIBILITY INTERFACES:
  ***************************************************************************/
 
 /****************************************************************************
@@ -65,7 +70,6 @@ static NTSTATUS pass_check_smb(const char *smb_name,
 
 {
        NTSTATUS nt_status;
-       extern struct auth_context *negprot_global_auth_context;
        auth_serversupplied_info *server_info = NULL;
        if (encrypted) {                
                auth_usersupplied_info *user_info = NULL;
@@ -79,7 +83,7 @@ static NTSTATUS pass_check_smb(const char *smb_name,
        } else {
                nt_status = check_plaintext_password(smb_name, plaintext_password, &server_info);
        }               
-       free_server_info(&server_info);
+       TALLOC_FREE(server_info);
        return nt_status;
 }
 
@@ -87,19 +91,28 @@ static NTSTATUS pass_check_smb(const char *smb_name,
 check if a username/password pair is ok via the auth subsystem.
 return True if the password is correct, False otherwise
 ****************************************************************************/
+
 BOOL password_ok(char *smb_name, DATA_BLOB password_blob)
 {
 
-       DATA_BLOB null_password = data_blob(NULL, 0);
-       extern BOOL global_encrypted_passwords_negotiated;
-       BOOL encrypted = (global_encrypted_passwords_negotiated && password_blob.length == 24);
+       DATA_BLOB null_password = data_blob_null;
+       BOOL encrypted = (global_encrypted_passwords_negotiated && (password_blob.length == 24 || password_blob.length > 46));
        
        if (encrypted) {
                /* 
                 * The password could be either NTLM or plain LM.  Try NTLM first, 
                 * but fall-through as required.
-                * NTLMv2 makes no sense here.
+                * Vista sends NTLMv2 here - we need to try the client given workgroup.
                 */
+               if (get_session_workgroup()) {
+                       if (NT_STATUS_IS_OK(pass_check_smb(smb_name, get_session_workgroup(), null_password, password_blob, null_password, encrypted))) {
+                               return True;
+                       }
+                       if (NT_STATUS_IS_OK(pass_check_smb(smb_name, get_session_workgroup(), password_blob, null_password, null_password, encrypted))) {
+                               return True;
+                       }
+               }
+
                if (NT_STATUS_IS_OK(pass_check_smb(smb_name, lp_workgroup(), null_password, password_blob, null_password, encrypted))) {
                        return True;
                }
@@ -115,5 +128,3 @@ BOOL password_ok(char *smb_name, DATA_BLOB password_blob)
 
        return False;
 }
-
-