From e536c2035cf44387e3631dbbda3ae77087c1759d Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 10 Mar 2025 13:53:58 +0100 Subject: [PATCH] os: auth: move GenerateRandomData() and make it static Only used in mitauth.c, so we can move it there and make it static. Signed-off-by: Enrico Weigelt, metux IT consult --- os/auth.c | 14 -------------- os/mitauth.c | 14 ++++++++++++++ os/osdep.h | 3 --- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/os/auth.c b/os/auth.c index fd1f3f409..23e91beda 100644 --- a/os/auth.c +++ b/os/auth.c @@ -297,17 +297,3 @@ GenerateAuthorization(unsigned name_length, } return -1; } - -void -GenerateRandomData(int len, char *buf) -{ -#ifdef HAVE_ARC4RANDOM_BUF - arc4random_buf(buf, len); -#else - int fd; - - fd = open("/dev/urandom", O_RDONLY); - read(fd, buf, len); - close(fd); -#endif -} diff --git a/os/mitauth.c b/os/mitauth.c index 625080d6b..753f9d2a3 100644 --- a/os/mitauth.c +++ b/os/mitauth.c @@ -132,6 +132,20 @@ MitRemoveCookie(unsigned short data_length, const char *data) static char cookie[16]; /* 128 bits */ +static void +GenerateRandomData(int len, char *buf) +{ +#ifdef HAVE_ARC4RANDOM_BUF + arc4random_buf(buf, len); +#else + int fd; + + fd = open("/dev/urandom", O_RDONLY); + read(fd, buf, len); + close(fd); +#endif +} + XID MitGenerateCookie(unsigned data_length, const char *data, diff --git a/os/osdep.h b/os/osdep.h index 0683ca3d9..a9934071c 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -134,9 +134,6 @@ extern Bool NewOutputPending; /* in access.c */ extern Bool ComputeLocalClient(ClientPtr client); -/* in auth.c */ -extern void GenerateRandomData(int len, char *buf); - /* OsTimer functions */ void TimerInit(void); Bool TimerForce(OsTimerPtr timer);