diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-06-26 00:25:28 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-06-26 00:25:28 +0000 |
commit | 633445be1a9be37ae727c044417f5607706cf4ae (patch) | |
tree | 3c037459f5249e5c18ee5b9e41802c5964364f95 /src/include | |
download | nsss-633445be1a9be37ae727c044417f5607706cf4ae.tar.xz |
Initial commit
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/grp.h | 27 | ||||
-rw-r--r-- | src/include/nsss/grp-all.h | 20 | ||||
-rw-r--r-- | src/include/nsss/grp-def.h | 16 | ||||
-rw-r--r-- | src/include/nsss/grp-switch.h | 20 | ||||
-rw-r--r-- | src/include/nsss/grp-unix.h | 20 | ||||
-rw-r--r-- | src/include/nsss/grp.h | 58 | ||||
-rw-r--r-- | src/include/nsss/nsss-all.h | 10 | ||||
-rw-r--r-- | src/include/nsss/nsss-switch.h | 93 | ||||
-rw-r--r-- | src/include/nsss/nsss-unix.h | 61 | ||||
-rw-r--r-- | src/include/nsss/nsss.h | 10 | ||||
-rw-r--r-- | src/include/nsss/nsssd.h | 84 | ||||
-rw-r--r-- | src/include/nsss/pwd-all.h | 20 | ||||
-rw-r--r-- | src/include/nsss/pwd-def.h | 19 | ||||
-rw-r--r-- | src/include/nsss/pwd-switch.h | 20 | ||||
-rw-r--r-- | src/include/nsss/pwd-unix.h | 20 | ||||
-rw-r--r-- | src/include/nsss/pwd.h | 58 | ||||
-rw-r--r-- | src/include/nsss/shadow-all.h | 18 | ||||
-rw-r--r-- | src/include/nsss/shadow-def.h | 21 | ||||
-rw-r--r-- | src/include/nsss/shadow-switch.h | 18 | ||||
-rw-r--r-- | src/include/nsss/shadow-unix.h | 18 | ||||
-rw-r--r-- | src/include/nsss/shadow.h | 52 | ||||
-rw-r--r-- | src/include/pwd.h | 20 | ||||
-rw-r--r-- | src/include/shadow.h | 26 |
23 files changed, 729 insertions, 0 deletions
diff --git a/src/include/grp.h b/src/include/grp.h new file mode 100644 index 0000000..4516a19 --- /dev/null +++ b/src/include/grp.h @@ -0,0 +1,27 @@ +/* ISC license. */ + +/* + This file is part of the nsss package. + See https://skarnet.org/software/nsss/ +*/ + +#ifndef GRP_H +#define GRP_H + +#include <nsss/grp.h> + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#include <sys/types.h> +extern int getgrouplist (char const *, gid_t, gid_t *, int *) ; +extern int setgroups (size_t, gid_t const *) ; +extern int initgroups (char const *, gid_t) ; +#endif + +#ifdef _GNU_SOURCE +#include <stdio.h> +extern struct group *fgetgrent (FILE *) ; +extern int fgetgrent_r (FILE *, struct group *, char *, size_t, struct group **) ; +extern int putgrent (struct group const *, FILE *) ; +#endif + +#endif diff --git a/src/include/nsss/grp-all.h b/src/include/nsss/grp-all.h new file mode 100644 index 0000000..54ea213 --- /dev/null +++ b/src/include/nsss/grp-all.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef NSSS_GRP_ALL_H +#define NSSS_GRP_ALL_H + +#include <nsss/grp-def.h> + +/* switch then fallback on unix */ + +extern void nsss_all_setgrent (void) ; +extern struct group *nsss_all_getgrent (void) ; +extern int nsss_all_getgrent_r (struct group *, char *, size_t, struct group **) ; +extern void nsss_all_endgrent (void) ; + +extern struct group *nsss_all_getgrgid (gid_t) ; +extern struct group *nsss_all_getgrnam (char const *) ; +extern int nsss_all_getgrgid_r (gid_t, struct group *, char *, size_t, struct group **) ; +extern int nsss_all_getgrnam_r (char const *, struct group *, char *, size_t, struct group **) ; + +#endif diff --git a/src/include/nsss/grp-def.h b/src/include/nsss/grp-def.h new file mode 100644 index 0000000..0a6db50 --- /dev/null +++ b/src/include/nsss/grp-def.h @@ -0,0 +1,16 @@ +/* ISC license. */ + +#ifndef NSSS_GRP_DEF_H +#define NSSS_GRP_DEF_H + +#include <sys/types.h> + +struct group +{ + char *gr_name ; + char *gr_passwd ; + gid_t gr_gid ; + char **gr_mem ; +} ; + +#endif diff --git a/src/include/nsss/grp-switch.h b/src/include/nsss/grp-switch.h new file mode 100644 index 0000000..6a9ba10 --- /dev/null +++ b/src/include/nsss/grp-switch.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef NSSS_GRP_SWITCH_H +#define NSSS_GRP_SWITCH_H + +#include <nsss/grp-def.h> + + /* Group functions contacting the nsssd daemon */ + +extern void nsss_switch_setgrent (void) ; +extern struct group *nsss_switch_getgrent (void) ; +extern int nsss_switch_getgrent_r (struct group *, char *, size_t, struct group **) ; +extern void nsss_switch_endgrent (void) ; + +extern struct group *nsss_switch_getgrgid (gid_t) ; +extern struct group *nsss_switch_getgrnam (char const *) ; +extern int nsss_switch_getgrgid_r (gid_t, struct group *, char *, size_t, struct group **) ; +extern int nsss_switch_getgrnam_r (char const *, struct group *, char *, size_t, struct group **) ; + +#endif diff --git a/src/include/nsss/grp-unix.h b/src/include/nsss/grp-unix.h new file mode 100644 index 0000000..fe089f1 --- /dev/null +++ b/src/include/nsss/grp-unix.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef NSSS_GRP_UNIX_H +#define NSSS_GRP_UNIX_H + +#include <nsss/grp-def.h> + + /* /etc/group backend */ + +extern void nsss_unix_setgrent (void) ; +extern struct group *nsss_unix_getgrent (void) ; +extern int nsss_unix_getgrent_r (struct group *, char *, size_t, struct group **) ; +extern void nsss_unix_endgrent (void) ; + +extern struct group *nsss_unix_getgrgid (gid_t) ; +extern struct group *nsss_unix_getgrnam (char const *) ; +extern int nsss_unix_getgrgid_r (gid_t, struct group *, char *, size_t, struct group **) ; +extern int nsss_unix_getgrnam_r (char const *, struct group *, char *, size_t, struct group **) ; + +#endif diff --git a/src/include/nsss/grp.h b/src/include/nsss/grp.h new file mode 100644 index 0000000..ea963b6 --- /dev/null +++ b/src/include/nsss/grp.h @@ -0,0 +1,58 @@ +/* ISC license. */ + +#ifndef NSSS_GRP_H +#define NSSS_GRP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NSSS_DISABLE_SWITCH + +#include <nsss/grp-unix.h> + +#define setgrent nsss_unix_setgrent +#define getgrent nsss_unix_getgrent +#define getgrent_r nsss_unix_getgrent_r +#define endgrent nsss_unix_endgrent +#define getgrgid nsss_unix_getgrgid +#define getgrgid_r nsss_unix_getgrgid_r +#define getgrnam nsss_unix_getgrnam +#define getgrnam_r nsss_unix_getgrnam_r + +#else +#ifdef NSSS_DISABLE_UNIX + +#include <nsss/grp-switch.h> + +#define setgrent nsss_switch_setgrent +#define getgrent nsss_switch_getgrent +#define getgrent_r nsss_switch_getgrent_r +#define endgrent nsss_switch_endgrent +#define getgrgid nsss_switch_getgrgid +#define getgrgid_r nsss_switch_getgrgid_r +#define getgrnam nsss_switch_getgrnam +#define getgrnam_r nsss_switch_getgrnam_r + +#else + +#include <nsss/grp-all.h> + +#define setgrent nsss_all_setgrent +#define getgrent nsss_all_getgrent +#define getgrent_r nsss_all_getgrent_r +#define endgrent nsss_all_endgrent +#define getgrgid nsss_all_getgrgid +#define getgrgid_r nsss_all_getgrgid_r +#define getgrnam nsss_all_getgrnam +#define getgrnam_r nsss_all_getgrnam_r + +#endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/nsss/nsss-all.h b/src/include/nsss/nsss-all.h new file mode 100644 index 0000000..4530e97 --- /dev/null +++ b/src/include/nsss/nsss-all.h @@ -0,0 +1,10 @@ +/* ISC license. */ + +#ifndef NSSS_ALL_H +#define NSSS_ALL_H + +#include <nsss/pwd-all.h> +#include <nsss/grp-all.h> +#include <nsss/shadow-all.h> + +#endif diff --git a/src/include/nsss/nsss-switch.h b/src/include/nsss/nsss-switch.h new file mode 100644 index 0000000..1bfe50f --- /dev/null +++ b/src/include/nsss/nsss-switch.h @@ -0,0 +1,93 @@ +/* ISC license. */ + +#ifndef NSSS_SWITCH_H +#define NSSS_SWITCH_H + +#include <sys/types.h> +#include <limits.h> +#include <skalibs/tai.h> +#include <skalibs/buffer.h> +#include <skalibs/stralloc.h> +#include <skalibs/genalloc.h> +#include <nsss/pwd-switch.h> +#include <nsss/grp-switch.h> +#include <nsss/shadow-switch.h> + +#define NSSS_SWITCH_BUFSIZE 4096 +#define NSSS_SWITCH_NAME_MAXLEN LOGIN_NAME_MAX + +typedef struct nsss_switch_s nsss_switch_t, *nsss_switch_t_ref ; +struct nsss_switch_s +{ + unsigned int held ; + buffer b ; + char buf[NSSS_SWITCH_BUFSIZE] ; +} ; +#define NSSS_SWITCH_ZERO { .held = 0, .b = BUFFER_ZERO } + +#define NSSS_SWITCH_PWD 0 +#define NSSS_SWITCH_GRP 1 +#define NSSS_SWITCH_SHADOW 2 + +extern int nsss_switch_start (nsss_switch_t *, unsigned int, char const *, tain_t const *, tain_t *) ; +#define nsss_switch_start_g(a, what, s, deadline) nsss_switch_start(a, what, s, (deadline), &STAMP) +extern void nsss_switch_end (nsss_switch_t *, unsigned int) ; + + + /* Password */ + +#define NSSS_SWITCH_PWD_END '\0' +#define NSSS_SWITCH_PWD_REWIND '\001' +#define NSSS_SWITCH_PWD_GET '\002' +#define NSSS_SWITCH_PWD_GETBYNAME '\003' +#define NSSS_SWITCH_PWD_GETBYUID '\004' + +extern int nsss_switch_pwd_end (nsss_switch_t *, tain_t const *, tain_t *) ; +#define nsss_switch_pwd_end_g(a, deadline) nsss_switch_pwd_end(a, (deadline), &STAMP) +extern int nsss_switch_pwd_rewind (nsss_switch_t *, tain_t const *, tain_t *) ; +#define nsss_switch_pwd_rewind_g(a, deadline) nsss_switch_pwd_rewind(a, (deadline), &STAMP) +extern int nsss_switch_pwd_get (nsss_switch_t *, struct passwd *, stralloc *, tain_t const *, tain_t *) ; +#define nsss_switch_pwd_get_g(a, b, sa, deadline) nsss_switch_pwd_get(a, b, sa, (deadline), &STAMP) +extern int nsss_switch_pwd_getbyname (nsss_switch_t *, struct passwd *, stralloc *, char const *, tain_t const *, tain_t *) ; +#define nsss_switch_pwd_getbyname_g(a, b, sa, name, deadline) nsss_switch_pwd_getbyname(a, b, sa, name, (deadline), &STAMP) +extern int nsss_switch_pwd_getbyuid (nsss_switch_t *, struct passwd *, stralloc *, uid_t, tain_t const *, tain_t *) ; +#define nsss_switch_pwd_getbyuid_g(a, b, sa, u, deadline) nsss_switch_pwd_getbyuid(a, b, sa, u, (deadline), &STAMP) + + + /* Group */ + +#define NSSS_SWITCH_GRP_END '\020' +#define NSSS_SWITCH_GRP_REWIND '\021' +#define NSSS_SWITCH_GRP_GET '\022' +#define NSSS_SWITCH_GRP_GETBYNAME '\023' +#define NSSS_SWITCH_GRP_GETBYGID '\024' + +extern int nsss_switch_grp_end (nsss_switch_t *, tain_t const *, tain_t *) ; +#define nsss_switch_grp_end_g(a, deadline) nsss_switch_grp_end(a, (deadline), &STAMP) +extern int nsss_switch_grp_rewind (nsss_switch_t *, tain_t const *, tain_t *) ; +#define nsss_switch_grp_rewind_g(a, deadline) nsss_switch_grp_rewind(a, (deadline), &STAMP) +extern int nsss_switch_grp_get (nsss_switch_t *, struct group *, stralloc *, genalloc *, tain_t const *, tain_t *) ; +#define nsss_switch_grp_get_g(a, b, sa, ga, deadline) nsss_switch_grp_get(a, b, sa, ga, (deadline), &STAMP) +extern int nsss_switch_grp_getbyname (nsss_switch_t *, struct group *, stralloc *, genalloc *, char const *, tain_t const *, tain_t *) ; +#define nsss_switch_grp_getbyname_g(a, b, sa, ga, name, deadline) nsss_switch_grp_getbyname(a, b, sa, ga, name, (deadline), &STAMP) +extern int nsss_switch_grp_getbygid (nsss_switch_t *, struct group *, stralloc *, genalloc *, gid_t, tain_t const *, tain_t *) ; +#define nsss_switch_grp_getbygid_g(a, b, sa, ga, g, deadline) nsss_switch_grp_getbygid(a, b, sa, ga, g, (deadline), &STAMP) + + + /* Shadow */ + +#define NSSS_SWITCH_SHADOW_END '\040' +#define NSSS_SWITCH_SHADOW_REWIND '\041' +#define NSSS_SWITCH_SHADOW_GET '\042' +#define NSSS_SWITCH_SHADOW_GETBYNAME '\043' + +extern int nsss_switch_shadow_end (nsss_switch_t *, tain_t const *, tain_t *) ; +#define nsss_switch_shadow_end_g(a, deadline) nsss_switch_shadow_end(a, (deadline), &STAMP) +extern int nsss_switch_shadow_rewind (nsss_switch_t *, tain_t const *, tain_t *) ; +#define nsss_switch_shadow_rewind_g(a, deadline) nsss_switch_shadow_rewind(a, (deadline), &STAMP) +extern int nsss_switch_shadow_get (nsss_switch_t *, struct spwd *, stralloc *, tain_t const *, tain_t *) ; +#define nsss_switch_shadow_get_g(a, b, sa, deadline) nsss_switch_shadow_get(a, b, sa, (deadline), &STAMP) +extern int nsss_switch_shadow_getbyname (nsss_switch_t *, struct spwd *, stralloc *, char const *, tain_t const *, tain_t *) ; +#define nsss_switch_shadow_getbyname_g(a, b, sa, name, deadline) nsss_switch_shadow_getbyname(a, b, sa, name, (deadline), &STAMP) + +#endif diff --git a/src/include/nsss/nsss-unix.h b/src/include/nsss/nsss-unix.h new file mode 100644 index 0000000..786bf88 --- /dev/null +++ b/src/include/nsss/nsss-unix.h @@ -0,0 +1,61 @@ +/* ISC license. */ + +#ifndef NSSS_UNIX_H +#define NSSS_UNIX_H + +#include <sys/types.h> +#include <skalibs/buffer.h> +#include <skalibs/stralloc.h> +#include <skalibs/genalloc.h> +#include <nsss/pwd-unix.h> +#include <nsss/grp-unix.h> +#include <nsss/shadow-unix.h> + +#define NSSS_UNIX_BUFSIZE 4096 + +typedef struct nsss_unix_s nsss_unix_t, *nsss_unix_t_ref ; +struct nsss_unix_s +{ + buffer b ; + char buf[NSSS_UNIX_BUFSIZE] ; +} ; +#define NSSS_UNIX_ZERO { .b = BUFFER_ZERO } + +extern int nsss_unix_start (nsss_unix_t *, char const *) ; +extern int nsss_unix_maybe_start (nsss_unix_t *, char const *) ; +extern void nsss_unix_end (nsss_unix_t *) ; +extern int nsss_unix_rewind (nsss_unix_t *) ; + + + /* Password */ + +#define nsss_unix_pwd_start(a) nsss_unix_start(a, "/etc/passwd") +#define nsss_unix_pwd_maybe_start(a) nsss_unix_maybe_start(a, "/etc/passwd") +#define nsss_unix_pwd_end(a) nsss_unix_end(a) +#define nsss_unix_pwd_rewind(a) nsss_unix_rewind(a) +extern int nsss_unix_pwd_get (nsss_unix_t *, struct passwd *, stralloc *) ; +extern int nsss_unix_pwd_getbyname (nsss_unix_t *, struct passwd *, stralloc *, char const *) ; +extern int nsss_unix_pwd_getbyuid (nsss_unix_t *, struct passwd *, stralloc *, uid_t) ; + + + /* Group */ + +#define nsss_unix_grp_start(a) nsss_unix_start(a, "/etc/group") +#define nsss_unix_grp_maybe_start(a) nsss_unix_maybe_start(a, "/etc/group") +#define nsss_unix_grp_end(a) nsss_unix_end(a) +#define nsss_unix_grp_rewind(a) nsss_unix_rewind(a) +extern int nsss_unix_grp_get (nsss_unix_t *, struct group *, stralloc *, genalloc *) ; +extern int nsss_unix_grp_getbyname (nsss_unix_t *, struct group *, stralloc *, genalloc *, char const *) ; +extern int nsss_unix_grp_getbygid (nsss_unix_t *, struct group *, stralloc *, genalloc *, gid_t) ; + + + /* Shadow */ + +#define nsss_unix_shadow_start(a) nsss_unix_start(a, "/etc/shadow") +#define nsss_unix_shadow_maybe_start(a) nsss_unix_maybe_start(a, "/etc/shadow") +#define nsss_unix_shadow_end(a) nsss_unix_end(a) +#define nsss_unix_shadow_rewind(a) nsss_unix_rewind(a) +extern int nsss_unix_shadow_get (nsss_unix_t *, struct spwd *, stralloc *) ; +extern int nsss_unix_shadow_getbyname (nsss_unix_t *, struct spwd *, stralloc *, char const *) ; + +#endif diff --git a/src/include/nsss/nsss.h b/src/include/nsss/nsss.h new file mode 100644 index 0000000..56e7c08 --- /dev/null +++ b/src/include/nsss/nsss.h @@ -0,0 +1,10 @@ +/* ISC license. */ + +#ifndef NSSS_H +#define NSSS_H + +#include <nsss/nsss-unix.h> +#include <nsss/nsss-switch.h> +#include <nsss/nsss-all.h> + +#endif diff --git a/src/include/nsss/nsssd.h b/src/include/nsss/nsssd.h new file mode 100644 index 0000000..7649873 --- /dev/null +++ b/src/include/nsss/nsssd.h @@ -0,0 +1,84 @@ +/* ISC license. */ + +#ifndef NSSSD_H +#define NSSSD_H + +#include <sys/types.h> +#include <nsss/pwd-def.h> +#include <nsss/grp-def.h> +#include <nsss/shadow-def.h> + +#define NSSSD_EOF 255 + +typedef struct nsssd_passwd_s nsssd_passwd_t, *nsssd_passwd_t_ref ; +struct nsssd_passwd_s +{ + size_t pw_name ; + size_t pw_passwd ; + uid_t pw_uid ; + uid_t pw_gid ; + size_t pw_gecos ; + size_t pw_dir ; + size_t pw_shell ; +} ; + +typedef struct nsssd_group_s nsssd_group_t, *nsssd_group_t_ref ; +struct nsssd_group_s +{ + size_t gr_name ; + size_t gr_passwd ; + gid_t gr_gid ; + size_t gr_mem ; + size_t gr_mem_n ; +} ; + +typedef struct nsssd_spwd_s nsssd_spwd_t, *nsssd_spwd_t_ref ; +struct nsssd_spwd_s +{ + size_t sp_namp ; + size_t sp_pwdp ; + long sp_lstchg ; + long sp_min ; + long sp_max ; + long sp_warn ; + long sp_inact ; + long sp_expire ; + unsigned long sp_flag ; +} ; + + +/* Functions provided by libnsssd */ + +extern int nsssd_main (char const *const *, char const *const *) ; +extern void nsssd_passwd_convert (struct passwd *, nsssd_passwd_t const *, char const *) ; +extern void nsssd_group_convert (struct group *, char **, nsssd_group_t const *, char const *, size_t const *) ; +extern void nsssd_spwd_convert (struct spwd *, nsssd_spwd_t const *, char const *) ; + + +/* Functions that must be provided by the backend */ + +extern void *nsssd_handle_init (void) ; +extern int nsssd_handle_start (void *, char const *const *, char const *const *) ; +extern void nsssd_handle_end (void *) ; + +extern int nsssd_pwd_start (void *) ; +extern int nsssd_pwd_rewind (void *) ; +extern int nsssd_pwd_get (void *, struct passwd *) ; +extern int nsssd_pwd_getbyuid (void *, struct passwd *, uid_t) ; +extern int nsssd_pwd_getbyname (void *, struct passwd *, char const *) ; +extern void nsssd_pwd_end (void *) ; + +extern int nsssd_grp_start (void *) ; +extern int nsssd_grp_rewind (void *) ; +extern int nsssd_grp_get (void *, struct group *) ; +extern int nsssd_grp_getbygid (void *, struct group *, gid_t) ; +extern int nsssd_grp_getbyname (void *, struct group *, char const *) ; +extern void nsssd_grp_end (void *) ; + +extern int nsssd_shadow_start (void *) ; +extern int nsssd_shadow_rewind (void *) ; +extern int nsssd_shadow_get (void *, struct spwd *) ; +extern int nsssd_shadow_getbyname (void *, struct spwd *, char const *) ; +extern void nsssd_shadow_end (void *) ; + +#endif diff --git a/src/include/nsss/pwd-all.h b/src/include/nsss/pwd-all.h new file mode 100644 index 0000000..02d38a3 --- /dev/null +++ b/src/include/nsss/pwd-all.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef NSSS_PWD_ALL_H +#define NSSS_PWD_ALL_H + +#include <nsss/pwd-def.h> + + /* switch then fallback on unix */ + +extern void nsss_all_setpwent (void) ; +extern struct passwd *nsss_all_getpwent (void) ; +extern int nsss_all_getpwent_r (struct passwd *, char *, size_t, struct passwd **) ; +extern void nsss_all_endpwent (void) ; + +extern struct passwd *nsss_all_getpwuid (uid_t) ; +extern int nsss_all_getpwuid_r (uid_t, struct passwd *, char *, size_t, struct passwd **) ; +extern struct passwd *nsss_all_getpwnam (char const *) ; +extern int nsss_all_getpwnam_r (char const *, struct passwd *, char *, size_t, struct passwd **) ; + +#endif diff --git a/src/include/nsss/pwd-def.h b/src/include/nsss/pwd-def.h new file mode 100644 index 0000000..44a4538 --- /dev/null +++ b/src/include/nsss/pwd-def.h @@ -0,0 +1,19 @@ +/* ISC license. */ + +#ifndef NSSS_PWD_DEF_H +#define NSSS_PWD_DEF_H + +#include <sys/types.h> + +struct passwd +{ + char *pw_name ; + char *pw_passwd ; + uid_t pw_uid ; + gid_t pw_gid ; + char *pw_gecos ; + char *pw_dir ; + char *pw_shell ; +} ; + +#endif diff --git a/src/include/nsss/pwd-switch.h b/src/include/nsss/pwd-switch.h new file mode 100644 index 0000000..f9ac48c --- /dev/null +++ b/src/include/nsss/pwd-switch.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef NSSS_PWD_SWITCH_H +#define NSSS_PWD_SWITCH_H + +#include <nsss/pwd-def.h> + + /* Password functions contacting the nsssd daemon */ + +extern void nsss_switch_setpwent (void) ; +extern struct passwd *nsss_switch_getpwent (void) ; +extern int nsss_switch_getpwent_r (struct passwd *, char *, size_t, struct passwd **) ; +extern void nsss_switch_endpwent (void) ; + +extern struct passwd *nsss_switch_getpwuid (uid_t) ; +extern int nsss_switch_getpwuid_r (uid_t, struct passwd *, char *, size_t, struct passwd **) ; +extern struct passwd *nsss_switch_getpwnam (char const *) ; +extern int nsss_switch_getpwnam_r (char const *, struct passwd *, char *, size_t, struct passwd **) ; + +#endif diff --git a/src/include/nsss/pwd-unix.h b/src/include/nsss/pwd-unix.h new file mode 100644 index 0000000..9b1d60c --- /dev/null +++ b/src/include/nsss/pwd-unix.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef NSSS_PWD_UNIX_H +#define NSSS_PWD_UNIX_H + +#include <nsss/pwd-def.h> + + /* /etc/passwd backend */ + +extern void nsss_unix_setpwent (void) ; +extern struct passwd *nsss_unix_getpwent (void) ; +extern int nsss_unix_getpwent_r (struct passwd *, char *, size_t, struct passwd **) ; +extern void nsss_unix_endpwent (void) ; + +extern struct passwd *nsss_unix_getpwuid (uid_t) ; +extern int nsss_unix_getpwuid_r (uid_t, struct passwd *, char *, size_t, struct passwd **) ; +extern struct passwd *nsss_unix_getpwnam (char const *) ; +extern int nsss_unix_getpwnam_r (char const *, struct passwd *, char *, size_t, struct passwd **) ; + +#endif diff --git a/src/include/nsss/pwd.h b/src/include/nsss/pwd.h new file mode 100644 index 0000000..950a5ce --- /dev/null +++ b/src/include/nsss/pwd.h @@ -0,0 +1,58 @@ +/* ISC license. */ + +#ifndef NSSS_PWD_H +#define NSSS_PWD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NSSS_DISABLE_SWITCH + +#include <nsss/pwd-unix.h> + +#define setpwent nsss_unix_setpwent +#define getpwent nsss_unix_getpwent +#define getpwent_r nsss_unix_getpwent_r +#define endpwent nsss_unix_endpwent +#define getpwuid nsss_unix_getpwuid +#define getpwuid_r nsss_unix_getpwuid_r +#define getpwnam nsss_unix_getpwnam +#define getpwnam_r nsss_unix_getpwnam_r + +#else +#ifdef NSSS_DISABLE_UNIX + +#include <nsss/pwd-switch.h> + +#define setpwent nsss_switch_setpwent +#define getpwent nsss_switch_getpwent +#define getpwent_r nsss_switch_getpwent_r +#define endpwent nsss_switch_endpwent +#define getpwuid nsss_switch_getpwuid +#define getpwuid_r nsss_switch_getpwuid_r +#define getpwnam nsss_switch_getpwnam +#define getpwnam_r nsss_switch_getpwnam_r + +#else + +#include <nsss/pwd-all.h> + +#define setpwent nsss_all_setpwent +#define getpwent nsss_all_getpwent +#define getpwent_r nsss_all_getpwent_r +#define endpwent nsss_all_endpwent +#define getpwuid nsss_all_getpwuid +#define getpwuid_r nsss_all_getpwuid_r +#define getpwnam nsss_all_getpwnam +#define getpwnam_r nsss_all_getpwnam_r + +#endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/nsss/shadow-all.h b/src/include/nsss/shadow-all.h new file mode 100644 index 0000000..09da550 --- /dev/null +++ b/src/include/nsss/shadow-all.h @@ -0,0 +1,18 @@ +/* ISC license. */ + +#ifndef NSSS_SHADOW_ALL_H +#define NSSS_SHADOW_ALL_H + +#include <nsss/shadow-def.h> + +/* switch then fallback on unix */ + +extern void nsss_all_setspent (void) ; +extern struct spwd *nsss_all_getspent (void) ; +extern int nsss_all_getspent_r (struct spwd *, char *, size_t, struct spwd **) ; +extern void nsss_all_endspent (void) ; + +extern struct spwd *nsss_all_getspnam (char const *) ; +extern int nsss_all_getspnam_r (char const *, struct spwd *, char *, size_t, struct spwd **) ; + +#endif diff --git a/src/include/nsss/shadow-def.h b/src/include/nsss/shadow-def.h new file mode 100644 index 0000000..7b73b95 --- /dev/null +++ b/src/include/nsss/shadow-def.h @@ -0,0 +1,21 @@ +/* ISC license. */ + +#ifndef NSSS_SHADOW_DEF_H +#define NSSS_SHADOW_DEF_H + +#include <sys/types.h> + +struct spwd +{ + char *sp_namp ; + char *sp_pwdp ; + long sp_lstchg ; + long sp_min ; + long sp_max ; + long sp_warn ; + long sp_inact ; + long sp_expire ; + unsigned long sp_flag ; +} ; + +#endif diff --git a/src/include/nsss/shadow-switch.h b/src/include/nsss/shadow-switch.h new file mode 100644 index 0000000..0126125 --- /dev/null +++ b/src/include/nsss/shadow-switch.h @@ -0,0 +1,18 @@ +/* ISC license. */ + +#ifndef NSSS_SHADOW_SWITCH_H +#define NSSS_SHADOW_SWITCH_H + +#include <nsss/shadow-def.h> + + /* Shadow functions contacting the nsssd daemon */ + +extern void nsss_switch_setspent (void) ; +extern struct spwd *nsss_switch_getspent (void) ; +extern int nsss_switch_getspent_r (struct spwd *, char *, size_t, struct spwd **) ; +extern void nsss_switch_endspent (void) ; + +extern struct spwd *nsss_switch_getspnam (char const *) ; +extern int nsss_switch_getspnam_r (char const *, struct spwd *, char *, size_t, struct spwd **) ; + +#endif diff --git a/src/include/nsss/shadow-unix.h b/src/include/nsss/shadow-unix.h new file mode 100644 index 0000000..6b7a111 --- /dev/null +++ b/src/include/nsss/shadow-unix.h @@ -0,0 +1,18 @@ +/* ISC license. */ + +#ifndef NSSS_SHADOW_UNIX_H +#define NSSS_SHADOW_UNIX_H + +#include <nsss/shadow-def.h> + + /* /etc/shadow functions */ + +extern void nsss_unix_setspent (void) ; +extern struct spwd *nsss_unix_getspent (void) ; +extern int nsss_unix_getspent_r (struct spwd *, char *, size_t, struct spwd **) ; +extern void nsss_unix_endspent (void) ; + +extern struct spwd *nsss_unix_getspnam (char const *) ; +extern int nsss_unix_getspnam_r (char const *, struct spwd *, char *, size_t, struct spwd **) ; + +#endif diff --git a/src/include/nsss/shadow.h b/src/include/nsss/shadow.h new file mode 100644 index 0000000..c3357fd --- /dev/null +++ b/src/include/nsss/shadow.h @@ -0,0 +1,52 @@ +/* ISC license. */ + +#ifndef NSSS_SHADOW_H +#define NSSS_SHADOW_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NSSS_DISABLE_SWITCH + +#include <nsss/shadow-unix.h> + +#define setspent nsss_unix_setspent +#define getspent nsss_unix_getspent +#define getspent_r nsss_unix_getspent_r +#define endspent nsss_unix_endspent +#define getspnam nsss_unix_getspnam +#define getspnam_r nsss_unix_getspnam_r + +#else +#ifdef NSSS_DISABLE_UNIX + +#include <nsss/shadow-switch.h> + +#define setspent nsss_switch_setspent +#define getspent nsss_switch_getspent +#define getspent_r nsss_switch_getspent_r +#define endspent nsss_switch_endspent +#define getspnam nsss_switch_getspnam +#define getspnam_r nsss_switch_getspnam_r + +#else + +#include <nsss/shadow-all.h> + +#define setspent nsss_all_setspent +#define getspent nsss_all_getspent +#define getspent_r nsss_all_getspent_r +#define endspent nsss_all_endspent +#define getspnam nsss_all_getspnam +#define getspnam_r nsss_all_getspnam_r + +#endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/pwd.h b/src/include/pwd.h new file mode 100644 index 0000000..6ad4faf --- /dev/null +++ b/src/include/pwd.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +/* + This file is part of the nsss package. + See https://skarnet.org/software/nsss/ +*/ + +#ifndef PWD_H +#define PWD_H + +#include <nsss/pwd.h> + +#ifdef _GNU_SOURCE +#include <stdio.h> +extern struct passwd *fgetpwent (FILE *) ; +extern int fgetpwent_r (FILE *, struct passwd *, char *, size_t, struct passwd **) ; +extern int putpwent (struct passwd const *, FILE *) ; +#endif + +#endif diff --git a/src/include/shadow.h b/src/include/shadow.h new file mode 100644 index 0000000..00d1944 --- /dev/null +++ b/src/include/shadow.h @@ -0,0 +1,26 @@ +/* ISC license. */ + +/* + This file is part of the nsss package. + See https://skarnet.org/software/nsss/ +*/ + +#ifndef SHADOW_H +#define SHADOW_H + +#include <nsss/shadow.h> + +#include <stdio.h> + +extern struct spwd *fgetspent (FILE *) ; +extern struct spwd *sgetspent (char const *) ; +extern int putspent (struct spwd const *, FILE *) ; +extern int lckpwdf (void) ; +extern int ulckpwdf (void) ; + +#ifdef _DEFAULT_SOURCE +extern int fgetspent_r(FILE *, struct spwd *, char *, size_t, struct spwd **) ; +extern int sgetspent_r (char const *, struct spwd *, char *, size_t, struct spwd **) ; +#endif + +#endif |