2 * SPDX-License-Identifier: ISC
4 * Copyright (c) 2010-2013, 2015-2017 Todd C. Miller <Todd.Miller@sudo.ws>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef SUDOERS_PWUTIL_H
20 #define SUDOERS_PWUTIL_H
22 #define ptr_to_item(p) ((struct cache_item *)((char *)p - offsetof(struct cache_item_##p, p)))
25 * Generic cache element.
29 unsigned int type; /* only used for gidlist */
30 char registry[16]; /* AIX-specific, empty otherwise */
41 struct group_list *grlist;
42 struct gid_list *gidlist;
47 * Container structs to simpify size and offset calculations and guarantee
48 * proper aligment of struct passwd, group, gid_list and group_list.
50 struct cache_item_pw {
51 struct cache_item cache;
55 struct cache_item_gr {
56 struct cache_item cache;
60 struct cache_item_grlist {
61 struct cache_item cache;
62 struct group_list grlist;
66 struct cache_item_gidlist {
67 struct cache_item cache;
68 struct gid_list gidlist;
72 struct cache_item *sudo_make_gritem(gid_t gid, const char *group);
73 struct cache_item *sudo_make_grlist_item(const struct passwd *pw, char * const *groups);
74 struct cache_item *sudo_make_gidlist_item(const struct passwd *pw, char * const *gids, unsigned int type);
75 struct cache_item *sudo_make_pwitem(uid_t uid, const char *user);
77 #endif /* SUDOERS_PWUTIL_H */