summaryrefslogtreecommitdiffstats
path: root/crypto/openssh
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssh')
-rw-r--r--crypto/openssh/COPYING.Ylonen70
-rw-r--r--crypto/openssh/FREEBSD-Xlist10
-rw-r--r--crypto/openssh/FREEBSD-tricks19
-rw-r--r--crypto/openssh/FREEBSD-upgrade130
-rw-r--r--crypto/openssh/LICENCE160
-rw-r--r--crypto/openssh/Makefile14
-rw-r--r--crypto/openssh/README.openssh244
-rw-r--r--crypto/openssh/acconfig.h83
-rw-r--r--crypto/openssh/auth-chall.c1
-rw-r--r--crypto/openssh/auth-krb5.c231
-rw-r--r--crypto/openssh/auth-pam.c972
-rw-r--r--crypto/openssh/auth-pam.h23
-rw-r--r--crypto/openssh/auth-passwd.c221
-rw-r--r--crypto/openssh/auth-rh-rsa.c6
-rw-r--r--crypto/openssh/auth-rsa.c6
-rw-r--r--crypto/openssh/auth-skey.c9
-rw-r--r--crypto/openssh/auth.c161
-rw-r--r--crypto/openssh/auth.h46
-rw-r--r--crypto/openssh/auth1.c132
-rw-r--r--crypto/openssh/auth2-chall.c13
-rw-r--r--crypto/openssh/auth2-kbdint.c1
-rw-r--r--crypto/openssh/auth2-pam-freebsd.c634
-rw-r--r--crypto/openssh/auth2-skey.c104
-rw-r--r--crypto/openssh/auth2.c75
-rw-r--r--crypto/openssh/authfd.c41
-rw-r--r--crypto/openssh/authfile.c13
-rw-r--r--crypto/openssh/aux.c36
-rw-r--r--crypto/openssh/bufaux.c9
-rw-r--r--crypto/openssh/canohost.c52
-rw-r--r--crypto/openssh/cipher.c382
-rw-r--r--crypto/openssh/cli.c231
-rw-r--r--crypto/openssh/cli.h42
-rw-r--r--crypto/openssh/compat.c18
-rw-r--r--crypto/openssh/compat.h8
-rw-r--r--crypto/openssh/config.h948
-rw-r--r--crypto/openssh/configure.ac607
-rw-r--r--crypto/openssh/dsa.c304
-rw-r--r--crypto/openssh/dsa.h45
-rw-r--r--crypto/openssh/fingerprint.c69
-rw-r--r--crypto/openssh/fingerprint.h34
-rw-r--r--crypto/openssh/hmac.c54
-rw-r--r--crypto/openssh/hmac.h34
-rw-r--r--crypto/openssh/hostfile.c6
-rw-r--r--crypto/openssh/includes.h14
-rw-r--r--crypto/openssh/key.c12
-rw-r--r--crypto/openssh/lib/Makefile35
-rw-r--r--crypto/openssh/log-client.c84
-rw-r--r--crypto/openssh/log-server.c173
-rw-r--r--crypto/openssh/log.h13
-rw-r--r--crypto/openssh/login.c145
-rw-r--r--crypto/openssh/loginrec.c85
-rw-r--r--crypto/openssh/monitor.c307
-rw-r--r--crypto/openssh/monitor.h9
-rw-r--r--crypto/openssh/monitor_wrap.c159
-rw-r--r--crypto/openssh/monitor_wrap.h30
-rw-r--r--crypto/openssh/myproposal.h8
-rw-r--r--crypto/openssh/nchan.h91
-rw-r--r--crypto/openssh/packet.h15
-rw-r--r--crypto/openssh/pty.c275
-rw-r--r--crypto/openssh/pty.h47
-rw-r--r--crypto/openssh/readconf.c201
-rw-r--r--crypto/openssh/readconf.h19
-rw-r--r--crypto/openssh/scard/Makefile20
-rw-r--r--crypto/openssh/scp-common.c98
-rw-r--r--crypto/openssh/scp-common.h64
-rw-r--r--crypto/openssh/scp.c108
-rw-r--r--crypto/openssh/scp/Makefile15
-rw-r--r--crypto/openssh/servconf.c175
-rw-r--r--crypto/openssh/servconf.h20
-rw-r--r--crypto/openssh/serverloop.c20
-rw-r--r--crypto/openssh/session.c330
-rw-r--r--crypto/openssh/session.h5
-rw-r--r--crypto/openssh/sftp-server/Makefile18
-rw-r--r--crypto/openssh/sftp/Makefile19
-rw-r--r--crypto/openssh/ssh-add.c9
-rw-r--r--crypto/openssh/ssh-add/Makefile18
-rw-r--r--crypto/openssh/ssh-agent.c39
-rw-r--r--crypto/openssh/ssh-agent/Makefile18
-rw-r--r--crypto/openssh/ssh-dss.h32
-rw-r--r--crypto/openssh/ssh-keygen/Makefile18
-rw-r--r--crypto/openssh/ssh-keyscan.c14
-rw-r--r--crypto/openssh/ssh-keyscan/Makefile18
-rw-r--r--crypto/openssh/ssh-keysign/Makefile18
-rw-r--r--crypto/openssh/ssh-rsa.h32
-rw-r--r--crypto/openssh/ssh.158
-rw-r--r--crypto/openssh/ssh.c104
-rw-r--r--crypto/openssh/ssh.h6
-rw-r--r--crypto/openssh/ssh/Makefile40
-rw-r--r--crypto/openssh/ssh_config9
-rw-r--r--crypto/openssh/ssh_config.5127
-rw-r--r--crypto/openssh/sshconnect.c185
-rw-r--r--crypto/openssh/sshconnect1.c589
-rw-r--r--crypto/openssh/sshconnect2.c625
-rw-r--r--crypto/openssh/sshd.895
-rw-r--r--crypto/openssh/sshd.c196
-rw-r--r--crypto/openssh/sshd/Makefile56
-rw-r--r--crypto/openssh/sshd_config44
-rw-r--r--crypto/openssh/sshd_config.5165
-rw-r--r--crypto/openssh/sshlogin.c6
-rw-r--r--crypto/openssh/sshpty.c24
-rw-r--r--crypto/openssh/util.c96
-rw-r--r--crypto/openssh/version.c59
-rw-r--r--crypto/openssh/version.h14
103 files changed, 5489 insertions, 5937 deletions
diff --git a/crypto/openssh/COPYING.Ylonen b/crypto/openssh/COPYING.Ylonen
deleted file mode 100644
index 5e681ed..0000000
--- 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/FREEBSD-Xlist b/crypto/openssh/FREEBSD-Xlist
new file mode 100644
index 0000000..4ea54ed
--- /dev/null
+++ b/crypto/openssh/FREEBSD-Xlist
@@ -0,0 +1,10 @@
+$FreeBSD$
+*.0
+*/.cvsignore
+.cvsignore
+autom4te*
+config.h.in
+configure
+contrib
+regress/*.[0-9]
+scard
diff --git a/crypto/openssh/FREEBSD-tricks b/crypto/openssh/FREEBSD-tricks
new file mode 100644
index 0000000..4ae5439
--- /dev/null
+++ b/crypto/openssh/FREEBSD-tricks
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+# Shell code to remove FreeBSD tags before merging
+grep -rl '\$Fre.BSD:' . >tags
+cat tags | while read f ; do
+ sed -i.orig -e '/\$Fre.BSD:/d' $f
+done
+
+# Shell + Perl code to add FreeBSD tags wherever an OpenBSD or Id tag occurs
+cat tags |
+xargs perl -n -i.orig -e 'print; s/\$(Id|OpenBSD): [^\$]*\$/\$FreeBSD\$/ && print'
+
+# Shell code to reexpand FreeBSD tags
+cat tags | while read f ; do
+ id=$(cvs diff $f | grep '\$Fre.BSD:' | sed 's/.*\(\$Fre.BSD:.*\$\).*/\1/') ;
+ if [ -n "$id" ] ; then
+ sed -i.orig -e "s@\\\$Fre.BSD\\\$@$id@" $f ;
+ fi ;
+done
diff --git a/crypto/openssh/FREEBSD-upgrade b/crypto/openssh/FREEBSD-upgrade
new file mode 100644
index 0000000..edc2008
--- /dev/null
+++ b/crypto/openssh/FREEBSD-upgrade
@@ -0,0 +1,130 @@
+
+
+ FreeBSD maintainer's guide to OpenSSH-portable
+ ==============================================
+
+
+0) Make sure your mail spool has plenty of free space. It'll fill up
+ pretty fast once you're done with this checklist.
+
+1) Grab the latest OpenSSH-portable tarball from the OpenBSD FTP
+ site (ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/)
+
+2) Unpack the tarball in a suitable directory.
+
+3) Remove trash:
+
+ $ eval "rm -rvf $(tr '[:space:]' ' ' </usr/src/crypto/openssh/FREEBSD-Xlist)"
+
+ Make sure that took care of everything, and if it didn't, make sure
+ to update FREEBSD-Xlist so you won't miss it the next time.
+
+4) Import the sources:
+
+ $ cvs import src/crypto/openssh OPENSSH OpenSSH_X_YpZ
+
+5) Resolve conflicts. Remember to bump the version number and
+ addendum in version.h.
+
+6) Generate configure and config.h.in:
+
+ $ autoconf
+ $ autoheader
+
+ Note: this requires a recent version of autoconf, not autoconf213.
+
+7) Run configure with the appropriate arguments:
+
+ $ ./configure --prefix=/usr --sysconfdir=/etc/ssh \
+ --with-pam --with-tcp-wrappers
+
+ Note that we don't want to configure OpenSSH for Kerberos using
+ configure since we have to be able to turn it on or off depending
+ on the value of MAKE_KERBEROS[45]. Our Makefiles take care of
+ this.
+
+8) Commit the resulting config.h. Make sure you don't accidentally
+ commit any other files created by autoconf, autoheader or
+ configure; they'll just clutter up the repo and cause trouble at
+ the next upgrade.
+
+9) Build and test.
+
+A) Re-commit everything on freefall (you *did* use a test repo for
+ this, didn't you?)
+
+
+
+ An overview of FreeBSD changes to OpenSSH-portable
+ ==================================================
+
+0) VersionAddendum
+
+ The SSH protocol allows for a human-readable version string of up
+ to 40 characters to be appended to the protocol version string.
+ FreeBSD takes advantage of this to include a date indicating the
+ "patch level", so people can easily determine whether their system
+ is vulnerable when an OpenSSH advisory goes out. Some people,
+ however, dislike advertising their patch level in the protocol
+ handshake, so we've added a VersionAddendum configuration variable
+ to allow them to change or disable it.
+
+1) Modified server-side defaults
+
+ We've modified some configuration defaults in sshd:
+
+ - For protocol version 2, we don't load RSA host keys by
+ default. If both RSA and DSA keys are present, we prefer DSA
+ to RSA.
+
+ - LoginGraceTime defaults to 120 seconds instead of 600.
+
+ - PermitRootLogin defaults to "no".
+
+ - X11Forwarding defaults to "yes" (it's a threat to the client,
+ not to the server.)
+
+ - Unless the config file says otherwise, we automatically enable
+ Kerberos support if an appropriate keytab is present.
+
+ - PAMAuthenticationViaKbdInt defaults to "yes".
+
+2) Modified client-side defaults
+
+ We've modified some configuration defaults in ssh:
+
+ - For protocol version 2, if both RSA and DSA keys are present,
+ we prefer DSA to RSA.
+
+ - CheckHostIP defaults to "no".
+
+3) Canonic host names
+
+ We've added code to ssh.c to canonicize the target host name after
+ reading options but before trying to connect. This eliminates the
+ usual problem with duplicate known_hosts entries.
+
+4) OPIE
+
+ We've added support for using OPIE as a drop-in replacement for
+ S/Key.
+
+5) PAM
+
+ We use our own PAM code, which wraps PAM in a KbdintDevice and
+ works with privsep, instead of OpenSSH's own PAM code.
+
+6) setusercontext() environment
+
+ Our setusercontext(3) can set environment variables, which we must
+ take care to transfer to the child's environment.
+
+
+
+This port was brought to you by (in no particular order) DARPA, NAI
+Labs, ThinkSec, Nescafé, the Aberlour Glenlivet Distillery Co.,
+Suzanne Vega, and a Sanford's #69 Deluxe Marker.
+
+ -- des@FreeBSD.org
+
+$FreeBSD$
diff --git a/crypto/openssh/LICENCE b/crypto/openssh/LICENCE
index b47556d..19d4c74 100644
--- a/crypto/openssh/LICENCE
+++ b/crypto/openssh/LICENCE
@@ -76,6 +76,14 @@ OpenSSH contains no GPL code.
POSSIBILITY OF SUCH DAMAGES.
2)
+ 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:
+
+ * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
+ * code or tables extracted from it, as desired without restriction.
+
+3)
The 32-bit CRC compensation attack detector in deattack.c was
contributed by CORE SDI S.A. under a BSD-style license.
@@ -96,7 +104,7 @@ OpenSSH contains no GPL code.
* Ariel Futoransky <futo@core-sdi.com>
* <http://www.core-sdi.com>
-3)
+4)
ssh-keygen was contributed by David Mazieres under a BSD-style
license.
@@ -106,7 +114,7 @@ OpenSSH contains no GPL code.
* permitted provided that due credit is given to the author and the
* OpenBSD project by leaving this copyright notice intact.
-4)
+5)
The Rijndael implementation by Vincent Rijmen, Antoon Bosselaers
and Paulo Barreto is in the public domain and distributed
with the following license:
@@ -133,10 +141,12 @@ OpenSSH contains no GPL code.
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-5)
- One component of the ssh source code is under a 3-clause BSD license,
+6)
+ One component of the ssh source code is under a 4-clause BSD license,
held by the University of California, since we pulled these parts from
- original Berkeley code.
+ original Berkeley code. The Regents of the University of California
+ have declared that term 3 is no longer enforceable on their source code,
+ but we retain that license as is.
* Copyright (c) 1983, 1990, 1992, 1993, 1995
* The Regents of the University of California. All rights reserved.
@@ -149,7 +159,11 @@ OpenSSH contains no GPL code.
* 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. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -165,7 +179,7 @@ OpenSSH contains no GPL code.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
-6)
+7)
Remaining components of the software are provided under a standard
2-term BSD licence with the following names as copyright holders:
@@ -178,31 +192,6 @@ OpenSSH contains no GPL code.
Kevin Steves
Daniel Kouril
Per Allansson
- Wesley Griffin
- Per Allansson
- Nils Nordman
- Simon Wilkinson
-
- Portable OpenSSH additionally includes code from the following copyright
- holders, also under the 2-term BSD license:
-
- Ben Lindstrom
- Tim Rice
- Andre Lucas
- Chris Adams
- Corinna Vinschen
- Cray Inc.
- Denis Parker
- Gert Doering
- Jakob Schlyter
- Jason Downs
- Juha Yrjölä
- Michael Stone
- Networks Associates Technology, Inc.
- Solar Designer
- Todd C. Miller
- Wayne Schroeder
- William Jones
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -223,110 +212,3 @@ OpenSSH contains no GPL code.
* 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.
-
-8) Portable OpenSSH contains the following additional licenses:
-
- a) md5crypt.c, md5crypt.h
-
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dknet.dk> wrote this file. As long as you retain this
- * notice you can do whatever you want with this stuff. If we meet
- * some day, and you think this stuff is worth it, you can buy me a
- * beer in return. Poul-Henning Kamp
-
- b) snprintf replacement
-
- * Copyright Patrick Powell 1995
- * This code is based on code written by Patrick Powell
- * (papowell@astart.com) It may be used for any purpose as long as this
- * notice remains intact on all source code distributions
-
- c) Compatibility code (openbsd-compat)
-
- Apart from the previously mentioned licenses, various pieces of code
- in the openbsd-compat/ subdirectory are licensed as follows:
-
- Some code is licensed under a 3-term BSD license, to the following
- copyright holders:
-
- Todd C. Miller
- Theo de Raadt
- Damien Miller
- Eric P. Allman
- The Regents of the University of California
-
- * 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. 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.
-
- Some code is licensed under an ISC-style license, to the following
- copyright holders:
-
- Internet Software Consortium.
- Todd C. Miller
-
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
- * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- Some code is licensed under a MIT-style license to the following
- copyright holders:
-
- Free Software Foundation, Inc.
-
- * Permission is hereby granted, free of charge, to any person obtaining a *
- * copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, distribute with modifications, sublicense, and/or sell *
- * copies of the Software, and to permit persons to whom the Software is *
- * furnished to do so, subject to the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be included *
- * in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
- * *
- * Except as contained in this notice, the name(s) of the above copyright *
- * holders shall not be used in advertising or otherwise to promote the *
- * sale, use or other dealings in this Software without prior written *
- * authorization. *
- ****************************************************************************/
-
-
-------
-$OpenBSD: LICENCE,v 1.17 2003/08/22 20:55:06 markus Exp $
diff --git a/crypto/openssh/Makefile b/crypto/openssh/Makefile
deleted file mode 100644
index 0b9c668..0000000
--- a/crypto/openssh/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $OpenBSD: Makefile,v 1.11 2002/05/23 19:24:30 markus Exp $
-
-.include <bsd.own.mk>
-
-SUBDIR= lib ssh sshd ssh-add ssh-keygen ssh-agent scp sftp-server \
- ssh-keysign ssh-keyscan sftp scard
-
-distribution:
- install -C -o root -g wheel -m 0644 ${.CURDIR}/ssh_config \
- ${DESTDIR}/etc/ssh/ssh_config
- install -C -o root -g wheel -m 0644 ${.CURDIR}/sshd_config \
- ${DESTDIR}/etc/ssh/sshd_config
-
-.include <bsd.subdir.mk>
diff --git a/crypto/openssh/README.openssh2 b/crypto/openssh/README.openssh2
deleted file mode 100644
index 12c90aa..0000000
--- 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/acconfig.h b/crypto/openssh/acconfig.h
index 9bfb9b6..be18366 100644
--- a/crypto/openssh/acconfig.h
+++ b/crypto/openssh/acconfig.h
@@ -1,28 +1,5 @@
-/* $Id: acconfig.h,v 1.166 2003/09/16 01:52:19 dtucker Exp $ */
-
-/*
- * Copyright (c) 1999-2003 Damien Miller. 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.
- */
+/* $Id: acconfig.h,v 1.149 2003/03/10 00:38:10 djm Exp $ */
+/* $FreeBSD$ */
#ifndef _CONFIG_H
#define _CONFIG_H
@@ -32,19 +9,9 @@
@TOP@
-/* Define if your platform breaks doing a seteuid before a setuid */
-#undef SETEUID_BREAKS_SETUID
-
-/* Define if your setreuid() is broken */
-#undef BROKEN_SETREUID
-
-/* Define if your setregid() is broken */
-#undef BROKEN_SETREGID
-
/* Define to a Set Process Title type if your system is */
/* supported by bsd-setproctitle.c */
#undef SPT_TYPE
-#undef SPT_PADCHAR
/* setgroups() NOOP allowed */
#undef SETGROUPS_NOOP
@@ -116,9 +83,6 @@
/* Define if you want to enable AIX4's authenticate function */
#undef WITH_AIXAUTHENTICATE
-/* Define if your AIX loginfailed() function takes 4 arguments (AIX >= 5.2) */
-#undef AIX_LOGINFAILED_4ARG
-
/* Define if you have/want arrays (cluster-wide session managment, not C arrays) */
#undef WITH_IRIX_ARRAY
@@ -238,18 +202,24 @@
/* Define if compiler implements __func__ */
#undef HAVE___func__
-/* Define this is you want GSSAPI support in the version 2 protocol */
-#undef GSSAPI
-
/* Define if you want Kerberos 5 support */
#undef KRB5
/* Define this if you are using the Heimdal version of Kerberos V5 */
#undef HEIMDAL
+/* Define if you want Kerberos 4 support */
+#undef KRB4
+
+/* Define if you want AFS support */
+#undef AFS
+
/* Define if you want S/Key support */
#undef SKEY
+/* Define if you want OPIE support */
+#undef OPIE
+
/* Define if you want TCP Wrappers support */
#undef LIBWRAP
@@ -329,6 +299,9 @@
/* Specify location of ssh.pid */
#undef _PATH_SSH_PIDDIR
+/* Use IPv4 for connection by default, IPv6 can still if explicity asked */
+#undef IPV4_DEFAULT
+
/* getaddrinfo is broken (if present) */
#undef BROKEN_GETADDRINFO
@@ -359,9 +332,6 @@
/* Define in your struct dirent expects you to allocate extra space for d_name */
#undef BROKEN_ONE_BYTE_DIRENT_D_NAME
-/* Define if your system has /etc/default/login */
-#undef HAVE_ETC_DEFAULT_LOGIN
-
/* Define if your getopt(3) defines and uses optreset */
#undef HAVE_GETOPT_OPTRESET
@@ -401,28 +371,15 @@
/* Silly mkstemp() */
#undef HAVE_STRICT_MKSTEMP
+/* Setproctitle emulation */
+#undef SETPROCTITLE_STRATEGY
+#undef SETPROCTITLE_PS_PADDING
+
/* Some systems put this outside of libc */
#undef HAVE_NANOSLEEP
-/* Define if sshd somehow reacquires a controlling TTY after setsid() */
-#undef SSHD_ACQUIRES_CTTY
-
-/* Define if cmsg_type is not passed correctly */
-#undef BROKEN_CMSG_TYPE
-
-/* Strings used in /etc/passwd to denote locked account */
-#undef LOCKED_PASSWD_STRING
-#undef LOCKED_PASSWD_PREFIX
-#undef LOCKED_PASSWD_SUBSTR
-
-/* Define if DNS support is to be activated */
-#undef DNS
-
-/* Define if getrrsetbyname() exists */
-#undef HAVE_GETRRSETBYNAME
-
-/* Define if HEADER.ad exists in arpa/nameser.h */
-#undef HAVE_HEADER_AD
+/* Pushing STREAMS modules incorrectly acquires a controlling TTY */
+#undef STREAMS_PUSH_ACQUIRES_CTTY
@BOTTOM@
diff --git a/crypto/openssh/auth-chall.c b/crypto/openssh/auth-chall.c
index 00d6e0e..6fff892 100644
--- a/crypto/openssh/auth-chall.c
+++ b/crypto/openssh/auth-chall.c
@@ -24,6 +24,7 @@
#include "includes.h"
RCSID("$OpenBSD: auth-chall.c,v 1.8 2001/05/18 14:13:28 markus Exp $");
+RCSID("$FreeBSD$");
#include "auth.h"
#include "log.h"
diff --git a/crypto/openssh/auth-krb5.c b/crypto/openssh/auth-krb5.c
index 713b6da..dbd4163 100644
--- a/crypto/openssh/auth-krb5.c
+++ b/crypto/openssh/auth-krb5.c
@@ -1,7 +1,7 @@
/*
* Kerberos v5 authentication and ticket-passing routines.
*
- * $FreeBSD$
+ * $xFreeBSD: src/crypto/openssh/auth-krb5.c,v 1.6 2001/02/13 16:58:04 assar Exp$
*/
/*
* Copyright (c) 2002 Daniel Kouril. All rights reserved.
@@ -28,7 +28,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth-krb5.c,v 1.12 2003/08/28 12:54:34 markus Exp $");
+RCSID("$OpenBSD: auth-krb5.c,v 1.10 2002/11/21 23:03:51 deraadt Exp $");
+RCSID("$FreeBSD$");
#include "ssh.h"
#include "ssh1.h"
@@ -40,8 +41,10 @@ RCSID("$OpenBSD: auth-krb5.c,v 1.12 2003/08/28 12:54:34 markus Exp $");
#include "auth.h"
#ifdef KRB5
-
#include <krb5.h>
+#ifndef HEIMDAL
+#define krb5_get_err_text(context,code) error_message(code)
+#endif /* !HEIMDAL */
extern ServerOptions options;
@@ -65,6 +68,193 @@ krb5_init(void *context)
return (0);
}
+/*
+ * Try krb5 authentication. server_user is passed for logging purposes
+ * only, in auth is received ticket, in client is returned principal
+ * from the ticket
+ */
+int
+auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *reply)
+{
+ krb5_error_code problem;
+ krb5_principal server;
+ krb5_ticket *ticket;
+ int fd, ret;
+
+ ret = 0;
+ server = NULL;
+ ticket = NULL;
+ reply->length = 0;
+
+ problem = krb5_init(authctxt);
+ if (problem)
+ goto err;
+
+ problem = krb5_auth_con_init(authctxt->krb5_ctx,
+ &authctxt->krb5_auth_ctx);
+ if (problem)
+ goto err;
+
+ fd = packet_get_connection_in();
+#ifdef HEIMDAL
+ problem = krb5_auth_con_setaddrs_from_fd(authctxt->krb5_ctx,
+ authctxt->krb5_auth_ctx, &fd);
+#else
+ problem = krb5_auth_con_genaddrs(authctxt->krb5_ctx,
+ authctxt->krb5_auth_ctx,fd,
+ KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR |
+ KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR);
+#endif
+ if (problem)
+ goto err;
+
+ problem = krb5_sname_to_principal(authctxt->krb5_ctx, NULL, NULL,
+ KRB5_NT_SRV_HST, &server);
+ if (problem)
+ goto err;
+
+ problem = krb5_rd_req(authctxt->krb5_ctx, &authctxt->krb5_auth_ctx,
+ auth, server, NULL, NULL, &ticket);
+ if (problem)
+ goto err;
+
+#ifdef HEIMDAL
+ problem = krb5_copy_principal(authctxt->krb5_ctx, ticket->client,
+ &authctxt->krb5_user);
+#else
+ problem = krb5_copy_principal(authctxt->krb5_ctx,
+ ticket->enc_part2->client,
+ &authctxt->krb5_user);
+#endif
+ if (problem)
+ goto err;
+
+ /* if client wants mutual auth */
+ problem = krb5_mk_rep(authctxt->krb5_ctx, authctxt->krb5_auth_ctx,
+ reply);
+ if (problem)
+ goto err;
+
+ /* Check .k5login authorization now. */
+ if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user,
+ authctxt->pw->pw_name))
+ goto err;
+
+ if (client)
+ krb5_unparse_name(authctxt->krb5_ctx, authctxt->krb5_user,
+ client);
+
+ ret = 1;
+ err:
+ if (server)
+ krb5_free_principal(authctxt->krb5_ctx, server);
+ if (ticket)
+ krb5_free_ticket(authctxt->krb5_ctx, ticket);
+ if (!ret && reply->length) {
+ xfree(reply->data);
+ memset(reply, 0, sizeof(*reply));
+ }
+
+ if (problem) {
+ if (authctxt->krb5_ctx != NULL)
+ debug("Kerberos v5 authentication failed: %s",
+ krb5_get_err_text(authctxt->krb5_ctx, problem));
+ else
+ debug("Kerberos v5 authentication failed: %d",
+ problem);
+ }
+
+ return (ret);
+}
+
+int
+auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt)
+{
+ krb5_error_code problem;
+ krb5_ccache ccache = NULL;
+ char *pname;
+ krb5_creds **creds;
+
+ if (authctxt->pw == NULL || authctxt->krb5_user == NULL)
+ return (0);
+
+ temporarily_use_uid(authctxt->pw);
+
+#ifdef HEIMDAL
+ problem = krb5_cc_gen_new(authctxt->krb5_ctx, &krb5_fcc_ops, &ccache);
+#else
+{
+ char ccname[40];
+ int tmpfd;
+
+ snprintf(ccname,sizeof(ccname),"FILE:/tmp/krb5cc_%d_XXXXXX",geteuid());
+
+ if ((tmpfd = mkstemp(ccname+strlen("FILE:")))==-1) {
+ log("mkstemp(): %.100s", strerror(errno));
+ problem = errno;
+ goto fail;
+ }
+ if (fchmod(tmpfd,S_IRUSR | S_IWUSR) == -1) {
+ log("fchmod(): %.100s", strerror(errno));
+ close(tmpfd);
+ problem = errno;
+ goto fail;
+ }
+ close(tmpfd);
+ problem = krb5_cc_resolve(authctxt->krb5_ctx, ccname, &ccache);
+}
+#endif
+ if (problem)
+ goto fail;
+
+ problem = krb5_cc_initialize(authctxt->krb5_ctx, ccache,
+ authctxt->krb5_user);
+ if (problem)
+ goto fail;
+
+#ifdef HEIMDAL
+ problem = krb5_rd_cred2(authctxt->krb5_ctx, authctxt->krb5_auth_ctx,
+ ccache, tgt);
+ if (problem)
+ goto fail;
+#else
+ problem = krb5_rd_cred(authctxt->krb5_ctx, authctxt->krb5_auth_ctx,
+ tgt, &creds, NULL);
+ if (problem)
+ goto fail;
+ problem = krb5_cc_store_cred(authctxt->krb5_ctx, ccache, *creds);
+ if (problem)
+ goto fail;
+#endif
+
+ authctxt->krb5_fwd_ccache = ccache;
+ ccache = NULL;
+
+ authctxt->krb5_ticket_file = (char *)krb5_cc_get_name(authctxt->krb5_ctx, authctxt->krb5_fwd_ccache);
+
+ problem = krb5_unparse_name(authctxt->krb5_ctx, authctxt->krb5_user,
+ &pname);
+ if (problem)
+ goto fail;
+
+ debug("Kerberos v5 TGT accepted (%s)", pname);
+
+ restore_uid();
+
+ return (1);
+
+ fail:
+ if (problem)
+ debug("Kerberos v5 TGT passing failed: %s",
+ krb5_get_err_text(authctxt->krb5_ctx, problem));
+ if (ccache)
+ krb5_cc_destroy(authctxt->krb5_ctx, ccache);
+
+ restore_uid();
+
+ return (0);
+}
+
int
auth_krb5_password(Authctxt *authctxt, const char *password)
{
@@ -75,7 +265,6 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
int tmpfd;
#endif
krb5_error_code problem;
- krb5_ccache ccache = NULL;
if (authctxt->pw == NULL)
return (0);
@@ -92,35 +281,23 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
goto out;
#ifdef HEIMDAL
- problem = krb5_cc_gen_new(authctxt->krb5_ctx, &krb5_mcc_ops, &ccache);
+ problem = krb5_cc_gen_new(authctxt->krb5_ctx, &krb5_mcc_ops,
+ &authctxt->krb5_fwd_ccache);
if (problem)
goto out;
- problem = krb5_cc_initialize(authctxt->krb5_ctx, ccache,
- authctxt->krb5_user);
+ problem = krb5_cc_initialize(authctxt->krb5_ctx,
+ authctxt->krb5_fwd_ccache, authctxt->krb5_user);
if (problem)
goto out;
restore_uid();
-
problem = krb5_verify_user(authctxt->krb5_ctx, authctxt->krb5_user,
- ccache, password, 1, NULL);
-
+ authctxt->krb5_fwd_ccache, password, 1, NULL);
temporarily_use_uid(authctxt->pw);
if (problem)
goto out;
- problem = krb5_cc_gen_new(authctxt->krb5_ctx, &krb5_fcc_ops,
- &authctxt->krb5_fwd_ccache);
- if (problem)
- goto out;
-
- problem = krb5_cc_copy_cache(authctxt->krb5_ctx, ccache,
- authctxt->krb5_fwd_ccache);
- krb5_cc_destroy(authctxt->krb5_ctx, ccache);
- ccache = NULL;
- if (problem)
- goto out;
#else
problem = krb5_get_init_creds_password(authctxt->krb5_ctx, &creds,
@@ -150,13 +327,13 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
snprintf(ccname,sizeof(ccname),"FILE:/tmp/krb5cc_%d_XXXXXX",geteuid());
if ((tmpfd = mkstemp(ccname+strlen("FILE:")))==-1) {
- logit("mkstemp(): %.100s", strerror(errno));
+ log("mkstemp(): %.100s", strerror(errno));
problem = errno;
goto out;
}
if (fchmod(tmpfd,S_IRUSR | S_IWUSR) == -1) {
- logit("fchmod(): %.100s", strerror(errno));
+ log("fchmod(): %.100s", strerror(errno));
close(tmpfd);
problem = errno;
goto out;
@@ -184,9 +361,6 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
restore_uid();
if (problem) {
- if (ccache)
- krb5_cc_destroy(authctxt->krb5_ctx, ccache);
-
if (authctxt->krb5_ctx != NULL && problem!=-1)
debug("Kerberos password authentication failed: %s",
krb5_get_err_text(authctxt->krb5_ctx, problem));
@@ -218,6 +392,11 @@ krb5_cleanup_proc(void *context)
krb5_free_principal(authctxt->krb5_ctx, authctxt->krb5_user);
authctxt->krb5_user = NULL;
}
+ if (authctxt->krb5_auth_ctx) {
+ krb5_auth_con_free(authctxt->krb5_ctx,
+ authctxt->krb5_auth_ctx);
+ authctxt->krb5_auth_ctx = NULL;
+ }
if (authctxt->krb5_ctx) {
krb5_free_context(authctxt->krb5_ctx);
authctxt->krb5_ctx = NULL;
diff --git a/crypto/openssh/auth-pam.c b/crypto/openssh/auth-pam.c
index e2c364e..fe9570f 100644
--- a/crypto/openssh/auth-pam.c
+++ b/crypto/openssh/auth-pam.c
@@ -1,11 +1,5 @@
-/*-
- * 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.
+/*
+ * Copyright (c) 2000 Damien Miller. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -16,730 +10,446 @@
* 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 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.
+ * 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.
*/
-/* Based on $FreeBSD$ */
#include "includes.h"
-RCSID("$Id: auth-pam.c,v 1.72.2.2 2003/09/23 09:24:21 djm Exp $");
#ifdef USE_PAM
-#include <security/pam_appl.h>
-
+#include "xmalloc.h"
+#include "log.h"
#include "auth.h"
+#include "auth-options.h"
#include "auth-pam.h"
-#include "buffer.h"
-#include "bufaux.h"
+#include "servconf.h"
#include "canohost.h"
-#include "log.h"
-#include "monitor_wrap.h"
-#include "msg.h"
-#include "packet.h"
#include "readpass.h"
-#include "servconf.h"
-#include "ssh2.h"
-#include "xmalloc.h"
-#include "auth-options.h"
-extern ServerOptions options;
+extern char *__progname;
-#define __unused
+extern int use_privsep;
-#ifdef USE_POSIX_THREADS
-#include <pthread.h>
-/*
- * Avoid namespace clash when *not* using pthreads for systems *with*
- * pthreads, which unconditionally define pthread_t via sys/types.h
- * (e.g. Linux)
- */
-typedef pthread_t sp_pthread_t;
-#else
-/*
- * Simulate threads with processes.
- */
-typedef pid_t sp_pthread_t;
+RCSID("$Id: auth-pam.c,v 1.55 2003/01/22 04:42:26 djm Exp $");
-static void
-pthread_exit(void *value __unused)
-{
- _exit(0);
-}
+#define NEW_AUTHTOK_MSG \
+ "Warning: Your password has expired, please change it now."
+#define NEW_AUTHTOK_MSG_PRIVSEP \
+ "Your password has expired, the session cannot proceed."
-static int
-pthread_create(sp_pthread_t *thread, const void *attr __unused,
- void *(*thread_start)(void *), void *arg)
-{
- pid_t pid;
-
- switch ((pid = fork())) {
- case -1:
- error("fork(): %s", strerror(errno));
- return (-1);
- case 0:
- thread_start(arg);
- _exit(1);
- default:
- *thread = pid;
- return (0);
- }
-}
+static int do_pam_conversation(int num_msg, const struct pam_message **msg,
+ struct pam_response **resp, void *appdata_ptr);
-static int
-pthread_cancel(sp_pthread_t thread)
+/* module-local variables */
+static struct pam_conv conv = {
+ (int (*)())do_pam_conversation,
+ NULL
+};
+static char *__pam_msg = NULL;
+static pam_handle_t *__pamh = NULL;
+static const char *__pampasswd = NULL;
+
+/* states for do_pam_conversation() */
+enum { INITIAL_LOGIN, OTHER } pamstate = INITIAL_LOGIN;
+/* remember whether pam_acct_mgmt() returned PAM_NEW_AUTHTOK_REQD */
+static int password_change_required = 0;
+/* remember whether the last pam_authenticate() succeeded or not */
+static int was_authenticated = 0;
+
+/* Remember what has been initialised */
+static int session_opened = 0;
+static int creds_set = 0;
+
+/* accessor which allows us to switch conversation structs according to
+ * the authentication method being used */
+void do_pam_set_conv(struct pam_conv *conv)
{
- return (kill(thread, SIGTERM));
+ pam_set_item(__pamh, PAM_CONV, conv);
}
-static int
-pthread_join(sp_pthread_t thread, void **value __unused)
+/* start an authentication run */
+int do_pam_authenticate(int flags)
{
- int status;
-
- waitpid(thread, &status, 0);
- return (status);
+ int retval = pam_authenticate(__pamh, flags);
+ was_authenticated = (retval == PAM_SUCCESS);
+ return retval;
}
-#endif
-
-
-static pam_handle_t *sshpam_handle = NULL;
-static int sshpam_err = 0;
-static int sshpam_authenticated = 0;
-static int sshpam_new_authtok_reqd = 0;
-static int sshpam_session_open = 0;
-static int sshpam_cred_established = 0;
-
-struct pam_ctxt {
- sp_pthread_t pam_thread;
- int pam_psock;
- int pam_csock;
- int pam_done;
-};
-
-static void sshpam_free_ctx(void *);
/*
- * Conversation function for authentication thread.
+ * PAM conversation function.
+ * There are two states this can run in.
+ *
+ * INITIAL_LOGIN mode simply feeds the password from the client into
+ * PAM in response to PAM_PROMPT_ECHO_OFF, and collects output
+ * messages with into __pam_msg. This is used during initial
+ * authentication to bypass the normal PAM password prompt.
+ *
+ * OTHER mode handles PAM_PROMPT_ECHO_OFF with read_passphrase()
+ * and outputs messages to stderr. This mode is used if pam_chauthtok()
+ * is called to update expired passwords.
*/
-static int
-sshpam_thread_conv(int n, const struct pam_message **msg,
- struct pam_response **resp, void *data)
+static int do_pam_conversation(int num_msg, const struct pam_message **msg,
+ struct pam_response **resp, void *appdata_ptr)
{
- Buffer buffer;
- struct pam_ctxt *ctxt;
struct pam_response *reply;
- int i;
-
- *resp = NULL;
-
- ctxt = data;
- if (n <= 0 || n > PAM_MAX_NUM_MSG)
- return (PAM_CONV_ERR);
-
- if ((reply = malloc(n * sizeof(*reply))) == NULL)
- return (PAM_CONV_ERR);
- memset(reply, 0, n * sizeof(*reply));
-
- buffer_init(&buffer);
- for (i = 0; i < n; ++i) {
- switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
- case PAM_PROMPT_ECHO_OFF:
- buffer_put_cstring(&buffer,
- PAM_MSG_MEMBER(msg, i, msg));
- ssh_msg_send(ctxt->pam_csock,
- PAM_MSG_MEMBER(msg, i, msg_style), &buffer);
- ssh_msg_recv(ctxt->pam_csock, &buffer);
- if (buffer_get_char(&buffer) != PAM_AUTHTOK)
- goto fail;
- reply[i].resp = buffer_get_string(&buffer, NULL);
- break;
- case PAM_PROMPT_ECHO_ON:
- buffer_put_cstring(&buffer,
- PAM_MSG_MEMBER(msg, i, msg));
- ssh_msg_send(ctxt->pam_csock,
- PAM_MSG_MEMBER(msg, i, msg_style), &buffer);
- ssh_msg_recv(ctxt->pam_csock, &buffer);
- if (buffer_get_char(&buffer) != PAM_AUTHTOK)
- goto fail;
- reply[i].resp = buffer_get_string(&buffer, NULL);
- break;
- case PAM_ERROR_MSG:
- buffer_put_cstring(&buffer,
- PAM_MSG_MEMBER(msg, i, msg));
- ssh_msg_send(ctxt->pam_csock,
- PAM_MSG_MEMBER(msg, i, msg_style), &buffer);
- break;
- case PAM_TEXT_INFO:
- buffer_put_cstring(&buffer,
- PAM_MSG_MEMBER(msg, i, msg));
- ssh_msg_send(ctxt->pam_csock,
- PAM_MSG_MEMBER(msg, i, msg_style), &buffer);
- break;
- default:
- goto fail;
+ int count;
+ char buf[1024];
+
+ /* PAM will free this later */
+ reply = xmalloc(num_msg * sizeof(*reply));
+
+ for (count = 0; count < num_msg; count++) {
+ if (pamstate == INITIAL_LOGIN) {
+ /*
+ * We can't use stdio yet, queue messages for
+ * printing later
+ */
+ switch(PAM_MSG_MEMBER(msg, count, msg_style)) {
+ case PAM_PROMPT_ECHO_ON:
+ xfree(reply);
+ return PAM_CONV_ERR;
+ case PAM_PROMPT_ECHO_OFF:
+ if (__pampasswd == NULL) {
+ xfree(reply);
+ return PAM_CONV_ERR;
+ }
+ reply[count].resp = xstrdup(__pampasswd);
+ reply[count].resp_retcode = PAM_SUCCESS;
+ break;
+ case PAM_ERROR_MSG:
+ case PAM_TEXT_INFO:
+ if (PAM_MSG_MEMBER(msg, count, msg) != NULL) {
+ message_cat(&__pam_msg,
+ PAM_MSG_MEMBER(msg, count, msg));
+ }
+ reply[count].resp = xstrdup("");
+ reply[count].resp_retcode = PAM_SUCCESS;
+ break;
+ default:
+ xfree(reply);
+ return PAM_CONV_ERR;
+ }
+ } else {
+ /*
+ * stdio is connected, so interact directly
+ */
+ switch(PAM_MSG_MEMBER(msg, count, msg_style)) {
+ case PAM_PROMPT_ECHO_ON:
+ fputs(PAM_MSG_MEMBER(msg, count, msg), stderr);
+ fgets(buf, sizeof(buf), stdin);
+ reply[count].resp = xstrdup(buf);
+ reply[count].resp_retcode = PAM_SUCCESS;
+ break;
+ case PAM_PROMPT_ECHO_OFF:
+ reply[count].resp =
+ read_passphrase(PAM_MSG_MEMBER(msg, count,
+ msg), RP_ALLOW_STDIN);
+ reply[count].resp_retcode = PAM_SUCCESS;
+ break;
+ case PAM_ERROR_MSG:
+ case PAM_TEXT_INFO:
+ if (PAM_MSG_MEMBER(msg, count, msg) != NULL)
+ fprintf(stderr, "%s\n",
+ PAM_MSG_MEMBER(msg, count, msg));
+ reply[count].resp = xstrdup("");
+ reply[count].resp_retcode = PAM_SUCCESS;
+ break;
+ default:
+ xfree(reply);
+ return PAM_CONV_ERR;
+ }
}
- buffer_clear(&buffer);
}
- buffer_free(&buffer);
+
*resp = reply;
- return (PAM_SUCCESS);
- fail:
- for(i = 0; i < n; i++) {
- if (reply[i].resp != NULL)
- xfree(reply[i].resp);
- }
- xfree(reply);
- buffer_free(&buffer);
- return (PAM_CONV_ERR);
+ return PAM_SUCCESS;
}
-/*
- * Authentication thread.
- */
-static void *
-sshpam_thread(void *ctxtp)
+/* Called at exit to cleanly shutdown PAM */
+void do_pam_cleanup_proc(void *context)
{
- struct pam_ctxt *ctxt = ctxtp;
- Buffer buffer;
- struct pam_conv sshpam_conv;
-#ifndef USE_POSIX_THREADS
- const char *pam_user;
-
- pam_get_item(sshpam_handle, PAM_USER, (const void **)&pam_user);
- setproctitle("%s [pam]", pam_user);
-#endif
+ int pam_retval = PAM_SUCCESS;
- sshpam_conv.conv = sshpam_thread_conv;
- sshpam_conv.appdata_ptr = ctxt;
-
- buffer_init(&buffer);
- sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
- (const void *)&sshpam_conv);
- if (sshpam_err != PAM_SUCCESS)
- goto auth_fail;
- sshpam_err = pam_authenticate(sshpam_handle, 0);
- if (sshpam_err != PAM_SUCCESS)
- goto auth_fail;
- buffer_put_cstring(&buffer, "OK");
- ssh_msg_send(ctxt->pam_csock, sshpam_err, &buffer);
- buffer_free(&buffer);
- pthread_exit(NULL);
-
- auth_fail:
- buffer_put_cstring(&buffer,
- pam_strerror(sshpam_handle, sshpam_err));
- ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer);
- buffer_free(&buffer);
- pthread_exit(NULL);
-
- return (NULL); /* Avoid warning for non-pthread case */
-}
+ if (__pamh && session_opened) {
+ pam_retval = pam_close_session(__pamh, 0);
+ if (pam_retval != PAM_SUCCESS)
+ log("Cannot close PAM session[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+ }
-static void
-sshpam_thread_cleanup(void *ctxtp)
-{
- struct pam_ctxt *ctxt = ctxtp;
+ if (__pamh && creds_set) {
+ pam_retval = pam_setcred(__pamh, PAM_DELETE_CRED);
+ if (pam_retval != PAM_SUCCESS)
+ debug("Cannot delete credentials[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+ }
- pthread_cancel(ctxt->pam_thread);
- pthread_join(ctxt->pam_thread, NULL);
- close(ctxt->pam_psock);
- close(ctxt->pam_csock);
+ if (__pamh) {
+ pam_retval = pam_end(__pamh, pam_retval);
+ if (pam_retval != PAM_SUCCESS)
+ log("Cannot release PAM authentication[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+ }
}
-static int
-sshpam_null_conv(int n, const struct pam_message **msg,
- struct pam_response **resp, void *data)
+/* Attempt password authentation using PAM */
+int auth_pam_password(Authctxt *authctxt, const char *password)
{
- return (PAM_CONV_ERR);
-}
+ extern ServerOptions options;
+ int pam_retval;
+ struct passwd *pw = authctxt->pw;
-static struct pam_conv null_conv = { sshpam_null_conv, NULL };
+ do_pam_set_conv(&conv);
-static void
-sshpam_cleanup(void *arg)
-{
- (void)arg;
- debug("PAM: cleanup");
- if (sshpam_handle == NULL)
- return;
- pam_set_item(sshpam_handle, PAM_CONV, (const void *)&null_conv);
- if (sshpam_cred_established) {
- pam_setcred(sshpam_handle, PAM_DELETE_CRED);
- sshpam_cred_established = 0;
- }
- if (sshpam_session_open) {
- pam_close_session(sshpam_handle, PAM_SILENT);
- sshpam_session_open = 0;
- }
- sshpam_authenticated = sshpam_new_authtok_reqd = 0;
- pam_end(sshpam_handle, sshpam_err);
- sshpam_handle = NULL;
-}
+ __pampasswd = password;
-static int
-sshpam_init(const char *user)
-{
- extern u_int utmp_len;
- extern char *__progname;
- const char *pam_rhost, *pam_user;
-
- if (sshpam_handle != NULL) {
- /* We already have a PAM context; check if the user matches */
- sshpam_err = pam_get_item(sshpam_handle,
- PAM_USER, (const void **)&pam_user);
- if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0)
- return (0);
- fatal_remove_cleanup(sshpam_cleanup, NULL);
- pam_end(sshpam_handle, sshpam_err);
- sshpam_handle = NULL;
- }
- debug("PAM: initializing for \"%s\"", user);
- sshpam_err =
- pam_start(SSHD_PAM_SERVICE, user, &null_conv, &sshpam_handle);
- if (sshpam_err != PAM_SUCCESS) {
- pam_end(sshpam_handle, sshpam_err);
- sshpam_handle = NULL;
- return (-1);
- }
- pam_rhost = get_remote_name_or_ip(utmp_len, options.use_dns);
- debug("PAM: setting PAM_RHOST to \"%s\"", pam_rhost);
- sshpam_err = pam_set_item(sshpam_handle, PAM_RHOST, pam_rhost);
- if (sshpam_err != PAM_SUCCESS) {
- pam_end(sshpam_handle, sshpam_err);
- sshpam_handle = NULL;
- return (-1);
- }
-#ifdef PAM_TTY_KLUDGE
- /*
- * Some silly PAM modules (e.g. pam_time) require a TTY to operate.
- * sshd doesn't set the tty until too late in the auth process and
- * may not even set one (for tty-less connections)
- */
- debug("PAM: setting PAM_TTY to \"ssh\"");
- sshpam_err = pam_set_item(sshpam_handle, PAM_TTY, "ssh");
- if (sshpam_err != PAM_SUCCESS) {
- pam_end(sshpam_handle, sshpam_err);
- sshpam_handle = NULL;
- return (-1);
+ pamstate = INITIAL_LOGIN;
+ pam_retval = do_pam_authenticate(
+ options.permit_empty_passwd == 0 ? PAM_DISALLOW_NULL_AUTHTOK : 0);
+ if (pam_retval == PAM_SUCCESS) {
+ debug("PAM Password authentication accepted for "
+ "user \"%.100s\"", pw->pw_name);
+ return 1;
+ } else {
+ debug("PAM Password authentication for \"%.100s\" "
+ "failed[%d]: %s", pw->pw_name, pam_retval,
+ PAM_STRERROR(__pamh, pam_retval));
+ return 0;
}
-#endif
- fatal_add_cleanup(sshpam_cleanup, NULL);
- return (0);
}
-static void *
-sshpam_init_ctx(Authctxt *authctxt)
+/* Do account management using PAM */
+int do_pam_account(char *username, char *remote_user)
{
- struct pam_ctxt *ctxt;
- int socks[2];
-
- /* Refuse to start if we don't have PAM enabled */
- if (!options.use_pam)
- return NULL;
-
- /* Initialize PAM */
- if (sshpam_init(authctxt->user) == -1) {
- error("PAM: initialization failed");
- return (NULL);
- }
+ int pam_retval;
- ctxt = xmalloc(sizeof *ctxt);
- ctxt->pam_done = 0;
+ do_pam_set_conv(&conv);
- /* Start the authentication thread */
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
- error("PAM: failed create sockets: %s", strerror(errno));
- xfree(ctxt);
- return (NULL);
+ if (remote_user) {
+ debug("PAM setting ruser to \"%.200s\"", remote_user);
+ pam_retval = pam_set_item(__pamh, PAM_RUSER, remote_user);
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM set ruser failed[%d]: %.200s", pam_retval,
+ PAM_STRERROR(__pamh, pam_retval));
}
- ctxt->pam_psock = socks[0];
- ctxt->pam_csock = socks[1];
- if (pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) {
- error("PAM: failed to start authentication thread: %s",
- strerror(errno));
- close(socks[0]);
- close(socks[1]);
- xfree(ctxt);
- return (NULL);
- }
- fatal_add_cleanup(sshpam_thread_cleanup, ctxt);
- return (ctxt);
-}
-static int
-sshpam_query(void *ctx, char **name, char **info,
- u_int *num, char ***prompts, u_int **echo_on)
-{
- Buffer buffer;
- struct pam_ctxt *ctxt = ctx;
- size_t plen;
- u_char type;
- char *msg;
- size_t len;
-
- buffer_init(&buffer);
- *name = xstrdup("");
- *info = xstrdup("");
- *prompts = xmalloc(sizeof(char *));
- **prompts = NULL;
- plen = 0;
- *echo_on = xmalloc(sizeof(u_int));
- while (ssh_msg_recv(ctxt->pam_psock, &buffer) == 0) {
- type = buffer_get_char(&buffer);
- msg = buffer_get_string(&buffer, NULL);
- switch (type) {
- case PAM_PROMPT_ECHO_ON:
- case PAM_PROMPT_ECHO_OFF:
- *num = 1;
- len = plen + strlen(msg) + 1;
- **prompts = xrealloc(**prompts, len);
- plen += snprintf(**prompts + plen, len, "%s", msg);
- **echo_on = (type == PAM_PROMPT_ECHO_ON);
- xfree(msg);
- return (0);
- case PAM_ERROR_MSG:
- case PAM_TEXT_INFO:
- /* accumulate messages */
- len = plen + strlen(msg) + 1;
- **prompts = xrealloc(**prompts, len);
- plen += snprintf(**prompts + plen, len, "%s", msg);
- xfree(msg);
- break;
+ pam_retval = pam_acct_mgmt(__pamh, 0);
+ debug2("pam_acct_mgmt() = %d", pam_retval);
+ switch (pam_retval) {
case PAM_SUCCESS:
- case PAM_AUTH_ERR:
- if (**prompts != NULL) {
- /* drain any accumulated messages */
-#if 0 /* XXX - not compatible with privsep */
- packet_start(SSH2_MSG_USERAUTH_BANNER);
- packet_put_cstring(**prompts);
- packet_put_cstring("");
- packet_send();
- packet_write_wait();
+ /* This is what we want */
+ break;
+#if 0
+ case PAM_NEW_AUTHTOK_REQD:
+ message_cat(&__pam_msg, use_privsep ?
+ NEW_AUTHTOK_MSG_PRIVSEP : NEW_AUTHTOK_MSG);
+ /* flag that password change is necessary */
+ password_change_required = 1;
+ /* disallow other functionality for now */
+ no_port_forwarding_flag |= 2;
+ no_agent_forwarding_flag |= 2;
+ no_x11_forwarding_flag |= 2;
+ break;
#endif
- xfree(**prompts);
- **prompts = NULL;
- }
- if (type == PAM_SUCCESS) {
- *num = 0;
- **echo_on = 0;
- ctxt->pam_done = 1;
- xfree(msg);
- return (0);
- }
- error("PAM: %s", msg);
default:
- *num = 0;
- **echo_on = 0;
- xfree(msg);
- ctxt->pam_done = -1;
- return (-1);
- }
+ log("PAM rejected by account configuration[%d]: "
+ "%.200s", pam_retval, PAM_STRERROR(__pamh,
+ pam_retval));
+ return(0);
}
- return (-1);
-}
-/* XXX - see also comment in auth-chall.c:verify_response */
-static int
-sshpam_respond(void *ctx, u_int num, char **resp)
-{
- Buffer buffer;
- struct pam_ctxt *ctxt = ctx;
-
- debug2("PAM: %s", __func__);
- switch (ctxt->pam_done) {
- case 1:
- sshpam_authenticated = 1;
- return (0);
- case 0:
- break;
- default:
- return (-1);
- }
- if (num != 1) {
- error("PAM: expected one response, got %u", num);
- return (-1);
- }
- buffer_init(&buffer);
- buffer_put_cstring(&buffer, *resp);
- ssh_msg_send(ctxt->pam_psock, PAM_AUTHTOK, &buffer);
- buffer_free(&buffer);
- return (1);
+ return(1);
}
-static void
-sshpam_free_ctx(void *ctxtp)
+/* Do PAM-specific session initialisation */
+void do_pam_session(char *username, const char *ttyname)
{
- struct pam_ctxt *ctxt = ctxtp;
+ int pam_retval;
- fatal_remove_cleanup(sshpam_thread_cleanup, ctxt);
- sshpam_thread_cleanup(ctxtp);
- xfree(ctxt);
- /*
- * We don't call sshpam_cleanup() here because we may need the PAM
- * handle at a later stage, e.g. when setting up a session. It's
- * still on the cleanup list, so pam_end() *will* be called before
- * the server process terminates.
- */
-}
+ do_pam_set_conv(&conv);
-KbdintDevice sshpam_device = {
- "pam",
- sshpam_init_ctx,
- sshpam_query,
- sshpam_respond,
- sshpam_free_ctx
-};
-
-KbdintDevice mm_sshpam_device = {
- "pam",
- mm_sshpam_init_ctx,
- mm_sshpam_query,
- mm_sshpam_respond,
- mm_sshpam_free_ctx
-};
+ if (ttyname != NULL) {
+ debug("PAM setting tty to \"%.200s\"", ttyname);
+ pam_retval = pam_set_item(__pamh, PAM_TTY, ttyname);
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM set tty failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+ }
-/*
- * This replaces auth-pam.c
- */
-void
-start_pam(const char *user)
-{
- if (!options.use_pam)
- fatal("PAM: initialisation requested when UsePAM=no");
+ pam_retval = pam_open_session(__pamh, 0);
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM session setup failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
- if (sshpam_init(user) == -1)
- fatal("PAM: initialisation failed");
+ session_opened = 1;
}
-void
-finish_pam(void)
+/* Set PAM credentials */
+void do_pam_setcred(int init)
{
- fatal_remove_cleanup(sshpam_cleanup, NULL);
- sshpam_cleanup(NULL);
-}
+ int pam_retval;
-u_int
-do_pam_account(void)
-{
- sshpam_err = pam_acct_mgmt(sshpam_handle, 0);
- debug3("%s: pam_acct_mgmt = %d", __func__, sshpam_err);
-
- if (sshpam_err != PAM_SUCCESS && sshpam_err != PAM_NEW_AUTHTOK_REQD)
- return (0);
-
- if (sshpam_err == PAM_NEW_AUTHTOK_REQD) {
- sshpam_new_authtok_reqd = 1;
-
- /* Prevent forwardings until password changed */
- no_port_forwarding_flag |= 2;
- no_agent_forwarding_flag |= 2;
- no_x11_forwarding_flag |= 2;
- }
+ if (__pamh == NULL)
+ return;
- return (1);
+ do_pam_set_conv(&conv);
+
+ debug("PAM establishing creds");
+ pam_retval = pam_setcred(__pamh,
+ init ? PAM_ESTABLISH_CRED : PAM_REINITIALIZE_CRED);
+ if (pam_retval != PAM_SUCCESS) {
+ if (was_authenticated)
+ fatal("PAM setcred failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+ else
+ debug("PAM setcred failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+ } else
+ creds_set = 1;
}
-void
-do_pam_session(void)
+/* accessor function for file scope static variable */
+int is_pam_password_change_required(void)
{
- sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
- (const void *)&null_conv);
- if (sshpam_err != PAM_SUCCESS)
- fatal("PAM: failed to set PAM_CONV: %s",
- pam_strerror(sshpam_handle, sshpam_err));
- sshpam_err = pam_open_session(sshpam_handle, 0);
- if (sshpam_err != PAM_SUCCESS)
- fatal("PAM: pam_open_session(): %s",
- pam_strerror(sshpam_handle, sshpam_err));
- sshpam_session_open = 1;
+ return password_change_required;
}
-void
-do_pam_set_tty(const char *tty)
+/*
+ * Have user change authentication token if pam_acct_mgmt() indicated
+ * it was expired. This needs to be called after an interactive
+ * session is established and the user's pty is connected to
+ * stdin/stdout/stderr.
+ */
+void do_pam_chauthtok(void)
{
- if (tty != NULL) {
- debug("PAM: setting PAM_TTY to \"%s\"", tty);
- sshpam_err = pam_set_item(sshpam_handle, PAM_TTY, tty);
- if (sshpam_err != PAM_SUCCESS)
- fatal("PAM: failed to set PAM_TTY: %s",
- pam_strerror(sshpam_handle, sshpam_err));
+ int pam_retval;
+
+ do_pam_set_conv(&conv);
+
+ if (password_change_required) {
+ if (use_privsep)
+ fatal("Password changing is currently unsupported"
+ " with privilege separation");
+ pamstate = OTHER;
+ pam_retval = pam_chauthtok(__pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM pam_chauthtok failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+#if 0
+ /* XXX: This would need to be done in the parent process,
+ * but there's currently no way to pass such request. */
+ no_port_forwarding_flag &= ~2;
+ no_agent_forwarding_flag &= ~2;
+ no_x11_forwarding_flag &= ~2;
+ if (!no_port_forwarding_flag && options.allow_tcp_forwarding)
+ channel_permit_all_opens();
+#endif
}
}
-void
-do_pam_setcred(int init)
+/* Cleanly shutdown PAM */
+void finish_pam(void)
{
- sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
- (const void *)&null_conv);
- if (sshpam_err != PAM_SUCCESS)
- fatal("PAM: failed to set PAM_CONV: %s",
- pam_strerror(sshpam_handle, sshpam_err));
- if (init) {
- debug("PAM: establishing credentials");
- sshpam_err = pam_setcred(sshpam_handle, PAM_ESTABLISH_CRED);
- } else {
- debug("PAM: reinitializing credentials");
- sshpam_err = pam_setcred(sshpam_handle, PAM_REINITIALIZE_CRED);
- }
- if (sshpam_err == PAM_SUCCESS) {
- sshpam_cred_established = 1;
- return;
- }
- if (sshpam_authenticated)
- fatal("PAM: pam_setcred(): %s",
- pam_strerror(sshpam_handle, sshpam_err));
- else
- debug("PAM: pam_setcred(): %s",
- pam_strerror(sshpam_handle, sshpam_err));
+ do_pam_cleanup_proc(NULL);
+ fatal_remove_cleanup(&do_pam_cleanup_proc, NULL);
}
-int
-is_pam_password_change_required(void)
+/* Start PAM authentication for specified account */
+void start_pam(const char *user)
{
- return (sshpam_new_authtok_reqd);
-}
+ int pam_retval;
+ extern ServerOptions options;
+ extern u_int utmp_len;
+ const char *rhost;
-static int
-pam_chauthtok_conv(int n, const struct pam_message **msg,
- struct pam_response **resp, void *data)
-{
- char input[PAM_MAX_MSG_SIZE];
- struct pam_response *reply;
- int i;
+ debug("Starting up PAM with username \"%.200s\"", user);
- *resp = NULL;
+ pam_retval = pam_start(SSHD_PAM_SERVICE, user, &conv, &__pamh);
- if (n <= 0 || n > PAM_MAX_NUM_MSG)
- return (PAM_CONV_ERR);
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM initialisation failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
- if ((reply = malloc(n * sizeof(*reply))) == NULL)
- return (PAM_CONV_ERR);
- memset(reply, 0, n * sizeof(*reply));
+ rhost = get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping);
+ debug("PAM setting rhost to \"%.200s\"", rhost);
- for (i = 0; i < n; ++i) {
- switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
- case PAM_PROMPT_ECHO_OFF:
- reply[i].resp =
- read_passphrase(PAM_MSG_MEMBER(msg, i, msg),
- RP_ALLOW_STDIN);
- reply[i].resp_retcode = PAM_SUCCESS;
- break;
- case PAM_PROMPT_ECHO_ON:
- fputs(PAM_MSG_MEMBER(msg, i, msg), stderr);
- fgets(input, sizeof input, stdin);
- reply[i].resp = xstrdup(input);
- reply[i].resp_retcode = PAM_SUCCESS;
- break;
- case PAM_ERROR_MSG:
- case PAM_TEXT_INFO:
- fputs(PAM_MSG_MEMBER(msg, i, msg), stderr);
- reply[i].resp_retcode = PAM_SUCCESS;
- break;
- default:
- goto fail;
- }
- }
- *resp = reply;
- return (PAM_SUCCESS);
+ pam_retval = pam_set_item(__pamh, PAM_RHOST, rhost);
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM set rhost failed[%d]: %.200s", pam_retval,
+ PAM_STRERROR(__pamh, pam_retval));
+#ifdef PAM_TTY_KLUDGE
+ /*
+ * Some PAM modules (e.g. pam_time) require a TTY to operate,
+ * and will fail in various stupid ways if they don't get one.
+ * sshd doesn't set the tty until too late in the auth process and may
+ * not even need one (for tty-less connections)
+ * Kludge: Set a fake PAM_TTY
+ */
+ pam_retval = pam_set_item(__pamh, PAM_TTY, "NODEVssh");
+ if (pam_retval != PAM_SUCCESS)
+ fatal("PAM set tty failed[%d]: %.200s",
+ pam_retval, PAM_STRERROR(__pamh, pam_retval));
+#endif /* PAM_TTY_KLUDGE */
- fail:
- for(i = 0; i < n; i++) {
- if (reply[i].resp != NULL)
- xfree(reply[i].resp);
- }
- xfree(reply);
- return (PAM_CONV_ERR);
+ fatal_add_cleanup(&do_pam_cleanup_proc, NULL);
}
-/*
- * XXX this should be done in the authentication phase, but ssh1 doesn't
- * support that
- */
-void
-do_pam_chauthtok(void)
+/* Return list of PAM environment strings */
+char **fetch_pam_environment(void)
{
- struct pam_conv pam_conv;
-
- pam_conv.conv = pam_chauthtok_conv;
- pam_conv.appdata_ptr = NULL;
-
- if (use_privsep)
- fatal("Password expired (unable to change with privsep)");
- sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
- (const void *)&pam_conv);
- if (sshpam_err != PAM_SUCCESS)
- fatal("PAM: failed to set PAM_CONV: %s",
- pam_strerror(sshpam_handle, sshpam_err));
- debug("PAM: changing password");
- sshpam_err = pam_chauthtok(sshpam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
- if (sshpam_err != PAM_SUCCESS)
- fatal("PAM: pam_chauthtok(): %s",
- pam_strerror(sshpam_handle, sshpam_err));
+#ifdef HAVE_PAM_GETENVLIST
+ return(pam_getenvlist(__pamh));
+#else /* HAVE_PAM_GETENVLIST */
+ return(NULL);
+#endif /* HAVE_PAM_GETENVLIST */
}
-/*
- * Set a PAM environment string. We need to do this so that the session
- * modules can handle things like Kerberos/GSI credentials that appear
- * during the ssh authentication process.
- */
-
-int
-do_pam_putenv(char *name, char *value)
+void free_pam_environment(char **env)
{
- int ret = 1;
-#ifdef HAVE_PAM_PUTENV
- char *compound;
- size_t len;
-
- len = strlen(name) + strlen(value) + 2;
- compound = xmalloc(len);
-
- snprintf(compound, len, "%s=%s", name, value);
- ret = pam_putenv(sshpam_handle, compound);
- xfree(compound);
-#endif
+ int i;
- return (ret);
+ if (env != NULL) {
+ for (i = 0; env[i] != NULL; i++)
+ xfree(env[i]);
+ }
}
-void
-print_pam_messages(void)
+/* Print any messages that have been generated during authentication */
+/* or account checking to stderr */
+void print_pam_messages(void)
{
- /* XXX */
+ if (__pam_msg != NULL)
+ fputs(__pam_msg, stderr);
}
-char **
-fetch_pam_environment(void)
+/* Append a message to buffer */
+void message_cat(char **p, const char *a)
{
-#ifdef HAVE_PAM_GETENVLIST
- debug("PAM: retrieving environment");
- return (pam_getenvlist(sshpam_handle));
-#else
- return (NULL);
-#endif
-}
+ char *cp;
+ size_t new_len;
-void
-free_pam_environment(char **env)
-{
- char **envp;
+ new_len = strlen(a);
- if (env == NULL)
- return;
+ if (*p) {
+ size_t len = strlen(*p);
+
+ *p = xrealloc(*p, new_len + len + 2);
+ cp = *p + len;
+ } else
+ *p = cp = xmalloc(new_len + 2);
- for (envp = env; *envp; envp++)
- xfree(*envp);
- xfree(env);
+ memcpy(cp, a, new_len);
+ cp[new_len] = '\n';
+ cp[new_len + 1] = '\0';
}
#endif /* USE_PAM */
diff --git a/crypto/openssh/auth-pam.h b/crypto/openssh/auth-pam.h
index 5c952f3..376d9ea 100644
--- a/crypto/openssh/auth-pam.h
+++ b/crypto/openssh/auth-pam.h
@@ -1,4 +1,5 @@
-/* $Id: auth-pam.h,v 1.21 2003/09/02 13:18:53 djm Exp $ */
+/* $Id: auth-pam.h,v 1.16 2002/07/23 00:44:07 stevesk Exp $ */
+/* $FreeBSD$ */
/*
* Copyright (c) 2000 Damien Miller. All rights reserved.
@@ -31,17 +32,19 @@
# define SSHD_PAM_SERVICE __progname
#endif
-void start_pam(const char *);
+void start_pam(const char *user);
void finish_pam(void);
-u_int do_pam_account(void);
-void do_pam_session(void);
-void do_pam_set_tty(const char *);
-void do_pam_setcred(int );
+int auth_pam_password(Authctxt *authctxt, const char *password);
+char **fetch_pam_environment(void);
+void free_pam_environment(char **env);
+int do_pam_authenticate(int flags);
+int do_pam_account(const char *username, const char *remote_user);
+void do_pam_session(const char *username, const char *ttyname);
+void do_pam_setcred(int init);
+void print_pam_messages(void);
int is_pam_password_change_required(void);
void do_pam_chauthtok(void);
-int do_pam_putenv(char *, char *);
-void print_pam_messages(void);
-char ** fetch_pam_environment(void);
-void free_pam_environment(char **);
+void do_pam_set_conv(struct pam_conv *);
+void message_cat(char **p, const char *a);
#endif /* USE_PAM */
diff --git a/crypto/openssh/auth-passwd.c b/crypto/openssh/auth-passwd.c
index 971c7ba..2778ba01 100644
--- a/crypto/openssh/auth-passwd.c
+++ b/crypto/openssh/auth-passwd.c
@@ -36,19 +36,62 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth-passwd.c,v 1.29 2003/08/26 09:58:43 markus Exp $");
+RCSID("$OpenBSD: auth-passwd.c,v 1.27 2002/05/24 16:45:16 stevesk Exp $");
+RCSID("$FreeBSD$");
#include "packet.h"
#include "log.h"
#include "servconf.h"
#include "auth.h"
-#ifdef WITH_AIXAUTHENTICATE
-# include "buffer.h"
-# include "canohost.h"
-extern Buffer loginmsg;
-#endif
+
+/*
+ * Do not try to use PAM for password authentication, as it is
+ * already (and far better) supported by the challenge/response
+ * authentication mechanism.
+ */
+#undef USE_PAM
+
+#if !defined(USE_PAM) && !defined(HAVE_OSF_SIA)
+/* Don't need any of these headers for the PAM or SIA cases */
+# ifdef HAVE_CRYPT_H
+# include <crypt.h>
+# endif
+# ifdef WITH_AIXAUTHENTICATE
+# include <login.h>
+# endif
+# ifdef __hpux
+# include <hpsecurity.h>
+# include <prot.h>
+# endif
+# ifdef HAVE_SECUREWARE
+# include <sys/security.h>
+# include <sys/audit.h>
+# include <prot.h>
+# endif /* HAVE_SECUREWARE */
+# if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
+# include <shadow.h>
+# endif
+# if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW)
+# include <sys/label.h>
+# include <sys/audit.h>
+# include <pwdadj.h>
+# endif
+# if defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT)
+# include "md5crypt.h"
+# endif /* defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) */
+
+# ifdef HAVE_CYGWIN
+# undef ERROR
+# include <windows.h>
+# include <sys/cygwin.h>
+# define is_winnt (GetVersion() < 0x80000000)
+# endif
+#endif /* !USE_PAM && !HAVE_OSF_SIA */
extern ServerOptions options;
+#ifdef WITH_AIXAUTHENTICATE
+extern char *aixloginmsg;
+#endif
/*
* Tries to authenticate the user using password. Returns true if
@@ -58,26 +101,46 @@ int
auth_password(Authctxt *authctxt, const char *password)
{
struct passwd * pw = authctxt->pw;
- int ok = authctxt->valid;
+#if !defined(USE_PAM) && !defined(HAVE_OSF_SIA)
+ char *encrypted_password;
+ char *pw_password;
+ char *salt;
+# if defined(__hpux) || defined(HAVE_SECUREWARE)
+ struct pr_passwd *spw;
+# endif /* __hpux || HAVE_SECUREWARE */
+# if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
+ struct spwd *spw;
+# endif
+# if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW)
+ struct passwd_adjunct *spw;
+# endif
+# ifdef WITH_AIXAUTHENTICATE
+ char *authmsg;
+ int authsuccess;
+ int reenter = 1;
+# endif
+#endif /* !defined(USE_PAM) && !defined(HAVE_OSF_SIA) */
/* deny if no user. */
if (pw == NULL)
return 0;
#ifndef HAVE_CYGWIN
- if (pw && pw->pw_uid == 0 && options.permit_root_login != PERMIT_YES)
- ok = 0;
+ if (pw->pw_uid == 0 && options.permit_root_login != PERMIT_YES)
+ return 0;
#endif
if (*password == '\0' && options.permit_empty_passwd == 0)
return 0;
-#if defined(HAVE_OSF_SIA)
- return auth_sia_password(authctxt, password) && ok;
+#if defined(USE_PAM)
+ return auth_pam_password(authctxt, password);
+#elif defined(HAVE_OSF_SIA)
+ return auth_sia_password(authctxt, password);
#else
# ifdef KRB5
if (options.kerberos_authentication == 1) {
int ret = auth_krb5_password(authctxt, password);
if (ret == 1 || ret == 0)
- return ret && ok;
+ return ret;
/* Fall back to ordinary passwd authentication. */
}
# endif
@@ -88,47 +151,27 @@ auth_password(Authctxt *authctxt, const char *password)
if (hToken == INVALID_HANDLE_VALUE)
return 0;
cygwin_set_impersonation_token(hToken);
- return ok;
+ return 1;
}
# endif
# ifdef WITH_AIXAUTHENTICATE
- {
- char *authmsg = NULL;
- int reenter = 1;
- int authsuccess = 0;
-
- if (authenticate(pw->pw_name, password, &reenter,
- &authmsg) == 0 && ok) {
- char *msg;
- char *host =
- (char *)get_canonical_hostname(options.use_dns);
-
- authsuccess = 1;
- aix_remove_embedded_newlines(authmsg);
-
- debug3("AIX/authenticate succeeded for user %s: %.100s",
- pw->pw_name, authmsg);
-
- /* No pty yet, so just label the line as "ssh" */
- aix_setauthdb(authctxt->user);
- if (loginsuccess(authctxt->user, host, "ssh",
- &msg) == 0) {
- if (msg != NULL) {
- debug("%s: msg %s", __func__, msg);
- buffer_append(&loginmsg, msg,
- strlen(msg));
- xfree(msg);
- }
- }
- } else {
- debug3("AIX/authenticate failed for user %s: %.100s",
- pw->pw_name, authmsg);
- }
-
- if (authmsg != NULL)
- xfree(authmsg);
-
- return authsuccess;
+ authsuccess = (authenticate(pw->pw_name,password,&reenter,&authmsg) == 0);
+
+ if (authsuccess)
+ /* We don't have a pty yet, so just label the line as "ssh" */
+ if (loginsuccess(authctxt->user,
+ get_canonical_hostname(options.verify_reverse_mapping),
+ "ssh", &aixloginmsg) < 0)
+ aixloginmsg = NULL;
+
+ return(authsuccess);
+# endif
+# ifdef KRB4
+ if (options.kerberos_authentication == 1) {
+ int ret = auth_krb4_password(authctxt, password);
+ if (ret == 1 || ret == 0)
+ return ret;
+ /* Fall back to ordinary passwd authentication. */
}
# endif
# ifdef BSD_AUTH
@@ -136,28 +179,64 @@ auth_password(Authctxt *authctxt, const char *password)
(char *)password) == 0)
return 0;
else
- return ok;
-# else
- {
- /* Just use the supplied fake password if authctxt is invalid */
- char *pw_password = authctxt->valid ? shadow_pw(pw) : pw->pw_passwd;
+ return 1;
+# endif
+ pw_password = pw->pw_passwd;
+
+ /*
+ * Various interfaces to shadow or protected password data
+ */
+# if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
+ spw = getspnam(pw->pw_name);
+ if (spw != NULL)
+ pw_password = spw->sp_pwdp;
+# endif /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */
+
+# if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW)
+ if (issecure() && (spw = getpwanam(pw->pw_name)) != NULL)
+ pw_password = spw->pwa_passwd;
+# endif /* defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) */
+
+# ifdef HAVE_SECUREWARE
+ if ((spw = getprpwnam(pw->pw_name)) != NULL)
+ pw_password = spw->ufld.fd_encrypt;
+# endif /* HAVE_SECUREWARE */
+
+# if defined(__hpux) && !defined(HAVE_SECUREWARE)
+ if (iscomsec() && (spw = getprpwnam(pw->pw_name)) != NULL)
+ pw_password = spw->ufld.fd_encrypt;
+# endif /* defined(__hpux) && !defined(HAVE_SECUREWARE) */
/* Check for users with no password. */
- if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0)
- return ok;
- else {
- /* Encrypt the candidate password using the proper salt. */
- char *encrypted_password = xcrypt(password,
- (pw_password[0] && pw_password[1]) ? pw_password : "xx");
-
- /*
- * Authentication is accepted if the encrypted passwords
- * are identical.
- */
- return (strcmp(encrypted_password, pw_password) == 0) && ok;
- }
+ if ((password[0] == '\0') && (pw_password[0] == '\0'))
+ return 1;
- }
-# endif
-#endif /* !HAVE_OSF_SIA */
+ if (pw_password[0] != '\0')
+ salt = pw_password;
+ else
+ salt = "xx";
+
+# ifdef HAVE_MD5_PASSWORDS
+ if (is_md5_salt(salt))
+ encrypted_password = md5_crypt(password, salt);
+ else
+ encrypted_password = crypt(password, salt);
+# else /* HAVE_MD5_PASSWORDS */
+# if defined(__hpux) && !defined(HAVE_SECUREWARE)
+ if (iscomsec())
+ encrypted_password = bigcrypt(password, salt);
+ else
+ encrypted_password = crypt(password, salt);
+# else
+# ifdef HAVE_SECUREWARE
+ encrypted_password = bigcrypt(password, salt);
+# else
+ encrypted_password = crypt(password, salt);
+# endif /* HAVE_SECUREWARE */
+# endif /* __hpux && !defined(HAVE_SECUREWARE) */
+# endif /* HAVE_MD5_PASSWORDS */
+
+ /* Authentication is accepted if the encrypted passwords are identical. */
+ return (strcmp(encrypted_password, pw_password) == 0);
+#endif /* !USE_PAM && !HAVE_OSF_SIA */
}
diff --git a/crypto/openssh/auth-rh-rsa.c b/crypto/openssh/auth-rh-rsa.c
index 2eb7e6e..d7848d0 100644
--- a/crypto/openssh/auth-rh-rsa.c
+++ b/crypto/openssh/auth-rh-rsa.c
@@ -13,7 +13,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth-rh-rsa.c,v 1.36 2003/06/02 09:17:34 markus Exp $");
+RCSID("$OpenBSD: auth-rh-rsa.c,v 1.34 2002/03/25 09:25:06 markus Exp $");
#include "packet.h"
#include "uidswap.h"
@@ -63,7 +63,7 @@ auth_rhosts_rsa(struct passwd *pw, char *cuser, Key *client_host_key)
client_host_key->rsa == NULL)
return 0;
- chost = (char *)get_canonical_hostname(options.use_dns);
+ chost = (char *)get_canonical_hostname(options.verify_reverse_mapping);
debug("Rhosts RSA authentication: canonical host %.900s", chost);
if (!PRIVSEP(auth_rhosts_rsa_key_allowed(pw, cuser, chost, client_host_key))) {
@@ -75,7 +75,7 @@ auth_rhosts_rsa(struct passwd *pw, char *cuser, Key *client_host_key)
/* Perform the challenge-response dialog with the client for the host key. */
if (!auth_rsa_challenge_dialog(client_host_key)) {
- logit("Client on %.800s failed to respond correctly to host authentication.",
+ log("Client on %.800s failed to respond correctly to host authentication.",
chost);
return 0;
}
diff --git a/crypto/openssh/auth-rsa.c b/crypto/openssh/auth-rsa.c
index 5631d23..92f6277 100644
--- a/crypto/openssh/auth-rsa.c
+++ b/crypto/openssh/auth-rsa.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth-rsa.c,v 1.57 2003/04/08 20:21:28 itojun Exp $");
+RCSID("$OpenBSD: auth-rsa.c,v 1.56 2002/06/10 16:53:06 stevesk Exp $");
#include <openssl/rsa.h>
#include <openssl/md5.h>
@@ -187,7 +187,7 @@ auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
secure_filename(f, file, pw, line, sizeof(line)) != 0) {
xfree(file);
fclose(f);
- logit("Authentication refused: %s", line);
+ log("Authentication refused: %s", line);
restore_uid();
return (0);
}
@@ -246,7 +246,7 @@ auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
/* check the real bits */
if (bits != BN_num_bits(key->rsa->n))
- logit("Warning: %s, line %lu: keysize mismatch: "
+ log("Warning: %s, line %lu: keysize mismatch: "
"actual %d vs. announced %d.",
file, linenum, BN_num_bits(key->rsa->n), bits);
diff --git a/crypto/openssh/auth-skey.c b/crypto/openssh/auth-skey.c
index f9ea03f..a534e35 100644
--- a/crypto/openssh/auth-skey.c
+++ b/crypto/openssh/auth-skey.c
@@ -23,10 +23,19 @@
*/
#include "includes.h"
RCSID("$OpenBSD: auth-skey.c,v 1.20 2002/06/30 21:59:45 deraadt Exp $");
+RCSID("$FreeBSD$");
#ifdef SKEY
+#ifdef OPIE
+#include <opie.h>
+#define skey opie
+#define skeychallenge(k, u, c) opiechallenge((k), (u), (c))
+#define skey_haskey(u) opie_haskey((u))
+#define skey_passcheck(u, r) opie_passverify((u), (r))
+#else
#include <skey.h>
+#endif
#include "xmalloc.h"
#include "auth.h"
diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c
index 46e495a..e8f0ab9 100644
--- a/crypto/openssh/auth.c
+++ b/crypto/openssh/auth.c
@@ -23,7 +23,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth.c,v 1.49 2003/08/26 09:58:43 markus Exp $");
+RCSID("$OpenBSD: auth.c,v 1.46 2002/11/04 10:07:53 markus Exp $");
+RCSID("$FreeBSD$");
#ifdef HAVE_LOGIN_H
#include <login.h>
@@ -54,7 +55,6 @@ RCSID("$OpenBSD: auth.c,v 1.49 2003/08/26 09:58:43 markus Exp $");
/* import */
extern ServerOptions options;
-extern Buffer loginmsg;
/* Debugging messages */
Buffer auth_debug;
@@ -73,25 +73,26 @@ int
allowed_user(struct passwd * pw)
{
struct stat st;
- const char *hostname = NULL, *ipaddr = NULL, *passwd = NULL;
+ const char *hostname = NULL, *ipaddr = NULL;
char *shell;
int i;
-#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
- struct spwd *spw = NULL;
+#ifdef WITH_AIXAUTHENTICATE
+ char *loginmsg;
+#endif /* WITH_AIXAUTHENTICATE */
+#if !defined(USE_PAM) && defined(HAVE_SHADOW_H) && \
+ !defined(DISABLE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
+ struct spwd *spw;
+ time_t today;
#endif
/* Shouldn't be called if pw is NULL, but better safe than sorry... */
if (!pw || !pw->pw_name)
return 0;
-#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
- if (!options.use_pam)
- spw = getspnam(pw->pw_name);
-#ifdef HAS_SHADOW_EXPIRE
+#if !defined(USE_PAM) && defined(HAVE_SHADOW_H) && \
+ !defined(DISABLE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
#define DAY (24L * 60 * 60) /* 1 day in seconds */
- if (!options.use_pam && spw != NULL) {
- time_t today;
-
+ if ((spw = getspnam(pw->pw_name)) != NULL) {
today = time(NULL) / DAY;
debug3("allowed_user: today %d sp_expire %d sp_lstchg %d"
" sp_max %d", (int)today, (int)spw->sp_expire,
@@ -102,58 +103,25 @@ allowed_user(struct passwd * pw)
* day after the day specified.
*/
if (spw->sp_expire != -1 && today > spw->sp_expire) {
- logit("Account %.100s has expired", pw->pw_name);
+ log("Account %.100s has expired", pw->pw_name);
return 0;
}
if (spw->sp_lstchg == 0) {
- logit("User %.100s password has expired (root forced)",
+ log("User %.100s password has expired (root forced)",
pw->pw_name);
return 0;
}
if (spw->sp_max != -1 &&
today > spw->sp_lstchg + spw->sp_max) {
- logit("User %.100s password has expired (password aged)",
+ log("User %.100s password has expired (password aged)",
pw->pw_name);
return 0;
}
}
-#endif /* HAS_SHADOW_EXPIRE */
-#endif /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */
-
- /* grab passwd field for locked account check */
-#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
- if (spw != NULL)
- passwd = spw->sp_pwdp;
-#else
- passwd = pw->pw_passwd;
#endif
- /* check for locked account */
- if (!options.use_pam && passwd && *passwd) {
- int locked = 0;
-
-#ifdef LOCKED_PASSWD_STRING
- if (strcmp(passwd, LOCKED_PASSWD_STRING) == 0)
- locked = 1;
-#endif
-#ifdef LOCKED_PASSWD_PREFIX
- if (strncmp(passwd, LOCKED_PASSWD_PREFIX,
- strlen(LOCKED_PASSWD_PREFIX)) == 0)
- locked = 1;
-#endif
-#ifdef LOCKED_PASSWD_SUBSTR
- if (strstr(passwd, LOCKED_PASSWD_SUBSTR))
- locked = 1;
-#endif
- if (locked) {
- logit("User %.100s not allowed because account is locked",
- pw->pw_name);
- return 0;
- }
- }
-
/*
* Get the shell from the password data. An empty shell field is
* legal, and means /bin/sh.
@@ -162,19 +130,19 @@ allowed_user(struct passwd * pw)
/* deny if shell does not exists or is not executable */
if (stat(shell, &st) != 0) {
- logit("User %.100s not allowed because shell %.100s does not exist",
+ log("User %.100s not allowed because shell %.100s does not exist",
pw->pw_name, shell);
return 0;
}
if (S_ISREG(st.st_mode) == 0 ||
(st.st_mode & (S_IXOTH|S_IXUSR|S_IXGRP)) == 0) {
- logit("User %.100s not allowed because shell %.100s is not executable",
+ log("User %.100s not allowed because shell %.100s is not executable",
pw->pw_name, shell);
return 0;
}
if (options.num_deny_users > 0 || options.num_allow_users > 0) {
- hostname = get_canonical_hostname(options.use_dns);
+ hostname = get_canonical_hostname(options.verify_reverse_mapping);
ipaddr = get_remote_ipaddr();
}
@@ -183,7 +151,7 @@ allowed_user(struct passwd * pw)
for (i = 0; i < options.num_deny_users; i++)
if (match_user(pw->pw_name, hostname, ipaddr,
options.deny_users[i])) {
- logit("User %.100s not allowed because listed in DenyUsers",
+ log("User %.100s not allowed because listed in DenyUsers",
pw->pw_name);
return 0;
}
@@ -196,7 +164,7 @@ allowed_user(struct passwd * pw)
break;
/* i < options.num_allow_users iff we break for loop */
if (i >= options.num_allow_users) {
- logit("User %.100s not allowed because not listed in AllowUsers",
+ log("User %.100s not allowed because not listed in AllowUsers",
pw->pw_name);
return 0;
}
@@ -204,7 +172,7 @@ allowed_user(struct passwd * pw)
if (options.num_deny_groups > 0 || options.num_allow_groups > 0) {
/* Get the user's group access list (primary and supplementary) */
if (ga_init(pw->pw_name, pw->pw_gid) == 0) {
- logit("User %.100s not allowed because not in any group",
+ log("User %.100s not allowed because not in any group",
pw->pw_name);
return 0;
}
@@ -214,7 +182,7 @@ allowed_user(struct passwd * pw)
if (ga_match(options.deny_groups,
options.num_deny_groups)) {
ga_free();
- logit("User %.100s not allowed because a group is listed in DenyGroups",
+ log("User %.100s not allowed because a group is listed in DenyGroups",
pw->pw_name);
return 0;
}
@@ -226,7 +194,7 @@ allowed_user(struct passwd * pw)
if (!ga_match(options.allow_groups,
options.num_allow_groups)) {
ga_free();
- logit("User %.100s not allowed because none of user's groups are listed in AllowGroups",
+ log("User %.100s not allowed because none of user's groups are listed in AllowGroups",
pw->pw_name);
return 0;
}
@@ -239,23 +207,26 @@ allowed_user(struct passwd * pw)
* PermitRootLogin to control logins via ssh), or if running as
* non-root user (since loginrestrictions will always fail).
*/
- if ((pw->pw_uid != 0) && (geteuid() == 0)) {
- char *msg;
-
- if (loginrestrictions(pw->pw_name, S_RLOGIN, NULL, &msg) != 0) {
- int loginrestrict_errno = errno;
-
- if (msg && *msg) {
- buffer_append(&loginmsg, msg, strlen(msg));
- aix_remove_embedded_newlines(msg);
- logit("Login restricted for %s: %.100s",
- pw->pw_name, msg);
+ if ((pw->pw_uid != 0) && (geteuid() == 0) &&
+ loginrestrictions(pw->pw_name, S_RLOGIN, NULL, &loginmsg) != 0) {
+ int loginrestrict_errno = errno;
+
+ if (loginmsg && *loginmsg) {
+ /* Remove embedded newlines (if any) */
+ char *p;
+ for (p = loginmsg; *p; p++) {
+ if (*p == '\n')
+ *p = ' ';
}
- /* Don't fail if /etc/nologin set */
- if (!(loginrestrict_errno == EPERM &&
- stat(_PATH_NOLOGIN, &st) == 0))
- return 0;
+ /* Remove trailing newline */
+ *--p = '\0';
+ log("Login restricted for %s: %.100s", pw->pw_name,
+ loginmsg);
}
+ /* Don't fail if /etc/nologin set */
+ if (!(loginrestrict_errno == EPERM &&
+ stat(_PATH_NOLOGIN, &st) == 0))
+ return 0;
}
#endif /* WITH_AIXAUTHENTICATE */
@@ -282,7 +253,7 @@ auth_log(Authctxt *authctxt, int authenticated, char *method, char *info)
!authctxt->valid ||
authctxt->failures >= AUTH_FAIL_LOG ||
strcmp(method, "password") == 0)
- authlog = logit;
+ authlog = log;
if (authctxt->postponed)
authmsg = "Postponed";
@@ -298,10 +269,13 @@ auth_log(Authctxt *authctxt, int authenticated, char *method, char *info)
get_remote_port(),
info);
-#ifdef CUSTOM_FAILED_LOGIN
+#ifdef WITH_AIXAUTHENTICATE
if (authenticated == 0 && strcmp(method, "password") == 0)
- record_failed_login(authctxt->user, "ssh");
-#endif
+ loginfailed(authctxt->user,
+ get_canonical_hostname(options.verify_reverse_mapping),
+ "ssh");
+#endif /* WITH_AIXAUTHENTICATE */
+
}
/*
@@ -320,12 +294,12 @@ auth_root_allowed(char *method)
break;
case PERMIT_FORCED_ONLY:
if (forced_command) {
- logit("Root login accepted for forced command.");
+ log("Root login accepted for forced command.");
return 1;
}
break;
}
- logit("ROOT LOGIN REFUSED FROM %.200s", get_remote_ipaddr());
+ log("ROOT LOGIN REFUSED FROM %.200s", get_remote_ipaddr());
return 0;
}
@@ -417,7 +391,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
(stat(user_hostfile, &st) == 0) &&
((st.st_uid != 0 && st.st_uid != pw->pw_uid) ||
(st.st_mode & 022) != 0)) {
- logit("Authentication refused for %.100s: "
+ log("Authentication refused for %.100s: "
"bad owner or modes for %.200s",
pw->pw_name, user_hostfile);
} else {
@@ -521,17 +495,19 @@ getpwnamallow(const char *user)
pw = getpwnam(user);
if (pw == NULL) {
- logit("Illegal user %.100s from %.100s",
+ log("Illegal user %.100s from %.100s",
user, get_remote_ipaddr());
-#ifdef CUSTOM_FAILED_LOGIN
- record_failed_login(user, "ssh");
+#ifdef WITH_AIXAUTHENTICATE
+ loginfailed(user,
+ get_canonical_hostname(options.verify_reverse_mapping),
+ "ssh");
#endif
return (NULL);
}
if (!allowed_user(pw))
return (NULL);
#ifdef HAVE_LOGIN_CAP
- if ((lc = login_getclass(pw->pw_class)) == NULL) {
+ if ((lc = login_getpwclass(pw)) == NULL) {
debug("unable to get login class: %s", user);
return (NULL);
}
@@ -589,24 +565,3 @@ auth_debug_reset(void)
auth_debug_init = 1;
}
}
-
-struct passwd *
-fakepw(void)
-{
- static struct passwd fake;
-
- memset(&fake, 0, sizeof(fake));
- fake.pw_name = "NOUSER";
- fake.pw_passwd =
- "$2a$06$r3.juUaHZDlIbQaO2dS9FuYxL1W9M81R1Tc92PoSNmzvpEqLkLGrK";
- fake.pw_gecos = "NOUSER";
- fake.pw_uid = -1;
- fake.pw_gid = -1;
-#ifdef HAVE_PW_CLASS_IN_PASSWD
- fake.pw_class = "";
-#endif
- fake.pw_dir = "/nonexist";
- fake.pw_shell = "/nonexist";
-
- return (&fake);
-}
diff --git a/crypto/openssh/auth.h b/crypto/openssh/auth.h
index beaacb8..4e19ee4 100644
--- a/crypto/openssh/auth.h
+++ b/crypto/openssh/auth.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: auth.h,v 1.46 2003/08/28 12:54:34 markus Exp $ */
+/* $OpenBSD: auth.h,v 1.41 2002/09/26 11:38:43 markus Exp $ */
+/* $FreeBSD$ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -48,32 +49,29 @@ typedef struct KbdintDevice KbdintDevice;
struct Authctxt {
int success;
- int postponed; /* authentication needs another step */
- int valid; /* user exists and is allowed to login */
+ int postponed;
+ int valid;
int attempt;
int failures;
- char *user; /* username sent by the client */
+ char *user;
char *service;
- struct passwd *pw; /* set if 'valid' */
+ struct passwd *pw;
char *style;
void *kbdintctxt;
#ifdef BSD_AUTH
auth_session_t *as;
#endif
+#ifdef KRB4
+ char *krb4_ticket_file;
+#endif
#ifdef KRB5
krb5_context krb5_ctx;
+ krb5_auth_context krb5_auth_ctx;
krb5_ccache krb5_fwd_ccache;
krb5_principal krb5_user;
char *krb5_ticket_file;
#endif
- void *methoddata;
};
-/*
- * Every authentication method has to handle authentication requests for
- * non-existing users, or for users that are not allowed to login. In this
- * case 'valid' is set to 0, but 'user' points to the username requested by
- * the client.
- */
struct Authmethod {
char *name;
@@ -114,6 +112,20 @@ int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
int user_key_allowed(struct passwd *, Key *);
+#ifdef KRB4
+#include <krb.h>
+int auth_krb4(Authctxt *, KTEXT, char **, KTEXT);
+int auth_krb4_password(Authctxt *, const char *);
+void krb4_cleanup_proc(void *);
+
+#ifdef AFS
+#include <kafs.h>
+int auth_krb4_tgt(Authctxt *, const char *);
+int auth_afs_token(Authctxt *, const char *);
+#endif /* AFS */
+
+#endif /* KRB4 */
+
#ifdef KRB5
int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *);
int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt);
@@ -122,6 +134,7 @@ void krb5_cleanup_proc(void *authctxt);
#endif /* KRB5 */
#include "auth-pam.h"
+#include "auth2-pam.h"
Authctxt *do_authentication(void);
Authctxt *do_authentication2(void);
@@ -173,11 +186,16 @@ void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
void auth_debug_send(void);
void auth_debug_reset(void);
-struct passwd *fakepw(void);
-
#define AUTH_FAIL_MAX 6
#define AUTH_FAIL_LOG (AUTH_FAIL_MAX/2)
#define AUTH_FAIL_MSG "Too many authentication failures for %.100s"
+#ifdef SKEY
+#ifdef OPIE
+#define SKEY_PROMPT "\nOPIE Password: "
+#else
#define SKEY_PROMPT "\nS/Key Password: "
#endif
+#endif
+
+#endif
diff --git a/crypto/openssh/auth1.c b/crypto/openssh/auth1.c
index dfe944d..18203fe 100644
--- a/crypto/openssh/auth1.c
+++ b/crypto/openssh/auth1.c
@@ -10,7 +10,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth1.c,v 1.52 2003/08/28 12:54:34 markus Exp $");
+RCSID("$OpenBSD: auth1.c,v 1.47 2003/02/06 21:22:42 markus Exp $");
+RCSID("$FreeBSD$");
#include "xmalloc.h"
#include "rsa.h"
@@ -49,6 +50,10 @@ get_authname(int type)
case SSH_CMSG_AUTH_TIS:
case SSH_CMSG_AUTH_TIS_RESPONSE:
return "challenge-response";
+#if defined(KRB4) || defined(KRB5)
+ case SSH_CMSG_AUTH_KERBEROS:
+ return "kerberos";
+#endif
}
snprintf(buf, sizeof buf, "bad-auth-msg-%d", type);
return buf;
@@ -77,7 +82,7 @@ do_authloop(Authctxt *authctxt)
/* If the user has no password, accept authentication immediately. */
if (options.password_authentication &&
-#ifdef KRB5
+#if defined(KRB4) || defined(KRB5)
(!options.kerberos_authentication || options.kerberos_or_local_passwd) &&
#endif
PRIVSEP(auth_password(authctxt, ""))) {
@@ -115,6 +120,100 @@ do_authloop(Authctxt *authctxt)
/* Process the packet. */
switch (type) {
+
+#if defined(KRB4) || defined(KRB5)
+ case SSH_CMSG_AUTH_KERBEROS:
+ if (!options.kerberos_authentication) {
+ verbose("Kerberos authentication disabled.");
+ } else {
+ char *kdata = packet_get_string(&dlen);
+ packet_check_eom();
+
+ if (kdata[0] == 4) { /* KRB_PROT_VERSION */
+#ifdef KRB4
+ KTEXT_ST tkt, reply;
+ tkt.length = dlen;
+ if (tkt.length < MAX_KTXT_LEN)
+ memcpy(tkt.dat, kdata, tkt.length);
+
+ if (PRIVSEP(auth_krb4(authctxt, &tkt,
+ &client_user, &reply))) {
+ authenticated = 1;
+ snprintf(info, sizeof(info),
+ " tktuser %.100s",
+ client_user);
+
+ packet_start(
+ SSH_SMSG_AUTH_KERBEROS_RESPONSE);
+ packet_put_string((char *)
+ reply.dat, reply.length);
+ packet_send();
+ packet_write_wait();
+ }
+#endif /* KRB4 */
+ } else {
+#ifdef KRB5
+ krb5_data tkt, reply;
+ tkt.length = dlen;
+ tkt.data = kdata;
+
+ if (PRIVSEP(auth_krb5(authctxt, &tkt,
+ &client_user, &reply))) {
+ authenticated = 1;
+ snprintf(info, sizeof(info),
+ " tktuser %.100s",
+ client_user);
+
+ /* Send response to client */
+ packet_start(
+ SSH_SMSG_AUTH_KERBEROS_RESPONSE);
+ packet_put_string((char *)
+ reply.data, reply.length);
+ packet_send();
+ packet_write_wait();
+
+ if (reply.length)
+ xfree(reply.data);
+ }
+#endif /* KRB5 */
+ }
+ xfree(kdata);
+ }
+ break;
+#endif /* KRB4 || KRB5 */
+
+#if defined(AFS) || defined(KRB5)
+ /* XXX - punt on backward compatibility here. */
+ case SSH_CMSG_HAVE_KERBEROS_TGT:
+ packet_send_debug("Kerberos TGT passing disabled before authentication.");
+ break;
+#ifdef AFS
+ case SSH_CMSG_HAVE_AFS_TOKEN:
+ packet_send_debug("AFS token passing disabled before authentication.");
+ break;
+#endif /* AFS */
+#endif /* AFS || KRB5 */
+
+ case SSH_CMSG_AUTH_RHOSTS:
+ if (!options.rhosts_authentication) {
+ verbose("Rhosts authentication disabled.");
+ break;
+ }
+ /*
+ * Get client user name. Note that we just have to
+ * trust the client; this is one reason why rhosts
+ * authentication is insecure. (Another is
+ * IP-spoofing on a local network.)
+ */
+ client_user = packet_get_string(&ulen);
+ packet_check_eom();
+
+ /* Try to authenticate using /etc/hosts.equiv and .rhosts. */
+ authenticated = auth_rhosts(pw, client_user);
+
+ snprintf(info, sizeof info, " ruser %.100s", client_user);
+ break;
+
case SSH_CMSG_AUTH_RHOSTS_RSA:
if (!options.rhosts_rsa_authentication) {
verbose("Rhosts with RSA authentication disabled.");
@@ -211,7 +310,7 @@ do_authloop(Authctxt *authctxt)
* Any unknown messages will be ignored (and failure
* returned) during authentication.
*/
- logit("Unknown message during authentication: type %d", type);
+ log("Unknown message during authentication: type %d", type);
break;
}
#ifdef BSD_AUTH
@@ -225,6 +324,8 @@ do_authloop(Authctxt *authctxt)
authctxt->user);
#ifdef _UNICOS
+ if (type == SSH_CMSG_AUTH_PASSWORD && !authenticated)
+ cray_login_failure(authctxt->user, IA_UDBERR);
if (authenticated && cray_access_denied(authctxt->user)) {
authenticated = 0;
fatal("Access denied for user %s.",authctxt->user);
@@ -244,10 +345,9 @@ do_authloop(Authctxt *authctxt)
!auth_root_allowed(get_authname(type)))
authenticated = 0;
#endif
-
#ifdef USE_PAM
- if (options.use_pam && authenticated &&
- !PRIVSEP(do_pam_account()))
+ if (!use_privsep && authenticated &&
+ !do_pam_account(pw->pw_name, client_user))
authenticated = 0;
#endif
@@ -262,8 +362,9 @@ do_authloop(Authctxt *authctxt)
if (authenticated)
return;
- if (authctxt->failures++ > AUTH_FAIL_MAX)
+ if (authctxt->failures++ > AUTH_FAIL_MAX) {
packet_disconnect(AUTH_FAIL_MSG, authctxt->user);
+ }
packet_start(SSH_SMSG_FAILURE);
packet_send();
@@ -292,6 +393,16 @@ do_authentication(void)
if ((style = strchr(user, ':')) != NULL)
*style++ = '\0';
+#ifdef KRB5
+ /* XXX - SSH.com Kerberos v5 braindeath. */
+ if ((datafellows & SSH_BUG_K5USER) &&
+ options.kerberos_authentication) {
+ char *p;
+ if ((p = strchr(user, '@')) != NULL)
+ *p = '\0';
+ }
+#endif
+
authctxt = authctxt_new();
authctxt->user = user;
authctxt->style = style;
@@ -299,17 +410,14 @@ do_authentication(void)
/* Verify that the user is a valid user. */
if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL)
authctxt->valid = 1;
- else {
+ else
debug("do_authentication: illegal user %s", user);
- authctxt->pw = fakepw();
- }
setproctitle("%s%s", authctxt->pw ? user : "unknown",
use_privsep ? " [net]" : "");
#ifdef USE_PAM
- if (options.use_pam)
- PRIVSEP(start_pam(user));
+ PRIVSEP(start_pam(authctxt->pw == NULL ? "NOUSER" : user));
#endif
/*
diff --git a/crypto/openssh/auth2-chall.c b/crypto/openssh/auth2-chall.c
index aacbf0b..1e48387 100644
--- a/crypto/openssh/auth2-chall.c
+++ b/crypto/openssh/auth2-chall.c
@@ -24,6 +24,7 @@
*/
#include "includes.h"
RCSID("$OpenBSD: auth2-chall.c,v 1.20 2002/06/30 21:59:45 deraadt Exp $");
+RCSID("$FreeBSD$");
#include "ssh2.h"
#include "auth.h"
@@ -42,7 +43,7 @@ static void input_userauth_info_response(int, u_int32_t, void *);
extern KbdintDevice bsdauth_device;
#else
#ifdef USE_PAM
-extern KbdintDevice sshpam_device;
+extern KbdintDevice pam_device;
#endif
#ifdef SKEY
extern KbdintDevice skey_device;
@@ -54,7 +55,7 @@ KbdintDevice *devices[] = {
&bsdauth_device,
#else
#ifdef USE_PAM
- &sshpam_device,
+ &pam_device,
#endif
#ifdef SKEY
&skey_device,
@@ -326,24 +327,22 @@ input_userauth_info_response(int type, u_int32_t seq, void *ctxt)
void
privsep_challenge_enable(void)
{
-#if defined(BSD_AUTH) || defined(USE_PAM) || defined(SKEY)
- int n = 0;
-#endif
#ifdef BSD_AUTH
extern KbdintDevice mm_bsdauth_device;
#endif
#ifdef USE_PAM
- extern KbdintDevice mm_sshpam_device;
+ extern KbdintDevice mm_pam_device;
#endif
#ifdef SKEY
extern KbdintDevice mm_skey_device;
#endif
+ int n = 0;
#ifdef BSD_AUTH
devices[n++] = &mm_bsdauth_device;
#else
#ifdef USE_PAM
- devices[n++] = &mm_sshpam_device;
+ devices[n++] = &mm_pam_device;
#endif
#ifdef SKEY
devices[n++] = &mm_skey_device;
diff --git a/crypto/openssh/auth2-kbdint.c b/crypto/openssh/auth2-kbdint.c
index 1696ef4..15c20b3 100644
--- a/crypto/openssh/auth2-kbdint.c
+++ b/crypto/openssh/auth2-kbdint.c
@@ -24,6 +24,7 @@
#include "includes.h"
RCSID("$OpenBSD: auth2-kbdint.c,v 1.2 2002/05/31 11:35:15 markus Exp $");
+RCSID("$FreeBSD$");
#include "packet.h"
#include "auth.h"
diff --git a/crypto/openssh/auth2-pam-freebsd.c b/crypto/openssh/auth2-pam-freebsd.c
new file mode 100644
index 0000000..e058981
--- /dev/null
+++ b/crypto/openssh/auth2-pam-freebsd.c
@@ -0,0 +1,634 @@
+/*-
+ * 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.
+ *
+ * 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.
+ */
+
+#include "includes.h"
+RCSID("$FreeBSD$");
+
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+
+#include "auth.h"
+#include "auth-pam.h"
+#include "buffer.h"
+#include "bufaux.h"
+#include "canohost.h"
+#include "log.h"
+#include "monitor_wrap.h"
+#include "msg.h"
+#include "packet.h"
+#include "readpass.h"
+#include "servconf.h"
+#include "ssh2.h"
+#include "xmalloc.h"
+
+#ifdef USE_POSIX_THREADS
+#include <pthread.h>
+#else
+/*
+ * Simulate threads with processes.
+ */
+typedef pid_t pthread_t;
+
+static void
+pthread_exit(void *value __unused)
+{
+ _exit(0);
+}
+
+static int
+pthread_create(pthread_t *thread, const void *attr __unused,
+ void *(*thread_start)(void *), void *arg)
+{
+ pid_t pid;
+
+ switch ((pid = fork())) {
+ case -1:
+ error("fork(): %s", strerror(errno));
+ return (-1);
+ case 0:
+ thread_start(arg);
+ _exit(1);
+ default:
+ *thread = pid;
+ return (0);
+ }
+}
+
+static int
+pthread_cancel(pthread_t thread)
+{
+ return (kill(thread, SIGTERM));
+}
+
+static int
+pthread_join(pthread_t thread, void **value __unused)
+{
+ int status;
+
+ waitpid(thread, &status, 0);
+ return (status);
+}
+#endif
+
+
+static pam_handle_t *pam_handle;
+static int pam_err;
+static int pam_authenticated;
+static int pam_new_authtok_reqd;
+static int pam_session_open;
+static int pam_cred_established;
+
+struct pam_ctxt {
+ pthread_t pam_thread;
+ int pam_psock;
+ int pam_csock;
+ int pam_done;
+};
+
+static void pam_free_ctx(void *);
+
+/*
+ * Conversation function for authentication thread.
+ */
+static int
+pam_thread_conv(int n,
+ const struct pam_message **msg,
+ struct pam_response **resp,
+ void *data)
+{
+ Buffer buffer;
+ struct pam_ctxt *ctxt;
+ int i;
+
+ ctxt = data;
+ if (n <= 0 || n > PAM_MAX_NUM_MSG)
+ return (PAM_CONV_ERR);
+ *resp = xmalloc(n * sizeof **resp);
+ memset(*resp, 0, n * sizeof **resp);
+ buffer_init(&buffer);
+ 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:
+ buffer_put_cstring(&buffer, msg[i]->msg);
+ ssh_msg_send(ctxt->pam_csock, msg[i]->msg_style, &buffer);
+ ssh_msg_recv(ctxt->pam_csock, &buffer);
+ if (buffer_get_char(&buffer) != PAM_AUTHTOK)
+ goto fail;
+ (*resp)[i].resp = buffer_get_string(&buffer, NULL);
+ break;
+ case PAM_PROMPT_ECHO_ON:
+ buffer_put_cstring(&buffer, msg[i]->msg);
+ ssh_msg_send(ctxt->pam_csock, msg[i]->msg_style, &buffer);
+ ssh_msg_recv(ctxt->pam_csock, &buffer);
+ if (buffer_get_char(&buffer) != PAM_AUTHTOK)
+ goto fail;
+ (*resp)[i].resp = buffer_get_string(&buffer, NULL);
+ break;
+ case PAM_ERROR_MSG:
+ buffer_put_cstring(&buffer, msg[i]->msg);
+ ssh_msg_send(ctxt->pam_csock, msg[i]->msg_style, &buffer);
+ break;
+ case PAM_TEXT_INFO:
+ buffer_put_cstring(&buffer, msg[i]->msg);
+ ssh_msg_send(ctxt->pam_csock, msg[i]->msg_style, &buffer);
+ break;
+ default:
+ goto fail;
+ }
+ buffer_clear(&buffer);
+ }
+ buffer_free(&buffer);
+ return (PAM_SUCCESS);
+ fail:
+ for (i = 0; i < n; ++i) {
+ if ((*resp)[i].resp != NULL) {
+ memset((*resp)[i].resp, 0, strlen((*resp)[i].resp));
+ xfree((*resp)[i].resp);
+ }
+ }
+ memset(*resp, 0, n * sizeof **resp);
+ xfree(*resp);
+ *resp = NULL;
+ buffer_free(&buffer);
+ return (PAM_CONV_ERR);
+}
+
+/*
+ * Authentication thread.
+ */
+static void *
+pam_thread(void *ctxtp)
+{
+ struct pam_ctxt *ctxt = ctxtp;
+ Buffer buffer;
+ struct pam_conv pam_conv = { pam_thread_conv, ctxt };
+
+#ifndef USE_POSIX_THREADS
+ {
+ const char *pam_user;
+
+ pam_get_item(pam_handle, PAM_USER, (const void **)&pam_user);
+ setproctitle("%s [pam]", pam_user);
+ }
+#endif
+ buffer_init(&buffer);
+ pam_err = pam_set_item(pam_handle, PAM_CONV, (const void *)&pam_conv);
+ if (pam_err != PAM_SUCCESS)
+ goto auth_fail;
+ pam_err = pam_authenticate(pam_handle, 0);
+ if (pam_err != PAM_SUCCESS)
+ goto auth_fail;
+ pam_err = pam_acct_mgmt(pam_handle, 0);
+ if (pam_err != PAM_SUCCESS && pam_err != PAM_NEW_AUTHTOK_REQD)
+ goto auth_fail;
+ buffer_put_cstring(&buffer, "OK");
+ ssh_msg_send(ctxt->pam_csock, pam_err, &buffer);
+ buffer_free(&buffer);
+ pthread_exit(NULL);
+ auth_fail:
+ buffer_put_cstring(&buffer,
+ pam_strerror(pam_handle, pam_err));
+ ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer);
+ buffer_free(&buffer);
+ pthread_exit(NULL);
+}
+
+static void
+pam_thread_cleanup(void *ctxtp)
+{
+ struct pam_ctxt *ctxt = ctxtp;
+
+ pthread_cancel(ctxt->pam_thread);
+ pthread_join(ctxt->pam_thread, NULL);
+ close(ctxt->pam_psock);
+ close(ctxt->pam_csock);
+}
+
+static int
+pam_null_conv(int n,
+ const struct pam_message **msg,
+ struct pam_response **resp,
+ void *data)
+{
+
+ return (PAM_CONV_ERR);
+}
+
+static struct pam_conv null_conv = { pam_null_conv, NULL };
+
+static void
+pam_cleanup(void *arg)
+{
+ (void)arg;
+ debug("PAM: cleanup");
+ pam_set_item(pam_handle, PAM_CONV, (const void *)&null_conv);
+ if (pam_cred_established) {
+ pam_setcred(pam_handle, PAM_DELETE_CRED);
+ pam_cred_established = 0;
+ }
+ if (pam_session_open) {
+ pam_close_session(pam_handle, PAM_SILENT);
+ pam_session_open = 0;
+ }
+ pam_authenticated = pam_new_authtok_reqd = 0;
+ pam_end(pam_handle, pam_err);
+ pam_handle = NULL;
+}
+
+static int
+pam_init(const char *user)
+{
+ extern ServerOptions options;
+ extern u_int utmp_len;
+ const char *pam_rhost, *pam_user;
+
+ if (pam_handle != NULL) {
+ /* We already have a PAM context; check if the user matches */
+ pam_err = pam_get_item(pam_handle,
+ PAM_USER, (const void **)&pam_user);
+ if (pam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0)
+ return (0);
+ fatal_remove_cleanup(pam_cleanup, NULL);
+ pam_end(pam_handle, pam_err);
+ pam_handle = NULL;
+ }
+ debug("PAM: initializing for \"%s\"", user);
+ pam_err = pam_start("sshd", user, &null_conv, &pam_handle);
+ if (pam_err != PAM_SUCCESS)
+ return (-1);
+ pam_rhost = get_remote_name_or_ip(utmp_len,
+ options.verify_reverse_mapping);
+ debug("PAM: setting PAM_RHOST to \"%s\"", pam_rhost);
+ pam_err = pam_set_item(pam_handle, PAM_RHOST, pam_rhost);
+ if (pam_err != PAM_SUCCESS) {
+ pam_end(pam_handle, pam_err);
+ pam_handle = NULL;
+ return (-1);
+ }
+ fatal_add_cleanup(pam_cleanup, NULL);
+ return (0);
+}
+
+static void *
+pam_init_ctx(Authctxt *authctxt)
+{
+ struct pam_ctxt *ctxt;
+ int socks[2];
+
+ /* Initialize PAM */
+ if (pam_init(authctxt->user) == -1) {
+ error("PAM: initialization failed");
+ return (NULL);
+ }
+
+ ctxt = xmalloc(sizeof *ctxt);
+ ctxt->pam_done = 0;
+
+ /* Start the authentication thread */
+ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
+ error("PAM: failed create sockets: %s", strerror(errno));
+ xfree(ctxt);
+ return (NULL);
+ }
+ ctxt->pam_psock = socks[0];
+ ctxt->pam_csock = socks[1];
+ if (pthread_create(&ctxt->pam_thread, NULL, pam_thread, ctxt) == -1) {
+ error("PAM: failed to start authentication thread: %s",
+ strerror(errno));
+ close(socks[0]);
+ close(socks[1]);
+ xfree(ctxt);
+ return (NULL);
+ }
+ fatal_add_cleanup(pam_thread_cleanup, ctxt);
+ return (ctxt);
+}
+
+static int
+pam_query(void *ctx, char **name, char **info,
+ u_int *num, char ***prompts, u_int **echo_on)
+{
+ Buffer buffer;
+ struct pam_ctxt *ctxt = ctx;
+ size_t plen;
+ u_char type;
+ char *msg;
+
+ buffer_init(&buffer);
+ *name = xstrdup("");
+ *info = xstrdup("");
+ *prompts = xmalloc(sizeof(char *));
+ **prompts = NULL;
+ plen = 0;
+ *echo_on = xmalloc(sizeof(u_int));
+ while (ssh_msg_recv(ctxt->pam_psock, &buffer) == 0) {
+ type = buffer_get_char(&buffer);
+ msg = buffer_get_string(&buffer, NULL);
+ switch (type) {
+ case PAM_PROMPT_ECHO_ON:
+ case PAM_PROMPT_ECHO_OFF:
+ *num = 1;
+ **prompts = xrealloc(**prompts, plen + strlen(msg) + 1);
+ plen += sprintf(**prompts + plen, "%s", msg);
+ **echo_on = (type == PAM_PROMPT_ECHO_ON);
+ xfree(msg);
+ return (0);
+ case PAM_ERROR_MSG:
+ case PAM_TEXT_INFO:
+ /* accumulate messages */
+ **prompts = xrealloc(**prompts, plen + strlen(msg) + 1);
+ plen += sprintf(**prompts + plen, "%s", msg);
+ xfree(msg);
+ break;
+ case PAM_NEW_AUTHTOK_REQD:
+ pam_new_authtok_reqd = 1;
+ /* FALLTHROUGH */
+ case PAM_SUCCESS:
+ case PAM_AUTH_ERR:
+ if (**prompts != NULL) {
+ /* drain any accumulated messages */
+#if 0 /* not compatible with privsep */
+ packet_start(SSH2_MSG_USERAUTH_BANNER);
+ packet_put_cstring(**prompts);
+ packet_put_cstring("");
+ packet_send();
+ packet_write_wait();
+#endif
+ xfree(**prompts);
+ **prompts = NULL;
+ }
+ if (type == PAM_SUCCESS) {
+ *num = 0;
+ **echo_on = 0;
+ ctxt->pam_done = 1;
+ xfree(msg);
+ return (0);
+ }
+ error("PAM: %s", msg);
+ default:
+ *num = 0;
+ **echo_on = 0;
+ xfree(msg);
+ ctxt->pam_done = -1;
+ return (-1);
+ }
+ }
+ return (-1);
+}
+
+static int
+pam_respond(void *ctx, u_int num, char **resp)
+{
+ Buffer buffer;
+ struct pam_ctxt *ctxt = ctx;
+ char *msg;
+
+ debug2("PAM: %s", __func__);
+ switch (ctxt->pam_done) {
+ case 1:
+ pam_authenticated = 1;
+ return (0);
+ case 0:
+ break;
+ default:
+ return (-1);
+ }
+ if (num != 1) {
+ error("PAM: expected one response, got %u", num);
+ return (-1);
+ }
+ buffer_init(&buffer);
+ buffer_put_cstring(&buffer, *resp);
+ ssh_msg_send(ctxt->pam_psock, PAM_AUTHTOK, &buffer);
+ buffer_free(&buffer);
+ return (1);
+}
+
+static void
+pam_free_ctx(void *ctxtp)
+{
+ struct pam_ctxt *ctxt = ctxtp;
+
+ fatal_remove_cleanup(pam_thread_cleanup, ctxt);
+ pam_thread_cleanup(ctxtp);
+ xfree(ctxt);
+ /*
+ * We don't call pam_cleanup() here because we may need the PAM
+ * handle at a later stage, e.g. when setting up a session. It's
+ * still on the cleanup list, so pam_end() *will* be called before
+ * the server process terminates.
+ */
+}
+
+KbdintDevice pam_device = {
+ "pam",
+ pam_init_ctx,
+ pam_query,
+ pam_respond,
+ pam_free_ctx
+};
+
+KbdintDevice mm_pam_device = {
+ "pam",
+ mm_pam_init_ctx,
+ mm_pam_query,
+ mm_pam_respond,
+ mm_pam_free_ctx
+};
+
+/*
+ * This replaces auth-pam.c
+ */
+void
+start_pam(const char *user)
+{
+ if (pam_init(user) == -1)
+ fatal("PAM: initialisation failed");
+}
+
+void
+finish_pam(void)
+{
+ fatal_remove_cleanup(pam_cleanup, NULL);
+ pam_cleanup(NULL);
+}
+
+int
+do_pam_account(const char *user, const char *ruser)
+{
+ /* XXX */
+ return (1);
+}
+
+void
+do_pam_session(const char *user, const char *tty)
+{
+ pam_err = pam_set_item(pam_handle, PAM_CONV, (const void *)&null_conv);
+ if (pam_err != PAM_SUCCESS)
+ fatal("PAM: failed to set PAM_CONV: %s",
+ pam_strerror(pam_handle, pam_err));
+ debug("PAM: setting PAM_TTY to \"%s\"", tty);
+ pam_err = pam_set_item(pam_handle, PAM_TTY, tty);
+ if (pam_err != PAM_SUCCESS)
+ fatal("PAM: failed to set PAM_TTY: %s",
+ pam_strerror(pam_handle, pam_err));
+ pam_err = pam_open_session(pam_handle, 0);
+ if (pam_err != PAM_SUCCESS)
+ fatal("PAM: pam_open_session(): %s",
+ pam_strerror(pam_handle, pam_err));
+ pam_session_open = 1;
+}
+
+void
+do_pam_setcred(int init)
+{
+ pam_err = pam_set_item(pam_handle, PAM_CONV, (const void *)&null_conv);
+ if (pam_err != PAM_SUCCESS)
+ fatal("PAM: failed to set PAM_CONV: %s",
+ pam_strerror(pam_handle, pam_err));
+ if (init) {
+ debug("PAM: establishing credentials");
+ pam_err = pam_setcred(pam_handle, PAM_ESTABLISH_CRED);
+ } else {
+ debug("PAM: reinitializing credentials");
+ pam_err = pam_setcred(pam_handle, PAM_REINITIALIZE_CRED);
+ }
+ if (pam_err == PAM_SUCCESS) {
+ pam_cred_established = 1;
+ return;
+ }
+ if (pam_authenticated)
+ fatal("PAM: pam_setcred(): %s",
+ pam_strerror(pam_handle, pam_err));
+ else
+ debug("PAM: pam_setcred(): %s",
+ pam_strerror(pam_handle, pam_err));
+}
+
+int
+is_pam_password_change_required(void)
+{
+ return (pam_new_authtok_reqd);
+}
+
+static int
+pam_chauthtok_conv(int n,
+ const struct pam_message **msg,
+ struct pam_response **resp,
+ void *data)
+{
+ char input[PAM_MAX_MSG_SIZE];
+ int i;
+
+ if (n <= 0 || n > PAM_MAX_NUM_MSG)
+ return (PAM_CONV_ERR);
+ *resp = xmalloc(n * sizeof **resp);
+ for (i = 0; i < n; ++i) {
+ switch (msg[i]->msg_style) {
+ case PAM_PROMPT_ECHO_OFF:
+ (*resp)[i].resp =
+ read_passphrase(msg[i]->msg, RP_ALLOW_STDIN);
+ (*resp)[i].resp_retcode = PAM_SUCCESS;
+ break;
+ case PAM_PROMPT_ECHO_ON:
+ fputs(msg[i]->msg, stderr);
+ fgets(input, sizeof input, stdin);
+ (*resp)[i].resp = xstrdup(input);
+ (*resp)[i].resp_retcode = PAM_SUCCESS;
+ break;
+ case PAM_ERROR_MSG:
+ case PAM_TEXT_INFO:
+ fputs(msg[i]->msg, stderr);
+ (*resp)[i].resp_retcode = PAM_SUCCESS;
+ break;
+ default:
+ goto fail;
+ }
+ }
+ return (PAM_SUCCESS);
+ fail:
+ xfree(*resp);
+ *resp = NULL;
+ return (PAM_CONV_ERR);
+}
+
+/*
+ * XXX this should be done in the authentication phase, but ssh1 doesn't
+ * support that
+ */
+void
+do_pam_chauthtok(void)
+{
+ struct pam_conv pam_conv = { pam_chauthtok_conv, NULL };
+
+ if (use_privsep)
+ fatal("PAM: chauthtok not supprted with privsep");
+ pam_err = pam_set_item(pam_handle, PAM_CONV, (const void *)&pam_conv);
+ if (pam_err != PAM_SUCCESS)
+ fatal("PAM: failed to set PAM_CONV: %s",
+ pam_strerror(pam_handle, pam_err));
+ debug("PAM: changing password");
+ pam_err = pam_chauthtok(pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+ if (pam_err != PAM_SUCCESS)
+ fatal("PAM: pam_chauthtok(): %s",
+ pam_strerror(pam_handle, pam_err));
+}
+
+void
+print_pam_messages(void)
+{
+ /* XXX */
+}
+
+char **
+fetch_pam_environment(void)
+{
+#ifdef HAVE_PAM_GETENVLIST
+ debug("PAM: retrieving environment");
+ return (pam_getenvlist(pam_handle));
+#else
+ return (NULL);
+#endif
+}
+
+void
+free_pam_environment(char **env)
+{
+ char **envp;
+
+ for (envp = env; *envp; envp++)
+ xfree(*envp);
+ xfree(env);
+}
+
+#endif /* USE_PAM */
diff --git a/crypto/openssh/auth2-skey.c b/crypto/openssh/auth2-skey.c
deleted file mode 100644
index 9de08fc..0000000
--- 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/auth2.c b/crypto/openssh/auth2.c
index 41e77ef..9cbe376 100644
--- a/crypto/openssh/auth2.c
+++ b/crypto/openssh/auth2.c
@@ -23,8 +23,10 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth2.c,v 1.102 2003/08/26 09:58:43 markus Exp $");
+RCSID("$OpenBSD: auth2.c,v 1.96 2003/02/06 21:22:43 markus Exp $");
+RCSID("$FreeBSD$");
+#include "canohost.h"
#include "ssh2.h"
#include "xmalloc.h"
#include "packet.h"
@@ -36,14 +38,10 @@ RCSID("$OpenBSD: auth2.c,v 1.102 2003/08/26 09:58:43 markus Exp $");
#include "pathnames.h"
#include "monitor_wrap.h"
-#ifdef GSSAPI
-#include "ssh-gss.h"
-#endif
-
/* import */
extern ServerOptions options;
extern u_char *session_id2;
-extern u_int session_id2_len;
+extern int session_id2_len;
Authctxt *x_authctxt = NULL;
@@ -54,16 +52,10 @@ extern Authmethod method_pubkey;
extern Authmethod method_passwd;
extern Authmethod method_kbdint;
extern Authmethod method_hostbased;
-#ifdef GSSAPI
-extern Authmethod method_gssapi;
-#endif
Authmethod *authmethods[] = {
&method_none,
&method_pubkey,
-#ifdef GSSAPI
- &method_gssapi,
-#endif
&method_passwd,
&method_kbdint,
&method_hostbased,
@@ -95,6 +87,10 @@ do_authentication2(void)
/* challenge-response is implemented via keyboard interactive */
if (options.challenge_response_authentication)
options.kbd_interactive_authentication = 1;
+ if (options.pam_authentication_via_kbd_int)
+ options.kbd_interactive_authentication = 1;
+ if (use_privsep)
+ options.pam_authentication_via_kbd_int = 0;
dispatch_init(&dispatch_protocol_error);
dispatch_set(SSH2_MSG_SERVICE_REQUEST, &input_service_request);
@@ -143,6 +139,13 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
Authmethod *m = NULL;
char *user, *service, *method, *style = NULL;
int authenticated = 0;
+#ifdef HAVE_LOGIN_CAP
+ login_cap_t *lc;
+ const char *from_host, *from_ip;
+
+ from_host = get_canonical_hostname(options.verify_reverse_mapping);
+ from_ip = get_remote_ipaddr();
+#endif
if (authctxt == NULL)
fatal("input_userauth_request: no authctxt");
@@ -163,15 +166,12 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
authctxt->valid = 1;
debug2("input_userauth_request: setting up authctxt for %s", user);
#ifdef USE_PAM
- if (options.use_pam)
- PRIVSEP(start_pam(authctxt->pw->pw_name));
+ PRIVSEP(start_pam(authctxt->pw->pw_name));
#endif
} else {
- logit("input_userauth_request: illegal user %s", user);
- authctxt->pw = fakepw();
+ log("input_userauth_request: illegal user %s", user);
#ifdef USE_PAM
- if (options.use_pam)
- PRIVSEP(start_pam(user));
+ PRIVSEP(start_pam("NOUSER"));
#endif
}
setproctitle("%s%s", authctxt->pw ? user : "unknown",
@@ -187,14 +187,29 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
"(%s,%s) -> (%s,%s)",
authctxt->user, authctxt->service, user, service);
}
- /* reset state */
- auth2_challenge_stop(authctxt);
-#ifdef GSSAPI
- dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
- dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL);
-#endif
+#ifdef HAVE_LOGIN_CAP
+ if (authctxt->pw != NULL) {
+ lc = login_getpwclass(authctxt->pw);
+ if (lc == NULL)
+ lc = login_getclassbyname(NULL, authctxt->pw);
+ if (!auth_hostok(lc, from_host, from_ip)) {
+ log("Denied connection for %.200s from %.200s [%.200s].",
+ authctxt->pw->pw_name, from_host, from_ip);
+ packet_disconnect("Sorry, you are not allowed to connect.");
+ }
+ if (!auth_timeok(lc, time(NULL))) {
+ log("LOGIN %.200s REFUSED (TIME) FROM %.200s",
+ authctxt->pw->pw_name, from_host);
+ packet_disconnect("Logins not available right now.");
+ }
+ login_close(lc);
+ lc = NULL;
+ }
+#endif /* HAVE_LOGIN_CAP */
+ /* reset state */
+ auth2_challenge_stop(authctxt);
authctxt->postponed = 0;
/* try to authenticate user */
@@ -225,9 +240,10 @@ userauth_finish(Authctxt *authctxt, int authenticated, char *method)
authenticated = 0;
#ifdef USE_PAM
- if (options.use_pam && authenticated && !PRIVSEP(do_pam_account()))
+ if (!use_privsep && authenticated && authctxt->user &&
+ !do_pam_account(authctxt->user, NULL))
authenticated = 0;
-#endif
+#endif /* USE_PAM */
#ifdef _UNICOS
if (authenticated && cray_access_denied(authctxt->user)) {
@@ -252,8 +268,13 @@ userauth_finish(Authctxt *authctxt, int authenticated, char *method)
/* now we can break out */
authctxt->success = 1;
} else {
- if (authctxt->failures++ > AUTH_FAIL_MAX)
+ if (authctxt->failures++ > AUTH_FAIL_MAX) {
packet_disconnect(AUTH_FAIL_MSG, authctxt->user);
+ }
+#ifdef _UNICOS
+ if (strcmp(method, "password") == 0)
+ cray_login_failure(authctxt->user, IA_UDBERR);
+#endif /* _UNICOS */
methods = authmethods_get();
packet_start(SSH2_MSG_USERAUTH_FAILURE);
packet_put_cstring(methods);
diff --git a/crypto/openssh/authfd.c b/crypto/openssh/authfd.c
index c78db6d..a186e01 100644
--- a/crypto/openssh/authfd.c
+++ b/crypto/openssh/authfd.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfd.c,v 1.61 2003/06/28 16:23:06 deraadt Exp $");
+RCSID("$OpenBSD: authfd.c,v 1.58 2003/01/23 13:50:27 markus Exp $");
#include <openssl/evp.h>
@@ -122,8 +122,8 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply
PUT_32BIT(buf, len);
/* Send the length and then the packet to the agent. */
- if (atomicio(vwrite, auth->fd, buf, 4) != 4 ||
- atomicio(vwrite, auth->fd, buffer_ptr(request),
+ if (atomicio(write, auth->fd, buf, 4) != 4 ||
+ atomicio(write, auth->fd, buffer_ptr(request),
buffer_len(request)) != buffer_len(request)) {
error("Error writing to authentication socket.");
return 0;
@@ -332,7 +332,7 @@ ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int versio
buffer_get_bignum(&auth->identities, key->rsa->n);
*comment = buffer_get_string(&auth->identities, NULL);
if (bits != BN_num_bits(key->rsa->n))
- logit("Warning: identity keysize mismatch: actual %d, announced %u",
+ log("Warning: identity keysize mismatch: actual %d, announced %u",
BN_num_bits(key->rsa->n), bits);
break;
case 2:
@@ -373,7 +373,7 @@ ssh_decrypt_challenge(AuthenticationConnection *auth,
if (key->type != KEY_RSA1)
return 0;
if (response_type == 0) {
- logit("Compatibility with ssh protocol version 1.0 no longer supported.");
+ log("Compatibility with ssh protocol version 1.0 no longer supported.");
return 0;
}
buffer_init(&buffer);
@@ -392,7 +392,7 @@ ssh_decrypt_challenge(AuthenticationConnection *auth,
type = buffer_get_char(&buffer);
if (agent_failed(type)) {
- logit("Agent admitted failure to authenticate using the key.");
+ log("Agent admitted failure to authenticate using the key.");
} else if (type != SSH_AGENT_RSA_RESPONSE) {
fatal("Bad authentication response: %d", type);
} else {
@@ -441,7 +441,7 @@ ssh_agent_sign(AuthenticationConnection *auth,
}
type = buffer_get_char(&msg);
if (agent_failed(type)) {
- logit("Agent admitted failure to sign using the key.");
+ log("Agent admitted failure to sign using the key.");
} else if (type != SSH2_AGENT_SIGN_RESPONSE) {
fatal("Bad authentication response: %d", type);
} else {
@@ -589,33 +589,16 @@ ssh_remove_identity(AuthenticationConnection *auth, Key *key)
}
int
-ssh_update_card(AuthenticationConnection *auth, int add,
- const char *reader_id, const char *pin, u_int life, u_int confirm)
+ssh_update_card(AuthenticationConnection *auth, int add, const char *reader_id, const char *pin)
{
Buffer msg;
- int type, constrained = (life || confirm);
-
- if (add) {
- type = constrained ?
- SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED :
- SSH_AGENTC_ADD_SMARTCARD_KEY;
- } else
- type = SSH_AGENTC_REMOVE_SMARTCARD_KEY;
+ int type;
buffer_init(&msg);
- buffer_put_char(&msg, type);
+ buffer_put_char(&msg, add ? SSH_AGENTC_ADD_SMARTCARD_KEY :
+ SSH_AGENTC_REMOVE_SMARTCARD_KEY);
buffer_put_cstring(&msg, reader_id);
buffer_put_cstring(&msg, pin);
-
- if (constrained) {
- if (life != 0) {
- buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_LIFETIME);
- buffer_put_int(&msg, life);
- }
- if (confirm != 0)
- buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_CONFIRM);
- }
-
if (ssh_request_reply(auth, &msg, &msg) == 0) {
buffer_free(&msg);
return 0;
@@ -658,7 +641,7 @@ decode_reply(int type)
case SSH_AGENT_FAILURE:
case SSH_COM_AGENT2_FAILURE:
case SSH2_AGENT_FAILURE:
- logit("SSH_AGENT_FAILURE");
+ log("SSH_AGENT_FAILURE");
return 0;
case SSH_AGENT_SUCCESS:
return 1;
diff --git a/crypto/openssh/authfile.c b/crypto/openssh/authfile.c
index 1f46093..90618ef 100644
--- a/crypto/openssh/authfile.c
+++ b/crypto/openssh/authfile.c
@@ -36,7 +36,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.54 2003/05/24 09:30:39 djm Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.52 2003/03/13 11:42:18 markus Exp $");
#include <openssl/err.h>
#include <openssl/evp.h>
@@ -514,7 +514,7 @@ key_perm_ok(int fd, const char *filename)
error("@ WARNING: UNPROTECTED PRIVATE KEY FILE! @");
error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
error("Permissions 0%3.3o for '%s' are too open.",
- (u_int)st.st_mode & 0777, filename);
+ st.st_mode & 0777, filename);
error("It is recommended that your private key files are NOT accessible by others.");
error("This private key will be ignored.");
return 0;
@@ -629,18 +629,9 @@ key_load_public(const char *filename, char **commentp)
Key *pub;
char file[MAXPATHLEN];
- /* try rsa1 private key */
pub = key_load_public_type(KEY_RSA1, filename, commentp);
if (pub != NULL)
return pub;
-
- /* try rsa1 public key */
- pub = key_new(KEY_RSA1);
- if (key_try_load_public(pub, filename, commentp) == 1)
- return pub;
- key_free(pub);
-
- /* try ssh2 public key */
pub = key_new(KEY_UNSPEC);
if (key_try_load_public(pub, filename, commentp) == 1)
return pub;
diff --git a/crypto/openssh/aux.c b/crypto/openssh/aux.c
deleted file mode 100644
index 899142d..0000000
--- 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/bufaux.c b/crypto/openssh/bufaux.c
index 37cc27f..ebb59f7 100644
--- a/crypto/openssh/bufaux.c
+++ b/crypto/openssh/bufaux.c
@@ -37,7 +37,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: bufaux.c,v 1.29 2003/04/08 20:21:28 itojun Exp $");
+RCSID("$OpenBSD: bufaux.c,v 1.28 2002/10/23 10:40:16 markus Exp $");
+RCSID("$FreeBSD$");
#include <openssl/bn.h>
#include "bufaux.h"
@@ -119,7 +120,7 @@ buffer_put_bignum2(Buffer *buffer, BIGNUM *value)
/**XXX should be two's-complement */
int i, carry;
u_char *uc = buf;
- logit("negativ!");
+ log("negativ!");
for (i = bytes-1, carry = 1; i>=0; i--) {
uc[i] ^= 0xff;
if (carry)
@@ -165,6 +166,7 @@ buffer_get_int(Buffer *buffer)
return GET_32BIT(buf);
}
+#ifdef HAVE_U_INT64_T
u_int64_t
buffer_get_int64(Buffer *buffer)
{
@@ -173,6 +175,7 @@ buffer_get_int64(Buffer *buffer)
buffer_get(buffer, (char *) buf, 8);
return GET_64BIT(buf);
}
+#endif
/*
* Stores integers in the buffer, msb first.
@@ -195,6 +198,7 @@ buffer_put_int(Buffer *buffer, u_int value)
buffer_append(buffer, buf, 4);
}
+#ifdef HAVE_U_INT64_T
void
buffer_put_int64(Buffer *buffer, u_int64_t value)
{
@@ -203,6 +207,7 @@ buffer_put_int64(Buffer *buffer, u_int64_t value)
PUT_64BIT(buf, value);
buffer_append(buffer, buf, 8);
}
+#endif
/*
* Returns an arbitrary binary string from the buffer. The string cannot
diff --git a/crypto/openssh/canohost.c b/crypto/openssh/canohost.c
index 438175f..941db23 100644
--- a/crypto/openssh/canohost.c
+++ b/crypto/openssh/canohost.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: canohost.c,v 1.37 2003/06/02 09:17:34 markus Exp $");
+RCSID("$OpenBSD: canohost.c,v 1.35 2002/11/26 02:38:54 stevesk Exp $");
#include "packet.h"
#include "xmalloc.h"
@@ -27,7 +27,7 @@ static void check_ip_options(int, char *);
*/
static char *
-get_remote_hostname(int socket, int use_dns)
+get_remote_hostname(int socket, int verify_reverse_mapping)
{
struct sockaddr_storage from;
int i;
@@ -72,9 +72,6 @@ get_remote_hostname(int socket, int use_dns)
NULL, 0, NI_NUMERICHOST) != 0)
fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed");
- if (!use_dns)
- return xstrdup(ntop);
-
if (from.ss_family == AF_INET)
check_ip_options(socket, ntop);
@@ -83,24 +80,14 @@ get_remote_hostname(int socket, int use_dns)
if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
NULL, 0, NI_NAMEREQD) != 0) {
/* Host name not found. Use ip address. */
+#if 0
+ log("Could not reverse map address %.100s.", ntop);
+#endif
return xstrdup(ntop);
}
- /*
- * if reverse lookup result looks like a numeric hostname,
- * someone is trying to trick us by PTR record like following:
- * 1.1.1.10.in-addr.arpa. IN PTR 2.3.4.5
- */
- memset(&hints, 0, sizeof(hints));
- hints.ai_socktype = SOCK_DGRAM; /*dummy*/
- hints.ai_flags = AI_NUMERICHOST;
- if (getaddrinfo(name, "0", &hints, &ai) == 0) {
- logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
- name, ntop);
- freeaddrinfo(ai);
- return xstrdup(ntop);
- }
-
+ /* Got host name. */
+ name[sizeof(name) - 1] = '\0';
/*
* Convert it to all lowercase (which is expected by the rest
* of this software).
@@ -108,6 +95,9 @@ get_remote_hostname(int socket, int use_dns)
for (i = 0; name[i]; i++)
if (isupper(name[i]))
name[i] = tolower(name[i]);
+
+ if (!verify_reverse_mapping)
+ return xstrdup(name);
/*
* Map it back to an IP address and check that the given
* address actually is an address of this host. This is
@@ -121,7 +111,7 @@ get_remote_hostname(int socket, int use_dns)
hints.ai_family = from.ss_family;
hints.ai_socktype = SOCK_STREAM;
if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
- logit("reverse mapping checking getaddrinfo for %.700s "
+ log("reverse mapping checking getaddrinfo for %.700s "
"failed - POSSIBLE BREAKIN ATTEMPT!", name);
return xstrdup(ntop);
}
@@ -136,7 +126,7 @@ get_remote_hostname(int socket, int use_dns)
/* If we reached the end of the list, the address was not there. */
if (!ai) {
/* Address not found for the host name. */
- logit("Address %.100s maps to %.600s, but this does not "
+ log("Address %.100s maps to %.600s, but this does not "
"map back to the address - POSSIBLE BREAKIN ATTEMPT!",
ntop, name);
return xstrdup(ntop);
@@ -159,7 +149,6 @@ get_remote_hostname(int socket, int use_dns)
static void
check_ip_options(int socket, char *ipaddr)
{
-#ifdef IP_OPTIONS
u_char options[200];
char text[sizeof(options) * 3 + 1];
socklen_t option_size;
@@ -177,12 +166,11 @@ check_ip_options(int socket, char *ipaddr)
for (i = 0; i < option_size; i++)
snprintf(text + i*3, sizeof(text) - i*3,
" %2.2x", options[i]);
- logit("Connection from %.100s with IP options:%.800s",
+ log("Connection from %.100s with IP options:%.800s",
ipaddr, text);
packet_disconnect("Connection from %.100s with IP options:%.800s",
ipaddr, text);
}
-#endif /* IP_OPTIONS */
}
/*
@@ -192,14 +180,14 @@ check_ip_options(int socket, char *ipaddr)
*/
const char *
-get_canonical_hostname(int use_dns)
+get_canonical_hostname(int verify_reverse_mapping)
{
static char *canonical_host_name = NULL;
- static int use_dns_done = 0;
+ static int verify_reverse_mapping_done = 0;
/* Check if we have previously retrieved name with same option. */
if (canonical_host_name != NULL) {
- if (use_dns_done != use_dns)
+ if (verify_reverse_mapping_done != verify_reverse_mapping)
xfree(canonical_host_name);
else
return canonical_host_name;
@@ -208,11 +196,11 @@ get_canonical_hostname(int use_dns)
/* Get the real hostname if socket; otherwise return UNKNOWN. */
if (packet_connection_is_on_socket())
canonical_host_name = get_remote_hostname(
- packet_get_connection_in(), use_dns);
+ packet_get_connection_in(), verify_reverse_mapping);
else
canonical_host_name = xstrdup("UNKNOWN");
- use_dns_done = use_dns;
+ verify_reverse_mapping_done = verify_reverse_mapping;
return canonical_host_name;
}
@@ -306,11 +294,11 @@ get_remote_ipaddr(void)
}
const char *
-get_remote_name_or_ip(u_int utmp_len, int use_dns)
+get_remote_name_or_ip(u_int utmp_len, int verify_reverse_mapping)
{
static const char *remote = "";
if (utmp_len > 0)
- remote = get_canonical_hostname(use_dns);
+ remote = get_canonical_hostname(verify_reverse_mapping);
if (utmp_len == 0 || strlen(remote) > utmp_len)
remote = get_remote_ipaddr();
return remote;
diff --git a/crypto/openssh/cipher.c b/crypto/openssh/cipher.c
index ce53367..b5d3874 100644
--- a/crypto/openssh/cipher.c
+++ b/crypto/openssh/cipher.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: cipher.c,v 1.65 2003/05/17 04:27:52 markus Exp $");
+RCSID("$OpenBSD: cipher.c,v 1.62 2002/11/21 22:45:31 markus Exp $");
#include "xmalloc.h"
#include "log.h"
@@ -49,14 +49,11 @@ RCSID("$OpenBSD: cipher.c,v 1.65 2003/05/17 04:27:52 markus Exp $");
#endif
#if OPENSSL_VERSION_NUMBER < 0x00907000L
-extern const EVP_CIPHER *evp_rijndael(void);
-extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
+#include "rijndael.h"
+static const EVP_CIPHER *evp_rijndael(void);
#endif
-extern const EVP_CIPHER *evp_ssh1_bf(void);
-extern const EVP_CIPHER *evp_ssh1_3des(void);
-extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int);
-extern const EVP_CIPHER *evp_aes_128_ctr(void);
-extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
+static const EVP_CIPHER *evp_ssh1_3des(void);
+static const EVP_CIPHER *evp_ssh1_bf(void);
struct Cipher {
char *name;
@@ -87,11 +84,6 @@ struct Cipher {
{ "rijndael-cbc@lysator.liu.se",
SSH_CIPHER_SSH2, 16, 32, EVP_aes_256_cbc },
#endif
-#if OPENSSL_VERSION_NUMBER >= 0x00906000L
- { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, evp_aes_128_ctr },
- { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, evp_aes_128_ctr },
- { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, evp_aes_128_ctr },
-#endif
{ NULL, SSH_CIPHER_ILLEGAL, 0, 0, NULL }
};
@@ -304,6 +296,298 @@ cipher_set_key_string(CipherContext *cc, Cipher *cipher,
memset(&md, 0, sizeof(md));
}
+/* Implementations for other non-EVP ciphers */
+
+/*
+ * This is used by SSH1:
+ *
+ * What kind of triple DES are these 2 routines?
+ *
+ * Why is there a redundant initialization vector?
+ *
+ * If only iv3 was used, then, this would till effect have been
+ * outer-cbc. However, there is also a private iv1 == iv2 which
+ * perhaps makes differential analysis easier. On the other hand, the
+ * private iv1 probably makes the CRC-32 attack ineffective. This is a
+ * result of that there is no longer any known iv1 to use when
+ * choosing the X block.
+ */
+struct ssh1_3des_ctx
+{
+ EVP_CIPHER_CTX k1, k2, k3;
+};
+
+static int
+ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
+ int enc)
+{
+ struct ssh1_3des_ctx *c;
+ u_char *k1, *k2, *k3;
+
+ if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) == NULL) {
+ c = xmalloc(sizeof(*c));
+ EVP_CIPHER_CTX_set_app_data(ctx, c);
+ }
+ if (key == NULL)
+ return (1);
+ if (enc == -1)
+ enc = ctx->encrypt;
+ k1 = k2 = k3 = (u_char *) key;
+ k2 += 8;
+ if (EVP_CIPHER_CTX_key_length(ctx) >= 16+8) {
+ if (enc)
+ k3 += 16;
+ else
+ k1 += 16;
+ }
+ EVP_CIPHER_CTX_init(&c->k1);
+ EVP_CIPHER_CTX_init(&c->k2);
+ EVP_CIPHER_CTX_init(&c->k3);
+#ifdef SSH_OLD_EVP
+ EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc);
+ EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc);
+ EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc);
+#else
+ if (EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc) == 0 ||
+ EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc) == 0 ||
+ EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc) == 0) {
+ memset(c, 0, sizeof(*c));
+ xfree(c);
+ EVP_CIPHER_CTX_set_app_data(ctx, NULL);
+ return (0);
+ }
+#endif
+ return (1);
+}
+
+static int
+ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, u_int len)
+{
+ struct ssh1_3des_ctx *c;
+
+ if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) == NULL) {
+ error("ssh1_3des_cbc: no context");
+ return (0);
+ }
+#ifdef SSH_OLD_EVP
+ EVP_Cipher(&c->k1, dest, (u_char *)src, len);
+ EVP_Cipher(&c->k2, dest, dest, len);
+ EVP_Cipher(&c->k3, dest, dest, len);
+#else
+ if (EVP_Cipher(&c->k1, dest, (u_char *)src, len) == 0 ||
+ EVP_Cipher(&c->k2, dest, dest, len) == 0 ||
+ EVP_Cipher(&c->k3, dest, dest, len) == 0)
+ return (0);
+#endif
+ return (1);
+}
+
+static int
+ssh1_3des_cleanup(EVP_CIPHER_CTX *ctx)
+{
+ struct ssh1_3des_ctx *c;
+
+ if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
+ memset(c, 0, sizeof(*c));
+ xfree(c);
+ EVP_CIPHER_CTX_set_app_data(ctx, NULL);
+ }
+ return (1);
+}
+
+static const EVP_CIPHER *
+evp_ssh1_3des(void)
+{
+ static EVP_CIPHER ssh1_3des;
+
+ memset(&ssh1_3des, 0, sizeof(EVP_CIPHER));
+ ssh1_3des.nid = NID_undef;
+ ssh1_3des.block_size = 8;
+ ssh1_3des.iv_len = 0;
+ ssh1_3des.key_len = 16;
+ ssh1_3des.init = ssh1_3des_init;
+ ssh1_3des.cleanup = ssh1_3des_cleanup;
+ ssh1_3des.do_cipher = ssh1_3des_cbc;
+#ifndef SSH_OLD_EVP
+ ssh1_3des.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH;
+#endif
+ return (&ssh1_3des);
+}
+
+/*
+ * SSH1 uses a variation on Blowfish, all bytes must be swapped before
+ * and after encryption/decryption. Thus the swap_bytes stuff (yuk).
+ */
+static void
+swap_bytes(const u_char *src, u_char *dst, int n)
+{
+ u_char c[4];
+
+ /* Process 4 bytes every lap. */
+ for (n = n / 4; n > 0; n--) {
+ c[3] = *src++;
+ c[2] = *src++;
+ c[1] = *src++;
+ c[0] = *src++;
+
+ *dst++ = c[0];
+ *dst++ = c[1];
+ *dst++ = c[2];
+ *dst++ = c[3];
+ }
+}
+
+#ifdef SSH_OLD_EVP
+static void bf_ssh1_init (EVP_CIPHER_CTX * ctx, const unsigned char *key,
+ const unsigned char *iv, int enc)
+{
+ if (iv != NULL)
+ memcpy (&(ctx->oiv[0]), iv, 8);
+ memcpy (&(ctx->iv[0]), &(ctx->oiv[0]), 8);
+ if (key != NULL)
+ BF_set_key (&(ctx->c.bf_ks), EVP_CIPHER_CTX_key_length (ctx),
+ key);
+}
+#endif
+static int (*orig_bf)(EVP_CIPHER_CTX *, u_char *, const u_char *, u_int) = NULL;
+
+static int
+bf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in, u_int len)
+{
+ int ret;
+
+ swap_bytes(in, out, len);
+ ret = (*orig_bf)(ctx, out, out, len);
+ swap_bytes(out, out, len);
+ return (ret);
+}
+
+static const EVP_CIPHER *
+evp_ssh1_bf(void)
+{
+ static EVP_CIPHER ssh1_bf;
+
+ memcpy(&ssh1_bf, EVP_bf_cbc(), sizeof(EVP_CIPHER));
+ orig_bf = ssh1_bf.do_cipher;
+ ssh1_bf.nid = NID_undef;
+#ifdef SSH_OLD_EVP
+ ssh1_bf.init = bf_ssh1_init;
+#endif
+ ssh1_bf.do_cipher = bf_ssh1_cipher;
+ ssh1_bf.key_len = 32;
+ return (&ssh1_bf);
+}
+
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+/* RIJNDAEL */
+#define RIJNDAEL_BLOCKSIZE 16
+struct ssh_rijndael_ctx
+{
+ rijndael_ctx r_ctx;
+ u_char r_iv[RIJNDAEL_BLOCKSIZE];
+};
+
+static int
+ssh_rijndael_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
+ int enc)
+{
+ struct ssh_rijndael_ctx *c;
+
+ if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) == NULL) {
+ c = xmalloc(sizeof(*c));
+ EVP_CIPHER_CTX_set_app_data(ctx, c);
+ }
+ if (key != NULL) {
+ if (enc == -1)
+ enc = ctx->encrypt;
+ rijndael_set_key(&c->r_ctx, (u_char *)key,
+ 8*EVP_CIPHER_CTX_key_length(ctx), enc);
+ }
+ if (iv != NULL)
+ memcpy(c->r_iv, iv, RIJNDAEL_BLOCKSIZE);
+ return (1);
+}
+
+static int
+ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
+ u_int len)
+{
+ struct ssh_rijndael_ctx *c;
+ u_char buf[RIJNDAEL_BLOCKSIZE];
+ u_char *cprev, *cnow, *plain, *ivp;
+ int i, j, blocks = len / RIJNDAEL_BLOCKSIZE;
+
+ if (len == 0)
+ return (1);
+ if (len % RIJNDAEL_BLOCKSIZE)
+ fatal("ssh_rijndael_cbc: bad len %d", len);
+ if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) == NULL) {
+ error("ssh_rijndael_cbc: no context");
+ return (0);
+ }
+ if (ctx->encrypt) {
+ cnow = dest;
+ plain = (u_char *)src;
+ cprev = c->r_iv;
+ for (i = 0; i < blocks; i++, plain+=RIJNDAEL_BLOCKSIZE,
+ cnow+=RIJNDAEL_BLOCKSIZE) {
+ for (j = 0; j < RIJNDAEL_BLOCKSIZE; j++)
+ buf[j] = plain[j] ^ cprev[j];
+ rijndael_encrypt(&c->r_ctx, buf, cnow);
+ cprev = cnow;
+ }
+ memcpy(c->r_iv, cprev, RIJNDAEL_BLOCKSIZE);
+ } else {
+ cnow = (u_char *) (src+len-RIJNDAEL_BLOCKSIZE);
+ plain = dest+len-RIJNDAEL_BLOCKSIZE;
+
+ memcpy(buf, cnow, RIJNDAEL_BLOCKSIZE);
+ for (i = blocks; i > 0; i--, cnow-=RIJNDAEL_BLOCKSIZE,
+ plain-=RIJNDAEL_BLOCKSIZE) {
+ rijndael_decrypt(&c->r_ctx, cnow, plain);
+ ivp = (i == 1) ? c->r_iv : cnow-RIJNDAEL_BLOCKSIZE;
+ for (j = 0; j < RIJNDAEL_BLOCKSIZE; j++)
+ plain[j] ^= ivp[j];
+ }
+ memcpy(c->r_iv, buf, RIJNDAEL_BLOCKSIZE);
+ }
+ return (1);
+}
+
+static int
+ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx)
+{
+ struct ssh_rijndael_ctx *c;
+
+ if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
+ memset(c, 0, sizeof(*c));
+ xfree(c);
+ EVP_CIPHER_CTX_set_app_data(ctx, NULL);
+ }
+ return (1);
+}
+
+static const EVP_CIPHER *
+evp_rijndael(void)
+{
+ static EVP_CIPHER rijndal_cbc;
+
+ memset(&rijndal_cbc, 0, sizeof(EVP_CIPHER));
+ rijndal_cbc.nid = NID_undef;
+ rijndal_cbc.block_size = RIJNDAEL_BLOCKSIZE;
+ rijndal_cbc.iv_len = RIJNDAEL_BLOCKSIZE;
+ rijndal_cbc.key_len = 16;
+ rijndal_cbc.init = ssh_rijndael_init;
+ rijndal_cbc.cleanup = ssh_rijndael_cleanup;
+ rijndal_cbc.do_cipher = ssh_rijndael_cbc;
+#ifndef SSH_OLD_EVP
+ rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
+ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
+#endif
+ return (&rijndal_cbc);
+}
+#endif
+
/*
* Exports an IV from the CipherContext required to export the key
* state back from the unprivileged child to the privileged parent
@@ -327,6 +611,7 @@ void
cipher_get_keyiv(CipherContext *cc, u_char *iv, u_int len)
{
Cipher *c = cc->cipher;
+ u_char *civ = NULL;
int evplen;
switch (c->number) {
@@ -339,28 +624,45 @@ cipher_get_keyiv(CipherContext *cc, u_char *iv, u_int len)
if (evplen != len)
fatal("%s: wrong iv length %d != %d", __func__,
evplen, len);
+
#if OPENSSL_VERSION_NUMBER < 0x00907000L
- if (c->evptype == evp_rijndael)
- ssh_rijndael_iv(&cc->evp, 0, iv, len);
- else
+ if (c->evptype == evp_rijndael) {
+ struct ssh_rijndael_ctx *aesc;
+
+ aesc = EVP_CIPHER_CTX_get_app_data(&cc->evp);
+ if (aesc == NULL)
+ fatal("%s: no rijndael context", __func__);
+ civ = aesc->r_iv;
+ } else
#endif
- if (c->evptype == evp_aes_128_ctr)
- ssh_aes_ctr_iv(&cc->evp, 0, iv, len);
- else
- memcpy(iv, cc->evp.iv, len);
- break;
- case SSH_CIPHER_3DES:
- ssh1_3des_iv(&cc->evp, 0, iv, 24);
+ {
+ civ = cc->evp.iv;
+ }
break;
+ case SSH_CIPHER_3DES: {
+ struct ssh1_3des_ctx *desc;
+ if (len != 24)
+ fatal("%s: bad 3des iv length: %d", __func__, len);
+ desc = EVP_CIPHER_CTX_get_app_data(&cc->evp);
+ if (desc == NULL)
+ fatal("%s: no 3des context", __func__);
+ debug3("%s: Copying 3DES IV", __func__);
+ memcpy(iv, desc->k1.iv, 8);
+ memcpy(iv + 8, desc->k2.iv, 8);
+ memcpy(iv + 16, desc->k3.iv, 8);
+ return;
+ }
default:
fatal("%s: bad cipher %d", __func__, c->number);
}
+ memcpy(iv, civ, len);
}
void
cipher_set_keyiv(CipherContext *cc, u_char *iv)
{
Cipher *c = cc->cipher;
+ u_char *div = NULL;
int evplen = 0;
switch (c->number) {
@@ -370,22 +672,36 @@ cipher_set_keyiv(CipherContext *cc, u_char *iv)
evplen = EVP_CIPHER_CTX_iv_length(&cc->evp);
if (evplen == 0)
return;
+
#if OPENSSL_VERSION_NUMBER < 0x00907000L
- if (c->evptype == evp_rijndael)
- ssh_rijndael_iv(&cc->evp, 1, iv, evplen);
- else
+ if (c->evptype == evp_rijndael) {
+ struct ssh_rijndael_ctx *aesc;
+
+ aesc = EVP_CIPHER_CTX_get_app_data(&cc->evp);
+ if (aesc == NULL)
+ fatal("%s: no rijndael context", __func__);
+ div = aesc->r_iv;
+ } else
#endif
- if (c->evptype == evp_aes_128_ctr)
- ssh_aes_ctr_iv(&cc->evp, 1, iv, evplen);
- else
- memcpy(cc->evp.iv, iv, evplen);
- break;
- case SSH_CIPHER_3DES:
- ssh1_3des_iv(&cc->evp, 1, iv, 24);
+ {
+ div = cc->evp.iv;
+ }
break;
+ case SSH_CIPHER_3DES: {
+ struct ssh1_3des_ctx *desc;
+ desc = EVP_CIPHER_CTX_get_app_data(&cc->evp);
+ if (desc == NULL)
+ fatal("%s: no 3des context", __func__);
+ debug3("%s: Installed 3DES IV", __func__);
+ memcpy(desc->k1.iv, iv, 8);
+ memcpy(desc->k2.iv, iv + 8, 8);
+ memcpy(desc->k3.iv, iv + 16, 8);
+ return;
+ }
default:
fatal("%s: bad cipher %d", __func__, c->number);
}
+ memcpy(div, iv, evplen);
}
#if OPENSSL_VERSION_NUMBER < 0x00907000L
diff --git a/crypto/openssh/cli.c b/crypto/openssh/cli.c
deleted file mode 100644
index 8f0b2b8..0000000
--- 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 6f57c9b..0000000
--- 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/compat.c b/crypto/openssh/compat.c
index af1d143..b256ba5 100644
--- a/crypto/openssh/compat.c
+++ b/crypto/openssh/compat.c
@@ -23,7 +23,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: compat.c,v 1.69 2003/08/29 10:03:15 markus Exp $");
+RCSID("$OpenBSD: compat.c,v 1.66 2003/04/01 10:31:26 markus Exp $");
+RCSID("$FreeBSD$");
#include "buffer.h"
#include "packet.h"
@@ -79,11 +80,7 @@ compat_datafellows(const char *version)
{ "OpenSSH_2.5.3*", SSH_BUG_NOREKEY|SSH_BUG_EXTEOF},
{ "OpenSSH_2.*,"
"OpenSSH_3.0*,"
- "OpenSSH_3.1*", SSH_BUG_EXTEOF|SSH_BUG_GSSAPI_BER},
- { "OpenSSH_3.2*,"
- "OpenSSH_3.3*,"
- "OpenSSH_3.4*,"
- "OpenSSH_3.5*", SSH_BUG_GSSAPI_BER},
+ "OpenSSH_3.1*", SSH_BUG_EXTEOF},
{ "Sun_SSH_1.0*", SSH_BUG_NOREKEY|SSH_BUG_EXTEOF},
{ "OpenSSH*", 0 },
{ "*MindTerm*", 0 },
@@ -135,9 +132,12 @@ compat_datafellows(const char *version)
"1.2.19*,"
"1.2.20*,"
"1.2.21*,"
- "1.2.22*", SSH_BUG_IGNOREMSG },
+ "1.2.22*", SSH_BUG_IGNOREMSG|SSH_BUG_K5USER },
{ "1.3.2*", /* F-Secure */
- SSH_BUG_IGNOREMSG },
+ SSH_BUG_IGNOREMSG|SSH_BUG_K5USER },
+ { "1.2.1*,"
+ "1.2.2*,"
+ "1.2.3*", SSH_BUG_K5USER },
{ "*SSH Compatible Server*", /* Netscreen */
SSH_BUG_PASSWORDPAD },
{ "*OSU_0*,"
@@ -189,7 +189,7 @@ proto_spec(const char *spec)
ret |= SSH_PROTO_2;
break;
default:
- logit("ignoring bad proto spec: '%s'.", p);
+ log("ignoring bad proto spec: '%s'.", p);
break;
}
}
diff --git a/crypto/openssh/compat.h b/crypto/openssh/compat.h
index 7a50044..881e450 100644
--- a/crypto/openssh/compat.h
+++ b/crypto/openssh/compat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: compat.h,v 1.36 2003/08/29 10:03:15 markus Exp $ */
+/* $OpenBSD: compat.h,v 1.34 2003/04/01 10:31:26 markus Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Markus Friedl. All rights reserved.
@@ -53,9 +53,9 @@
#define SSH_BUG_DERIVEKEY 0x00040000
#define SSH_BUG_DUMMYCHAN 0x00100000
#define SSH_BUG_EXTEOF 0x00200000
-#define SSH_BUG_PROBE 0x00400000
-#define SSH_BUG_FIRSTKEX 0x00800000
-#define SSH_BUG_GSSAPI_BER 0x01000000
+#define SSH_BUG_K5USER 0x00400000
+#define SSH_BUG_PROBE 0x00800000
+#define SSH_BUG_FIRSTKEX 0x01000000
void enable_compat13(void);
void enable_compat20(void);
diff --git a/crypto/openssh/config.h b/crypto/openssh/config.h
new file mode 100644
index 0000000..a5176e8
--- /dev/null
+++ b/crypto/openssh/config.h
@@ -0,0 +1,948 @@
+/* config.h. Generated by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+/* $Id: acconfig.h,v 1.149 2003/03/10 00:38:10 djm Exp $ */
+/* $FreeBSD$ */
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+/* Generated automatically from acconfig.h by autoheader. */
+/* Please make your changes there */
+
+
+/* Define to a Set Process Title type if your system is */
+/* supported by bsd-setproctitle.c */
+/* #undef SPT_TYPE */
+
+/* setgroups() NOOP allowed */
+/* #undef SETGROUPS_NOOP */
+
+/* SCO workaround */
+/* #undef BROKEN_SYS_TERMIO_H */
+
+/* Define if you have SecureWare-based protected password database */
+/* #undef HAVE_SECUREWARE */
+
+/* If your header files don't define LOGIN_PROGRAM, then use this (detected) */
+/* from environment and PATH */
+#define LOGIN_PROGRAM_FALLBACK "/usr/bin/login"
+
+/* Define if your password has a pw_class field */
+#define HAVE_PW_CLASS_IN_PASSWD 1
+
+/* Define if your password has a pw_expire field */
+#define HAVE_PW_EXPIRE_IN_PASSWD 1
+
+/* Define if your password has a pw_change field */
+#define HAVE_PW_CHANGE_IN_PASSWD 1
+
+/* Define if your system uses access rights style file descriptor passing */
+/* #undef HAVE_ACCRIGHTS_IN_MSGHDR */
+
+/* Define if your system uses ancillary data style file descriptor passing */
+#define HAVE_CONTROL_IN_MSGHDR 1
+
+/* Define if you system's inet_ntoa is busted (e.g. Irix gcc issue) */
+/* #undef BROKEN_INET_NTOA */
+
+/* Define if your system defines sys_errlist[] */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define if your system defines sys_nerr */
+#define HAVE_SYS_NERR 1
+
+/* Define if your system choked on IP TOS setting */
+/* #undef IP_TOS_IS_BROKEN */
+
+/* Define if you have the getuserattr function. */
+/* #undef HAVE_GETUSERATTR */
+
+/* Work around problematic Linux PAM modules handling of PAM_TTY */
+/* #undef PAM_TTY_KLUDGE */
+
+/* Use PIPES instead of a socketpair() */
+/* #undef USE_PIPES */
+
+/* Define if your snprintf is busted */
+/* #undef BROKEN_SNPRINTF */
+
+/* Define if you are on Cygwin */
+/* #undef HAVE_CYGWIN */
+
+/* Define if you have a broken realpath. */
+/* #undef BROKEN_REALPATH */
+
+/* Define if you are on NeXT */
+/* #undef HAVE_NEXT */
+
+/* Define if you are on NEWS-OS */
+/* #undef HAVE_NEWS4 */
+
+/* Define if you want to enable PAM support */
+#define USE_PAM 1
+
+/* Define if you want to enable AIX4's authenticate function */
+/* #undef WITH_AIXAUTHENTICATE */
+
+/* Define if you have/want arrays (cluster-wide session managment, not C arrays) */
+/* #undef WITH_IRIX_ARRAY */
+
+/* Define if you want IRIX project management */
+/* #undef WITH_IRIX_PROJECT */
+
+/* Define if you want IRIX audit trails */
+/* #undef WITH_IRIX_AUDIT */
+
+/* Define if you want IRIX kernel jobs */
+/* #undef WITH_IRIX_JOBS */
+
+/* Location of PRNGD/EGD random number socket */
+/* #undef PRNGD_SOCKET */
+
+/* Port number of PRNGD/EGD random number socket */
+/* #undef PRNGD_PORT */
+
+/* Builtin PRNG command timeout */
+#define ENTROPY_TIMEOUT_MSEC 200
+
+/* non-privileged user for privilege separation */
+#define SSH_PRIVSEP_USER "sshd"
+
+/* Define if you want to install preformatted manpages.*/
+/* #undef MANTYPE */
+
+/* Define if your ssl headers are included with #include <openssl/header.h> */
+#define HAVE_OPENSSL 1
+
+/* Define if you are linking against RSAref. Used only to print the right
+ * message at run-time. */
+/* #undef RSAREF */
+
+/* struct timeval */
+#define HAVE_STRUCT_TIMEVAL 1
+
+/* struct utmp and struct utmpx fields */
+#define HAVE_HOST_IN_UTMP 1
+/* #undef HAVE_HOST_IN_UTMPX */
+/* #undef HAVE_ADDR_IN_UTMP */
+/* #undef HAVE_ADDR_IN_UTMPX */
+/* #undef HAVE_ADDR_V6_IN_UTMP */
+/* #undef HAVE_ADDR_V6_IN_UTMPX */
+/* #undef HAVE_SYSLEN_IN_UTMPX */
+/* #undef HAVE_PID_IN_UTMP */
+/* #undef HAVE_TYPE_IN_UTMP */
+/* #undef HAVE_TYPE_IN_UTMPX */
+/* #undef HAVE_TV_IN_UTMP */
+/* #undef HAVE_TV_IN_UTMPX */
+/* #undef HAVE_ID_IN_UTMP */
+/* #undef HAVE_ID_IN_UTMPX */
+/* #undef HAVE_EXIT_IN_UTMP */
+#define HAVE_TIME_IN_UTMP 1
+/* #undef HAVE_TIME_IN_UTMPX */
+
+/* Define if you don't want to use your system's login() call */
+/* #undef DISABLE_LOGIN */
+
+/* Define if you don't want to use pututline() etc. to write [uw]tmp */
+/* #undef DISABLE_PUTUTLINE */
+
+/* Define if you don't want to use pututxline() etc. to write [uw]tmpx */
+/* #undef DISABLE_PUTUTXLINE */
+
+/* Define if you don't want to use lastlog */
+/* #undef DISABLE_LASTLOG */
+
+/* Define if you don't want to use lastlog in session.c */
+/* #undef NO_SSH_LASTLOG */
+
+/* Define if you don't want to use utmp */
+/* #undef DISABLE_UTMP */
+
+/* Define if you don't want to use utmpx */
+#define DISABLE_UTMPX 1
+
+/* Define if you don't want to use wtmp */
+/* #undef DISABLE_WTMP */
+
+/* Define if you don't want to use wtmpx */
+#define DISABLE_WTMPX 1
+
+/* Some systems need a utmpx entry for /bin/login to work */
+/* #undef LOGIN_NEEDS_UTMPX */
+
+/* Some versions of /bin/login need the TERM supplied on the commandline */
+/* #undef LOGIN_NEEDS_TERM */
+
+/* Define if your login program cannot handle end of options ("--") */
+/* #undef LOGIN_NO_ENDOPT */
+
+/* Define if you want to specify the path to your lastlog file */
+/* #undef CONF_LASTLOG_FILE */
+
+/* Define if you want to specify the path to your utmp file */
+#define CONF_UTMP_FILE "/var/run/utmp"
+
+/* Define if you want to specify the path to your wtmp file */
+#define CONF_WTMP_FILE "/var/log/wtmp"
+
+/* Define if you want to specify the path to your utmpx file */
+/* #undef CONF_UTMPX_FILE */
+
+/* Define if you want to specify the path to your wtmpx file */
+/* #undef CONF_WTMPX_FILE */
+
+/* Define if you want external askpass support */
+/* #undef USE_EXTERNAL_ASKPASS */
+
+/* Define if libc defines __progname */
+#define HAVE___PROGNAME 1
+
+/* Define if compiler implements __FUNCTION__ */
+#define HAVE___FUNCTION__ 1
+
+/* Define if compiler implements __func__ */
+#define HAVE___func__ 1
+
+/* Define if you want Kerberos 5 support */
+/* #undef KRB5 */
+
+/* Define this if you are using the Heimdal version of Kerberos V5 */
+/* #undef HEIMDAL */
+
+/* Define if you want Kerberos 4 support */
+/* #undef KRB4 */
+
+/* Define if you want AFS support */
+/* #undef AFS */
+
+/* Define if you want S/Key support */
+/* #undef SKEY */
+
+/* Define if you want OPIE support */
+/* #undef OPIE */
+
+/* Define if you want TCP Wrappers support */
+#define LIBWRAP 1
+
+/* Define if your libraries define login() */
+#define HAVE_LOGIN 1
+
+/* Define if your libraries define daemon() */
+#define HAVE_DAEMON 1
+
+/* Define if your libraries define getpagesize() */
+#define HAVE_GETPAGESIZE 1
+
+/* Define if xauth is found in your path */
+#define XAUTH_PATH "/usr/X11R6/bin/xauth"
+
+/* Define if you want to allow MD5 passwords */
+/* #undef HAVE_MD5_PASSWORDS */
+
+/* Define if you want to disable shadow passwords */
+/* #undef DISABLE_SHADOW */
+
+/* Define if you want to use shadow password expire field */
+/* #undef HAS_SHADOW_EXPIRE */
+
+/* Define if you have Digital Unix Security Integration Architecture */
+/* #undef HAVE_OSF_SIA */
+
+/* Define if you have getpwanam(3) [SunOS 4.x] */
+/* #undef HAVE_GETPWANAM */
+
+/* Define if you have an old version of PAM which takes only one argument */
+/* to pam_strerror */
+/* #undef HAVE_OLD_PAM */
+
+/* Define if you are using Solaris-derived PAM which passes pam_messages */
+/* to the conversation function with an extra level of indirection */
+/* #undef PAM_SUN_CODEBASE */
+
+/* Set this to your mail directory if you don't have maillock.h */
+/* #undef MAIL_DIRECTORY */
+
+/* Data types */
+#define HAVE_U_INT 1
+#define HAVE_INTXX_T 1
+#define HAVE_U_INTXX_T 1
+#define HAVE_UINTXX_T 1
+#define HAVE_INT64_T 1
+#define HAVE_U_INT64_T 1
+#define HAVE_U_CHAR 1
+#define HAVE_SIZE_T 1
+#define HAVE_SSIZE_T 1
+#define HAVE_CLOCK_T 1
+#define HAVE_MODE_T 1
+#define HAVE_PID_T 1
+#define HAVE_SA_FAMILY_T 1
+#define HAVE_STRUCT_SOCKADDR_STORAGE 1
+#define HAVE_STRUCT_ADDRINFO 1
+#define HAVE_STRUCT_IN6_ADDR 1
+#define HAVE_STRUCT_SOCKADDR_IN6 1
+
+/* Fields in struct sockaddr_storage */
+#define HAVE_SS_FAMILY_IN_SS 1
+/* #undef HAVE___SS_FAMILY_IN_SS */
+
+/* Define if you have /dev/ptmx */
+/* #undef HAVE_DEV_PTMX */
+
+/* Define if you have /dev/ptc */
+/* #undef HAVE_DEV_PTS_AND_PTC */
+
+/* Define if you need to use IP address instead of hostname in $DISPLAY */
+/* #undef IPADDR_IN_DISPLAY */
+
+/* Specify default $PATH */
+/* #undef USER_PATH */
+
+/* Specify location of ssh.pid */
+#define _PATH_SSH_PIDDIR "/var/run"
+
+/* Use IPv4 for connection by default, IPv6 can still if explicity asked */
+/* #undef IPV4_DEFAULT */
+
+/* getaddrinfo is broken (if present) */
+/* #undef BROKEN_GETADDRINFO */
+
+/* Workaround more Linux IPv6 quirks */
+/* #undef DONT_TRY_OTHER_AF */
+
+/* Detect IPv4 in IPv6 mapped addresses and treat as IPv4 */
+/* #undef IPV4_IN_IPV6 */
+
+/* Define if you have BSD auth support */
+/* #undef BSD_AUTH */
+
+/* Define if X11 doesn't support AF_UNIX sockets on that system */
+/* #undef NO_X11_UNIX_SOCKETS */
+
+/* Define if the concept of ports only accessible to superusers isn't known */
+/* #undef NO_IPPORT_RESERVED_CONCEPT */
+
+/* Needed for SCO and NeXT */
+/* #undef BROKEN_SAVED_UIDS */
+
+/* Define if your system glob() function has the GLOB_ALTDIRFUNC extension */
+#define GLOB_HAS_ALTDIRFUNC 1
+
+/* Define if your system glob() function has gl_matchc options in glob_t */
+/* #undef GLOB_HAS_GL_MATCHC */
+
+/* Define in your struct dirent expects you to allocate extra space for d_name */
+/* #undef BROKEN_ONE_BYTE_DIRENT_D_NAME */
+
+/* Define if your getopt(3) defines and uses optreset */
+#define HAVE_GETOPT_OPTRESET 1
+
+/* Define on *nto-qnx systems */
+/* #undef MISSING_NFDBITS */
+
+/* Define on *nto-qnx systems */
+/* #undef MISSING_HOWMANY */
+
+/* Define on *nto-qnx systems */
+/* #undef MISSING_FD_MASK */
+
+/* Define if you want smartcard support */
+/* #undef SMARTCARD */
+
+/* Define if you want smartcard support using sectok */
+/* #undef USE_SECTOK */
+
+/* Define if you want smartcard support using OpenSC */
+/* #undef USE_OPENSC */
+
+/* Define if you want to use OpenSSL's internally seeded PRNG only */
+#define OPENSSL_PRNG_ONLY 1
+
+/* Define if you shouldn't strip 'tty' from your ttyname in [uw]tmp */
+/* #undef WITH_ABBREV_NO_TTY */
+
+/* Define if you want a different $PATH for the superuser */
+/* #undef SUPERUSER_PATH */
+
+/* Path that unprivileged child will chroot() to in privep mode */
+/* #undef PRIVSEP_PATH */
+
+/* Define if your platform needs to skip post auth file descriptor passing */
+/* #undef DISABLE_FD_PASSING */
+
+/* Silly mkstemp() */
+/* #undef HAVE_STRICT_MKSTEMP */
+
+/* Setproctitle emulation */
+/* #undef SETPROCTITLE_STRATEGY */
+/* #undef SETPROCTITLE_PS_PADDING */
+
+/* Some systems put this outside of libc */
+#define HAVE_NANOSLEEP 1
+
+/* Pushing STREAMS modules incorrectly acquires a controlling TTY */
+/* #undef STREAMS_PUSH_ACQUIRES_CTTY */
+
+
+/* Define to 1 if the `getpgrp' function requires zero arguments. */
+#define GETPGRP_VOID 1
+
+/* Define to 1 if you have the `arc4random' function. */
+#define HAVE_ARC4RANDOM 1
+
+/* Define to 1 if you have the `b64_ntop' function. */
+/* #undef HAVE_B64_NTOP */
+
+/* Define to 1 if you have the `b64_pton' function. */
+/* #undef HAVE_B64_PTON */
+
+/* Define to 1 if you have the `basename' function. */
+#define HAVE_BASENAME 1
+
+/* Define to 1 if you have the `bcopy' function. */
+#define HAVE_BCOPY 1
+
+/* Define to 1 if you have the `bindresvport_sa' function. */
+#define HAVE_BINDRESVPORT_SA 1
+
+/* Define to 1 if you have the <bstring.h> header file. */
+/* #undef HAVE_BSTRING_H */
+
+/* Define to 1 if you have the `clock' function. */
+#define HAVE_CLOCK 1
+
+/* Define to 1 if you have the <crypt.h> header file. */
+/* #undef HAVE_CRYPT_H */
+
+/* Define to 1 if you have the `dirname' function. */
+#define HAVE_DIRNAME 1
+
+/* Define to 1 if you have the <endian.h> header file. */
+/* #undef HAVE_ENDIAN_H */
+
+/* Define to 1 if you have the `endutent' function. */
+/* #undef HAVE_ENDUTENT */
+
+/* Define to 1 if you have the `endutxent' function. */
+/* #undef HAVE_ENDUTXENT */
+
+/* Define to 1 if you have the `fchmod' function. */
+#define HAVE_FCHMOD 1
+
+/* Define to 1 if you have the `fchown' function. */
+#define HAVE_FCHOWN 1
+
+/* Define to 1 if you have the <floatingpoint.h> header file. */
+#define HAVE_FLOATINGPOINT_H 1
+
+/* Define to 1 if you have the `freeaddrinfo' function. */
+#define HAVE_FREEADDRINFO 1
+
+/* Define to 1 if you have the `futimes' function. */
+#define HAVE_FUTIMES 1
+
+/* Define to 1 if you have the `gai_strerror' function. */
+#define HAVE_GAI_STRERROR 1
+
+/* Define to 1 if you have the `getaddrinfo' function. */
+#define HAVE_GETADDRINFO 1
+
+/* Define to 1 if you have the `getcwd' function. */
+#define HAVE_GETCWD 1
+
+/* Define to 1 if you have the `getgrouplist' function. */
+#define HAVE_GETGROUPLIST 1
+
+/* Define to 1 if you have the `getluid' function. */
+/* #undef HAVE_GETLUID */
+
+/* Define to 1 if you have the `getnameinfo' function. */
+#define HAVE_GETNAMEINFO 1
+
+/* Define to 1 if you have the `getopt' function. */
+#define HAVE_GETOPT 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getpeereid' function. */
+#define HAVE_GETPEEREID 1
+
+/* Define to 1 if you have the `getpwanam' function. */
+/* #undef HAVE_GETPWANAM */
+
+/* Define to 1 if you have the `getrlimit' function. */
+#define HAVE_GETRLIMIT 1
+
+/* Define to 1 if you have the `getrusage' function. */
+#define HAVE_GETRUSAGE 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the `getttyent' function. */
+#define HAVE_GETTTYENT 1
+
+/* Define to 1 if you have the `getutent' function. */
+/* #undef HAVE_GETUTENT */
+
+/* Define to 1 if you have the `getutid' function. */
+/* #undef HAVE_GETUTID */
+
+/* Define to 1 if you have the `getutline' function. */
+/* #undef HAVE_GETUTLINE */
+
+/* Define to 1 if you have the `getutxent' function. */
+/* #undef HAVE_GETUTXENT */
+
+/* Define to 1 if you have the `getutxid' function. */
+/* #undef HAVE_GETUTXID */
+
+/* Define to 1 if you have the `getutxline' function. */
+/* #undef HAVE_GETUTXLINE */
+
+/* Define to 1 if you have the `glob' function. */
+#define HAVE_GLOB 1
+
+/* Define to 1 if you have the <glob.h> header file. */
+#define HAVE_GLOB_H 1
+
+/* Define to 1 if you have the <ia.h> header file. */
+/* #undef HAVE_IA_H */
+
+/* Define to 1 if you have the `inet_aton' function. */
+#define HAVE_INET_ATON 1
+
+/* Define to 1 if you have the `inet_ntoa' function. */
+#define HAVE_INET_NTOA 1
+
+/* Define to 1 if you have the `inet_ntop' function. */
+#define HAVE_INET_NTOP 1
+
+/* Define to 1 if you have the `innetgr' function. */
+#define HAVE_INNETGR 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <krb.h> header file. */
+/* #undef HAVE_KRB_H */
+
+/* Define to 1 if you have the <lastlog.h> header file. */
+/* #undef HAVE_LASTLOG_H */
+
+/* Define to 1 if you have the `crypt' library (-lcrypt). */
+/* #undef HAVE_LIBCRYPT */
+
+/* Define to 1 if you have the `des' library (-ldes). */
+/* #undef HAVE_LIBDES */
+
+/* Define to 1 if you have the `des425' library (-ldes425). */
+/* #undef HAVE_LIBDES425 */
+
+/* Define to 1 if you have the `dl' library (-ldl). */
+/* #undef HAVE_LIBDL */
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#define HAVE_LIBGEN_H 1
+
+/* Define to 1 if you have the `krb' library (-lkrb). */
+/* #undef HAVE_LIBKRB */
+
+/* Define to 1 if you have the `krb4' library (-lkrb4). */
+/* #undef HAVE_LIBKRB4 */
+
+/* Define to 1 if you have the `nsl' library (-lnsl). */
+/* #undef HAVE_LIBNSL */
+
+/* Define to 1 if you have the `pam' library (-lpam). */
+#define HAVE_LIBPAM 1
+
+/* Define to 1 if you have the `resolv' library (-lresolv). */
+/* #undef HAVE_LIBRESOLV */
+
+/* Define to 1 if you have the `sectok' library (-lsectok). */
+/* #undef HAVE_LIBSECTOK */
+
+/* Define to 1 if you have the `socket' library (-lsocket). */
+/* #undef HAVE_LIBSOCKET */
+
+/* Define to 1 if you have the <libutil.h> header file. */
+#define HAVE_LIBUTIL_H 1
+
+/* Define to 1 if you have the `xnet' library (-lxnet). */
+/* #undef HAVE_LIBXNET */
+
+/* Define to 1 if you have the `z' library (-lz). */
+#define HAVE_LIBZ 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <login_cap.h> header file. */
+#define HAVE_LOGIN_CAP_H 1
+
+/* Define to 1 if you have the `login_getcapbool' function. */
+#define HAVE_LOGIN_GETCAPBOOL 1
+
+/* Define to 1 if you have the <login.h> header file. */
+/* #undef HAVE_LOGIN_H */
+
+/* Define to 1 if you have the `logout' function. */
+#define HAVE_LOGOUT 1
+
+/* Define to 1 if you have the `logwtmp' function. */
+#define HAVE_LOGWTMP 1
+
+/* Define to 1 if you have the <maillock.h> header file. */
+/* #undef HAVE_MAILLOCK_H */
+
+/* Define to 1 if you have the `md5_crypt' function. */
+/* #undef HAVE_MD5_CRYPT */
+
+/* Define to 1 if you have the `memmove' function. */
+#define HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mkdtemp' function. */
+#define HAVE_MKDTEMP 1
+
+/* Define to 1 if you have the `mmap' function. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the <netgroup.h> header file. */
+/* #undef HAVE_NETGROUP_H */
+
+/* Define to 1 if you have the <netinet/in_systm.h> header file. */
+#define HAVE_NETINET_IN_SYSTM_H 1
+
+/* Define to 1 if you have the `ngetaddrinfo' function. */
+/* #undef HAVE_NGETADDRINFO */
+
+/* Define to 1 if you have the `nsleep' function. */
+/* #undef HAVE_NSLEEP */
+
+/* Define to 1 if you have the `ogetaddrinfo' function. */
+/* #undef HAVE_OGETADDRINFO */
+
+/* Define to 1 if you have the `openpty' function. */
+#define HAVE_OPENPTY 1
+
+/* Define to 1 if you have the `pam_getenvlist' function. */
+#define HAVE_PAM_GETENVLIST 1
+
+/* Define to 1 if you have the <paths.h> header file. */
+#define HAVE_PATHS_H 1
+
+/* Define to 1 if you have the `pstat' function. */
+/* #undef HAVE_PSTAT */
+
+/* Define to 1 if you have the <pty.h> header file. */
+/* #undef HAVE_PTY_H */
+
+/* Define to 1 if you have the `pututline' function. */
+/* #undef HAVE_PUTUTLINE */
+
+/* Define to 1 if you have the `pututxline' function. */
+/* #undef HAVE_PUTUTXLINE */
+
+/* Define to 1 if you have the `readpassphrase' function. */
+#define HAVE_READPASSPHRASE 1
+
+/* Define to 1 if you have the <readpassphrase.h> header file. */
+#define HAVE_READPASSPHRASE_H 1
+
+/* Define to 1 if you have the `realpath' function. */
+#define HAVE_REALPATH 1
+
+/* Define to 1 if you have the `recvmsg' function. */
+#define HAVE_RECVMSG 1
+
+/* Define to 1 if you have the <rpc/types.h> header file. */
+#define HAVE_RPC_TYPES_H 1
+
+/* Define to 1 if you have the `rresvport_af' function. */
+#define HAVE_RRESVPORT_AF 1
+
+/* Define to 1 if you have the <sectok.h> header file. */
+/* #undef HAVE_SECTOK_H */
+
+/* Define to 1 if you have the <security/pam_appl.h> header file. */
+#define HAVE_SECURITY_PAM_APPL_H 1
+
+/* Define to 1 if you have the `sendmsg' function. */
+#define HAVE_SENDMSG 1
+
+/* Define to 1 if you have the `setdtablesize' function. */
+/* #undef HAVE_SETDTABLESIZE */
+
+/* Define to 1 if you have the `setegid' function. */
+#define HAVE_SETEGID 1
+
+/* Define to 1 if you have the `setenv' function. */
+#define HAVE_SETENV 1
+
+/* Define to 1 if you have the `seteuid' function. */
+#define HAVE_SETEUID 1
+
+/* Define to 1 if you have the `setgroups' function. */
+#define HAVE_SETGROUPS 1
+
+/* Define to 1 if you have the `setlogin' function. */
+#define HAVE_SETLOGIN 1
+
+/* Define to 1 if you have the `setluid' function. */
+/* #undef HAVE_SETLUID */
+
+/* Define to 1 if you have the `setpcred' function. */
+/* #undef HAVE_SETPCRED */
+
+/* Define to 1 if you have the `setproctitle' function. */
+#define HAVE_SETPROCTITLE 1
+
+/* Define to 1 if you have the `setresgid' function. */
+#define HAVE_SETRESGID 1
+
+/* Define to 1 if you have the `setreuid' function. */
+#define HAVE_SETREUID 1
+
+/* Define to 1 if you have the `setrlimit' function. */
+#define HAVE_SETRLIMIT 1
+
+/* Define to 1 if you have the `setsid' function. */
+#define HAVE_SETSID 1
+
+/* Define to 1 if you have the `setutent' function. */
+/* #undef HAVE_SETUTENT */
+
+/* Define to 1 if you have the `setutxent' function. */
+/* #undef HAVE_SETUTXENT */
+
+/* Define to 1 if you have the `setvbuf' function. */
+#define HAVE_SETVBUF 1
+
+/* Define to 1 if you have the <shadow.h> header file. */
+/* #undef HAVE_SHADOW_H */
+
+/* Define to 1 if you have the `sigaction' function. */
+#define HAVE_SIGACTION 1
+
+/* Define to 1 if you have the `sigvec' function. */
+#define HAVE_SIGVEC 1
+
+/* Define to 1 if the system has the type `sig_atomic_t'. */
+#define HAVE_SIG_ATOMIC_T 1
+
+/* Define to 1 if you have the `snprintf' function. */
+#define HAVE_SNPRINTF 1
+
+/* Define to 1 if you have the `socketpair' function. */
+#define HAVE_SOCKETPAIR 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the `strftime' function. */
+#define HAVE_STRFTIME 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcat' function. */
+#define HAVE_STRLCAT 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#define HAVE_STRLCPY 1
+
+/* Define to 1 if you have the `strmode' function. */
+#define HAVE_STRMODE 1
+
+/* Define to 1 if you have the `strnvis' function. */
+/* #undef HAVE_STRNVIS */
+
+/* Define to 1 if you have the `strsep' function. */
+#define HAVE_STRSEP 1
+
+/* Define to 1 if `st_blksize' is member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+
+/* Define to 1 if the system has the type `struct timespec'. */
+#define HAVE_STRUCT_TIMESPEC 1
+
+/* Define to 1 if you have the `sysconf' function. */
+#define HAVE_SYSCONF 1
+
+/* Define to 1 if you have the <sys/bitypes.h> header file. */
+/* #undef HAVE_SYS_BITYPES_H */
+
+/* Define to 1 if you have the <sys/bsdtty.h> header file. */
+/* #undef HAVE_SYS_BSDTTY_H */
+
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#define HAVE_SYS_CDEFS_H 1
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/pstat.h> header file. */
+/* #undef HAVE_SYS_PSTAT_H */
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/stropts.h> header file. */
+/* #undef HAVE_SYS_STROPTS_H */
+
+/* Define to 1 if you have the <sys/sysmacros.h> header file. */
+/* #undef HAVE_SYS_SYSMACROS_H */
+
+/* Define to 1 if you have the <sys/timers.h> header file. */
+#define HAVE_SYS_TIMERS_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#define HAVE_SYS_UN_H 1
+
+/* Define to 1 if you have the `tcgetpgrp' function. */
+#define HAVE_TCGETPGRP 1
+
+/* Define to 1 if you have the `time' function. */
+#define HAVE_TIME 1
+
+/* Define to 1 if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define to 1 if you have the <tmpdir.h> header file. */
+/* #undef HAVE_TMPDIR_H */
+
+/* Define to 1 if you have the `truncate' function. */
+#define HAVE_TRUNCATE 1
+
+/* Define to 1 if you have the <ttyent.h> header file. */
+#define HAVE_TTYENT_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `updwtmp' function. */
+/* #undef HAVE_UPDWTMP */
+
+/* Define to 1 if you have the <usersec.h> header file. */
+/* #undef HAVE_USERSEC_H */
+
+/* Define to 1 if you have the <util.h> header file. */
+/* #undef HAVE_UTIL_H */
+
+/* Define to 1 if you have the `utimes' function. */
+#define HAVE_UTIMES 1
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `utmpname' function. */
+/* #undef HAVE_UTMPNAME */
+
+/* Define to 1 if you have the `utmpxname' function. */
+/* #undef HAVE_UTMPXNAME */
+
+/* Define to 1 if you have the <utmpx.h> header file. */
+/* #undef HAVE_UTMPX_H */
+
+/* Define to 1 if you have the <utmp.h> header file. */
+#define HAVE_UTMP_H 1
+
+/* Define to 1 if you have the `vhangup' function. */
+/* #undef HAVE_VHANGUP */
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#define HAVE_VSNPRINTF 1
+
+/* Define to 1 if you have the `waitpid' function. */
+#define HAVE_WAITPID 1
+
+/* Define to 1 if you have the `_getpty' function. */
+/* #undef HAVE__GETPTY */
+
+/* Define to 1 if you have the `__b64_ntop' function. */
+#define HAVE___B64_NTOP 1
+
+/* Define to 1 if you have the `__b64_pton' function. */
+#define HAVE___B64_PTON 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+
+/* The size of a `char', as computed by sizeof. */
+#define SIZEOF_CHAR 1
+
+/* The size of a `int', as computed by sizeof. */
+#define SIZEOF_INT 4
+
+/* The size of a `long int', as computed by sizeof. */
+#define SIZEOF_LONG_INT 4
+
+/* The size of a `long long int', as computed by sizeof. */
+#define SIZEOF_LONG_LONG_INT 8
+
+/* The size of a `short int', as computed by sizeof. */
+#define SIZEOF_SHORT_INT 2
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef WORDS_BIGENDIAN */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+ if it is not supported. */
+/* #undef inline */
+
+/* type to use in place of socklen_t if not defined */
+/* #undef socklen_t */
+
+/* ******************* Shouldn't need to edit below this line ************** */
+
+#endif /* _CONFIG_H */
diff --git a/crypto/openssh/configure.ac b/crypto/openssh/configure.ac
index 916dc10..240d67d 100644
--- a/crypto/openssh/configure.ac
+++ b/crypto/openssh/configure.ac
@@ -1,4 +1,5 @@
-# $Id: configure.ac,v 1.154.2.11 2003/09/23 09:24:21 djm Exp $
+# $Id: configure.ac,v 1.113 2003/03/21 01:18:09 mouring Exp $
+# $FreeBSD$
AC_INIT
AC_CONFIG_SRCDIR([ssh.c])
@@ -9,7 +10,6 @@ AC_CANONICAL_HOST
AC_C_BIGENDIAN
# Checks for programs.
-AC_PROG_AWK
AC_PROG_CPP
AC_PROG_RANLIB
AC_PROG_INSTALL
@@ -55,56 +55,36 @@ fi
# Check for some target-specific stuff
case "$host" in
*-*-aix*)
+ AFS_LIBS="-lld"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
- AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
- if (test -z "$blibpath"); then
- blibpath="/usr/lib:/lib:/usr/local/lib"
- fi
- saved_LDFLAGS="$LDFLAGS"
- for tryflags in -blibpath: -Wl,-blibpath: -Wl,-rpath, ;do
- if (test -z "$blibflags"); then
- LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
- AC_TRY_LINK([], [], [blibflags=$tryflags])
- fi
- done
- if (test -z "$blibflags"); then
- AC_MSG_RESULT(not found)
- AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
- else
- AC_MSG_RESULT($blibflags)
+ if (test "$LD" != "gcc" && test -z "$blibpath"); then
+ AC_MSG_CHECKING([if linkage editor ($LD) accepts -blibpath])
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -blibpath:/usr/lib:/lib:/usr/local/lib"
+ AC_TRY_LINK([],
+ [],
+ [
+ AC_MSG_RESULT(yes)
+ blibpath="/usr/lib:/lib:/usr/local/lib"
+ ],
+ [ AC_MSG_RESULT(no) ]
+ )
+ LDFLAGS="$saved_LDFLAGS"
fi
- LDFLAGS="$saved_LDFLAGS"
- dnl Check for authenticate. Might be in libs.a on older AIXes
AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE)],
[AC_CHECK_LIB(s,authenticate,
[ AC_DEFINE(WITH_AIXAUTHENTICATE)
LIBS="$LIBS -ls"
])
])
- dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
- AC_CHECK_DECL(loginfailed,
- [AC_MSG_CHECKING(if loginfailed takes 4 arguments)
- AC_TRY_COMPILE(
- [#include <usersec.h>],
- [(void)loginfailed("user","host","tty",0);],
- [AC_MSG_RESULT(yes)
- AC_DEFINE(AIX_LOGINFAILED_4ARG)],
- [AC_MSG_RESULT(no)]
- )],
- [],
- [#include <usersec.h>]
- )
- AC_CHECK_FUNCS(setauthdb)
AC_DEFINE(BROKEN_GETADDRINFO)
AC_DEFINE(BROKEN_REALPATH)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
dnl AIX handles lastlog as part of its login message
AC_DEFINE(DISABLE_LASTLOG)
AC_DEFINE(LOGIN_NEEDS_UTMPX)
- AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
+ AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
+ AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
;;
*-*-cygwin*)
check_for_libcrypt_later=1
@@ -112,6 +92,7 @@ case "$host" in
AC_DEFINE(HAVE_CYGWIN)
AC_DEFINE(USE_PIPES)
AC_DEFINE(DISABLE_SHADOW)
+ AC_DEFINE(IPV4_DEFAULT)
AC_DEFINE(IP_TOS_IS_BROKEN)
AC_DEFINE(NO_X11_UNIX_SOCKETS)
AC_DEFINE(NO_IPPORT_RESERVED_CONCEPT)
@@ -132,9 +113,6 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
[AC_MSG_RESULT(buggy)
AC_DEFINE(BROKEN_GETADDRINFO)],
[AC_MSG_RESULT(assume it is working)])
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
;;
*-*-hpux10.26)
if test -z "$GCC"; then
@@ -148,8 +126,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_UTMP)
- AC_DEFINE(LOCKED_PASSWD_STRING, "*")
- AC_DEFINE(SPT_TYPE,SPT_PSTAT)
+ AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
LIBS="$LIBS -lsec -lsecpw"
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
disable_ptmx_check=yes
@@ -165,8 +142,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_UTMP)
- AC_DEFINE(LOCKED_PASSWD_STRING, "*")
- AC_DEFINE(SPT_TYPE,SPT_PSTAT)
+ AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
LIBS="$LIBS -lsec"
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
;;
@@ -179,8 +155,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_UTMP)
- AC_DEFINE(LOCKED_PASSWD_STRING, "*")
- AC_DEFINE(SPT_TYPE,SPT_PSTAT)
+ AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
LIBS="$LIBS -lsec"
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
;;
@@ -190,7 +165,6 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
PATH="$PATH:/usr/etc"
AC_DEFINE(BROKEN_INET_NTOA)
AC_DEFINE(WITH_ABBREV_NO_TTY)
- AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
;;
*-*-irix6*)
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
@@ -201,26 +175,16 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(WITH_IRIX_AUDIT)
AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS)])
AC_DEFINE(BROKEN_INET_NTOA)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
AC_DEFINE(WITH_ABBREV_NO_TTY)
- AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
;;
*-*-linux*)
no_dev_ptmx=1
check_for_libcrypt_later=1
- check_for_openpty_ctty_bug=1
AC_DEFINE(DONT_TRY_OTHER_AF)
AC_DEFINE(PAM_TTY_KLUDGE)
- AC_DEFINE(LOCKED_PASSWD_PREFIX, "!!")
- AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
+ AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
+ AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
inet6_default_4in6=yes
- case `uname -r` in
- 1.*|2.0.*)
- AC_DEFINE(BROKEN_CMSG_TYPE)
- ;;
- esac
;;
mips-sony-bsd|mips-sony-newsos4)
AC_DEFINE(HAVE_NEWS4)
@@ -233,11 +197,6 @@ mips-sony-bsd|mips-sony-newsos4)
*-*-freebsd*)
check_for_libcrypt_later=1
;;
-*-*-bsdi*)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
- ;;
*-next-*)
conf_lastlog_location="/usr/adm/lastlog"
conf_utmp_location=/etc/utmp
@@ -258,10 +217,7 @@ mips-sony-bsd|mips-sony-newsos4)
AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(LOGIN_NEEDS_TERM)
AC_DEFINE(PAM_TTY_KLUDGE)
- AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
- # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
- AC_DEFINE(SSHD_ACQUIRES_CTTY)
- external_path_file=/etc/default/login
+ AC_DEFINE(STREAMS_PUSH_ACQUIRES_CTTY)
# hardwire lastlog location (can't detect it on some versions)
conf_lastlog_location="/var/adm/lastlog"
AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
@@ -288,10 +244,6 @@ mips-sony-bsd|mips-sony-newsos4)
LDFLAGS="$LDFLAGS -L/usr/local/lib"
LIBS="$LIBS -lc89"
AC_DEFINE(USE_PIPES)
- AC_DEFINE(SSHD_ACQUIRES_CTTY)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
;;
*-sni-sysv*)
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
@@ -300,8 +252,6 @@ mips-sony-bsd|mips-sony-newsos4)
IPADDR_IN_DISPLAY=yes
AC_DEFINE(USE_PIPES)
AC_DEFINE(IP_TOS_IS_BROKEN)
- AC_DEFINE(SSHD_ACQUIRES_CTTY)
- external_path_file=/etc/default/login
# /usr/ucblib/libucb.a no longer needed on ReliantUNIX
# Attention: always take care to bind libsocket and libnsl before libc,
# otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
@@ -310,17 +260,11 @@ mips-sony-bsd|mips-sony-newsos4)
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_DEFINE(USE_PIPES)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
;;
*-*-sysv5*)
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_DEFINE(USE_PIPES)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
;;
*-*-sysv*)
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
@@ -337,7 +281,6 @@ mips-sony-bsd|mips-sony-newsos4)
AC_DEFINE(HAVE_SECUREWARE)
AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(BROKEN_SAVED_UIDS)
- AC_DEFINE(WITH_ABBREV_NO_TTY)
AC_CHECK_FUNCS(getluid setluid)
MANTYPE=man
do_sco3_extra_lib_check=yes
@@ -354,10 +297,6 @@ mips-sony-bsd|mips-sony-newsos4)
AC_DEFINE(HAVE_SECUREWARE)
AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_FD_PASSING)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
- AC_DEFINE(WITH_ABBREV_NO_TTY)
AC_CHECK_FUNCS(getluid setluid)
MANTYPE=man
;;
@@ -368,14 +307,6 @@ mips-sony-bsd|mips-sony-newsos4)
LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
MANTYPE=cat
;;
-*-*-unicosmp*)
- AC_DEFINE(WITH_ABBREV_NO_TTY)
- AC_DEFINE(USE_PIPES)
- AC_DEFINE(DISABLE_FD_PASSING)
- LDFLAGS="$LDFLAGS"
- LIBS="$LIBS -lgen -lacid"
- MANTYPE=cat
- ;;
*-*-unicos*)
AC_DEFINE(USE_PIPES)
AC_DEFINE(DISABLE_FD_PASSING)
@@ -408,11 +339,6 @@ mips-sony-bsd|mips-sony-newsos4)
fi
fi
AC_DEFINE(DISABLE_FD_PASSING)
- AC_DEFINE(BROKEN_GETADDRINFO)
- AC_DEFINE(SETEUID_BREAKS_SETUID)
- AC_DEFINE(BROKEN_SETREUID)
- AC_DEFINE(BROKEN_SETREGID)
- AC_DEFINE(LOCKED_PASSWD_SUBSTR, "Nologin")
;;
*-*-nto-qnx)
@@ -458,29 +384,17 @@ AC_ARG_WITH(libs,
]
)
-AC_MSG_CHECKING(compiler and flags for sanity)
-AC_TRY_RUN([
-#include <stdio.h>
-int main(){exit(0);}
- ],
- [ AC_MSG_RESULT(yes) ],
- [
- AC_MSG_RESULT(no)
- AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
- ]
-)
-
# Checks for header files.
-AC_CHECK_HEADERS(bstring.h crypt.h endian.h features.h floatingpoint.h \
- getopt.h glob.h ia.h lastlog.h limits.h login.h \
+AC_CHECK_HEADERS(bstring.h crypt.h endian.h floatingpoint.h \
+ getopt.h glob.h ia.h lastlog.h libgen.h limits.h login.h \
login_cap.h maillock.h netdb.h netgroup.h \
netinet/in_systm.h paths.h pty.h readpassphrase.h \
rpc/types.h security/pam_appl.h shadow.h stddef.h stdint.h \
- strings.h sys/strtio.h sys/audit.h sys/bitypes.h sys/bsdtty.h \
- sys/cdefs.h sys/mman.h sys/pstat.h sys/select.h sys/stat.h \
+ strings.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h \
+ sys/mman.h sys/pstat.h sys/select.h sys/stat.h \
sys/stropts.h sys/sysmacros.h sys/time.h sys/timers.h \
sys/un.h time.h tmpdir.h ttyent.h usersec.h \
- util.h utime.h utmp.h utmpx.h vis.h)
+ util.h utime.h utmp.h utmpx.h)
# Checks for libraries.
AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match))
@@ -493,46 +407,8 @@ if test "x$with_tcp_wrappers" != "xno" ; then
fi
fi
-dnl IRIX and Solaris 2.5.1 have dirname() in libgen
-AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
- AC_CHECK_LIB(gen, dirname,[
- AC_CACHE_CHECK([for broken dirname],
- ac_cv_have_broken_dirname, [
- save_LIBS="$LIBS"
- LIBS="$LIBS -lgen"
- AC_TRY_RUN(
- [
-#include <libgen.h>
-#include <string.h>
-
-int main(int argc, char **argv) {
- char *s, buf[32];
-
- strncpy(buf,"/etc", 32);
- s = dirname(buf);
- if (!s || strncmp(s, "/", 32) != 0) {
- exit(1);
- } else {
- exit(0);
- }
-}
- ],
- [ ac_cv_have_broken_dirname="no" ],
- [ ac_cv_have_broken_dirname="yes" ]
- )
- LIBS="$save_LIBS"
- ])
- if test "x$ac_cv_have_broken_dirname" = "xno" ; then
- LIBS="$LIBS -lgen"
- AC_DEFINE(HAVE_DIRNAME)
- AC_CHECK_HEADERS(libgen.h)
- fi
- ])
-])
-
AC_CHECK_FUNC(getspnam, ,
AC_CHECK_LIB(gen, getspnam, LIBS="$LIBS -lgen"))
-AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
AC_ARG_WITH(rpath,
[ --without-rpath Disable auto-added -R linker paths],
@@ -673,6 +549,41 @@ int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
]
)
+# Check whether user wants OPIE support
+OPIE_MSG="no"
+AC_ARG_WITH(opie,
+ [ --with-opie[[=PATH]] Enable OPIE support
+ (optionally in PATH)],
+ [
+ if test "x$withval" != "xno" ; then
+
+ if test "x$withval" != "xyes" ; then
+ CPPFLAGS="$CPPFLAGS -I${withval}/include"
+ LDFLAGS="$LDFLAGS -L${withval}/lib"
+ fi
+
+ AC_DEFINE(SKEY)
+ AC_DEFINE(OPIE)
+ LIBS="-lopie $LIBS"
+ OPIE_MSG="yes"
+
+ AC_MSG_CHECKING([for opie support])
+ AC_TRY_RUN(
+ [
+#include <sys/types.h>
+#include <stdio.h>
+#include <opie.h>
+int main() { char *ff = opie_keyinfo(""); ff=""; return 0; }
+ ],
+ [AC_MSG_RESULT(yes)],
+ [
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([** Incomplete or missing opie libraries.])
+ ])
+ fi
+ ]
+)
+
# Check whether user wants TCP wrappers support
TCPW_MSG="no"
AC_ARG_WITH(tcp-wrappers,
@@ -729,47 +640,60 @@ AC_ARG_WITH(tcp-wrappers,
dnl Checks for library functions. Please keep in alphabetical order
AC_CHECK_FUNCS(\
- arc4random __b64_ntop b64_ntop __b64_pton b64_pton basename \
- bcopy bindresvport_sa clock fchmod fchown freeaddrinfo futimes \
- getaddrinfo getcwd getgrouplist getnameinfo getopt \
- getpeereid _getpty getrlimit getttyent glob inet_aton \
+ arc4random __b64_ntop b64_ntop __b64_pton b64_pton basename bcopy \
+ bindresvport_sa clock fchmod fchown freeaddrinfo futimes \
+ gai_strerror getaddrinfo getcwd getgrouplist getnameinfo getopt \
+ getpeereid _getpty getrlimit getrusage getttyent glob inet_aton \
inet_ntoa inet_ntop innetgr login_getcapbool md5_crypt memmove \
- mkdtemp mmap ngetaddrinfo nsleep ogetaddrinfo openlog_r openpty \
- pstat readpassphrase realpath recvmsg rresvport_af sendmsg \
- setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
- setproctitle setregid setresgid setresuid setreuid setrlimit \
- setsid setvbuf sigaction sigvec snprintf socketpair strerror \
- strlcat strlcpy strmode strnvis sysconf tcgetpgrp \
- truncate utimes vhangup vsnprintf waitpid \
+ mkdtemp mmap ngetaddrinfo nsleep ogetaddrinfo openpty pstat \
+ readpassphrase realpath recvmsg rresvport_af sendmsg setdtablesize \
+ setegid setenv seteuid setgroups setlogin setpcred setproctitle \
+ setresgid setreuid setrlimit setsid setvbuf sigaction sigvec \
+ snprintf socketpair strerror strlcat strlcpy strmode strnvis \
+ sysconf tcgetpgrp truncate utimes vhangup vsnprintf waitpid \
)
-# IRIX has a const char return value for gai_strerror()
-AC_CHECK_FUNCS(gai_strerror,[
- AC_DEFINE(HAVE_GAI_STRERROR)
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-const char *gai_strerror(int);],[
-char *str;
-
-str = gai_strerror(0);],[
- AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
- [Define if gai_strerror() returns const char *])])])
-
AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
-dnl Make sure prototypes are defined for these before using them.
+dnl Make sure strsep prototype is defined before defining HAVE_STRSEP
AC_CHECK_DECL(strsep, [AC_CHECK_FUNCS(strsep)])
-AC_CHECK_DECL(getrusage, [AC_CHECK_FUNCS(getrusage)])
-dnl tcsendbreak might be a macro
-AC_CHECK_DECL(tcsendbreak,
- [AC_DEFINE(HAVE_TCSENDBREAK)],
- [AC_CHECK_FUNCS(tcsendbreak)],
- [#include <termios.h>]
-)
+dnl IRIX and Solaris 2.5.1 have dirname() in libgen
+AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
+ AC_CHECK_LIB(gen, dirname,[
+ AC_CACHE_CHECK([for broken dirname],
+ ac_cv_have_broken_dirname, [
+ save_LIBS="$LIBS"
+ LIBS="$LIBS -lgen"
+ AC_TRY_RUN(
+ [
+#include <libgen.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ char *s, buf[32];
+
+ strncpy(buf,"/etc", 32);
+ s = dirname(buf);
+ if (!s || strncmp(s, "/", 32) != 0) {
+ exit(1);
+ } else {
+ exit(0);
+ }
+}
+ ],
+ [ ac_cv_have_broken_dirname="no" ],
+ [ ac_cv_have_broken_dirname="yes" ]
+ )
+ LIBS="$save_LIBS"
+ ])
+ if test "x$ac_cv_have_broken_dirname" = "xno" ; then
+ LIBS="$LIBS -lgen"
+ AC_DEFINE(HAVE_DIRNAME)
+ AC_CHECK_HEADERS(libgen.h)
+ fi
+ ])
+])
dnl Checks for time functions
AC_CHECK_FUNCS(gettimeofday time)
@@ -833,53 +757,6 @@ unlink(template); exit(0);
)
fi
-dnl make sure that openpty does not reacquire controlling terminal
-if test ! -z "$check_for_openpty_ctty_bug"; then
- AC_MSG_CHECKING(if openpty correctly handles controlling tty)
- AC_TRY_RUN(
- [
-#include <stdio.h>
-#include <sys/fcntl.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-int
-main()
-{
- pid_t pid;
- int fd, ptyfd, ttyfd, status;
-
- pid = fork();
- if (pid < 0) { /* failed */
- exit(1);
- } else if (pid > 0) { /* parent */
- waitpid(pid, &status, 0);
- if (WIFEXITED(status))
- exit(WEXITSTATUS(status));
- else
- exit(2);
- } else { /* child */
- close(0); close(1); close(2);
- setsid();
- openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
- fd = open("/dev/tty", O_RDWR | O_NOCTTY);
- if (fd >= 0)
- exit(3); /* Acquired ctty: broken */
- else
- exit(0); /* Did not acquire ctty: OK */
- }
-}
- ],
- [
- AC_MSG_RESULT(yes)
- ],
- [
- AC_MSG_RESULT(no)
- AC_DEFINE(SSHD_ACQUIRES_CTTY)
- ]
- )
-fi
-
AC_FUNC_GETPGRP
# Check for PAM libs
@@ -895,7 +772,6 @@ AC_ARG_WITH(pam,
AC_CHECK_LIB(dl, dlopen, , )
AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
AC_CHECK_FUNCS(pam_getenvlist)
- AC_CHECK_FUNCS(pam_putenv)
disable_shadow=yes
PAM_MSG="yes"
@@ -1060,15 +936,13 @@ int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
],
[
AC_MSG_RESULT(no)
- AC_MSG_ERROR([Your OpenSSL headers do not match your library.
-Check config.log for details.
-Also see contrib/findssl.sh for help identifying header/library mismatches.])
+ AC_MSG_ERROR(Your OpenSSL headers do not match your library)
]
)
# Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
# version in OpenSSL. Skip this for PAM
-if test "x$check_for_libcrypt_later" = "x1"; then
+if test "x$PAM_MSG" = "xno" -a "x$check_for_libcrypt_later" = "x1"; then
AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
fi
@@ -1874,7 +1748,11 @@ AC_CACHE_CHECK([whether getopt has optreset support],
ac_cv_have_getopt_optreset, [
AC_TRY_LINK(
[
+#if HAVE_GETOPT_H
#include <getopt.h>
+#elif HAVE_UNISTD_H
+#include <unistd.h>
+#endif
],
[ extern int optreset; optreset = 0; ],
[ ac_cv_have_getopt_optreset="yes" ],
@@ -1909,6 +1787,7 @@ if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
fi
SCARD_MSG="no"
+
# Check whether user wants sectok support
AC_ARG_WITH(sectok,
[ --with-sectok Enable smartcard support using libsectok],
@@ -1958,29 +1837,6 @@ if test x$opensc_config_prefix != x ; then
fi
fi
-# Check whether user wants DNS support
-DNS_MSG="no"
-AC_ARG_WITH(dns,
- [ --with-dns Support for fetching keys from DNS (experimental)],
- [
- if test "x$withval" != "xno" ; then
- DNS_MSG="yes"
- AC_DEFINE(DNS)
- AC_SEARCH_LIBS(getrrsetbyname, resolv,
- [AC_DEFINE(HAVE_GETRRSETBYNAME)],
- [
- # Needed by our getrrsetbyname()
- AC_SEARCH_LIBS(res_query, resolv)
- AC_SEARCH_LIBS(dn_expand, resolv)
- AC_CHECK_FUNCS(_getshort _getlong)
- AC_CHECK_MEMBER(HEADER.ad,
- [AC_DEFINE(HAVE_HEADER_AD)],,
- [#include <arpa/nameser.h>])
- ])
- fi
- ]
-)
-
# Check whether user wants Kerberos 5 support
KRB5_MSG="no"
AC_ARG_WITH(kerberos5,
@@ -2013,38 +1869,93 @@ AC_ARG_WITH(kerberos5,
if test ! -z "$blibpath" ; then
blibpath="$blibpath:${KRB5ROOT}/lib"
fi
- AC_SEARCH_LIBS(dn_expand, resolv)
-
- AC_CHECK_LIB(gssapi,gss_init_sec_context,
- [ AC_DEFINE(GSSAPI)
- K5LIBS="-lgssapi $K5LIBS" ],
- [ AC_CHECK_LIB(gssapi_krb5,gss_init_sec_context,
- [ AC_DEFINE(GSSAPI)
- K5LIBS="-lgssapi_krb5 $K5LIBS" ],
- AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]),
- $K5LIBS)
- ],
- $K5LIBS)
-
- AC_CHECK_HEADER(gssapi.h, ,
- [ unset ac_cv_header_gssapi_h
- CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
- AC_CHECK_HEADERS(gssapi.h, ,
- AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
- )
- ]
- )
-
- oldCPP="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
- AC_CHECK_HEADER(gssapi_krb5.h, ,
- [ CPPFLAGS="$oldCPP" ])
+ AC_CHECK_LIB(resolv, dn_expand, , )
KRB5=yes
fi
]
)
-LIBS="$LIBS $K5LIBS"
+# Check whether user wants Kerberos 4 support
+KRB4_MSG="no"
+AC_ARG_WITH(kerberos4,
+ [ --with-kerberos4=PATH Enable Kerberos 4 support],
+ [
+ if test "x$withval" != "xno" ; then
+ if test "x$withval" != "xyes" ; then
+ CPPFLAGS="$CPPFLAGS -I${withval}/include"
+ LDFLAGS="$LDFLAGS -L${withval}/lib"
+ if test ! -z "$need_dash_r" ; then
+ LDFLAGS="$LDFLAGS -R${withval}/lib"
+ fi
+ if test ! -z "$blibpath" ; then
+ blibpath="$blibpath:${withval}/lib"
+ fi
+ else
+ if test -d /usr/include/kerberosIV ; then
+ CPPFLAGS="$CPPFLAGS -I/usr/include/kerberosIV"
+ fi
+ fi
+
+ AC_CHECK_HEADERS(krb.h)
+ if test "$ac_cv_header_krb_h" != yes; then
+ AC_MSG_WARN([Cannot find krb.h, build may fail])
+ fi
+ AC_CHECK_LIB(krb, main)
+ if test "$ac_cv_lib_krb_main" != yes; then
+ AC_CHECK_LIB(krb4, main)
+ if test "$ac_cv_lib_krb4_main" != yes; then
+ AC_MSG_WARN([Cannot find libkrb nor libkrb4, build may fail])
+ else
+ KLIBS="-lkrb4"
+ fi
+ else
+ KLIBS="-lkrb"
+ fi
+ AC_CHECK_LIB(des, des_cbc_encrypt)
+ if test "$ac_cv_lib_des_des_cbc_encrypt" != yes; then
+ AC_CHECK_LIB(des425, des_cbc_encrypt)
+ if test "$ac_cv_lib_des425_des_cbc_encrypt" != yes; then
+ AC_MSG_WARN([Cannot find libdes nor libdes425, build may fail])
+ else
+ KLIBS="-ldes425"
+ fi
+ else
+ KLIBS="-ldes"
+ fi
+ AC_CHECK_LIB(resolv, dn_expand, , )
+ KRB4=yes
+ KRB4_MSG="yes"
+ AC_DEFINE(KRB4)
+ fi
+ ]
+)
+
+# Check whether user wants AFS support
+AFS_MSG="no"
+AC_ARG_WITH(afs,
+ [ --with-afs=PATH Enable AFS support],
+ [
+ if test "x$withval" != "xno" ; then
+
+ if test "x$withval" != "xyes" ; then
+ CPPFLAGS="$CPPFLAGS -I${withval}/include"
+ LDFLAGS="$LDFLAGS -L${withval}/lib"
+ fi
+
+ if test -z "$KRB4" ; then
+ AC_MSG_WARN([AFS requires Kerberos IV support, build may fail])
+ fi
+
+ LIBS="-lkafs $LIBS"
+ if test ! -z "$AFS_LIBS" ; then
+ LIBS="$LIBS $AFS_LIBS"
+ fi
+ AC_DEFINE(AFS)
+ AFS_MSG="yes"
+ fi
+ ]
+)
+LIBS="$LIBS $KLIBS $K5LIBS"
# Looking for programs, paths and files
@@ -2214,52 +2125,30 @@ else
)
fi
-# check for /etc/default/login and use it if present.
-AC_ARG_ENABLE(etc-default-login,
- [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],,
-[
-AC_CHECK_FILE("/etc/default/login", [ external_path_file=/etc/default/login ])
-
-if test "x$external_path_file" = "x/etc/default/login"; then
- AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
-fi
-])
-
dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
if test $ac_cv_func_login_getcapbool = "yes" -a \
$ac_cv_header_login_cap_h = "yes" ; then
- external_path_file=/etc/login.conf
+ USES_LOGIN_CONF=yes
fi
-
# Whether to mess with the default path
SERVER_PATH_MSG="(default)"
AC_ARG_WITH(default-path,
[ --with-default-path= Specify default \$PATH environment for server],
[
- if test "x$external_path_file" = "x/etc/login.conf" ; then
+ if test "$USES_LOGIN_CONF" = "yes" ; then
AC_MSG_WARN([
--with-default-path=PATH has no effect on this system.
Edit /etc/login.conf instead.])
elif test "x$withval" != "xno" ; then
- if test ! -z "$external_path_file" ; then
- AC_MSG_WARN([
---with-default-path=PATH will only be used if PATH is not defined in
-$external_path_file .])
- fi
user_path="$withval"
SERVER_PATH_MSG="$withval"
fi
],
- [ if test "x$external_path_file" = "x/etc/login.conf" ; then
- AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
+ [ if test "$USES_LOGIN_CONF" = "yes" ; then
+ AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
else
- if test ! -z "$external_path_file" ; then
- AC_MSG_WARN([
-If PATH is defined in $external_path_file, ensure the path to scp is included,
-otherwise scp will not work.])
- fi
- AC_TRY_RUN(
- [
+ AC_TRY_RUN(
+ [
/* find out what STDPATH is */
#include <stdio.h>
#ifdef HAVE_PATHS_H
@@ -2313,7 +2202,7 @@ main()
fi
fi ]
)
-if test "x$external_path_file" != "x/etc/login.conf" ; then
+if test "$USES_LOGIN_CONF" != "yes" ; then
AC_DEFINE_UNQUOTED(USER_PATH, "$user_path")
AC_SUBST(user_path)
fi
@@ -2330,6 +2219,18 @@ AC_ARG_WITH(superuser-path,
)
+# Whether to force IPv4 by default (needed on broken glibc Linux)
+IPV4_HACK_MSG="no"
+AC_ARG_WITH(ipv4-default,
+ [ --with-ipv4-default Use IPv4 by connections unless '-6' specified],
+ [
+ if test "x$withval" != "xno" ; then
+ AC_DEFINE(IPV4_DEFAULT)
+ IPV4_HACK_MSG="yes"
+ fi
+ ]
+)
+
AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
IPV4_IN6_HACK_MSG="no"
AC_ARG_WITH(4in6,
@@ -2393,67 +2294,35 @@ AC_SUBST(piddir)
dnl allow user to disable some login recording features
AC_ARG_ENABLE(lastlog,
[ --disable-lastlog disable use of lastlog even if detected [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_LASTLOG)
- fi
- ]
+ [ AC_DEFINE(DISABLE_LASTLOG) ]
)
AC_ARG_ENABLE(utmp,
[ --disable-utmp disable use of utmp even if detected [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_UTMP)
- fi
- ]
+ [ AC_DEFINE(DISABLE_UTMP) ]
)
AC_ARG_ENABLE(utmpx,
[ --disable-utmpx disable use of utmpx even if detected [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_UTMPX)
- fi
- ]
+ [ AC_DEFINE(DISABLE_UTMPX) ]
)
AC_ARG_ENABLE(wtmp,
[ --disable-wtmp disable use of wtmp even if detected [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_WTMP)
- fi
- ]
+ [ AC_DEFINE(DISABLE_WTMP) ]
)
AC_ARG_ENABLE(wtmpx,
[ --disable-wtmpx disable use of wtmpx even if detected [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_WTMPX)
- fi
- ]
+ [ AC_DEFINE(DISABLE_WTMPX) ]
)
AC_ARG_ENABLE(libutil,
[ --disable-libutil disable use of libutil (login() etc.) [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_LOGIN)
- fi
- ]
+ [ AC_DEFINE(DISABLE_LOGIN) ]
)
AC_ARG_ENABLE(pututline,
[ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_PUTUTLINE)
- fi
- ]
+ [ AC_DEFINE(DISABLE_PUTUTLINE) ]
)
AC_ARG_ENABLE(pututxline,
[ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
- [
- if test "x$enableval" = "xno" ; then
- AC_DEFINE(DISABLE_PUTUTXLINE)
- fi
- ]
+ [ AC_DEFINE(DISABLE_PUTUTXLINE) ]
)
AC_ARG_WITH(lastlog,
[ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
@@ -2644,8 +2513,8 @@ fi
if test ! -z "$blibpath" ; then
- LDFLAGS="$LDFLAGS $blibflags$blibpath"
- AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
+ LDFLAGS="$LDFLAGS -blibpath:$blibpath"
+ AC_MSG_WARN([Please check and edit -blibpath in LDFLAGS in Makefile])
fi
dnl remove pam and dl because they are in $LIBPAM
@@ -2683,28 +2552,26 @@ echo " Askpass program: $E"
echo " Manual pages: $F"
echo " PID file: $G"
echo " Privilege separation chroot path: $H"
-if test "x$external_path_file" = "x/etc/login.conf" ; then
-echo " At runtime, sshd will use the path defined in $external_path_file"
-echo " Make sure the path to scp is present, otherwise scp will not work"
+if test "$USES_LOGIN_CONF" = "yes" ; then
+echo " At runtime, sshd will use the path defined in /etc/login.conf"
else
echo " sshd default user PATH: $I"
- if test ! -z "$external_path_file"; then
-echo " (If PATH is set in $external_path_file it will be used instead. If"
-echo " used, ensure the path to scp is present, otherwise scp will not work.)"
- fi
fi
if test ! -z "$superuser_path" ; then
echo " sshd superuser user PATH: $J"
fi
echo " Manpage format: $MANTYPE"
-echo " DNS support: $DNS_MSG"
-echo " PAM support: $PAM_MSG"
+echo " PAM support: ${PAM_MSG}"
+echo " KerberosIV support: $KRB4_MSG"
echo " KerberosV support: $KRB5_MSG"
echo " Smartcard support: $SCARD_MSG"
+echo " AFS support: $AFS_MSG"
echo " S/KEY support: $SKEY_MSG"
+echo " OPIE support: $OPIE_MSG"
echo " TCP Wrappers support: $TCPW_MSG"
echo " MD5 password support: $MD5_MSG"
echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
+echo " Use IPv4 by default hack: $IPV4_HACK_MSG"
echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
echo " BSD Auth support: $BSD_AUTH_MSG"
echo " Random number source: $RAND_MSG"
diff --git a/crypto/openssh/dsa.c b/crypto/openssh/dsa.c
deleted file mode 100644
index 4ff4b58..0000000
--- 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 252e788..0000000
--- 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 4b0966d..0000000
--- 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 fbb0d4c..0000000
--- 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 48a1763..0000000
--- 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 281300e..0000000
--- 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/hostfile.c b/crypto/openssh/hostfile.c
index 42a8aa7..dcee034 100644
--- a/crypto/openssh/hostfile.c
+++ b/crypto/openssh/hostfile.c
@@ -36,7 +36,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: hostfile.c,v 1.31 2003/04/08 20:21:28 itojun Exp $");
+RCSID("$OpenBSD: hostfile.c,v 1.30 2002/07/24 16:11:18 markus Exp $");
#include "packet.h"
#include "match.h"
@@ -77,10 +77,10 @@ hostfile_check_key(int bits, Key *key, const char *host, const char *filename, i
if (key == NULL || key->type != KEY_RSA1 || key->rsa == NULL)
return 1;
if (bits != BN_num_bits(key->rsa->n)) {
- logit("Warning: %s, line %d: keysize mismatch for host %s: "
+ log("Warning: %s, line %d: keysize mismatch for host %s: "
"actual %d vs. announced %d.",
filename, linenum, host, BN_num_bits(key->rsa->n), bits);
- logit("Warning: replace %d with %d in %s, line %d.",
+ log("Warning: replace %d with %d in %s, line %d.",
bits, BN_num_bits(key->rsa->n), filename, linenum);
}
return 1;
diff --git a/crypto/openssh/includes.h b/crypto/openssh/includes.h
index 033cd91..9a9bd0c 100644
--- a/crypto/openssh/includes.h
+++ b/crypto/openssh/includes.h
@@ -1,4 +1,5 @@
/* $OpenBSD: includes.h,v 1.17 2002/01/26 16:44:22 stevesk Exp $ */
+/* $FreeBSD$ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -17,7 +18,7 @@
#define INCLUDES_H
#define RCSID(msg) \
-static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
+__RCSID(msg)
#include "config.h"
@@ -50,6 +51,9 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
#ifdef HAVE_NETGROUP_H
# include <netgroup.h>
#endif
+#if defined(HAVE_NETDB_H)
+# include <netdb.h>
+#endif
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif
@@ -65,7 +69,6 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
#ifdef HAVE_NEXT
# include <libc.h>
#endif
-#define __USE_GNU /* before unistd.h, activate extra prototypes for glibc */
#include <unistd.h> /* For STDIN_FILENO, etc */
#include <termios.h> /* Struct winsize */
@@ -131,18 +134,12 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h> /* for MAP_ANONYMOUS */
#endif
-#ifdef HAVE_SYS_STRTIO_H
-#include <sys/strtio.h> /* for TIOCCBRK on HP-UX */
-#endif
#include <netinet/in_systm.h> /* For typedefs */
#include <netinet/in.h> /* For IPv6 macros */
#include <netinet/ip.h> /* For IPTOS macros */
#include <netinet/tcp.h>
#include <arpa/inet.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
#ifdef HAVE_RPC_TYPES_H
# include <rpc/types.h> /* For INADDR_LOOPBACK */
#endif
@@ -171,6 +168,7 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
#include "version.h"
#include "openbsd-compat/openbsd-compat.h"
+#include "openbsd-compat/bsd-cygwin_util.h"
#include "openbsd-compat/bsd-nextstep.h"
#include "entropy.h"
diff --git a/crypto/openssh/key.c b/crypto/openssh/key.c
index 54318cb..060b637 100644
--- a/crypto/openssh/key.c
+++ b/crypto/openssh/key.c
@@ -32,7 +32,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "includes.h"
-RCSID("$OpenBSD: key.c,v 1.54 2003/07/09 13:58:19 avsm Exp $");
+RCSID("$OpenBSD: key.c,v 1.51 2003/02/12 09:33:04 markus Exp $");
#include <openssl/evp.h>
@@ -169,7 +169,7 @@ key_equal(Key *a, Key *b)
return 0;
}
-u_char*
+static u_char *
key_fingerprint_raw(Key *k, enum fp_type dgst_type, u_int *dgst_raw_length)
{
const EVP_MD *md = NULL;
@@ -236,10 +236,8 @@ key_fingerprint_hex(u_char *dgst_raw, u_int dgst_raw_len)
for (i = 0; i < dgst_raw_len; i++) {
char hex[4];
snprintf(hex, sizeof(hex), "%02x:", dgst_raw[i]);
- strlcat(retval, hex, dgst_raw_len * 3 + 1);
+ strlcat(retval, hex, dgst_raw_len * 3);
}
-
- /* Remove the trailing ':' character */
retval[(dgst_raw_len * 3) - 1] = '\0';
return retval;
}
@@ -440,7 +438,7 @@ key_read(Key *ret, char **cpp)
xfree(blob);
return -1;
}
- k = key_from_blob(blob, (u_int)n);
+ k = key_from_blob(blob, n);
xfree(blob);
if (k == NULL) {
error("key_read: key_from_blob %s failed", cp);
@@ -676,7 +674,7 @@ key_names_valid2(const char *names)
}
Key *
-key_from_blob(u_char *blob, u_int blen)
+key_from_blob(u_char *blob, int blen)
{
Buffer b;
char *ktype;
diff --git a/crypto/openssh/lib/Makefile b/crypto/openssh/lib/Makefile
deleted file mode 100644
index ac950a9..0000000
--- a/crypto/openssh/lib/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-# $OpenBSD: Makefile,v 1.36 2002/06/11 15:23:29 hin 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 fatal.c \
- hostfile.c log.c match.c mpaux.c nchan.c packet.c readpass.c \
- rsa.c tildexpand.c ttymodes.c xmalloc.c atomicio.c \
- key.c dispatch.c kex.c mac.c uuencode.c misc.c \
- rijndael.c ssh-dss.c ssh-rsa.c dh.c kexdh.c kexgex.c \
- scard.c monitor_wrap.c monitor_fdpass.c msg.c
-
-DEBUGLIBS= no
-NOPROFILE= yes
-NOPIC= yes
-
-install:
- @echo -n
-
-.include <bsd.own.mk>
-
-.if (${KERBEROS5:L} == "yes")
-CFLAGS+= -DKRB5 -I${DESTDIR}/usr/include/kerberosV
-.endif # KERBEROS5
-
-.if (${KERBEROS:L} == "yes")
-CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
-.if (${AFS:L} == "yes")
-CFLAGS+= -DAFS
-SRCS+= radix.c
-.endif # AFS
-.endif # KERBEROS
-
-.include <bsd.lib.mk>
diff --git a/crypto/openssh/log-client.c b/crypto/openssh/log-client.c
deleted file mode 100644
index 505c8c3..0000000
--- 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 de3d5cf..0000000
--- 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/log.h b/crypto/openssh/log.h
index c366681..628086a 100644
--- a/crypto/openssh/log.h
+++ b/crypto/openssh/log.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: log.h,v 1.9 2003/04/08 20:21:28 itojun Exp $ */
+/* $OpenBSD: log.h,v 1.8 2002/07/19 15:43:33 markus Exp $ */
+/* $FreeBSD$ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -53,9 +54,17 @@ void log_init(char *, LogLevel, SyslogFacility, int);
SyslogFacility log_facility_number(char *);
LogLevel log_level_number(char *);
+#define fatal ssh_fatal
+#define error ssh_error
+#define log ssh_log
+#define verbose ssh_verbose
+#define debug ssh_debug
+#define debug2 ssh_debug2
+#define debug3 ssh_debug3
+
void fatal(const char *, ...) __attribute__((format(printf, 1, 2)));
void error(const char *, ...) __attribute__((format(printf, 1, 2)));
-void logit(const char *, ...) __attribute__((format(printf, 1, 2)));
+void log(const char *, ...) __attribute__((format(printf, 1, 2)));
void verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
void debug(const char *, ...) __attribute__((format(printf, 1, 2)));
void debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
diff --git a/crypto/openssh/login.c b/crypto/openssh/login.c
deleted file mode 100644
index 1d59cd8..0000000
--- 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/loginrec.c b/crypto/openssh/loginrec.c
index bdac3e9..55b408a 100644
--- a/crypto/openssh/loginrec.c
+++ b/crypto/openssh/loginrec.c
@@ -12,6 +12,11 @@
* 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
@@ -158,7 +163,8 @@
#include "log.h"
#include "atomicio.h"
-RCSID("$Id: loginrec.c,v 1.52 2003/07/06 05:20:46 dtucker Exp $");
+RCSID("$Id: loginrec.c,v 1.47 2003/03/10 00:23:07 djm Exp $");
+RCSID("$FreeBSD$");
#ifdef HAVE_UTIL_H
# include <util.h>
@@ -408,7 +414,7 @@ login_write (struct logininfo *li)
{
#ifndef HAVE_CYGWIN
if ((int)geteuid() != 0) {
- logit("Attempt to write login records by non-root user (aborting)");
+ log("Attempt to write login records by non-root user (aborting)");
return 1;
}
#endif
@@ -652,7 +658,8 @@ construct_utmp(struct logininfo *li,
/* Use strncpy because we don't necessarily want null termination */
strncpy(ut->ut_name, li->username, MIN_SIZEOF(ut->ut_name, li->username));
# ifdef HAVE_HOST_IN_UTMP
- strncpy(ut->ut_host, li->hostname, MIN_SIZEOF(ut->ut_host, li->hostname));
+ realhostname_sa(ut->ut_host, sizeof ut->ut_host,
+ &li->hostaddr.sa, li->hostaddr.sa.sa_len);
# endif
# ifdef HAVE_ADDR_IN_UTMP
/* this is just a 32-bit IP address */
@@ -813,7 +820,7 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
endttyent();
if((struct ttyent *)0 == ty) {
- logit("utmp_write_entry: tty not found");
+ log("utmp_write_entry: tty not found");
return(1);
}
#else /* FIXME */
@@ -837,8 +844,8 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
}
(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
- if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut))
- logit("utmp_write_direct: error writing %s: %s",
+ if (atomicio(write, fd, ut, sizeof(*ut)) != sizeof(*ut))
+ log("utmp_write_direct: error writing %s: %s",
UTMP_FILE, strerror(errno));
(void)close(fd);
@@ -857,12 +864,12 @@ utmp_perform_login(struct logininfo *li)
construct_utmp(li, &ut);
# ifdef UTMP_USE_LIBRARY
if (!utmp_write_library(li, &ut)) {
- logit("utmp_perform_login: utmp_write_library() failed");
+ log("utmp_perform_login: utmp_write_library() failed");
return 0;
}
# else
if (!utmp_write_direct(li, &ut)) {
- logit("utmp_perform_login: utmp_write_direct() failed");
+ log("utmp_perform_login: utmp_write_direct() failed");
return 0;
}
# endif
@@ -878,12 +885,12 @@ utmp_perform_logout(struct logininfo *li)
construct_utmp(li, &ut);
# ifdef UTMP_USE_LIBRARY
if (!utmp_write_library(li, &ut)) {
- logit("utmp_perform_logout: utmp_write_library() failed");
+ log("utmp_perform_logout: utmp_write_library() failed");
return 0;
}
# else
if (!utmp_write_direct(li, &ut)) {
- logit("utmp_perform_logout: utmp_write_direct() failed");
+ log("utmp_perform_logout: utmp_write_direct() failed");
return 0;
}
# endif
@@ -902,7 +909,7 @@ utmp_write_entry(struct logininfo *li)
return utmp_perform_logout(li);
default:
- logit("utmp_write_entry: invalid type field");
+ log("utmp_write_entry: invalid type field");
return 0;
}
}
@@ -943,7 +950,7 @@ utmpx_write_library(struct logininfo *li, struct utmpx *utx)
static int
utmpx_write_direct(struct logininfo *li, struct utmpx *utx)
{
- logit("utmpx_write_direct: not implemented!");
+ log("utmpx_write_direct: not implemented!");
return 0;
}
# endif /* UTMPX_USE_LIBRARY */
@@ -956,12 +963,12 @@ utmpx_perform_login(struct logininfo *li)
construct_utmpx(li, &utx);
# ifdef UTMPX_USE_LIBRARY
if (!utmpx_write_library(li, &utx)) {
- logit("utmpx_perform_login: utmp_write_library() failed");
+ log("utmpx_perform_login: utmp_write_library() failed");
return 0;
}
# else
if (!utmpx_write_direct(li, &ut)) {
- logit("utmpx_perform_login: utmp_write_direct() failed");
+ log("utmpx_perform_login: utmp_write_direct() failed");
return 0;
}
# endif
@@ -999,7 +1006,7 @@ utmpx_write_entry(struct logininfo *li)
case LTYPE_LOGOUT:
return utmpx_perform_logout(li);
default:
- logit("utmpx_write_entry: invalid type field");
+ log("utmpx_write_entry: invalid type field");
return 0;
}
}
@@ -1021,14 +1028,14 @@ wtmp_write(struct logininfo *li, struct utmp *ut)
int fd, ret = 1;
if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
- logit("wtmp_write: problem writing %s: %s",
+ log("wtmp_write: problem writing %s: %s",
WTMP_FILE, strerror(errno));
return 0;
}
if (fstat(fd, &buf) == 0)
- if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) {
+ if (atomicio(write, fd, ut, sizeof(*ut)) != sizeof(*ut)) {
ftruncate(fd, buf.st_size);
- logit("wtmp_write: problem writing %s: %s",
+ log("wtmp_write: problem writing %s: %s",
WTMP_FILE, strerror(errno));
ret = 0;
}
@@ -1065,7 +1072,7 @@ wtmp_write_entry(struct logininfo *li)
case LTYPE_LOGOUT:
return wtmp_perform_logout(li);
default:
- logit("wtmp_write_entry: invalid type field");
+ log("wtmp_write_entry: invalid type field");
return 0;
}
}
@@ -1114,12 +1121,12 @@ wtmp_get_entry(struct logininfo *li)
li->tv_sec = li->tv_usec = 0;
if ((fd = open(WTMP_FILE, O_RDONLY)) < 0) {
- logit("wtmp_get_entry: problem opening %s: %s",
+ log("wtmp_get_entry: problem opening %s: %s",
WTMP_FILE, strerror(errno));
return 0;
}
if (fstat(fd, &st) != 0) {
- logit("wtmp_get_entry: couldn't stat %s: %s",
+ log("wtmp_get_entry: couldn't stat %s: %s",
WTMP_FILE, strerror(errno));
close(fd);
return 0;
@@ -1134,7 +1141,7 @@ wtmp_get_entry(struct logininfo *li)
while (!found) {
if (atomicio(read, fd, &ut, sizeof(ut)) != sizeof(ut)) {
- logit("wtmp_get_entry: read of %s failed: %s",
+ log("wtmp_get_entry: read of %s failed: %s",
WTMP_FILE, strerror(errno));
close (fd);
return 0;
@@ -1187,15 +1194,15 @@ wtmpx_write(struct logininfo *li, struct utmpx *utx)
int fd, ret = 1;
if ((fd = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
- logit("wtmpx_write: problem opening %s: %s",
+ log("wtmpx_write: problem opening %s: %s",
WTMPX_FILE, strerror(errno));
return 0;
}
if (fstat(fd, &buf) == 0)
- if (atomicio(vwrite, fd, utx, sizeof(*utx)) != sizeof(*utx)) {
+ if (atomicio(write, fd, utx, sizeof(*utx)) != sizeof(*utx)) {
ftruncate(fd, buf.st_size);
- logit("wtmpx_write: problem writing %s: %s",
+ log("wtmpx_write: problem writing %s: %s",
WTMPX_FILE, strerror(errno));
ret = 0;
}
@@ -1234,7 +1241,7 @@ wtmpx_write_entry(struct logininfo *li)
case LTYPE_LOGOUT:
return wtmpx_perform_logout(li);
default:
- logit("wtmpx_write_entry: invalid type field");
+ log("wtmpx_write_entry: invalid type field");
return 0;
}
}
@@ -1270,12 +1277,12 @@ wtmpx_get_entry(struct logininfo *li)
li->tv_sec = li->tv_usec = 0;
if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) {
- logit("wtmpx_get_entry: problem opening %s: %s",
+ log("wtmpx_get_entry: problem opening %s: %s",
WTMPX_FILE, strerror(errno));
return 0;
}
if (fstat(fd, &st) != 0) {
- logit("wtmpx_get_entry: couldn't stat %s: %s",
+ log("wtmpx_get_entry: couldn't stat %s: %s",
WTMPX_FILE, strerror(errno));
close(fd);
return 0;
@@ -1290,7 +1297,7 @@ wtmpx_get_entry(struct logininfo *li)
while (!found) {
if (atomicio(read, fd, &utx, sizeof(utx)) != sizeof(utx)) {
- logit("wtmpx_get_entry: read of %s failed: %s",
+ log("wtmpx_get_entry: read of %s failed: %s",
WTMPX_FILE, strerror(errno));
close (fd);
return 0;
@@ -1335,7 +1342,7 @@ syslogin_perform_login(struct logininfo *li)
struct utmp *ut;
if (! (ut = (struct utmp *)malloc(sizeof(*ut)))) {
- logit("syslogin_perform_login: couldn't malloc()");
+ log("syslogin_perform_login: couldn't malloc()");
return 0;
}
construct_utmp(li, ut);
@@ -1354,7 +1361,7 @@ syslogin_perform_logout(struct logininfo *li)
(void)line_stripname(line, li->line, sizeof(line));
if (!logout(line)) {
- logit("syslogin_perform_logout: logout() returned an error");
+ log("syslogin_perform_logout: logout() returned an error");
# ifdef HAVE_LOGWTMP
} else {
logwtmp(line, "", "");
@@ -1377,7 +1384,7 @@ syslogin_write_entry(struct logininfo *li)
case LTYPE_LOGOUT:
return syslogin_perform_logout(li);
default:
- logit("syslogin_write_entry: Invalid type field");
+ log("syslogin_write_entry: Invalid type field");
return 0;
}
}
@@ -1412,7 +1419,7 @@ lastlog_filetype(char *filename)
struct stat st;
if (stat(LASTLOG_FILE, &st) != 0) {
- logit("lastlog_perform_login: Couldn't stat %s: %s", LASTLOG_FILE,
+ log("lastlog_perform_login: Couldn't stat %s: %s", LASTLOG_FILE,
strerror(errno));
return 0;
}
@@ -1443,12 +1450,12 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
LASTLOG_FILE, li->username);
break;
default:
- logit("lastlog_openseek: %.100s is not a file or directory!",
+ log("lastlog_openseek: %.100s is not a file or directory!",
LASTLOG_FILE);
return 0;
}
- *fd = open(lastlog_file, filemode, 0600);
+ *fd = open(lastlog_file, filemode);
if ( *fd < 0) {
debug("lastlog_openseek: Couldn't open %s: %s",
lastlog_file, strerror(errno));
@@ -1460,7 +1467,7 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
offset = (off_t) ((long)li->uid * sizeof(struct lastlog));
if ( lseek(*fd, offset, SEEK_SET) != offset ) {
- logit("lastlog_openseek: %s->lseek(): %s",
+ log("lastlog_openseek: %s->lseek(): %s",
lastlog_file, strerror(errno));
return 0;
}
@@ -1482,9 +1489,9 @@ lastlog_perform_login(struct logininfo *li)
return(0);
/* write the entry */
- if (atomicio(vwrite, fd, &last, sizeof(last)) != sizeof(last)) {
+ if (atomicio(write, fd, &last, sizeof(last)) != sizeof(last)) {
close(fd);
- logit("lastlog_write_filemode: Error writing to %s: %s",
+ log("lastlog_write_filemode: Error writing to %s: %s",
LASTLOG_FILE, strerror(errno));
return 0;
}
@@ -1500,7 +1507,7 @@ lastlog_write_entry(struct logininfo *li)
case LTYPE_LOGIN:
return lastlog_perform_login(li);
default:
- logit("lastlog_write_entry: Invalid type field");
+ log("lastlog_write_entry: Invalid type field");
return 0;
}
}
diff --git a/crypto/openssh/monitor.c b/crypto/openssh/monitor.c
index e565647..17a1ce6 100644
--- a/crypto/openssh/monitor.c
+++ b/crypto/openssh/monitor.c
@@ -25,13 +25,22 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor.c,v 1.49 2003/08/28 12:54:34 markus Exp $");
+RCSID("$OpenBSD: monitor.c,v 1.36 2003/04/01 10:22:21 markus Exp $");
+RCSID("$FreeBSD$");
#include <openssl/dh.h>
#ifdef SKEY
+#ifdef OPIE
+#include <opie.h>
+#define skey opie
+#define skeychallenge(k, u, c) opiechallenge((k), (u), (c))
+#define skey_haskey(u) opie_haskey((u))
+#define skey_passcheck(u, r) opie_passverify((u), (r))
+#else
#include <skey.h>
#endif
+#endif
#include "ssh.h"
#include "auth.h"
@@ -59,11 +68,6 @@ RCSID("$OpenBSD: monitor.c,v 1.49 2003/08/28 12:54:34 markus Exp $");
#include "ssh2.h"
#include "mpaux.h"
-#ifdef GSSAPI
-#include "ssh-gss.h"
-static Gssctxt *gsscontext = NULL;
-#endif
-
/* Imports */
extern ServerOptions options;
extern u_int utmp_len;
@@ -98,7 +102,7 @@ struct {
u_int olen;
} child_state;
-/* Functions on the monitor that answer unprivileged requests */
+/* Functions on the montior that answer unprivileged requests */
int mm_answer_moduli(int, Buffer *);
int mm_answer_sign(int, Buffer *);
@@ -123,17 +127,17 @@ int mm_answer_sessid(int, Buffer *);
#ifdef USE_PAM
int mm_answer_pam_start(int, Buffer *);
-int mm_answer_pam_account(int, Buffer *);
int mm_answer_pam_init_ctx(int, Buffer *);
int mm_answer_pam_query(int, Buffer *);
int mm_answer_pam_respond(int, Buffer *);
int mm_answer_pam_free_ctx(int, Buffer *);
#endif
-#ifdef GSSAPI
-int mm_answer_gss_setup_ctx(int, Buffer *);
-int mm_answer_gss_accept_ctx(int, Buffer *);
-int mm_answer_gss_userok(int, Buffer *);
+#ifdef KRB4
+int mm_answer_krb4(int, Buffer *);
+#endif
+#ifdef KRB5
+int mm_answer_krb5(int, Buffer *);
#endif
static Authctxt *authctxt;
@@ -146,9 +150,8 @@ static int key_blobtype = MM_NOKEY;
static char *hostbased_cuser = NULL;
static char *hostbased_chost = NULL;
static char *auth_method = "unknown";
-static u_int session_id2_len = 0;
+static int session_id2_len = 0;
static u_char *session_id2 = NULL;
-static pid_t monitor_child_pid;
struct mon_table {
enum monitor_reqtype type;
@@ -173,7 +176,6 @@ struct mon_table mon_dispatch_proto20[] = {
{MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
#ifdef USE_PAM
{MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start},
- {MONITOR_REQ_PAM_ACCOUNT, 0, mm_answer_pam_account},
{MONITOR_REQ_PAM_INIT_CTX, MON_ISAUTH, mm_answer_pam_init_ctx},
{MONITOR_REQ_PAM_QUERY, MON_ISAUTH, mm_answer_pam_query},
{MONITOR_REQ_PAM_RESPOND, MON_ISAUTH, mm_answer_pam_respond},
@@ -189,11 +191,6 @@ struct mon_table mon_dispatch_proto20[] = {
#endif
{MONITOR_REQ_KEYALLOWED, MON_ISAUTH, mm_answer_keyallowed},
{MONITOR_REQ_KEYVERIFY, MON_AUTH, mm_answer_keyverify},
-#ifdef GSSAPI
- {MONITOR_REQ_GSSSETUP, MON_ISAUTH, mm_answer_gss_setup_ctx},
- {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
- {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
-#endif
{0, 0, NULL}
};
@@ -225,12 +222,17 @@ struct mon_table mon_dispatch_proto15[] = {
#endif
#ifdef USE_PAM
{MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start},
- {MONITOR_REQ_PAM_ACCOUNT, 0, mm_answer_pam_account},
{MONITOR_REQ_PAM_INIT_CTX, MON_ISAUTH, mm_answer_pam_init_ctx},
{MONITOR_REQ_PAM_QUERY, MON_ISAUTH, mm_answer_pam_query},
{MONITOR_REQ_PAM_RESPOND, MON_ISAUTH, mm_answer_pam_respond},
{MONITOR_REQ_PAM_FREE_CTX, MON_ONCE|MON_AUTHDECIDE, mm_answer_pam_free_ctx},
#endif
+#ifdef KRB4
+ {MONITOR_REQ_KRB4, MON_ONCE|MON_AUTH, mm_answer_krb4},
+#endif
+#ifdef KRB5
+ {MONITOR_REQ_KRB5, MON_ONCE|MON_AUTH, mm_answer_krb5},
+#endif
{0, 0, NULL}
};
@@ -304,18 +306,6 @@ monitor_child_preauth(struct monitor *pmonitor)
if (authctxt->pw->pw_uid == 0 &&
!auth_root_allowed(auth_method))
authenticated = 0;
-#ifdef USE_PAM
- /* PAM needs to perform account checks after auth */
- if (options.use_pam) {
- Buffer m;
-
- buffer_init(&m);
- mm_request_receive_expect(pmonitor->m_sendfd,
- MONITOR_REQ_PAM_ACCOUNT, &m);
- authenticated = mm_answer_pam_account(pmonitor->m_sendfd, &m);
- buffer_free(&m);
- }
-#endif
}
if (ent->flags & MON_AUTHDECIDE) {
@@ -337,25 +327,9 @@ monitor_child_preauth(struct monitor *pmonitor)
return (authctxt);
}
-static void
-monitor_set_child_handler(pid_t pid)
-{
- monitor_child_pid = pid;
-}
-
-static void
-monitor_child_handler(int signal)
-{
- kill(monitor_child_pid, signal);
-}
-
void
monitor_child_postauth(struct monitor *pmonitor)
{
- monitor_set_child_handler(pmonitor->m_pid);
- signal(SIGHUP, &monitor_child_handler);
- signal(SIGTERM, &monitor_child_handler);
-
if (compat20) {
mon_dispatch = mon_dispatch_postauth20;
@@ -363,6 +337,7 @@ monitor_child_postauth(struct monitor *pmonitor)
monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
+
} else {
mon_dispatch = mon_dispatch_postauth15;
monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
@@ -598,8 +573,7 @@ mm_answer_pwnamallow(int socket, Buffer *m)
}
#ifdef USE_PAM
- if (options.use_pam)
- monitor_permit(mon_dispatch, MONITOR_REQ_PAM_START, 1);
+ monitor_permit(mon_dispatch, MONITOR_REQ_PAM_START, 1);
#endif
return (0);
@@ -649,7 +623,7 @@ mm_answer_authpassword(int socket, Buffer *m)
passwd = buffer_get_string(m, &plen);
/* Only authenticate if the context is valid */
authenticated = options.password_authentication &&
- auth_password(authctxt, passwd);
+ authctxt->valid && auth_password(authctxt, passwd);
memset(passwd, 0, strlen(passwd));
xfree(passwd);
@@ -782,39 +756,17 @@ mm_answer_pam_start(int socket, Buffer *m)
{
char *user;
- if (!options.use_pam)
- fatal("UsePAM not set, but ended up in %s anyway", __func__);
-
user = buffer_get_string(m, NULL);
start_pam(user);
xfree(user);
- monitor_permit(mon_dispatch, MONITOR_REQ_PAM_ACCOUNT, 1);
-
return (0);
}
-int
-mm_answer_pam_account(int socket, Buffer *m)
-{
- u_int ret;
-
- if (!options.use_pam)
- fatal("UsePAM not set, but ended up in %s anyway", __func__);
-
- ret = do_pam_account();
-
- buffer_put_int(m, ret);
-
- mm_request_send(socket, MONITOR_ANS_PAM_ACCOUNT, m);
-
- return (ret);
-}
-
-static void *sshpam_ctxt, *sshpam_authok;
-extern KbdintDevice sshpam_device;
+static void *pam_ctxt, *pam_authok;
+extern KbdintDevice pam_device;
int
mm_answer_pam_init_ctx(int socket, Buffer *m)
@@ -822,10 +774,10 @@ mm_answer_pam_init_ctx(int socket, Buffer *m)
debug3("%s", __func__);
authctxt->user = buffer_get_string(m, NULL);
- sshpam_ctxt = (sshpam_device.init_ctx)(authctxt);
- sshpam_authok = NULL;
+ pam_ctxt = (pam_device.init_ctx)(authctxt);
+ pam_authok = NULL;
buffer_clear(m);
- if (sshpam_ctxt != NULL) {
+ if (pam_ctxt != NULL) {
monitor_permit(mon_dispatch, MONITOR_REQ_PAM_FREE_CTX, 1);
buffer_put_int(m, 1);
} else {
@@ -843,10 +795,10 @@ mm_answer_pam_query(int socket, Buffer *m)
int i, ret;
debug3("%s", __func__);
- sshpam_authok = NULL;
- ret = (sshpam_device.query)(sshpam_ctxt, &name, &info, &num, &prompts, &echo_on);
+ pam_authok = NULL;
+ ret = (pam_device.query)(pam_ctxt, &name, &info, &num, &prompts, &echo_on);
if (ret == 0 && num == 0)
- sshpam_authok = sshpam_ctxt;
+ pam_authok = pam_ctxt;
if (num > 1 || name == NULL || info == NULL)
ret = -1;
buffer_clear(m);
@@ -877,25 +829,25 @@ mm_answer_pam_respond(int socket, Buffer *m)
int i, ret;
debug3("%s", __func__);
- sshpam_authok = NULL;
+ pam_authok = NULL;
num = buffer_get_int(m);
if (num > 0) {
resp = xmalloc(num * sizeof(char *));
for (i = 0; i < num; ++i)
resp[i] = buffer_get_string(m, NULL);
- ret = (sshpam_device.respond)(sshpam_ctxt, num, resp);
+ ret = (pam_device.respond)(pam_ctxt, num, resp);
for (i = 0; i < num; ++i)
xfree(resp[i]);
xfree(resp);
} else {
- ret = (sshpam_device.respond)(sshpam_ctxt, num, NULL);
+ ret = (pam_device.respond)(pam_ctxt, num, NULL);
}
buffer_clear(m);
buffer_put_int(m, ret);
mm_request_send(socket, MONITOR_ANS_PAM_RESPOND, m);
auth_method = "keyboard-interactive/pam";
if (ret == 0)
- sshpam_authok = sshpam_ctxt;
+ pam_authok = pam_ctxt;
return (0);
}
@@ -904,10 +856,10 @@ mm_answer_pam_free_ctx(int socket, Buffer *m)
{
debug3("%s", __func__);
- (sshpam_device.free_ctx)(sshpam_ctxt);
+ (pam_device.free_ctx)(pam_ctxt);
buffer_clear(m);
mm_request_send(socket, MONITOR_ANS_PAM_FREE_CTX, m);
- return (sshpam_authok == sshpam_ctxt);
+ return (pam_authok == pam_ctxt);
}
#endif
@@ -1032,7 +984,7 @@ monitor_valid_userblob(u_char *data, u_int datalen)
fail++;
p = buffer_get_string(&b, NULL);
if (strcmp(authctxt->user, p) != 0) {
- logit("wrong user name passed to monitor: expected %s != %.100s",
+ log("wrong user name passed to monitor: expected %s != %.100s",
authctxt->user, p);
fail++;
}
@@ -1080,7 +1032,7 @@ monitor_valid_hostbasedblob(u_char *data, u_int datalen, char *cuser,
fail++;
p = buffer_get_string(&b, NULL);
if (strcmp(authctxt->user, p) != 0) {
- logit("wrong user name passed to monitor: expected %s != %.100s",
+ log("wrong user name passed to monitor: expected %s != %.100s",
authctxt->user, p);
fail++;
}
@@ -1190,14 +1142,14 @@ mm_record_login(Session *s, struct passwd *pw)
}
/* Record that there was a login on that tty from the remote host. */
record_login(s->pid, s->tty, pw->pw_name, pw->pw_uid,
- get_remote_name_or_ip(utmp_len, options.use_dns),
+ get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping),
(struct sockaddr *)&from, fromlen);
}
static void
mm_session_close(Session *s)
{
- debug3("%s: session %d pid %ld", __func__, s->self, (long)s->pid);
+ debug3("%s: session %d pid %d", __func__, s->self, s->pid);
if (s->ttyfd != -1) {
debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ptyfd);
fatal_remove_cleanup(session_pty_cleanup2, (void *)s);
@@ -1461,6 +1413,89 @@ mm_answer_rsa_response(int socket, Buffer *m)
return (success);
}
+#ifdef KRB4
+int
+mm_answer_krb4(int socket, Buffer *m)
+{
+ KTEXT_ST auth, reply;
+ char *client, *p;
+ int success;
+ u_int alen;
+
+ reply.length = auth.length = 0;
+
+ p = buffer_get_string(m, &alen);
+ if (alen >= MAX_KTXT_LEN)
+ fatal("%s: auth too large", __func__);
+ memcpy(auth.dat, p, alen);
+ auth.length = alen;
+ memset(p, 0, alen);
+ xfree(p);
+
+ success = options.kerberos_authentication &&
+ authctxt->valid &&
+ auth_krb4(authctxt, &auth, &client, &reply);
+
+ memset(auth.dat, 0, alen);
+ buffer_clear(m);
+ buffer_put_int(m, success);
+
+ if (success) {
+ buffer_put_cstring(m, client);
+ buffer_put_string(m, reply.dat, reply.length);
+ if (client)
+ xfree(client);
+ if (reply.length)
+ memset(reply.dat, 0, reply.length);
+ }
+
+ debug3("%s: sending result %d", __func__, success);
+ mm_request_send(socket, MONITOR_ANS_KRB4, m);
+
+ auth_method = "kerberos";
+
+ /* Causes monitor loop to terminate if authenticated */
+ return (success);
+}
+#endif
+
+#ifdef KRB5
+int
+mm_answer_krb5(int socket, Buffer *m)
+{
+ krb5_data tkt, reply;
+ char *client_user;
+ u_int len;
+ int success;
+
+ /* use temporary var to avoid size issues on 64bit arch */
+ tkt.data = buffer_get_string(m, &len);
+ tkt.length = len;
+
+ success = options.kerberos_authentication &&
+ authctxt->valid &&
+ auth_krb5(authctxt, &tkt, &client_user, &reply);
+
+ if (tkt.length)
+ xfree(tkt.data);
+
+ buffer_clear(m);
+ buffer_put_int(m, success);
+
+ if (success) {
+ buffer_put_cstring(m, client_user);
+ buffer_put_string(m, reply.data, reply.length);
+ if (client_user)
+ xfree(client_user);
+ if (reply.length)
+ xfree(reply.data);
+ }
+ mm_request_send(socket, MONITOR_ANS_KRB5, m);
+
+ return success;
+}
+#endif
+
int
mm_answer_term(int socket, Buffer *req)
{
@@ -1576,8 +1611,6 @@ mm_get_keystate(struct monitor *pmonitor)
Buffer m;
u_char *blob, *p;
u_int bloblen, plen;
- u_int32_t seqnr, packets;
- u_int64_t blocks;
debug3("%s: Waiting for new keys", __func__);
@@ -1607,14 +1640,8 @@ mm_get_keystate(struct monitor *pmonitor)
xfree(blob);
/* Now get sequence numbers for the packets */
- seqnr = buffer_get_int(&m);
- blocks = buffer_get_int64(&m);
- packets = buffer_get_int(&m);
- packet_set_state(MODE_OUT, seqnr, blocks, packets);
- seqnr = buffer_get_int(&m);
- blocks = buffer_get_int64(&m);
- packets = buffer_get_int(&m);
- packet_set_state(MODE_IN, seqnr, blocks, packets);
+ packet_set_seqnr(MODE_OUT, buffer_get_int(&m));
+ packet_set_seqnr(MODE_IN, buffer_get_int(&m));
skip:
/* Get the key context */
@@ -1735,79 +1762,3 @@ monitor_reinit(struct monitor *mon)
mon->m_recvfd = pair[0];
mon->m_sendfd = pair[1];
}
-
-#ifdef GSSAPI
-int
-mm_answer_gss_setup_ctx(int socket, Buffer *m)
-{
- gss_OID_desc oid;
- OM_uint32 major;
- u_int len;
-
- oid.elements = buffer_get_string(m, &len);
- oid.length = len;
-
- major = ssh_gssapi_server_ctx(&gsscontext, &oid);
-
- xfree(oid.elements);
-
- buffer_clear(m);
- buffer_put_int(m, major);
-
- mm_request_send(socket,MONITOR_ANS_GSSSETUP, m);
-
- /* Now we have a context, enable the step */
- monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 1);
-
- return (0);
-}
-
-int
-mm_answer_gss_accept_ctx(int socket, Buffer *m)
-{
- gss_buffer_desc in;
- gss_buffer_desc out = GSS_C_EMPTY_BUFFER;
- OM_uint32 major,minor;
- OM_uint32 flags = 0; /* GSI needs this */
- u_int len;
-
- in.value = buffer_get_string(m, &len);
- in.length = len;
- major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
- xfree(in.value);
-
- buffer_clear(m);
- buffer_put_int(m, major);
- buffer_put_string(m, out.value, out.length);
- buffer_put_int(m, flags);
- mm_request_send(socket, MONITOR_ANS_GSSSTEP, m);
-
- gss_release_buffer(&minor, &out);
-
- /* Complete - now we can do signing */
- if (major==GSS_S_COMPLETE) {
- monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
- monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
- }
- return (0);
-}
-
-int
-mm_answer_gss_userok(int socket, Buffer *m)
-{
- int authenticated;
-
- authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);
-
- buffer_clear(m);
- buffer_put_int(m, authenticated);
-
- debug3("%s: sending result %d", __func__, authenticated);
- mm_request_send(socket, MONITOR_ANS_GSSUSEROK, m);
-
- auth_method="gssapi";
-
- /* Monitor loop will terminate if authenticated */
- return (authenticated);
-}
-#endif /* GSSAPI */
diff --git a/crypto/openssh/monitor.h b/crypto/openssh/monitor.h
index 2461156..5fd6ec2 100644
--- a/crypto/openssh/monitor.h
+++ b/crypto/openssh/monitor.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: monitor.h,v 1.11 2003/08/28 12:54:34 markus Exp $ */
+/* $OpenBSD: monitor.h,v 1.8 2002/09/26 11:38:43 markus Exp $ */
+/* $FreeBSD$ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
@@ -49,11 +50,9 @@ enum monitor_reqtype {
MONITOR_REQ_RSAKEYALLOWED, MONITOR_ANS_RSAKEYALLOWED,
MONITOR_REQ_RSACHALLENGE, MONITOR_ANS_RSACHALLENGE,
MONITOR_REQ_RSARESPONSE, MONITOR_ANS_RSARESPONSE,
- MONITOR_REQ_GSSSETUP, MONITOR_ANS_GSSSETUP,
- MONITOR_REQ_GSSSTEP, MONITOR_ANS_GSSSTEP,
- MONITOR_REQ_GSSUSEROK, MONITOR_ANS_GSSUSEROK,
+ MONITOR_REQ_KRB4, MONITOR_ANS_KRB4,
+ MONITOR_REQ_KRB5, MONITOR_ANS_KRB5,
MONITOR_REQ_PAM_START,
- MONITOR_REQ_PAM_ACCOUNT, MONITOR_ANS_PAM_ACCOUNT,
MONITOR_REQ_PAM_INIT_CTX, MONITOR_ANS_PAM_INIT_CTX,
MONITOR_REQ_PAM_QUERY, MONITOR_ANS_PAM_QUERY,
MONITOR_REQ_PAM_RESPOND, MONITOR_ANS_PAM_RESPOND,
diff --git a/crypto/openssh/monitor_wrap.c b/crypto/openssh/monitor_wrap.c
index 4034d56..54a5216 100644
--- a/crypto/openssh/monitor_wrap.c
+++ b/crypto/openssh/monitor_wrap.c
@@ -25,7 +25,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor_wrap.c,v 1.31 2003/08/28 12:54:34 markus Exp $");
+RCSID("$OpenBSD: monitor_wrap.c,v 1.24 2003/04/01 10:22:21 markus Exp $");
+RCSID("$FreeBSD$");
#include <openssl/bn.h>
#include <openssl/dh.h>
@@ -47,16 +48,11 @@ RCSID("$OpenBSD: monitor_wrap.c,v 1.31 2003/08/28 12:54:34 markus Exp $");
#include "atomicio.h"
#include "monitor_fdpass.h"
#include "getput.h"
-#include "servconf.h"
#include "auth.h"
#include "channels.h"
#include "session.h"
-#ifdef GSSAPI
-#include "ssh-gss.h"
-#endif
-
/* Imports */
extern int compat20;
extern Newkeys *newkeys[];
@@ -64,7 +60,6 @@ extern z_stream incoming_stream;
extern z_stream outgoing_stream;
extern struct monitor *pmonitor;
extern Buffer input, output;
-extern ServerOptions options;
void
mm_request_send(int socket, enum monitor_reqtype type, Buffer *m)
@@ -76,9 +71,9 @@ mm_request_send(int socket, enum monitor_reqtype type, Buffer *m)
PUT_32BIT(buf, mlen + 1);
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */
- if (atomicio(vwrite, socket, buf, sizeof(buf)) != sizeof(buf))
+ if (atomicio(write, socket, buf, sizeof(buf)) != sizeof(buf))
fatal("%s: write", __func__);
- if (atomicio(vwrite, socket, buffer_ptr(m), mlen) != mlen)
+ if (atomicio(write, socket, buffer_ptr(m), mlen) != mlen)
fatal("%s: write", __func__);
}
@@ -526,8 +521,6 @@ mm_send_keystate(struct monitor *pmonitor)
Buffer m;
u_char *blob, *p;
u_int bloblen, plen;
- u_int32_t seqnr, packets;
- u_int64_t blocks;
buffer_init(&m);
@@ -576,14 +569,8 @@ mm_send_keystate(struct monitor *pmonitor)
buffer_put_string(&m, blob, bloblen);
xfree(blob);
- packet_get_state(MODE_OUT, &seqnr, &blocks, &packets);
- buffer_put_int(&m, seqnr);
- buffer_put_int64(&m, blocks);
- buffer_put_int(&m, packets);
- packet_get_state(MODE_IN, &seqnr, &blocks, &packets);
- buffer_put_int(&m, seqnr);
- buffer_put_int64(&m, blocks);
- buffer_put_int(&m, packets);
+ buffer_put_int(&m, packet_get_seqnr(MODE_OUT));
+ buffer_put_int(&m, packet_get_seqnr(MODE_IN));
debug3("%s: New keys have been sent", __func__);
skip:
@@ -675,8 +662,6 @@ mm_start_pam(char *user)
Buffer m;
debug3("%s entering", __func__);
- if (!options.use_pam)
- fatal("UsePAM=no, but ended up in %s anyway", __func__);
buffer_init(&m);
buffer_put_cstring(&m, user);
@@ -686,32 +671,8 @@ mm_start_pam(char *user)
buffer_free(&m);
}
-u_int
-mm_do_pam_account(void)
-{
- Buffer m;
- u_int ret;
-
- debug3("%s entering", __func__);
- if (!options.use_pam)
- fatal("UsePAM=no, but ended up in %s anyway", __func__);
-
- buffer_init(&m);
- mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_ACCOUNT, &m);
-
- mm_request_receive_expect(pmonitor->m_recvfd,
- MONITOR_ANS_PAM_ACCOUNT, &m);
- ret = buffer_get_int(&m);
-
- buffer_free(&m);
-
- debug3("%s returning %d", __func__, ret);
-
- return (ret);
-}
-
void *
-mm_sshpam_init_ctx(Authctxt *authctxt)
+mm_pam_init_ctx(Authctxt *authctxt)
{
Buffer m;
int success;
@@ -733,7 +694,7 @@ mm_sshpam_init_ctx(Authctxt *authctxt)
}
int
-mm_sshpam_query(void *ctx, char **name, char **info,
+mm_pam_query(void *ctx, char **name, char **info,
u_int *num, char ***prompts, u_int **echo_on)
{
Buffer m;
@@ -760,7 +721,7 @@ mm_sshpam_query(void *ctx, char **name, char **info,
}
int
-mm_sshpam_respond(void *ctx, u_int num, char **resp)
+mm_pam_respond(void *ctx, u_int num, char **resp)
{
Buffer m;
int i, ret;
@@ -780,7 +741,7 @@ mm_sshpam_respond(void *ctx, u_int num, char **resp)
}
void
-mm_sshpam_free_ctx(void *ctxtp)
+mm_pam_free_ctx(void *ctxtp)
{
Buffer m;
@@ -894,6 +855,7 @@ mm_bsdauth_respond(void *ctx, u_int numresponses, char **responses)
return ((authok == 0) ? -1 : 0);
}
+#ifdef SKEY
int
mm_skey_query(void *ctx, char **name, char **infotxt,
u_int *numprompts, char ***prompts, u_int **echo_on)
@@ -957,6 +919,7 @@ mm_skey_respond(void *ctx, u_int numresponses, char **responses)
return ((authok == 0) ? -1 : 0);
}
+#endif
void
mm_ssh1_session_id(u_char session_id[16])
@@ -1071,69 +1034,73 @@ mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
return (success);
}
-#ifdef GSSAPI
-OM_uint32
-mm_ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid)
+#ifdef KRB4
+int
+mm_auth_krb4(Authctxt *authctxt, void *_auth, char **client, void *_reply)
{
- Buffer m;
- OM_uint32 major;
-
- /* Client doesn't get to see the context */
- *ctx = NULL;
-
- buffer_init(&m);
- buffer_put_string(&m, oid->elements, oid->length);
-
- mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSETUP, &m);
- mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSETUP, &m);
-
- major = buffer_get_int(&m);
-
- buffer_free(&m);
- return (major);
-}
+ KTEXT auth, reply;
+ Buffer m;
+ u_int rlen;
+ int success = 0;
+ char *p;
-OM_uint32
-mm_ssh_gssapi_accept_ctx(Gssctxt *ctx, gss_buffer_desc *in,
- gss_buffer_desc *out, OM_uint32 *flags)
-{
- Buffer m;
- OM_uint32 major;
- u_int len;
+ debug3("%s entering", __func__);
+ auth = _auth;
+ reply = _reply;
buffer_init(&m);
- buffer_put_string(&m, in->value, in->length);
+ buffer_put_string(&m, auth->dat, auth->length);
- mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSTEP, &m);
- mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSTEP, &m);
-
- major = buffer_get_int(&m);
- out->value = buffer_get_string(&m, &len);
- out->length = len;
- if (flags)
- *flags = buffer_get_int(&m);
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB4, &m);
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB4, &m);
+ success = buffer_get_int(&m);
+ if (success) {
+ *client = buffer_get_string(&m, NULL);
+ p = buffer_get_string(&m, &rlen);
+ if (rlen >= MAX_KTXT_LEN)
+ fatal("%s: reply from monitor too large", __func__);
+ reply->length = rlen;
+ memcpy(reply->dat, p, rlen);
+ memset(p, 0, rlen);
+ xfree(p);
+ }
buffer_free(&m);
-
- return (major);
+ return (success);
}
+#endif
+#ifdef KRB5
int
-mm_ssh_gssapi_userok(char *user)
+mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp)
{
+ krb5_data *tkt, *reply;
Buffer m;
- int authenticated = 0;
+ int success;
+
+ debug3("%s entering", __func__);
+ tkt = (krb5_data *) argp;
+ reply = (krb5_data *) resp;
buffer_init(&m);
+ buffer_put_string(&m, tkt->data, tkt->length);
- mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUSEROK, &m);
- mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUSEROK,
- &m);
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB5, &m);
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB5, &m);
- authenticated = buffer_get_int(&m);
+ success = buffer_get_int(&m);
+ if (success) {
+ u_int len;
+
+ *userp = buffer_get_string(&m, NULL);
+ reply->data = buffer_get_string(&m, &len);
+ reply->length = len;
+ } else {
+ memset(reply, 0, sizeof(*reply));
+ *userp = NULL;
+ }
buffer_free(&m);
- debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
- return (authenticated);
+ return (success);
}
-#endif /* GSSAPI */
+#endif
diff --git a/crypto/openssh/monitor_wrap.h b/crypto/openssh/monitor_wrap.h
index 5e03345..e404be5 100644
--- a/crypto/openssh/monitor_wrap.h
+++ b/crypto/openssh/monitor_wrap.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: monitor_wrap.h,v 1.11 2003/08/28 12:54:34 markus Exp $ */
+/* $OpenBSD: monitor_wrap.h,v 1.8 2002/09/26 11:38:43 markus Exp $ */
+/* $FreeBSD$ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
@@ -55,21 +56,12 @@ int mm_auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
int mm_auth_rsa_verify_response(Key *, BIGNUM *, u_char *);
BIGNUM *mm_auth_rsa_generate_challenge(Key *);
-#ifdef GSSAPI
-#include "ssh-gss.h"
-OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **ctxt, gss_OID oid);
-OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *ctxt,
- gss_buffer_desc *recv, gss_buffer_desc *send, OM_uint32 *flags);
-int mm_ssh_gssapi_userok(char *user);
-#endif
-
#ifdef USE_PAM
void mm_start_pam(char *);
-u_int mm_do_pam_account(void);
-void *mm_sshpam_init_ctx(struct Authctxt *);
-int mm_sshpam_query(void *, char **, char **, u_int *, char ***, u_int **);
-int mm_sshpam_respond(void *, u_int, char **);
-void mm_sshpam_free_ctx(void *);
+void *mm_pam_init_ctx(struct Authctxt *);
+int mm_pam_query(void *, char **, char **, u_int *, char ***, u_int **);
+int mm_pam_respond(void *, u_int, char **);
+void mm_pam_free_ctx(void *);
#endif
void mm_terminate(void);
@@ -96,6 +88,16 @@ int mm_bsdauth_respond(void *, u_int, char **);
int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **);
int mm_skey_respond(void *, u_int, char **);
+/* auth_krb */
+#ifdef KRB4
+int mm_auth_krb4(struct Authctxt *, void *, char **, void *);
+#endif
+#ifdef KRB5
+/* auth and reply are really krb5_data objects, but we don't want to
+ * include all of the krb5 headers here */
+int mm_auth_krb5(void *authctxt, void *auth, char **client, void *reply);
+#endif
+
/* zlib allocation hooks */
void *mm_zalloc(struct mm_master *, u_int, u_int);
diff --git a/crypto/openssh/myproposal.h b/crypto/openssh/myproposal.h
index 8b431d9..372ac7e 100644
--- a/crypto/openssh/myproposal.h
+++ b/crypto/openssh/myproposal.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: myproposal.h,v 1.15 2003/05/17 04:27:52 markus Exp $ */
+/* $OpenBSD: myproposal.h,v 1.14 2002/04/03 09:26:11 markus Exp $ */
+/* $FreeBSD$ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -24,11 +25,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define KEX_DEFAULT_KEX "diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1"
-#define KEX_DEFAULT_PK_ALG "ssh-rsa,ssh-dss"
+#define KEX_DEFAULT_PK_ALG "ssh-dss,ssh-rsa"
#define KEX_DEFAULT_ENCRYPT \
"aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour," \
- "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se," \
- "aes128-ctr,aes192-ctr,aes256-ctr"
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se"
#define KEX_DEFAULT_MAC \
"hmac-md5,hmac-sha1,hmac-ripemd160," \
"hmac-ripemd160@openssh.com," \
diff --git a/crypto/openssh/nchan.h b/crypto/openssh/nchan.h
deleted file mode 100644
index 623eccc..0000000
--- 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/packet.h b/crypto/openssh/packet.h
index 7732faf..46830c3 100644
--- a/crypto/openssh/packet.h
+++ b/crypto/openssh/packet.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.h,v 1.40 2003/06/24 08:23:46 markus Exp $ */
+/* $OpenBSD: packet.h,v 1.37 2003/04/01 10:22:21 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -62,8 +62,8 @@ int packet_get_keyiv_len(int);
void packet_get_keyiv(int, u_char *, u_int);
int packet_get_keycontext(int, u_char *);
void packet_set_keycontext(int, u_char *);
-void packet_get_state(int, u_int32_t *, u_int64_t *, u_int32_t *);
-void packet_set_state(int, u_int32_t, u_int64_t, u_int32_t);
+u_int32_t packet_get_seqnr(int);
+void packet_set_seqnr(int, u_int32_t);
int packet_get_ssh1_cipher(void);
void packet_set_iv(int, u_char *);
@@ -81,8 +81,8 @@ void packet_add_padding(u_char);
void tty_make_modes(int, struct termios *);
void tty_parse_modes(int, int *);
-extern u_int max_packet_size;
-u_int packet_set_maxsize(u_int);
+extern int max_packet_size;
+int packet_set_maxsize(int);
#define packet_get_maxsize() max_packet_size
/* don't allow remaining bytes after the end of the message */
@@ -90,13 +90,10 @@ u_int packet_set_maxsize(u_int);
do { \
int _len = packet_remaining(); \
if (_len > 0) { \
- logit("Packet integrity error (%d bytes remaining) at %s:%d", \
+ log("Packet integrity error (%d bytes remaining) at %s:%d", \
_len ,__FILE__, __LINE__); \
packet_disconnect("Packet integrity error."); \
} \
} while (0)
-int packet_need_rekeying(void);
-void packet_set_rekey_limit(u_int32_t);
-
#endif /* PACKET_H */
diff --git a/crypto/openssh/pty.c b/crypto/openssh/pty.c
deleted file mode 100644
index 9300bd5..0000000
--- 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 13d8e60..0000000
--- 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/readconf.c b/crypto/openssh/readconf.c
index 13987ff..0742b5f 100644
--- a/crypto/openssh/readconf.c
+++ b/crypto/openssh/readconf.c
@@ -12,7 +12,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: readconf.c,v 1.121 2003/09/01 18:15:50 markus Exp $");
+RCSID("$OpenBSD: readconf.c,v 1.104 2003/04/01 10:22:21 markus Exp $");
+RCSID("$FreeBSD$");
#include "ssh.h"
#include "xmalloc.h"
@@ -57,6 +58,7 @@ RCSID("$OpenBSD: readconf.c,v 1.121 2003/09/01 18:15:50 markus Exp $");
Host fascist.blob.com
Port 23123
User tylonen
+ RhostsAuthentication no
PasswordAuthentication no
Host puukko.hut.fi
@@ -74,6 +76,7 @@ RCSID("$OpenBSD: readconf.c,v 1.121 2003/09/01 18:15:50 markus Exp $");
Host *
ForwardAgent no
ForwardX11 no
+ RhostsAuthentication yes
PasswordAuthentication yes
RSAAuthentication yes
RhostsRSAAuthentication yes
@@ -89,9 +92,18 @@ RCSID("$OpenBSD: readconf.c,v 1.121 2003/09/01 18:15:50 markus Exp $");
typedef enum {
oBadOption,
- oForwardAgent, oForwardX11, oGatewayPorts,
+ oForwardAgent, oForwardX11, oGatewayPorts, oRhostsAuthentication,
oPasswordAuthentication, oRSAAuthentication,
oChallengeResponseAuthentication, oXAuthLocation,
+#if defined(KRB4) || defined(KRB5)
+ oKerberosAuthentication,
+#endif
+#if defined(AFS) || defined(KRB5)
+ oKerberosTgtPassing,
+#endif
+#ifdef AFS
+ oAFSTokenPassing,
+#endif
oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
@@ -103,9 +115,9 @@ typedef enum {
oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
oClearAllForwardings, oNoHostAuthenticationForLocalhost,
- oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
- oAddressFamily, oGssAuthentication, oGssDelegateCreds,
- oDeprecated, oUnsupported
+ oEnableSSHKeysign,
+ oVersionAddendum,
+ oDeprecated
} OpCodes;
/* Textual representations of the tokens. */
@@ -119,7 +131,7 @@ static struct {
{ "xauthlocation", oXAuthLocation },
{ "gatewayports", oGatewayPorts },
{ "useprivilegedport", oUsePrivilegedPort },
- { "rhostsauthentication", oDeprecated },
+ { "rhostsauthentication", oRhostsAuthentication },
{ "passwordauthentication", oPasswordAuthentication },
{ "kbdinteractiveauthentication", oKbdInteractiveAuthentication },
{ "kbdinteractivedevices", oKbdInteractiveDevices },
@@ -131,15 +143,14 @@ static struct {
{ "challengeresponseauthentication", oChallengeResponseAuthentication },
{ "skeyauthentication", oChallengeResponseAuthentication }, /* alias */
{ "tisauthentication", oChallengeResponseAuthentication }, /* alias */
- { "kerberosauthentication", oUnsupported },
- { "kerberostgtpassing", oUnsupported },
- { "afstokenpassing", oUnsupported },
-#if defined(GSSAPI)
- { "gssapiauthentication", oGssAuthentication },
- { "gssapidelegatecredentials", oGssDelegateCreds },
-#else
- { "gssapiauthentication", oUnsupported },
- { "gssapidelegatecredentials", oUnsupported },
+#if defined(KRB4) || defined(KRB5)
+ { "kerberosauthentication", oKerberosAuthentication },
+#endif
+#if defined(AFS) || defined(KRB5)
+ { "kerberostgtpassing", oKerberosTgtPassing },
+#endif
+#ifdef AFS
+ { "afstokenpassing", oAFSTokenPassing },
#endif
{ "fallbacktorsh", oDeprecated },
{ "usersh", oDeprecated },
@@ -175,22 +186,11 @@ static struct {
{ "preferredauthentications", oPreferredAuthentications },
{ "hostkeyalgorithms", oHostKeyAlgorithms },
{ "bindaddress", oBindAddress },
-#ifdef SMARTCARD
{ "smartcarddevice", oSmartcardDevice },
-#else
- { "smartcarddevice", oUnsupported },
-#endif
{ "clearallforwardings", oClearAllForwardings },
{ "enablesshkeysign", oEnableSSHKeysign },
-#ifdef DNS
- { "verifyhostkeydns", oVerifyHostKeyDNS },
-#else
- { "verifyhostkeydns", oUnsupported },
-#endif
{ "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
- { "rekeylimit", oRekeyLimit },
- { "connecttimeout", oConnectTimeout },
- { "addressfamily", oAddressFamily },
+ { "versionaddendum", oVersionAddendum },
{ NULL, oBadOption }
};
@@ -284,13 +284,6 @@ process_config_line(Options *options, const char *host,
u_short fwd_port, fwd_host_port;
char sfwd_host_port[6];
- /* Strip trailing whitespace */
- for(len = strlen(line) - 1; len > 0; len--) {
- if (strchr(WHITESPACE, line[len]) == NULL)
- break;
- line[len] = '\0';
- }
-
s = line;
/* Get the keyword. (Each line is supposed to begin with a keyword). */
keyword = strdelim(&s);
@@ -307,20 +300,6 @@ process_config_line(Options *options, const char *host,
/* don't panic, but count bad options */
return -1;
/* NOTREACHED */
- case oConnectTimeout:
- intptr = &options->connection_timeout;
-/* parse_time: */
- arg = strdelim(&s);
- if (!arg || *arg == '\0')
- fatal("%s line %d: missing time value.",
- filename, linenum);
- if ((value = convtime(arg)) == -1)
- fatal("%s line %d: invalid time value.",
- filename, linenum);
- if (*intptr == -1)
- *intptr = value;
- break;
-
case oForwardAgent:
intptr = &options->forward_agent;
parse_flag:
@@ -350,6 +329,10 @@ parse_flag:
intptr = &options->use_privileged_port;
goto parse_flag;
+ case oRhostsAuthentication:
+ intptr = &options->rhosts_authentication;
+ goto parse_flag;
+
case oPasswordAuthentication:
intptr = &options->password_authentication;
goto parse_flag;
@@ -381,15 +364,21 @@ parse_flag:
case oChallengeResponseAuthentication:
intptr = &options->challenge_response_authentication;
goto parse_flag;
-
- case oGssAuthentication:
- intptr = &options->gss_authentication;
+#if defined(KRB4) || defined(KRB5)
+ case oKerberosAuthentication:
+ intptr = &options->kerberos_authentication;
goto parse_flag;
-
- case oGssDelegateCreds:
- intptr = &options->gss_deleg_creds;
+#endif
+#if defined(AFS) || defined(KRB5)
+ case oKerberosTgtPassing:
+ intptr = &options->kerberos_tgt_passing;
goto parse_flag;
-
+#endif
+#ifdef AFS
+ case oAFSTokenPassing:
+ intptr = &options->afs_token_passing;
+ goto parse_flag;
+#endif
case oBatchMode:
intptr = &options->batch_mode;
goto parse_flag;
@@ -398,10 +387,6 @@ parse_flag:
intptr = &options->check_host_ip;
goto parse_flag;
- case oVerifyHostKeyDNS:
- intptr = &options->verify_host_key_dns;
- goto parse_flag;
-
case oStrictHostKeyChecking:
intptr = &options->strict_host_key_checking;
arg = strdelim(&s);
@@ -441,31 +426,6 @@ parse_flag:
intptr = &options->compression_level;
goto parse_int;
- case oRekeyLimit:
- intptr = &options->rekey_limit;
- arg = strdelim(&s);
- if (!arg || *arg == '\0')
- fatal("%.200s line %d: Missing argument.", filename, linenum);
- if (arg[0] < '0' || arg[0] > '9')
- fatal("%.200s line %d: Bad number.", filename, linenum);
- value = strtol(arg, &endofnumber, 10);
- if (arg == endofnumber)
- fatal("%.200s line %d: Bad number.", filename, linenum);
- switch (toupper(*endofnumber)) {
- case 'K':
- value *= 1<<10;
- break;
- case 'M':
- value *= 1<<20;
- break;
- case 'G':
- value *= 1<<30;
- break;
- }
- if (*activep && *intptr == -1)
- *intptr = value;
- break;
-
case oIdentityFile:
arg = strdelim(&s);
if (!arg || *arg == '\0')
@@ -532,8 +492,6 @@ parse_string:
goto parse_string;
case oProxyCommand:
- if (s == NULL)
- fatal("%.200s line %d: Missing argument.", filename, linenum);
charptr = &options->proxy_command;
len = strspn(s, WHITESPACE "=");
if (*activep && *charptr == NULL)
@@ -671,7 +629,7 @@ parse_int:
fatal("%.200s line %d: Badly formatted port number.",
filename, linenum);
if (*activep)
- add_local_forward(options, fwd_port, "socks", 0);
+ add_local_forward(options, fwd_port, "socks4", 0);
break;
case oClearAllForwardings:
@@ -711,35 +669,22 @@ parse_int:
*intptr = value;
break;
- case oAddressFamily:
- arg = strdelim(&s);
- intptr = &options->address_family;
- if (strcasecmp(arg, "inet") == 0)
- value = AF_INET;
- else if (strcasecmp(arg, "inet6") == 0)
- value = AF_INET6;
- else if (strcasecmp(arg, "any") == 0)
- value = AF_UNSPEC;
- else
- fatal("Unsupported AddressFamily \"%s\"", arg);
- if (*activep && *intptr == -1)
- *intptr = value;
- break;
-
case oEnableSSHKeysign:
intptr = &options->enable_ssh_keysign;
goto parse_flag;
+ case oVersionAddendum:
+ ssh_version_set_addendum(strtok(s, "\n"));
+ do {
+ arg = strdelim(&s);
+ } while (arg != NULL && *arg != '\0');
+ break;
+
case oDeprecated:
debug("%s line %d: Deprecated option \"%s\"",
filename, linenum, keyword);
return 0;
- case oUnsupported:
- error("%s line %d: Unsupported option \"%s\"",
- filename, linenum, keyword);
- return 0;
-
default:
fatal("process_config_line: Unimplemented opcode %d", opcode);
}
@@ -809,11 +754,19 @@ initialize_options(Options * options)
options->xauth_location = NULL;
options->gateway_ports = -1;
options->use_privileged_port = -1;
+ options->rhosts_authentication = -1;
options->rsa_authentication = -1;
options->pubkey_authentication = -1;
options->challenge_response_authentication = -1;
- options->gss_authentication = -1;
- options->gss_deleg_creds = -1;
+#if defined(KRB4) || defined(KRB5)
+ options->kerberos_authentication = -1;
+#endif
+#if defined(AFS) || defined(KRB5)
+ options->kerberos_tgt_passing = -1;
+#endif
+#ifdef AFS
+ options->afs_token_passing = -1;
+#endif
options->password_authentication = -1;
options->kbd_interactive_authentication = -1;
options->kbd_interactive_devices = NULL;
@@ -826,9 +779,7 @@ initialize_options(Options * options)
options->keepalives = -1;
options->compression_level = -1;
options->port = -1;
- options->address_family = -1;
options->connection_attempts = -1;
- options->connection_timeout = -1;
options->number_of_password_prompts = -1;
options->cipher = -1;
options->ciphers = NULL;
@@ -854,8 +805,6 @@ initialize_options(Options * options)
options->smartcard_device = NULL;
options->enable_ssh_keysign = - 1;
options->no_host_authentication_for_localhost = - 1;
- options->rekey_limit = - 1;
- options->verify_host_key_dns = -1;
}
/*
@@ -878,16 +827,26 @@ fill_default_options(Options * options)
options->gateway_ports = 0;
if (options->use_privileged_port == -1)
options->use_privileged_port = 0;
+ if (options->rhosts_authentication == -1)
+ options->rhosts_authentication = 0;
if (options->rsa_authentication == -1)
options->rsa_authentication = 1;
if (options->pubkey_authentication == -1)
options->pubkey_authentication = 1;
if (options->challenge_response_authentication == -1)
options->challenge_response_authentication = 1;
- if (options->gss_authentication == -1)
- options->gss_authentication = 1;
- if (options->gss_deleg_creds == -1)
- options->gss_deleg_creds = 0;
+#if defined(KRB4) || defined(KRB5)
+ if (options->kerberos_authentication == -1)
+ options->kerberos_authentication = 1;
+#endif
+#if defined(AFS) || defined(KRB5)
+ if (options->kerberos_tgt_passing == -1)
+ options->kerberos_tgt_passing = 1;
+#endif
+#ifdef AFS
+ if (options->afs_token_passing == -1)
+ options->afs_token_passing = 1;
+#endif
if (options->password_authentication == -1)
options->password_authentication = 1;
if (options->kbd_interactive_authentication == -1)
@@ -899,7 +858,7 @@ fill_default_options(Options * options)
if (options->batch_mode == -1)
options->batch_mode = 0;
if (options->check_host_ip == -1)
- options->check_host_ip = 1;
+ options->check_host_ip = 0;
if (options->strict_host_key_checking == -1)
options->strict_host_key_checking = 2; /* 2 is default */
if (options->compression == -1)
@@ -910,8 +869,6 @@ fill_default_options(Options * options)
options->compression_level = 6;
if (options->port == -1)
options->port = 0; /* Filled in ssh_connect. */
- if (options->address_family == -1)
- options->address_family = AF_UNSPEC;
if (options->connection_attempts == -1)
options->connection_attempts = 1;
if (options->number_of_password_prompts == -1)
@@ -964,10 +921,6 @@ fill_default_options(Options * options)
options->no_host_authentication_for_localhost = 0;
if (options->enable_ssh_keysign == -1)
options->enable_ssh_keysign = 0;
- if (options->rekey_limit == -1)
- options->rekey_limit = 0;
- if (options->verify_host_key_dns == -1)
- options->verify_host_key_dns = 0;
/* options->proxy_command should not be set by default */
/* options->user will be set in the main program if appropriate */
/* options->hostname will be set in the main program if appropriate */
diff --git a/crypto/openssh/readconf.h b/crypto/openssh/readconf.h
index 60287f7..78e04fe 100644
--- a/crypto/openssh/readconf.h
+++ b/crypto/openssh/readconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.h,v 1.55 2003/09/01 18:15:50 markus Exp $ */
+/* $OpenBSD: readconf.h,v 1.46 2003/04/01 10:22:21 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -33,6 +33,7 @@ typedef struct {
char *xauth_location; /* Location for xauth program */
int gateway_ports; /* Allow remote connects to forwarded ports. */
int use_privileged_port; /* Don't use privileged port if false. */
+ int rhosts_authentication; /* Try rhosts authentication. */
int rhosts_rsa_authentication; /* Try rhosts with RSA
* authentication. */
int rsa_authentication; /* Try RSA authentication. */
@@ -40,8 +41,15 @@ typedef struct {
int hostbased_authentication; /* ssh2's rhosts_rsa */
int challenge_response_authentication;
/* Try S/Key or TIS, authentication. */
- int gss_authentication; /* Try GSS authentication */
- int gss_deleg_creds; /* Delegate GSS credentials */
+#if defined(KRB4) || defined(KRB5)
+ int kerberos_authentication; /* Try Kerberos authentication. */
+#endif
+#if defined(AFS) || defined(KRB5)
+ int kerberos_tgt_passing; /* Try Kerberos TGT passing. */
+#endif
+#ifdef AFS
+ int afs_token_passing; /* Try AFS token passing. */
+#endif
int password_authentication; /* Try password
* authentication. */
int kbd_interactive_authentication; /* Try keyboard-interactive auth. */
@@ -56,11 +64,8 @@ typedef struct {
LogLevel log_level; /* Level for logging. */
int port; /* Port to connect. */
- int address_family;
int connection_attempts; /* Max attempts (seconds) before
* giving up */
- int connection_timeout; /* Max time (seconds) before
- * aborting connection attempt */
int number_of_password_prompts; /* Max number of password
* prompts. */
int cipher; /* Cipher to use. */
@@ -81,7 +86,6 @@ typedef struct {
char *preferred_authentications;
char *bind_address; /* local socket address for connection to sshd */
char *smartcard_device; /* Smartcard reader device */
- int verify_host_key_dns; /* Verify host key using DNS */
int num_identity_files; /* Number of files for RSA/DSA identities. */
char *identity_files[SSH_MAX_IDENTITY_FILES];
@@ -97,7 +101,6 @@ typedef struct {
int clear_forwardings;
int enable_ssh_keysign;
- int rekey_limit;
int no_host_authentication_for_localhost;
} Options;
diff --git a/crypto/openssh/scard/Makefile b/crypto/openssh/scard/Makefile
deleted file mode 100644
index 1cf7bbd..0000000
--- a/crypto/openssh/scard/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# $OpenBSD: Makefile,v 1.2 2001/06/29 07:02:09 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-CARDLET= Ssh.bin
-DATADIR= /usr/libdata/ssh
-
-all: ${CARDLET}
-
-clean:
- rm -f ${CARDLET}
-
-install: ${CARDLET}
- install -c -m ${LIBMODE} -o ${LIBOWN} -g ${LIBGRP} \
- ${CARDLET} ${DESTDIR}${DATADIR}
-
-Ssh.bin: ${.CURDIR}/Ssh.bin.uu
- uudecode ${.CURDIR}/$@.uu
-
-.include <bsd.prog.mk>
diff --git a/crypto/openssh/scp-common.c b/crypto/openssh/scp-common.c
deleted file mode 100644
index 7e5f09c..0000000
--- 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 e0ab6ec..0000000
--- 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/scp.c b/crypto/openssh/scp.c
index 4f9247c..35d4c5f 100644
--- a/crypto/openssh/scp.c
+++ b/crypto/openssh/scp.c
@@ -52,7 +52,11 @@
* 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. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -71,7 +75,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: scp.c,v 1.108 2003/07/18 01:54:25 deraadt Exp $");
+RCSID("$OpenBSD: scp.c,v 1.102 2003/03/05 22:33:43 markus Exp $");
#include "xmalloc.h"
#include "atomicio.h"
@@ -107,16 +111,7 @@ int showprogress = 1;
char *ssh_program = _PATH_SSH_PROGRAM;
/* This is used to store the pid of ssh_program */
-pid_t do_cmd_pid = -1;
-
-static void
-killchild(int signo)
-{
- if (do_cmd_pid > 1)
- kill(do_cmd_pid, signo);
-
- _exit(1);
-}
+pid_t do_cmd_pid;
/*
* This function executes the given command as the specified user on the
@@ -151,7 +146,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
close(reserved[0]);
close(reserved[1]);
- /* Fork a child to execute the command on the remote host using ssh. */
+ /* For a child to execute the command on the remote host using ssh. */
do_cmd_pid = fork();
if (do_cmd_pid == 0) {
/* Child. */
@@ -179,9 +174,6 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
*fdout = pin[1];
close(pout[1]);
*fdin = pout[0];
- signal(SIGTERM, killchild);
- signal(SIGINT, killchild);
- signal(SIGHUP, killchild);
return 0;
}
@@ -214,7 +206,9 @@ void toremote(char *, int, char *[]);
void usage(void);
int
-main(int argc, char **argv)
+main(argc, argv)
+ int argc;
+ char *argv[];
{
int ch, fflag, tflag, status;
double speed;
@@ -222,7 +216,7 @@ main(int argc, char **argv)
extern char *optarg;
extern int optind;
- __progname = ssh_get_progname(argv[0]);
+ __progname = get_progname(argv[0]);
args.list = NULL;
addargs(&args, "ssh"); /* overwritten with ssh_program */
@@ -298,7 +292,7 @@ main(int argc, char **argv)
argv += optind;
if ((pwd = getpwuid(userid = getuid())) == NULL)
- fatal("unknown user %u", (u_int) userid);
+ fatal("unknown user %d", (int) userid);
if (!isatty(STDERR_FILENO))
showprogress = 0;
@@ -359,7 +353,9 @@ main(int argc, char **argv)
}
void
-toremote(char *targ, int argc, char **argv)
+toremote(targ, argc, argv)
+ char *targ, *argv[];
+ int argc;
{
int i, len;
char *bp, *host, *src, *suser, *thost, *tuser;
@@ -447,7 +443,9 @@ toremote(char *targ, int argc, char **argv)
}
void
-tolocal(int argc, char **argv)
+tolocal(argc, argv)
+ int argc;
+ char *argv[];
{
int i, len;
char *bp, *host, *src, *suser;
@@ -496,7 +494,9 @@ tolocal(int argc, char **argv)
}
void
-source(int argc, char **argv)
+source(argc, argv)
+ int argc;
+ char *argv[];
{
struct stat stb;
static BUF buffer;
@@ -549,18 +549,25 @@ syserr: run_err("%s: %s", name, strerror(errno));
(void) snprintf(buf, sizeof buf, "T%lu 0 %lu 0\n",
(u_long) stb.st_mtime,
(u_long) stb.st_atime);
- (void) atomicio(vwrite, remout, buf, strlen(buf));
+ (void) atomicio(write, remout, buf, strlen(buf));
if (response() < 0)
goto next;
}
#define FILEMODEMASK (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
+#ifdef HAVE_LONG_LONG_INT
snprintf(buf, sizeof buf, "C%04o %lld %s\n",
(u_int) (stb.st_mode & FILEMODEMASK),
- (int64_t)stb.st_size, last);
+ (long long)stb.st_size, last);
+#else
+ /* XXX: Handle integer overflow? */
+ snprintf(buf, sizeof buf, "C%04o %lu %s\n",
+ (u_int) (stb.st_mode & FILEMODEMASK),
+ (u_long) stb.st_size, last);
+#endif
if (verbose_mode) {
fprintf(stderr, "Sending file modes: %s", buf);
}
- (void) atomicio(vwrite, remout, buf, strlen(buf));
+ (void) atomicio(write, remout, buf, strlen(buf));
if (response() < 0)
goto next;
if ((bp = allocbuf(&buffer, fd, 2048)) == NULL) {
@@ -580,9 +587,9 @@ next: (void) close(fd);
haderr = result >= 0 ? EIO : errno;
}
if (haderr)
- (void) atomicio(vwrite, remout, bp->buf, amt);
+ (void) atomicio(write, remout, bp->buf, amt);
else {
- result = atomicio(vwrite, remout, bp->buf, amt);
+ result = atomicio(write, remout, bp->buf, amt);
if (result != amt)
haderr = result >= 0 ? EIO : errno;
statbytes += result;
@@ -596,7 +603,7 @@ next: (void) close(fd);
if (close(fd) < 0 && !haderr)
haderr = errno;
if (!haderr)
- (void) atomicio(vwrite, remout, "", 1);
+ (void) atomicio(write, remout, "", 1);
else
run_err("%s: %s", name, strerror(haderr));
(void) response();
@@ -604,7 +611,9 @@ next: (void) close(fd);
}
void
-rsource(char *name, struct stat *statp)
+rsource(name, statp)
+ char *name;
+ struct stat *statp;
{
DIR *dirp;
struct dirent *dp;
@@ -623,7 +632,7 @@ rsource(char *name, struct stat *statp)
(void) snprintf(path, sizeof(path), "T%lu 0 %lu 0\n",
(u_long) statp->st_mtime,
(u_long) statp->st_atime);
- (void) atomicio(vwrite, remout, path, strlen(path));
+ (void) atomicio(write, remout, path, strlen(path));
if (response() < 0) {
closedir(dirp);
return;
@@ -633,7 +642,7 @@ rsource(char *name, struct stat *statp)
(u_int) (statp->st_mode & FILEMODEMASK), 0, last);
if (verbose_mode)
fprintf(stderr, "Entering directory: %s", path);
- (void) atomicio(vwrite, remout, path, strlen(path));
+ (void) atomicio(write, remout, path, strlen(path));
if (response() < 0) {
closedir(dirp);
return;
@@ -652,7 +661,7 @@ rsource(char *name, struct stat *statp)
source(1, vect);
}
(void) closedir(dirp);
- (void) atomicio(vwrite, remout, "E\n", 2);
+ (void) atomicio(write, remout, "E\n", 2);
(void) response();
}
@@ -711,7 +720,9 @@ bwlimit(int amount)
}
void
-sink(int argc, char **argv)
+sink(argc, argv)
+ int argc;
+ char *argv[];
{
static BUF buffer;
struct stat stb;
@@ -742,7 +753,7 @@ sink(int argc, char **argv)
if (targetshouldbedirectory)
verifydir(targ);
- (void) atomicio(vwrite, remout, "", 1);
+ (void) atomicio(write, remout, "", 1);
if (stat(targ, &stb) == 0 && S_ISDIR(stb.st_mode))
targisdir = 1;
for (first = 1;; first = 0) {
@@ -760,7 +771,7 @@ sink(int argc, char **argv)
if (buf[0] == '\01' || buf[0] == '\02') {
if (iamremote == 0)
- (void) atomicio(vwrite, STDERR_FILENO,
+ (void) atomicio(write, STDERR_FILENO,
buf + 1, strlen(buf + 1));
if (buf[0] == '\02')
exit(1);
@@ -768,7 +779,7 @@ sink(int argc, char **argv)
continue;
}
if (buf[0] == 'E') {
- (void) atomicio(vwrite, remout, "", 1);
+ (void) atomicio(write, remout, "", 1);
return;
}
if (ch == '\n')
@@ -790,7 +801,7 @@ sink(int argc, char **argv)
atime.tv_usec = strtol(cp, &cp, 10);
if (!cp || *cp++ != '\0')
SCREWUP("atime.usec not delimited");
- (void) atomicio(vwrite, remout, "", 1);
+ (void) atomicio(write, remout, "", 1);
continue;
}
if (*cp != 'C' && *cp != 'D') {
@@ -875,7 +886,7 @@ sink(int argc, char **argv)
bad: run_err("%s: %s", np, strerror(errno));
continue;
}
- (void) atomicio(vwrite, remout, "", 1);
+ (void) atomicio(write, remout, "", 1);
if ((bp = allocbuf(&buffer, ofd, 4096)) == NULL) {
(void) close(ofd);
continue;
@@ -912,7 +923,7 @@ bad: run_err("%s: %s", np, strerror(errno));
if (count == bp->cnt) {
/* Keep reading so we stay sync'd up. */
if (wrerr == NO) {
- j = atomicio(vwrite, ofd, bp->buf, count);
+ j = atomicio(write, ofd, bp->buf, count);
if (j != count) {
wrerr = YES;
wrerrno = j >= 0 ? EIO : errno;
@@ -925,7 +936,7 @@ bad: run_err("%s: %s", np, strerror(errno));
if (showprogress)
stop_progress_meter();
if (count != 0 && wrerr == NO &&
- (j = atomicio(vwrite, ofd, bp->buf, count)) != count) {
+ (j = atomicio(write, ofd, bp->buf, count)) != count) {
wrerr = YES;
wrerrno = j >= 0 ? EIO : errno;
}
@@ -970,7 +981,7 @@ bad: run_err("%s: %s", np, strerror(errno));
run_err("%s: %s", np, strerror(wrerrno));
break;
case NO:
- (void) atomicio(vwrite, remout, "", 1);
+ (void) atomicio(write, remout, "", 1);
break;
case DISPLAYED:
break;
@@ -1005,7 +1016,7 @@ response(void)
} while (cp < &rbuf[sizeof(rbuf) - 1] && ch != '\n');
if (!iamremote)
- (void) atomicio(vwrite, STDERR_FILENO, rbuf, cp - rbuf);
+ (void) atomicio(write, STDERR_FILENO, rbuf, cp - rbuf);
++errs;
if (resp == 1)
return (-1);
@@ -1050,7 +1061,8 @@ run_err(const char *fmt,...)
}
void
-verifydir(char *cp)
+verifydir(cp)
+ char *cp;
{
struct stat stb;
@@ -1064,7 +1076,8 @@ verifydir(char *cp)
}
int
-okname(char *cp0)
+okname(cp0)
+ char *cp0;
{
int c;
char *cp;
@@ -1094,7 +1107,9 @@ bad: fprintf(stderr, "%s: invalid user name\n", cp0);
}
BUF *
-allocbuf(BUF *bp, int fd, int blksize)
+allocbuf(bp, fd, blksize)
+ BUF *bp;
+ int fd, blksize;
{
size_t size;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
@@ -1122,7 +1137,8 @@ allocbuf(BUF *bp, int fd, int blksize)
}
void
-lostconn(int signo)
+lostconn(signo)
+ int signo;
{
if (!iamremote)
write(STDERR_FILENO, "lost connection\n", 16);
diff --git a/crypto/openssh/scp/Makefile b/crypto/openssh/scp/Makefile
deleted file mode 100644
index c8959bb..0000000
--- a/crypto/openssh/scp/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $OpenBSD: Makefile,v 1.13 2001/05/03 23:09:55 mouring Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= scp
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/bin
-MAN= scp.1
-
-SRCS= scp.c misc.c
-
-.include <bsd.prog.mk>
diff --git a/crypto/openssh/servconf.c b/crypto/openssh/servconf.c
index 58f49a2..fcb4809 100644
--- a/crypto/openssh/servconf.c
+++ b/crypto/openssh/servconf.c
@@ -10,7 +10,24 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.127 2003/09/01 18:15:50 markus Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.116 2003/02/21 09:05:53 markus Exp $");
+RCSID("$FreeBSD$");
+
+#if defined(KRB4)
+#include <krb.h>
+#endif
+#if defined(KRB5)
+#ifdef HEIMDAL
+#include <krb5.h>
+#else
+/* Bodge - but then, so is using the kerberos IV KEYFILE to get a Kerberos V
+ * keytab */
+#define KEYFILE "/etc/krb5.keytab"
+#endif
+#endif
+#ifdef AFS
+#include <kafs.h>
+#endif
#include "ssh.h"
#include "log.h"
@@ -40,7 +57,7 @@ initialize_server_options(ServerOptions *options)
memset(options, 0, sizeof(*options));
/* Portable-specific options */
- options->use_pam = -1;
+ options->pam_authentication_via_kbd_int = -1;
/* Standard Options */
options->num_ports = 0;
@@ -64,16 +81,23 @@ initialize_server_options(ServerOptions *options)
options->keepalives = -1;
options->log_facility = SYSLOG_FACILITY_NOT_SET;
options->log_level = SYSLOG_LEVEL_NOT_SET;
+ options->rhosts_authentication = -1;
options->rhosts_rsa_authentication = -1;
options->hostbased_authentication = -1;
options->hostbased_uses_name_from_packet_only = -1;
options->rsa_authentication = -1;
options->pubkey_authentication = -1;
+#if defined(KRB4) || defined(KRB5)
options->kerberos_authentication = -1;
options->kerberos_or_local_passwd = -1;
options->kerberos_ticket_cleanup = -1;
- options->gss_authentication=-1;
- options->gss_cleanup_creds = -1;
+#endif
+#if defined(AFS) || defined(KRB5)
+ options->kerberos_tgt_passing = -1;
+#endif
+#ifdef AFS
+ options->afs_token_passing = -1;
+#endif
options->password_authentication = -1;
options->kbd_interactive_authentication = -1;
options->challenge_response_authentication = -1;
@@ -95,7 +119,7 @@ initialize_server_options(ServerOptions *options)
options->max_startups_rate = -1;
options->max_startups = -1;
options->banner = NULL;
- options->use_dns = -1;
+ options->verify_reverse_mapping = -1;
options->client_alive_interval = -1;
options->client_alive_count_max = -1;
options->authorized_keys_file = NULL;
@@ -109,8 +133,8 @@ void
fill_default_server_options(ServerOptions *options)
{
/* Portable-specific options */
- if (options->use_pam == -1)
- options->use_pam = 0;
+ if (options->pam_authentication_via_kbd_int == -1)
+ options->pam_authentication_via_kbd_int = 0;
/* Standard Options */
if (options->protocol == SSH_PROTO_UNKNOWN)
@@ -122,8 +146,6 @@ fill_default_server_options(ServerOptions *options)
_PATH_HOST_KEY_FILE;
if (options->protocol & SSH_PROTO_2) {
options->host_key_files[options->num_host_key_files++] =
- _PATH_HOST_RSA_KEY_FILE;
- options->host_key_files[options->num_host_key_files++] =
_PATH_HOST_DSA_KEY_FILE;
}
}
@@ -140,7 +162,7 @@ fill_default_server_options(ServerOptions *options)
if (options->key_regeneration_time == -1)
options->key_regeneration_time = 3600;
if (options->permit_root_login == PERMIT_NOT_SET)
- options->permit_root_login = PERMIT_YES;
+ options->permit_root_login = PERMIT_NO;
if (options->ignore_rhosts == -1)
options->ignore_rhosts = 1;
if (options->ignore_user_known_hosts == -1)
@@ -150,7 +172,7 @@ fill_default_server_options(ServerOptions *options)
if (options->print_lastlog == -1)
options->print_lastlog = 1;
if (options->x11_forwarding == -1)
- options->x11_forwarding = 0;
+ options->x11_forwarding = 1;
if (options->x11_display_offset == -1)
options->x11_display_offset = 10;
if (options->x11_use_localhost == -1)
@@ -165,6 +187,8 @@ fill_default_server_options(ServerOptions *options)
options->log_facility = SYSLOG_FACILITY_AUTH;
if (options->log_level == SYSLOG_LEVEL_NOT_SET)
options->log_level = SYSLOG_LEVEL_INFO;
+ if (options->rhosts_authentication == -1)
+ options->rhosts_authentication = 0;
if (options->rhosts_rsa_authentication == -1)
options->rhosts_rsa_authentication = 0;
if (options->hostbased_authentication == -1)
@@ -175,16 +199,34 @@ fill_default_server_options(ServerOptions *options)
options->rsa_authentication = 1;
if (options->pubkey_authentication == -1)
options->pubkey_authentication = 1;
+#if defined(KRB4) && defined(KRB5)
+ if (options->kerberos_authentication == -1)
+ options->kerberos_authentication =
+ (access(KEYFILE, R_OK) == 0 ||
+ access(krb5_defkeyname, R_OK) == 0);
+#elif defined(KRB4)
+ if (options->kerberos_authentication == -1)
+ options->kerberos_authentication =
+ (access(KEYFILE, R_OK) == 0);
+#elif defined(KRB5)
if (options->kerberos_authentication == -1)
- options->kerberos_authentication = 0;
+ options->kerberos_authentication =
+ (access(krb5_defkeyname, R_OK) == 0);
+#endif
+#if defined(KRB4) || defined(KRB5)
if (options->kerberos_or_local_passwd == -1)
options->kerberos_or_local_passwd = 1;
if (options->kerberos_ticket_cleanup == -1)
options->kerberos_ticket_cleanup = 1;
- if (options->gss_authentication == -1)
- options->gss_authentication = 0;
- if (options->gss_cleanup_creds == -1)
- options->gss_cleanup_creds = 1;
+#endif
+#if defined(AFS) || defined(KRB5)
+ if (options->kerberos_tgt_passing == -1)
+ options->kerberos_tgt_passing = 0;
+#endif
+#ifdef AFS
+ if (options->afs_token_passing == -1)
+ options->afs_token_passing = 0;
+#endif
if (options->password_authentication == -1)
options->password_authentication = 1;
if (options->kbd_interactive_authentication == -1)
@@ -209,8 +251,8 @@ fill_default_server_options(ServerOptions *options)
options->max_startups_rate = 100; /* 100% */
if (options->max_startups_begin == -1)
options->max_startups_begin = options->max_startups;
- if (options->use_dns == -1)
- options->use_dns = 1;
+ if (options->verify_reverse_mapping == -1)
+ options->verify_reverse_mapping = 0;
if (options->client_alive_interval == -1)
options->client_alive_interval = 0;
if (options->client_alive_count_max == -1)
@@ -244,13 +286,21 @@ fill_default_server_options(ServerOptions *options)
typedef enum {
sBadOption, /* == unknown option */
/* Portable-specific options */
- sUsePAM,
+ sPAMAuthenticationViaKbdInt,
/* Standard Options */
sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
sPermitRootLogin, sLogFacility, sLogLevel,
- sRhostsRSAAuthentication, sRSAAuthentication,
+ sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication,
+#if defined(KRB4) || defined(KRB5)
sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
- sKerberosTgtPassing, sChallengeResponseAuthentication,
+#endif
+#if defined(AFS) || defined(KRB5)
+ sKerberosTgtPassing,
+#endif
+#ifdef AFS
+ sAFSTokenPassing,
+#endif
+ sChallengeResponseAuthentication,
sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
sPrintMotd, sPrintLastLog, sIgnoreRhosts,
sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
@@ -259,12 +309,12 @@ typedef enum {
sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
- sBanner, sUseDNS, sHostbasedAuthentication,
+ sBanner, sVerifyReverseMapping, sHostbasedAuthentication,
sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
- sGssAuthentication, sGssCleanupCreds,
sUsePrivilegeSeparation,
- sDeprecated, sUnsupported
+ sVersionAddendum,
+ sDeprecated
} ServerOpCodes;
/* Textual representation of the tokens. */
@@ -273,12 +323,9 @@ static struct {
ServerOpCodes opcode;
} keywords[] = {
/* Portable-specific options */
-#ifdef USE_PAM
- { "usepam", sUsePAM },
-#else
- { "usepam", sUnsupported },
+#if 0
+ { "PAMAuthenticationViaKbdInt", sPAMAuthenticationViaKbdInt },
#endif
- { "pamauthenticationviakbdint", sDeprecated },
/* Standard Options */
{ "port", sPort },
{ "hostkey", sHostKeyFile },
@@ -290,30 +337,23 @@ static struct {
{ "permitrootlogin", sPermitRootLogin },
{ "syslogfacility", sLogFacility },
{ "loglevel", sLogLevel },
- { "rhostsauthentication", sDeprecated },
+ { "rhostsauthentication", sRhostsAuthentication },
{ "rhostsrsaauthentication", sRhostsRSAAuthentication },
{ "hostbasedauthentication", sHostbasedAuthentication },
{ "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly },
{ "rsaauthentication", sRSAAuthentication },
{ "pubkeyauthentication", sPubkeyAuthentication },
{ "dsaauthentication", sPubkeyAuthentication }, /* alias */
-#ifdef KRB5
+#if defined(KRB4) || defined(KRB5)
{ "kerberosauthentication", sKerberosAuthentication },
{ "kerberosorlocalpasswd", sKerberosOrLocalPasswd },
{ "kerberosticketcleanup", sKerberosTicketCleanup },
-#else
- { "kerberosauthentication", sUnsupported },
- { "kerberosorlocalpasswd", sUnsupported },
- { "kerberosticketcleanup", sUnsupported },
#endif
- { "kerberostgtpassing", sUnsupported },
- { "afstokenpassing", sUnsupported },
-#ifdef GSSAPI
- { "gssapiauthentication", sGssAuthentication },
- { "gssapicleanupcreds", sGssCleanupCreds },
-#else
- { "gssapiauthentication", sUnsupported },
- { "gssapicleanupcreds", sUnsupported },
+#if defined(AFS) || defined(KRB5)
+ { "kerberostgtpassing", sKerberosTgtPassing },
+#endif
+#ifdef AFS
+ { "afstokenpassing", sAFSTokenPassing },
#endif
{ "passwordauthentication", sPasswordAuthentication },
{ "kbdinteractiveauthentication", sKbdInteractiveAuthentication },
@@ -347,14 +387,14 @@ static struct {
{ "subsystem", sSubsystem },
{ "maxstartups", sMaxStartups },
{ "banner", sBanner },
- { "usedns", sUseDNS },
- { "verifyreversemapping", sDeprecated },
- { "reversemappingcheck", sDeprecated },
+ { "verifyreversemapping", sVerifyReverseMapping },
+ { "reversemappingcheck", sVerifyReverseMapping },
{ "clientaliveinterval", sClientAliveInterval },
{ "clientalivecountmax", sClientAliveCountMax },
{ "authorizedkeysfile", sAuthorizedKeysFile },
{ "authorizedkeysfile2", sAuthorizedKeysFile2 },
{ "useprivilegeseparation", sUsePrivilegeSeparation},
+ { "versionaddendum", sVersionAddendum },
{ NULL, sBadOption }
};
@@ -433,8 +473,8 @@ process_server_config_line(ServerOptions *options, char *line,
opcode = parse_token(arg, filename, linenum);
switch (opcode) {
/* Portable-specific options */
- case sUsePAM:
- intptr = &options->use_pam;
+ case sPAMAuthenticationViaKbdInt:
+ intptr = &options->pam_authentication_via_kbd_int;
goto parse_flag;
/* Standard Options */
@@ -597,6 +637,10 @@ parse_flag:
intptr = &options->ignore_user_known_hosts;
goto parse_flag;
+ case sRhostsAuthentication:
+ intptr = &options->rhosts_authentication;
+ goto parse_flag;
+
case sRhostsRSAAuthentication:
intptr = &options->rhosts_rsa_authentication;
goto parse_flag;
@@ -616,7 +660,7 @@ parse_flag:
case sPubkeyAuthentication:
intptr = &options->pubkey_authentication;
goto parse_flag;
-
+#if defined(KRB4) || defined(KRB5)
case sKerberosAuthentication:
intptr = &options->kerberos_authentication;
goto parse_flag;
@@ -628,14 +672,17 @@ parse_flag:
case sKerberosTicketCleanup:
intptr = &options->kerberos_ticket_cleanup;
goto parse_flag;
-
- case sGssAuthentication:
- intptr = &options->gss_authentication;
+#endif
+#if defined(AFS) || defined(KRB5)
+ case sKerberosTgtPassing:
+ intptr = &options->kerberos_tgt_passing;
goto parse_flag;
-
- case sGssCleanupCreds:
- intptr = &options->gss_cleanup_creds;
+#endif
+#ifdef AFS
+ case sAFSTokenPassing:
+ intptr = &options->afs_token_passing;
goto parse_flag;
+#endif
case sPasswordAuthentication:
intptr = &options->password_authentication;
@@ -701,8 +748,8 @@ parse_flag:
intptr = &options->gateway_ports;
goto parse_flag;
- case sUseDNS:
- intptr = &options->use_dns;
+ case sVerifyReverseMapping:
+ intptr = &options->verify_reverse_mapping;
goto parse_flag;
case sLogFacility:
@@ -877,15 +924,15 @@ parse_flag:
intptr = &options->client_alive_count_max;
goto parse_int;
- case sDeprecated:
- logit("%s line %d: Deprecated option %s",
- filename, linenum, arg);
- while (arg)
- arg = strdelim(&cp);
+ case sVersionAddendum:
+ ssh_version_set_addendum(strtok(cp, "\n"));
+ do {
+ arg = strdelim(&cp);
+ } while (arg != NULL && *arg != '\0');
break;
- case sUnsupported:
- logit("%s line %d: Unsupported option %s",
+ case sDeprecated:
+ log("%s line %d: Deprecated option %s",
filename, linenum, arg);
while (arg)
arg = strdelim(&cp);
diff --git a/crypto/openssh/servconf.h b/crypto/openssh/servconf.h
index 828e94c..ea74f6e 100644
--- a/crypto/openssh/servconf.h
+++ b/crypto/openssh/servconf.h
@@ -1,4 +1,5 @@
-/* $OpenBSD: servconf.h,v 1.65 2003/09/01 18:15:50 markus Exp $ */
+/* $OpenBSD: servconf.h,v 1.59 2002/07/30 17:03:55 markus Exp $ */
+/* $FreeBSD$ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -65,12 +66,15 @@ typedef struct {
int gateway_ports; /* If true, allow remote connects to forwarded ports. */
SyslogFacility log_facility; /* Facility for system logging. */
LogLevel log_level; /* Level for system logging. */
+ int rhosts_authentication; /* If true, permit rhosts
+ * authentication. */
int rhosts_rsa_authentication; /* If true, permit rhosts RSA
* authentication. */
int hostbased_authentication; /* If true, permit ssh2 hostbased auth */
int hostbased_uses_name_from_packet_only; /* experimental */
int rsa_authentication; /* If true, permit RSA authentication. */
int pubkey_authentication; /* If true, permit ssh2 pubkey authentication. */
+#if defined(KRB4) || defined(KRB5)
int kerberos_authentication; /* If true, permit Kerberos
* authentication. */
int kerberos_or_local_passwd; /* If true, permit kerberos
@@ -80,8 +84,14 @@ typedef struct {
* /etc/passwd */
int kerberos_ticket_cleanup; /* If true, destroy ticket
* file on logout. */
- int gss_authentication; /* If true, permit GSSAPI authentication */
- int gss_cleanup_creds; /* If true, destroy cred cache on logout */
+#endif
+#if defined(AFS) || defined(KRB5)
+ int kerberos_tgt_passing; /* If true, permit Kerberos TGT
+ * passing. */
+#endif
+#ifdef AFS
+ int afs_token_passing; /* If true, permit AFS token passing. */
+#endif
int password_authentication; /* If true, permit password
* authentication. */
int kbd_interactive_authentication; /* If true, permit */
@@ -109,7 +119,7 @@ typedef struct {
int max_startups_rate;
int max_startups;
char *banner; /* SSH-2 banner message */
- int use_dns;
+ int verify_reverse_mapping; /* cross-check ip and dns */
int client_alive_interval; /*
* poke the client this often to
* see if it's still there
@@ -122,7 +132,7 @@ typedef struct {
char *authorized_keys_file; /* File containing public keys */
char *authorized_keys_file2;
- int use_pam; /* Enable auth via PAM */
+ int pam_authentication_via_kbd_int;
} ServerOptions;
void initialize_server_options(ServerOptions *);
diff --git a/crypto/openssh/serverloop.c b/crypto/openssh/serverloop.c
index a953902..f4df9cc 100644
--- a/crypto/openssh/serverloop.c
+++ b/crypto/openssh/serverloop.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.110 2003/06/24 08:23:46 markus Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.106 2003/04/01 10:22:21 markus Exp $");
#include "xmalloc.h"
#include "packet.h"
@@ -158,7 +158,7 @@ sigchld_handler(int sig)
static void
make_packets_from_stderr_data(void)
{
- u_int len;
+ int len;
/* Send buffered stderr data to the client. */
while (buffer_len(&stderr_buffer) > 0 &&
@@ -187,7 +187,7 @@ make_packets_from_stderr_data(void)
static void
make_packets_from_stdout_data(void)
{
- u_int len;
+ int len;
/* Send buffered stdout data to the client. */
while (buffer_len(&stdout_buffer) > 0 &&
@@ -771,14 +771,8 @@ server_loop2(Authctxt *authctxt)
&nalloc, 0);
collect_children();
- if (!rekeying) {
+ if (!rekeying)
channel_after_select(readset, writeset);
- if (packet_need_rekeying()) {
- debug("need rekeying");
- xxx_kex->done = 0;
- kex_send_kexinit(xxx_kex);
- }
- }
process_input(readset);
if (connection_closed)
break;
@@ -880,7 +874,7 @@ server_request_direct_tcpip(char *ctype)
return NULL;
c = channel_new(ctype, SSH_CHANNEL_CONNECTING,
sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT,
- CHAN_TCP_PACKET_DEFAULT, 0, "direct-tcpip", 1);
+ CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip"), 1);
return c;
}
@@ -899,7 +893,7 @@ server_request_session(char *ctype)
*/
c = channel_new(ctype, SSH_CHANNEL_LARVAL,
-1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT,
- 0, "server-session", 1);
+ 0, xstrdup("server-session"), 1);
if (session_open(xxx_authctxt, c->self) != 1) {
debug("session open failed, free channel %d", c->self);
channel_free(c);
@@ -977,7 +971,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
pw = auth_get_user();
if (pw == NULL)
fatal("server_input_global_request: no user");
- listen_address = packet_get_string(NULL);
+ listen_address = packet_get_string(NULL); /* XXX currently ignored */
listen_port = (u_short)packet_get_int();
debug("server_input_global_request: tcpip-forward listen %s port %d",
listen_address, listen_port);
diff --git a/crypto/openssh/session.c b/crypto/openssh/session.c
index 2898ac5..f2d73a4 100644
--- a/crypto/openssh/session.c
+++ b/crypto/openssh/session.c
@@ -33,7 +33,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.164 2003/09/18 08:49:45 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.154 2003/03/05 22:33:43 markus Exp $");
+RCSID("$FreeBSD$");
#include "ssh.h"
#include "ssh1.h"
@@ -58,8 +59,10 @@ RCSID("$OpenBSD: session.c,v 1.164 2003/09/18 08:49:45 markus Exp $");
#include "session.h"
#include "monitor_wrap.h"
-#ifdef GSSAPI
-#include "ssh-gss.h"
+#ifdef HAVE_CYGWIN
+#include <windows.h>
+#include <sys/cygwin.h>
+#define is_winnt (GetVersion() < 0x80000000)
#endif
/* func */
@@ -93,7 +96,6 @@ extern int debug_flag;
extern u_int utmp_len;
extern int startup_pipe;
extern void destroy_sensitive_data(void);
-extern Buffer loginmsg;
/* original command from peer. */
const char *original_command = NULL;
@@ -102,6 +104,10 @@ const char *original_command = NULL;
#define MAX_SESSIONS 10
Session sessions[MAX_SESSIONS];
+#ifdef WITH_AIXAUTHENTICATE
+char *aixloginmsg;
+#endif /* WITH_AIXAUTHENTICATE */
+
#ifdef HAVE_LOGIN_CAP
login_cap_t *lc;
#endif
@@ -187,7 +193,7 @@ auth_input_request_forwarding(struct passwd * pw)
nc = channel_new("auth socket",
SSH_CHANNEL_AUTH_SOCKET, sock, sock, -1,
CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT,
- 0, "auth socket", 1);
+ 0, xstrdup("auth socket"), 1);
strlcpy(nc->path, auth_sock_name, sizeof(nc->path));
return 1;
}
@@ -220,6 +226,10 @@ do_authenticated(Authctxt *authctxt)
/* remove agent socket */
if (auth_sock_name != NULL)
auth_sock_cleanup_proc(authctxt->pw);
+#ifdef KRB4
+ if (options.kerberos_ticket_cleanup)
+ krb4_cleanup_proc(authctxt);
+#endif
#ifdef KRB5
if (options.kerberos_ticket_cleanup)
krb5_cleanup_proc(authctxt);
@@ -332,6 +342,58 @@ do_authenticated1(Authctxt *authctxt)
success = 1;
break;
+#if defined(AFS) || defined(KRB5)
+ case SSH_CMSG_HAVE_KERBEROS_TGT:
+ if (!options.kerberos_tgt_passing) {
+ verbose("Kerberos TGT passing disabled.");
+ } else {
+ char *kdata = packet_get_string(&dlen);
+ packet_check_eom();
+
+ /* XXX - 0x41, see creds_to_radix version */
+ if (kdata[0] != 0x41) {
+#ifdef KRB5
+ krb5_data tgt;
+ tgt.data = kdata;
+ tgt.length = dlen;
+
+ if (auth_krb5_tgt(s->authctxt, &tgt))
+ success = 1;
+ else
+ verbose("Kerberos v5 TGT refused for %.100s", s->authctxt->user);
+#endif /* KRB5 */
+ } else {
+#ifdef AFS
+ if (auth_krb4_tgt(s->authctxt, kdata))
+ success = 1;
+ else
+ verbose("Kerberos v4 TGT refused for %.100s", s->authctxt->user);
+#endif /* AFS */
+ }
+ xfree(kdata);
+ }
+ break;
+#endif /* AFS || KRB5 */
+
+#ifdef AFS
+ case SSH_CMSG_HAVE_AFS_TOKEN:
+ if (!options.afs_token_passing || !k_hasafs()) {
+ verbose("AFS token passing disabled.");
+ } else {
+ /* Accept AFS token. */
+ char *token = packet_get_string(&dlen);
+ packet_check_eom();
+
+ if (auth_afs_token(s->authctxt, token))
+ success = 1;
+ else
+ verbose("AFS token refused for %.100s",
+ s->authctxt->user);
+ xfree(token);
+ }
+ break;
+#endif /* AFS */
+
case SSH_CMSG_EXEC_SHELL:
case SSH_CMSG_EXEC_CMD:
if (type == SSH_CMSG_EXEC_CMD) {
@@ -351,7 +413,7 @@ do_authenticated1(Authctxt *authctxt)
* Any unknown messages in this phase are ignored,
* and a failure message is returned.
*/
- logit("Unknown packet type received after authentication: %d", type);
+ log("Unknown packet type received after authentication: %d", type);
}
packet_start(success ? SSH_SMSG_SUCCESS : SSH_SMSG_FAILURE);
packet_send();
@@ -395,12 +457,11 @@ do_exec_no_pty(Session *s, const char *command)
session_proctitle(s);
#if defined(USE_PAM)
- if (options.use_pam) {
- do_pam_setcred(1);
- if (is_pam_password_change_required())
- packet_disconnect("Password change required but no "
- "TTY available");
- }
+ do_pam_session(s->pw->pw_name, NULL);
+ do_pam_setcred(1);
+ if (is_pam_password_change_required())
+ packet_disconnect("Password change required but no "
+ "TTY available");
#endif /* USE_PAM */
/* Fork the child. */
@@ -523,10 +584,8 @@ do_exec_pty(Session *s, const char *command)
ttyfd = s->ttyfd;
#if defined(USE_PAM)
- if (options.use_pam) {
- do_pam_set_tty(s->tty);
- do_pam_setcred(1);
- }
+ do_pam_session(s->pw->pw_name, s->tty);
+ do_pam_setcred(1);
#endif
/* Fork the child. */
@@ -632,7 +691,7 @@ do_pre_login(Session *s)
}
record_utmp_only(pid, s->tty, s->pw->pw_name,
- get_remote_name_or_ip(utmp_len, options.use_dns),
+ get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping),
(struct sockaddr *)&from, fromlen);
}
#endif
@@ -650,14 +709,6 @@ do_exec(Session *s, const char *command)
debug("Forced command '%.900s'", command);
}
-#ifdef GSSAPI
- if (options.gss_authentication) {
- temporarily_use_uid(s->pw);
- ssh_gssapi_storecreds();
- restore_uid();
- }
-#endif
-
if (s->ttyfd != -1)
do_exec_pty(s, command);
else
@@ -695,7 +746,7 @@ do_login(Session *s, const char *command)
if (!use_privsep)
record_login(pid, s->tty, pw->pw_name, pw->pw_uid,
get_remote_name_or_ip(utmp_len,
- options.use_dns),
+ options.verify_reverse_mapping),
(struct sockaddr *)&from, fromlen);
#ifdef USE_PAM
@@ -703,10 +754,9 @@ do_login(Session *s, const char *command)
* If password change is needed, do it now.
* This needs to occur before the ~/.hushlogin check.
*/
- if (options.use_pam && is_pam_password_change_required()) {
+ if (is_pam_password_change_required()) {
print_pam_messages();
do_pam_chauthtok();
- /* XXX - signal [net] parent to enable forwardings */
}
#endif
@@ -714,16 +764,13 @@ do_login(Session *s, const char *command)
return;
#ifdef USE_PAM
- if (options.use_pam && !is_pam_password_change_required())
+ if (!is_pam_password_change_required())
print_pam_messages();
#endif /* USE_PAM */
-
- /* display post-login message */
- if (buffer_len(&loginmsg) > 0) {
- buffer_append(&loginmsg, "\0", 1);
- printf("%s\n", (char *)buffer_ptr(&loginmsg));
- }
- buffer_free(&loginmsg);
+#ifdef WITH_AIXAUTHENTICATE
+ if (aixloginmsg && *aixloginmsg)
+ printf("%s\n", aixloginmsg);
+#endif /* WITH_AIXAUTHENTICATE */
#ifndef NO_SSH_LASTLOG
if (options.print_lastlog && s->last_login_time != 0) {
@@ -749,6 +796,24 @@ do_motd(void)
{
FILE *f;
char buf[256];
+#ifdef HAVE_LOGIN_CAP
+ const char *fname;
+#endif
+
+#ifdef HAVE_LOGIN_CAP
+ fname = login_getcapstr(lc, "copyright", NULL, NULL);
+ if (fname != NULL && (f = fopen(fname, "r")) != NULL) {
+ while (fgets(buf, sizeof(buf), f) != NULL)
+ fputs(buf, stdout);
+ fclose(f);
+ } else
+#endif /* HAVE_LOGIN_CAP */
+ (void)printf("%s\n\t%s %s\n",
+ "Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994",
+ "The Regents of the University of California. ",
+ "All rights reserved.");
+
+ (void)printf("\n");
if (options.print_motd) {
#ifdef HAVE_LOGIN_CAP
@@ -794,7 +859,7 @@ check_quietlogin(Session *s, const char *command)
* Sets the value of the given variable in the environment. If the variable
* already exists, its value is overriden.
*/
-void
+static void
child_set_env(char ***envp, u_int *envsizep, const char *name,
const char *value)
{
@@ -803,16 +868,6 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
u_int i, namelen;
/*
- * If we're passed an uninitialized list, allocate a single null
- * entry before continuing.
- */
- if (*envp == NULL && *envsizep == 0) {
- *envp = xmalloc(sizeof(char *));
- *envp[0] = NULL;
- *envsizep = 1;
- }
-
- /*
* Find the slot where the value should be stored. If the variable
* already exists, we reuse the slot; otherwise we append a new slot
* at the end of the array, expanding if necessary.
@@ -889,61 +944,6 @@ read_environment_file(char ***env, u_int *envsize,
fclose(f);
}
-#ifdef HAVE_ETC_DEFAULT_LOGIN
-/*
- * Return named variable from specified environment, or NULL if not present.
- */
-static char *
-child_get_env(char **env, const char *name)
-{
- int i;
- size_t len;
-
- len = strlen(name);
- for (i=0; env[i] != NULL; i++)
- if (strncmp(name, env[i], len) == 0 && env[i][len] == '=')
- return(env[i] + len + 1);
- return NULL;
-}
-
-/*
- * Read /etc/default/login.
- * We pick up the PATH (or SUPATH for root) and UMASK.
- */
-static void
-read_etc_default_login(char ***env, u_int *envsize, uid_t uid)
-{
- char **tmpenv = NULL, *var;
- u_int i, tmpenvsize = 0;
- mode_t mask;
-
- /*
- * We don't want to copy the whole file to the child's environment,
- * so we use a temporary environment and copy the variables we're
- * interested in.
- */
- read_environment_file(&tmpenv, &tmpenvsize, "/etc/default/login");
-
- if (tmpenv == NULL)
- return;
-
- if (uid == 0)
- var = child_get_env(tmpenv, "SUPATH");
- else
- var = child_get_env(tmpenv, "PATH");
- if (var != NULL)
- child_set_env(env, envsize, "PATH", var);
-
- if ((var = child_get_env(tmpenv, "UMASK")) != NULL)
- if (sscanf(var, "%5lo", &mask) == 1)
- umask(mask);
-
- for (i = 0; tmpenv[i] != NULL; i++)
- xfree(tmpenv[i]);
- xfree(tmpenv);
-}
-#endif /* HAVE_ETC_DEFAULT_LOGIN */
-
void copy_environment(char **source, char ***env, u_int *envsize)
{
char *var_name, *var_val;
@@ -972,7 +972,11 @@ do_setup_env(Session *s, const char *shell)
{
char buf[256];
u_int i, envsize;
- char **env, *laddr, *path = NULL;
+ char **env, *laddr;
+#ifdef HAVE_LOGIN_CAP
+ extern char **environ;
+ char **senv, **var;
+#endif
struct passwd *pw = s->pw;
/* Initialize the environment. */
@@ -988,13 +992,8 @@ do_setup_env(Session *s, const char *shell)
copy_environment(environ, &env, &envsize);
#endif
-#ifdef GSSAPI
- /* Allow any GSSAPI methods that we've used to alter
- * the childs environment as they see fit
- */
- ssh_gssapi_do_child(&env, &envsize);
-#endif
-
+ if (getenv("TZ"))
+ child_set_env(&env, &envsize, "TZ", getenv("TZ"));
if (!options.use_login) {
/* Set basic environment. */
child_set_env(&env, &envsize, "USER", pw->pw_name);
@@ -1003,11 +1002,22 @@ do_setup_env(Session *s, const char *shell)
child_set_env(&env, &envsize, "LOGIN", pw->pw_name);
#endif
child_set_env(&env, &envsize, "HOME", pw->pw_dir);
+ snprintf(buf, sizeof buf, "%.200s/%.50s",
+ _PATH_MAILDIR, pw->pw_name);
+ child_set_env(&env, &envsize, "MAIL", buf);
#ifdef HAVE_LOGIN_CAP
- if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH) < 0)
- child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
- else
- child_set_env(&env, &envsize, "PATH", getenv("PATH"));
+ child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
+ child_set_env(&env, &envsize, "TERM", "su");
+ senv = environ;
+ environ = xmalloc(sizeof(char *));
+ *environ = NULL;
+ (void) setusercontext(lc, pw, pw->pw_uid,
+ LOGIN_SETENV|LOGIN_SETPATH);
+ copy_environment(environ, &env, &envsize);
+ for (var = environ; *var != NULL; ++var)
+ xfree(*var);
+ xfree(environ);
+ environ = senv;
#else /* HAVE_LOGIN_CAP */
# ifndef HAVE_CYGWIN
/*
@@ -1016,27 +1026,18 @@ do_setup_env(Session *s, const char *shell)
* needed for loading shared libraries. So the path better
* remains intact here.
*/
-# ifdef HAVE_ETC_DEFAULT_LOGIN
- read_etc_default_login(&env, &envsize, pw->pw_uid);
- path = child_get_env(env, "PATH");
-# endif /* HAVE_ETC_DEFAULT_LOGIN */
- if (path == NULL || *path == '\0') {
- child_set_env(&env, &envsize, "PATH",
- s->pw->pw_uid == 0 ?
- SUPERUSER_PATH : _PATH_STDPATH);
- }
+# ifdef SUPERUSER_PATH
+ child_set_env(&env, &envsize, "PATH",
+ s->pw->pw_uid == 0 ? SUPERUSER_PATH : _PATH_STDPATH);
+# else
+ child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
+# endif /* SUPERUSER_PATH */
# endif /* HAVE_CYGWIN */
#endif /* HAVE_LOGIN_CAP */
- snprintf(buf, sizeof buf, "%.200s/%.50s",
- _PATH_MAILDIR, pw->pw_name);
- child_set_env(&env, &envsize, "MAIL", buf);
-
/* Normal systems set SHELL by default. */
child_set_env(&env, &envsize, "SHELL", shell);
}
- if (getenv("TZ"))
- child_set_env(&env, &envsize, "TZ", getenv("TZ"));
/* Set custom environment options from RSA authentication. */
if (!options.use_login) {
@@ -1093,6 +1094,11 @@ do_setup_env(Session *s, const char *shell)
read_environment_file(&env, &envsize, "/etc/environment");
}
#endif
+#ifdef KRB4
+ if (s->authctxt->krb4_ticket_file)
+ child_set_env(&env, &envsize, "KRBTKFILE",
+ s->authctxt->krb4_ticket_file);
+#endif
#ifdef KRB5
if (s->authctxt->krb5_ticket_file)
child_set_env(&env, &envsize, "KRB5CCNAME",
@@ -1103,9 +1109,10 @@ do_setup_env(Session *s, const char *shell)
* Pull in any environment variables that may have
* been set by PAM.
*/
- if (options.use_pam) {
- char **p = fetch_pam_environment();
+ {
+ char **p;
+ p = fetch_pam_environment();
copy_environment(p, &env, &envsize);
free_pam_environment(p);
}
@@ -1217,7 +1224,7 @@ do_nologin(struct passwd *pw)
#endif
if (f) {
/* /etc/nologin exists. Print its contents and exit. */
- logit("User %.100s not allowed because %s exists",
+ log("User %.100s not allowed because %s exists",
pw->pw_name, _PATH_NOLOGIN);
while (fgets(buf, sizeof(buf), f))
fputs(buf, stderr);
@@ -1237,15 +1244,14 @@ do_setusercontext(struct passwd *pw)
{
#ifdef HAVE_SETPCRED
- if (setpcred(pw->pw_name, (char **)NULL) == -1)
- fatal("Failed to set process credentials");
+ setpcred(pw->pw_name);
#endif /* HAVE_SETPCRED */
#ifdef HAVE_LOGIN_CAP
# ifdef __bsdi__
setpgid(0, 0);
# endif
if (setusercontext(lc, pw, pw->pw_uid,
- (LOGIN_SETALL & ~LOGIN_SETPATH)) < 0) {
+ (LOGIN_SETALL & ~(LOGIN_SETENV|LOGIN_SETPATH))) < 0) {
perror("unable to set user context");
exit(1);
}
@@ -1274,10 +1280,7 @@ do_setusercontext(struct passwd *pw)
* These will have been wiped by the above initgroups() call.
* Reestablish them here.
*/
- if (options.use_pam) {
- do_pam_session();
- do_pam_setcred(0);
- }
+ do_pam_setcred(0);
# endif /* USE_PAM */
# if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY)
irix_setusercontext(pw);
@@ -1332,6 +1335,9 @@ do_child(Session *s, const char *command)
const char *shell, *shell0, *hostname = NULL;
struct passwd *pw = s->pw;
u_int i;
+#ifdef HAVE_LOGIN_CAP
+ int lc_requirehome;
+#endif
/* remove hostkey from the child's memory */
destroy_sensitive_data();
@@ -1378,7 +1384,7 @@ do_child(Session *s, const char *command)
/* we have to stash the hostname before we close our socket. */
if (options.use_login)
hostname = get_remote_name_or_ip(utmp_len,
- options.use_dns);
+ options.verify_reverse_mapping);
/*
* Close the connection descriptors; note that this is the child, and
* the server will still have the socket open, and it is important
@@ -1399,6 +1405,10 @@ do_child(Session *s, const char *command)
/* XXX better use close-on-exec? -markus */
channel_close_all();
+#ifdef HAVE_LOGIN_CAP
+ lc_requirehome = login_getcapbool(lc, "requirehome", 0);
+ login_close(lc);
+#endif
/*
* Close any extra file descriptors. Note that there may still be
* descriptors left by system functions. They will be closed later.
@@ -1420,12 +1430,24 @@ do_child(Session *s, const char *command)
*/
environ = env;
+#ifdef AFS
+ /* Try to get AFS tokens for the local cell. */
+ if (k_hasafs()) {
+ char cell[64];
+
+ if (k_afs_cell_of_file(pw->pw_dir, cell, sizeof(cell)) == 0)
+ krb_afslog(cell, 0);
+
+ krb_afslog(0, 0);
+ }
+#endif /* AFS */
+
/* Change current directory to the user\'s home directory. */
if (chdir(pw->pw_dir) < 0) {
fprintf(stderr, "Could not chdir to home directory %s: %s\n",
pw->pw_dir, strerror(errno));
#ifdef HAVE_LOGIN_CAP
- if (login_getcapbool(lc, "requirehome", 0))
+ if (lc_requirehome)
exit(1);
#endif
}
@@ -1689,7 +1711,7 @@ session_subsystem_req(Session *s)
int i;
packet_check_eom();
- logit("subsystem request for %.100s", subsys);
+ log("subsystem request for %.100s", subsys);
for (i = 0; i < options.num_subsystems; i++) {
if (strcmp(subsys, options.subsystem_name[i]) == 0) {
@@ -1708,7 +1730,7 @@ session_subsystem_req(Session *s)
}
if (!success)
- logit("subsystem request for %.100s failed, subsystem not found",
+ log("subsystem request for %.100s failed, subsystem not found",
subsys);
xfree(subsys);
@@ -1756,20 +1778,6 @@ session_exec_req(Session *s)
}
static int
-session_break_req(Session *s)
-{
- u_int break_length;
-
- break_length = packet_get_int(); /* ignored */
- packet_check_eom();
-
- if (s->ttyfd == -1 ||
- tcsendbreak(s->ttyfd, 0) < 0)
- return 0;
- return 1;
-}
-
-static int
session_auth_agent_req(Session *s)
{
static int called = 0;
@@ -1793,7 +1801,7 @@ session_input_channel_req(Channel *c, const char *rtype)
Session *s;
if ((s = session_by_channel(c->self)) == NULL) {
- logit("session_input_channel_req: no session %d req %.100s",
+ log("session_input_channel_req: no session %d req %.100s",
c->self, rtype);
return 0;
}
@@ -1816,8 +1824,6 @@ session_input_channel_req(Channel *c, const char *rtype)
success = session_auth_agent_req(s);
} else if (strcmp(rtype, "subsystem") == 0) {
success = session_subsystem_req(s);
- } else if (strcmp(rtype, "break") == 0) {
- success = session_break_req(s);
}
}
if (strcmp(rtype, "window-change") == 0) {
@@ -2154,8 +2160,4 @@ static void
do_authenticated2(Authctxt *authctxt)
{
server_loop2(authctxt);
-#if defined(GSSAPI)
- if (options.gss_cleanup_creds)
- ssh_gssapi_cleanup_creds(NULL);
-#endif
}
diff --git a/crypto/openssh/session.h b/crypto/openssh/session.h
index 525e47f..d3ddfab 100644
--- a/crypto/openssh/session.h
+++ b/crypto/openssh/session.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.h,v 1.20 2003/08/22 10:56:09 markus Exp $ */
+/* $OpenBSD: session.h,v 1.19 2002/06/30 21:59:45 deraadt Exp $ */
/*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -68,7 +68,4 @@ Session *session_new(void);
Session *session_by_tty(char *);
void session_close(Session *);
void do_setusercontext(struct passwd *);
-void child_set_env(char ***envp, u_int *envsizep, const char *name,
- const char *value);
-
#endif
diff --git a/crypto/openssh/sftp-server/Makefile b/crypto/openssh/sftp-server/Makefile
deleted file mode 100644
index e068239..0000000
--- a/crypto/openssh/sftp-server/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $OpenBSD: Makefile,v 1.5 2001/03/03 23:59:36 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= sftp-server
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/libexec
-MAN= sftp-server.8
-
-SRCS= sftp-server.c sftp-common.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto
-DPADD+= ${LIBCRYPTO}
diff --git a/crypto/openssh/sftp/Makefile b/crypto/openssh/sftp/Makefile
deleted file mode 100644
index 3f5d866..0000000
--- a/crypto/openssh/sftp/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# $OpenBSD: Makefile,v 1.5 2001/05/03 23:09:57 mouring Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= sftp
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/bin
-MAN= sftp.1
-
-SRCS= sftp.c sftp-client.c sftp-int.c sftp-common.c sftp-glob.c misc.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto
-DPADD+= ${LIBCRYPTO}
-
diff --git a/crypto/openssh/ssh-add.c b/crypto/openssh/ssh-add.c
index 2e394e5..9adec30 100644
--- a/crypto/openssh/ssh-add.c
+++ b/crypto/openssh/ssh-add.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-add.c,v 1.68 2003/06/16 10:22:45 markus Exp $");
+RCSID("$OpenBSD: ssh-add.c,v 1.66 2003/03/05 22:33:43 markus Exp $");
#include <openssl/evp.h>
@@ -164,8 +164,7 @@ add_file(AuthenticationConnection *ac, const char *filename)
if (private != NULL)
break;
clear_pass();
- snprintf(msg, sizeof msg,
- "Bad passphrase, try again for %.200s: ", comment);
+ strlcpy(msg, "Bad passphrase, try again: ", sizeof msg);
}
}
@@ -202,7 +201,7 @@ update_card(AuthenticationConnection *ac, int add, const char *id)
if (pin == NULL)
return -1;
- if (ssh_update_card(ac, add, id, pin, lifetime, confirm)) {
+ if (ssh_update_card(ac, add, id, pin)) {
fprintf(stderr, "Card %s: %s\n",
add ? "added" : "removed", id);
ret = 0;
@@ -319,7 +318,7 @@ main(int argc, char **argv)
char *sc_reader_id = NULL;
int i, ch, deleting = 0, ret = 0;
- __progname = ssh_get_progname(argv[0]);
+ __progname = get_progname(argv[0]);
init_rng();
seed_rng();
diff --git a/crypto/openssh/ssh-add/Makefile b/crypto/openssh/ssh-add/Makefile
deleted file mode 100644
index 2f7bf42..0000000
--- a/crypto/openssh/ssh-add/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $OpenBSD: Makefile,v 1.20 2001/03/04 00:51:25 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= ssh-add
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/bin
-MAN= ssh-add.1
-
-SRCS= ssh-add.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto
-DPADD+= ${LIBCRYPTO}
diff --git a/crypto/openssh/ssh-agent.c b/crypto/openssh/ssh-agent.c
index e1e6cae..097fad9 100644
--- a/crypto/openssh/ssh-agent.c
+++ b/crypto/openssh/ssh-agent.c
@@ -35,7 +35,8 @@
#include "includes.h"
#include "openbsd-compat/sys-queue.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.112 2003/09/18 08:49:45 markus Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.108 2003/03/13 11:44:50 markus Exp $");
+RCSID("$FreeBSD$");
#include <openssl/evp.h>
#include <openssl/md5.h>
@@ -261,7 +262,7 @@ process_authentication_challenge1(SocketEntry *e)
/* The response is MD5 of decrypted challenge plus session id. */
len = BN_num_bytes(challenge);
if (len <= 0 || len > 32) {
- logit("process_authentication_challenge: bad challenge length %d", len);
+ log("process_authentication_challenge: bad challenge length %d", len);
goto failure;
}
memset(buf, 0, 32);
@@ -350,7 +351,7 @@ process_remove_identity(SocketEntry *e, int version)
buffer_get_bignum(&e->request, key->rsa->n);
if (bits != key_size(key))
- logit("Warning: identity keysize mismatch: actual %u, announced %u",
+ log("Warning: identity keysize mismatch: actual %u, announced %u",
key_size(key), bits);
break;
case 2:
@@ -580,29 +581,13 @@ static void
process_add_smartcard_key (SocketEntry *e)
{
char *sc_reader_id = NULL, *pin;
- int i, version, success = 0, death = 0, confirm = 0;
+ int i, version, success = 0;
Key **keys, *k;
Identity *id;
Idtab *tab;
sc_reader_id = buffer_get_string(&e->request, NULL);
pin = buffer_get_string(&e->request, NULL);
-
- while (buffer_len(&e->request)) {
- switch (buffer_get_char(&e->request)) {
- case SSH_AGENT_CONSTRAIN_LIFETIME:
- death = time(NULL) + buffer_get_int(&e->request);
- break;
- case SSH_AGENT_CONSTRAIN_CONFIRM:
- confirm = 1;
- break;
- default:
- break;
- }
- }
- if (lifetime && !death)
- death = time(NULL) + lifetime;
-
keys = sc_get_keys(sc_reader_id, pin);
xfree(sc_reader_id);
xfree(pin);
@@ -618,9 +603,9 @@ process_add_smartcard_key (SocketEntry *e)
if (lookup_identity(k, version) == NULL) {
id = xmalloc(sizeof(Identity));
id->key = k;
- id->comment = sc_get_key_label(k);
- id->death = death;
- id->confirm = confirm;
+ id->comment = xstrdup("smartcard key");
+ id->death = 0;
+ id->confirm = 0;
TAILQ_INSERT_TAIL(&tab->idlist, id, next);
tab->nentries++;
success = 1;
@@ -764,7 +749,6 @@ process_message(SocketEntry *e)
break;
#ifdef SMARTCARD
case SSH_AGENTC_ADD_SMARTCARD_KEY:
- case SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED:
process_add_smartcard_key(e);
break;
case SSH_AGENTC_REMOVE_SMARTCARD_KEY:
@@ -980,7 +964,7 @@ check_parent_exists(int sig)
/* printf("Parent has died - Authentication agent exiting.\n"); */
cleanup_handler(sig); /* safe */
}
- mysignal(SIGALRM, check_parent_exists);
+ signal(SIGALRM, check_parent_exists);
alarm(10);
errno = save_errno;
}
@@ -1022,10 +1006,11 @@ main(int ac, char **av)
/* drop */
setegid(getgid());
setgid(getgid());
+ setuid(geteuid());
SSLeay_add_all_algorithms();
- __progname = ssh_get_progname(av[0]);
+ __progname = get_progname(av[0]);
init_rng();
seed_rng();
@@ -1212,7 +1197,7 @@ skip:
fatal_add_cleanup(cleanup_socket, NULL);
new_socket(AUTH_SOCKET, sock);
if (ac > 0) {
- mysignal(SIGALRM, check_parent_exists);
+ signal(SIGALRM, check_parent_exists);
alarm(10);
}
idtab_init();
diff --git a/crypto/openssh/ssh-agent/Makefile b/crypto/openssh/ssh-agent/Makefile
deleted file mode 100644
index c252dbd..0000000
--- a/crypto/openssh/ssh-agent/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $OpenBSD: Makefile,v 1.21 2001/06/27 19:29:16 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= ssh-agent
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/bin
-MAN= ssh-agent.1
-
-SRCS= ssh-agent.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto
-DPADD+= ${LIBCRYPTO}
diff --git a/crypto/openssh/ssh-dss.h b/crypto/openssh/ssh-dss.h
index 94961b1..e69de29 100644
--- a/crypto/openssh/ssh-dss.h
+++ b/crypto/openssh/ssh-dss.h
@@ -1,32 +0,0 @@
-/* $OpenBSD: ssh-dss.h,v 1.6 2002/02/24 19:14:59 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.
- */
-#ifndef DSA_H
-#define DSA_H
-
-int ssh_dss_sign(Key *, u_char **, u_int *, u_char *, u_int);
-int ssh_dss_verify(Key *, u_char *, u_int, u_char *, u_int);
-
-#endif
diff --git a/crypto/openssh/ssh-keygen/Makefile b/crypto/openssh/ssh-keygen/Makefile
deleted file mode 100644
index d175813..0000000
--- a/crypto/openssh/ssh-keygen/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $OpenBSD: Makefile,v 1.21 2001/06/27 19:29:16 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= ssh-keygen
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/bin
-MAN= ssh-keygen.1
-
-SRCS= ssh-keygen.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto
-DPADD+= ${LIBCRYPTO}
diff --git a/crypto/openssh/ssh-keyscan.c b/crypto/openssh/ssh-keyscan.c
index 9fa8aae..5b4eb82 100644
--- a/crypto/openssh/ssh-keyscan.c
+++ b/crypto/openssh/ssh-keyscan.c
@@ -7,7 +7,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.44 2003/06/28 16:23:06 deraadt Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.41 2003/02/16 17:09:57 markus Exp $");
#include "openbsd-compat/sys-queue.h"
@@ -31,7 +31,11 @@ RCSID("$OpenBSD: ssh-keyscan.c,v 1.44 2003/06/28 16:23:06 deraadt Exp $");
/* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
Default value is AF_UNSPEC means both IPv4 and IPv6. */
+#ifdef IPV4_DEFAULT
+int IPv4or6 = AF_INET;
+#else
int IPv4or6 = AF_UNSPEC;
+#endif
int ssh_port = SSH_DEFAULT_PORT;
@@ -393,7 +397,7 @@ tcpconnect(char *host)
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr));
for (ai = aitop; ai; ai = ai->ai_next) {
- s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ s = socket(ai->ai_family, SOCK_STREAM, 0);
if (s < 0) {
error("socket: %s", strerror(errno));
continue;
@@ -541,7 +545,7 @@ congreet(int s)
n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n",
c->c_keytype == KT_RSA1? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2,
c->c_keytype == KT_RSA1? PROTOCOL_MINOR_1 : PROTOCOL_MINOR_2);
- if (atomicio(vwrite, s, buf, n) != n) {
+ if (atomicio(write, s, buf, n) != n) {
error("write (%s): %s", c->c_name, strerror(errno));
confree(s);
return;
@@ -681,7 +685,7 @@ fatal(const char *fmt,...)
static void
usage(void)
{
- fprintf(stderr, "usage: %s [-v46] [-p port] [-T timeout] [-t type] [-f file]\n"
+ fprintf(stderr, "usage: %s [-v46] [-p port] [-T timeout] [-f file]\n"
"\t\t [host | addrlist namelist] [...]\n",
__progname);
exit(1);
@@ -697,7 +701,7 @@ main(int argc, char **argv)
extern int optind;
extern char *optarg;
- __progname = ssh_get_progname(argv[0]);
+ __progname = get_progname(argv[0]);
init_rng();
seed_rng();
TAILQ_INIT(&tq);
diff --git a/crypto/openssh/ssh-keyscan/Makefile b/crypto/openssh/ssh-keyscan/Makefile
deleted file mode 100644
index 2ea5c23..0000000
--- a/crypto/openssh/ssh-keyscan/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $OpenBSD: Makefile,v 1.4 2001/08/05 23:18:20 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= ssh-keyscan
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/bin
-MAN= ssh-keyscan.1
-
-SRCS= ssh-keyscan.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto -lz
-DPADD+= ${LIBCRYPTO} ${LIBZ}
diff --git a/crypto/openssh/ssh-keysign/Makefile b/crypto/openssh/ssh-keysign/Makefile
deleted file mode 100644
index 1a13d9e..0000000
--- a/crypto/openssh/ssh-keysign/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 2002/05/31 10:30:33 markus Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= ssh-keysign
-BINOWN= root
-
-BINMODE?=4555
-
-BINDIR= /usr/libexec
-MAN= ssh-keysign.8
-
-SRCS= ssh-keysign.c
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto -lz
-DPADD+= ${LIBCRYPTO} ${LIBZ}
diff --git a/crypto/openssh/ssh-rsa.h b/crypto/openssh/ssh-rsa.h
index 7177a3f..e69de29 100644
--- a/crypto/openssh/ssh-rsa.h
+++ b/crypto/openssh/ssh-rsa.h
@@ -1,32 +0,0 @@
-/* $OpenBSD: ssh-rsa.h,v 1.6 2002/02/24 19:14:59 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.
- */
-#ifndef SSH_RSA_H
-#define SSH_RSA_H
-
-int ssh_rsa_sign(Key *, u_char **, u_int *, u_char *, u_int);
-int ssh_rsa_verify(Key *, u_char *, u_int, u_char *, u_int);
-
-#endif
diff --git a/crypto/openssh/ssh.1 b/crypto/openssh/ssh.1
index c81cb42..0699ada 100644
--- a/crypto/openssh/ssh.1
+++ b/crypto/openssh/ssh.1
@@ -34,7 +34,8 @@
.\" (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: ssh.1,v 1.175 2003/07/22 13:35:22 markus Exp $
+.\" $OpenBSD: ssh.1,v 1.168 2003/03/28 10:11:43 jmc Exp $
+.\" $FreeBSD$
.Dd September 25, 1999
.Dt SSH 1
.Os
@@ -49,7 +50,7 @@
.Pp
.Nm ssh
.Bk -words
-.Op Fl afgknqstvxACNTVX1246
+.Op Fl afgknqstvxACNTX1246
.Op Fl b Ar bind_address
.Op Fl c Ar cipher_spec
.Op Fl e Ar escape_char
@@ -103,7 +104,7 @@ depending on the protocol version used:
First, if the machine the user logs in from is listed in
.Pa /etc/hosts.equiv
or
-.Pa /etc/shosts.equiv
+.Pa /etc/ssh/shosts.equiv
on the remote machine, and the user names are
the same on both sides, the user is immediately permitted to log in.
Second, if
@@ -127,7 +128,7 @@ It means that if the login would be permitted by
.Pa $HOME/.shosts ,
.Pa /etc/hosts.equiv ,
or
-.Pa /etc/shosts.equiv ,
+.Pa /etc/ssh/shosts.equiv ,
and if additionally the server can verify the client's
host key (see
.Pa /etc/ssh/ssh_known_hosts
@@ -301,9 +302,6 @@ Background ssh at logout when waiting for forwarded connection / X11 sessions
to terminate
.It Cm ~?
Display a list of escape characters
-.It Cm ~B
-Send a BREAK to the remote system (only useful for SSH protocol version 2
-and if the peer supports it)
.It Cm ~C
Open command line (only useful for adding port forwardings using the
.Fl L
@@ -337,6 +335,7 @@ The user should not manually set
.Ev DISPLAY .
Forwarding of X11 connections can be
configured on the command line or in configuration files.
+Take note that X11 forwarding can represent a security hazard.
.Pp
The
.Ev DISPLAY
@@ -488,13 +487,13 @@ It is possible to have multiple
options (and multiple identities specified in
configuration files).
.It Fl I Ar smartcard_device
-Specifies which smartcard device to use.
-The argument is the device
+Specifies which smartcard device to use. The argument is
+the device
.Nm
should use to communicate with a smartcard used for storing the user's
private RSA key.
.It Fl k
-Disables forwarding of Kerberos tickets.
+Disables forwarding of Kerberos tickets and AFS tokens.
This may also be specified on a per-host basis in the configuration file.
.It Fl l Ar login_name
Specifies the user to log in as on the remote machine.
@@ -542,10 +541,9 @@ per-host basis in the configuration file.
Quiet mode.
Causes all warning and diagnostic messages to be suppressed.
.It Fl s
-May be used to request invocation of a subsystem on the remote system.
-Subsystems are a feature of the SSH2 protocol which facilitate the use
-of SSH as a secure transport for other applications (eg. sftp).
-The subsystem is specified as the remote command.
+May be used to request invocation of a subsystem on the remote system. Subsystems are a feature of the SSH2 protocol which facilitate the use
+of SSH as a secure transport for other applications (eg. sftp). The
+subsystem is specified as the remote command.
.It Fl t
Force pseudo-tty allocation.
This can be used to execute arbitrary
@@ -567,10 +565,8 @@ This is helpful in
debugging connection, authentication, and configuration problems.
Multiple
.Fl v
-options increase the verbosity.
-The maximum is 3.
-.It Fl V
-Display the version number and exit.
+options increases the verbosity.
+Maximum is 3.
.It Fl x
Disables X11 forwarding.
.It Fl X
@@ -649,9 +645,9 @@ on the local side, and whenever a connection is made to this port, the
connection is forwarded over the secure channel, and the application
protocol is then used to determine where to connect to from the
remote machine.
-Currently the SOCKS4 and SOCKS5 protocols are supported, and
+Currently the SOCKS4 protocol is supported, and
.Nm
-will act as a SOCKS server.
+will act as a SOCKS4 server.
Only root can forward privileged ports.
Dynamic port forwardings can also be specified in the configuration file.
.It Fl 1
@@ -690,7 +686,7 @@ It is automatically set by
to point to a value of the form
.Dq hostname:n
where hostname indicates
-the host where the shell runs, and n is an integer >= 1.
+the host where the shell runs, and n is an integer \*(>= 1.
.Nm
uses this special value to forward X11 connections over the secure
channel.
@@ -935,7 +931,7 @@ same.
Additionally, successful RSA host authentication is normally
required.
This file should only be writable by root.
-.It Pa /etc/shosts.equiv
+.It Pa /etc/ssh/shosts.equiv
This file is processed exactly as
.Pa /etc/hosts.equiv .
This file may be useful to permit logins using
@@ -965,6 +961,15 @@ above.
.Nm
exits with the exit status of the remote command or with 255
if an error occurred.
+.Sh AUTHORS
+OpenSSH is a derivative of the original and free
+ssh 1.2.12 release by Tatu Ylonen.
+Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
+Theo de Raadt and Dug Song
+removed many bugs, re-added newer features and
+created OpenSSH.
+Markus Friedl contributed the support for SSH
+protocol versions 1.5 and 2.0.
.Sh SEE ALSO
.Xr rsh 1 ,
.Xr scp 1 ,
@@ -987,12 +992,3 @@ if an error occurred.
.%D January 2002
.%O work in progress material
.Re
-.Sh AUTHORS
-OpenSSH is a derivative of the original and free
-ssh 1.2.12 release by Tatu Ylonen.
-Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
-Theo de Raadt and Dug Song
-removed many bugs, re-added newer features and
-created OpenSSH.
-Markus Friedl contributed the support for SSH
-protocol versions 1.5 and 2.0.
diff --git a/crypto/openssh/ssh.c b/crypto/openssh/ssh.c
index 35418f6..51a9fc8 100644
--- a/crypto/openssh/ssh.c
+++ b/crypto/openssh/ssh.c
@@ -40,7 +40,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.201 2003/09/01 18:15:50 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.190 2003/02/06 09:27:29 markus Exp $");
+RCSID("$FreeBSD$");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -79,6 +80,14 @@ extern char *__progname;
char *__progname;
#endif
+/* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
+ Default value is AF_UNSPEC means both IPv4 and IPv6. */
+#ifdef IPV4_DEFAULT
+int IPv4or6 = AF_INET;
+#else
+int IPv4or6 = AF_UNSPEC;
+#endif
+
/* Flag indicating whether debug mode is on. This can be set on the command line. */
int debug_flag = 0;
@@ -154,6 +163,9 @@ usage(void)
_PATH_SSH_USER_CONFFILE);
fprintf(stderr, " -A Enable authentication agent forwarding.\n");
fprintf(stderr, " -a Disable authentication agent forwarding (default).\n");
+#ifdef AFS
+ fprintf(stderr, " -k Disable Kerberos ticket and AFS token forwarding.\n");
+#endif /* AFS */
fprintf(stderr, " -X Enable X11 connection forwarding.\n");
fprintf(stderr, " -x Disable X11 connection forwarding (default).\n");
fprintf(stderr, " -i file Identity for public key authentication "
@@ -211,7 +223,7 @@ main(int ac, char **av)
extern int optind, optreset;
extern char *optarg;
- __progname = ssh_get_progname(av[0]);
+ __progname = get_progname(av[0]);
init_rng();
/*
@@ -242,7 +254,7 @@ main(int ac, char **av)
/* Get user data. */
pw = getpwuid(original_real_uid);
if (!pw) {
- logit("You don't exist, go away!");
+ log("unknown user %d", original_real_uid);
exit(1);
}
/* Take a copy of the returned structure. */
@@ -273,10 +285,10 @@ again:
options.protocol = SSH_PROTO_2;
break;
case '4':
- options.address_family = AF_INET;
+ IPv4or6 = AF_INET;
break;
case '6':
- options.address_family = AF_INET6;
+ IPv4or6 = AF_INET6;
break;
case 'n':
stdin_null_flag = 1;
@@ -303,9 +315,12 @@ again:
case 'A':
options.forward_agent = 1;
break;
+#ifdef AFS
case 'k':
- /* ignored for backward compatibility */
+ options.kerberos_tgt_passing = 0;
+ options.afs_token_passing = 0;
break;
+#endif
case 'i':
if (stat(optarg, &st) < 0) {
fprintf(stderr, "Warning: Identity file %s "
@@ -332,22 +347,22 @@ again:
tty_flag = 1;
break;
case 'v':
- if (debug_flag == 0) {
+ if (0 == debug_flag) {
debug_flag = 1;
options.log_level = SYSLOG_LEVEL_DEBUG1;
- } else {
- if (options.log_level < SYSLOG_LEVEL_DEBUG3)
- options.log_level++;
+ } else if (options.log_level < SYSLOG_LEVEL_DEBUG3) {
+ options.log_level++;
break;
- }
+ } else
+ fatal("Too high debugging level.");
/* fallthrough */
case 'V':
fprintf(stderr,
- "%s, SSH protocols %d.%d/%d.%d, %s\n",
+ "%s, SSH protocols %d.%d/%d.%d, OpenSSL 0x%8.8lx\n",
SSH_VERSION,
PROTOCOL_MAJOR_1, PROTOCOL_MINOR_1,
PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2,
- SSLeay_version(SSLEAY_VERSION));
+ SSLeay());
if (opt == 'V')
exit(0);
break;
@@ -413,9 +428,9 @@ again:
case 'L':
case 'R':
- if (sscanf(optarg, "%5[0123456789]:%255[^:]:%5[0123456789]",
+ if (sscanf(optarg, "%5[0-9]:%255[^:]:%5[0-9]",
sfwd_port, buf, sfwd_host_port) != 3 &&
- sscanf(optarg, "%5[0123456789]/%255[^/]/%5[0123456789]",
+ sscanf(optarg, "%5[0-9]/%255[^/]/%5[0-9]",
sfwd_port, buf, sfwd_host_port) != 3) {
fprintf(stderr,
"Bad forwarding specification '%s'\n",
@@ -444,7 +459,7 @@ again:
optarg);
exit(1);
}
- add_local_forward(&options, fwd_port, "socks", 0);
+ add_local_forward(&options, fwd_port, "socks4", 0);
break;
case 'C':
@@ -504,6 +519,7 @@ again:
SSLeay_add_all_algorithms();
ERR_load_crypto_strings();
+ channel_set_af(IPv4or6);
/* Initialize the command to execute on remote host. */
buffer_init(&command);
@@ -544,7 +560,7 @@ again:
/* Do not allocate a tty if stdin is not a tty. */
if (!isatty(fileno(stdin)) && !force_tty_flag) {
if (tty_flag)
- logit("Pseudo-terminal will not be allocated because stdin is not a terminal.");
+ log("Pseudo-terminal will not be allocated because stdin is not a terminal.");
tty_flag = 0;
}
@@ -575,8 +591,6 @@ again:
/* Fill configuration defaults. */
fill_default_options(&options);
- channel_set_af(options.address_family);
-
/* reinit */
log_init(av[0], options.log_level, SYSLOG_FACILITY_USER, 1);
@@ -588,20 +602,42 @@ again:
if (options.hostname != NULL)
host = options.hostname;
- /* force lowercase for hostkey matching */
- if (options.host_key_alias != NULL) {
- for (p = options.host_key_alias; *p; p++)
- if (isupper(*p))
- *p = tolower(*p);
+ /* Find canonic host name. */
+ if (strchr(host, '.') == 0) {
+ struct addrinfo hints;
+ struct addrinfo *ai = NULL;
+ int errgai;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = IPv4or6;
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_socktype = SOCK_STREAM;
+ errgai = getaddrinfo(host, NULL, &hints, &ai);
+ if (errgai == 0) {
+ if (ai->ai_canonname != NULL)
+ host = xstrdup(ai->ai_canonname);
+ freeaddrinfo(ai);
+ }
}
if (options.proxy_command != NULL &&
strcmp(options.proxy_command, "none") == 0)
options.proxy_command = NULL;
+ /* Disable rhosts authentication if not running as root. */
+#ifdef HAVE_CYGWIN
+ /* Ignore uid if running under Windows */
+ if (!options.use_privileged_port) {
+#else
+ if (original_effective_uid != 0 || !options.use_privileged_port) {
+#endif
+ debug("Rhosts Authentication disabled, "
+ "originating port will not be trusted.");
+ options.rhosts_authentication = 0;
+ }
/* Open a connection to the remote host. */
- if (ssh_connect(host, &hostaddr, options.port,
- options.address_family, options.connection_attempts,
+
+ if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
+ options.connection_attempts,
#ifdef HAVE_CYGWIN
options.use_privileged_port,
#else
@@ -775,7 +811,7 @@ x11_get_proto(char **_proto, char **_data)
if (!got_data) {
u_int32_t rand = 0;
- logit("Warning: No xauth data; using fake authentication data for X11 forwarding.");
+ log("Warning: No xauth data; using fake authentication data for X11 forwarding.");
strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto);
for (i = 0; i < 16; i++) {
if (i % 4 == 0)
@@ -855,7 +891,7 @@ ssh_session(void)
if (type == SSH_SMSG_SUCCESS)
packet_start_compression(options.compression_level);
else if (type == SSH_SMSG_FAILURE)
- logit("Warning: Remote host refused compression.");
+ log("Warning: Remote host refused compression.");
else
packet_disconnect("Protocol error waiting for compression response.");
}
@@ -894,7 +930,7 @@ ssh_session(void)
interactive = 1;
have_tty = 1;
} else if (type == SSH_SMSG_FAILURE)
- logit("Warning: Remote host failed or refused to allocate a pseudo tty.");
+ log("Warning: Remote host failed or refused to allocate a pseudo tty.");
else
packet_disconnect("Protocol error waiting for pty request response.");
}
@@ -912,7 +948,7 @@ ssh_session(void)
if (type == SSH_SMSG_SUCCESS) {
interactive = 1;
} else if (type == SSH_SMSG_FAILURE) {
- logit("Warning: Remote host denied X11 forwarding.");
+ log("Warning: Remote host denied X11 forwarding.");
} else {
packet_disconnect("Protocol error waiting for X11 forwarding");
}
@@ -931,7 +967,7 @@ ssh_session(void)
type = packet_read();
packet_check_eom();
if (type != SSH_SMSG_SUCCESS)
- logit("Warning: Remote host denied authentication agent forwarding.");
+ log("Warning: Remote host denied authentication agent forwarding.");
}
/* Initiate port forwardings. */
@@ -999,7 +1035,7 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
options.remote_forwards[i].host,
options.remote_forwards[i].host_port);
if (type == SSH2_MSG_REQUEST_FAILURE)
- logit("Warning: remote port forwarding failed for listen port %d",
+ log("Warning: remote port forwarding failed for listen port %d",
options.remote_forwards[i].port);
}
@@ -1114,7 +1150,7 @@ ssh_session2_open(void)
c = channel_new(
"session", SSH_CHANNEL_OPENING, in, out, err,
window, packetmax, CHAN_EXTENDED_WRITE,
- "client-session", /*nonblock*/0);
+ xstrdup("client-session"), /*nonblock*/0);
debug3("ssh_session2_open: channel_new: %d", c->self);
@@ -1166,7 +1202,7 @@ load_public_identity_files(void)
sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1));
options.num_identity_files++;
options.identity_keys[0] = keys[i];
- options.identity_files[0] = sc_get_key_label(keys[i]);
+ options.identity_files[0] = xstrdup("smartcard key");;
}
if (options.num_identity_files > SSH_MAX_IDENTITY_FILES)
options.num_identity_files = SSH_MAX_IDENTITY_FILES;
diff --git a/crypto/openssh/ssh.h b/crypto/openssh/ssh.h
index e88b9b8..0a6ad13 100644
--- a/crypto/openssh/ssh.h
+++ b/crypto/openssh/ssh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.h,v 1.74 2003/09/01 13:52:18 markus Exp $ */
+/* $OpenBSD: ssh.h,v 1.71 2002/06/22 02:00:29 stevesk Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -20,6 +20,7 @@
#include <stdarg.h> /* For va_list */
#include <syslog.h> /* For LOG_AUTH and friends */
#include <sys/socket.h> /* For struct sockaddr_storage */
+#include "openbsd-compat/fake-socket.h" /* For struct sockaddr_storage */
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
@@ -88,6 +89,9 @@
*/
#define SSH_SESSION_KEY_LENGTH 32
+/* Name of Kerberos service for SSH to use. */
+#define KRB4_SERVICE_NAME "rcmd"
+
/* Used to identify ``EscapeChar none'' */
#define SSH_ESCAPECHAR_NONE -2
diff --git a/crypto/openssh/ssh/Makefile b/crypto/openssh/ssh/Makefile
deleted file mode 100644
index 80511de..0000000
--- a/crypto/openssh/ssh/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-# $OpenBSD: Makefile,v 1.42 2002/06/20 19:56:07 stevesk Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= ssh
-BINOWN= root
-
-#BINMODE?=4555
-
-BINDIR= /usr/bin
-MAN= ssh.1 ssh_config.5
-LINKS= ${BINDIR}/ssh ${BINDIR}/slogin
-MLINKS= ssh.1 slogin.1
-
-SRCS= ssh.c readconf.c clientloop.c sshtty.c \
- sshconnect.c sshconnect1.c sshconnect2.c
-
-.include <bsd.own.mk> # for AFS
-
-.if (${KERBEROS5:L} == "yes")
-CFLAGS+= -DKRB5 -I${DESTDIR}/usr/include/kerberosV
-LDADD+= -lkrb5 -lasn1 -lcom_err
-DPADD+= ${LIBKRB5} ${LIBASN1} ${LIBCOM_ERR}
-.endif # KERBEROS5
-
-.if (${KERBEROS:L} == "yes")
-CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
-LDADD+= -lkrb
-DPADD+= ${LIBKRB}
-.if (${AFS:L} == "yes")
-CFLAGS+= -DAFS
-LDADD+= -lkafs
-DPADD+= ${LIBKAFS}
-.endif # AFS
-.endif # KERBEROS
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto -lz -ldes
-DPADD+= ${LIBCRYPTO} ${LIBZ} ${LIBDES}
diff --git a/crypto/openssh/ssh_config b/crypto/openssh/ssh_config
index 2692e89..e3f82cf 100644
--- a/crypto/openssh/ssh_config
+++ b/crypto/openssh/ssh_config
@@ -1,4 +1,5 @@
-# $OpenBSD: ssh_config,v 1.19 2003/08/13 08:46:31 markus Exp $
+# $OpenBSD: ssh_config,v 1.16 2002/07/03 14:21:05 markus Exp $
+# $FreeBSD$
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
@@ -18,14 +19,13 @@
# Host *
# ForwardAgent no
# ForwardX11 no
+# RhostsAuthentication no
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# BatchMode no
-# CheckHostIP yes
-# AddressFamily any
-# ConnectTimeout 0
+# CheckHostIP no
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
@@ -35,3 +35,4 @@
# Cipher 3des
# Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
# EscapeChar ~
+# VersionAddendum FreeBSD-20030924
diff --git a/crypto/openssh/ssh_config.5 b/crypto/openssh/ssh_config.5
index 7a435a9..f67f37d 100644
--- a/crypto/openssh/ssh_config.5
+++ b/crypto/openssh/ssh_config.5
@@ -34,7 +34,8 @@
.\" (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: ssh_config.5,v 1.20 2003/09/02 18:50:06 jmc Exp $
+.\" $OpenBSD: ssh_config.5,v 1.7 2003/03/28 10:11:43 jmc Exp $
+.\" $FreeBSD$
.Dd September 25, 1999
.Dt SSH_CONFIG 5
.Os
@@ -104,7 +105,7 @@ keyword) to be only for those hosts that match one of the patterns
given after the keyword.
.Ql \&*
and
-.Ql \&?
+.Ql ?
can be used as wildcards in the
patterns.
A single
@@ -115,14 +116,13 @@ The host is the
.Ar hostname
argument given on the command line (i.e., the name is not converted to
a canonicalized host name before matching).
-.It Cm AddressFamily
-Specifies which address family to use when connecting.
-Valid arguments are
-.Dq any ,
-.Dq inet
-(Use IPv4 only) or
-.Dq inet6
-(Use IPv6 only.)
+.It Cm AFSTokenPassing
+Specifies whether to pass AFS tokens to remote host.
+The argument to this keyword must be
+.Dq yes
+or
+.Dq no .
+This option applies to protocol version 1 only.
.It Cm BatchMode
If set to
.Dq yes ,
@@ -161,7 +161,7 @@ If the option is set to
.Dq no ,
the check will not be executed.
The default is
-.Dq yes .
+.Dq no .
.It Cm Cipher
Specifies the cipher to use for encrypting the session
in protocol version 1.
@@ -228,41 +228,18 @@ Specifies the number of tries (one per second) to make before exiting.
The argument must be an integer.
This may be useful in scripts if the connection sometimes fails.
The default is 1.
-.It Cm ConnectTimeout
-Specifies the timeout (in seconds) used when connecting to the ssh
-server, instead of using the default system TCP timeout.
-This value is used only when the target is down or really unreachable,
-not when it refuses the connection.
.It Cm DynamicForward
Specifies that a TCP/IP port on the local machine be forwarded
over the secure channel, and the application
protocol is then used to determine where to connect to from the
remote machine.
The argument must be a port number.
-Currently the SOCKS4 and SOCKS5 protocols are supported, and
+Currently the SOCKS4 protocol is supported, and
.Nm ssh
-will act as a SOCKS server.
+will act as a SOCKS4 server.
Multiple forwardings may be specified, and
additional forwardings can be given on the command line.
Only the superuser can forward privileged ports.
-.It Cm EnableSSHKeysign
-Setting this option to
-.Dq yes
-in the global client configuration file
-.Pa /etc/ssh/ssh_config
-enables the use of the helper program
-.Xr ssh-keysign 8
-during
-.Cm HostbasedAuthentication .
-The argument must be
-.Dq yes
-or
-.Dq no .
-The default is
-.Dq no .
-See
-.Xr ssh-keysign 8
-for more information.
.It Cm EscapeChar
Sets the escape character (default:
.Ql ~ ) .
@@ -331,18 +308,6 @@ The default is
Specifies a file to use for the global
host key database instead of
.Pa /etc/ssh/ssh_known_hosts .
-.It Cm GSSAPIAuthentication
-Specifies whether authentication based on GSSAPI may be used, either using
-the result of a successful key exchange, or using GSSAPI user
-authentication.
-The default is
-.Dq yes .
-Note that this option applies to protocol version 2 only.
-.It Cm GSSAPIDelegateCredentials
-Forward (delegate) credentials to the server.
-The default is
-.Dq no .
-Note that this option applies to protocol version 2 only.
.It Cm HostbasedAuthentication
Specifies whether to try rhosts based authentication with public key
authentication.
@@ -375,8 +340,7 @@ Numeric IP addresses are also permitted (both on the command line and in
specifications).
.It Cm IdentityFile
Specifies a file from which the user's RSA or DSA authentication identity
-is read.
-The default is
+is read. The default is
.Pa $HOME/.ssh/identity
for protocol version 1, and
.Pa $HOME/.ssh/id_rsa
@@ -407,6 +371,19 @@ This is important in scripts, and many users want it too.
.Pp
To disable keepalives, the value should be set to
.Dq no .
+.It Cm KerberosAuthentication
+Specifies whether Kerberos authentication will be used.
+The argument to this keyword must be
+.Dq yes
+or
+.Dq no .
+.It Cm KerberosTgtPassing
+Specifies whether a Kerberos TGT will be forwarded to the server.
+This will only work if the Kerberos server is actually an AFS kaserver.
+The argument to this keyword must be
+.Dq yes
+or
+.Dq no .
.It Cm LocalForward
Specifies that a TCP/IP port on the local machine be forwarded over
the secure channel to the specified host and port from the remote machine.
@@ -460,8 +437,7 @@ Specifies the port number to connect on the remote host.
Default is 22.
.It Cm PreferredAuthentications
Specifies the order in which the client should try protocol 2
-authentication methods.
-This allows a client to prefer one method (e.g.
+authentication methods. This allows a client to prefer one method (e.g.
.Cm keyboard-interactive )
over another method (e.g.
.Cm password )
@@ -529,6 +505,26 @@ IPv6 addresses can be specified with an alternative syntax:
Multiple forwardings may be specified, and additional
forwardings can be given on the command line.
Only the superuser can forward privileged ports.
+.It Cm RhostsAuthentication
+Specifies whether to try rhosts based authentication.
+Note that this
+declaration only affects the client side and has no effect whatsoever
+on security.
+Most servers do not permit RhostsAuthentication because it
+is not secure (see
+.Cm RhostsRSAAuthentication ) .
+The argument to this keyword must be
+.Dq yes
+or
+.Dq no .
+The default is
+.Dq no .
+This option applies to protocol version 1 only and requires
+.Nm ssh
+to be setuid root and
+.Cm UsePrivilegedPort
+to be set to
+.Dq yes .
.It Cm RhostsRSAAuthentication
Specifies whether to try rhosts based authentication with RSA host
authentication.
@@ -554,12 +550,12 @@ The default is
.Dq yes .
Note that this option applies to protocol version 1 only.
.It Cm SmartcardDevice
-Specifies which smartcard device to use.
-The argument to this keyword is the device
+Specifies which smartcard device to use. The argument to this keyword is
+the device
.Nm ssh
should use to communicate with a smartcard used for storing the user's
-private RSA key.
-By default, no device is specified and smartcard support is not activated.
+private RSA key. By default, no device is specified and smartcard support
+is not activated.
.It Cm StrictHostKeyChecking
If this flag is set to
.Dq yes ,
@@ -609,9 +605,11 @@ If set to
must be setuid root.
Note that this option must be set to
.Dq yes
-for
+if
+.Cm RhostsAuthentication
+and
.Cm RhostsRSAAuthentication
-with older servers.
+authentications are needed with older servers.
.It Cm User
Specifies the user to log in as.
This can be useful when a different user name is used on different machines.
@@ -621,12 +619,11 @@ having to remember to give the user name on the command line.
Specifies a file to use for the user
host key database instead of
.Pa $HOME/.ssh/known_hosts .
-.It Cm VerifyHostKeyDNS
-Specifies whether to verify the remote key using DNS and SSHFP resource
-records.
+.It Cm VersionAddendum
+Specifies a string to append to the regular version string to identify
+OS- or site-specific modifications.
The default is
-.Dq no .
-Note that this option applies to protocol version 2 only.
+.Dq FreeBSD-20030924 .
.It Cm XAuthLocation
Specifies the full pathname of the
.Xr xauth 1
@@ -652,8 +649,6 @@ values that are not specified in the user's configuration file, and
for those users who do not have a configuration file.
This file must be world-readable.
.El
-.Sh SEE ALSO
-.Xr ssh 1
.Sh AUTHORS
OpenSSH is a derivative of the original and free
ssh 1.2.12 release by Tatu Ylonen.
@@ -663,3 +658,5 @@ removed many bugs, re-added newer features and
created OpenSSH.
Markus Friedl contributed the support for SSH
protocol versions 1.5 and 2.0.
+.Sh SEE ALSO
+.Xr ssh 1
diff --git a/crypto/openssh/sshconnect.c b/crypto/openssh/sshconnect.c
index f29ac80..dae2596 100644
--- a/crypto/openssh/sshconnect.c
+++ b/crypto/openssh/sshconnect.c
@@ -13,7 +13,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.148 2003/09/18 07:52:54 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.137 2002/11/21 23:03:51 deraadt Exp $");
#include <openssl/bn.h>
@@ -33,17 +33,9 @@ RCSID("$OpenBSD: sshconnect.c,v 1.148 2003/09/18 07:52:54 markus Exp $");
#include "misc.h"
#include "readpass.h"
-#ifdef DNS
-#include "dns.h"
-#endif
-
char *client_version_string = NULL;
char *server_version_string = NULL;
-#ifdef DNS
-int verified_host_key_dns = 0;
-#endif
-
/* import */
extern Options options;
extern char *__progname;
@@ -171,7 +163,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
* Creates a (possibly privileged) socket for use as the ssh connection.
*/
static int
-ssh_create_socket(int privileged, struct addrinfo *ai)
+ssh_create_socket(int privileged, int family)
{
int sock, gaierr;
struct addrinfo hints, *res;
@@ -183,16 +175,15 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
if (privileged) {
int p = IPPORT_RESERVED - 1;
PRIV_START;
- sock = rresvport_af(&p, ai->ai_family);
+ sock = rresvport_af(&p, family);
PRIV_END;
if (sock < 0)
- error("rresvport: af=%d %.100s", ai->ai_family,
- strerror(errno));
+ error("rresvport: af=%d %.100s", family, strerror(errno));
else
debug("Allocated local port %d.", p);
return sock;
}
- sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ sock = socket(family, SOCK_STREAM, 0);
if (sock < 0)
error("socket: %.100s", strerror(errno));
@@ -201,9 +192,8 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
return sock;
memset(&hints, 0, sizeof(hints));
- hints.ai_family = ai->ai_family;
- hints.ai_socktype = ai->ai_socktype;
- hints.ai_protocol = ai->ai_protocol;
+ hints.ai_family = family;
+ hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
gaierr = getaddrinfo(options.bind_address, "0", &hints, &res);
if (gaierr) {
@@ -222,74 +212,6 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
return sock;
}
-static int
-timeout_connect(int sockfd, const struct sockaddr *serv_addr,
- socklen_t addrlen, int timeout)
-{
- fd_set *fdset;
- struct timeval tv;
- socklen_t optlen;
- int fdsetsz, optval, rc, result = -1;
-
- if (timeout <= 0)
- return (connect(sockfd, serv_addr, addrlen));
-
- if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
- return (-1);
-
- rc = connect(sockfd, serv_addr, addrlen);
- if (rc == 0)
- return (0);
- if (errno != EINPROGRESS)
- return (-1);
-
- fdsetsz = howmany(sockfd + 1, NFDBITS) * sizeof(fd_mask);
- fdset = (fd_set *)xmalloc(fdsetsz);
-
- memset(fdset, 0, fdsetsz);
- FD_SET(sockfd, fdset);
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
-
- for(;;) {
- rc = select(sockfd + 1, NULL, fdset, NULL, &tv);
- if (rc != -1 || errno != EINTR)
- break;
- }
-
- switch(rc) {
- case 0:
- /* Timed out */
- errno = ETIMEDOUT;
- break;
- case -1:
- /* Select error */
- debug("select: %s", strerror(errno));
- break;
- case 1:
- /* Completed or failed */
- optval = 0;
- optlen = sizeof(optval);
- if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval,
- &optlen) == -1) {
- debug("getsockopt: %s", strerror(errno));
- break;
- }
- if (optval != 0) {
- errno = optval;
- break;
- }
- result = 0;
- break;
- default:
- /* Should not occur */
- fatal("Bogus return (%d) from select()", rc);
- }
-
- xfree(fdset);
- return (result);
-}
-
/*
* Opens a TCP/IP connection to the remote server on the given host.
* The address of the remote host will be returned in hostaddr.
@@ -373,13 +295,12 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
host, ntop, strport);
/* Create a socket for connecting. */
- sock = ssh_create_socket(needpriv, ai);
+ sock = ssh_create_socket(needpriv, ai->ai_family);
if (sock < 0)
/* Any error is already output */
continue;
- if (timeout_connect(sock, ai->ai_addr, ai->ai_addrlen,
- options.connection_timeout) >= 0) {
+ if (connect(sock, ai->ai_addr, ai->ai_addrlen) >= 0) {
/* Successful connection. */
memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);
break;
@@ -411,7 +332,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
/* Return failure if we didn't get a successful connection. */
if (attempt >= connection_attempts) {
- logit("ssh: connect to host %s port %s: %s",
+ log("ssh: connect to host %s port %s: %s",
host, strport, strerror(errno));
return full_failure ? ECONNABORTED : ECONNREFUSED;
}
@@ -500,7 +421,7 @@ ssh_exchange_identification(void)
enable_compat13();
minor1 = 3;
if (options.forward_agent) {
- logit("Agent forwarding disabled for protocol 1.3");
+ log("Agent forwarding disabled for protocol 1.3");
options.forward_agent = 0;
}
}
@@ -524,7 +445,7 @@ ssh_exchange_identification(void)
compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
compat20 ? PROTOCOL_MINOR_2 : minor1,
SSH_VERSION);
- if (atomicio(vwrite, connection_out, buf, strlen(buf)) != strlen(buf))
+ if (atomicio(write, connection_out, buf, strlen(buf)) != strlen(buf))
fatal("write: %.100s", strerror(errno));
client_version_string = xstrdup(buf);
chop(client_version_string);
@@ -575,7 +496,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
int salen;
char ntop[NI_MAXHOST];
char msg[1024];
- int len, host_line, ip_line;
+ int len, host_line, ip_line, has_keys;
const char *host_file = NULL, *ip_file = NULL;
/*
@@ -691,16 +612,16 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
debug("Found key in %s:%d", host_file, host_line);
if (options.check_host_ip && ip_status == HOST_NEW) {
if (readonly)
- logit("%s host key for IP address "
+ log("%s host key for IP address "
"'%.128s' not in list of known hosts.",
type, ip);
else if (!add_host_to_hostfile(user_hostfile, ip,
host_key))
- logit("Failed to add the %s host key for IP "
+ log("Failed to add the %s host key for IP "
"address '%.128s' to the list of known "
"hosts (%.30s).", type, ip, user_hostfile);
else
- logit("Warning: Permanently added the %s host "
+ log("Warning: Permanently added the %s host "
"key for IP address '%.128s' to the list "
"of known hosts.", type, ip);
}
@@ -719,36 +640,19 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
"have requested strict checking.", type, host);
goto fail;
} else if (options.strict_host_key_checking == 2) {
- char msg1[1024], msg2[1024];
-
- if (show_other_keys(host, host_key))
- snprintf(msg1, sizeof(msg1),
- "\nbut keys of different type are already"
- " known for this host.");
- else
- snprintf(msg1, sizeof(msg1), ".");
+ has_keys = show_other_keys(host, host_key);
/* The default */
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
- msg2[0] = '\0';
-#ifdef DNS
- if (options.verify_host_key_dns) {
- if (verified_host_key_dns)
- snprintf(msg2, sizeof(msg2),
- "Matching host key fingerprint"
- " found in DNS.\n");
- else
- snprintf(msg2, sizeof(msg2),
- "No matching host key fingerprint"
- " found in DNS.\n");
- }
-#endif
snprintf(msg, sizeof(msg),
"The authenticity of host '%.200s (%s)' can't be "
"established%s\n"
- "%s key fingerprint is %s.\n%s"
+ "%s key fingerprint is %s.\n"
"Are you sure you want to continue connecting "
"(yes/no)? ",
- host, ip, msg1, type, fp, msg2);
+ host, ip,
+ has_keys ? ",\nbut keys of different type are already "
+ "known for this host." : ".",
+ type, fp);
xfree(fp);
if (!confirm(msg))
goto fail;
@@ -764,10 +668,10 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
* local known_hosts file.
*/
if (!add_host_to_hostfile(user_hostfile, hostp, host_key))
- logit("Failed to add the host to the list of known "
+ log("Failed to add the host to the list of known "
"hosts (%.500s).", user_hostfile);
else
- logit("Warning: Permanently added '%.200s' (%s) to the "
+ log("Warning: Permanently added '%.200s' (%s) to the "
"list of known hosts.", hostp, type);
break;
case HOST_CHANGED:
@@ -818,7 +722,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
/*
* If strict host key checking has not been requested, allow
- * the connection but without MITM-able authentication or
+ * the connection but without password authentication or
* agent forwarding.
*/
if (options.password_authentication) {
@@ -826,17 +730,6 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
"man-in-the-middle attacks.");
options.password_authentication = 0;
}
- if (options.kbd_interactive_authentication) {
- error("Keyboard-interactive authentication is disabled"
- " to avoid man-in-the-middle attacks.");
- options.kbd_interactive_authentication = 0;
- options.challenge_response_authentication = 0;
- }
- if (options.challenge_response_authentication) {
- error("Challenge/response authentication is disabled"
- " to avoid man-in-the-middle attacks.");
- options.challenge_response_authentication = 0;
- }
if (options.forward_agent) {
error("Agent forwarding is disabled to avoid "
"man-in-the-middle attacks.");
@@ -881,7 +774,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
host_file, host_line);
}
if (options.strict_host_key_checking == 1) {
- logit("%s", msg);
+ log(msg);
error("Exiting, you have requested strict checking.");
goto fail;
} else if (options.strict_host_key_checking == 2) {
@@ -890,7 +783,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
if (!confirm(msg))
goto fail;
} else {
- logit("%s", msg);
+ log(msg);
}
}
@@ -902,33 +795,11 @@ fail:
return -1;
}
-/* returns 0 if key verifies or -1 if key does NOT verify */
int
verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
{
struct stat st;
-#ifdef DNS
- if (options.verify_host_key_dns) {
- switch(verify_host_key_dns(host, hostaddr, host_key)) {
- case DNS_VERIFY_OK:
-#ifdef DNSSEC
- return 0;
-#else
- verified_host_key_dns = 1;
- break;
-#endif
- case DNS_VERIFY_FAILED:
- return -1;
- case DNS_VERIFY_ERROR:
- break;
- default:
- debug3("bad return value from verify_host_key_dns");
- break;
- }
- }
-#endif /* DNS */
-
/* return ok if the key can be found in an old keyfile */
if (stat(options.system_hostfile2, &st) == 0 ||
stat(options.user_hostfile2, &st) == 0) {
@@ -1010,7 +881,7 @@ show_key_from_file(const char *file, const char *host, int keytype)
if ((ret = lookup_key_in_hostfile_by_type(file, host,
keytype, found, &line))) {
fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX);
- logit("WARNING: %s key found for host %s\n"
+ log("WARNING: %s key found for host %s\n"
"in %s:%d\n"
"%s key fingerprint %s.",
key_type(found), host, file, line,
diff --git a/crypto/openssh/sshconnect1.c b/crypto/openssh/sshconnect1.c
index 2f89964..2fc9a98 100644
--- a/crypto/openssh/sshconnect1.c
+++ b/crypto/openssh/sshconnect1.c
@@ -13,11 +13,25 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect1.c,v 1.56 2003/08/28 12:54:34 markus Exp $");
+RCSID("$OpenBSD: sshconnect1.c,v 1.52 2002/08/08 13:50:23 aaron Exp $");
#include <openssl/bn.h>
#include <openssl/md5.h>
+#ifdef KRB4
+#include <krb.h>
+#endif
+#ifdef KRB5
+#include <krb5.h>
+#ifndef HEIMDAL
+#define krb5_get_err_text(context,code) error_message(code)
+#endif /* !HEIMDAL */
+#endif
+#ifdef AFS
+#include <kafs.h>
+#include "radix.h"
+#endif
+
#include "ssh.h"
#include "ssh1.h"
#include "xmalloc.h"
@@ -108,7 +122,7 @@ try_agent_authentication(void)
* although it advertised it supports this. Just
* return a wrong value.
*/
- logit("Authentication agent failed to decrypt challenge.");
+ log("Authentication agent failed to decrypt challenge.");
memset(response, 0, sizeof(response));
}
key_free(key);
@@ -366,6 +380,478 @@ try_rhosts_rsa_authentication(const char *local_user, Key * host_key)
return 0;
}
+#ifdef KRB4
+static int
+try_krb4_authentication(void)
+{
+ KTEXT_ST auth; /* Kerberos data */
+ char *reply;
+ char inst[INST_SZ];
+ char *realm;
+ CREDENTIALS cred;
+ int r, type;
+ socklen_t slen;
+ Key_schedule schedule;
+ u_long checksum, cksum;
+ MSG_DAT msg_data;
+ struct sockaddr_in local, foreign;
+ struct stat st;
+
+ /* Don't do anything if we don't have any tickets. */
+ if (stat(tkt_string(), &st) < 0)
+ return 0;
+
+ strlcpy(inst, (char *)krb_get_phost(get_canonical_hostname(1)),
+ INST_SZ);
+
+ realm = (char *)krb_realmofhost(get_canonical_hostname(1));
+ if (!realm) {
+ debug("Kerberos v4: no realm for %s", get_canonical_hostname(1));
+ return 0;
+ }
+ /* This can really be anything. */
+ checksum = (u_long)getpid();
+
+ r = krb_mk_req(&auth, KRB4_SERVICE_NAME, inst, realm, checksum);
+ if (r != KSUCCESS) {
+ debug("Kerberos v4 krb_mk_req failed: %s", krb_err_txt[r]);
+ return 0;
+ }
+ /* Get session key to decrypt the server's reply with. */
+ r = krb_get_cred(KRB4_SERVICE_NAME, inst, realm, &cred);
+ if (r != KSUCCESS) {
+ debug("get_cred failed: %s", krb_err_txt[r]);
+ return 0;
+ }
+ des_key_sched((des_cblock *) cred.session, schedule);
+
+ /* Send authentication info to server. */
+ packet_start(SSH_CMSG_AUTH_KERBEROS);
+ packet_put_string((char *) auth.dat, auth.length);
+ packet_send();
+ packet_write_wait();
+
+ /* Zero the buffer. */
+ (void) memset(auth.dat, 0, MAX_KTXT_LEN);
+
+ slen = sizeof(local);
+ memset(&local, 0, sizeof(local));
+ if (getsockname(packet_get_connection_in(),
+ (struct sockaddr *)&local, &slen) < 0)
+ debug("getsockname failed: %s", strerror(errno));
+
+ slen = sizeof(foreign);
+ memset(&foreign, 0, sizeof(foreign));
+ if (getpeername(packet_get_connection_in(),
+ (struct sockaddr *)&foreign, &slen) < 0) {
+ debug("getpeername failed: %s", strerror(errno));
+ fatal_cleanup();
+ }
+ /* Get server reply. */
+ type = packet_read();
+ switch (type) {
+ case SSH_SMSG_FAILURE:
+ /* Should really be SSH_SMSG_AUTH_KERBEROS_FAILURE */
+ debug("Kerberos v4 authentication failed.");
+ return 0;
+ break;
+
+ case SSH_SMSG_AUTH_KERBEROS_RESPONSE:
+ /* SSH_SMSG_AUTH_KERBEROS_SUCCESS */
+ debug("Kerberos v4 authentication accepted.");
+
+ /* Get server's response. */
+ reply = packet_get_string((u_int *) &auth.length);
+ if (auth.length >= MAX_KTXT_LEN)
+ fatal("Kerberos v4: Malformed response from server");
+ memcpy(auth.dat, reply, auth.length);
+ xfree(reply);
+
+ packet_check_eom();
+
+ /*
+ * If his response isn't properly encrypted with the session
+ * key, and the decrypted checksum fails to match, he's
+ * bogus. Bail out.
+ */
+ r = krb_rd_priv(auth.dat, auth.length, schedule, &cred.session,
+ &foreign, &local, &msg_data);
+ if (r != KSUCCESS) {
+ debug("Kerberos v4 krb_rd_priv failed: %s",
+ krb_err_txt[r]);
+ packet_disconnect("Kerberos v4 challenge failed!");
+ }
+ /* Fetch the (incremented) checksum that we supplied in the request. */
+ memcpy((char *)&cksum, (char *)msg_data.app_data,
+ sizeof(cksum));
+ cksum = ntohl(cksum);
+
+ /* If it matches, we're golden. */
+ if (cksum == checksum + 1) {
+ debug("Kerberos v4 challenge successful.");
+ return 1;
+ } else
+ packet_disconnect("Kerberos v4 challenge failed!");
+ break;
+
+ default:
+ packet_disconnect("Protocol error on Kerberos v4 response: %d", type);
+ }
+ return 0;
+}
+
+#endif /* KRB4 */
+
+#ifdef KRB5
+static int
+try_krb5_authentication(krb5_context *context, krb5_auth_context *auth_context)
+{
+ krb5_error_code problem;
+ const char *tkfile;
+ struct stat buf;
+ krb5_ccache ccache = NULL;
+ const char *remotehost;
+ krb5_data ap;
+ int type;
+ krb5_ap_rep_enc_part *reply = NULL;
+ int ret;
+
+ memset(&ap, 0, sizeof(ap));
+
+ problem = krb5_init_context(context);
+ if (problem) {
+ debug("Kerberos v5: krb5_init_context failed");
+ ret = 0;
+ goto out;
+ }
+
+ problem = krb5_auth_con_init(*context, auth_context);
+ if (problem) {
+ debug("Kerberos v5: krb5_auth_con_init failed");
+ ret = 0;
+ goto out;
+ }
+
+#ifndef HEIMDAL
+ problem = krb5_auth_con_setflags(*context, *auth_context,
+ KRB5_AUTH_CONTEXT_RET_TIME);
+ if (problem) {
+ debug("Keberos v5: krb5_auth_con_setflags failed");
+ ret = 0;
+ goto out;
+ }
+#endif
+
+ tkfile = krb5_cc_default_name(*context);
+ if (strncmp(tkfile, "FILE:", 5) == 0)
+ tkfile += 5;
+
+ if (stat(tkfile, &buf) == 0 && getuid() != buf.st_uid) {
+ debug("Kerberos v5: could not get default ccache (permission denied).");
+ ret = 0;
+ goto out;
+ }
+
+ problem = krb5_cc_default(*context, &ccache);
+ if (problem) {
+ debug("Kerberos v5: krb5_cc_default failed: %s",
+ krb5_get_err_text(*context, problem));
+ ret = 0;
+ goto out;
+ }
+
+ remotehost = get_canonical_hostname(1);
+
+ problem = krb5_mk_req(*context, auth_context, AP_OPTS_MUTUAL_REQUIRED,
+ "host", remotehost, NULL, ccache, &ap);
+ if (problem) {
+ debug("Kerberos v5: krb5_mk_req failed: %s",
+ krb5_get_err_text(*context, problem));
+ ret = 0;
+ goto out;
+ }
+
+ packet_start(SSH_CMSG_AUTH_KERBEROS);
+ packet_put_string((char *) ap.data, ap.length);
+ packet_send();
+ packet_write_wait();
+
+ xfree(ap.data);
+ ap.length = 0;
+
+ type = packet_read();
+ switch (type) {
+ case SSH_SMSG_FAILURE:
+ /* Should really be SSH_SMSG_AUTH_KERBEROS_FAILURE */
+ debug("Kerberos v5 authentication failed.");
+ ret = 0;
+ break;
+
+ case SSH_SMSG_AUTH_KERBEROS_RESPONSE:
+ /* SSH_SMSG_AUTH_KERBEROS_SUCCESS */
+ debug("Kerberos v5 authentication accepted.");
+
+ /* Get server's response. */
+ ap.data = packet_get_string((unsigned int *) &ap.length);
+ packet_check_eom();
+ /* XXX je to dobre? */
+
+ problem = krb5_rd_rep(*context, *auth_context, &ap, &reply);
+ if (problem) {
+ ret = 0;
+ }
+ ret = 1;
+ break;
+
+ default:
+ packet_disconnect("Protocol error on Kerberos v5 response: %d",
+ type);
+ ret = 0;
+ break;
+
+ }
+
+ out:
+ if (ccache != NULL)
+ krb5_cc_close(*context, ccache);
+ if (reply != NULL)
+ krb5_free_ap_rep_enc_part(*context, reply);
+ if (ap.length > 0)
+#ifdef HEIMDAL
+ krb5_data_free(&ap);
+#else
+ krb5_free_data_contents(*context, &ap);
+#endif
+
+ return (ret);
+}
+
+static void
+send_krb5_tgt(krb5_context context, krb5_auth_context auth_context)
+{
+ int fd, type;
+ krb5_error_code problem;
+ krb5_data outbuf;
+ krb5_ccache ccache = NULL;
+ krb5_creds creds;
+#ifdef HEIMDAL
+ krb5_kdc_flags flags;
+#else
+ int forwardable;
+#endif
+ const char *remotehost;
+
+ memset(&creds, 0, sizeof(creds));
+ memset(&outbuf, 0, sizeof(outbuf));
+
+ fd = packet_get_connection_in();
+
+#ifdef HEIMDAL
+ problem = krb5_auth_con_setaddrs_from_fd(context, auth_context, &fd);
+#else
+ problem = krb5_auth_con_genaddrs(context, auth_context, fd,
+ KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR |
+ KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR);
+#endif
+ if (problem)
+ goto out;
+
+ problem = krb5_cc_default(context, &ccache);
+ if (problem)
+ goto out;
+
+ problem = krb5_cc_get_principal(context, ccache, &creds.client);
+ if (problem)
+ goto out;
+
+ remotehost = get_canonical_hostname(1);
+
+#ifdef HEIMDAL
+ problem = krb5_build_principal(context, &creds.server,
+ strlen(creds.client->realm), creds.client->realm,
+ "krbtgt", creds.client->realm, NULL);
+#else
+ problem = krb5_build_principal(context, &creds.server,
+ creds.client->realm.length, creds.client->realm.data,
+ "host", remotehost, NULL);
+#endif
+ if (problem)
+ goto out;
+
+ creds.times.endtime = 0;
+
+#ifdef HEIMDAL
+ flags.i = 0;
+ flags.b.forwarded = 1;
+ flags.b.forwardable = krb5_config_get_bool(context, NULL,
+ "libdefaults", "forwardable", NULL);
+ problem = krb5_get_forwarded_creds(context, auth_context,
+ ccache, flags.i, remotehost, &creds, &outbuf);
+#else
+ forwardable = 1;
+ problem = krb5_fwd_tgt_creds(context, auth_context, remotehost,
+ creds.client, creds.server, ccache, forwardable, &outbuf);
+#endif
+
+ if (problem)
+ goto out;
+
+ packet_start(SSH_CMSG_HAVE_KERBEROS_TGT);
+ packet_put_string((char *)outbuf.data, outbuf.length);
+ packet_send();
+ packet_write_wait();
+
+ type = packet_read();
+
+ if (type == SSH_SMSG_SUCCESS) {
+ char *pname;
+
+ krb5_unparse_name(context, creds.client, &pname);
+ debug("Kerberos v5 TGT forwarded (%s).", pname);
+ xfree(pname);
+ } else
+ debug("Kerberos v5 TGT forwarding failed.");
+
+ return;
+
+ out:
+ if (problem)
+ debug("Kerberos v5 TGT forwarding failed: %s",
+ krb5_get_err_text(context, problem));
+ if (creds.client)
+ krb5_free_principal(context, creds.client);
+ if (creds.server)
+ krb5_free_principal(context, creds.server);
+ if (ccache)
+ krb5_cc_close(context, ccache);
+ if (outbuf.data)
+ xfree(outbuf.data);
+}
+#endif /* KRB5 */
+
+#ifdef AFS
+static void
+send_krb4_tgt(void)
+{
+ CREDENTIALS *creds;
+ struct stat st;
+ char buffer[4096], pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
+ int problem, type;
+
+ /* Don't do anything if we don't have any tickets. */
+ if (stat(tkt_string(), &st) < 0)
+ return;
+
+ creds = xmalloc(sizeof(*creds));
+
+ problem = krb_get_tf_fullname(TKT_FILE, pname, pinst, prealm);
+ if (problem)
+ goto out;
+
+ problem = krb_get_cred("krbtgt", prealm, prealm, creds);
+ if (problem)
+ goto out;
+
+ if (time(0) > krb_life_to_time(creds->issue_date, creds->lifetime)) {
+ problem = RD_AP_EXP;
+ goto out;
+ }
+ creds_to_radix(creds, (u_char *)buffer, sizeof(buffer));
+
+ packet_start(SSH_CMSG_HAVE_KERBEROS_TGT);
+ packet_put_cstring(buffer);
+ packet_send();
+ packet_write_wait();
+
+ type = packet_read();
+
+ if (type == SSH_SMSG_SUCCESS)
+ debug("Kerberos v4 TGT forwarded (%s%s%s@%s).",
+ creds->pname, creds->pinst[0] ? "." : "",
+ creds->pinst, creds->realm);
+ else
+ debug("Kerberos v4 TGT rejected.");
+
+ xfree(creds);
+ return;
+
+ out:
+ debug("Kerberos v4 TGT passing failed: %s", krb_err_txt[problem]);
+ xfree(creds);
+}
+
+static void
+send_afs_tokens(void)
+{
+ CREDENTIALS creds;
+ struct ViceIoctl parms;
+ struct ClearToken ct;
+ int i, type, len;
+ char buf[2048], *p, *server_cell;
+ char buffer[8192];
+
+ /* Move over ktc_GetToken, here's something leaner. */
+ for (i = 0; i < 100; i++) { /* just in case */
+ parms.in = (char *) &i;
+ parms.in_size = sizeof(i);
+ parms.out = buf;
+ parms.out_size = sizeof(buf);
+ if (k_pioctl(0, VIOCGETTOK, &parms, 0) != 0)
+ break;
+ p = buf;
+
+ /* Get secret token. */
+ memcpy(&creds.ticket_st.length, p, sizeof(u_int));
+ if (creds.ticket_st.length > MAX_KTXT_LEN)
+ break;
+ p += sizeof(u_int);
+ memcpy(creds.ticket_st.dat, p, creds.ticket_st.length);
+ p += creds.ticket_st.length;
+
+ /* Get clear token. */
+ memcpy(&len, p, sizeof(len));
+ if (len != sizeof(struct ClearToken))
+ break;
+ p += sizeof(len);
+ memcpy(&ct, p, len);
+ p += len;
+ p += sizeof(len); /* primary flag */
+ server_cell = p;
+
+ /* Flesh out our credentials. */
+ strlcpy(creds.service, "afs", sizeof(creds.service));
+ creds.instance[0] = '\0';
+ strlcpy(creds.realm, server_cell, REALM_SZ);
+ memcpy(creds.session, ct.HandShakeKey, DES_KEY_SZ);
+ creds.issue_date = ct.BeginTimestamp;
+ creds.lifetime = krb_time_to_life(creds.issue_date,
+ ct.EndTimestamp);
+ creds.kvno = ct.AuthHandle;
+ snprintf(creds.pname, sizeof(creds.pname), "AFS ID %d", ct.ViceId);
+ creds.pinst[0] = '\0';
+
+ /* Encode token, ship it off. */
+ if (creds_to_radix(&creds, (u_char *)buffer,
+ sizeof(buffer)) <= 0)
+ break;
+ packet_start(SSH_CMSG_HAVE_AFS_TOKEN);
+ packet_put_cstring(buffer);
+ packet_send();
+ packet_write_wait();
+
+ /* Roger, Roger. Clearance, Clarence. What's your vector,
+ Victor? */
+ type = packet_read();
+
+ if (type == SSH_SMSG_FAILURE)
+ debug("AFS token for cell %s rejected.", server_cell);
+ else if (type != SSH_SMSG_SUCCESS)
+ packet_disconnect("Protocol error on AFS token response: %d", type);
+ }
+}
+
+#endif /* AFS */
+
/*
* Tries to authenticate with any string-based challenge/response system.
* Note that the client code is not tied to s/key or TIS.
@@ -404,7 +890,7 @@ try_challenge_response_authentication(void)
if (i != 0)
error("Permission denied, please try again.");
if (options.cipher == SSH_CIPHER_NONE)
- logit("WARNING: Encryption is disabled! "
+ log("WARNING: Encryption is disabled! "
"Response will be transmitted in clear text.");
response = read_passphrase(prompt, 0);
if (strcmp(response, "") == 0) {
@@ -439,7 +925,7 @@ try_password_authentication(char *prompt)
debug("Doing password authentication.");
if (options.cipher == SSH_CIPHER_NONE)
- logit("WARNING: Encryption is disabled! Password will be transmitted in clear text.");
+ log("WARNING: Encryption is disabled! Password will be transmitted in clear text.");
for (i = 0; i < options.number_of_password_prompts; i++) {
if (i != 0)
error("Permission denied, please try again.");
@@ -495,9 +981,9 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
rbits = BN_num_bits(server_key->rsa->n);
if (bits != rbits) {
- logit("Warning: Server lies about size of server public key: "
+ log("Warning: Server lies about size of server public key: "
"actual size is %d bits vs. announced %d.", rbits, bits);
- logit("Warning: This may be due to an old implementation of ssh.");
+ log("Warning: This may be due to an old implementation of ssh.");
}
/* Get the host key. */
host_key = key_new(KEY_RSA1);
@@ -507,9 +993,9 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
rbits = BN_num_bits(host_key->rsa->n);
if (bits != rbits) {
- logit("Warning: Server lies about size of server host key: "
+ log("Warning: Server lies about size of server host key: "
"actual size is %d bits vs. announced %d.", rbits, bits);
- logit("Warning: This may be due to an old implementation of ssh.");
+ log("Warning: This may be due to an old implementation of ssh.");
}
/* Get protocol flags. */
@@ -600,7 +1086,7 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
options.cipher = ssh_cipher_default;
} else if (options.cipher == SSH_CIPHER_ILLEGAL ||
!(cipher_mask_ssh1(1) & (1 << options.cipher))) {
- logit("No valid SSH1 cipher, using %.100s instead.",
+ log("No valid SSH1 cipher, using %.100s instead.",
cipher_name(ssh_cipher_default));
options.cipher = ssh_cipher_default;
}
@@ -654,6 +1140,10 @@ void
ssh_userauth1(const char *local_user, const char *server_user, char *host,
Sensitive *sensitive)
{
+#ifdef KRB5
+ krb5_context context = NULL;
+ krb5_auth_context auth_context = NULL;
+#endif
int i, type;
if (supported_authentications == 0)
@@ -678,6 +1168,56 @@ ssh_userauth1(const char *local_user, const char *server_user, char *host,
if (type != SSH_SMSG_FAILURE)
packet_disconnect("Protocol error: got %d in response to SSH_CMSG_USER", type);
+#ifdef KRB5
+ if ((supported_authentications & (1 << SSH_AUTH_KERBEROS)) &&
+ options.kerberos_authentication) {
+ debug("Trying Kerberos v5 authentication.");
+
+ if (try_krb5_authentication(&context, &auth_context)) {
+ type = packet_read();
+ if (type == SSH_SMSG_SUCCESS)
+ goto success;
+ if (type != SSH_SMSG_FAILURE)
+ packet_disconnect("Protocol error: got %d in response to Kerberos v5 auth", type);
+ }
+ }
+#endif /* KRB5 */
+
+#ifdef KRB4
+ if ((supported_authentications & (1 << SSH_AUTH_KERBEROS)) &&
+ options.kerberos_authentication) {
+ debug("Trying Kerberos v4 authentication.");
+
+ if (try_krb4_authentication()) {
+ type = packet_read();
+ if (type == SSH_SMSG_SUCCESS)
+ goto success;
+ if (type != SSH_SMSG_FAILURE)
+ packet_disconnect("Protocol error: got %d in response to Kerberos v4 auth", type);
+ }
+ }
+#endif /* KRB4 */
+
+ /*
+ * Use rhosts authentication if running in privileged socket and we
+ * do not wish to remain anonymous.
+ */
+ if ((supported_authentications & (1 << SSH_AUTH_RHOSTS)) &&
+ options.rhosts_authentication) {
+ debug("Trying rhosts authentication.");
+ packet_start(SSH_CMSG_AUTH_RHOSTS);
+ packet_put_cstring(local_user);
+ packet_send();
+ packet_write_wait();
+
+ /* The server should respond with success or failure. */
+ type = packet_read();
+ if (type == SSH_SMSG_SUCCESS)
+ goto success;
+ if (type != SSH_SMSG_FAILURE)
+ packet_disconnect("Protocol error: got %d in response to rhosts auth",
+ type);
+ }
/*
* Try .rhosts or /etc/hosts.equiv authentication with RSA host
* authentication.
@@ -731,5 +1271,36 @@ ssh_userauth1(const char *local_user, const char *server_user, char *host,
/* NOTREACHED */
success:
+#ifdef KRB5
+ /* Try Kerberos v5 TGT passing. */
+ if ((supported_authentications & (1 << SSH_PASS_KERBEROS_TGT)) &&
+ options.kerberos_tgt_passing && context && auth_context) {
+ if (options.cipher == SSH_CIPHER_NONE)
+ log("WARNING: Encryption is disabled! Ticket will be transmitted in the clear!");
+ send_krb5_tgt(context, auth_context);
+ }
+ if (auth_context)
+ krb5_auth_con_free(context, auth_context);
+ if (context)
+ krb5_free_context(context);
+#endif
+
+#ifdef AFS
+ /* Try Kerberos v4 TGT passing if the server supports it. */
+ if ((supported_authentications & (1 << SSH_PASS_KERBEROS_TGT)) &&
+ options.kerberos_tgt_passing) {
+ if (options.cipher == SSH_CIPHER_NONE)
+ log("WARNING: Encryption is disabled! Ticket will be transmitted in the clear!");
+ send_krb4_tgt();
+ }
+ /* Try AFS token passing if the server supports it. */
+ if ((supported_authentications & (1 << SSH_PASS_AFS_TOKEN)) &&
+ options.afs_token_passing && k_hasafs()) {
+ if (options.cipher == SSH_CIPHER_NONE)
+ log("WARNING: Encryption is disabled! Token will be transmitted in the clear!");
+ send_afs_tokens();
+ }
+#endif /* AFS */
+
return; /* need statement after label */
}
diff --git a/crypto/openssh/sshconnect2.c b/crypto/openssh/sshconnect2.c
index 933c223..642b34b 100644
--- a/crypto/openssh/sshconnect2.c
+++ b/crypto/openssh/sshconnect2.c
@@ -23,9 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect2.c,v 1.124 2003/08/25 10:33:33 djm Exp $");
-
-#include "openbsd-compat/sys-queue.h"
+RCSID("$OpenBSD: sshconnect2.c,v 1.114 2003/04/01 10:22:21 markus Exp $");
#include "ssh.h"
#include "ssh2.h"
@@ -50,10 +48,6 @@ RCSID("$OpenBSD: sshconnect2.c,v 1.124 2003/08/25 10:33:33 djm Exp $");
#include "msg.h"
#include "pathnames.h"
-#ifdef GSSAPI
-#include "ssh-gss.h"
-#endif
-
/* import */
extern char *client_version_string;
extern char *server_version_string;
@@ -64,7 +58,7 @@ extern Options options;
*/
u_char *session_id2 = NULL;
-u_int session_id2_len = 0;
+int session_id2_len = 0;
char *xxx_host;
struct sockaddr *xxx_hostaddr;
@@ -88,7 +82,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
xxx_hostaddr = hostaddr;
if (options.ciphers == (char *)-1) {
- logit("No valid ciphers for protocol version 2 given, using defaults.");
+ log("No valid ciphers for protocol version 2 given, using defaults.");
options.ciphers = NULL;
}
if (options.ciphers != NULL) {
@@ -114,9 +108,6 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
options.hostkeyalgorithms;
- if (options.rekey_limit)
- packet_set_rekey_limit(options.rekey_limit);
-
/* start key exchange */
kex = kex_setup(myproposal);
kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
@@ -147,18 +138,10 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
typedef struct Authctxt Authctxt;
typedef struct Authmethod Authmethod;
-typedef struct identity Identity;
-typedef struct idlist Idlist;
-
-struct identity {
- TAILQ_ENTRY(identity) next;
- AuthenticationConnection *ac; /* set if agent supports key */
- Key *key; /* public/private key */
- char *filename; /* comment for agent-only keys */
- int tried;
- int isprivate; /* key points to the private key */
-};
-TAILQ_HEAD(idlist, identity);
+
+typedef int sign_cb_fn(
+ Authctxt *authctxt, Key *key,
+ u_char **sigp, u_int *lenp, u_char *data, u_int datalen);
struct Authctxt {
const char *server_user;
@@ -169,14 +152,14 @@ struct Authctxt {
int success;
char *authlist;
/* pubkey */
- Idlist keys;
+ Key *last_key;
+ sign_cb_fn *last_key_sign;
+ int last_key_hint;
AuthenticationConnection *agent;
/* hostbased */
Sensitive *sensitive;
/* kbd-interactive */
int info_req_seen;
- /* generic */
- void *methoddata;
};
struct Authmethod {
char *name; /* string to compare against server's list */
@@ -198,35 +181,17 @@ int userauth_pubkey(Authctxt *);
int userauth_passwd(Authctxt *);
int userauth_kbdint(Authctxt *);
int userauth_hostbased(Authctxt *);
-int userauth_kerberos(Authctxt *);
-
-#ifdef GSSAPI
-int userauth_gssapi(Authctxt *authctxt);
-void input_gssapi_response(int type, u_int32_t, void *);
-void input_gssapi_token(int type, u_int32_t, void *);
-void input_gssapi_hash(int type, u_int32_t, void *);
-void input_gssapi_error(int, u_int32_t, void *);
-void input_gssapi_errtok(int, u_int32_t, void *);
-#endif
void userauth(Authctxt *, char *);
-static int sign_and_send_pubkey(Authctxt *, Identity *);
-static void pubkey_prepare(Authctxt *);
-static void pubkey_cleanup(Authctxt *);
-static Key *load_identity_file(char *);
+static int sign_and_send_pubkey(Authctxt *, Key *, sign_cb_fn *);
+static void clear_auth_state(Authctxt *);
static Authmethod *authmethod_get(char *authlist);
static Authmethod *authmethod_lookup(const char *name);
static char *authmethods_get(void);
Authmethod authmethods[] = {
-#ifdef GSSAPI
- {"gssapi",
- userauth_gssapi,
- &options.gss_authentication,
- NULL},
-#endif
{"hostbased",
userauth_hostbased,
&options.hostbased_authentication,
@@ -283,7 +248,7 @@ ssh_userauth2(const char *local_user, const char *server_user, char *host,
/* setup authentication context */
memset(&authctxt, 0, sizeof(authctxt));
- pubkey_prepare(&authctxt);
+ authctxt.agent = ssh_get_authentication_connection();
authctxt.server_user = server_user;
authctxt.local_user = local_user;
authctxt.host = host;
@@ -291,7 +256,6 @@ ssh_userauth2(const char *local_user, const char *server_user, char *host,
authctxt.success = 0;
authctxt.method = authmethod_lookup("none");
authctxt.authlist = NULL;
- authctxt.methoddata = NULL;
authctxt.sensitive = sensitive;
authctxt.info_req_seen = 0;
if (authctxt.method == NULL)
@@ -306,19 +270,14 @@ ssh_userauth2(const char *local_user, const char *server_user, char *host,
dispatch_set(SSH2_MSG_USERAUTH_BANNER, &input_userauth_banner);
dispatch_run(DISPATCH_BLOCK, &authctxt.success, &authctxt); /* loop until success */
- pubkey_cleanup(&authctxt);
- dispatch_range(SSH2_MSG_USERAUTH_MIN, SSH2_MSG_USERAUTH_MAX, NULL);
+ if (authctxt.agent != NULL)
+ ssh_close_authentication_connection(authctxt.agent);
debug("Authentication succeeded (%s).", authctxt.method->name);
}
-
void
userauth(Authctxt *authctxt, char *authlist)
{
- if (authctxt->methoddata) {
- xfree(authctxt->methoddata);
- authctxt->methoddata = NULL;
- }
if (authlist == NULL) {
authlist = authctxt->authlist;
} else {
@@ -331,12 +290,6 @@ userauth(Authctxt *authctxt, char *authlist)
if (method == NULL)
fatal("Permission denied (%s).", authlist);
authctxt->method = method;
-
- /* reset the per method handler */
- dispatch_range(SSH2_MSG_USERAUTH_PER_METHOD_MIN,
- SSH2_MSG_USERAUTH_PER_METHOD_MAX, NULL);
-
- /* and try new method */
if (method->userauth(authctxt) != 0) {
debug2("we sent a %s packet, wait for reply", method->name);
break;
@@ -361,7 +314,7 @@ input_userauth_banner(int type, u_int32_t seq, void *ctxt)
debug3("input_userauth_banner");
msg = packet_get_string(NULL);
lang = packet_get_string(NULL);
- logit("%s", msg);
+ fprintf(stderr, "%s", msg);
xfree(msg);
xfree(lang);
}
@@ -374,8 +327,7 @@ input_userauth_success(int type, u_int32_t seq, void *ctxt)
fatal("input_userauth_success: no authentication context");
if (authctxt->authlist)
xfree(authctxt->authlist);
- if (authctxt->methoddata)
- xfree(authctxt->methoddata);
+ clear_auth_state(authctxt);
authctxt->success = 1; /* break out */
}
@@ -394,9 +346,10 @@ input_userauth_failure(int type, u_int32_t seq, void *ctxt)
packet_check_eom();
if (partial != 0)
- logit("Authenticated with partial success.");
+ log("Authenticated with partial success.");
debug("Authentications that can continue: %s", authlist);
+ clear_auth_state(authctxt);
userauth(authctxt, authlist);
}
void
@@ -404,7 +357,6 @@ input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt)
{
Authctxt *authctxt = ctxt;
Key *key = NULL;
- Identity *id = NULL;
Buffer b;
int pktype, sent = 0;
u_int alen, blen;
@@ -427,267 +379,55 @@ input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt)
}
packet_check_eom();
- debug("Server accepts key: pkalg %s blen %u", pkalg, blen);
-
- if ((pktype = key_type_from_name(pkalg)) == KEY_UNSPEC) {
- debug("unknown pkalg %s", pkalg);
- goto done;
- }
- if ((key = key_from_blob(pkblob, blen)) == NULL) {
- debug("no key from blob. pkalg %s", pkalg);
- goto done;
- }
- if (key->type != pktype) {
- error("input_userauth_pk_ok: type mismatch "
- "for decoded key (received %d, expected %d)",
- key->type, pktype);
- goto done;
- }
- fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
- debug2("input_userauth_pk_ok: fp %s", fp);
- xfree(fp);
+ debug("Server accepts key: pkalg %s blen %u lastkey %p hint %d",
+ pkalg, blen, authctxt->last_key, authctxt->last_key_hint);
- TAILQ_FOREACH(id, &authctxt->keys, next) {
- if (key_equal(key, id->key)) {
- sent = sign_and_send_pubkey(authctxt, id);
+ do {
+ if (authctxt->last_key == NULL ||
+ authctxt->last_key_sign == NULL) {
+ debug("no last key or no sign cb");
break;
}
- }
-done:
+ if ((pktype = key_type_from_name(pkalg)) == KEY_UNSPEC) {
+ debug("unknown pkalg %s", pkalg);
+ break;
+ }
+ if ((key = key_from_blob(pkblob, blen)) == NULL) {
+ debug("no key from blob. pkalg %s", pkalg);
+ break;
+ }
+ if (key->type != pktype) {
+ error("input_userauth_pk_ok: type mismatch "
+ "for decoded key (received %d, expected %d)",
+ key->type, pktype);
+ break;
+ }
+ fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
+ debug2("input_userauth_pk_ok: fp %s", fp);
+ xfree(fp);
+ if (!key_equal(key, authctxt->last_key)) {
+ debug("key != last_key");
+ break;
+ }
+ sent = sign_and_send_pubkey(authctxt, key,
+ authctxt->last_key_sign);
+ } while (0);
+
if (key != NULL)
key_free(key);
xfree(pkalg);
xfree(pkblob);
+ /* unregister */
+ clear_auth_state(authctxt);
+ dispatch_set(SSH2_MSG_USERAUTH_PK_OK, NULL);
+
/* try another method if we did not send a packet */
if (sent == 0)
userauth(authctxt, NULL);
-}
-
-#ifdef GSSAPI
-int
-userauth_gssapi(Authctxt *authctxt)
-{
- Gssctxt *gssctxt = NULL;
- static gss_OID_set supported = NULL;
- static int mech = 0;
- OM_uint32 min;
- int ok = 0;
-
- /* Try one GSSAPI method at a time, rather than sending them all at
- * once. */
-
- if (supported == NULL)
- gss_indicate_mechs(&min, &supported);
-
- /* Check to see if the mechanism is usable before we offer it */
- while (mech<supported->count && !ok) {
- if (gssctxt)
- ssh_gssapi_delete_ctx(&gssctxt);
- ssh_gssapi_build_ctx(&gssctxt);
- ssh_gssapi_set_oid(gssctxt, &supported->elements[mech]);
-
- /* My DER encoding requires length<128 */
- if (supported->elements[mech].length < 128 &&
- !GSS_ERROR(ssh_gssapi_import_name(gssctxt,
- authctxt->host))) {
- ok = 1; /* Mechanism works */
- } else {
- mech++;
- }
- }
-
- if (!ok) return 0;
-
- authctxt->methoddata=(void *)gssctxt;
-
- packet_start(SSH2_MSG_USERAUTH_REQUEST);
- packet_put_cstring(authctxt->server_user);
- packet_put_cstring(authctxt->service);
- packet_put_cstring(authctxt->method->name);
- packet_put_int(1);
-
- /* Some servers encode the OID incorrectly (as we used to) */
- if (datafellows & SSH_BUG_GSSAPI_BER) {
- packet_put_string(supported->elements[mech].elements,
- supported->elements[mech].length);
- } else {
- packet_put_int((supported->elements[mech].length)+2);
- packet_put_char(SSH_GSS_OIDTYPE);
- packet_put_char(supported->elements[mech].length);
- packet_put_raw(supported->elements[mech].elements,
- supported->elements[mech].length);
- }
-
- packet_send();
-
- dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_RESPONSE, &input_gssapi_response);
- dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, &input_gssapi_token);
- dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_ERROR, &input_gssapi_error);
- dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, &input_gssapi_errtok);
-
- mech++; /* Move along to next candidate */
-
- return 1;
-}
-
-void
-input_gssapi_response(int type, u_int32_t plen, void *ctxt)
-{
- Authctxt *authctxt = ctxt;
- Gssctxt *gssctxt;
- OM_uint32 status, ms;
- int oidlen;
- char *oidv;
- gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
-
- if (authctxt == NULL)
- fatal("input_gssapi_response: no authentication context");
- gssctxt = authctxt->methoddata;
-
- /* Setup our OID */
- oidv = packet_get_string(&oidlen);
-
- if (datafellows & SSH_BUG_GSSAPI_BER) {
- if (!ssh_gssapi_check_oid(gssctxt, oidv, oidlen))
- fatal("Server returned different OID than expected");
- } else {
- if(oidv[0] != SSH_GSS_OIDTYPE || oidv[1] != oidlen-2) {
- debug("Badly encoded mechanism OID received");
- userauth(authctxt, NULL);
- xfree(oidv);
- return;
- }
- if (!ssh_gssapi_check_oid(gssctxt, oidv+2, oidlen-2))
- fatal("Server returned different OID than expected");
- }
-
- packet_check_eom();
-
- xfree(oidv);
-
- status = ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds,
- GSS_C_NO_BUFFER, &send_tok, NULL);
- if (GSS_ERROR(status)) {
- if (send_tok.length > 0) {
- packet_start(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK);
- packet_put_string(send_tok.value, send_tok.length);
- packet_send();
- gss_release_buffer(&ms, &send_tok);
- }
- /* Start again with next method on list */
- debug("Trying to start again");
- userauth(authctxt, NULL);
- return;
- }
-
- /* We must have data to send */
- packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN);
- packet_put_string(send_tok.value, send_tok.length);
- packet_send();
- gss_release_buffer(&ms, &send_tok);
}
-void
-input_gssapi_token(int type, u_int32_t plen, void *ctxt)
-{
- Authctxt *authctxt = ctxt;
- Gssctxt *gssctxt;
- gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
- gss_buffer_desc recv_tok;
- OM_uint32 status, ms;
- u_int slen;
-
- if (authctxt == NULL)
- fatal("input_gssapi_response: no authentication context");
- gssctxt = authctxt->methoddata;
-
- recv_tok.value = packet_get_string(&slen);
- recv_tok.length = slen; /* safe typecast */
-
- packet_check_eom();
-
- status=ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds,
- &recv_tok, &send_tok, NULL);
-
- xfree(recv_tok.value);
-
- if (GSS_ERROR(status)) {
- if (send_tok.length > 0) {
- packet_start(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK);
- packet_put_string(send_tok.value, send_tok.length);
- packet_send();
- gss_release_buffer(&ms, &send_tok);
- }
- /* Start again with the next method in the list */
- userauth(authctxt, NULL);
- return;
- }
-
- if (send_tok.length > 0) {
- packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN);
- packet_put_string(send_tok.value, send_tok.length);
- packet_send();
- gss_release_buffer(&ms, &send_tok);
- }
-
- if (status == GSS_S_COMPLETE) {
- /* If that succeeded, send a exchange complete message */
- packet_start(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE);
- packet_send();
- }
-}
-
-void
-input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)
-{
- Authctxt *authctxt = ctxt;
- Gssctxt *gssctxt;
- gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
- gss_buffer_desc recv_tok;
- OM_uint32 status, ms;
- u_int len;
-
- if (authctxt == NULL)
- fatal("input_gssapi_response: no authentication context");
- gssctxt = authctxt->methoddata;
-
- recv_tok.value = packet_get_string(&len);
- recv_tok.length = len;
-
- packet_check_eom();
-
- /* Stick it into GSSAPI and see what it says */
- status = ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds,
- &recv_tok, &send_tok, NULL);
-
- xfree(recv_tok.value);
- gss_release_buffer(&ms, &send_tok);
-
- /* Server will be returning a failed packet after this one */
-}
-
-void
-input_gssapi_error(int type, u_int32_t plen, void *ctxt)
-{
- OM_uint32 maj, min;
- char *msg;
- char *lang;
-
- maj=packet_get_int();
- min=packet_get_int();
- msg=packet_get_string(NULL);
- lang=packet_get_string(NULL);
-
- packet_check_eom();
-
- debug("Server GSSAPI Error:\n%s\n", msg);
- xfree(msg);
- xfree(lang);
-}
-#endif /* GSSAPI */
-
int
userauth_none(Authctxt *authctxt)
{
@@ -751,7 +491,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
info = packet_get_string(NULL);
lang = packet_get_string(NULL);
if (strlen(info) > 0)
- logit("%s", info);
+ log("%s", info);
xfree(info);
xfree(lang);
packet_start(SSH2_MSG_USERAUTH_REQUEST);
@@ -783,7 +523,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
if (strcmp(password, retype) != 0) {
memset(password, 0, strlen(password));
xfree(password);
- logit("Mismatch; try again, EOF to quit.");
+ log("Mismatch; try again, EOF to quit.");
password = NULL;
}
memset(retype, 0, strlen(retype));
@@ -799,44 +539,34 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
&input_userauth_passwd_changereq);
}
-static int
-identity_sign(Identity *id, u_char **sigp, u_int *lenp,
- u_char *data, u_int datalen)
+static void
+clear_auth_state(Authctxt *authctxt)
{
- Key *prv;
- int ret;
+ /* XXX clear authentication state */
+ dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ, NULL);
- /* the agent supports this key */
- if (id->ac)
- return (ssh_agent_sign(id->ac, id->key, sigp, lenp,
- data, datalen));
- /*
- * we have already loaded the private key or
- * the private key is stored in external hardware
- */
- if (id->isprivate || (id->key->flags & KEY_FLAG_EXT))
- return (key_sign(id->key, sigp, lenp, data, datalen));
- /* load the private key from the file */
- if ((prv = load_identity_file(id->filename)) == NULL)
- return (-1);
- ret = key_sign(prv, sigp, lenp, data, datalen);
- key_free(prv);
- return (ret);
+ if (authctxt->last_key != NULL && authctxt->last_key_hint == -1) {
+ debug3("clear_auth_state: key_free %p", authctxt->last_key);
+ key_free(authctxt->last_key);
+ }
+ authctxt->last_key = NULL;
+ authctxt->last_key_hint = -2;
+ authctxt->last_key_sign = NULL;
}
static int
-sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
+sign_and_send_pubkey(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback)
{
Buffer b;
u_char *blob, *signature;
u_int bloblen, slen;
- u_int skip = 0;
+ int skip = 0;
int ret = -1;
int have_sig = 1;
debug3("sign_and_send_pubkey");
- if (key_to_blob(id->key, &blob, &bloblen) == 0) {
+ if (key_to_blob(k, &blob, &bloblen) == 0) {
/* we cannot handle this key */
debug3("sign_and_send_pubkey: cannot handle key");
return 0;
@@ -861,12 +591,12 @@ sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
} else {
buffer_put_cstring(&b, authctxt->method->name);
buffer_put_char(&b, have_sig);
- buffer_put_cstring(&b, key_ssh_name(id->key));
+ buffer_put_cstring(&b, key_ssh_name(k));
}
buffer_put_string(&b, blob, bloblen);
/* generate signature */
- ret = identity_sign(id, &signature, &slen,
+ ret = (*sign_callback)(authctxt, k, &signature, &slen,
buffer_ptr(&b), buffer_len(&b));
if (ret == -1) {
xfree(blob);
@@ -886,7 +616,7 @@ sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
buffer_put_cstring(&b, authctxt->method->name);
buffer_put_char(&b, have_sig);
if (!(datafellows & SSH_BUG_PKAUTH))
- buffer_put_cstring(&b, key_ssh_name(id->key));
+ buffer_put_cstring(&b, key_ssh_name(k));
buffer_put_string(&b, blob, bloblen);
}
xfree(blob);
@@ -910,19 +640,23 @@ sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
}
static int
-send_pubkey_test(Authctxt *authctxt, Identity *id)
+send_pubkey_test(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback,
+ int hint)
{
u_char *blob;
u_int bloblen, have_sig = 0;
debug3("send_pubkey_test");
- if (key_to_blob(id->key, &blob, &bloblen) == 0) {
+ if (key_to_blob(k, &blob, &bloblen) == 0) {
/* we cannot handle this key */
debug3("send_pubkey_test: cannot handle key");
return 0;
}
/* register callback for USERAUTH_PK_OK message */
+ authctxt->last_key_sign = sign_callback;
+ authctxt->last_key_hint = hint;
+ authctxt->last_key = k;
dispatch_set(SSH2_MSG_USERAUTH_PK_OK, &input_userauth_pk_ok);
packet_start(SSH2_MSG_USERAUTH_REQUEST);
@@ -931,7 +665,7 @@ send_pubkey_test(Authctxt *authctxt, Identity *id)
packet_put_cstring(authctxt->method->name);
packet_put_char(have_sig);
if (!(datafellows & SSH_BUG_PKAUTH))
- packet_put_cstring(key_ssh_name(id->key));
+ packet_put_cstring(key_ssh_name(k));
packet_put_string(blob, bloblen);
xfree(blob);
packet_send();
@@ -976,134 +710,103 @@ load_identity_file(char *filename)
return private;
}
-/*
- * try keys in the following order:
- * 1. agent keys that are found in the config file
- * 2. other agent keys
- * 3. keys that are only listed in the config file
- */
-static void
-pubkey_prepare(Authctxt *authctxt)
+static int
+identity_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, u_int *lenp,
+ u_char *data, u_int datalen)
{
- Identity *id;
- Idlist agent, files, *preferred;
- Key *key;
- AuthenticationConnection *ac;
- char *comment;
- int i, found;
-
- TAILQ_INIT(&agent); /* keys from the agent */
- TAILQ_INIT(&files); /* keys from the config file */
- preferred = &authctxt->keys;
- TAILQ_INIT(preferred); /* preferred order of keys */
-
- /* list of keys stored in the filesystem */
- for (i = 0; i < options.num_identity_files; i++) {
- key = options.identity_keys[i];
- if (key && key->type == KEY_RSA1)
- continue;
- options.identity_keys[i] = NULL;
- id = xmalloc(sizeof(*id));
- memset(id, 0, sizeof(*id));
- id->key = key;
- id->filename = xstrdup(options.identity_files[i]);
- TAILQ_INSERT_TAIL(&files, id, next);
- }
- /* list of keys supported by the agent */
- if ((ac = ssh_get_authentication_connection())) {
- for (key = ssh_get_first_identity(ac, &comment, 2);
- key != NULL;
- key = ssh_get_next_identity(ac, &comment, 2)) {
- found = 0;
- TAILQ_FOREACH(id, &files, next) {
- /* agent keys from the config file are preferred */
- if (key_equal(key, id->key)) {
- key_free(key);
- xfree(comment);
- TAILQ_REMOVE(&files, id, next);
- TAILQ_INSERT_TAIL(preferred, id, next);
- id->ac = ac;
- found = 1;
- break;
- }
- }
- if (!found) {
- id = xmalloc(sizeof(*id));
- memset(id, 0, sizeof(*id));
- id->key = key;
- id->filename = comment;
- id->ac = ac;
- TAILQ_INSERT_TAIL(&agent, id, next);
- }
- }
- /* append remaining agent keys */
- for (id = TAILQ_FIRST(&agent); id; id = TAILQ_FIRST(&agent)) {
- TAILQ_REMOVE(&agent, id, next);
- TAILQ_INSERT_TAIL(preferred, id, next);
- }
- authctxt->agent = ac;
- }
- /* append remaining keys from the config file */
- for (id = TAILQ_FIRST(&files); id; id = TAILQ_FIRST(&files)) {
- TAILQ_REMOVE(&files, id, next);
- TAILQ_INSERT_TAIL(preferred, id, next);
- }
- TAILQ_FOREACH(id, preferred, next) {
- debug2("key: %s (%p)", id->filename, id->key);
- }
+ Key *private;
+ int idx, ret;
+
+ idx = authctxt->last_key_hint;
+ if (idx < 0)
+ return -1;
+
+ /* private key is stored in external hardware */
+ if (options.identity_keys[idx]->flags & KEY_FLAG_EXT)
+ return key_sign(options.identity_keys[idx], sigp, lenp, data, datalen);
+
+ private = load_identity_file(options.identity_files[idx]);
+ if (private == NULL)
+ return -1;
+ ret = key_sign(private, sigp, lenp, data, datalen);
+ key_free(private);
+ return ret;
}
-static void
-pubkey_cleanup(Authctxt *authctxt)
+static int
+agent_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, u_int *lenp,
+ u_char *data, u_int datalen)
+{
+ return ssh_agent_sign(authctxt->agent, key, sigp, lenp, data, datalen);
+}
+
+static int
+key_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, u_int *lenp,
+ u_char *data, u_int datalen)
{
- Identity *id;
-
- if (authctxt->agent != NULL)
- ssh_close_authentication_connection(authctxt->agent);
- for (id = TAILQ_FIRST(&authctxt->keys); id;
- id = TAILQ_FIRST(&authctxt->keys)) {
- TAILQ_REMOVE(&authctxt->keys, id, next);
- if (id->key)
- key_free(id->key);
- if (id->filename)
- xfree(id->filename);
- xfree(id);
+ return key_sign(key, sigp, lenp, data, datalen);
+}
+
+static int
+userauth_pubkey_agent(Authctxt *authctxt)
+{
+ static int called = 0;
+ int ret = 0;
+ char *comment;
+ Key *k;
+
+ if (called == 0) {
+ if (ssh_get_num_identities(authctxt->agent, 2) == 0)
+ debug2("userauth_pubkey_agent: no keys at all");
+ called = 1;
+ }
+ k = ssh_get_next_identity(authctxt->agent, &comment, 2);
+ if (k == NULL) {
+ debug2("userauth_pubkey_agent: no more keys");
+ } else {
+ debug("Offering agent key: %s", comment);
+ xfree(comment);
+ ret = send_pubkey_test(authctxt, k, agent_sign_cb, -1);
+ if (ret == 0)
+ key_free(k);
}
+ if (ret == 0)
+ debug2("userauth_pubkey_agent: no message sent");
+ return ret;
}
int
userauth_pubkey(Authctxt *authctxt)
{
- Identity *id;
+ static int idx = 0;
int sent = 0;
+ Key *key;
+ char *filename;
- while ((id = TAILQ_FIRST(&authctxt->keys))) {
- if (id->tried++)
- return (0);
- TAILQ_REMOVE(&authctxt->keys, id, next);
- TAILQ_INSERT_TAIL(&authctxt->keys, id, next);
- /*
- * send a test message if we have the public key. for
- * encrypted keys we cannot do this and have to load the
- * private key instead
- */
- if (id->key && id->key->type != KEY_RSA1) {
- debug("Offering public key: %s", id->filename);
- sent = send_pubkey_test(authctxt, id);
- } else if (id->key == NULL) {
- debug("Trying private key: %s", id->filename);
- id->key = load_identity_file(id->filename);
- if (id->key != NULL) {
- id->isprivate = 1;
- sent = sign_and_send_pubkey(authctxt, id);
- key_free(id->key);
- id->key = NULL;
+ if (authctxt->agent != NULL) {
+ do {
+ sent = userauth_pubkey_agent(authctxt);
+ } while (!sent && authctxt->agent->howmany > 0);
+ }
+ while (!sent && idx < options.num_identity_files) {
+ key = options.identity_keys[idx];
+ filename = options.identity_files[idx];
+ if (key == NULL) {
+ debug("Trying private key: %s", filename);
+ key = load_identity_file(filename);
+ if (key != NULL) {
+ sent = sign_and_send_pubkey(authctxt, key,
+ key_sign_cb);
+ key_free(key);
}
+ } else if (key->type != KEY_RSA1) {
+ debug("Offering public key: %s", filename);
+ sent = send_pubkey_test(authctxt, key,
+ identity_sign_cb, idx);
}
- if (sent)
- return (sent);
+ idx++;
}
- return (0);
+ return sent;
}
/*
@@ -1159,9 +862,9 @@ input_userauth_info_req(int type, u_int32_t seq, void *ctxt)
inst = packet_get_string(NULL);
lang = packet_get_string(NULL);
if (strlen(name) > 0)
- logit("%s", name);
+ log("%s", name);
if (strlen(inst) > 0)
- logit("%s", inst);
+ log("%s", inst);
xfree(name);
xfree(inst);
xfree(lang);
diff --git a/crypto/openssh/sshd.8 b/crypto/openssh/sshd.8
index 0eeea66..b7eddc9 100644
--- a/crypto/openssh/sshd.8
+++ b/crypto/openssh/sshd.8
@@ -34,7 +34,8 @@
.\" (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: sshd.8,v 1.199 2003/08/13 08:46:31 markus Exp $
+.\" $OpenBSD: sshd.8,v 1.194 2003/01/31 21:54:40 jmc Exp $
+.\" $FreeBSD$
.Dd September 25, 1999
.Dt SSHD 8
.Os
@@ -67,7 +68,7 @@ install and use as possible.
.Nm
is the daemon that listens for connections from clients.
It is normally started at boot from
-.Pa /etc/rc .
+.Pa /etc/rc.d/sshd .
It forks a new
daemon for each incoming connection.
The forked daemons handle
@@ -114,29 +115,6 @@ authentication combined with RSA host
authentication, RSA challenge-response authentication, or password
based authentication.
.Pp
-Regardless of the authentication type, the account is checked to
-ensure that it is accessible. An account is not accessible if it is
-locked, listed in
-.Cm DenyUsers
-or its group is listed in
-.Cm DenyGroups
-\&. The definition of a locked account is system dependant. Some platforms
-have their own account database (eg AIX) and some modify the passwd field (
-.Ql \&*LK\&*
-on Solaris,
-.Ql \&*
-on HP-UX, containing
-.Ql Nologin
-on Tru64 and a leading
-.Ql \&!!
-on Linux). If there is a requirement to disable password authentication
-for the account while allowing still public-key, then the passwd field
-should be set to something other than these values (eg
-.Ql NP
-or
-.Ql \&*NP\&*
-).
-.Pp
Rhosts authentication is normally disabled
because it is fundamentally insecure, but can be enabled in the server
configuration file if desired.
@@ -243,8 +221,6 @@ host key files are normally not readable by anyone but root).
The default is
.Pa /etc/ssh/ssh_host_key
for protocol version 1, and
-.Pa /etc/ssh/ssh_host_rsa_key
-and
.Pa /etc/ssh/ssh_host_dsa_key
for protocol version 2.
It is possible to have multiple host key files for
@@ -315,6 +291,7 @@ may also be used to prevent
from making DNS requests unless the authentication
mechanism or configuration requires it.
Authentication mechanisms that may require DNS include
+.Cm RhostsAuthentication ,
.Cm RhostsRSAAuthentication ,
.Cm HostbasedAuthentication
and using a
@@ -367,8 +344,9 @@ section).
If the login is on a tty, records login time.
.It
Checks
-.Pa /etc/nologin ;
-if it exists, prints contents and quits
+.Pa /etc/nologin and
+.Pa /var/run/nologin ;
+if one exists, it prints the contents and quits
(unless root).
.It
Changes to run with normal user privileges.
@@ -390,11 +368,12 @@ If
exists, runs it; else if
.Pa /etc/ssh/sshrc
exists, runs
-it; otherwise runs xauth.
+it; otherwise runs
+.Xr xauth 1 .
The
.Dq rc
files are given the X11
-authentication protocol and cookie in standard input.
+authentication protocol and cookie (if applicable) in standard input.
.It
Runs user's shell or command.
.El
@@ -451,13 +430,13 @@ that option keywords are case-insensitive):
Specifies that in addition to public key authentication, the canonical name
of the remote host must be present in the comma-separated list of
patterns
-.Pf ( Ql \&*
+.Pf ( Ql *
and
-.Ql \&?
+.Ql ?
serve as wildcards).
The list may also contain
patterns negated by prefixing them with
-.Ql \&! ;
+.Ql ! ;
if the canonical host name matches a negated pattern, the key is not accepted.
The purpose
of this option is to optionally increase security: public key authentication
@@ -519,9 +498,9 @@ IPv6 addresses can be specified with an alternative syntax:
.Ar host/port .
Multiple
.Cm permitopen
-options may be applied separated by commas.
-No pattern matching is performed on the specified hostnames,
-they must be literal domains or addresses.
+options may be applied separated by commas. No pattern matching is
+performed on the specified hostnames, they must be literal domains or
+addresses.
.El
.Ss Examples
1024 33 12121.\|.\|.\|312314325 ylo@foo.bar
@@ -546,16 +525,12 @@ Each line in these files contains the following fields: hostnames,
bits, exponent, modulus, comment.
The fields are separated by spaces.
.Pp
-Hostnames is a comma-separated list of patterns
-.Pf ( Ql \&*
-and
-.Ql \&?
-act as
+Hostnames is a comma-separated list of patterns ('*' and '?' act as
wildcards); each pattern in turn is matched against the canonical host
name (when authenticating a client) or against the user-supplied
name (when authenticating a server).
A pattern may also be preceded by
-.Ql \&!
+.Ql !
to indicate negation: if the host name matches a negated
pattern, it is not accepted (by that line) even if it matched another
pattern on the line.
@@ -598,15 +573,15 @@ Contains configuration data for
.Nm sshd .
The file format and configuration options are described in
.Xr sshd_config 5 .
-.It Pa /etc/ssh/ssh_host_key, /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_rsa_key
-These three files contain the private parts of the host keys.
+.It Pa /etc/ssh/ssh_host_key, /etc/ssh/ssh_host_dsa_key
+These two files contain the private parts of the host keys.
These files should only be owned by root, readable only by root, and not
accessible to others.
Note that
.Nm
does not start if this file is group/world-accessible.
-.It Pa /etc/ssh/ssh_host_key.pub, /etc/ssh/ssh_host_dsa_key.pub, /etc/ssh/ssh_host_rsa_key.pub
-These three files contain the public parts of the host keys.
+.It Pa /etc/ssh/ssh_host_key.pub, /etc/ssh/ssh_host_dsa_key.pub
+These two files contain the public parts of the host keys.
These files should be world-readable but writable only by
root.
Their contents should match the respective private parts.
@@ -615,7 +590,7 @@ really used for anything; they are provided for the convenience of
the user so their contents can be copied to known hosts files.
These files are created using
.Xr ssh-keygen 1 .
-.It Pa /etc/moduli
+.It Pa /etc/ssh/moduli
Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
The file format is described in
.Xr moduli 5 .
@@ -727,7 +702,7 @@ The only valid use for user names that I can think
of is in negative entries.
.Pp
Note that this warning also applies to rsh/rlogin.
-.It Pa /etc/shosts.equiv
+.It Pa /etc/ssh/shosts.equiv
This is processed exactly as
.Pa /etc/hosts.equiv .
However, this file may be useful in environments that want to run both
@@ -793,6 +768,17 @@ This can be used to specify
machine-specific login-time initializations globally.
This file should be writable only by root, and should be world-readable.
.El
+.Sh AUTHORS
+OpenSSH is a derivative of the original and free
+ssh 1.2.12 release by Tatu Ylonen.
+Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
+Theo de Raadt and Dug Song
+removed many bugs, re-added newer features and
+created OpenSSH.
+Markus Friedl contributed the support for SSH
+protocol versions 1.5 and 2.0.
+Niels Provos and Markus Friedl contributed support
+for privilege separation.
.Sh SEE ALSO
.Xr scp 1 ,
.Xr sftp 1 ,
@@ -824,14 +810,3 @@ This file should be writable only by root, and should be world-readable.
.%D January 2002
.%O work in progress material
.Re
-.Sh AUTHORS
-OpenSSH is a derivative of the original and free
-ssh 1.2.12 release by Tatu Ylonen.
-Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
-Theo de Raadt and Dug Song
-removed many bugs, re-added newer features and
-created OpenSSH.
-Markus Friedl contributed the support for SSH
-protocol versions 1.5 and 2.0.
-Niels Provos and Markus Friedl contributed support
-for privilege separation.
diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index 47df9ca..bdf16d1 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -42,7 +42,8 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.276 2003/08/28 12:54:34 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.263 2003/02/16 17:09:57 markus Exp $");
+RCSID("$FreeBSD$");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -53,6 +54,10 @@ RCSID("$OpenBSD: sshd.c,v 1.276 2003/08/28 12:54:34 markus Exp $");
#include <prot.h>
#endif
+#ifdef __FreeBSD__
+#include <resolv.h>
+#endif
+
#include "ssh.h"
#include "ssh1.h"
#include "ssh2.h"
@@ -112,7 +117,11 @@ char *config_file_name = _PATH_SERVER_CONFIG_FILE;
* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
* Default value is AF_UNSPEC means both IPv4 and IPv6.
*/
+#ifdef IPV4_DEFAULT
+int IPv4or6 = AF_INET;
+#else
int IPv4or6 = AF_UNSPEC;
+#endif
/*
* Debug mode flag. This can be set on the command line. If debug
@@ -188,7 +197,7 @@ u_char session_id[16];
/* same for ssh2 */
u_char *session_id2 = NULL;
-u_int session_id2_len = 0;
+int session_id2_len = 0;
/* record remote hostname or ip */
u_int utmp_len = MAXHOSTNAMELEN;
@@ -201,9 +210,6 @@ int startup_pipe; /* in child */
int use_privsep;
struct monitor *pmonitor;
-/* message to be displayed after login */
-Buffer loginmsg;
-
/* Prototypes for various functions defined later in this file. */
void destroy_sensitive_data(void);
void demote_sensitive_data(void);
@@ -257,11 +263,11 @@ sighup_handler(int sig)
static void
sighup_restart(void)
{
- logit("Received SIGHUP; restarting.");
+ log("Received SIGHUP; restarting.");
close_listen_socks();
close_startup_pipes();
execv(saved_argv[0], saved_argv);
- logit("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0],
+ log("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0],
strerror(errno));
exit(1);
}
@@ -370,37 +376,39 @@ sshd_exchange_identification(int sock_in, int sock_out)
snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n", major, minor, SSH_VERSION);
server_version_string = xstrdup(buf);
- /* Send our protocol version identification. */
- if (atomicio(vwrite, sock_out, server_version_string,
- strlen(server_version_string))
- != strlen(server_version_string)) {
- logit("Could not write ident string to %s", get_remote_ipaddr());
- fatal_cleanup();
- }
-
- /* Read other sides version identification. */
- memset(buf, 0, sizeof(buf));
- for (i = 0; i < sizeof(buf) - 1; i++) {
- if (atomicio(read, sock_in, &buf[i], 1) != 1) {
- logit("Did not receive identification string from %s",
- get_remote_ipaddr());
+ if (client_version_string == NULL) {
+ /* Send our protocol version identification. */
+ if (atomicio(write, sock_out, server_version_string,
+ strlen(server_version_string))
+ != strlen(server_version_string)) {
+ log("Could not write ident string to %s", get_remote_ipaddr());
fatal_cleanup();
}
- if (buf[i] == '\r') {
- buf[i] = 0;
- /* Kludge for F-Secure Macintosh < 1.0.2 */
- if (i == 12 &&
- strncmp(buf, "SSH-1.5-W1.0", 12) == 0)
+
+ /* Read other sides version identification. */
+ memset(buf, 0, sizeof(buf));
+ for (i = 0; i < sizeof(buf) - 1; i++) {
+ if (atomicio(read, sock_in, &buf[i], 1) != 1) {
+ log("Did not receive identification string from %s",
+ get_remote_ipaddr());
+ fatal_cleanup();
+ }
+ if (buf[i] == '\r') {
+ buf[i] = 0;
+ /* Kludge for F-Secure Macintosh < 1.0.2 */
+ if (i == 12 &&
+ strncmp(buf, "SSH-1.5-W1.0", 12) == 0)
+ break;
+ continue;
+ }
+ if (buf[i] == '\n') {
+ buf[i] = 0;
break;
- continue;
- }
- if (buf[i] == '\n') {
- buf[i] = 0;
- break;
+ }
}
+ buf[sizeof(buf) - 1] = 0;
+ client_version_string = xstrdup(buf);
}
- buf[sizeof(buf) - 1] = 0;
- client_version_string = xstrdup(buf);
/*
* Check that the versions match. In future this might accept
@@ -409,10 +417,10 @@ sshd_exchange_identification(int sock_in, int sock_out)
if (sscanf(client_version_string, "SSH-%d.%d-%[^\n]\n",
&remote_major, &remote_minor, remote_version) != 3) {
s = "Protocol mismatch.\n";
- (void) atomicio(vwrite, sock_out, s, strlen(s));
+ (void) atomicio(write, sock_out, s, strlen(s));
close(sock_in);
close(sock_out);
- logit("Bad protocol version identification '%.100s' from %s",
+ log("Bad protocol version identification '%.100s' from %s",
client_version_string, get_remote_ipaddr());
fatal_cleanup();
}
@@ -422,13 +430,13 @@ sshd_exchange_identification(int sock_in, int sock_out)
compat_datafellows(remote_version);
if (datafellows & SSH_BUG_PROBE) {
- logit("probed from %s with %s. Don't panic.",
+ log("probed from %s with %s. Don't panic.",
get_remote_ipaddr(), client_version_string);
fatal_cleanup();
}
if (datafellows & SSH_BUG_SCANNER) {
- logit("scanned from %s with %s. Don't panic.",
+ log("scanned from %s with %s. Don't panic.",
get_remote_ipaddr(), client_version_string);
fatal_cleanup();
}
@@ -470,10 +478,10 @@ sshd_exchange_identification(int sock_in, int sock_out)
if (mismatch) {
s = "Protocol major versions differ.\n";
- (void) atomicio(vwrite, sock_out, s, strlen(s));
+ (void) atomicio(write, sock_out, s, strlen(s));
close(sock_in);
close(sock_out);
- logit("Protocol major versions differ for %s: %.200s vs. %.200s",
+ log("Protocol major versions differ for %s: %.200s vs. %.200s",
get_remote_ipaddr(),
server_version_string, client_version_string);
fatal_cleanup();
@@ -565,6 +573,8 @@ privsep_preauth_child(void)
do_setusercontext(pw);
#else
gidset[0] = pw->pw_gid;
+ if (setgid(pw->pw_gid) < 0)
+ fatal("setgid failed for %u", pw->pw_gid );
if (setgroups(1, gidset) < 0)
fatal("setgroups: %.100s", strerror(errno));
permanently_set_uid(pw);
@@ -819,27 +829,27 @@ main(int ac, char **av)
#ifdef HAVE_SECUREWARE
(void)set_auth_parameters(ac, av);
#endif
- __progname = ssh_get_progname(av[0]);
+ __progname = get_progname(av[0]);
init_rng();
/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
saved_argc = ac;
+ saved_argv = av;
saved_argv = xmalloc(sizeof(*saved_argv) * (ac + 1));
for (i = 0; i < ac; i++)
saved_argv[i] = xstrdup(av[i]);
- saved_argv[i] = NULL;
+ saved_argv[ac] = NULL;
#ifndef HAVE_SETPROCTITLE
/* Prepare for later setproctitle emulation */
compat_init_setproctitle(ac, av);
- av = saved_argv;
#endif
/* Initialize configuration options to their default values. */
initialize_server_options(&options);
/* Parse command-line arguments. */
- while ((opt = getopt(ac, av, "f:p:b:k:h:g:u:o:dDeiqtQ46")) != -1) {
+ while ((opt = getopt(ac, av, "f:p:b:k:h:g:V:u:o:dDeiqtQ46")) != -1) {
switch (opt) {
case '4':
IPv4or6 = AF_INET;
@@ -851,11 +861,15 @@ main(int ac, char **av)
config_file_name = optarg;
break;
case 'd':
- if (debug_flag == 0) {
+ if (0 == debug_flag) {
debug_flag = 1;
options.log_level = SYSLOG_LEVEL_DEBUG1;
- } else if (options.log_level < SYSLOG_LEVEL_DEBUG3)
+ } else if (options.log_level < SYSLOG_LEVEL_DEBUG3) {
options.log_level++;
+ } else {
+ fprintf(stderr, "Too high debugging level.\n");
+ exit(1);
+ }
break;
case 'D':
no_daemon_flag = 1;
@@ -906,6 +920,11 @@ main(int ac, char **av)
}
options.host_key_files[options.num_host_key_files++] = optarg;
break;
+ case 'V':
+ client_version_string = optarg;
+ /* only makes sense with inetd_flag, i.e. no listen() */
+ inetd_flag = 1;
+ break;
case 't':
test_flag = 1;
break;
@@ -997,15 +1016,15 @@ main(int ac, char **av)
key_type(key));
}
if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) {
- logit("Disabling protocol version 1. Could not load host key");
+ log("Disabling protocol version 1. Could not load host key");
options.protocol &= ~SSH_PROTO_1;
}
if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
- logit("Disabling protocol version 2. Could not load host key");
+ log("Disabling protocol version 2. Could not load host key");
options.protocol &= ~SSH_PROTO_2;
}
if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
- logit("sshd: no hostkeys available -- exiting.");
+ log("sshd: no hostkeys available -- exiting.");
exit(1);
}
@@ -1140,8 +1159,7 @@ main(int ac, char **av)
continue;
}
/* Create socket for listening. */
- listen_sock = socket(ai->ai_family, ai->ai_socktype,
- ai->ai_protocol);
+ listen_sock = socket(ai->ai_family, SOCK_STREAM, 0);
if (listen_sock < 0) {
/* kernel may not support ipv6 */
verbose("socket: %.100s", strerror(errno));
@@ -1174,7 +1192,7 @@ main(int ac, char **av)
num_listen_socks++;
/* Start listening on the port. */
- logit("Server listening on %s port %s.", ntop, strport);
+ log("Server listening on %s port %s.", ntop, strport);
if (listen(listen_sock, 5) < 0)
fatal("listen: %.100s", strerror(errno));
@@ -1209,10 +1227,7 @@ main(int ac, char **av)
* overwrite any old pid in the file.
*/
f = fopen(options.pid_file, "wb");
- if (f == NULL) {
- error("Couldn't create pid file \"%s\": %s",
- options.pid_file, strerror(errno));
- } else {
+ if (f) {
fprintf(f, "%ld\n", (long) getpid());
fclose(f);
}
@@ -1253,7 +1268,7 @@ main(int ac, char **av)
if (ret < 0 && errno != EINTR)
error("select: %.100s", strerror(errno));
if (received_sigterm) {
- logit("Received signal %d; terminating.",
+ log("Received signal %d; terminating.",
(int) received_sigterm);
close_listen_socks();
unlink(options.pid_file);
@@ -1391,11 +1406,11 @@ main(int ac, char **av)
* setlogin() affects the entire process group. We don't
* want the child to be able to affect the parent.
*/
-#if !defined(SSHD_ACQUIRES_CTTY)
+#if !defined(STREAMS_PUSH_ACQUIRES_CTTY)
/*
- * If setsid is called, on some platforms sshd will later acquire a
- * controlling terminal which will result in "could not set
- * controlling tty" errors.
+ * If setsid is called on Solaris, sshd will acquire the controlling
+ * terminal while pushing STREAMS modules. This will prevent the
+ * shell from acquiring it later.
*/
if (!debug_flag && !inetd_flag && setsid() < 0)
error("setsid: %.100s", strerror(errno));
@@ -1420,6 +1435,17 @@ main(int ac, char **av)
sizeof(on)) < 0)
error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));
+#ifdef __FreeBSD__
+ /*
+ * Initialize the resolver. This may not happen automatically
+ * before privsep chroot().
+ */
+ if ((_res.options & RES_INIT) == 0) {
+ debug("res_init()");
+ res_init();
+ }
+#endif
+
/*
* Register our connection. This turns encryption off because we do
* not have a key.
@@ -1462,12 +1488,37 @@ main(int ac, char **av)
alarm(options.login_grace_time);
sshd_exchange_identification(sock_in, sock_out);
+ /*
+ * Check that the connection comes from a privileged port.
+ * Rhosts-Authentication only makes sense from privileged
+ * programs. Of course, if the intruder has root access on his local
+ * machine, he can connect from any port. So do not use these
+ * authentication methods from machines that you do not trust.
+ */
+ if (options.rhosts_authentication &&
+ (remote_port >= IPPORT_RESERVED ||
+ remote_port < IPPORT_RESERVED / 2)) {
+ debug("Rhosts Authentication disabled, "
+ "originating port %d not trusted.", remote_port);
+ options.rhosts_authentication = 0;
+ }
+#if defined(KRB4) && !defined(KRB5)
+ if (!packet_connection_is_ipv4() &&
+ options.kerberos_authentication) {
+ debug("Kerberos Authentication disabled, only available for IPv4.");
+ options.kerberos_authentication = 0;
+ }
+#endif /* KRB4 && !KRB5 */
+#ifdef AFS
+ /* If machine has AFS, set process authentication group. */
+ if (k_hasafs()) {
+ k_setpag();
+ k_unlog();
+ }
+#endif /* AFS */
packet_set_nonblocking();
- /* prepare buffers to collect authentication messages */
- buffer_init(&loginmsg);
-
if (use_privsep)
if ((authctxt = privsep_preauth()) != NULL)
goto authenticated;
@@ -1509,8 +1560,7 @@ main(int ac, char **av)
verbose("Closing connection to %.100s", remote_ip);
#ifdef USE_PAM
- if (options.use_pam)
- finish_pam();
+ finish_pam();
#endif /* USE_PAM */
packet_close();
@@ -1622,10 +1672,24 @@ do_ssh1_kex(void)
/* Declare supported authentication types. */
auth_mask = 0;
+ if (options.rhosts_authentication)
+ auth_mask |= 1 << SSH_AUTH_RHOSTS;
if (options.rhosts_rsa_authentication)
auth_mask |= 1 << SSH_AUTH_RHOSTS_RSA;
if (options.rsa_authentication)
auth_mask |= 1 << SSH_AUTH_RSA;
+#if defined(KRB4) || defined(KRB5)
+ if (options.kerberos_authentication)
+ auth_mask |= 1 << SSH_AUTH_KERBEROS;
+#endif
+#if defined(AFS) || defined(KRB5)
+ if (options.kerberos_tgt_passing)
+ auth_mask |= 1 << SSH_PASS_KERBEROS_TGT;
+#endif
+#ifdef AFS
+ if (options.afs_token_passing)
+ auth_mask |= 1 << SSH_PASS_AFS_TOKEN;
+#endif
if (options.challenge_response_authentication == 1)
auth_mask |= 1 << SSH_AUTH_TIS;
if (options.password_authentication)
@@ -1703,7 +1767,7 @@ do_ssh1_kex(void)
u_char *buf = xmalloc(bytes);
MD5_CTX md;
- logit("do_connection: generating a fake encryption key");
+ log("do_connection: generating a fake encryption key");
BN_bn2bin(session_key_int, buf);
MD5_Init(&md);
MD5_Update(&md, buf, bytes);
diff --git a/crypto/openssh/sshd/Makefile b/crypto/openssh/sshd/Makefile
deleted file mode 100644
index 14ef3e0..0000000
--- a/crypto/openssh/sshd/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-# $OpenBSD: Makefile,v 1.51 2002/06/20 19:56:07 stevesk Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= sshd
-BINOWN= root
-BINMODE=555
-BINDIR= /usr/sbin
-MAN= sshd.8 sshd_config.5
-CFLAGS+=-DHAVE_LOGIN_CAP -DBSD_AUTH
-
-SRCS= sshd.c auth-rhosts.c auth-passwd.c auth-rsa.c auth-rh-rsa.c \
- sshpty.c sshlogin.c servconf.c serverloop.c uidswap.c \
- auth.c auth1.c auth2.c auth-options.c session.c \
- auth-chall.c auth2-chall.c groupaccess.c \
- auth-skey.c auth-bsdauth.c monitor_mm.c monitor.c \
- auth2-none.c auth2-passwd.c auth2-pubkey.c \
- auth2-hostbased.c auth2-kbdint.c
-
-.include <bsd.own.mk> # for KERBEROS and AFS
-
-.if (${KERBEROS5:L} == "yes")
-CFLAGS+=-DKRB5 -I${DESTDIR}/usr/include/kerberosV
-SRCS+= auth-krb5.c
-LDADD+= -lkrb5 -lkafs -lasn1 -lcom_err
-DPADD+= ${LIBKRB5} ${LIBKAFS} ${LIBASN1} ${LIBCOM_ERR}
-.endif # KERBEROS5
-
-.if (${KERBEROS:L} == "yes")
-.if (${AFS:L} == "yes")
-CFLAGS+= -DAFS
-LDADD+= -lkafs
-DPADD+= ${LIBKAFS}
-.endif # AFS
-CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
-SRCS+= auth-krb4.c
-LDADD+= -lkrb
-DPADD+= ${LIBKRB}
-.endif # KERBEROS
-
-.include <bsd.prog.mk>
-
-LDADD+= -lcrypto -lutil -lz -ldes
-DPADD+= ${LIBCRYPTO} ${LIBUTIL} ${LIBZ} ${LIBDES}
-
-.if (${TCP_WRAPPERS:L} == "yes")
-CFLAGS+= -DLIBWRAP
-LDADD+= -lwrap
-DPADD+= ${LIBWRAP}
-.endif
-
-#.if (${SKEY:L} == "yes")
-#CFLAGS+= -DSKEY
-#LDADD+= -lskey
-#DPADD+= ${SKEY}
-#.endif
diff --git a/crypto/openssh/sshd_config b/crypto/openssh/sshd_config
index dd53f10..56fb52c 100644
--- a/crypto/openssh/sshd_config
+++ b/crypto/openssh/sshd_config
@@ -1,4 +1,5 @@
-# $OpenBSD: sshd_config,v 1.65 2003/08/28 12:54:34 markus Exp $
+# $OpenBSD: sshd_config,v 1.59 2002/09/25 11:17:16 markus Exp $
+# $FreeBSD$
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
@@ -10,6 +11,11 @@
# possible, but leave them commented. Uncommented options change a
# default value.
+# Note that some of FreeBSD's defaults differ from OpenBSD's, and
+# FreeBSD has a few additional options.
+
+#VersionAddendum FreeBSD-20030924
+
#Port 22
#Protocol 2,1
#ListenAddress 0.0.0.0
@@ -18,11 +24,10 @@
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
-#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
-#KeyRegenerationInterval 1h
+#KeyRegenerationInterval 3600
#ServerKeyBits 768
# Logging
@@ -32,14 +37,18 @@
# Authentication:
-#LoginGraceTime 2m
-#PermitRootLogin yes
+#LoginGraceTime 120
+#PermitRootLogin no
#StrictModes yes
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
+# rhosts authentication should not be used
+#RhostsAuthentication no
+# Don't read the user's ~/.rhosts and ~/.shosts files
+#IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
@@ -47,14 +56,12 @@
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
-# Don't read the user's ~/.rhosts and ~/.shosts files
-#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
-# Change to no to disable s/key passwords
+# Change to no to disable PAM authentication
#ChallengeResponseAuthentication yes
# Kerberos options
@@ -62,18 +69,12 @@
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
-# GSSAPI options
-#GSSAPIAuthentication no
-#GSSAPICleanupCreds yes
+#AFSTokenPassing no
-# Set this to 'yes' to enable PAM authentication (via challenge-response)
-# and session processing. Depending on your PAM configuration, this may
-# bypass the setting of 'PasswordAuthentication'
-#UsePAM yes
+# Kerberos TGT Passing only works with the AFS kaserver
+#KerberosTgtPassing no
-#AllowTcpForwarding yes
-#GatewayPorts no
-#X11Forwarding no
+#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
@@ -83,14 +84,11 @@
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression yes
-#ClientAliveInterval 0
-#ClientAliveCountMax 3
-#UseDNS yes
-#PidFile /var/run/sshd.pid
-#MaxStartups 10
+#MaxStartups 10
# no default banner path
#Banner /some/path
+#VerifyReverseMapping no
# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server
diff --git a/crypto/openssh/sshd_config.5 b/crypto/openssh/sshd_config.5
index 727fdb1..7a07a11 100644
--- a/crypto/openssh/sshd_config.5
+++ b/crypto/openssh/sshd_config.5
@@ -34,7 +34,8 @@
.\" (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: sshd_config.5,v 1.25 2003/09/01 09:50:04 markus Exp $
+.\" $OpenBSD: sshd_config.5,v 1.15 2003/03/28 10:11:43 jmc Exp $
+.\" $FreeBSD$
.Dd September 25, 1999
.Dt SSHD_CONFIG 5
.Os
@@ -61,6 +62,10 @@ The possible
keywords and their meanings are as follows (note that
keywords are case-insensitive and arguments are case-sensitive):
.Bl -tag -width Ds
+.It Cm AFSTokenPassing
+Specifies whether an AFS token may be forwarded to the server.
+Default is
+.Dq no .
.It Cm AllowGroups
This keyword can be followed by a list of group name patterns, separated
by spaces.
@@ -68,7 +73,7 @@ If specified, login is allowed only for users whose primary
group or supplementary group list matches one of the patterns.
.Ql \&*
and
-.Ql \&?
+.Ql ?
can be used as
wildcards in the patterns.
Only group names are valid; a numerical group ID is not recognized.
@@ -89,7 +94,7 @@ If specified, login is allowed only for user names that
match one of the patterns.
.Ql \&*
and
-.Ql \&?
+.Ql ?
can be used as
wildcards in the patterns.
Only user names are valid; a numerical user ID is not recognized.
@@ -103,8 +108,7 @@ Specifies the file that contains the public keys that can be used
for user authentication.
.Cm AuthorizedKeysFile
may contain tokens of the form %T which are substituted during connection
-set-up.
-The following tokens are defined: %% is replaced by a literal '%',
+set-up. The following tokens are defined: %% is replaced by a literal '%',
%h is replaced by the home directory of the user being authenticated and
%u is replaced by the username of that user.
After expansion,
@@ -122,10 +126,17 @@ This option is only available for protocol version 2.
By default, no banner is displayed.
.Pp
.It Cm ChallengeResponseAuthentication
-Specifies whether challenge response authentication is allowed.
-All authentication styles from
-.Xr login.conf 5
-are supported.
+Specifies whether challenge-response authentication is allowed.
+Specifically, in
+.Fx ,
+this controls the use of PAM (see
+.Xr pam 3 )
+for authentication.
+Note that this affects the effectiveness of the
+.Cm PasswordAuthentication
+and
+.Cm PermitRootLogin
+variables.
The default is
.Dq yes .
.It Cm Ciphers
@@ -135,7 +146,7 @@ The default is
.Pp
.Bd -literal
``aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,
- aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr''
+ aes192-cbc,aes256-cbc''
.Ed
.It Cm ClientAliveInterval
Sets a timeout interval in seconds after which if no data has been received
@@ -150,24 +161,20 @@ This option applies to protocol version 2 only.
Sets the number of client alive messages (see above) which may be
sent without
.Nm sshd
-receiving any messages back from the client.
-If this threshold is reached while client alive messages are being sent,
+receiving any messages back from the client. If this threshold is
+reached while client alive messages are being sent,
.Nm sshd
-will disconnect the client, terminating the session.
-It is important to note that the use of client alive messages is very
-different from
+will disconnect the client, terminating the session. It is important
+to note that the use of client alive messages is very different from
.Cm KeepAlive
-(below).
-The client alive messages are sent through the encrypted channel
-and therefore will not be spoofable.
-The TCP keepalive option enabled by
+(below). The client alive messages are sent through the
+encrypted channel and therefore will not be spoofable. The TCP keepalive
+option enabled by
.Cm KeepAlive
-is spoofable.
-The client alive mechanism is valuable when the client or
+is spoofable. The client alive mechanism is valuable when the client or
server depend on knowing when a connection has become inactive.
.Pp
-The default value is 3.
-If
+The default value is 3. If
.Cm ClientAliveInterval
(above) is set to 15, and
.Cm ClientAliveCountMax
@@ -188,7 +195,7 @@ Login is disallowed for users whose primary group or supplementary
group list matches one of the patterns.
.Ql \&*
and
-.Ql \&?
+.Ql ?
can be used as
wildcards in the patterns.
Only group names are valid; a numerical group ID is not recognized.
@@ -200,7 +207,7 @@ by spaces.
Login is disallowed for user names that match one of the patterns.
.Ql \&*
and
-.Ql \&?
+.Ql ?
can be used as wildcards in the patterns.
Only user names are valid; a numerical user ID is not recognized.
By default, login is allowed for all users.
@@ -225,17 +232,6 @@ or
.Dq no .
The default is
.Dq no .
-.It Cm GSSAPIAuthentication
-Specifies whether user authentication based on GSSAPI is allowed.
-The default is
-.Dq no .
-Note that this option applies to protocol version 2 only.
-.It Cm GSSAPICleanupCredentials
-Specifies whether to automatically destroy the user's credentials cache
-on logout.
-The default is
-.Dq yes .
-Note that this option applies to protocol version 2 only.
.It Cm HostbasedAuthentication
Specifies whether rhosts or /etc/hosts.equiv authentication together
with successful public key client host authentication is allowed
@@ -251,8 +247,6 @@ used by SSH.
The default is
.Pa /etc/ssh/ssh_host_key
for protocol version 1, and
-.Pa /etc/ssh/ssh_host_rsa_key
-and
.Pa /etc/ssh/ssh_host_dsa_key
for protocol version 2.
Note that
@@ -271,13 +265,14 @@ Specifies that
and
.Pa .shosts
files will not be used in
+.Cm RhostsAuthentication ,
.Cm RhostsRSAAuthentication
or
.Cm HostbasedAuthentication .
.Pp
.Pa /etc/hosts.equiv
and
-.Pa /etc/shosts.equiv
+.Pa /etc/ssh/shosts.equiv
are still used.
The default is
.Dq yes .
@@ -314,9 +309,11 @@ This avoids infinitely hanging sessions.
To disable keepalives, the value should be set to
.Dq no .
.It Cm KerberosAuthentication
-Specifies whether the password provided by the user for
+Specifies whether Kerberos authentication is allowed.
+This can be in the form of a Kerberos ticket, or if
.Cm PasswordAuthentication
-will be validated through the Kerberos KDC.
+is yes, the password provided by the user will be validated through
+the Kerberos KDC.
To use this option, the server needs a
Kerberos servtab which allows the verification of the KDC's identity.
Default is
@@ -328,6 +325,11 @@ such as
.Pa /etc/passwd .
Default is
.Dq yes .
+.It Cm KerberosTgtPassing
+Specifies whether a Kerberos TGT may be forwarded to the server.
+Default is
+.Dq no ,
+as this only works when the Kerberos KDC is actually an AFS kaserver.
.It Cm KerberosTicketCleanup
Specifies whether to automatically destroy the user's ticket cache
file on logout.
@@ -373,12 +375,11 @@ is not specified,
.Nm sshd
will listen on the address and all prior
.Cm Port
-options specified.
-The default is to listen on all local addresses.
+options specified. The default is to listen on all local
+addresses.
Multiple
.Cm ListenAddress
-options are permitted.
-Additionally, any
+options are permitted. Additionally, any
.Cm Port
options must precede this option for non port qualified addresses.
.It Cm LoginGraceTime
@@ -431,6 +432,17 @@ are refused if the number of unauthenticated connections reaches
Specifies whether password authentication is allowed.
The default is
.Dq yes .
+Note that if
+.Cm ChallengeResponseAuthentication
+is
+.Dq yes ,
+and the PAM authentication policy for
+.Nm sshd
+includes
+.Xr pam_unix 8 ,
+password authentication will be allowed through the challenge-response
+mechanism regardless of the value of
+.Cm PasswordAuthentication .
.It Cm PermitEmptyPasswords
When password authentication is allowed, it specifies whether the
server allows login to accounts with empty password strings.
@@ -446,7 +458,14 @@ The argument must be
or
.Dq no .
The default is
-.Dq yes .
+.Dq no .
+Note that if
+.Cm ChallengeResponseAuthentication
+is
+.Dq yes ,
+the root user may be allowed in with its password even if
+.Cm PermitRootLogin is set to
+.Dq without-password .
.Pp
If this option is set to
.Dq without-password
@@ -459,8 +478,8 @@ but only if the
.Ar command
option has been specified
(which may be useful for taking remote backups even if root login is
-normally not allowed).
-All other authentication methods are disabled for root.
+normally not allowed). All other authentication methods are disabled
+for root.
.Pp
If this option is set to
.Dq no
@@ -533,15 +552,24 @@ Specifies whether public key authentication is allowed.
The default is
.Dq yes .
Note that this option applies to protocol version 2 only.
+.It Cm RhostsAuthentication
+Specifies whether authentication using rhosts or
+.Pa /etc/hosts.equiv
+files is sufficient.
+Normally, this method should not be permitted because it is insecure.
.Cm RhostsRSAAuthentication
should be used
instead, because it performs RSA-based host authentication in addition
-to normal rhosts or /etc/hosts.equiv authentication.
+to normal rhosts or
+.Pa /etc/hosts.equiv
+authentication.
The default is
.Dq no .
This option applies to protocol version 1 only.
.It Cm RhostsRSAAuthentication
-Specifies whether rhosts or /etc/hosts.equiv authentication together
+Specifies whether rhosts or
+.Pa /etc/hosts.equiv
+authentication together
with successful RSA host authentication is allowed.
The default is
.Dq no .
@@ -580,14 +608,6 @@ Gives the facility code that is used when logging messages from
The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
The default is AUTH.
-.It Cm UseDNS
-Specifies whether
-.Nm sshd
-should lookup the remote host name and check that
-the resolved host name for the remote IP address maps back to the
-very same IP address.
-The default is
-.Dq yes .
.It Cm UseLogin
Specifies whether
.Xr login 1
@@ -607,13 +627,6 @@ cookies.
If
.Cm UsePrivilegeSeparation
is specified, it will be disabled after authentication.
-.It Cm UsePAM
-Enables PAM authentication (via challenge-response) and session set up.
-If you enable this, you should probably disable
-.Cm PasswordAuthentication .
-If you enable
-.CM UsePAM
-then you will not be able to run sshd as a non-root user.
.It Cm UsePrivilegeSeparation
Specifies whether
.Nm sshd
@@ -625,6 +638,19 @@ The goal of privilege separation is to prevent privilege
escalation by containing any corruption within the unprivileged processes.
The default is
.Dq yes .
+.It Cm VerifyReverseMapping
+Specifies whether
+.Nm sshd
+should try to verify the remote host name and check that
+the resolved host name for the remote IP address maps back to the
+very same IP address.
+The default is
+.Dq no .
+.It Cm VersionAddendum
+Specifies a string to append to the regular version string to identify
+OS- or site-specific modifications.
+The default is
+.Dq FreeBSD-20030924 .
.It Cm X11DisplayOffset
Specifies the first display number available for
.Nm sshd Ns 's
@@ -640,7 +666,7 @@ The argument must be
or
.Dq no .
The default is
-.Dq no .
+.Dq yes .
.Pp
When X11 forwarding is enabled, there may be additional exposure to
the server and to client displays if the
@@ -655,7 +681,7 @@ display server may be exposed to attack when the ssh client requests
forwarding (see the warnings for
.Cm ForwardX11
in
-.Xr ssh_config 5 ) .
+.Xr ssh_config 5 ).
A system administrator may have a stance in which they want to
protect clients that may expose themselves to attack by unwittingly
requesting X11 forwarding, which can warrant a
@@ -701,6 +727,7 @@ The default is
.Pa /usr/X11R6/bin/xauth .
.El
.Ss Time Formats
+.Pp
.Nm sshd
command-line arguments and configuration file options that specify time
may be expressed using a sequence of the form:
@@ -749,8 +776,6 @@ Contains configuration data for
This file should be writable by root only, but it is recommended
(though not necessary) that it be world-readable.
.El
-.Sh SEE ALSO
-.Xr sshd 8
.Sh AUTHORS
OpenSSH is a derivative of the original and free
ssh 1.2.12 release by Tatu Ylonen.
@@ -762,3 +787,5 @@ Markus Friedl contributed the support for SSH
protocol versions 1.5 and 2.0.
Niels Provos and Markus Friedl contributed support
for privilege separation.
+.Sh SEE ALSO
+.Xr sshd 8
diff --git a/crypto/openssh/sshlogin.c b/crypto/openssh/sshlogin.c
index 36b6489..12555d6 100644
--- a/crypto/openssh/sshlogin.c
+++ b/crypto/openssh/sshlogin.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshlogin.c,v 1.7 2003/06/12 07:57:38 markus Exp $");
+RCSID("$OpenBSD: sshlogin.c,v 1.5 2002/08/29 15:57:25 stevesk Exp $");
#include "loginrec.h"
@@ -60,8 +60,8 @@ get_last_login_time(uid_t uid, const char *logname,
}
/*
- * Records that the user has logged in. I wish these parts of operating
- * systems were more standardized.
+ * 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,
diff --git a/crypto/openssh/sshpty.c b/crypto/openssh/sshpty.c
index 4747cea..d28947f 100644
--- a/crypto/openssh/sshpty.c
+++ b/crypto/openssh/sshpty.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshpty.c,v 1.10 2003/06/12 07:57:38 markus Exp $");
+RCSID("$OpenBSD: sshpty.c,v 1.8 2003/02/03 08:56:16 markus Exp $");
#ifdef HAVE_UTIL_H
# include <util.h>
@@ -101,12 +101,12 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
error("/dev/ptmx: %.100s", strerror(errno));
return 0;
}
- old_signal = signal(SIGCHLD, SIG_DFL);
+ old_signal = mysignal(SIGCHLD, SIG_DFL);
if (grantpt(ptm) < 0) {
error("grantpt: %.100s", strerror(errno));
return 0;
}
- signal(SIGCHLD, old_signal);
+ mysignal(SIGCHLD, old_signal);
if (unlockpt(ptm) < 0) {
error("unlockpt: %.100s", strerror(errno));
return 0;
@@ -226,7 +226,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
}
/* set tty modes to a sane state for broken clients */
if (tcgetattr(*ptyfd, &tio) < 0)
- logit("Getting tty modes for pty failed: %.100s", strerror(errno));
+ log("Getting tty modes for pty failed: %.100s", strerror(errno));
else {
tio.c_lflag |= (ECHO | ISIG | ICANON);
tio.c_oflag |= (OPOST | ONLCR);
@@ -234,7 +234,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
/* Set the new modes for the terminal. */
if (tcsetattr(*ptyfd, TCSANOW, &tio) < 0)
- logit("Setting tty modes for pty failed: %.100s", strerror(errno));
+ log("Setting tty modes for pty failed: %.100s", strerror(errno));
}
return 1;
@@ -258,7 +258,7 @@ pty_release(const char *ttyname)
error("chmod %.100s 0666 failed: %.100s", ttyname, strerror(errno));
}
-/* Makes the tty the process's controlling tty and sets it to sane modes. */
+/* Makes the tty the processes controlling tty and sets it to sane modes. */
void
pty_make_controlling_tty(int *ttyfd, const char *ttyname)
@@ -274,9 +274,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
fd = open(ttyname, O_RDWR|O_NOCTTY);
if (fd != -1) {
- signal(SIGHUP, SIG_IGN);
+ mysignal(SIGHUP, SIG_IGN);
ioctl(fd, TCVHUP, (char *)NULL);
- signal(SIGHUP, SIG_DFL);
+ mysignal(SIGHUP, SIG_DFL);
setpgid(0, 0);
close(fd);
} else {
@@ -323,9 +323,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
error("SETPGRP %s",strerror(errno));
#endif /* HAVE_NEWS4 */
#ifdef USE_VHANGUP
- old = signal(SIGHUP, SIG_IGN);
+ old = mysignal(SIGHUP, SIG_IGN);
vhangup();
- signal(SIGHUP, old);
+ mysignal(SIGHUP, old);
#endif /* USE_VHANGUP */
fd = open(ttyname, O_RDWR);
if (fd < 0) {
@@ -409,10 +409,10 @@ pty_setowner(struct passwd *pw, const char *ttyname)
if (errno == EROFS &&
(st.st_mode & (S_IRGRP | S_IROTH)) == 0)
debug("chmod(%.100s, 0%o) failed: %.100s",
- ttyname, (u_int)mode, strerror(errno));
+ ttyname, mode, strerror(errno));
else
fatal("chmod(%.100s, 0%o) failed: %.100s",
- ttyname, (u_int)mode, strerror(errno));
+ ttyname, mode, strerror(errno));
}
}
}
diff --git a/crypto/openssh/util.c b/crypto/openssh/util.c
deleted file mode 100644
index 1a591a6..0000000
--- 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);
-}
diff --git a/crypto/openssh/version.c b/crypto/openssh/version.c
new file mode 100644
index 0000000..a661439
--- /dev/null
+++ b/crypto/openssh/version.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2001 Brian Fundakowski Feldman
+ * 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 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$
+ */
+
+#include "includes.h"
+#include "version.h"
+#include "xmalloc.h"
+
+
+static char *version = NULL;
+
+const char *
+ssh_version_get(void) {
+
+ if (version == NULL)
+ version = xstrdup(SSH_VERSION_BASE " " SSH_VERSION_ADDENDUM);
+ return (version);
+}
+
+void
+ssh_version_set_addendum(const char *add) {
+ char *newvers;
+ size_t size;
+
+ if (add != NULL) {
+ size = strlen(SSH_VERSION_BASE) + 1 + strlen(add) + 1;
+ newvers = xmalloc(size);
+ snprintf(newvers, size, "%s %s", SSH_VERSION_BASE, add);
+ } else {
+ newvers = xstrdup(SSH_VERSION_BASE);
+ }
+ if (version != NULL)
+ xfree(version);
+ version = newvers;
+}
diff --git a/crypto/openssh/version.h b/crypto/openssh/version.h
index 0a98e42..0e4887a 100644
--- a/crypto/openssh/version.h
+++ b/crypto/openssh/version.h
@@ -1,3 +1,13 @@
-/* $OpenBSD: version.h,v 1.39 2003/09/16 21:02:40 markus Exp $ */
+/* $OpenBSD: version.h,v 1.37 2003/04/01 10:56:46 markus Exp $ */
+/* $FreeBSD$ */
+
+#ifndef SSH_VERSION
+
+#define SSH_VERSION (ssh_version_get())
+#define SSH_VERSION_BASE "OpenSSH_3.6.1p1"
+#define SSH_VERSION_ADDENDUM "FreeBSD-20030924"
+
+const char *ssh_version_get(void);
+void ssh_version_set_addendum(const char *add);
+#endif /* SSH_VERSION */
-#define SSH_VERSION "OpenSSH_3.7.1p2"
OpenPOWER on IntegriCloud