aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-01-10 15:30:44 +1100
committerNicholas Tay <nick@windblume.net>2022-01-10 15:30:44 +1100
commit59afa1af29c192b7a00777ab093814aa20f546ad (patch)
tree78af122b82e7e35fb84610fcadacb079248580f7
parent9f9903f90443e30eaa39c096257f5eb9fca04101 (diff)
downloadpassgen-59afa1af29c192b7a00777ab093814aa20f546ad.tar.gz
passgen-59afa1af29c192b7a00777ab093814aa20f546ad.tar.bz2
passgen-59afa1af29c192b7a00777ab093814aa20f546ad.zip
Switch to getentropy C api (to port to macOS)
-rw-r--r--passgen.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/passgen.c b/passgen.c
index c2d1738..2220be6 100644
--- a/passgen.c
+++ b/passgen.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <unistd.h>
#ifdef __linux__
#include <sys/random.h>
@@ -12,8 +13,6 @@
#if defined (_WIN32) && ! defined (__MINGW32__)
#include <io.h>
-#elif ! defined (__linux__)
-#include <unistd.h>
#endif
#endif
@@ -113,7 +112,7 @@ int main(int argc, char *argv[])
do {
#ifdef __linux__
unsigned int r;
- getrandom(&r, sizeof(r), 0);
+ getentropy(&r, sizeof(r));
#else
long r = rand();
#endif