diff options
author | Eduardo Chappa <chappa@washington.edu> | 2016-02-28 14:36:21 -0700 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2016-02-28 14:36:21 -0700 |
commit | 27b0c30862b56feccb120c896e1354b501681e2a (patch) | |
tree | cccf058a802b9eb87b7e9fba0c3982cc6a03586b /pith | |
parent | 4bf825141cd564a2c5a23c55f79e04665c428641 (diff) | |
download | alpine-27b0c30862b56feccb120c896e1354b501681e2a.tar.xz |
* Protection against deleting new key and certificate when replacing key
that encrypts password file in case that the new key/certificate pairs
have the same name as the old key/certificate.
Diffstat (limited to 'pith')
-rw-r--r-- | pith/smime.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pith/smime.c b/pith/smime.c index d32a97c9..da3cd253 100644 --- a/pith/smime.c +++ b/pith/smime.c @@ -781,11 +781,15 @@ import_certificate(WhichCerts ctype) build_path(buf, PATHCERTDIR(ctype), pwdcert->name, sizeof(buf)); strncat(buf, EXTCERT(Private), 4); buf[sizeof(buf)-1] = '\0'; - if(unlink(buf) < 0) - q_status_message(SM_ORDER, 1, 3, _("Failed to remove old key")); + if(strcmp(PrivateKeyPath, buf)){ + if (unlink(buf) < 0) + q_status_message(SM_ORDER, 1, 3, _("Failed to remove old key")); + } build_path(buf, PATHCERTDIR(ctype), pwdcert->cname, sizeof(buf)); - if(unlink(buf) < 0) - q_status_message(SM_ORDER, 1, 3, _("Failed to remove old certificate")); + if(strcmp(PublicCertPath, buf)){ + if(unlink(buf) < 0) + q_status_message(SM_ORDER, 1, 3, _("Failed to remove old certificate")); + } free_personal_certs((PERSONAL_CERT **)&ps_global->pwdcert); ps_global->pwdcert = pc; rc = 1; |