Compare commits
1 Commits
master
...
submit/arc
Author | SHA1 | Date | |
---|---|---|---|
|
df290e52a1 |
14
os/auth.c
14
os/auth.c
|
@ -312,17 +312,3 @@ GenerateAuthorization(unsigned name_length,
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* XCSECURITY */
|
#endif /* XCSECURITY */
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ MitGenerateCookie(unsigned data_length,
|
||||||
if (i >= sizeof(cookie))
|
if (i >= sizeof(cookie))
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
GenerateRandomData(sizeof(cookie), cookie);
|
arc4random_buf(cookie, sizeof(cookie));
|
||||||
status = MitAddCookie(sizeof(cookie), cookie, id);
|
status = MitAddCookie(sizeof(cookie), cookie, id);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
id = -1;
|
id = -1;
|
||||||
|
|
13
os/osdep.h
13
os/osdep.h
|
@ -128,7 +128,16 @@ extern WorkQueuePtr workQueue;
|
||||||
/* in access.c */
|
/* in access.c */
|
||||||
extern Bool ComputeLocalClient(ClientPtr client);
|
extern Bool ComputeLocalClient(ClientPtr client);
|
||||||
|
|
||||||
/* in auth.c */
|
/* for platforms lacking arc4random_buf() libc function */
|
||||||
extern void GenerateRandomData(int len, char *buf);
|
#ifndef HAVE_ARC4RANDOM_BUF
|
||||||
|
static inline void arc4random_buf(char *buf, size_t len)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = open("/dev/urandom", O_RDONLY);
|
||||||
|
read(fd, buf, len);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_ARC4RANDOM_BUF */
|
||||||
|
|
||||||
#endif /* _OSDEP_H_ */
|
#endif /* _OSDEP_H_ */
|
||||||
|
|
Loading…
Reference in New Issue