summaryrefslogtreecommitdiff
path: root/ssh-pkcs11-helper.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-21 12:53:35 +0000
committerDamien Miller <djm@mindrot.org>2019-01-21 23:56:52 +1100
commitc7670b091a7174760d619ef6738b4f26b2093301 (patch)
tree2955001e5574431487f93bf70a9c2e6733bae619 /ssh-pkcs11-helper.c
parent49d8c8e214d39acf752903566b105d06c565442a (diff)
upstream: add "-v" flags to ssh-add and ssh-pkcs11-helper to turn up
debug verbosity. Make ssh-agent turn on ssh-pkcs11-helper's verbosity when it is run in debug mode ("ssh-agent -d"), so we get to see errors from the PKCS#11 code. ok markus@ OpenBSD-Commit-ID: 0a798643c6a92a508df6bd121253ba1c8bee659d
Diffstat (limited to 'ssh-pkcs11-helper.c')
-rw-r--r--ssh-pkcs11-helper.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/ssh-pkcs11-helper.c b/ssh-pkcs11-helper.c
index 92c6728ba..c7dfea279 100644
--- a/ssh-pkcs11-helper.c
+++ b/ssh-pkcs11-helper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11-helper.c,v 1.15 2019/01/20 22:51:37 djm Exp $ */ 1/* $OpenBSD: ssh-pkcs11-helper.c,v 1.16 2019/01/21 12:53:35 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * 4 *
@@ -307,11 +307,12 @@ cleanup_exit(int i)
307 _exit(i); 307 _exit(i);
308} 308}
309 309
310
310int 311int
311main(int argc, char **argv) 312main(int argc, char **argv)
312{ 313{
313 fd_set *rset, *wset; 314 fd_set *rset, *wset;
314 int r, in, out, max, log_stderr = 0; 315 int r, ch, in, out, max, log_stderr = 0;
315 ssize_t len, olen, set_size; 316 ssize_t len, olen, set_size;
316 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; 317 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
317 LogLevel log_level = SYSLOG_LEVEL_ERROR; 318 LogLevel log_level = SYSLOG_LEVEL_ERROR;
@@ -320,14 +321,31 @@ main(int argc, char **argv)
320 extern char *__progname; 321 extern char *__progname;
321 322
322 ssh_malloc_init(); /* must be called before any mallocs */ 323 ssh_malloc_init(); /* must be called before any mallocs */
324 __progname = ssh_get_progname(argv[0]);
325 seed_rng();
323 TAILQ_INIT(&pkcs11_keylist); 326 TAILQ_INIT(&pkcs11_keylist);
324 pkcs11_init(0);
325 327
326 seed_rng(); 328 log_init(__progname, log_level, log_facility, log_stderr);
327 __progname = ssh_get_progname(argv[0]); 329
330 while ((ch = getopt(argc, argv, "v")) != -1) {
331 switch (ch) {
332 case 'v':
333 log_stderr = 1;
334 if (log_level == SYSLOG_LEVEL_ERROR)
335 log_level = SYSLOG_LEVEL_DEBUG1;
336 else if (log_level < SYSLOG_LEVEL_DEBUG3)
337 log_level++;
338 break;
339 default:
340 fprintf(stderr, "usage: %s [-v]\n", __progname);
341 exit(1);
342 }
343 }
328 344
329 log_init(__progname, log_level, log_facility, log_stderr); 345 log_init(__progname, log_level, log_facility, log_stderr);
330 346
347 pkcs11_init(0);
348
331 in = STDIN_FILENO; 349 in = STDIN_FILENO;
332 out = STDOUT_FILENO; 350 out = STDOUT_FILENO;
333 351