Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | From bdf01a581d58eb5340e9238d143dbcac9db5b11c Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 30 Jan 2016 19:29:45 +0000 |
| 4 | Subject: [PATCH] check for nss.h |
| 5 | |
| 6 | nss.h may not available on all libc implementations, e.g. musl does not |
| 7 | have this header, this patch detects nss.h presence and defines the data |
| 8 | types that are required if nss.h is missing on platform |
| 9 | |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | Upstream-Status: Pending |
| 13 | |
| 14 | configure.ac | 2 +- |
| 15 | src/nss.c | 11 +++++++++++ |
| 16 | 2 files changed, 12 insertions(+), 1 deletion(-) |
| 17 | |
| 18 | diff --git a/configure.ac b/configure.ac |
| 19 | index aa66bc6..ce19b07 100644 |
| 20 | --- a/configure.ac |
| 21 | +++ b/configure.ac |
| 22 | @@ -71,7 +71,7 @@ AC_PROG_LIBTOOL |
| 23 | |
| 24 | # Checks for header files. |
| 25 | AC_HEADER_STDC |
| 26 | -AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h nss.h sys/ioctl.h]) |
| 27 | +AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h nss.h sys/ioctl.h nss.h]) |
| 28 | |
| 29 | # Checks for typedefs, structures, and compiler characteristics. |
| 30 | AC_C_CONST |
| 31 | diff --git a/src/nss.c b/src/nss.c |
| 32 | index e48e315..406733b 100644 |
| 33 | --- a/src/nss.c |
| 34 | +++ b/src/nss.c |
| 35 | @@ -29,7 +29,18 @@ |
| 36 | #include <assert.h> |
| 37 | #include <netdb.h> |
| 38 | #include <sys/socket.h> |
| 39 | +#ifdef HAVE_NSS_H |
| 40 | #include <nss.h> |
| 41 | +#else |
| 42 | +enum nss_status { |
| 43 | + NSS_STATUS_TRYAGAIN = -2, |
| 44 | + NSS_STATUS_UNAVAIL, |
| 45 | + NSS_STATUS_NOTFOUND, |
| 46 | + NSS_STATUS_SUCCESS, |
| 47 | + NSS_STATUS_RETURN |
| 48 | +}; |
| 49 | +#endif |
| 50 | + |
| 51 | #include <stdio.h> |
| 52 | #include <stdlib.h> |
| 53 | |
| 54 | -- |
| 55 | 2.7.0 |
| 56 | |