diff options
author | Eduardo Chappa <chappa@washington.edu> | 2016-10-05 19:05:24 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2016-10-05 19:05:24 -0600 |
commit | b3cae4deb342505d445af54093c39b0d3a7a8f28 (patch) | |
tree | 0f31a8a673caa535792f433d8a92accebafe502f /pith/smime.c | |
parent | 4f2c1e32cfe0ebcb628c5a55a52eef283aa39446 (diff) | |
download | alpine-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/smime.c')
-rw-r--r-- | pith/smime.c | 16 |
1 files changed, 12 insertions, 4 deletions
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 |