Skip to content

Commit

Permalink
use stat
Browse files Browse the repository at this point in the history
  • Loading branch information
smittals2 committed Feb 18, 2025
1 parent 06cc975 commit aee3147
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crypto/fipsmodule/rand/snapsafe_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../delocate.h"

Expand All @@ -23,13 +24,16 @@ DEFINE_BSS_GET(int, snapsafety_state)

static void do_aws_snapsafe_init(void) {
*sgc_addr_bss_get() = NULL;
*snapsafety_state_bss_get() = SNAPSAFETY_STATE_FAILED_INITIALISE;
*snapsafety_state_bss_get() = SNAPSAFETY_STATE_NOT_SUPPORTED;

struct stat buff;
if (stat(CRYPTO_get_sysgenid_path(), &buff) != 0) {
return;
}

*snapsafety_state_bss_get() = SNAPSAFETY_STATE_FAILED_INITIALISE;
int fd_sgc = open(CRYPTO_get_sysgenid_path(), O_RDONLY);
if (fd_sgc == -1) {
if (errno == ENOENT) {
*snapsafety_state_bss_get() = SNAPSAFETY_STATE_NOT_SUPPORTED;
}
if (fd_sgc != 0) {
return;
}

Expand Down

0 comments on commit aee3147

Please sign in to comment.