/usr/include/gdm/gdm-pam-extensions.h is in libgdm-dev 3.28.3-0ubuntu18.04.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2017 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef GDM_PAM_EXTENSIONS_H
#define GDM_PAM_EXTENSIONS_H
#include <alloca.h>
#include <endian.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <limits.h>
#include <security/pam_appl.h>
typedef struct {
uint32_t length;
unsigned char type;
unsigned char data[];
} GdmPamExtensionMessage;
#define GDM_PAM_EXTENSION_MESSAGE_FROM_PAM_MESSAGE(query) (GdmPamExtensionMessage *) (void *) query->msg
#define GDM_PAM_EXTENSION_MESSAGE_TO_PAM_REPLY(msg) (char *) (void *) msg
#define GDM_PAM_EXTENSION_MESSAGE_TO_BINARY_PROMPT_MESSAGE(extended_message, binary_message) \
{ \
(binary_message)->msg_style = PAM_BINARY_PROMPT; \
(binary_message)->msg = (void *) extended_message; \
}
#define GDM_PAM_EXTENSION_MESSAGE_TRUNCATED(msg) be32toh(msg->length) < sizeof (GdmPamExtensionMessage)
#define GDM_PAM_EXTENSION_MESSAGE_INVALID_TYPE(msg) \
({ \
bool _invalid = true; \
int _n = -1; \
const char *_supported_extensions; \
_supported_extensions = getenv ("GDM_SUPPORTED_PAM_EXTENSIONS"); \
if (_supported_extensions != NULL) { \
const char *_p = _supported_extensions; \
while (*_p != '\0' && _n < UCHAR_MAX) { \
size_t _length; \
_length = strcspn (_p, " "); \
if (_length > 0) \
_n++; \
_p += _length; \
_length = strspn (_p, " "); \
_p += _length; \
} \
if (_n >= msg->type) \
_invalid = false; \
} \
_invalid; \
})
#define GDM_PAM_EXTENSION_MESSAGE_MATCH(msg, supported_extensions, name) (strcmp (supported_extensions[msg->type], name) == 0)
/* environment block should be a statically allocated chunk of memory. This is important because
* putenv() will leak otherwise (and setenv isn't thread safe)
*/
#define GDM_PAM_EXTENSION_ADVERTISE_SUPPORTED_EXTENSIONS(environment_block, supported_extensions) \
{ \
size_t _size = 0; \
unsigned char _t, _num_chunks; \
char *_p; \
_p = environment_block; \
_p = stpncpy (_p, "GDM_SUPPORTED_PAM_EXTENSIONS", sizeof(environment_block)); \
*_p = '\0'; \
_size += strlen (_p); \
for (_t = 0; supported_extensions[_t] != NULL && _t < UCHAR_MAX; _t++) {\
size_t _next_chunk = strlen (supported_extensions[_t]) + strlen (" "); \
if (_size + _next_chunk >= sizeof (environment_block)) \
break; \
_size += _next_chunk; \
}\
_num_chunks = _t; \
if (_t != 0) { \
_p = stpcpy (_p, "="); \
for (_t = 0; _t < _num_chunks; _t++) { \
if (_t != 0) \
_p = stpcpy (_p, " "); \
_p = stpcpy (_p, supported_extensions[_t]); \
} \
*_p = '\0'; \
putenv (environment_block); \
} \
}
#define GDM_PAM_EXTENSION_LOOK_UP_TYPE(name, extension_type) \
({ \
bool _supported = false; \
unsigned char _t = 0; \
const char *_supported_extensions; \
_supported_extensions = getenv ("GDM_SUPPORTED_PAM_EXTENSIONS"); \
if (_supported_extensions != NULL) { \
const char *_p = _supported_extensions; \
while (*_p != '\0') { \
size_t _length; \
_length = strcspn (_p, " "); \
if (strncmp (_p, name, _length) == 0) { \
_supported = true; \
break; \
} \
_p += _length; \
_length = strspn (_p, " "); \
_p += _length; \
if (_t >= UCHAR_MAX) { \
break; \
} \
_t++; \
} \
if (_supported && extension_type != NULL) \
*extension_type = _t; \
} \
_supported; \
})
#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
|