d5591fb
configure.ac: Improve C99 compatibility
d5591fb
d5591fb
Future compilers will not support implicit declarations and implicit
d5591fb
ints by default.  This means that configure probes which rely on them
d5591fb
will fail unconditionally, without actually testing anything.
d5591fb
d5591fb
The changes mostly mirror what has been implemented in the openssh
d5591fb
repository, but had to be adapted somewhat because of drift between
d5591fb
the two versions of configure.ac.
d5591fb
d5591fb
Sam James has submitted similar fixes upstream:
d5591fb
d5591fb
  <https://github.com/jbeverly/pam_ssh_agent_auth/pull/41>
d5591fb
d5591fb
diff --git a/configure.ac b/configure.ac
d5591fb
index 6496679..d927b62 100644
d5591fb
--- a/configure.ac
d5591fb
+++ b/configure.ac
d5591fb
@@ -500,10 +500,10 @@ int main(void) { exit(0); }
d5591fb
 	AC_DEFINE(HAVE_BUNDLE, 1, [Define if your system uses bundles instead of ELF shared objects])
d5591fb
 	AC_MSG_CHECKING(if we have working getaddrinfo)
d5591fb
 	AC_TRY_RUN([#include <mach-o/dyld.h>
d5591fb
-main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
d5591fb
-		exit(0);
d5591fb
+int main(void) { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
d5591fb
+		return 0;
d5591fb
 	else
d5591fb
-		exit(1);
d5591fb
+		return 1;
d5591fb
 }], [AC_MSG_RESULT(working)],
d5591fb
 	[AC_MSG_RESULT(buggy)
d5591fb
 	AC_DEFINE(BROKEN_GETADDRINFO, 1, [getaddrinfo is broken (if present)])],
d5591fb
@@ -917,8 +917,8 @@ AC_SUBST(LDFLAGS_SHARED)
d5591fb
 AC_MSG_CHECKING(compiler and flags for sanity)
d5591fb
 AC_RUN_IFELSE(
d5591fb
 	[AC_LANG_SOURCE([
d5591fb
-#include <stdio.h>
d5591fb
-int main(){exit(0);}
d5591fb
+#include <stdlib.h>
d5591fb
+int main(void){exit(0);}
d5591fb
 	])],
d5591fb
 	[	AC_MSG_RESULT(yes) ],
d5591fb
 	[
d5591fb
@@ -951,9 +951,9 @@ int main(int argc, char **argv) {
d5591fb
     strncpy(buf,"/etc", 32);
d5591fb
     s = dirname(buf);
d5591fb
     if (!s || strncmp(s, "/", 32) != 0) {
d5591fb
-	exit(1);
d5591fb
+	return 1;
d5591fb
     } else {
d5591fb
-	exit(0);
d5591fb
+	return 0;
d5591fb
     }
d5591fb
 }
d5591fb
 				]])],
d5591fb
@@ -1102,7 +1102,7 @@ AC_RUN_IFELSE(
d5591fb
 	[AC_LANG_SOURCE([[
d5591fb
 #include <sys/types.h>
d5591fb
 #include <dirent.h>
d5591fb
-int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));}
d5591fb
+int main(void){struct dirent d;return sizeof(d.d_name)<=sizeof(char);}
d5591fb
 	]])],
d5591fb
 	[AC_MSG_RESULT(yes)],
