summaryrefslogtreecommitdiff
path: root/pith
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2016-10-05 19:05:24 -0600
committerEduardo Chappa <chappa@washington.edu>2016-10-05 19:05:24 -0600
commitb3cae4deb342505d445af54093c39b0d3a7a8f28 (patch)
tree0f31a8a673caa535792f433d8a92accebafe502f /pith
parent4f2c1e32cfe0ebcb628c5a55a52eef283aa39446 (diff)
downloadalpine-b3cae4deb342505d445af54093c39b0d3a7a8f28.tar.xz
* Add return codes to setup_pwdcert function, so that caller can know
what happened and decide accordingly. Fixes the fact that Alpine will fail to create self signed certificate, when the .pwd directory does not exist.
Diffstat (limited to 'pith')
-rw-r--r--pith/pine.hlp2
-rw-r--r--pith/smime.c16
2 files changed, 13 insertions, 5 deletions
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 0a8e2ef7..a4f67718 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 173 2016-10-05 01:10:48
+Alpine Commit 174 2016-10-05 19:05:20
============= h_news =================
<HTML>
<HEAD>
diff --git a/pith/smime.c b/pith/smime.c
index 9ee83340..d219ba03 100644
--- a/pith/smime.c
+++ b/pith/smime.c
@@ -203,9 +203,14 @@ load_key_and_cert(char *pathkeydir, char *pathcertdir, char **keyfile,
* Ok, that should do it.
*
* return values: 0 - everything is normal
- * 1 - User could not unlock key
+ * 1 - User could not unlock key or no key in directory.
* 2 - User cancelled to create self signed certificate
- * -1 - a not normal value.
+ * -1 - we do not know which directory to use
+ * -2 - "-pwdcertdir" was given by user, but directory does not exist
+ * -3 - "DF_PASSWORD_DIR" exists but it is not a directory!!??
+ * -4 - we tried to create DF_PASSWORD_DIR but failed.
+ * -5 - password directory exists, but it is empty
+ *
*/
int
setup_pwdcert(void **pwdcert)
@@ -233,19 +238,22 @@ setup_pwdcert(void **pwdcert)
strncpy(pathdir, ps_global->pwdcertdir, sizeof(pathdir));
pathdir[sizeof(pathdir)-1] = '\0';
}
+ else rv = -2;
} else {
smime_path(DF_PASSWORD_DIR, pathdir, sizeof(pathdir));
if(our_stat(pathdir, &sbuf) == 0){
if((sbuf.st_mode & S_IFMT) == S_IFDIR)
setup_dir++;
+ else rv = -3;
} else if(can_access(pathdir, ACCESS_EXISTS) != 0
&& our_mkpath(pathdir, 0700) == 0)
setup_dir++;
+ else rv = -4;
}
if(setup_dir == 0){
was_here = 0;
- return -1;
+ return rv;
}
if(load_key_and_cert(pathdir, pathdir, &keyfile, &certfile, &pkey, &pcert) < 0){
@@ -275,7 +283,7 @@ setup_pwdcert(void **pwdcert)
*/
if(setup_certdir){ /* if we are here, pwdcertdir failed */
was_here = 0;
- return -1;
+ return -5;
}
/* look to see if there are any certificates lying around, first