1 /* Copyright (C) 1996-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
21 /* This is an *internal* header. */
23 #include <arpa/nameser.h>
24 #include <netinet/in.h>
31 /* Actions performed after lookup finished. */
41 typedef struct service_library
43 /* Name of service (`files', `dns', `nis', ...). */
45 /* Pointer to the loaded shared library. */
47 /* And the link to the next entry. */
48 struct service_library
*next
;
52 /* For mapping a function name to a function pointer. It is known in
53 nsswitch.c:nss_lookup_function that a string pointer for the lookup key
54 is the first member. */
62 /* To access the action based on the status value use this macro. */
63 #define nss_next_action(ni, status) nss_action_get (ni, status)
67 /* Indices into DATABASES in nsswitch.c and __NSS_DATABASE_CUSTOM. */
70 # define DEFINE_DATABASE(arg) NSS_DBSIDX_##arg,
71 # include "databases.def"
72 # undef DEFINE_DATABASE
76 /* Flags whether custom rules for database is set. */
77 extern bool __nss_database_custom
[NSS_DBSIDX_max
] attribute_hidden
;
80 /* Warning for NSS functions, which don't require dlopen if glibc
81 was built with --enable-static-nss. */
83 # define nss_interface_function(name)
85 # define nss_interface_function(name) static_link_warning (name)
89 /* Interface functions for NSS. */
91 /* Put first function with name FCT_NAME for SERVICE in FCTP. The
92 position is remembered in NI. The function returns a value < 0 if
93 an error occurred or no such function exists. */
94 extern int __nss_lookup (struct nss_action
**ni
, const char *fct_name
,
95 const char *fct2_name
, void **fctp
);
96 libc_hidden_proto (__nss_lookup
)
98 /* Determine the next step in the lookup process according to the
99 result STATUS of the call to the last function returned by
100 `__nss_lookup' or `__nss_next'. NI specifies the last function
101 examined. The function return a value > 0 if the process should
102 stop with the last result of the last function call to be the
103 result of the entire lookup. The returned value is 0 if there is
104 another function to use and < 0 if an error occurred.
106 If ALL_VALUES is nonzero, the return value will not be > 0 as long as
107 there is a possibility the lookup process can ever use following
108 services. In other words, only if all four lookup results have
109 the action RETURN associated the lookup process stops before the
111 extern int __nss_next2 (struct nss_action
**ni
, const char *fct_name
,
112 const char *fct2_name
, void **fctp
, int status
,
113 int all_values
) attribute_hidden
;
114 libc_hidden_proto (__nss_next2
)
115 extern int __nss_next (struct nss_action
**ni
, const char *fct_name
, void **fctp
,
116 int status
, int all_values
);
118 /* Search for the service described in NI for a function named FCT_NAME
119 and return a pointer to this function if successful. */
120 extern void *__nss_lookup_function (struct nss_action
*ni
, const char *fct_name
);
121 libc_hidden_proto (__nss_lookup_function
)
124 /* Called by NSCD to disable recursive calls and enable special handling
125 when used in nscd. */
127 extern void __nss_disable_nscd (void (*) (size_t, struct traced_file
*));
130 typedef int (*db_lookup_function
) (struct nss_action
**, const char *, const char *,
132 typedef enum nss_status (*setent_function
) (int);
133 typedef enum nss_status (*endent_function
) (void);
134 typedef enum nss_status (*getent_function
) (void *, char *, size_t,
136 typedef int (*getent_r_function
) (void *, char *, size_t,
137 void **result
, int *);
139 extern void __nss_setent (const char *func_name
,
140 db_lookup_function lookup_fct
,
141 struct nss_action
**nip
, struct nss_action
**startp
,
142 struct nss_action
**last_nip
, int stayon
,
143 int *stayon_tmp
, int res
)
145 extern void __nss_endent (const char *func_name
,
146 db_lookup_function lookup_fct
,
147 struct nss_action
**nip
, struct nss_action
**startp
,
148 struct nss_action
**last_nip
, int res
)
150 extern int __nss_getent_r (const char *getent_func_name
,
151 const char *setent_func_name
,
152 db_lookup_function lookup_fct
,
153 struct nss_action
**nip
, struct nss_action
**startp
,
154 struct nss_action
**last_nip
, int *stayon_tmp
,
156 void *resbuf
, char *buffer
, size_t buflen
,
157 void **result
, int *h_errnop
)
159 extern void *__nss_getent (getent_r_function func
,
160 void **resbuf
, char **buffer
, size_t buflen
,
161 size_t *buffer_size
, int *h_errnop
)
163 struct resolv_context
;
165 extern int __nss_hostname_digits_dots_context (struct resolv_context
*,
167 struct hostent
*resbuf
,
171 struct hostent
**result
,
172 enum nss_status
*status
, int af
,
173 int *h_errnop
) attribute_hidden
;
174 extern int __nss_hostname_digits_dots (const char *name
,
175 struct hostent
*resbuf
, char **buffer
,
176 size_t *buffer_size
, size_t buflen
,
177 struct hostent
**result
,
178 enum nss_status
*status
, int af
,
180 libc_hidden_proto (__nss_hostname_digits_dots
)
182 /* Maximum number of aliases we allow. */
183 #define MAX_NR_ALIASES 48
184 #define MAX_NR_ADDRS 48
186 /* Prototypes for __nss_*_lookup2 functions. */
187 #define DEFINE_DATABASE(arg) \
188 extern struct nss_action *__nss_##arg##_database attribute_hidden; \
189 int __nss_##arg##_lookup2 (struct nss_action **, const char *, \
190 const char *, void **); \
191 libc_hidden_proto (__nss_##arg##_lookup2)
192 #include "databases.def"
193 #undef DEFINE_DATABASE
195 #include <nss/nss_module.h>
196 #include <nss/nss_action.h>
197 #include <nss/nss_database.h>
199 #endif /* nsswitch.h */