[PATCH xserver 2/7] os: make GenerateRandomData() independent of XCSECURITY

Emil Velikov emil.l.velikov at gmail.com
Thu Aug 3 19:15:46 UTC 2017


The function itself does not depend on the macro. Move it outside
of the ifdef guard and remove the identical copy in XWIN.

This is step 1 towards removing the duplication in winauth.c and moving
the OS specifics to os/

Cc: Jon Turney <jon.turney at dronecode.org.uk>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 hw/xwin/winauth.c | 10 ----------
 os/auth.c         |  4 ++--
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/hw/xwin/winauth.c b/hw/xwin/winauth.c
index e86343952..b7d1e2c7d 100644
--- a/hw/xwin/winauth.c
+++ b/hw/xwin/winauth.c
@@ -68,16 +68,6 @@ static xcb_auth_info_t auth_info;
  */
 
 #ifndef XCSECURITY
-void
-GenerateRandomData(int len, char *buf)
-{
-    int fd;
-
-    fd = open("/dev/urandom", O_RDONLY);
-    read(fd, buf, len);
-    close(fd);
-}
-
 static char cookie[16];         /* 128 bits */
 
 XID
diff --git a/os/auth.c b/os/auth.c
index c7b333ca2..9d87c1f39 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -302,6 +302,8 @@ GenerateAuthorization(unsigned name_length,
     return -1;
 }
 
+#endif                          /* XCSECURITY */
+
 void
 GenerateRandomData(int len, char *buf)
 {
@@ -315,5 +317,3 @@ GenerateRandomData(int len, char *buf)
     close(fd);
 #endif
 }
-
-#endif                          /* XCSECURITY */
-- 
2.13.3



More information about the xorg-devel mailing list