294c78
# HG changeset patch
294c78
# User Daiki Ueno <dueno@redhat.com>
294c78
# Date 1523546409 -7200
294c78
#      Thu Apr 12 17:20:09 2018 +0200
294c78
# Node ID 919e116728f29263c17ec31716ac2bd04c10e9ca
294c78
# Parent  2eefd697d661efb82a77c84d893e6fbceefdf458
294c78
Bug 1453408, modutil -changepw fails in FIPS mode if password is an empty string
294c78
294c78
diff --git a/cmd/modutil/pk11.c b/cmd/modutil/pk11.c
294c78
--- a/cmd/modutil/pk11.c
294c78
+++ b/cmd/modutil/pk11.c
294c78
@@ -764,6 +764,10 @@ ChangePW(char *tokenName, char *pwFile, 
294c78
             ret = CHANGEPW_FAILED_ERR;
294c78
             goto loser;
294c78
         }
294c78
+    } else if (PK11_IsFIPS() && *newpw == '\0' && PK11_CheckUserPassword(slot, newpw) == SECSuccess) {
294c78
+        /* Workaround to suppress harmless error in FIPS mode:
294c78
+         * When explicitly setting empty password while the old
294c78
+         * password is also empty, skip */
294c78
     } else {
294c78
         if (PK11_ChangePW(slot, oldpw, newpw) != SECSuccess) {
294c78
             PR_fprintf(PR_STDERR, errStrings[CHANGEPW_FAILED_ERR], tokenName);