]> granicus.if.org Git - linux-pam/blobdiff - modules/pam_unix/passverify.c
Relevant BUGIDs: 2487654
[linux-pam] / modules / pam_unix / passverify.c
index 281716e09c42ee1743840fec109976165bf746ed..8cf95c3331afef93f0bd90814f1034cafb92880d 100644 (file)
@@ -272,8 +272,16 @@ PAMH_ARG_DECL(int check_shadow_expiry,
                *daysleft = (int)((spent->sp_lstchg + spent->sp_max) - curdays);
                D(("warn before expiry"));
        }
+       if ((curdays - spent->sp_lstchg < spent->sp_min)
+           && (spent->sp_min != -1)) {
+               /* 
+                * The last password change was too recent. This error will be ignored
+                * if no password change is attempted.
+                */
+               D(("password change too recent"));
+               return PAM_AUTHTOK_ERR;
+       }
        return PAM_SUCCESS;
-
 }
 
 /* passwd/salt conversion macros */
@@ -672,8 +680,13 @@ save_old_password(pam_handle_t *pamh, const char *forwho, const char *oldpass,
        }
     }
 
+    if (fflush(pwfile) || fsync(fileno(pwfile))) {
+       D(("fflush or fsync error writing entries to old passwords file: %m"));
+       err = 1;
+    }
+    
     if (fclose(pwfile)) {
-       D(("error writing entries to old passwords file: %m"));
+       D(("fclose error writing entries to old passwords file: %m"));
        err = 1;
     }
 
@@ -787,8 +800,13 @@ PAMH_ARG_DECL(int unix_update_passwd,
     }
     fclose(opwfile);
 
+    if (fflush(pwfile) || fsync(fileno(pwfile))) {
+       D(("fflush or fsync error writing entries to password file: %m"));
+       err = 1;
+    }
+    
     if (fclose(pwfile)) {
-       D(("error writing entries to password file: %m"));
+       D(("fclose error writing entries to password file: %m"));
        err = 1;
     }
 
@@ -908,8 +926,13 @@ PAMH_ARG_DECL(int unix_update_shadow,
     }
     fclose(opwfile);
 
+    if (fflush(pwfile) || fsync(fileno(pwfile))) {
+       D(("fflush or fsync error writing entries to shadow file: %m"));
+       err = 1;
+    }
+    
     if (fclose(pwfile)) {
-       D(("error writing entries to shadow file: %m"));
+       D(("fclose error writing entries to shadow file: %m"));
        err = 1;
     }
 
@@ -986,8 +1009,12 @@ su_sighandler(int sig)
 {
 #ifndef SA_RESETHAND
         /* emulate the behaviour of the SA_RESETHAND flag */
-        if ( sig == SIGILL || sig == SIGTRAP || sig == SIGBUS || sig = SIGSERV )
-                signal(sig, SIG_DFL);
+        if ( sig == SIGILL || sig == SIGTRAP || sig == SIGBUS || sig = SIGSERV ) {
+               struct sigaction sa;
+               memset(&sa, '\0', sizeof(sa));
+               sa.sa_handler = SIG_DFL;
+                sigaction(sig, &sa, NULL);
+       }
 #endif
         if (sig > 0) {
                 _exit(sig);