d5591fb
 	[
d5591fb
@@ -1327,8 +1327,10 @@ AC_CHECK_FUNCS(setresuid, [
d5591fb
 	AC_MSG_CHECKING(if setresuid seems to work)
d5591fb
 	AC_RUN_IFELSE(
d5591fb
 		[AC_LANG_SOURCE([[
d5591fb
+#define _GNU_SOURCE
d5591fb
 #include <stdlib.h>
d5591fb
 #include <errno.h>
d5591fb
+#include <unistd.h>
d5591fb
 int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
d5591fb
 		]])],
d5591fb
 		[AC_MSG_RESULT(yes)],
d5591fb
@@ -1344,8 +1346,10 @@ AC_CHECK_FUNCS(setresgid, [
d5591fb
 	AC_MSG_CHECKING(if setresgid seems to work)
d5591fb
 	AC_RUN_IFELSE(
d5591fb
 		[AC_LANG_SOURCE([[
d5591fb
+#define _GNU_SOURCE
d5591fb
 #include <stdlib.h>
d5591fb
 #include <errno.h>
d5591fb
+#include <unistd.h>
d5591fb
 int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
d5591fb
 		]])],
d5591fb
 		[AC_MSG_RESULT(yes)],
d5591fb
@@ -1384,7 +1388,7 @@ if test "x$ac_cv_func_snprintf" = "xyes" ; then
d5591fb
 	AC_RUN_IFELSE(
d5591fb
 		[AC_LANG_SOURCE([[
d5591fb
 #include <stdio.h>
d5591fb
-int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
d5591fb
+int main(void){char b[5];snprintf(b,5,"123456789");return b[4]!='\0';}
d5591fb
 		]])],
d5591fb
 		[AC_MSG_RESULT(yes)],
d5591fb
 		[
d5591fb
@@ -1418,7 +1422,7 @@ int x_snprintf(char *str,size_t count,const char *fmt,...)
d5591fb
 int main(void)
d5591fb
 {
d5591fb
 	char x[1];
d5591fb
-	exit(x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1);
d5591fb
+	return x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1;
d5591fb
 } ]])],
d5591fb
 		[AC_MSG_RESULT(yes)],
d5591fb
 		[
d5591fb
@@ -1467,7 +1471,8 @@ AC_MSG_CHECKING([for (overly) strict mkstemp])
d5591fb
 AC_RUN_IFELSE(
d5591fb
 	[AC_LANG_SOURCE([[
d5591fb
 #include <stdlib.h>
d5591fb
-main() { char template[]="conftest.mkstemp-test";
d5591fb
+#include <unistd.h>
d5591fb
+int main(void) { char template[]="conftest.mkstemp-test";
d5591fb
 if (mkstemp(template) == -1)
d5591fb
 	exit(1);
d5591fb
 unlink(template); exit(0);
d5591fb
@@ -1492,10 +1497,14 @@ if test ! -z "$check_for_openpty_ctty_bug"; then
d5591fb
 	AC_MSG_CHECKING(if openpty correctly handles controlling tty)
d5591fb
 	AC_RUN_IFELSE(
d5591fb
 		[AC_LANG_SOURCE([[
d5591fb
+#include <stdlib.h>
d5591fb
 #include <stdio.h>
d5591fb
 #include <sys/fcntl.h>
d5591fb
 #include <sys/types.h>
d5591fb
 #include <sys/wait.h>
d5591fb
+#ifdef HAVE_PTY_H
d5591fb
+#include <pty.h>
d5591fb
+#endif
d5591fb
 
d5591fb
 int
d5591fb
 main()
d5591fb
@@ -1543,6 +1552,7 @@ if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
d5591fb
 	AC_RUN_IFELSE(
d5591fb
 		[AC_LANG_SOURCE([[
d5591fb
 #include <stdio.h>
d5591fb
+#include <stdlib.h>
d5591fb
 #include <sys/socket.h>
d5591fb
 #include <netdb.h>
d5591fb
 #include <errno.h>
d5591fb
@@ -1748,6 +1758,7 @@ AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL, 1,
d5591fb
 AC_MSG_CHECKING([OpenSSL header version])
d5591fb
 AC_RUN_IFELSE(
d5591fb
 	[AC_LANG_SOURCE([[
d5591fb
+#include <stdlib.h>
d5591fb
 #include <stdio.h>
d5591fb
 #include <string.h>
d5591fb
 #include <openssl/opensslv.h>
d5591fb
@@ -1794,12 +1805,12 @@ int main(void) {
d5591fb
 
d5591fb
 	fd = fopen(DATA,"w");
d5591fb
 	if(fd == NULL)
d5591fb
-		exit(1);
d5591fb
+		return 1;
d5591fb
 
d5591fb
 	if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
d5591fb
-		exit(1);
d5591fb
+		return 1;
d5591fb
 
d5591fb
-	exit(0);
d5591fb
+	return 0;
d5591fb
 }
d5591fb
 	]])],
d5591fb
 	[
d5591fb
@@ -1829,7 +1840,7 @@ AC_RUN_IFELSE(
d5591fb
 	[AC_LANG_SOURCE([[
d5591fb
 #include <string.h>
d5591fb
 #include <openssl/opensslv.h>
d5591fb
-int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
d5591fb
+int main(void) { return SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1; }
d5591fb
 	]])],
d5591fb
 	[
d5591fb
 		AC_MSG_RESULT(yes)
d5591fb
@@ -2598,7 +2609,7 @@ dnl test snprintf (broken on SCO w/gcc)
d5591fb
 #include <stdio.h>
d5591fb
 #include <string.h>
d5591fb
 #ifdef HAVE_SNPRINTF
d5591fb
-main()
d5591fb
+int main(void)
d5591fb
 {
d5591fb
 	char buf[50];
d5591fb
 	char expected_out[50];
d5591fb
@@ -2611,11 +2622,11 @@ main()
d5591fb
 	strcpy(expected_out, "9223372036854775807");
d5591fb
 	snprintf(buf, mazsize, "%lld", num);
d5591fb
 	if(strcmp(buf, expected_out) != 0)
d5591fb
-		exit(1);
d5591fb
-	exit(0);
d5591fb
+		return 1;
d5591fb
+	return 0;
d5591fb
 }
d5591fb
 #else
d5591fb
-main() { exit(0); }
d5591fb
+int main(void) { return 0; }
d5591fb
 #endif
d5591fb
 		]])], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ],
d5591fb
 		AC_MSG_WARN([cross compiling: Assuming working snprintf()])
d5591fb
@@ -2746,11 +2757,11 @@ AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
d5591fb
 int main() {
d5591fb
 #ifdef msg_accrights
d5591fb
 #error "msg_accrights is a macro"
d5591fb
-exit(1);
d5591fb
+return 1;
d5591fb
 #endif
d5591fb
 struct msghdr m;
d5591fb
 m.msg_accrights = 0;
d5591fb
-exit(0);
d5591fb
+return 0;
d5591fb
 }
d5591fb
 		])],
d5591fb
 		[ ac_cv_have_accrights_in_msghdr="yes" ],
d5591fb
@@ -2773,11 +2784,11 @@ AC_CACHE_CHECK([for msg_control field in struct msghdr],
d5591fb
 int main() {
d5591fb
 #ifdef msg_control
d5591fb
 #error "msg_control is a macro"
d5591fb
-exit(1);
d5591fb
+return 1;
d5591fb
 #endif
d5591fb
 struct msghdr m;
d5591fb
 m.msg_control = 0;
d5591fb
-exit(0);
d5591fb
+return 0;
d5591fb
 }
d5591fb
 		])],
d5591fb
 		[ ac_cv_have_control_in_msghdr="yes" ],
d5591fb
@@ -2791,7 +2802,7 @@ if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
d5591fb
 fi
d5591fb
 
d5591fb
 AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
d5591fb
-	AC_TRY_LINK([],
d5591fb
+	AC_TRY_LINK([#include <stdio.h>],
d5591fb
 		[ extern char *__progname; printf("%s", __progname); ],
d5591fb
 		[ ac_cv_libc_defines___progname="yes" ],
d5591fb
 		[ ac_cv_libc_defines___progname="no" ]
d5591fb
@@ -2871,7 +2882,7 @@ if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
d5591fb
 fi
d5591fb
 
d5591fb
 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
d5591fb
-	AC_TRY_LINK([],
d5591fb
+	AC_TRY_LINK([#include <stdio.h>],
d5591fb
 		[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);],
d5591fb
 		[ ac_cv_libc_defines_sys_errlist="yes" ],
d5591fb
 		[ ac_cv_libc_defines_sys_errlist="no" ]
d5591fb
@@ -2884,7 +2895,7 @@ fi
d5591fb
 
d5591fb
 
d5591fb
 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
d5591fb
-	AC_TRY_LINK([],
d5591fb
+	AC_TRY_LINK([#include <stdio.h>],
d5591fb
 		[ extern int sys_nerr; printf("%i", sys_nerr);],
d5591fb
 		[ ac_cv_libc_defines_sys_nerr="yes" ],
d5591fb
 		[ ac_cv_libc_defines_sys_nerr="no" ]