summaryrefslogtreecommitdiff
path: root/pam_gdm/pam_gdm.c
diff options
context:
space:
mode:
Diffstat (limited to 'pam_gdm/pam_gdm.c')
-rw-r--r--pam_gdm/pam_gdm.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/pam_gdm/pam_gdm.c b/pam_gdm/pam_gdm.c
index 90a05573..7beb04e7 100644
--- a/pam_gdm/pam_gdm.c
+++ b/pam_gdm/pam_gdm.c
@@ -17,18 +17,47 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+#include <config.h>
+
+#include <unistd.h>
+
#include <security/_pam_macros.h>
#include <security/pam_ext.h>
#include <security/pam_misc.h>
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
+#ifdef HAVE_KEYUTILS
+#include <keyutils.h>
+#endif
+
int
pam_sm_authenticate (pam_handle_t *pamh,
int flags,
int argc,
const char **argv)
{
+#ifdef HAVE_KEYUTILS
+ int r;
+ void *cached_password = NULL;
+ key_serial_t serial;
+
+ serial = find_key_by_type_and_desc ("user", "cryptsetup", 0);
+ if (serial == 0)
+ return PAM_AUTHINFO_UNAVAIL;
+
+ r = keyctl_read_alloc (serial, &cached_password);
+ if (r < 0)
+ return PAM_AUTHINFO_UNAVAIL;
+
+ r = pam_set_item (pamh, PAM_AUTHTOK, cached_password);
+
+ free (cached_password);
+
+ if (r < 0)
+ return PAM_AUTH_ERR;
+#endif
+
return PAM_SUCCESS;
}