|
|
f65af0 |
From 08ada3f8d7f80067a1b43e6172394d1326e3d178 Mon Sep 17 00:00:00 2001
|
|
|
f65af0 |
From: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
f65af0 |
Date: Wed, 8 Aug 2018 12:28:53 +0300
|
|
|
f65af0 |
Subject: [PATCH] Move fips_enabled to a common library to share across
|
|
|
f65af0 |
different plugins
|
|
|
f65af0 |
|
|
|
f65af0 |
Related: https://pagure.io/freeipa/issue/7659
|
|
|
f65af0 |
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
|
|
|
f65af0 |
---
|
|
|
f65af0 |
.../ipa-slapi-plugins/ipa-pwd-extop/common.c | 24 +-----------------
|
|
|
f65af0 |
util/ipa_pwd.c | 25 +++++++++++++++++++
|
|
|
f65af0 |
util/ipa_pwd.h | 2 ++
|
|
|
f65af0 |
3 files changed, 28 insertions(+), 23 deletions(-)
|
|
|
f65af0 |
|
|
|
f65af0 |
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/common.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/common.c
|
|
|
f65af0 |
index 5efadac5b1fd57e5f91a886224fa2f1ab88305ac..db7183bf2b115dcb0c21f7a6bdb8e55db26224c4 100644
|
|
|
f65af0 |
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/common.c
|
|
|
f65af0 |
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/common.c
|
|
|
f65af0 |
@@ -46,7 +46,6 @@
|
|
|
f65af0 |
/* Type of connection for this operation;*/
|
|
|
f65af0 |
#define LDAP_EXTOP_PASSMOD_CONN_SECURE
|
|
|
f65af0 |
|
|
|
f65af0 |
-#define PROC_SYS_FIPS "/proc/sys/crypto/fips_enabled"
|
|
|
f65af0 |
|
|
|
f65af0 |
/* Uncomment the following #undef FOR TESTING:
|
|
|
f65af0 |
* allows non-SSL connections to use the password change extended op */
|
|
|
f65af0 |
@@ -64,27 +63,6 @@ static const char *ipapwd_def_encsalts[] = {
|
|
|
f65af0 |
NULL
|
|
|
f65af0 |
};
|
|
|
f65af0 |
|
|
|
f65af0 |
-static bool fips_enabled(void)
|
|
|
f65af0 |
-{
|
|
|
f65af0 |
- int fd;
|
|
|
f65af0 |
- ssize_t len;
|
|
|
f65af0 |
- char buf[8];
|
|
|
f65af0 |
-
|
|
|
f65af0 |
- fd = open(PROC_SYS_FIPS, O_RDONLY);
|
|
|
f65af0 |
- if (fd != -1) {
|
|
|
f65af0 |
- len = read(fd, buf, sizeof(buf));
|
|
|
f65af0 |
- close(fd);
|
|
|
f65af0 |
- /* Assume FIPS in enabled if PROC_SYS_FIPS contains a non-0 value
|
|
|
f65af0 |
- * similar to the is_fips_enabled() check in
|
|
|
f65af0 |
- * ipaplatform/redhat/tasks.py */
|
|
|
f65af0 |
- if (!(len == 2 && buf[0] == '0' && buf[1] == '\n')) {
|
|
|
f65af0 |
- return true;
|
|
|
f65af0 |
- }
|
|
|
f65af0 |
- }
|
|
|
f65af0 |
-
|
|
|
f65af0 |
- return false;
|
|
|
f65af0 |
-}
|
|
|
f65af0 |
-
|
|
|
f65af0 |
static struct ipapwd_krbcfg *ipapwd_getConfig(void)
|
|
|
f65af0 |
{
|
|
|
f65af0 |
krb5_error_code krberr;
|
|
|
f65af0 |
@@ -255,7 +233,7 @@ static struct ipapwd_krbcfg *ipapwd_getConfig(void)
|
|
|
f65af0 |
|
|
|
f65af0 |
/* get the ipa etc/ipaConfig entry */
|
|
|
f65af0 |
config->allow_nt_hash = false;
|
|
|
f65af0 |
- if (fips_enabled()) {
|
|
|
f65af0 |
+ if (ipapwd_fips_enabled()) {
|
|
|
f65af0 |
LOG("FIPS mode is enabled, NT hashes are not allowed.\n");
|
|
|
f65af0 |
} else {
|
|
|
f65af0 |
ret = ipapwd_getEntry(ipa_etc_config_dn, &config_entry, NULL);
|
|
|
f65af0 |
diff --git a/util/ipa_pwd.c b/util/ipa_pwd.c
|
|
|
f65af0 |
index f6564c8021c656031d3f459dd50d830934c7143b..9890c980cacad08302fb5305c3aa9598a81ec681 100644
|
|
|
f65af0 |
--- a/util/ipa_pwd.c
|
|
|
f65af0 |
+++ b/util/ipa_pwd.c
|
|
|
f65af0 |
@@ -27,6 +27,8 @@
|
|
|
f65af0 |
#include <stdio.h>
|
|
|
f65af0 |
#include <time.h>
|
|
|
f65af0 |
#include <ctype.h>
|
|
|
f65af0 |
+#include <fcntl.h>
|
|
|
f65af0 |
+#include <unistd.h>
|
|
|
f65af0 |
#include <nss.h>
|
|
|
f65af0 |
#include <nssb64.h>
|
|
|
f65af0 |
#include <hasht.h>
|
|
|
f65af0 |
@@ -656,3 +658,26 @@ done:
|
|
|
f65af0 |
free(hash);
|
|
|
f65af0 |
return ret;
|
|
|
f65af0 |
}
|
|
|
f65af0 |
+
|
|
|
f65af0 |
+#define PROC_SYS_FIPS "/proc/sys/crypto/fips_enabled"
|
|
|
f65af0 |
+
|
|
|
f65af0 |
+bool ipapwd_fips_enabled(void)
|
|
|
f65af0 |
+{
|
|
|
f65af0 |
+ int fd;
|
|
|
f65af0 |
+ ssize_t len;
|
|
|
f65af0 |
+ char buf[8];
|
|
|
f65af0 |
+
|
|
|
f65af0 |
+ fd = open(PROC_SYS_FIPS, O_RDONLY);
|
|
|
f65af0 |
+ if (fd != -1) {
|
|
|
f65af0 |
+ len = read(fd, buf, sizeof(buf));
|
|
|
f65af0 |
+ close(fd);
|
|
|
f65af0 |
+ /* Assume FIPS in enabled if PROC_SYS_FIPS contains a non-0 value
|
|
|
f65af0 |
+ * similar to the is_fips_enabled() check in
|
|
|
f65af0 |
+ * ipaplatform/redhat/tasks.py */
|
|
|
f65af0 |
+ if (!(len == 2 && buf[0] == '0' && buf[1] == '\n')) {
|
|
|
f65af0 |
+ return true;
|
|
|
f65af0 |
+ }
|
|
|
f65af0 |
+ }
|
|
|
f65af0 |
+
|
|
|
f65af0 |
+ return false;
|
|
|
f65af0 |
+}
|
|
|
f65af0 |
diff --git a/util/ipa_pwd.h b/util/ipa_pwd.h
|
|
|
f65af0 |
index b3ee75063adc4baa93bbd4991161bebe1d233bb8..664c8b1827591e716095d9ef1727e422c7d82680 100644
|
|
|
f65af0 |
--- a/util/ipa_pwd.h
|
|
|
f65af0 |
+++ b/util/ipa_pwd.h
|
|
|
f65af0 |
@@ -77,3 +77,5 @@ int ipapwd_generate_new_history(char *password,
|
|
|
f65af0 |
int *new_pwd_hlen);
|
|
|
f65af0 |
|
|
|
f65af0 |
int encode_nt_key(char *newPasswd, uint8_t *nt_key);
|
|
|
f65af0 |
+
|
|
|
f65af0 |
+bool ipapwd_fips_enabled(void);
|
|
|
f65af0 |
--
|
|
|
f65af0 |
2.17.1
|
|
|
f65af0 |
|