|
Packit |
6c4009 |
/* Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _NSSWITCH_H
|
|
Packit |
6c4009 |
#define _NSSWITCH_H 1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* This is an *internal* header. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <arpa/nameser.h>
|
|
Packit |
6c4009 |
#include <netinet/in.h>
|
|
Packit |
6c4009 |
#include <nss.h>
|
|
Packit |
6c4009 |
#include <resolv.h>
|
|
Packit |
6c4009 |
#include <search.h>
|
|
Packit |
6c4009 |
#include <dlfcn.h>
|
|
Packit |
6c4009 |
#include <stdbool.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Actions performed after lookup finished. */
|
|
Packit |
6c4009 |
typedef enum
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
NSS_ACTION_CONTINUE,
|
|
Packit |
6c4009 |
NSS_ACTION_RETURN,
|
|
Packit |
6c4009 |
NSS_ACTION_MERGE
|
|
Packit |
6c4009 |
} lookup_actions;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
typedef struct service_library
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Name of service (`files', `dns', `nis', ...). */
|
|
Packit |
6c4009 |
const char *name;
|
|
Packit |
6c4009 |
/* Pointer to the loaded shared library. */
|
|
Packit |
6c4009 |
void *lib_handle;
|
|
Packit |
6c4009 |
/* And the link to the next entry. */
|
|
Packit |
6c4009 |
struct service_library *next;
|
|
Packit |
6c4009 |
} service_library;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* For mapping a function name to a function pointer. It is known in
|
|
Packit |
6c4009 |
nsswitch.c:nss_lookup_function that a string pointer for the lookup key
|
|
Packit |
6c4009 |
is the first member. */
|
|
Packit |
6c4009 |
typedef struct
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
const char *fct_name;
|
|
Packit |
6c4009 |
void *fct_ptr;
|
|
Packit |
6c4009 |
} known_function;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
typedef struct service_user
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* And the link to the next entry. */
|
|
Packit |
6c4009 |
struct service_user *next;
|
|
Packit |
6c4009 |
/* Action according to result. */
|
|
Packit |
6c4009 |
lookup_actions actions[5];
|
|
Packit |
6c4009 |
/* Link to the underlying library object. */
|
|
Packit |
6c4009 |
service_library *library;
|
|
Packit |
6c4009 |
/* Collection of known functions. */
|
|
Packit |
6c4009 |
void *known;
|
|
Packit |
6c4009 |
/* Name of the service (`files', `dns', `nis', ...). */
|
|
Packit |
6c4009 |
char name[0];
|
|
Packit |
6c4009 |
} service_user;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* To access the action based on the status value use this macro. */
|
|
Packit |
6c4009 |
#define nss_next_action(ni, status) ((ni)->actions[2 + status])
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
typedef struct name_database_entry
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* And the link to the next entry. */
|
|
Packit |
6c4009 |
struct name_database_entry *next;
|
|
Packit |
6c4009 |
/* List of service to be used. */
|
|
Packit |
6c4009 |
service_user *service;
|
|
Packit |
6c4009 |
/* Name of the database. */
|
|
Packit |
6c4009 |
char name[0];
|
|
Packit |
6c4009 |
} name_database_entry;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
typedef struct name_database
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* List of all known databases. */
|
|
Packit |
6c4009 |
name_database_entry *entry;
|
|
Packit |
6c4009 |
/* List of libraries with service implementation. */
|
|
Packit |
6c4009 |
service_library *library;
|
|
Packit |
6c4009 |
} name_database;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef USE_NSCD
|
|
Packit |
6c4009 |
/* Indices into DATABASES in nsswitch.c and __NSS_DATABASE_CUSTOM. */
|
|
Packit |
6c4009 |
enum
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
# define DEFINE_DATABASE(arg) NSS_DBSIDX_##arg,
|
|
Packit |
6c4009 |
# include "databases.def"
|
|
Packit |
6c4009 |
# undef DEFINE_DATABASE
|
|
Packit |
6c4009 |
NSS_DBSIDX_max
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Flags whether custom rules for database is set. */
|
|
Packit |
6c4009 |
extern bool __nss_database_custom[NSS_DBSIDX_max] attribute_hidden;
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Warning for NSS functions, which don't require dlopen if glibc
|
|
Packit |
6c4009 |
was built with --enable-static-nss. */
|
|
Packit |
6c4009 |
#ifdef DO_STATIC_NSS
|
|
Packit |
6c4009 |
# define nss_interface_function(name)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define nss_interface_function(name) static_link_warning (name)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Interface functions for NSS. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Get the data structure representing the specified database.
|
|
Packit |
6c4009 |
If there is no configuration for this database in the file,
|
|
Packit |
6c4009 |
parse a service list from DEFCONFIG and use that. More
|
|
Packit |
6c4009 |
than one function can use the database. */
|
|
Packit Bot |
d8342a |
extern int __nss_database_lookup2 (const char *database,
|
|
Packit Bot |
d8342a |
const char *alternative_name,
|
|
Packit Bot |
d8342a |
const char *defconfig, service_user **ni);
|
|
Packit Bot |
d8342a |
libc_hidden_proto (__nss_database_lookup2)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Put first function with name FCT_NAME for SERVICE in FCTP. The
|
|
Packit |
6c4009 |
position is remembered in NI. The function returns a value < 0 if
|
|
Packit |
6c4009 |
an error occurred or no such function exists. */
|
|
Packit |
6c4009 |
extern int __nss_lookup (service_user **ni, const char *fct_name,
|
|
Packit |
6c4009 |
const char *fct2_name, void **fctp);
|
|
Packit |
6c4009 |
libc_hidden_proto (__nss_lookup)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Determine the next step in the lookup process according to the
|
|
Packit |
6c4009 |
result STATUS of the call to the last function returned by
|
|
Packit |
6c4009 |
`__nss_lookup' or `__nss_next'. NI specifies the last function
|
|
Packit |
6c4009 |
examined. The function return a value > 0 if the process should
|
|
Packit |
6c4009 |
stop with the last result of the last function call to be the
|
|
Packit |
6c4009 |
result of the entire lookup. The returned value is 0 if there is
|
|
Packit |
6c4009 |
another function to use and < 0 if an error occurred.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
If ALL_VALUES is nonzero, the return value will not be > 0 as long as
|
|
Packit |
6c4009 |
there is a possibility the lookup process can ever use following
|
|
Packit |
6c4009 |
services. In other words, only if all four lookup results have
|
|
Packit |
6c4009 |
the action RETURN associated the lookup process stops before the
|
|
Packit |
6c4009 |
natural end. */
|
|
Packit |
6c4009 |
extern int __nss_next2 (service_user **ni, const char *fct_name,
|
|
Packit |
6c4009 |
const char *fct2_name, void **fctp, int status,
|
|
Packit |
6c4009 |
int all_values) attribute_hidden;
|
|
Packit |
6c4009 |
libc_hidden_proto (__nss_next2)
|
|
Packit |
6c4009 |
extern int __nss_next (service_user **ni, const char *fct_name, void **fctp,
|
|
Packit |
6c4009 |
int status, int all_values);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Search for the service described in NI for a function named FCT_NAME
|
|
Packit |
6c4009 |
and return a pointer to this function if successful. */
|
|
Packit |
6c4009 |
extern void *__nss_lookup_function (service_user *ni, const char *fct_name);
|
|
Packit |
6c4009 |
libc_hidden_proto (__nss_lookup_function)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Called by NSCD to disable recursive calls and enable special handling
|
|
Packit |
6c4009 |
when used in nscd. */
|
|
Packit |
6c4009 |
struct traced_file;
|
|
Packit |
6c4009 |
extern void __nss_disable_nscd (void (*) (size_t, struct traced_file *));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
typedef int (*db_lookup_function) (service_user **, const char *, const char *,
|
|
Packit |
6c4009 |
void **);
|
|
Packit |
6c4009 |
typedef enum nss_status (*setent_function) (int);
|
|
Packit |
6c4009 |
typedef enum nss_status (*endent_function) (void);
|
|
Packit |
6c4009 |
typedef enum nss_status (*getent_function) (void *, char *, size_t,
|
|
Packit |
6c4009 |
int *, int *);
|
|
Packit |
6c4009 |
typedef int (*getent_r_function) (void *, char *, size_t,
|
|
Packit |
6c4009 |
void **result, int *);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
extern void __nss_setent (const char *func_name,
|
|
Packit |
6c4009 |
db_lookup_function lookup_fct,
|
|
Packit |
6c4009 |
service_user **nip, service_user **startp,
|
|
Packit |
6c4009 |
service_user **last_nip, int stayon,
|
|
Packit |
6c4009 |
int *stayon_tmp, int res)
|
|
Packit |
6c4009 |
attribute_hidden;
|
|
Packit |
6c4009 |
extern void __nss_endent (const char *func_name,
|
|
Packit |
6c4009 |
db_lookup_function lookup_fct,
|
|
Packit |
6c4009 |
service_user **nip, service_user **startp,
|
|
Packit |
6c4009 |
service_user **last_nip, int res)
|
|
Packit |
6c4009 |
attribute_hidden;
|
|
Packit |
6c4009 |
extern int __nss_getent_r (const char *getent_func_name,
|
|
Packit |
6c4009 |
const char *setent_func_name,
|
|
Packit |
6c4009 |
db_lookup_function lookup_fct,
|
|
Packit |
6c4009 |
service_user **nip, service_user **startp,
|
|
Packit |
6c4009 |
service_user **last_nip, int *stayon_tmp,
|
|
Packit |
6c4009 |
int res,
|
|
Packit |
6c4009 |
void *resbuf, char *buffer, size_t buflen,
|
|
Packit |
6c4009 |
void **result, int *h_errnop)
|
|
Packit |
6c4009 |
attribute_hidden;
|
|
Packit |
6c4009 |
extern void *__nss_getent (getent_r_function func,
|
|
Packit |
6c4009 |
void **resbuf, char **buffer, size_t buflen,
|
|
Packit |
6c4009 |
size_t *buffer_size, int *h_errnop)
|
|
Packit |
6c4009 |
attribute_hidden;
|
|
Packit |
6c4009 |
struct resolv_context;
|
|
Packit |
6c4009 |
struct hostent;
|
|
Packit |
6c4009 |
extern int __nss_hostname_digits_dots_context (struct resolv_context *,
|
|
Packit |
6c4009 |
const char *name,
|
|
Packit |
6c4009 |
struct hostent *resbuf,
|
|
Packit |
6c4009 |
char **buffer,
|
|
Packit |
6c4009 |
size_t *buffer_size,
|
|
Packit |
6c4009 |
size_t buflen,
|
|
Packit |
6c4009 |
struct hostent **result,
|
|
Packit |
6c4009 |
enum nss_status *status, int af,
|
|
Packit |
6c4009 |
int *h_errnop) attribute_hidden;
|
|
Packit |
6c4009 |
extern int __nss_hostname_digits_dots (const char *name,
|
|
Packit |
6c4009 |
struct hostent *resbuf, char **buffer,
|
|
Packit |
6c4009 |
size_t *buffer_size, size_t buflen,
|
|
Packit |
6c4009 |
struct hostent **result,
|
|
Packit |
6c4009 |
enum nss_status *status, int af,
|
|
Packit |
6c4009 |
int *h_errnop);
|
|
Packit |
6c4009 |
libc_hidden_proto (__nss_hostname_digits_dots)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Maximum number of aliases we allow. */
|
|
Packit |
6c4009 |
#define MAX_NR_ALIASES 48
|
|
Packit |
6c4009 |
#define MAX_NR_ADDRS 48
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Prototypes for __nss_*_lookup2 functions. */
|
|
Packit |
6c4009 |
#define DEFINE_DATABASE(arg) \
|
|
Packit |
6c4009 |
extern service_user *__nss_##arg##_database attribute_hidden; \
|
|
Packit |
6c4009 |
int __nss_##arg##_lookup2 (service_user **, const char *, \
|
|
Packit |
6c4009 |
const char *, void **); \
|
|
Packit |
6c4009 |
libc_hidden_proto (__nss_##arg##_lookup2)
|
|
Packit |
6c4009 |
#include "databases.def"
|
|
Packit |
6c4009 |
#undef DEFINE_DATABASE
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* nsswitch.h */
|