Fix password remove rule 69/144769/1
authorsangwan.kwon <sangwan.kwon@samsung.com>
Fri, 18 Aug 2017 01:18:53 +0000 (21:18 -0400)
committersangwan.kwon <sangwan.kwon@samsung.com>
Fri, 18 Aug 2017 01:24:27 +0000 (21:24 -0400)
When password quality is AUTH_PWD_QUALITY_UNSPECIFIED,
password should be able to remove no mather what any policies setted.

Change-Id: I83e2a85f49b6d48eb92a89d38991daf8a2587a91
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
src/server/service/include/policy-file.h
src/server/service/policy-file.cpp
src/server/service/policy-manager.cpp

index 74aaaf12ac22b8046c52bed95bb78e05603cba10..cfb692806b49217693c6055c3dd5566f3ea7a0d6 100644 (file)
@@ -55,6 +55,7 @@ public:
 
        bool checkQualityType(const std::string &password) const;
        void setQualityType(unsigned int qualityType);
+       unsigned int getQualityType() const;
 
        bool isValidPattern(const std::string &pattern) const;
        bool checkPattern(const std::string &password) const;
index bef942f1b6b0e5e84a2fd6ef7b6666aafabff13c..2394657dc0fa6c7fa2703264db087cfd634eb131 100644 (file)
@@ -392,6 +392,11 @@ void PolicyFile::setQualityType(unsigned int qualityType)
        m_policy.qualityType = qualityType;
 }
 
+unsigned int PolicyFile::getQualityType() const
+{
+       return m_policy.qualityType;
+}
+
 // policy pattern
 bool PolicyFile::isValidPattern(const std::string &pattern) const
 {
index 150fd6d061fbb92ab4631ebd92b36228d916451d..3f14e59ab2375b89c42c554cfc799d18342fbe72 100644 (file)
@@ -81,6 +81,9 @@ int PolicyManager::checkPolicy(unsigned int passwdType,
        if (!itPolicy->second.isPolicyActive() || (passwdType != AUTH_PWD_NORMAL))
                return AUTH_PASSWD_API_SUCCESS;
 
+       if (itPolicy->second.getQualityType() == AUTH_PWD_QUALITY_UNSPECIFIED && newPassword.empty())
+               return AUTH_PASSWD_API_SUCCESS;
+
        if (!itPolicy->second.checkMinLength(newPassword)) {
                LogError("new passwd's minLength is invalid");
                return AUTH_PASSWD_API_ERROR_INVALID_MIN_LENGTH;