vishalmishra434 / rpms / openssh

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