r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[abartlet/samba.git/.git] / source3 / auth / pass_check.c
index 63918796efbc95c97739f481fb5bfe2e131ab5b9..b1a6e4d4021f35265cc73469d4bda3933834e457 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,
@@ -14,8 +14,7 @@
    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/>.
 */
 
 /* this module is for checking a username/password against a system
@@ -92,6 +91,7 @@ check on a DCE/DFS authentication
 ********************************************************************/
 static BOOL dfs_auth(char *user, char *password)
 {
+       struct tm *t;
        error_status_t err;
        int err2;
        int prterr;
@@ -341,8 +341,13 @@ static BOOL dfs_auth(char *user, char *password)
        set_effective_uid(0);
        set_effective_gid(0);
 
-       DEBUG(0,
-             ("DCE context expires: %s", asctime(localtime(&expire_time))));
+       t = localtime(&expire_time);
+       if (t) {
+               const char *asct = asctime(t);
+               if (asct) {
+                       DEBUG(0,("DCE context expires: %s", asct));
+               }
+       }
 
        dcelogin_atmost_once = 1;
        return (True);
@@ -452,9 +457,9 @@ static NTSTATUS string_combinations2(char *s, int offset, NTSTATUS (*fn) (const
 
        for (i = offset; i < (len - (N - 1)); i++) {
                char c = s[i];
-               if (!islower(c))
+               if (!islower_ascii(c))
                        continue;
-               s[i] = toupper(c);
+               s[i] = toupper_ascii(c);
                if (!NT_STATUS_EQUAL(nt_status = string_combinations2(s, i + 1, fn, N - 1),NT_STATUS_WRONG_PASSWORD)) {
                        return (nt_status);
                }
@@ -579,7 +584,7 @@ static NTSTATUS password_check(const char *password)
        }
 #endif /* HAVE_CRYPT */
 #endif /* HAVE_BIGCRYPT && HAVE_CRYPT && USE_BOTH_CRYPT_CALLS */
-#endif /* WITH_PAM || KRB4_AUTH || KRB5_AUTH */
+#endif /* WITH_PAM */
 }
 
 
@@ -599,7 +604,7 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
 
        NTSTATUS nt_status;
 
-#if DEBUG_PASSWORD
+#ifdef DEBUG_PASSWORD
        DEBUG(100, ("checking user=[%s] pass=[%s]\n", user, password));
 #endif
 
@@ -634,6 +639,7 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
        /* Also the place to keep the 'password' no matter what
           crazy struct it started in... */
        fstrcpy(this_crypted, pass->pw_passwd);
+       fstrcpy(this_salt, pass->pw_passwd);
 
 #ifdef HAVE_GETSPNAM
        {
@@ -645,8 +651,10 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
                   perhaps for IPC password changing requests */
 
                spass = getspnam(pass->pw_name);
-               if (spass && spass->sp_pwdp)
+               if (spass && spass->sp_pwdp) {
                        fstrcpy(this_crypted, spass->sp_pwdp);
+                       fstrcpy(this_salt, spass->sp_pwdp);
+               }
        }
 #elif defined(IA_UINFO)
        {
@@ -704,9 +712,6 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
        }
 #endif
 
-       /* extract relevant info */
-       fstrcpy(this_salt, pass->pw_passwd);
-
 #if defined(HAVE_TRUNCATED_SALT)
        /* crypt on some platforms (HPUX in particular)
           won't work with more than 2 salt characters. */
@@ -757,7 +762,7 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
 
        /* try all lowercase if it's currently all uppercase */
        if (strhasupper(pass2)) {
-               strlower(pass2);
+               strlower_m(pass2);
                if NT_STATUS_IS_OK(nt_status = password_check(pass2)) {
                        if (fn)
                                fn(user, pass2);
@@ -771,8 +776,7 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
        }
 
        /* last chance - all combinations of up to level chars upper! */
-       strlower(pass2);
-
+       strlower_m(pass2);
  
         if (NT_STATUS_IS_OK(nt_status = string_combinations(pass2, password_check, level))) {
                 if (fn)