Annotation of embedaddon/sudo/compat/nss_dbdefs.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (c) 2013 Todd C. Miller <Todd.Miller@courtesan.com>
3: *
4: * Permission to use, copy, modify, and distribute this software for any
5: * purpose with or without fee is hereby granted, provided that the above
6: * copyright notice and this permission notice appear in all copies.
7: *
8: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15: */
16:
17: #ifndef _COMPAT_NSS_DBDEFS_H
18: #define _COMPAT_NSS_DBDEFS_H
19:
20: /*
21: * Bits of nss_dbdefs.h and nss_common.h needed to implement
22: * getgrouplist(3) using nss_search(3).
23: *
24: * HP-UX does not ship those headers so we need this compatibility header.
25: * It may also work on other systems that use a Solaris-derived nsswitch
26: * API.
27: */
28:
29: #ifdef NEED_HPUX_MUTEX
30: # include <synch.h>
31: #endif
32:
33: typedef enum {
34: NSS_SUCCESS,
35: NSS_NOTFOUND,
36: NSS_UNAVAIL
37: } nss_status_t;
38:
39: typedef struct nss_db_params {
40: const char *name;
41: const char *config_name;
42: const char *default_config;
43: unsigned int max_active_per_src;
44: unsigned int max_dormant_per_src;
45: int flags;
46: void *finders;
47: void *private;
48: void (*cleanup)(struct nss_db_params *);
49: } nss_db_params_t;
50:
51: struct nss_groupsbymem {
52: const char *username;
53: gid_t *gid_array;
54: int maxgids;
55: int force_slow_way;
56: int (*str2ent)(const char *, int, void *, char *, int);
57: nss_status_t (*process_cstr)(const char *, int, struct nss_groupsbymem *);
58: int numgids;
59: };
60:
61: typedef struct {
62: void *result; /* group struct to fill in. */
63: char *buffer; /* string buffer for above */
64: size_t buflen; /* string buffer size */
65: } nss_XbyY_buf_t;
66:
67: typedef struct {
68: void *state; /* really struct nss_db_state * */
69: #ifdef NEED_HPUX_MUTEX
70: lwp_mutex_t lock;
71: #endif
72: } nss_db_root_t;
73:
74: #ifdef NEED_HPUX_MUTEX
75: # define NSS_DB_ROOT_INIT { 0, LWP_MUTEX_INITIALIZER }
76: #else
77: # define NSS_DB_ROOT_INIT { 0 }
78: #endif
79: # define DEFINE_NSS_DB_ROOT(name) nss_db_root_t name = NSS_DB_ROOT_INIT
80:
81: /* Backend function to find all groups a user belongs to for initgroups(). */
82: #define NSS_DBOP_GROUP_BYMEMBER 6
83:
84: /* str2ent function return values */
85: #define NSS_STR_PARSE_SUCCESS 0
86: #define NSS_STR_PARSE_PARSE 1
87: #define NSS_STR_PARSE_ERANGE 2
88:
89: /* Max length for an /etc/group file line. */
90: #define NSS_BUFLEN_GROUP 8192
91:
92: /* HP-UX uses an extra underscore for these functions. */
93: #ifdef HAVE___NSS_INITF_GROUP
94: # define _nss_initf_group __nss_initf_group
95: #endif
96: #ifdef HAVE___NSS_XBYY_BUF_ALLOC
97: # define _nss_XbyY_buf_alloc __nss_XbyY_buf_alloc
98: # define _nss_XbyY_buf_free __nss_XbyY_buf_free
99: #endif
100:
101: typedef void (*nss_db_initf_t)(nss_db_params_t *);
102: extern nss_status_t nss_search(nss_db_root_t *, nss_db_initf_t, int, void *);
103: extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int, int);
104: extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
105:
106: #endif /* _COMPAT_NSS_DBDEFS_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>