From d39ed7b722761e5110e26c8e937782ecb24b7315 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 26 Jul 2017 13:28:50 -0400 Subject: daemon: add ChoiceList PAM extension This commit adds one PAM extension, a "Choice List" using the new PAM_BINARY_PROMPT protocol added in the previous commit. The PAM module sends a list of (key, row text) pairs, and GDM ferries the request to gnome-shell using a new user verifier sub-interface. gnome-shell should present the list to the user and pass back the corresponding key, which GDM ferries back to the PAM module. Note this commit is only the daemon side. A subsequent commit will add the libgdm API needed for gnome-shell to actually deal with this new PAM extension. https://bugzilla.gnome.org/show_bug.cgi?id=788851 --- pam-extensions/gdm-pam-extensions.h | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'pam-extensions') diff --git a/pam-extensions/gdm-pam-extensions.h b/pam-extensions/gdm-pam-extensions.h index eff2f40a..cecb7422 100644 --- a/pam-extensions/gdm-pam-extensions.h +++ b/pam-extensions/gdm-pam-extensions.h @@ -130,4 +130,49 @@ typedef struct { #define GDM_PAM_EXTENSION_SUPPORTED(name) GDM_PAM_EXTENSION_LOOK_UP_TYPE(name, (unsigned char *) NULL) +typedef struct { + const char *key; + const char *text; +} GdmChoiceListItems; + +typedef struct { + size_t number_of_items; + GdmChoiceListItems items[]; +} GdmChoiceList; + +typedef struct { + GdmPamExtensionMessage header; + + char *prompt_message; + GdmChoiceList list; +} GdmPamExtensionChoiceListRequest; + +typedef struct { + GdmPamExtensionMessage header; + + char *key; +} GdmPamExtensionChoiceListResponse; + +#define GDM_PAM_EXTENSION_CHOICE_LIST "org.gnome.DisplayManager.UserVerifier.ChoiceList" + +#define GDM_CHOICE_LIST_SIZE(num_items) (offsetof(GdmChoiceList, items) + (num_items) * sizeof (GdmChoiceListItems)) +#define GDM_PAM_EXTENSION_CHOICE_LIST_REQUEST_SIZE(num_items) (offsetof(GdmPamExtensionChoiceListRequest, list) + GDM_CHOICE_LIST_SIZE((num_items))) +#define GDM_PAM_EXTENSION_CHOICE_LIST_REQUEST_INIT(request, title, num_items) \ +{ \ + int _n = num_items; \ + GDM_PAM_EXTENSION_LOOK_UP_TYPE (GDM_PAM_EXTENSION_CHOICE_LIST, &request->header.type); \ + request->header.length = htobe32 (GDM_PAM_EXTENSION_CHOICE_LIST_REQUEST_SIZE(_n)); \ + request->prompt_message = title; \ + request->list.number_of_items = _n; \ +} + +#define GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_SIZE sizeof (GdmPamExtensionChoiceListResponse) +#define GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_INIT(response) \ +{ \ + GDM_PAM_EXTENSION_LOOK_UP_TYPE (GDM_PAM_EXTENSION_CHOICE_LIST, &response->header.type); \ + response->header.length = htobe32 (GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_SIZE); \ + response->key = NULL; \ +} +#define GDM_PAM_EXTENSION_REPLY_TO_CHOICE_LIST_RESPONSE(reply) ((GdmPamExtensionChoiceListResponse *) (void *) reply->resp) + #endif -- cgit v1.2.1