summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2017-12-06 17:11:41 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-12-05 00:45:54 +0000
commit1813b6c02a5f01776ad8279d544aba931cf4be7d (patch)
treede191baa0764620723c70b470aa222f89f627df8
parent61d2349205f0a6fc61d0d03ee5c4efee162c26d7 (diff)
downloadchrome-ec-1813b6c02a5f01776ad8279d544aba931cf4be7d.tar.gz
ccd: require password to change or clear it
Let's not allow the user to clear or change CCD password without specifying the old password. To keep things simple, two changes are being made: - do not allow setting password if password is already set - when clearing the password require user to enter 'clear:<password>' instead of just 'clear' BRANCH=cr50 BUG=b:70029808 TEST=verified that setting password is possible only if there is no password set currently, and that invoking 'ccd password clear:<old password>' indeed clears the password. Change-Id: I3753c2701e224ef89b25ad68c1b47b54eef9cdb1 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/813098 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1332611 Reviewed-by: Marco Chen <marcochen@chromium.org> Commit-Queue: Marco Chen <marcochen@chromium.org> Tested-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1359935 Reviewed-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com> Tested-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com> Commit-Queue: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com>
-rw-r--r--common/ccd_config.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c
index 9cfa0648f3..6d19d972d2 100644
--- a/common/ccd_config.c
+++ b/common/ccd_config.c
@@ -781,13 +781,23 @@ static int do_ccd_password(char *password)
if (ccd_state == CCD_STATE_LOCKED)
return EC_ERROR_ACCESS_DENIED;
- /* If password was set from Opened, can't change if just Unlocked */
- if (raw_has_password() && ccd_state == CCD_STATE_UNLOCKED &&
- !ccd_get_flag(CCD_FLAG_PASSWORD_SET_WHEN_UNLOCKED))
- return EC_ERROR_ACCESS_DENIED;
+ if (raw_has_password()) {
+ const char clear_prefix[] = {'c', 'l', 'e', 'a', 'r', ':'};
+
+ /*
+ * The only allowed action at this point is to clear the
+ * password. To do it the user is supposed to enter
+ * 'clear:<passwd>'
+ */
+ if (strncasecmp(password, clear_prefix, sizeof(clear_prefix)))
+ return EC_ERROR_ACCESS_DENIED;
+
+ if (raw_check_password(password + sizeof(clear_prefix)) !=
+ EC_SUCCESS)
+ return EC_ERROR_ACCESS_DENIED;
- if (!strcasecmp(password, "clear"))
return ccd_reset_password();
+ }
/* Set new password */
return ccd_set_password(password);