Use arc4random_buf(3) if available to generate cookies.
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
This commit is contained in:
parent
d7ac755f0b
commit
957e8db38f
|
@ -225,6 +225,8 @@ AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\
|
||||||
timingsafe_memcmp])
|
timingsafe_memcmp])
|
||||||
AM_CONDITIONAL(POLL, [test "x$ac_cv_func_poll" = "xyes"])
|
AM_CONDITIONAL(POLL, [test "x$ac_cv_func_poll" = "xyes"])
|
||||||
|
|
||||||
|
AC_CHECK_LIB([bsd], [arc4random_buf])
|
||||||
|
|
||||||
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
|
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
|
||||||
|
|
||||||
dnl Check for SO_PEERCRED #define
|
dnl Check for SO_PEERCRED #define
|
||||||
|
|
|
@ -125,6 +125,9 @@
|
||||||
/* Build a standalone xpbproxy */
|
/* Build a standalone xpbproxy */
|
||||||
#undef STANDALONE_XPBPROXY
|
#undef STANDALONE_XPBPROXY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `bsd' library (-lbsd). */
|
||||||
|
#undef HAVE_LIBBSD
|
||||||
|
|
||||||
/* Define to 1 if you have the `m' library (-lm). */
|
/* Define to 1 if you have the `m' library (-lm). */
|
||||||
#undef HAVE_LIBM
|
#undef HAVE_LIBM
|
||||||
|
|
||||||
|
@ -161,6 +164,9 @@
|
||||||
/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
|
/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
|
||||||
#undef HAVE_RPCSVC_DBM_H
|
#undef HAVE_RPCSVC_DBM_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `arc4random_buf' function. */
|
||||||
|
#undef HAVE_ARC4RANDOM_BUF
|
||||||
|
|
||||||
/* Define to use libc SHA1 functions */
|
/* Define to use libc SHA1 functions */
|
||||||
#undef HAVE_SHA1_IN_LIBC
|
#undef HAVE_SHA1_IN_LIBC
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ from The Open Group.
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <X11/Xw32defs.h>
|
#include <X11/Xw32defs.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBBSD
|
||||||
|
#include <bsd/stdlib.h> /* for arc4random_buf() */
|
||||||
|
#endif
|
||||||
|
|
||||||
struct protocol {
|
struct protocol {
|
||||||
unsigned short name_length;
|
unsigned short name_length;
|
||||||
|
@ -303,11 +306,15 @@ GenerateAuthorization(unsigned name_length,
|
||||||
void
|
void
|
||||||
GenerateRandomData(int len, char *buf)
|
GenerateRandomData(int len, char *buf)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_ARC4RANDOMBUF
|
||||||
|
arc4random_buf(buf, len);
|
||||||
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = open("/dev/urandom", O_RDONLY);
|
fd = open("/dev/urandom", O_RDONLY);
|
||||||
read(fd, buf, len);
|
read(fd, buf, len);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* XCSECURITY */
|
#endif /* XCSECURITY */
|
||||||
|
|
Loading…
Reference in New Issue