From 6fdb4834cdb5557d9bd7562f61984da8bd0d9c80 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 9 Sep 2021 19:58:12 +0000 Subject: Prepare for 0.2.0.0, lots of changes. - Make _r functions completely thread-safe. - Save a lot of forking by having a persistent nsss_switch_query - Introduce a timeout to make the server expire - Start writing nsss-switch, not working yet. Signed-off-by: Laurent Bercot --- src/include/nsss/nsss-switch.h | 31 ++++++++++++++++++++++--------- src/include/nsss/nsssd.h | 4 ++-- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src/include') diff --git a/src/include/nsss/nsss-switch.h b/src/include/nsss/nsss-switch.h index e0ce2dc..9110b13 100644 --- a/src/include/nsss/nsss-switch.h +++ b/src/include/nsss/nsss-switch.h @@ -6,10 +6,12 @@ #include #include #include + #include #include #include #include + #include #include #include @@ -26,27 +28,38 @@ typedef struct nsss_switch_s nsss_switch_t, *nsss_switch_t_ref ; struct nsss_switch_s { unsigned int held ; + char const *path ; buffer b ; char buf[NSSS_SWITCH_BUFSIZE] ; } ; -#define NSSS_SWITCH_ZERO { .held = 0, .b = BUFFER_ZERO } +#define NSSS_SWITCH_ZERO { .held = 0, .path = 0, .b = BUFFER_ZERO } -#define NSSS_SWITCH_PWD 0 -#define NSSS_SWITCH_GRP 1 -#define NSSS_SWITCH_SHADOW 2 +#define NSSS_SWITCH_PWD 1 +#define NSSS_SWITCH_GRP 2 +#define NSSS_SWITCH_SHADOW 4 extern int nsss_switch_start (nsss_switch_t *, unsigned int, char const *, tain const *, tain *) ; #define nsss_switch_start_g(a, what, s, deadline) nsss_switch_start(a, what, s, (deadline), &STAMP) +extern int nsss_switch_startf (nsss_switch_t *, unsigned int, char const *const *, tain const *, tain *) ; +#define nsss_switch_startf_g(a, what, argv, deadline) nsss_switch_startf(a, what, argv, (deadline), &STAMP) extern void nsss_switch_end (nsss_switch_t *, unsigned int) ; + /* Internal management */ + +#define NSSS_SWITCH_SET_TIMEOUT '\001' + +extern int nsss_switch_set_timeout (nsss_switch_t *, unsigned int, tain const *, tain *) ; +#define nsss_switch_set_timeout_g(a, timeout, deadline) nsss_switch_set_timeout(a, timeout, (deadline), &STAMP) + + /* 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' +#define NSSS_SWITCH_PWD_END '\010' +#define NSSS_SWITCH_PWD_REWIND '\011' +#define NSSS_SWITCH_PWD_GET '\012' +#define NSSS_SWITCH_PWD_GETBYNAME '\013' +#define NSSS_SWITCH_PWD_GETBYUID '\014' extern int nsss_switch_pwd_end (nsss_switch_t *, tain const *, tain *) ; #define nsss_switch_pwd_end_g(a, deadline) nsss_switch_pwd_end(a, (deadline), &STAMP) diff --git a/src/include/nsss/nsssd.h b/src/include/nsss/nsssd.h index b21e6d2..99e93f8 100644 --- a/src/include/nsss/nsssd.h +++ b/src/include/nsss/nsssd.h @@ -49,7 +49,7 @@ struct nsssd_spwd_s /* Functions provided by libnsssd */ -extern int nsssd_main (char const *const *, char const *const *) ; +extern int nsssd_main (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 *) ; @@ -58,7 +58,7 @@ 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 int nsssd_handle_start (void *, char const *const *) ; extern void nsssd_handle_end (void *) ; extern int nsssd_pwd_start (void *) ; -- cgit v1.2.3