Blame SOURCES/freeradius-FIPS-exit-if-md5-not-allowed.patch

acdfd7
Author: Antonio Torres <antorres@redhat.com>
acdfd7
Date:   Fri Jul 2 07:12:48 2021 -0400
acdfd7
Subject: [PATCH] exit if host in FIPS mode and MD5 not explicitly allowed
acdfd7
acdfd7
	FIPS does not allow MD5, which FreeRADIUS needs to work. The user should
acdfd7
	explicitly allow MD5 usage by setting the RADIUS_MD5_FIPS_OVERRIDE environment
acdfd7
	variable to 1 or else FR should exit at start.
acdfd7
	
acdfd7
	Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1958979
acdfd7
	Signed-off-by: Antonio Torres antorres@redhat.com
acdfd7
---
acdfd7
 src/main/radiusd.c | 14 ++++++++++++++
acdfd7
 1 file changed, 14 insertions(+)
acdfd7
acdfd7
diff --git a/src/main/radiusd.c b/src/main/radiusd.c
acdfd7
index 9739514509..58a48895e6 100644
acdfd7
--- a/src/main/radiusd.c
acdfd7
+++ b/src/main/radiusd.c
acdfd7
@@ -298,6 +298,20 @@ int main(int argc, char *argv[])
acdfd7
 		exit(EXIT_FAILURE);
acdfd7
 	}
acdfd7
 
acdfd7
+	/*
acdfd7
+	 *  If host is in FIPS mode, we need the user to explicitly allow MD5 usage.
acdfd7
+	 */
acdfd7
+	char *fips_md5_override = getenv("RADIUS_MD5_FIPS_OVERRIDE");
acdfd7
+	FILE *fips_file = fopen("/proc/sys/crypto/fips_enabled", "r");
acdfd7
+	if (fips_file != NULL) {
acdfd7
+		int fips_enabled = fgetc(fips_file) - '0';
acdfd7
+		fclose(fips_file);
acdfd7
+		if (fips_enabled == 1 && (fips_md5_override == NULL || atoi(fips_md5_override) != 1)) {
acdfd7
+			fprintf(stderr, "Cannot run FreeRADIUS in FIPS mode because it uses MD5. To allow MD5 usage, set RADIUS_MD5_FIPS_OVERRIDE=1 before starting FreeRADIUS.\n");
acdfd7
+			exit(EXIT_FAILURE);
acdfd7
+		}
acdfd7
+	}
acdfd7
+
acdfd7
 	/*
acdfd7
 	 *  According to the talloc peeps, no two threads may modify any part of
acdfd7
 	 *  a ctx tree with a common root without synchronisation.