aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2006-09-28 18:53:22 +0000
committerRob Austein <sra@hactrn.net>2006-09-28 18:53:22 +0000
commitff50aad5076ed20b8ec87283fa5f9d128a4af812 (patch)
tree695e8489cf33bfefe12a3cda9666fb9282993a35
parent8fdbefa8a2d53b7a56c8707992ac2f83f630a84e (diff)
Add log_openssl_errors(). At the moment it's silent, which is good,
as it suggests that I'm not ignoring any errors we care about. May want to insert calls to this function in other places, eg, after each call to walk_cert() or at least after processing each trust anchor. svn path=/rcynic/rcynic.c; revision=339
-rw-r--r--rcynic/rcynic.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/rcynic/rcynic.c b/rcynic/rcynic.c
index 9ef543d9..09add560 100644
--- a/rcynic/rcynic.c
+++ b/rcynic/rcynic.c
@@ -69,7 +69,7 @@ typedef struct rcynic_ctx {
char *jane, *rsync, *authenticated, *old_authenticated, *unauthenticated;
STACK *rsync_cache;
int indent;
- int rsync_verbose, mkdir_verbose;
+ int rsync_verbose, mkdir_verbose, err_verbose;
} rcynic_ctx_t;
/*
@@ -111,6 +111,28 @@ static void logmsg(const rcynic_ctx_t *rc, const char *fmt, ...)
}
/*
+ * Print OpenSSL library errors.
+ */
+static void log_openssl_errors(const rcynic_ctx_t *rc)
+{
+ const char *data, *file;
+ unsigned long code;
+ char error[256];
+ int flags, line;
+
+ if (!rc->err_verbose)
+ return;
+
+ while ((code = ERR_get_error_line_data(&file, &line, &data, &flags))) {
+ ERR_error_string_n(code, error, sizeof(error));
+ if (data && (flags & ERR_TXT_STRING))
+ logmsg(rc, "OpenSSL error %s:%d: %s", file, line, error, data);
+ else
+ logmsg(rc, "OpenSSL error %s:%d", file, line, error);
+ }
+}
+
+/*
* Make a directory if it doesn't already exist.
*/
static int mkdir_maybe(const rcynic_ctx_t *rc, const char *name)
@@ -1067,6 +1089,9 @@ int main(int argc, char *argv[])
else if (!name_cmp(val->name, "mkdir-verbose"))
rc.mkdir_verbose = atoi(val->value);
+ else if (!name_cmp(val->name, "err-verbose"))
+ rc.err_verbose = atoi(val->value);
+
else if (!name_cmp(val->name, "rsync-program"))
rc.rsync = strdup(val->value);
}
@@ -1146,6 +1171,8 @@ int main(int argc, char *argv[])
ret = 0;
done:
+ log_openssl_errors(&rc);
+
/*
* Do NOT free cfg_section, NCONF_free() takes care of that
*/