|
|
51e8c3 |
--- a/src/vlock/auth.c
|
|
|
51e8c3 |
+++ b/src/vlock/auth.c
|
|
|
51e8c3 |
@@ -4,7 +4,7 @@
|
|
|
51e8c3 |
PAM authentication routine for vlock, the VT locking program for linux.
|
|
|
51e8c3 |
|
|
|
51e8c3 |
Copyright (C) 1994-1998 Michael K. Johnson <johnsonm@redhat.com>
|
|
|
51e8c3 |
- Copyright (C) 2002, 2005 Dmitry V. Levin <ldv@altlinux.org>
|
|
|
51e8c3 |
+ Copyright (C) 2002, 2005, 2013 Dmitry V. Levin <ldv@altlinux.org>
|
|
|
51e8c3 |
|
|
|
51e8c3 |
This program is free software; you can redistribute it and/or modify
|
|
|
51e8c3 |
it under the terms of the GNU General Public License as published by
|
|
|
51e8c3 |
@@ -36,6 +36,25 @@
|
|
|
51e8c3 |
/* Unrecognized PAM error timeout. */
|
|
|
51e8c3 |
#define ERROR_TIMEOUT 10
|
|
|
51e8c3 |
|
|
|
51e8c3 |
+static int
|
|
|
51e8c3 |
+do_account_password_management (pam_handle_t *pamh)
|
|
|
51e8c3 |
+{
|
|
|
51e8c3 |
+ int rc;
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
+ /* Whether the authenticated user is allowed to log in? */
|
|
|
51e8c3 |
+ rc = pam_acct_mgmt (pamh, 0);
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
+ /* Do we need to prompt the user for a new password? */
|
|
|
51e8c3 |
+ if (rc == PAM_NEW_AUTHTOK_REQD)
|
|
|
51e8c3 |
+ rc = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
+ /* Extend the lifetime of the existing credentials. */
|
|
|
51e8c3 |
+ if (rc == PAM_SUCCESS)
|
|
|
51e8c3 |
+ rc = pam_setcred (pamh, PAM_REFRESH_CRED);
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
+ return rc;
|
|
|
51e8c3 |
+}
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
int
|
|
|
51e8c3 |
get_password (pam_handle_t * pamh, const char *username, const char *tty)
|
|
|
51e8c3 |
{
|
|
|
51e8c3 |
@@ -84,6 +103,23 @@ get_password (pam_handle_t * pamh, const char *username, const char *tty)
|
|
|
51e8c3 |
switch (rc)
|
|
|
51e8c3 |
{
|
|
|
51e8c3 |
case PAM_SUCCESS:
|
|
|
51e8c3 |
+ rc = do_account_password_management (pamh);
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
+ if (rc != PAM_SUCCESS)
|
|
|
51e8c3 |
+ {
|
|
|
51e8c3 |
+ /*
|
|
|
51e8c3 |
+ * The user was authenticated but
|
|
|
51e8c3 |
+ * either account or password management
|
|
|
51e8c3 |
+ * returned an error.
|
|
|
51e8c3 |
+ */
|
|
|
51e8c3 |
+ printf ("%s.\n\n\n",
|
|
|
51e8c3 |
+ pam_strerror (pamh, rc));
|
|
|
51e8c3 |
+ fflush (stdout);
|
|
|
51e8c3 |
+ pam_end (pamh, rc);
|
|
|
51e8c3 |
+ pamh = 0;
|
|
|
51e8c3 |
+ break;
|
|
|
51e8c3 |
+ }
|
|
|
51e8c3 |
+
|
|
|
51e8c3 |
pam_end (pamh, rc);
|
|
|
51e8c3 |
/* Log the fact of console unlocking. */
|
|
|
51e8c3 |
syslog (LOG_NOTICE,
|