2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2014-07-10 23:33:55 +02:00
|
|
|
#pragma once
|
|
|
|
|
2015-11-18 22:46:33 +01:00
|
|
|
#include <grp.h>
|
2014-07-10 23:33:55 +02:00
|
|
|
#include <netdb.h>
|
2015-11-18 22:46:33 +01:00
|
|
|
#include <nss.h>
|
2015-07-09 19:46:20 +02:00
|
|
|
#include <pwd.h>
|
2015-11-18 22:46:33 +01:00
|
|
|
#include <resolv.h>
|
2015-07-09 19:46:20 +02:00
|
|
|
|
2016-01-26 22:34:46 +01:00
|
|
|
#define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH
|
|
|
|
|
2017-02-01 01:55:33 +01:00
|
|
|
#ifndef DEPRECATED_RES_USE_INET6
|
|
|
|
# define DEPRECATED_RES_USE_INET6 0x00002000
|
|
|
|
#endif
|
|
|
|
|
2014-07-10 23:33:55 +02:00
|
|
|
#define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
|
|
|
|
enum nss_status _nss_##module##_gethostbyname4_r( \
|
|
|
|
const char *name, \
|
|
|
|
struct gaih_addrtuple **pat, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop, \
|
|
|
|
int32_t *ttlp) _public_; \
|
|
|
|
enum nss_status _nss_##module##_gethostbyname3_r( \
|
|
|
|
const char *name, \
|
|
|
|
int af, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop, \
|
|
|
|
int32_t *ttlp, \
|
|
|
|
char **canonp) _public_; \
|
|
|
|
enum nss_status _nss_##module##_gethostbyname2_r( \
|
|
|
|
const char *name, \
|
|
|
|
int af, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop) _public_; \
|
|
|
|
enum nss_status _nss_##module##_gethostbyname_r( \
|
|
|
|
const char *name, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop) _public_
|
|
|
|
|
|
|
|
#define NSS_GETHOSTBYADDR_PROTOTYPES(module) \
|
|
|
|
enum nss_status _nss_##module##_gethostbyaddr2_r( \
|
|
|
|
const void* addr, socklen_t len, \
|
|
|
|
int af, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop, \
|
|
|
|
int32_t *ttlp) _public_; \
|
|
|
|
enum nss_status _nss_##module##_gethostbyaddr_r( \
|
|
|
|
const void* addr, socklen_t len, \
|
|
|
|
int af, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop) _public_
|
|
|
|
|
|
|
|
#define NSS_GETHOSTBYNAME_FALLBACKS(module) \
|
|
|
|
enum nss_status _nss_##module##_gethostbyname2_r( \
|
|
|
|
const char *name, \
|
|
|
|
int af, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop) { \
|
|
|
|
return _nss_##module##_gethostbyname3_r( \
|
|
|
|
name, \
|
|
|
|
af, \
|
|
|
|
host, \
|
|
|
|
buffer, buflen, \
|
|
|
|
errnop, h_errnop, \
|
|
|
|
NULL, \
|
|
|
|
NULL); \
|
|
|
|
} \
|
|
|
|
enum nss_status _nss_##module##_gethostbyname_r( \
|
|
|
|
const char *name, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop) { \
|
2014-07-17 19:27:48 +02:00
|
|
|
enum nss_status ret = NSS_STATUS_NOTFOUND; \
|
|
|
|
\
|
2017-02-01 01:55:33 +01:00
|
|
|
if (_res.options & DEPRECATED_RES_USE_INET6) \
|
2014-07-17 19:27:48 +02:00
|
|
|
ret = _nss_##module##_gethostbyname3_r( \
|
|
|
|
name, \
|
|
|
|
AF_INET6, \
|
|
|
|
host, \
|
|
|
|
buffer, buflen, \
|
|
|
|
errnop, h_errnop, \
|
|
|
|
NULL, \
|
|
|
|
NULL); \
|
|
|
|
if (ret == NSS_STATUS_NOTFOUND) \
|
|
|
|
ret = _nss_##module##_gethostbyname3_r( \
|
2014-07-10 23:33:55 +02:00
|
|
|
name, \
|
2014-07-17 19:27:48 +02:00
|
|
|
AF_INET, \
|
2014-07-10 23:33:55 +02:00
|
|
|
host, \
|
|
|
|
buffer, buflen, \
|
|
|
|
errnop, h_errnop, \
|
|
|
|
NULL, \
|
|
|
|
NULL); \
|
2014-07-17 19:27:48 +02:00
|
|
|
return ret; \
|
2018-03-06 09:34:03 +01:00
|
|
|
}
|
2014-07-10 23:33:55 +02:00
|
|
|
|
|
|
|
#define NSS_GETHOSTBYADDR_FALLBACKS(module) \
|
|
|
|
enum nss_status _nss_##module##_gethostbyaddr_r( \
|
|
|
|
const void* addr, socklen_t len, \
|
|
|
|
int af, \
|
|
|
|
struct hostent *host, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop, int *h_errnop) { \
|
|
|
|
return _nss_##module##_gethostbyaddr2_r( \
|
|
|
|
addr, len, \
|
|
|
|
af, \
|
|
|
|
host, \
|
|
|
|
buffer, buflen, \
|
|
|
|
errnop, h_errnop, \
|
|
|
|
NULL); \
|
2018-03-06 09:34:03 +01:00
|
|
|
}
|
2015-07-09 19:46:20 +02:00
|
|
|
|
|
|
|
#define NSS_GETPW_PROTOTYPES(module) \
|
|
|
|
enum nss_status _nss_##module##_getpwnam_r( \
|
|
|
|
const char *name, \
|
|
|
|
struct passwd *pwd, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop) _public_; \
|
2016-07-14 19:16:19 +02:00
|
|
|
enum nss_status _nss_##module##_getpwuid_r( \
|
2015-07-09 19:46:20 +02:00
|
|
|
uid_t uid, \
|
|
|
|
struct passwd *pwd, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop) _public_
|
|
|
|
|
|
|
|
#define NSS_GETGR_PROTOTYPES(module) \
|
|
|
|
enum nss_status _nss_##module##_getgrnam_r( \
|
|
|
|
const char *name, \
|
|
|
|
struct group *gr, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop) _public_; \
|
|
|
|
enum nss_status _nss_##module##_getgrgid_r( \
|
|
|
|
gid_t gid, \
|
|
|
|
struct group *gr, \
|
|
|
|
char *buffer, size_t buflen, \
|
|
|
|
int *errnop) _public_
|
2016-03-03 21:35:34 +01:00
|
|
|
|
2019-08-07 12:33:33 +02:00
|
|
|
#define NSS_PWENT_PROTOTYPES(module) \
|
|
|
|
enum nss_status _nss_##module##_endpwent( \
|
|
|
|
void) _public_; \
|
|
|
|
enum nss_status _nss_##module##_setpwent( \
|
|
|
|
int stayopen) _public_; \
|
|
|
|
enum nss_status _nss_##module##_getpwent_r( \
|
|
|
|
struct passwd *result, \
|
|
|
|
char *buffer, \
|
|
|
|
size_t buflen, \
|
|
|
|
int *errnop) _public_;
|
|
|
|
|
|
|
|
#define NSS_GRENT_PROTOTYPES(module) \
|
|
|
|
enum nss_status _nss_##module##_endgrent( \
|
|
|
|
void) _public_; \
|
|
|
|
enum nss_status _nss_##module##_setgrent( \
|
|
|
|
int stayopen) _public_; \
|
|
|
|
enum nss_status _nss_##module##_getgrent_r( \
|
|
|
|
struct group *result, \
|
|
|
|
char *buffer, \
|
|
|
|
size_t buflen, \
|
|
|
|
int *errnop) _public_;
|
|
|
|
|
|
|
|
#define NSS_INITGROUPS_PROTOTYPE(module) \
|
|
|
|
enum nss_status _nss_##module##_initgroups_dyn( \
|
|
|
|
const char *user, \
|
|
|
|
gid_t group, \
|
|
|
|
long int *start, \
|
|
|
|
long int *size, \
|
|
|
|
gid_t **groupsp, \
|
|
|
|
long int limit, \
|
|
|
|
int *errnop) _public_;
|
|
|
|
|
2016-03-03 21:35:34 +01:00
|
|
|
typedef enum nss_status (*_nss_gethostbyname4_r_t)(
|
|
|
|
const char *name,
|
|
|
|
struct gaih_addrtuple **pat,
|
|
|
|
char *buffer, size_t buflen,
|
|
|
|
int *errnop, int *h_errnop,
|
|
|
|
int32_t *ttlp);
|
|
|
|
|
|
|
|
typedef enum nss_status (*_nss_gethostbyname3_r_t)(
|
|
|
|
const char *name,
|
|
|
|
int af,
|
|
|
|
struct hostent *result,
|
|
|
|
char *buffer, size_t buflen,
|
|
|
|
int *errnop, int *h_errnop,
|
|
|
|
int32_t *ttlp,
|
|
|
|
char **canonp);
|
|
|
|
|
2016-03-04 16:50:45 +01:00
|
|
|
typedef enum nss_status (*_nss_gethostbyname2_r_t)(
|
|
|
|
const char *name,
|
|
|
|
int af,
|
|
|
|
struct hostent *result,
|
|
|
|
char *buffer, size_t buflen,
|
|
|
|
int *errnop, int *h_errnop);
|
|
|
|
|
|
|
|
typedef enum nss_status (*_nss_gethostbyname_r_t)(
|
|
|
|
const char *name,
|
|
|
|
struct hostent *result,
|
|
|
|
char *buffer, size_t buflen,
|
|
|
|
int *errnop, int *h_errnop);
|
|
|
|
|
2016-03-03 21:35:34 +01:00
|
|
|
typedef enum nss_status (*_nss_gethostbyaddr2_r_t)(
|
|
|
|
const void* addr, socklen_t len,
|
|
|
|
int af,
|
|
|
|
struct hostent *result,
|
|
|
|
char *buffer, size_t buflen,
|
|
|
|
int *errnop, int *h_errnop,
|
|
|
|
int32_t *ttlp);
|
2016-03-04 16:50:45 +01:00
|
|
|
typedef enum nss_status (*_nss_gethostbyaddr_r_t)(
|
|
|
|
const void* addr, socklen_t len,
|
|
|
|
int af,
|
|
|
|
struct hostent *host,
|
|
|
|
char *buffer, size_t buflen,
|
|
|
|
int *errnop, int *h_errnop);
|