[PATCH] Fix Linux-PAM 0.99.3.0 compiling when system headers don't define HOST_NAME_MAX. (fwd)

Dan Yefimov dan at D00M.lightwave.net.ru
Sun Jan 29 14:20:38 UTC 2006


				Hello!
	While compiling Linux-PAM 0.99.3.0 I've discovered that on my system 
compiling modules/pam_echo/pam_echo.c fails because of HOST_NAME_MAX is 
undefined on my system. Attached a patch that simply defines HOST_NAME_MAX to 
either MAXHOSTNAME (if that is defined in sys/param.h, which is my case) or to 
64, if the former is not defined (which is unlikely, but...). The patch is 
applied to configure.in only (of course, after that autoreconf should be 
invoked). Please apply.
-- 

    Sincerely Your, Dan.
-------------- next part --------------
--- Linux-PAM-0.99.3.0/configure.in.host-name-max	2005-12-12 19:56:27.000000000 +0300
+++ Linux-PAM-0.99.3.0/configure.in	2006-01-28 01:31:58.000000000 +0300
@@ -395,6 +395,46 @@
 AC_CHECK_FUNCS(getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r)
 AC_CHECK_FUNCS(getgrouplist getline getdelim)
 
+AH_BOTTOM([#ifndef HAVE_HOST_NAME_MAX
+ #ifdef HAVE_MAXHOSTNAME
+  #include <sys/param.h>
+  #define HOST_NAME_MAX MAXHOSTNAME
+ #else 
+  #define HOST_NAME_MAX 64
+ #endif
+#endif])
+ac_cv_maxhostname_defined=no
+AC_CACHE_CHECK([[whether HOST_NAME_MAX is defined in limits.h]],
+	[ac_cv_host_name_max_defined],
+	[AC_COMPILE_IFELSE([[#include <limits.h>
+
+char name[HOST_NAME_MAX];
+
+int main()
+{
+  return 0;
+}]], [ac_cv_host_name_max_defined=yes
+		 AC_MSG_RESULT([ac_cv_host_name_max_defined])],
+		[ac_cv_host_name_max_defined=no
+		AC_MSG_RESULT([ac_cv_host_name_max_defined])
+		AC_CACHE_CHECK([[whether MAXHOSTNAME is defined in sys/param.h]],
+			[ac_cv_maxhostname_defined],
+			[AC_COMPILE_IFELSE([[#include <sys/param.h>
+
+char name[MAXHOSTNAME];
+
+int main()
+{
+	return 0;
+}]], [ac_cv_maxhostname_defined=yes], [ac_cv_maxhostname_defined=no])])
+		AC_MSG_RESULT([ac_cv_maxhostname_defined])])])
+if test $ac_cv_host_name_max_defined = yes; then
+	AC_DEFINE([HAVE_HOST_NAME_MAX], 1, [Define if system header limits.h defines HOST_NAME_MAX])
+fi
+if test $ac_cv_maxhostname_defined = yes; then
+	AC_DEFINE([HAVE_MAXHOSTNAME], 1, [Define if system header sys/param.h defines MAXHOSTNAME])
+fi
+
 dnl Checks for programs/utilities
 AC_CHECK_PROG(SGML2PS, sgml2ps, yes, no)
 AC_CHECK_PROG(SGML2TXT, sgml2txt, yes, no)


More information about the Pam-list mailing list