work around missing LOGIN_NAME_MAX

Both Linux and OpenBSD have LOGIN_NAME_MAX available when including
limits.h, FreeBSD, Darwin and possibly others don't.

FreeBSD (and maybe Darwin) have MAXLOGNAME, so try to use that if
available.  Otherwise use _POSIX_LOGIN_NAME_MAX, but only has a fallback
since it has a lower value (9 at the time of writing).

If everything fails, use 32 which is what OpenBSD use by default;
OpenSMTPd also defaults to it.

(compat copied from kamid.)
This commit is contained in:
Omar Polo 2022-10-30 07:30:23 +00:00
parent 50a8f9107c
commit fad3441ba9
1 changed files with 12 additions and 0 deletions

12
configure vendored
View File

@ -319,6 +319,7 @@ echo "#include <sys/types.h>"
echo "#include <sys/uio.h>"
echo "#include <stdint.h>"
echo "#include <imsg.h>"
echo "#include <limits.h>"
cat <<__HEREDOC__
@ -423,6 +424,17 @@ cat <<__HEREDOC__
#ifndef __dead
#define __dead __attribute__((noreturn))
#endif
/* Linux and OpenBSD have LOGIN_NAME_MAX, FreeBSD MAXLOGNAME. */
#ifndef LOGIN_NAME_MAX
# if defined(MAXLOGNAME)
# define LOGIN_NAME_MAX MAXLOGNAME
# elif defined(_POSIX_LOGIN_NAME_MAX)
# define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX
# else
# define LOGIN_NAME_MAX 32
# endif
#endif
__HEREDOC__
echo "file config.h: written" 1>&2