diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2002-02-22 12:20:35 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2002-02-22 12:20:35 +0000 |
commit | 846fcce886d6668d7a51159fd7b44cb238dd4705 (patch) | |
tree | 7affb596fdd79686e833cb69b7840f5b9d8a1965 /usr.bin | |
parent | 4e54fca38d274840a968d4eea38aad8c0243e1d8 (diff) |
overwrite fatal() in ssh-keyscan.c; fixes pr 2354; ok provos@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/fatal.c | 40 | ||||
-rw-r--r-- | usr.bin/ssh/lib/Makefile | 6 | ||||
-rw-r--r-- | usr.bin/ssh/log.c | 17 | ||||
-rw-r--r-- | usr.bin/ssh/log.h | 4 | ||||
-rw-r--r-- | usr.bin/ssh/ssh-keyscan.c | 19 |
5 files changed, 60 insertions, 26 deletions
diff --git a/usr.bin/ssh/fatal.c b/usr.bin/ssh/fatal.c new file mode 100644 index 00000000000..9e7d1600073 --- /dev/null +++ b/usr.bin/ssh/fatal.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2002 Markus Friedl. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "includes.h" +RCSID("$OpenBSD: fatal.c,v 1.1 2002/02/22 12:20:34 markus Exp $"); + +#include "log.h" + +/* Fatal messages. This function never returns. */ + +void +fatal(const char *fmt,...) +{ + va_list args; + va_start(args, fmt); + do_log(SYSLOG_LEVEL_FATAL, fmt, args); + va_end(args); + fatal_cleanup(); +} diff --git a/usr.bin/ssh/lib/Makefile b/usr.bin/ssh/lib/Makefile index da489ea8e42..369cf90eac9 100644 --- a/usr.bin/ssh/lib/Makefile +++ b/usr.bin/ssh/lib/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.30 2002/01/25 22:04:10 mickey Exp $ +# $OpenBSD: Makefile,v 1.31 2002/02/22 12:20:34 markus Exp $ .PATH: ${.CURDIR}/.. LIB= ssh -SRCS= authfd.c authfile.c bufaux.c buffer.c canohost.c \ - channels.c cipher.c compat.c compress.c crc32.c deattack.c \ +SRCS= authfd.c authfile.c bufaux.c buffer.c canohost.c channels.c \ + cipher.c compat.c compress.c crc32.c deattack.c fatal.c \ hostfile.c log.c match.c mpaux.c nchan.c packet.c readpass.c \ rsa.c tildexpand.c ttymodes.c uidswap.c xmalloc.c atomicio.c \ key.c dispatch.c kex.c mac.c uuencode.c misc.c \ diff --git a/usr.bin/ssh/log.c b/usr.bin/ssh/log.c index 4b0f7a46eda..887045f2187 100644 --- a/usr.bin/ssh/log.c +++ b/usr.bin/ssh/log.c @@ -34,7 +34,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: log.c,v 1.21 2002/02/04 12:15:25 markus Exp $"); +RCSID("$OpenBSD: log.c,v 1.22 2002/02/22 12:20:34 markus Exp $"); #include "log.h" #include "xmalloc.h" @@ -85,8 +85,6 @@ static struct { { NULL, SYSLOG_LEVEL_NOT_SET } }; -static void do_log(LogLevel level, const char *fmt, va_list args); - SyslogFacility log_facility_number(char *name) { @@ -108,17 +106,6 @@ log_level_number(char *name) return log_levels[i].val; return SYSLOG_LEVEL_NOT_SET; } -/* Fatal messages. This function never returns. */ - -void -fatal(const char *fmt,...) -{ - va_list args; - va_start(args, fmt); - do_log(SYSLOG_LEVEL_FATAL, fmt, args); - va_end(args); - fatal_cleanup(); -} /* Error messages that should be logged. */ @@ -320,7 +307,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) #define MSGBUFSIZ 1024 -static void +void do_log(LogLevel level, const char *fmt, va_list args) { char msgbuf[MSGBUFSIZ]; diff --git a/usr.bin/ssh/log.h b/usr.bin/ssh/log.h index 208a6dde1f0..276ba05ea66 100644 --- a/usr.bin/ssh/log.h +++ b/usr.bin/ssh/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.5 2002/02/04 12:15:25 markus Exp $ */ +/* $OpenBSD: log.h,v 1.6 2002/02/22 12:20:34 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -60,4 +60,6 @@ void fatal_cleanup(void); void fatal_add_cleanup(void (*) (void *), void *); void fatal_remove_cleanup(void (*) (void *), void *); +void do_log(LogLevel, const char *, va_list); + #endif diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index d714feb94b7..95b556fc222 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -7,7 +7,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keyscan.c,v 1.33 2001/12/10 20:34:31 markus Exp $"); +RCSID("$OpenBSD: ssh-keyscan.c,v 1.34 2002/02/22 12:20:34 markus Exp $"); #include <sys/queue.h> #include <errno.h> @@ -636,11 +636,17 @@ do_host(char *host) } } -static void -fatal_callback(void *arg) +void +fatal(const char *fmt,...) { + va_list args; + va_start(args, fmt); + do_log(SYSLOG_LEVEL_FATAL, fmt, args); + va_end(args); if (nonfatal_fatal) longjmp(kexjmp, -1); + else + fatal_cleanup(); } static void @@ -653,9 +659,9 @@ usage(void) fprintf(stderr, " -p port Connect to the specified port.\n"); fprintf(stderr, " -t keytype Specify the host key type.\n"); fprintf(stderr, " -T timeout Set connection timeout.\n"); - fprintf(stderr, " -v Verbose; display verbose debugging messages.\n"); - fprintf(stderr, " -4 Use IPv4 only.\n"); - fprintf(stderr, " -6 Use IPv6 only.\n"); + fprintf(stderr, " -v Verbose; display verbose debugging messages.\n"); + fprintf(stderr, " -4 Use IPv4 only.\n"); + fprintf(stderr, " -6 Use IPv6 only.\n"); exit(1); } @@ -739,7 +745,6 @@ main(int argc, char **argv) usage(); log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1); - fatal_add_cleanup(fatal_callback, NULL); maxfd = fdlim_get(1); if (maxfd < 0) |