aboutsummaryrefslogtreecommitdiff
path: root/kms/client/kms_client.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-15 18:57:33 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-15 19:02:34 +0200
commit048b8d21ecbd1168ff8e033b12cbfd66bba0127c (patch)
treef536c35090a6ed78803d064c0784370a2424ca7a /kms/client/kms_client.c
parentc447a9a35f51815db307e5d58630040cd63ad4b7 (diff)
Add support for desktop portal capture (-w portal)
Diffstat (limited to 'kms/client/kms_client.c')
-rw-r--r--kms/client/kms_client.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c
index 869bf81..ddd9b89 100644
--- a/kms/client/kms_client.c
+++ b/kms/client/kms_client.c
@@ -12,6 +12,7 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/capability.h>
+#include <sys/random.h>
#define GSR_SOCKET_PAIR_LOCAL 0
#define GSR_SOCKET_PAIR_REMOTE 1
@@ -20,15 +21,9 @@ static void cleanup_socket(gsr_kms_client *self, bool kill_server);
static int gsr_kms_client_replace_connection(gsr_kms_client *self);
static bool generate_random_characters(char *buffer, int buffer_size, const char *alphabet, size_t alphabet_size) {
- int fd = open("/dev/urandom", O_RDONLY);
- if(fd == -1) {
- perror("/dev/urandom");
- return false;
- }
-
- if(read(fd, buffer, buffer_size) < buffer_size) {
- fprintf(stderr, "Failed to read %d bytes from /dev/urandom\n", buffer_size);
- close(fd);
+ /* TODO: Use other functions on other platforms than linux */
+ if(getrandom(buffer, buffer_size, 0) < buffer_size) {
+ fprintf(stderr, "Failed to get random bytes, error: %s\n", strerror(errno));
return false;
}
@@ -37,7 +32,6 @@ static bool generate_random_characters(char *buffer, int buffer_size, const char
buffer[i] = alphabet[c % alphabet_size];
}
- close(fd);
return true;
}