comparison dbutil.c @ 73:0bf5cebe622c

Dropbearkey can now print out pubkey portions
author Matt Johnston <matt@ucc.asn.au>
date Sat, 14 Aug 2004 17:35:28 +0000
parents b0316ce64e4b
children c85c88500ea6
comparison
equal deleted inserted replaced
72:9597c2e3b9d4 73:0bf5cebe622c
54 #include "session.h" 54 #include "session.h"
55 #include "atomicio.h" 55 #include "atomicio.h"
56 56
57 #define MAX_FMT 100 57 #define MAX_FMT 100
58 58
59 void (*_dropbear_exit)(int exitcode, const char* format, va_list param) = NULL; 59 static void generic_dropbear_exit(int exitcode, const char* format,
60 void (*_dropbear_log)(int priority, const char* format, va_list param) = NULL; 60 va_list param);
61 static void generic_dropbear_log(int priority, const char* format,
62 va_list param);
63
64 void (*_dropbear_exit)(int exitcode, const char* format, va_list param)
65 = generic_dropbear_exit;
66 void (*_dropbear_log)(int priority, const char* format, va_list param)
67 = generic_dropbear_log;
61 68
62 int usingsyslog = 0; /* set by runopts, but required externally to sessions */ 69 int usingsyslog = 0; /* set by runopts, but required externally to sessions */
63 #ifndef DISABLE_SYSLOG 70 #ifndef DISABLE_SYSLOG
64 void startsyslog() { 71 void startsyslog() {
65 72
86 va_start(param, format); 93 va_start(param, format);
87 _dropbear_exit(EXIT_FAILURE, format, param); 94 _dropbear_exit(EXIT_FAILURE, format, param);
88 va_end(param); 95 va_end(param);
89 } 96 }
90 97
98 static void generic_dropbear_exit(int exitcode, const char* format,
99 va_list param) {
100
101 char fmtbuf[300];
102
103 snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s", format);
104
105 _dropbear_log(LOG_INFO, fmtbuf, param);
106
107 exit(exitcode);
108 }
109
110 static void generic_dropbear_log(int priority, const char* format,
111 va_list param) {
112
113 char printbuf[1024];
114
115 vsnprintf(printbuf, sizeof(printbuf), format, param);
116
117 fprintf(stderr, "%s\n", printbuf);
118
119 }
91 120
92 /* this is what can be called to write arbitrary log messages */ 121 /* this is what can be called to write arbitrary log messages */
93 void dropbear_log(int priority, const char* format, ...) { 122 void dropbear_log(int priority, const char* format, ...) {
94 123
95 va_list param; 124 va_list param;