[gdm/rstrode/wip/list-extension: 5/5] wip! add little test module
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/rstrode/wip/list-extension: 5/5] wip! add little test module
- Date: Thu, 20 Jul 2017 15:47:31 +0000 (UTC)
commit 29b40a2b885cc648d0f7364831d4b671b318b742
Author: Ray Strode <rstrode redhat com>
Date: Wed Jul 19 17:25:17 2017 -0400
wip! add little test module
daemon/pam_testlist.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/daemon/pam_testlist.c b/daemon/pam_testlist.c
new file mode 100644
index 0000000..7ca20e9
--- /dev/null
+++ b/daemon/pam_testlist.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * compile with gcc -rdynamic -fPIC -shared -lpam pam_testlist.c -o pam_testlist.so
+ */
+
+#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>
+
+#include "gdm-pam-extensions.h"
+
+int
+pam_sm_authenticate (pam_handle_t *pamh,
+ int flags,
+ int argc,
+ const char **argv)
+{
+ int retval = PAM_ABORT;
+
+ const char *supported_pam_extensions;
+ struct pam_conv *conv;
+ struct pam_message prompt_message;
+ const struct pam_message *prompt_messages[1];
+ struct pam_response *reply = NULL;
+
+ GdmPamExtensionChoiceListRequest *request = NULL;
+ GdmPamExtensionChoiceListResponse *response = NULL;
+ uint32_t number_of_items = 4;
+ int i = 0;
+ char type;
+
+ if (!GDM_PAM_EXTENSION_SUPPORTED (GDM_PAM_EXTENSION_CHOICE_LIST))
+ goto out;
+
+ pam_info (pamh, "Please select a certificate");
+
+ retval = pam_get_item (pamh, PAM_CONV, (const void **) &conv);
+ if (retval != PAM_SUCCESS)
+ goto out;
+
+ request = malloc (GDM_PAM_EXTENSION_CHOICE_LIST_REQUEST_SIZE (number_of_items));
+ GDM_PAM_EXTENSION_CHOICE_LIST_REQUEST_INIT (request, number_of_items);
+
+ request->list.items[i].key = "john-smith-edipi0";
+ request->list.items[i++].text = "EDIPI Cert 0";
+ request->list.items[i].key = "john-smith-piv-sig0";
+ request->list.items[i++].text = "PIV Signature Cert 0";
+ request->list.items[i].key = "john-smith-secret0";
+ request->list.items[i++].text = "Class Secret Cert 0";
+ request->list.items[i].key = "john-smith-mess-hall0";
+ request->list.items[i++].text = "Mess Hall Cert 0";
+
+ GDM_PAM_EXTENSION_MESSAGE_TO_BINARY_PROMPT_MESSAGE (request, &prompt_message);
+ prompt_messages[0] = &prompt_message;
+
+ retval = conv->conv (1, prompt_messages, &reply, conv->appdata_ptr);
+
+ if (retval != PAM_SUCCESS)
+ goto out;
+
+ retval = PAM_ABORT;
+ response = GDM_PAM_EXTENSION_REPLY_TO_CHOICE_LIST_RESPONSE(reply);
+
+ if (response->key == NULL)
+ goto out;
+
+ for (i = 0; i < number_of_items; i++) {
+ if (strcmp (response->key, request->list.items[i].key) != 0)
+ continue;
+ pam_info (pamh, "Certificate ā%sā selected", request->list.items[i].text);
+ retval = PAM_SUCCESS;
+ }
+
+out:
+ free (request);
+ free (response);
+
+ return retval;
+}
+
+int
+pam_sm_setcred (pam_handle_t *pamh,
+ int flags,
+ int argc,
+ const char **argv)
+{
+ return PAM_SUCCESS;
+}
+
+int
+pam_sm_acct_mgmt (pam_handle_t *pamh,
+ int flags,
+ int argc,
+ const char **argv)
+{
+ return PAM_SUCCESS;
+}
+
+int
+pam_sm_chauthtok (pam_handle_t *pamh,
+ int flags,
+ int argc,
+ const char **argv)
+{
+ return PAM_SUCCESS;
+}
+
+int
+pam_sm_open_session (pam_handle_t *pamh,
+ int flags,
+ int argc,
+ const char **argv)
+{
+ return PAM_SUCCESS;
+}
+
+int
+pam_sm_close_session (pam_handle_t *pamh,
+ int flags,
+ int argc,
+ const char **argv)
+{
+ return PAM_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]