summaryrefslogtreecommitdiff
path: root/reentr.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-03-11 12:24:33 -0600
committerKarl Williamson <khw@cpan.org>2020-03-18 14:29:46 -0600
commit5baa389e84c8348c7335cd8e58d1a2f6f917f7e4 (patch)
tree9c680609ae48e379e7f855f03d4b9613d664682c /reentr.h
parent5f47881659a0e7bfbe5db3cda32beec498c07696 (diff)
downloadperl-5baa389e84c8348c7335cd8e58d1a2f6f917f7e4.tar.gz
reentr.c: Handle getspnam()
This has never worked to increase the buffer size if necessary. Apparently the default has always been big enough. But this commit fixes it to retry if too small. I don't think there is a way to write tests for this. getspnam is called only as a small part of pp_gpwent, and is not part of the API, and is called only when run as root. I did test it on my box, with gdb, starting with a buffer size of 1, and single stepping and observing that it works as I expected.
Diffstat (limited to 'reentr.h')
-rw-r--r--reentr.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/reentr.h b/reentr.h
index 9e65001dcb..25f21ad1a6 100644
--- a/reentr.h
+++ b/reentr.h
@@ -357,6 +357,22 @@
# undef USE_PWENT_BUFFER
# endif
+/* The getspent getspnam using buffer? */
+
+# if defined(HAS_GETSPNAM_R) && (GETSPNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETSPNAM_R_PROTO == REENTRANT_PROTO_S_CSBI)
+# define GETSPNAM_R_HAS_BUFFER
+# else
+# undef GETSPNAM_R_HAS_BUFFER
+# endif
+
+/* Any of the getspent getspnam using buffer? */
+
+# if (defined(GETSPENT_R_HAS_BUFFER) || defined(GETSPNAM_R_HAS_BUFFER))
+# define USE_SPENT_BUFFER
+# else
+# undef USE_SPENT_BUFFER
+# endif
+
/* The gethostent gethostbyaddr gethostbyname using ptr? */
# if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE)
@@ -1495,6 +1511,12 @@ typedef struct {
+
+/* Special case this; if others came along, could automate it */
+# ifdef HAS_GETSPNAM_R
+# define KEY_getspnam -1
+# endif
+
#endif /* USE_REENTRANT_API */
#endif