diff options
| -rw-r--r-- | crypto/openssh/COPYING.Ylonen | 70 | ||||
| -rw-r--r-- | crypto/openssh/README.openssh2 | 44 | ||||
| -rw-r--r-- | crypto/openssh/auth2-pam.c | 334 | ||||
| -rw-r--r-- | crypto/openssh/auth2-skey.c | 104 | ||||
| -rw-r--r-- | crypto/openssh/aux.c | 36 | ||||
| -rw-r--r-- | crypto/openssh/cli.c | 231 | ||||
| -rw-r--r-- | crypto/openssh/cli.h | 42 | ||||
| -rw-r--r-- | crypto/openssh/dsa.c | 304 | ||||
| -rw-r--r-- | crypto/openssh/dsa.h | 45 | ||||
| -rw-r--r-- | crypto/openssh/fingerprint.c | 69 | ||||
| -rw-r--r-- | crypto/openssh/fingerprint.h | 34 | ||||
| -rw-r--r-- | crypto/openssh/hmac.c | 54 | ||||
| -rw-r--r-- | crypto/openssh/hmac.h | 34 | ||||
| -rw-r--r-- | crypto/openssh/log-client.c | 84 | ||||
| -rw-r--r-- | crypto/openssh/log-server.c | 173 | ||||
| -rw-r--r-- | crypto/openssh/login.c | 145 | ||||
| -rw-r--r-- | crypto/openssh/nchan.h | 91 | ||||
| -rw-r--r-- | crypto/openssh/pty.c | 275 | ||||
| -rw-r--r-- | crypto/openssh/pty.h | 47 | ||||
| -rw-r--r-- | crypto/openssh/scp-common.c | 98 | ||||
| -rw-r--r-- | crypto/openssh/scp-common.h | 64 | ||||
| -rw-r--r-- | crypto/openssh/util.c | 96 | 
22 files changed, 0 insertions, 2474 deletions
diff --git a/crypto/openssh/COPYING.Ylonen b/crypto/openssh/COPYING.Ylonen deleted file mode 100644 index 5e681edd29308..0000000000000 --- a/crypto/openssh/COPYING.Ylonen +++ /dev/null @@ -1,70 +0,0 @@ -This file is part of the ssh software, Copyright (c) 1995 Tatu Ylonen, Finland - - -COPYING POLICY AND OTHER LEGAL ISSUES - -As far as I am concerned, the code I have written for this software -can be used freely for any purpose.  Any derived versions of this -software must be clearly marked as such, and if the derived work is -incompatible with the protocol description in the RFC file, it must be -called by a name other than "ssh" or "Secure Shell". - -However, I am not implying to give any licenses to any patents or -copyrights held by third parties, and the software includes parts that -are not under my direct control.  As far as I know, all included -source code is used in accordance with the relevant license agreements -and can be used freely for any purpose (the GNU license being the most -restrictive); see below for details. - -[ RSA is no longer included. ] -[ IDEA is no longer included. ] -[ DES is now external. ] -[ GMP is now external. No more GNU licence. ] -[ Zlib is now external. ] -[ The make-ssh-known-hosts script is no longer included. ] -[ TSS has been removed. ] -[ MD5 is now external. ] -[ RC4 support has been removed. ] -[ Blowfish is now external. ] - -The 32-bit CRC implementation in crc32.c is due to Gary S. Brown. -Comments in the file indicate it may be used for any purpose without -restrictions. - -The 32-bit CRC compensation attack detector in deattack.c was -contributed by CORE SDI S.A. under a BSD-style license. See -http://www.core-sdi.com/english/ssh/ for details. - -Note that any information and cryptographic algorithms used in this -software are publicly available on the Internet and at any major -bookstore, scientific library, and patent office worldwide.  More -information can be found e.g. at "http://www.cs.hut.fi/crypto". - -The legal status of this program is some combination of all these -permissions and restrictions.  Use only at your own responsibility. -You will be responsible for any legal consequences yourself; I am not -making any claims whether possessing or using this is legal or not in -your country, and I am not taking any responsibility on your behalf. - - -			    NO WARRANTY - -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. diff --git a/crypto/openssh/README.openssh2 b/crypto/openssh/README.openssh2 deleted file mode 100644 index 12c90aa316907..0000000000000 --- a/crypto/openssh/README.openssh2 +++ /dev/null @@ -1,44 +0,0 @@ -$Id: README.openssh2,v 1.8 2000/05/07 18:30:03 markus Exp $ - -howto: -	1) generate server key: -		$ ssh-keygen -d -f /etc/ssh_host_dsa_key -N '' -	2) enable ssh2: -		server: add 'Protocol 2,1' to /etc/sshd_config -		client: ssh -o 'Protocol 2,1', or add to .ssh/config -	3) DSA authentication similar to RSA (add keys to ~/.ssh/authorized_keys2) -	   interop w/ ssh.com dsa-keys: -		ssh-keygen -f /key/from/ssh.com -X >> ~/.ssh/authorized_keys2 -	   and vice versa -		ssh-keygen -f /privatekey/from/openssh -x > ~/.ssh2/mykey.pub -		echo Key mykey.pub >> ~/.ssh2/authorization - -works: -	secsh-transport: works w/o rekey -		proposal exchange, i.e. different enc/mac/comp per direction -		encryption: blowfish-cbc, 3des-cbc, arcfour, cast128-cbc -		mac: hmac-md5, hmac-sha1, (hmac-ripemd160) -		compression: zlib, none -	secsh-userauth: passwd and pubkey with DSA -	secsh-connection: pty+shell or command, flow control works (window adjust) -		tcp-forwarding: -L works, -R incomplete -		x11-fwd -	dss/dsa: host key database in ~/.ssh/known_hosts2 -	client interops w/ sshd2, lshd -	server interops w/ ssh2, lsh, ssh.com's Windows client, SecureCRT, F-Secure SSH Client 4.0, SecureFX (secure ftp) -	server supports multiple concurrent sessions (e.g. with SSH.com Windows client) -todo: -	re-keying -	secsh-connection features: -		 tcp-forwarding, agent-fwd -	auth other than passwd, and DSA-pubkey: -		 keyboard-interactive, (PGP-pubkey?) -	config -	server-auth w/ old host-keys -	cleanup -	advanced key storage? -	keynote -	sftp - --markus -$Date: 2000/05/07 18:30:03 $ diff --git a/crypto/openssh/auth2-pam.c b/crypto/openssh/auth2-pam.c deleted file mode 100644 index 7a238562c857d..0000000000000 --- a/crypto/openssh/auth2-pam.c +++ /dev/null @@ -1,334 +0,0 @@ -/*- - * Copyright (c) 2002 Networks Associates Technology, Inc. - * All rights reserved. - * - * This software was developed for the FreeBSD Project by ThinkSec AS and - * NAI Labs, the Security Research Division of Network Associates, Inc. - * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the - * DARPA CHATS research program. - * - * 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. - * 3. The name of the author may not be used to endorse or promote - *    products derived from this software without specific prior written - *    permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - * - * $FreeBSD$ - */ - -#ifdef USE_PAM -#include "includes.h" -RCSID("$FreeBSD$"); - -#include <security/pam_appl.h> - -#include "auth.h" -#include "xmalloc.h" - -struct pam_ctxt { -	char		*pam_user; -	pid_t		 pam_pid; -	int		 pam_sock; -	int		 pam_done; -}; - -static void pam_free_ctx(void *); - -/* - * Send message to parent or child. - */ -static int -pam_send(struct pam_ctxt *ctxt, char *fmt, ...) -{ -	va_list ap; -	char *mstr; -	size_t len; -	int r; - -	va_start(ap, fmt); -	len = vasprintf(&mstr, fmt, ap); -	va_end(ap); -	if (mstr == NULL) -		exit(1); -	if (ctxt->pam_pid != 0) -		debug2("to child: %s", mstr); -	r = send(ctxt->pam_sock, mstr, len + 1, MSG_EOR); -	free(mstr); -	return (r); -} - -/* - * Peek at first byte of next message. - */ -static int -pam_peek(struct pam_ctxt *ctxt) -{ -	char ch; - -	if (recv(ctxt->pam_sock, &ch, 1, MSG_PEEK) < 1) -		return (-1); -	return (ch); -} - -/* - * Receive a message from parent or child. - */ -static char * -pam_receive(struct pam_ctxt *ctxt) -{ -	char *buf; -	size_t len; -	ssize_t rlen; - -	len = 64; -	buf = NULL; -	do { -		len *= 2; -		buf = xrealloc(buf, len); -		rlen = recv(ctxt->pam_sock, buf, len, MSG_PEEK); -		if (rlen < 1) { -			xfree(buf); -			return (NULL); -		} -	} while (rlen == len); -	if (recv(ctxt->pam_sock, buf, len, 0) != rlen) { -		xfree(buf); -		return (NULL); -	} -	if (ctxt->pam_pid != 0) -		debug2("from child: %s", buf); -	return (buf); -} - -/* - * Conversation function for child process. - */ -static int -pam_child_conv(int n, -	 const struct pam_message **msg, -	 struct pam_response **resp, -	 void *data) -{ -	struct pam_ctxt *ctxt; -	char *line; -	size_t len; -	int i; - -	ctxt = data; -	if (n <= 0 || n > PAM_MAX_NUM_MSG) -		return (PAM_CONV_ERR); -	if ((*resp = calloc(n, sizeof **resp)) == NULL) -		return (PAM_BUF_ERR); -	for (i = 0; i < n; ++i) { -		resp[i]->resp_retcode = 0; -		resp[i]->resp = NULL; -		switch (msg[i]->msg_style) { -		case PAM_PROMPT_ECHO_OFF: -			pam_send(ctxt, "p%s", msg[i]->msg); -			resp[i]->resp = pam_receive(ctxt); -			break; -		case PAM_PROMPT_ECHO_ON: -			pam_send(ctxt, "P%s", msg[i]->msg); -			resp[i]->resp = pam_receive(ctxt); -			break; -		case PAM_ERROR_MSG: -			/*pam_send(ctxt, "e%s", msg[i]->msg);*/ -			break; -		case PAM_TEXT_INFO: -			/*pam_send(ctxt, "i%s", msg[i]->msg);*/ -			break; -		default: -			goto fail; -		} -	} -	return (PAM_SUCCESS); - fail: -	while (i) -		free(resp[--i]); -	free(*resp); -	*resp = NULL; -	return (PAM_CONV_ERR); -} - -/* - * Child process. - */ -static void * -pam_child(struct pam_ctxt *ctxt) -{ -	struct pam_conv pam_conv = { pam_child_conv, ctxt }; -	pam_handle_t *pamh; -	char *msg; -	int pam_err; - -	pam_err = pam_start("sshd", ctxt->pam_user, &pam_conv, &pamh); -	if (pam_err != PAM_SUCCESS) -		goto auth_fail; -	pam_err = pam_authenticate(pamh, 0); -	if (pam_err != PAM_SUCCESS) -		goto auth_fail; -	pam_send(ctxt, "=OK"); -	pam_end(pamh, pam_err); -	exit(0); - auth_fail: -	pam_send(ctxt, "!%s", pam_strerror(pamh, pam_err)); -	pam_end(pamh, pam_err); -	exit(0); -} - -static void * -pam_init_ctx(Authctxt *authctxt) -{ -	struct pam_ctxt *ctxt; -	int socks[2]; -	int i; - -	ctxt = xmalloc(sizeof *ctxt); -	ctxt->pam_user = xstrdup(authctxt->user); -	ctxt->pam_done = 0; -	if (socketpair(AF_UNIX, SOCK_DGRAM, PF_UNSPEC, socks) == -1) { -		error("%s: failed create sockets: %s", -		    __func__, strerror(errno)); -		xfree(ctxt); -		return (NULL); -	} -	if ((ctxt->pam_pid = fork()) == -1) { -		error("%s: failed to fork auth-pam child: %s", -		    __func__, strerror(errno)); -		close(socks[0]); -		close(socks[1]); -		xfree(ctxt); -		return (NULL); -	} -	if (ctxt->pam_pid == 0) { -		/* close everything except our end of the pipe */ -		ctxt->pam_sock = socks[1]; -		for (i = 0; i < getdtablesize(); ++i) -			if (i != ctxt->pam_sock) -				close(i); -		pam_child(ctxt); -		/* not reached */ -		exit(1); -	} -	ctxt->pam_sock = socks[0]; -	close(socks[1]); -	return (ctxt); -} - -static int -pam_query(void *ctx, char **name, char **info, -    u_int *num, char ***prompts, u_int **echo_on) -{ -	struct pam_ctxt *ctxt = ctx; -	char *msg; - -	if ((msg = pam_receive(ctxt)) == NULL) -		return (-1); -	*name = xstrdup(""); -	*info = xstrdup(""); -	*prompts = xmalloc(sizeof(char *)); -	*echo_on = xmalloc(sizeof(u_int)); -	switch (*msg) { -	case 'P': -		**echo_on = 1; -	case 'p': -		*num = 1; -		**prompts = xstrdup(msg + 1); -		**echo_on = (*msg == 'P'); -		break; -	case '=': -		*num = 0; -		**echo_on = 0; -		ctxt->pam_done = 1; -		break; -	case '!': -		error("%s", msg + 1); -	default: -		*num = 0; -		**echo_on = 0; -		xfree(msg); -		ctxt->pam_done = -1; -		return (-1); -	} -	xfree(msg); -	return (0); -} - -static int -pam_respond(void *ctx, u_int num, char **resp) -{ -	struct pam_ctxt *ctxt = ctx; -	char *msg; - -	debug2(__func__); -	switch (ctxt->pam_done) { -	case 1: -		return (0);	 -	case 0: -		break; -	default: -		return (-1); -	} -	if (num != 1) { -		error("expected one response, got %u", num); -		return (-1); -	} -	pam_send(ctxt, "%s", *resp); -	switch (pam_peek(ctxt)) { -	case 'P': -	case 'p': -		return (1); -	case '=': -		msg = pam_receive(ctxt); -		xfree(msg); -		ctxt->pam_done = 1; -		return (0); -	default: -		msg = pam_receive(ctxt); -		if (*msg == '!') -			error("%s", msg + 1); -		xfree(msg); -		ctxt->pam_done = -1; -		return (-1); -	} -} - -static void -pam_free_ctx(void *ctxtp) -{ -	struct pam_ctxt *ctxt = ctxtp; -	int i; - -	close(ctxt->pam_sock); -	kill(ctxt->pam_pid, SIGHUP); -	xfree(ctxt->pam_user); -	xfree(ctxt); -} - -KbdintDevice pam_device = { -	"pam", -	pam_init_ctx, -	pam_query, -	pam_respond, -	pam_free_ctx -}; - -#endif /* USE_PAM */ diff --git a/crypto/openssh/auth2-skey.c b/crypto/openssh/auth2-skey.c deleted file mode 100644 index 9de08fc09cfd8..0000000000000 --- a/crypto/openssh/auth2-skey.c +++ /dev/null @@ -1,104 +0,0 @@ -#include "includes.h" -RCSID("$OpenBSD: auth2-skey.c,v 1.1 2000/10/11 20:14:38 markus Exp $"); - -#include "ssh.h" -#include "ssh2.h" -#include "auth.h" -#include "packet.h" -#include "xmalloc.h" -#include "dispatch.h" - -void	send_userauth_into_request(Authctxt *authctxt, int echo); -void	input_userauth_info_response(int type, int plen, void *ctxt); - -/* - * try skey authentication, always return -1 (= postponed) since we have to - * wait for the s/key response. - */ -int -auth2_skey(Authctxt *authctxt) -{ -	send_userauth_into_request(authctxt, 0); -	dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, &input_userauth_info_response); -	return -1; -} - -void -send_userauth_into_request(Authctxt *authctxt, int echo) -{ -	int retval = -1; -	struct skey skey; -	char challenge[SKEY_MAX_CHALLENGE]; -	char *fake; - -	if (authctxt->user == NULL) -		fatal("send_userauth_into_request: internal error: no user"); - -	/* get skey challenge */ -	if (authctxt->valid) -		retval = skeychallenge(&skey, authctxt->user, challenge); - -	if (retval == -1) { -		fake = skey_fake_keyinfo(authctxt->user); -		strlcpy(challenge, fake, sizeof challenge); -	} -	/* send our info request */ -	packet_start(SSH2_MSG_USERAUTH_INFO_REQUEST); -	packet_put_cstring("S/Key Authentication");	/* Name */ -	packet_put_cstring(challenge);			/* Instruction */ -	packet_put_cstring("");				/* Language */ -	packet_put_int(1);			 	/* Number of prompts */ -	packet_put_cstring(echo ? -		 "Response [Echo]: ": "Response: ");	/* Prompt */ -	packet_put_char(echo);				/* Echo */ -	packet_send(); -	packet_write_wait(); -	memset(challenge, 'c', sizeof challenge); -} - -void -input_userauth_info_response(int type, int plen, void *ctxt) -{ -	Authctxt *authctxt = ctxt; -	int authenticated = 0; -	unsigned int nresp, rlen; -	char *resp, *method; - -	if (authctxt == NULL) -		fatal("input_userauth_info_response: no authentication context"); - -	if (authctxt->attempt++ >= AUTH_FAIL_MAX) -		packet_disconnect("too many failed userauth_requests"); - -	nresp = packet_get_int(); -	if (nresp == 1) { -		/* we only support s/key and assume s/key for nresp == 1 */ -		method = "s/key"; -		resp = packet_get_string(&rlen); -		packet_done(); -		if (strlen(resp) == 0) { -			/* -			 * if we received a null response, resend prompt with -			 * echo enabled -			 */ -			authenticated = -1; -			userauth_log(authctxt, authenticated, method); -			send_userauth_into_request(authctxt, 1); -		} else { -			/* verify skey response */ -			if (authctxt->valid && -			    skey_haskey(authctxt->pw->pw_name) == 0 && -			    skey_passcheck(authctxt->pw->pw_name, resp) != -1) { -				authenticated = 1; -			} else { -				authenticated = 0; -			} -			memset(resp, 'r', rlen); -			/* unregister callback */ -			dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); -			userauth_log(authctxt, authenticated, method); -			userauth_reply(authctxt, authenticated); -		} -		xfree(resp); -	} -} diff --git a/crypto/openssh/aux.c b/crypto/openssh/aux.c deleted file mode 100644 index 899142da71671..0000000000000 --- a/crypto/openssh/aux.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "includes.h" -RCSID("$OpenBSD: aux.c,v 1.2 2000/05/17 09:47:59 markus Exp $"); - -#include "ssh.h" - -char * -chop(char *s) -{ -	char *t = s; -	while (*t) { -		if(*t == '\n' || *t == '\r') { -			*t = '\0'; -			return s; -		} -		t++; -	} -	return s; - -} - -void -set_nonblock(int fd) -{ -	int val; -	val = fcntl(fd, F_GETFL, 0); -	if (val < 0) { -		error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); -		return; -	} -	if (val & O_NONBLOCK) -		return; -	debug("fd %d setting O_NONBLOCK", fd); -	val |= O_NONBLOCK; -	if (fcntl(fd, F_SETFL, val) == -1) -		error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd, strerror(errno)); -} diff --git a/crypto/openssh/cli.c b/crypto/openssh/cli.c deleted file mode 100644 index 8f0b2b87e36c2..0000000000000 --- a/crypto/openssh/cli.c +++ /dev/null @@ -1,231 +0,0 @@ -/*	$OpenBSD: cli.c,v 1.11 2001/03/06 00:33:04 deraadt Exp $	*/ - -/* - * Copyright (c) 2000 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: cli.c,v 1.11 2001/03/06 00:33:04 deraadt Exp $"); - -#include "xmalloc.h" -#include "log.h" -#include "cli.h" - -#include <vis.h> - -static int cli_input = -1; -static int cli_output = -1; -static int cli_from_stdin = 0; - -sigset_t oset; -sigset_t nset; -struct sigaction nsa; -struct sigaction osa; -struct termios ntio; -struct termios otio; -int echo_modified; - -volatile int intr; - -static int -cli_open(int from_stdin) -{ -	if (cli_input >= 0 && cli_output >= 0 && cli_from_stdin == from_stdin) -		return 1; - -	if (from_stdin) { -		if (!cli_from_stdin && cli_input >= 0) { -			(void)close(cli_input); -		} -		cli_input = STDIN_FILENO; -		cli_output = STDERR_FILENO; -	} else { -		cli_input = cli_output = open(_PATH_TTY, O_RDWR); -		if (cli_input < 0) -			fatal("You have no controlling tty.  Cannot read passphrase."); -	} - -	cli_from_stdin = from_stdin; - -	return cli_input >= 0 && cli_output >= 0 && cli_from_stdin == from_stdin; -} - -static void -cli_close(void) -{ -	if (!cli_from_stdin && cli_input >= 0) -		close(cli_input); -	cli_input = -1; -	cli_output = -1; -	cli_from_stdin = 0; -	return; -} - -void -intrcatch(int sig) -{ -	intr = 1; -} - -static void -cli_echo_disable(void) -{ -	sigemptyset(&nset); -	sigaddset(&nset, SIGTSTP); -	(void) sigprocmask(SIG_BLOCK, &nset, &oset); - -	intr = 0; - -	memset(&nsa, 0, sizeof(nsa)); -	nsa.sa_handler = intrcatch; -	(void) sigaction(SIGINT, &nsa, &osa); - -	echo_modified = 0; -	if (tcgetattr(cli_input, &otio) == 0 && (otio.c_lflag & ECHO)) { -		echo_modified = 1; -		ntio = otio; -		ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); -		(void) tcsetattr(cli_input, TCSANOW, &ntio); -	} -	return; -} - -static void -cli_echo_restore(void) -{ -	if (echo_modified != 0) { -		tcsetattr(cli_input, TCSANOW, &otio); -		echo_modified = 0; -	} - -	(void) sigprocmask(SIG_SETMASK, &oset, NULL); -	(void) sigaction(SIGINT, &osa, NULL); - -	if (intr != 0) { -		kill(getpid(), SIGINT); -		sigemptyset(&nset); -		/* XXX tty has not neccessarily drained by now? */ -		sigsuspend(&nset); -		intr = 0; -	} -	return; -} - -static int -cli_read(char* buf, int size, int echo) -{ -	char ch = 0; -	int i = 0; -	int n; - -	if (!echo) -		cli_echo_disable(); - -	while (ch != '\n') { -		n = read(cli_input, &ch, 1); -		if (n == -1 && (errno == EAGAIN || errno == EINTR)) -			continue; -		if (n != 1) -			break; -		if (ch == '\n' || intr != 0) -			break; -		if (i < size) -			buf[i++] = ch; -	} -	buf[i] = '\0'; - -	if (!echo) -		cli_echo_restore(); -	if (!intr && !echo) -		(void) write(cli_output, "\n", 1); -	return i; -} - -static int -cli_write(char* buf, int size) -{ -	int i, len, pos, ret = 0; -	char *output, *p; - -	output = xmalloc(4*size); -	for (p = output, i = 0; i < size; i++) { -		if (buf[i] == '\n' || buf[i] == '\r') -			*p++ = buf[i]; -		else -			p = vis(p, buf[i], 0, 0); -	} -	len = p - output; - -	for (pos = 0; pos < len; pos += ret) { -		ret = write(cli_output, output + pos, len - pos); -		if (ret == -1) { -			xfree(output); -			return -1; -		} -	} -	xfree(output); -	return 0; -} - -/* - * Presents a prompt and returns the response allocated with xmalloc(). - * Uses /dev/tty or stdin/out depending on arg.  Optionally disables echo - * of response depending on arg.  Tries to ensure that no other userland - * buffer is storing the response. - */ -char* -cli_read_passphrase(char* prompt, int from_stdin, int echo_enable) -{ -	char	buf[BUFSIZ]; -	char*	p; - -	if (!cli_open(from_stdin)) -		fatal("Cannot read passphrase."); - -	fflush(stdout); - -	cli_write(prompt, strlen(prompt)); -	cli_read(buf, sizeof buf, echo_enable); - -	cli_close(); - -	p = xstrdup(buf); -	memset(buf, 0, sizeof(buf)); -	return (p); -} - -char* -cli_prompt(char* prompt, int echo_enable) -{ -	return cli_read_passphrase(prompt, 0, echo_enable); -} - -void -cli_mesg(char* mesg) -{ -	cli_open(0); -	cli_write(mesg, strlen(mesg)); -	cli_write("\n", strlen("\n")); -	cli_close(); -	return; -} diff --git a/crypto/openssh/cli.h b/crypto/openssh/cli.h deleted file mode 100644 index 6f57c9b8ad0ac..0000000000000 --- a/crypto/openssh/cli.h +++ /dev/null @@ -1,42 +0,0 @@ -/*	$OpenBSD: cli.h,v 1.4 2001/03/01 03:38:33 deraadt Exp $	*/ - -/* - * Copyright (c) 2000 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. - */ - -/* $OpenBSD: cli.h,v 1.4 2001/03/01 03:38:33 deraadt Exp $ */ - -#ifndef CLI_H -#define CLI_H - -/* - * Presents a prompt and returns the response allocated with xmalloc(). - * Uses /dev/tty or stdin/out depending on arg.  Optionally disables echo - * of response depending on arg.  Tries to ensure that no other userland - * buffer is storing the response. - */ -char *	cli_read_passphrase(char * prompt, int from_stdin, int echo_enable); -char *	cli_prompt(char * prompt, int echo_enable); -void	cli_mesg(char * mesg); - -#endif /* CLI_H */ diff --git a/crypto/openssh/dsa.c b/crypto/openssh/dsa.c deleted file mode 100644 index 4ff4b58f2b491..0000000000000 --- a/crypto/openssh/dsa.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 2000 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: dsa.c,v 1.11 2000/09/07 20:27:51 deraadt Exp $"); - -#include "ssh.h" -#include "xmalloc.h" -#include "buffer.h" -#include "bufaux.h" -#include "compat.h" - -#include <openssl/bn.h> -#include <openssl/dh.h> -#include <openssl/rsa.h> -#include <openssl/dsa.h> -#include <openssl/evp.h> -#include <openssl/bio.h> -#include <openssl/pem.h> - -#include <openssl/hmac.h> -#include "kex.h" -#include "key.h" -#include "uuencode.h" - -#define INTBLOB_LEN	20 -#define SIGBLOB_LEN	(2*INTBLOB_LEN) - -Key * -dsa_key_from_blob(char *blob, int blen) -{ -	Buffer b; -	char *ktype; -	int rlen; -	DSA *dsa; -	Key *key; - -#ifdef DEBUG_DSS -	dump_base64(stderr, blob, blen); -#endif -	/* fetch & parse DSA/DSS pubkey */ -	buffer_init(&b); -	buffer_append(&b, blob, blen); -	ktype = buffer_get_string(&b, NULL); -	if (strcmp(KEX_DSS, ktype) != 0) { -		error("dsa_key_from_blob: cannot handle type %s", ktype); -		buffer_free(&b); -		xfree(ktype); -		return NULL; -	} -	key = key_new(KEY_DSA); -	dsa = key->dsa; -	buffer_get_bignum2(&b, dsa->p); -	buffer_get_bignum2(&b, dsa->q); -	buffer_get_bignum2(&b, dsa->g); -	buffer_get_bignum2(&b, dsa->pub_key); -	rlen = buffer_len(&b); -	if(rlen != 0) -		error("dsa_key_from_blob: remaining bytes in key blob %d", rlen); -	buffer_free(&b); -	xfree(ktype); - -#ifdef DEBUG_DSS -	DSA_print_fp(stderr, dsa, 8); -#endif -	return key; -} -int -dsa_make_key_blob(Key *key, unsigned char **blobp, unsigned int *lenp) -{ -	Buffer b; -	int len; -	unsigned char *buf; - -	if (key == NULL || key->type != KEY_DSA) -		return 0; -	buffer_init(&b); -	buffer_put_cstring(&b, KEX_DSS); -	buffer_put_bignum2(&b, key->dsa->p); -	buffer_put_bignum2(&b, key->dsa->q); -	buffer_put_bignum2(&b, key->dsa->g); -	buffer_put_bignum2(&b, key->dsa->pub_key); -	len = buffer_len(&b); -	buf = xmalloc(len); -	memcpy(buf, buffer_ptr(&b), len); -	memset(buffer_ptr(&b), 0, len); -	buffer_free(&b); -	if (lenp != NULL) -		*lenp = len; -	if (blobp != NULL) -		*blobp = buf; -	return len; -} -int -dsa_sign( -    Key *key, -    unsigned char **sigp, int *lenp, -    unsigned char *data, int datalen) -{ -	unsigned char *digest; -	unsigned char *ret; -	DSA_SIG *sig; -	EVP_MD *evp_md = EVP_sha1(); -	EVP_MD_CTX md; -	unsigned int rlen; -	unsigned int slen; -	unsigned int len; -	unsigned char sigblob[SIGBLOB_LEN]; -	Buffer b; - -	if (key == NULL || key->type != KEY_DSA || key->dsa == NULL) { -		error("dsa_sign: no DSA key"); -		return -1; -	} -	digest = xmalloc(evp_md->md_size); -	EVP_DigestInit(&md, evp_md); -	EVP_DigestUpdate(&md, data, datalen); -	EVP_DigestFinal(&md, digest, NULL); - -	sig = DSA_do_sign(digest, evp_md->md_size, key->dsa); -	if (sig == NULL) { -		fatal("dsa_sign: cannot sign"); -	} - -	rlen = BN_num_bytes(sig->r); -	slen = BN_num_bytes(sig->s); -	if (rlen > INTBLOB_LEN || slen > INTBLOB_LEN) { -		error("bad sig size %d %d", rlen, slen); -		DSA_SIG_free(sig); -		return -1; -	} -	debug("sig size %d %d", rlen, slen); - -	memset(sigblob, 0, SIGBLOB_LEN); -	BN_bn2bin(sig->r, sigblob+ SIGBLOB_LEN - INTBLOB_LEN - rlen); -	BN_bn2bin(sig->s, sigblob+ SIGBLOB_LEN - slen); -	DSA_SIG_free(sig); - -	if (datafellows & SSH_BUG_SIGBLOB) { -		debug("datafellows"); -		ret = xmalloc(SIGBLOB_LEN); -		memcpy(ret, sigblob, SIGBLOB_LEN); -		if (lenp != NULL) -			*lenp = SIGBLOB_LEN; -		if (sigp != NULL) -			*sigp = ret; -	} else { -		/* ietf-drafts */ -		buffer_init(&b); -		buffer_put_cstring(&b, KEX_DSS); -		buffer_put_string(&b, sigblob, SIGBLOB_LEN); -		len = buffer_len(&b); -		ret = xmalloc(len); -		memcpy(ret, buffer_ptr(&b), len); -		buffer_free(&b); -		if (lenp != NULL) -			*lenp = len; -		if (sigp != NULL) -			*sigp = ret; -	} -	return 0; -} -int -dsa_verify( -    Key *key, -    unsigned char *signature, int signaturelen, -    unsigned char *data, int datalen) -{ -	Buffer b; -	unsigned char *digest; -	DSA_SIG *sig; -	EVP_MD *evp_md = EVP_sha1(); -	EVP_MD_CTX md; -	unsigned char *sigblob; -	char *txt; -	unsigned int len; -	int rlen; -	int ret; - -	if (key == NULL || key->type != KEY_DSA || key->dsa == NULL) { -		error("dsa_verify: no DSA key"); -		return -1; -	} - -	if (!(datafellows & SSH_BUG_SIGBLOB) && -	    signaturelen == SIGBLOB_LEN) { -		datafellows |= ~SSH_BUG_SIGBLOB; -		log("autodetect SSH_BUG_SIGBLOB"); -	} else if ((datafellows & SSH_BUG_SIGBLOB) && -	    signaturelen != SIGBLOB_LEN) { -		log("autoremove SSH_BUG_SIGBLOB"); -		datafellows &= ~SSH_BUG_SIGBLOB; -	} - -	debug("len %d datafellows %d", signaturelen, datafellows); - -	/* fetch signature */ -	if (datafellows & SSH_BUG_SIGBLOB) { -		sigblob = signature; -		len = signaturelen; -	} else { -		/* ietf-drafts */ -		char *ktype; -		buffer_init(&b); -		buffer_append(&b, (char *) signature, signaturelen); -		ktype = buffer_get_string(&b, NULL); -		if (strcmp(KEX_DSS, ktype) != 0) { -			error("dsa_verify: cannot handle type %s", ktype); -			buffer_free(&b); -			return -1; -		} -		sigblob = (unsigned char *)buffer_get_string(&b, &len); -		rlen = buffer_len(&b); -		if(rlen != 0) { -			error("remaining bytes in signature %d", rlen); -			buffer_free(&b); -			return -1; -		} -		buffer_free(&b); -		xfree(ktype); -	} - -	if (len != SIGBLOB_LEN) { -		fatal("bad sigbloblen %d != SIGBLOB_LEN", len); -	} - -	/* parse signature */ -	sig = DSA_SIG_new(); -	sig->r = BN_new(); -	sig->s = BN_new(); -	BN_bin2bn(sigblob, INTBLOB_LEN, sig->r); -	BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s); - -	if (!(datafellows & SSH_BUG_SIGBLOB)) { -		memset(sigblob, 0, len); -		xfree(sigblob); -	} -	 -	/* sha1 the data */ -	digest = xmalloc(evp_md->md_size); -	EVP_DigestInit(&md, evp_md); -	EVP_DigestUpdate(&md, data, datalen); -	EVP_DigestFinal(&md, digest, NULL); - -	ret = DSA_do_verify(digest, evp_md->md_size, sig, key->dsa); - -	memset(digest, 0, evp_md->md_size); -	xfree(digest); -	DSA_SIG_free(sig); - -	switch (ret) { -	case 1: -		txt = "correct"; -		break; -	case 0: -		txt = "incorrect"; -		break; -	case -1: -	default: -		txt = "error"; -		break; -	} -	debug("dsa_verify: signature %s", txt); -	return ret; -} - -Key * -dsa_generate_key(unsigned int bits) -{ -	DSA *dsa = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); -	Key *k; -	if (dsa == NULL) { -		fatal("DSA_generate_parameters failed"); -	} -	if (!DSA_generate_key(dsa)) { -		fatal("DSA_generate_keys failed"); -	} - -	k = key_new(KEY_EMPTY); -	k->type = KEY_DSA; -	k->dsa = dsa; -	return k; -} diff --git a/crypto/openssh/dsa.h b/crypto/openssh/dsa.h deleted file mode 100644 index 252e7880beb59..0000000000000 --- a/crypto/openssh/dsa.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2000 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. - */ -#ifndef DSA_H -#define DSA_H - -Key	*dsa_key_from_blob(char *blob, int blen); -int	dsa_make_key_blob(Key *key, unsigned char **blobp, unsigned int *lenp); - -int -dsa_sign( -    Key *key, -    unsigned char **sigp, int *lenp, -    unsigned char *data, int datalen); - -int -dsa_verify( -    Key *key, -    unsigned char *signature, int signaturelen, -    unsigned char *data, int datalen); - -Key * -dsa_generate_key(unsigned int bits); - -#endif diff --git a/crypto/openssh/fingerprint.c b/crypto/openssh/fingerprint.c deleted file mode 100644 index 4b0966d91557e..0000000000000 --- a/crypto/openssh/fingerprint.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1999 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. - * 3. All advertising materials mentioning features or use of this software - *    must display the following acknowledgement: - *      This product includes software developed by Markus Friedl. - * 4. The name of the author may not be used to endorse or promote products - *    derived from this software without specific prior written permission. - * - * 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("$Id: fingerprint.c,v 1.6 2000/04/12 09:39:10 markus Exp $"); - -#include "ssh.h" -#include "xmalloc.h" -#include <openssl/md5.h> - -#define FPRINT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" - -/* - * Generate key fingerprint in ascii format. - * Based on ideas and code from Bjoern Groenvall <bg@sics.se> - */ -char * -fingerprint(BIGNUM *e, BIGNUM *n) -{ -	static char retval[80]; -	MD5_CTX md; -	unsigned char d[16]; -	unsigned char *buf; -	int nlen, elen; - -	nlen = BN_num_bytes(n); -	elen = BN_num_bytes(e); - -	buf = xmalloc(nlen + elen); - -	BN_bn2bin(n, buf); -	BN_bn2bin(e, buf + nlen); - -	MD5_Init(&md); -	MD5_Update(&md, buf, nlen + elen); -	MD5_Final(d, &md); -	snprintf(retval, sizeof(retval), FPRINT, -	    d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], -	    d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); -	memset(buf, 0, nlen + elen); -	xfree(buf); -	return retval; -} diff --git a/crypto/openssh/fingerprint.h b/crypto/openssh/fingerprint.h deleted file mode 100644 index fbb0d4c462060..0000000000000 --- a/crypto/openssh/fingerprint.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 1999 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. - * 3. All advertising materials mentioning features or use of this software - *    must display the following acknowledgement: - *      This product includes software developed by Markus Friedl. - * 4. The name of the author may not be used to endorse or promote products - *    derived from this software without specific prior written permission. - * - * 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. - */ -/* RCSID("$Id: fingerprint.h,v 1.3 1999/11/24 16:15:25 markus Exp $"); */ - -#ifndef FINGERPRINT_H -#define FINGERPRINT_H -char   *fingerprint(BIGNUM * e, BIGNUM * n); -#endif diff --git a/crypto/openssh/hmac.c b/crypto/openssh/hmac.c deleted file mode 100644 index 48a176304bebe..0000000000000 --- a/crypto/openssh/hmac.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2000 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: hmac.c,v 1.4 2000/09/07 20:27:51 deraadt Exp $"); - -#include "xmalloc.h" -#include "ssh.h" -#include "getput.h" - -#include <openssl/hmac.h> - -unsigned char * -hmac( -    EVP_MD *evp_md, -    unsigned int seqno, -    unsigned char *data, int datalen, -    unsigned char *key, int keylen) -{ -	HMAC_CTX c; -	static unsigned char m[EVP_MAX_MD_SIZE]; -	unsigned char b[4]; - -	if (key == NULL) -		fatal("hmac: no key"); -	HMAC_Init(&c, key, keylen, evp_md); -	PUT_32BIT(b, seqno); -	HMAC_Update(&c, b, sizeof b); -	HMAC_Update(&c, data, datalen); -	HMAC_Final(&c, m, NULL); -	HMAC_cleanup(&c); -	return(m); -} diff --git a/crypto/openssh/hmac.h b/crypto/openssh/hmac.h deleted file mode 100644 index 281300e25c48d..0000000000000 --- a/crypto/openssh/hmac.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2000 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. - */ -#ifndef HMAC_H -#define HMAC_H - -unsigned char * -hmac( -    EVP_MD *evp_md, -    unsigned int seqno, -    unsigned char *data, int datalen, -    unsigned char *key, int len); - -#endif diff --git a/crypto/openssh/log-client.c b/crypto/openssh/log-client.c deleted file mode 100644 index 505c8c33787a7..0000000000000 --- a/crypto/openssh/log-client.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Author: Tatu Ylonen <ylo@cs.hut.fi> - * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - *                    All rights reserved - * Client-side versions of debug(), log(), etc.  These print to stderr. - * This is a stripped down version of log-server.c. - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose.  Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - * - * - * Copyright (c) 2000 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: log-client.c,v 1.12 2000/09/12 20:53:10 markus Exp $"); - -#include "xmalloc.h" -#include "ssh.h" - -static LogLevel log_level = SYSLOG_LEVEL_INFO; - -/* Initialize the log. - *   av0	program name (should be argv[0]) - *   level	logging level - */ - -void -log_init(char *av0, LogLevel level, SyslogFacility ignored1, int ignored2) -{ -	switch (level) { -	case SYSLOG_LEVEL_QUIET: -	case SYSLOG_LEVEL_ERROR: -	case SYSLOG_LEVEL_FATAL: -	case SYSLOG_LEVEL_INFO: -	case SYSLOG_LEVEL_VERBOSE: -	case SYSLOG_LEVEL_DEBUG1: -	case SYSLOG_LEVEL_DEBUG2: -	case SYSLOG_LEVEL_DEBUG3: -		log_level = level; -		break; -	default: -		/* unchanged */ -		break; -	} -} - -#define MSGBUFSIZ 1024 - -void -do_log(LogLevel level, const char *fmt, va_list args) -{ -	char msgbuf[MSGBUFSIZ]; - -	if (level > log_level) -		return; -	if (level >= SYSLOG_LEVEL_DEBUG1) -		fprintf(stderr, "debug: "); -	vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); -	fprintf(stderr, "%s\r\n", msgbuf); -} diff --git a/crypto/openssh/log-server.c b/crypto/openssh/log-server.c deleted file mode 100644 index de3d5cfeb9700..0000000000000 --- a/crypto/openssh/log-server.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Author: Tatu Ylonen <ylo@cs.hut.fi> - * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - *                    All rights reserved - * Server-side versions of debug(), log(), etc.  These normally send the output - * to the system log. - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose.  Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - * - * - * Copyright (c) 2000 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: log-server.c,v 1.17 2000/09/12 20:53:10 markus Exp $"); - -#include <syslog.h> -#include "packet.h" -#include "xmalloc.h" -#include "ssh.h" - -static LogLevel log_level = SYSLOG_LEVEL_INFO; -static int log_on_stderr = 0; -static int log_facility = LOG_AUTH; - -/* Initialize the log. - *   av0	program name (should be argv[0]) - *   on_stderr	print also on stderr - *   level	logging level - */ - -void -log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) -{ -	switch (level) { -	case SYSLOG_LEVEL_QUIET: -	case SYSLOG_LEVEL_ERROR: -	case SYSLOG_LEVEL_FATAL: -	case SYSLOG_LEVEL_INFO: -	case SYSLOG_LEVEL_VERBOSE: -	case SYSLOG_LEVEL_DEBUG1: -	case SYSLOG_LEVEL_DEBUG2: -	case SYSLOG_LEVEL_DEBUG3: -		log_level = level; -		break; -	default: -		fprintf(stderr, "Unrecognized internal syslog level code %d\n", -			(int) level); -		exit(1); -	} -	switch (facility) { -	case SYSLOG_FACILITY_DAEMON: -		log_facility = LOG_DAEMON; -		break; -	case SYSLOG_FACILITY_USER: -		log_facility = LOG_USER; -		break; -	case SYSLOG_FACILITY_AUTH: -		log_facility = LOG_AUTH; -		break; -	case SYSLOG_FACILITY_LOCAL0: -		log_facility = LOG_LOCAL0; -		break; -	case SYSLOG_FACILITY_LOCAL1: -		log_facility = LOG_LOCAL1; -		break; -	case SYSLOG_FACILITY_LOCAL2: -		log_facility = LOG_LOCAL2; -		break; -	case SYSLOG_FACILITY_LOCAL3: -		log_facility = LOG_LOCAL3; -		break; -	case SYSLOG_FACILITY_LOCAL4: -		log_facility = LOG_LOCAL4; -		break; -	case SYSLOG_FACILITY_LOCAL5: -		log_facility = LOG_LOCAL5; -		break; -	case SYSLOG_FACILITY_LOCAL6: -		log_facility = LOG_LOCAL6; -		break; -	case SYSLOG_FACILITY_LOCAL7: -		log_facility = LOG_LOCAL7; -		break; -	default: -		fprintf(stderr, "Unrecognized internal syslog facility code %d\n", -			(int) facility); -		exit(1); -	} -	log_on_stderr = on_stderr; -} - -#define MSGBUFSIZ 1024 - -void -do_log(LogLevel level, const char *fmt, va_list args) -{ -	char msgbuf[MSGBUFSIZ]; -	char fmtbuf[MSGBUFSIZ]; -	char *txt = NULL; -	int pri = LOG_INFO; -	extern char *__progname; - -	if (level > log_level) -		return; -	switch (level) { -	case SYSLOG_LEVEL_ERROR: -		txt = "error"; -		pri = LOG_ERR; -		break; -	case SYSLOG_LEVEL_FATAL: -		txt = "fatal"; -		pri = LOG_ERR; -		break; -	case SYSLOG_LEVEL_INFO: -	case SYSLOG_LEVEL_VERBOSE: -		pri = LOG_INFO; -		break; -	case SYSLOG_LEVEL_DEBUG1: -		txt = "debug1"; -		pri = LOG_DEBUG; -		break; -	case SYSLOG_LEVEL_DEBUG2: -		txt = "debug2"; -		pri = LOG_DEBUG; -		break; -	case SYSLOG_LEVEL_DEBUG3: -		txt = "debug3"; -		pri = LOG_DEBUG; -		break; -	default: -		txt = "internal error"; -		pri = LOG_ERR; -		break; -	} -	if (txt != NULL) { -		snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", txt, fmt); -		vsnprintf(msgbuf, sizeof(msgbuf), fmtbuf, args); -	} else { -		vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); -	} -	if (log_on_stderr) { -		fprintf(stderr, "%s\n", msgbuf); -	} else { -		openlog(__progname, LOG_PID, log_facility); -		syslog(pri, "%.500s", msgbuf); -		closelog(); -	} -} diff --git a/crypto/openssh/login.c b/crypto/openssh/login.c deleted file mode 100644 index 1d59cd825f732..0000000000000 --- a/crypto/openssh/login.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Author: Tatu Ylonen <ylo@cs.hut.fi> - * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - *                    All rights reserved - * This file performs some of the things login(1) normally does.  We cannot - * easily use something like login -p -h host -f user, because there are - * several different logins around, and it is hard to determined what kind of - * login the current system has.  Also, we want to be able to execute commands - * on a tty. - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose.  Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - * - * Copyright (c) 1999 Theo de Raadt.  All rights reserved. - * Copyright (c) 1999 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: login.c,v 1.15 2000/09/07 20:27:52 deraadt Exp $"); - -#include <util.h> -#include <utmp.h> -#include "ssh.h" - -/* - * Returns the time when the user last logged in.  Returns 0 if the - * information is not available.  This must be called before record_login. - * The host the user logged in from will be returned in buf. - */ - -/* - * Returns the time when the user last logged in (or 0 if no previous login - * is found).  The name of the host used last time is returned in buf. - */ - -unsigned long -get_last_login_time(uid_t uid, const char *logname, -		    char *buf, unsigned int bufsize) -{ -	struct lastlog ll; -	char *lastlog; -	int fd; - -	lastlog = _PATH_LASTLOG; -	buf[0] = '\0'; - -	fd = open(lastlog, O_RDONLY); -	if (fd < 0) -		return 0; -	lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET); -	if (read(fd, &ll, sizeof(ll)) != sizeof(ll)) { -		close(fd); -		return 0; -	} -	close(fd); -	if (bufsize > sizeof(ll.ll_host) + 1) -		bufsize = sizeof(ll.ll_host) + 1; -	strncpy(buf, ll.ll_host, bufsize - 1); -	buf[bufsize - 1] = 0; -	return ll.ll_time; -} - -/* - * Records that the user has logged in.  I these parts of operating systems - * were more standardized. - */ - -void -record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid, -	     const char *host, struct sockaddr * addr) -{ -	int fd; -	struct lastlog ll; -	char *lastlog; -	struct utmp u; -	const char *utmp, *wtmp; - -	/* Construct an utmp/wtmp entry. */ -	memset(&u, 0, sizeof(u)); -	strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line)); -	u.ut_time = time(NULL); -	strncpy(u.ut_name, user, sizeof(u.ut_name)); -	strncpy(u.ut_host, host, sizeof(u.ut_host)); - -	/* Figure out the file names. */ -	utmp = _PATH_UTMP; -	wtmp = _PATH_WTMP; - -	login(&u); -	lastlog = _PATH_LASTLOG; - -	/* Update lastlog unless actually recording a logout. */ -	if (strcmp(user, "") != 0) { -		/* -		 * It is safer to bzero the lastlog structure first because -		 * some systems might have some extra fields in it (e.g. SGI) -		 */ -		memset(&ll, 0, sizeof(ll)); - -		/* Update lastlog. */ -		ll.ll_time = time(NULL); -		strncpy(ll.ll_line, ttyname + 5, sizeof(ll.ll_line)); -		strncpy(ll.ll_host, host, sizeof(ll.ll_host)); -		fd = open(lastlog, O_RDWR); -		if (fd >= 0) { -			lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET); -			if (write(fd, &ll, sizeof(ll)) != sizeof(ll)) -				log("Could not write %.100s: %.100s", lastlog, strerror(errno)); -			close(fd); -		} -	} -} - -/* Records that the user has logged out. */ - -void -record_logout(pid_t pid, const char *ttyname) -{ -	const char *line = ttyname + 5;	/* /dev/ttyq8 -> ttyq8 */ -	if (logout(line)) -		logwtmp(line, "", ""); -} diff --git a/crypto/openssh/nchan.h b/crypto/openssh/nchan.h deleted file mode 100644 index 623ecccc31cfb..0000000000000 --- a/crypto/openssh/nchan.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 1999 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. - */ - -/* RCSID("$OpenBSD: nchan.h,v 1.10 2001/02/28 08:54:55 markus Exp $"); */ - -#ifndef NCHAN_H -#define NCHAN_H - -/* - * SSH Protocol 1.5 aka New Channel Protocol - * Thanks to Martina, Axel and everyone who left Erlangen, leaving me bored. - * Written by Markus Friedl in October 1999 - * - * Protocol versions 1.3 and 1.5 differ in the handshake protocol used for the - * tear down of channels: - * - * 1.3:	strict request-ack-protocol: - * 	CLOSE	-> - * 		<-  CLOSE_CONFIRM - * - * 1.5:	uses variations of: - * 	IEOF	-> - * 		<-  OCLOSE - * 		<-  IEOF - * 	OCLOSE	-> - * 	i.e. both sides have to close the channel - * - * See the debugging output from 'ssh -v' and 'sshd -d' of - * ssh-1.2.27 as an example. - * - */ - -/* ssh-proto-1.5 overloads prot-1.3-message-types */ -#define SSH_MSG_CHANNEL_INPUT_EOF	SSH_MSG_CHANNEL_CLOSE -#define SSH_MSG_CHANNEL_OUTPUT_CLOSE	SSH_MSG_CHANNEL_CLOSE_CONFIRMATION - -/* possible input states */ -#define CHAN_INPUT_OPEN			0x01 -#define CHAN_INPUT_WAIT_DRAIN		0x02 -#define CHAN_INPUT_WAIT_OCLOSE		0x04 -#define CHAN_INPUT_CLOSED		0x08 - -/* possible output states */ -#define CHAN_OUTPUT_OPEN		0x10 -#define CHAN_OUTPUT_WAIT_DRAIN		0x20 -#define CHAN_OUTPUT_WAIT_IEOF		0x40 -#define CHAN_OUTPUT_CLOSED		0x80 - -#define CHAN_CLOSE_SENT			0x01 -#define CHAN_CLOSE_RCVD			0x02 - - -/* Channel EVENTS */ -typedef void    chan_event_fn(Channel * c); - -/* for the input state */ -extern chan_event_fn	*chan_rcvd_oclose; -extern chan_event_fn	*chan_read_failed; -extern chan_event_fn	*chan_ibuf_empty; - -/* for the output state */ -extern chan_event_fn	*chan_rcvd_ieof; -extern chan_event_fn	*chan_write_failed; -extern chan_event_fn	*chan_obuf_empty; - -int chan_is_dead(Channel * c); - -void    chan_init_iostates(Channel * c); -void	chan_init(void); -#endif diff --git a/crypto/openssh/pty.c b/crypto/openssh/pty.c deleted file mode 100644 index 9300bd530415c..0000000000000 --- a/crypto/openssh/pty.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Author: Tatu Ylonen <ylo@cs.hut.fi> - * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - *                    All rights reserved - * Allocating a pseudo-terminal, and making it the controlling tty. - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose.  Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - */ - -#include "includes.h" -RCSID("$OpenBSD: pty.c,v 1.16 2000/09/07 21:13:37 markus Exp $"); - -#include <util.h> -#include "pty.h" -#include "ssh.h" - -/* Pty allocated with _getpty gets broken if we do I_PUSH:es to it. */ -#if defined(HAVE__GETPTY) || defined(HAVE_OPENPTY) -#undef HAVE_DEV_PTMX -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -/* - * Allocates and opens a pty.  Returns 0 if no pty could be allocated, or - * nonzero if a pty was successfully allocated.  On success, open file - * descriptors for the pty and tty sides and the name of the tty side are - * returned (the buffer must be able to hold at least 64 characters). - */ - -int -pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) -{ -#if defined(HAVE_OPENPTY) || defined(BSD4_4) -	/* openpty(3) exists in OSF/1 and some other os'es */ -	char buf[64]; -	int i; - -	i = openpty(ptyfd, ttyfd, buf, NULL, NULL); -	if (i < 0) { -		error("openpty: %.100s", strerror(errno)); -		return 0; -	} -	strlcpy(namebuf, buf, namebuflen);	/* possible truncation */ -	return 1; -#else /* HAVE_OPENPTY */ -#ifdef HAVE__GETPTY -	/* -	 * _getpty(3) exists in SGI Irix 4.x, 5.x & 6.x -- it generates more -	 * pty's automagically when needed -	 */ -	char *slave; - -	slave = _getpty(ptyfd, O_RDWR, 0622, 0); -	if (slave == NULL) { -		error("_getpty: %.100s", strerror(errno)); -		return 0; -	} -	strlcpy(namebuf, slave, namebuflen); -	/* Open the slave side. */ -	*ttyfd = open(namebuf, O_RDWR | O_NOCTTY); -	if (*ttyfd < 0) { -		error("%.200s: %.100s", namebuf, strerror(errno)); -		close(*ptyfd); -		return 0; -	} -	return 1; -#else /* HAVE__GETPTY */ -#ifdef HAVE_DEV_PTMX -	/* -	 * This code is used e.g. on Solaris 2.x.  (Note that Solaris 2.3 -	 * also has bsd-style ptys, but they simply do not work.) -	 */ -	int ptm; -	char *pts; - -	ptm = open("/dev/ptmx", O_RDWR | O_NOCTTY); -	if (ptm < 0) { -		error("/dev/ptmx: %.100s", strerror(errno)); -		return 0; -	} -	if (grantpt(ptm) < 0) { -		error("grantpt: %.100s", strerror(errno)); -		return 0; -	} -	if (unlockpt(ptm) < 0) { -		error("unlockpt: %.100s", strerror(errno)); -		return 0; -	} -	pts = ptsname(ptm); -	if (pts == NULL) -		error("Slave pty side name could not be obtained."); -	strlcpy(namebuf, pts, namebuflen); -	*ptyfd = ptm; - -	/* Open the slave side. */ -	*ttyfd = open(namebuf, O_RDWR | O_NOCTTY); -	if (*ttyfd < 0) { -		error("%.100s: %.100s", namebuf, strerror(errno)); -		close(*ptyfd); -		return 0; -	} -	/* Push the appropriate streams modules, as described in Solaris pts(7). */ -	if (ioctl(*ttyfd, I_PUSH, "ptem") < 0) -		error("ioctl I_PUSH ptem: %.100s", strerror(errno)); -	if (ioctl(*ttyfd, I_PUSH, "ldterm") < 0) -		error("ioctl I_PUSH ldterm: %.100s", strerror(errno)); -	if (ioctl(*ttyfd, I_PUSH, "ttcompat") < 0) -		error("ioctl I_PUSH ttcompat: %.100s", strerror(errno)); -	return 1; -#else /* HAVE_DEV_PTMX */ -#ifdef HAVE_DEV_PTS_AND_PTC -	/* AIX-style pty code. */ -	const char *name; - -	*ptyfd = open("/dev/ptc", O_RDWR | O_NOCTTY); -	if (*ptyfd < 0) { -		error("Could not open /dev/ptc: %.100s", strerror(errno)); -		return 0; -	} -	name = ttyname(*ptyfd); -	if (!name) -		fatal("Open of /dev/ptc returns device for which ttyname fails."); -	strlcpy(namebuf, name, namebuflen); -	*ttyfd = open(name, O_RDWR | O_NOCTTY); -	if (*ttyfd < 0) { -		error("Could not open pty slave side %.100s: %.100s", -		      name, strerror(errno)); -		close(*ptyfd); -		return 0; -	} -	return 1; -#else /* HAVE_DEV_PTS_AND_PTC */ -	/* BSD-style pty code. */ -	char buf[64]; -	int i; -	const char *ptymajors = "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ"; -	const char *ptyminors = "0123456789abcdef"; -	int num_minors = strlen(ptyminors); -	int num_ptys = strlen(ptymajors) * num_minors; - -	for (i = 0; i < num_ptys; i++) { -		snprintf(buf, sizeof buf, "/dev/pty%c%c", ptymajors[i / num_minors], -			 ptyminors[i % num_minors]); -		*ptyfd = open(buf, O_RDWR | O_NOCTTY); -		if (*ptyfd < 0) -			continue; -		snprintf(namebuf, namebuflen, "/dev/tty%c%c", -		    ptymajors[i / num_minors], ptyminors[i % num_minors]); - -		/* Open the slave side. */ -		*ttyfd = open(namebuf, O_RDWR | O_NOCTTY); -		if (*ttyfd < 0) { -			error("%.100s: %.100s", namebuf, strerror(errno)); -			close(*ptyfd); -			return 0; -		} -		return 1; -	} -	return 0; -#endif /* HAVE_DEV_PTS_AND_PTC */ -#endif /* HAVE_DEV_PTMX */ -#endif /* HAVE__GETPTY */ -#endif /* HAVE_OPENPTY */ -} - -/* Releases the tty.  Its ownership is returned to root, and permissions to 0666. */ - -void -pty_release(const char *ttyname) -{ -	if (chown(ttyname, (uid_t) 0, (gid_t) 0) < 0) -		error("chown %.100s 0 0 failed: %.100s", ttyname, strerror(errno)); -	if (chmod(ttyname, (mode_t) 0666) < 0) -		error("chmod %.100s 0666 failed: %.100s", ttyname, strerror(errno)); -} - -/* Makes the tty the processes controlling tty and sets it to sane modes. */ - -void -pty_make_controlling_tty(int *ttyfd, const char *ttyname) -{ -	int fd; - -	/* First disconnect from the old controlling tty. */ -#ifdef TIOCNOTTY -	fd = open("/dev/tty", O_RDWR | O_NOCTTY); -	if (fd >= 0) { -		(void) ioctl(fd, TIOCNOTTY, NULL); -		close(fd); -	} -#endif /* TIOCNOTTY */ -	if (setsid() < 0) -		error("setsid: %.100s", strerror(errno)); - -	/* -	 * Verify that we are successfully disconnected from the controlling -	 * tty. -	 */ -	fd = open("/dev/tty", O_RDWR | O_NOCTTY); -	if (fd >= 0) { -		error("Failed to disconnect from controlling tty."); -		close(fd); -	} -	/* Make it our controlling tty. */ -#ifdef TIOCSCTTY -	debug("Setting controlling tty using TIOCSCTTY."); -	/* -	 * We ignore errors from this, because HPSUX defines TIOCSCTTY, but -	 * returns EINVAL with these arguments, and there is absolutely no -	 * documentation. -	 */ -	ioctl(*ttyfd, TIOCSCTTY, NULL); -#endif /* TIOCSCTTY */ -	fd = open(ttyname, O_RDWR); -	if (fd < 0) -		error("%.100s: %.100s", ttyname, strerror(errno)); -	else -		close(fd); - -	/* Verify that we now have a controlling tty. */ -	fd = open("/dev/tty", O_WRONLY); -	if (fd < 0) -		error("open /dev/tty failed - could not set controlling tty: %.100s", -		      strerror(errno)); -	else { -		close(fd); -	} -} - -/* Changes the window size associated with the pty. */ - -void -pty_change_window_size(int ptyfd, int row, int col, -		       int xpixel, int ypixel) -{ -	struct winsize w; -	w.ws_row = row; -	w.ws_col = col; -	w.ws_xpixel = xpixel; -	w.ws_ypixel = ypixel; -	(void) ioctl(ptyfd, TIOCSWINSZ, &w); -} - -void -pty_setowner(struct passwd *pw, const char *ttyname) -{ -	struct group *grp; -	gid_t gid; -	mode_t mode; - -	/* Determine the group to make the owner of the tty. */ -	grp = getgrnam("tty"); -	if (grp) { -		gid = grp->gr_gid; -		mode = S_IRUSR | S_IWUSR | S_IWGRP; -	} else { -		gid = pw->pw_gid; -		mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; -	} - -	/* Change ownership of the tty. */ -	if (chown(ttyname, pw->pw_uid, gid) < 0) -		fatal("chown(%.100s, %d, %d) failed: %.100s", -		    ttyname, pw->pw_uid, gid, strerror(errno)); -	if (chmod(ttyname, mode) < 0) -		fatal("chmod(%.100s, 0%o) failed: %.100s", -		    ttyname, mode, strerror(errno)); -} diff --git a/crypto/openssh/pty.h b/crypto/openssh/pty.h deleted file mode 100644 index 13d8e6026cc3c..0000000000000 --- a/crypto/openssh/pty.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Author: Tatu Ylonen <ylo@cs.hut.fi> - * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - *                    All rights reserved - * Functions for allocating a pseudo-terminal and making it the controlling - * tty. - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose.  Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - */ - -/* RCSID("$OpenBSD: pty.h,v 1.8 2000/09/07 20:27:52 deraadt Exp $"); */ - -#ifndef PTY_H -#define PTY_H - -/* - * Allocates and opens a pty.  Returns 0 if no pty could be allocated, or - * nonzero if a pty was successfully allocated.  On success, open file - * descriptors for the pty and tty sides and the name of the tty side are - * returned (the buffer must be able to hold at least 64 characters). - */ -int     pty_allocate(int *ptyfd, int *ttyfd, char *ttyname, int ttynamelen); - -/* - * Releases the tty.  Its ownership is returned to root, and permissions to - * 0666. - */ -void    pty_release(const char *ttyname); - -/* - * Makes the tty the processes controlling tty and sets it to sane modes. - * This may need to reopen the tty to get rid of possible eavesdroppers. - */ -void    pty_make_controlling_tty(int *ttyfd, const char *ttyname); - -/* Changes the window size associated with the pty. */ -void -pty_change_window_size(int ptyfd, int row, int col, -    int xpixel, int ypixel); - -void	pty_setowner(struct passwd *pw, const char *ttyname); - -#endif				/* PTY_H */ diff --git a/crypto/openssh/scp-common.c b/crypto/openssh/scp-common.c deleted file mode 100644 index 7e5f09c74fae3..0000000000000 --- a/crypto/openssh/scp-common.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1999 Theo de Raadt.  All rights reserved. - * Copyright (c) 1999 Aaron Campbell.  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. - */ - -/* - * Parts from: - * - * Copyright (c) 1983, 1990, 1992, 1993, 1995 - *	The Regents of the University of California.  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. - * 3. All advertising materials mentioning features or use of this software - *    must display the following acknowledgement: - *	This product includes software developed by the University of - *	California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - *    may be used to endorse or promote products derived from this software - *    without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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: scp-common.c,v 1.1 2001/04/16 02:31:43 mouring Exp $"); - -char * -cleanhostname(host) -	char *host; -{ -	if (*host == '[' && host[strlen(host) - 1] == ']') { -		host[strlen(host) - 1] = '\0'; -		return (host + 1); -	} else -		return host; -} - -char * -colon(cp) -	char *cp; -{ -	int flag = 0; - -	if (*cp == ':')		/* Leading colon is part of file name. */ -		return (0); -	if (*cp == '[') -		flag = 1; - -	for (; *cp; ++cp) { -		if (*cp == '@' && *(cp+1) == '[') -			flag = 1; -		if (*cp == ']' && *(cp+1) == ':' && flag) -			return (cp+1); -		if (*cp == ':' && !flag) -			return (cp); -		if (*cp == '/') -			return (0); -	} -	return (0); -} diff --git a/crypto/openssh/scp-common.h b/crypto/openssh/scp-common.h deleted file mode 100644 index e0ab6ec32a7d0..0000000000000 --- a/crypto/openssh/scp-common.h +++ /dev/null @@ -1,64 +0,0 @@ -/* $OpenBSD: scp-common.h,v 1.1 2001/04/16 02:31:43 mouring Exp $ */ -/* - * Copyright (c) 1999 Theo de Raadt.  All rights reserved. - * Copyright (c) 1999 Aaron Campbell.  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. - */ - -/* - * Parts from: - * - * Copyright (c) 1983, 1990, 1992, 1993, 1995 - *	The Regents of the University of California.  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. - * 3. All advertising materials mentioning features or use of this software - *    must display the following acknowledgement: - *	This product includes software developed by the University of - *	California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - *    may be used to endorse or promote products derived from this software - *    without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - */ - -char *cleanhostname(char *host); -char *colon(char *cp); diff --git a/crypto/openssh/util.c b/crypto/openssh/util.c deleted file mode 100644 index 1a591a6f0f518..0000000000000 --- a/crypto/openssh/util.c +++ /dev/null @@ -1,96 +0,0 @@ -/*	$OpenBSD: util.c,v 1.6 2000/10/27 07:32:19 markus Exp $	*/ - -/* - * Copyright (c) 2000 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: util.c,v 1.6 2000/10/27 07:32:19 markus Exp $"); - -#include "ssh.h" - -char * -chop(char *s) -{ -	char *t = s; -	while (*t) { -		if(*t == '\n' || *t == '\r') { -			*t = '\0'; -			return s; -		} -		t++; -	} -	return s; - -} - -void -set_nonblock(int fd) -{ -	int val; -	val = fcntl(fd, F_GETFL, 0); -	if (val < 0) { -		error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); -		return; -	} -	if (val & O_NONBLOCK) { -		debug("fd %d IS O_NONBLOCK", fd); -		return; -	} -	debug("fd %d setting O_NONBLOCK", fd); -	val |= O_NONBLOCK; -	if (fcntl(fd, F_SETFL, val) == -1) -		if (errno != ENODEV) -			error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", -			    fd, strerror(errno)); -} - -/* Characters considered whitespace in strsep calls. */ -#define WHITESPACE " \t\r\n" - -char * -strdelim(char **s) -{ -	char *old; -	int wspace = 0; - -	if (*s == NULL) -		return NULL; - -	old = *s; - -	*s = strpbrk(*s, WHITESPACE "="); -	if (*s == NULL) -		return (old); - -	/* Allow only one '=' to be skipped */ -	if (*s[0] == '=') -		wspace = 1; -	*s[0] = '\0'; - -	*s += strspn(*s + 1, WHITESPACE) + 1; -	if (*s[0] == '=' && !wspace) -		*s += strspn(*s + 1, WHITESPACE) + 1; - -	return (old); -}  | 
