From 2e43737864d64f105b0ba67ca4d9731f955cdc6b Mon Sep 17 00:00:00 2001 From: jbasney Date: Fri, 16 Feb 2007 19:22:13 +0000 Subject: [PATCH] OPENSSH_4_5P1_20070215 merged to GPT branch --- openssh/CREDITS | 1 + openssh/CVSNOTES | 18 + openssh/ChangeLog | 4745 ++++++----------- openssh/ChangeLog.gssapi | 60 + openssh/HPN12-README | 2 + openssh/INSTALL | 33 +- openssh/LICENCE | 2 + openssh/Makefile.in | 21 +- openssh/OVERVIEW | 5 +- openssh/README | 2 +- openssh/README.platform | 12 + openssh/README.tun | 8 +- openssh/acss.c | 3 + openssh/atomicio.c | 69 +- openssh/atomicio.h | 14 +- openssh/audit-bsm.c | 8 + openssh/audit.c | 5 + openssh/audit.h | 2 - openssh/auth-bsdauth.c | 18 +- openssh/auth-chall.c | 10 +- openssh/auth-krb5.c | 14 +- openssh/auth-options.c | 28 +- openssh/auth-options.h | 2 +- openssh/auth-pam.c | 85 +- openssh/auth-passwd.c | 11 +- openssh/auth-rh-rsa.c | 12 +- openssh/auth-rhosts.c | 16 +- openssh/auth-rsa.c | 29 +- openssh/auth-shadow.c | 5 +- openssh/auth-sia.c | 19 +- openssh/auth-skey.c | 27 +- openssh/auth.c | 96 +- openssh/auth.h | 10 +- openssh/auth1.c | 22 +- openssh/auth2-chall.c | 15 +- openssh/auth2-gss.c | 16 +- openssh/auth2-hostbased.c | 17 +- openssh/auth2-kbdint.c | 11 +- openssh/auth2-none.c | 18 +- openssh/auth2-passwd.c | 13 +- openssh/auth2-pubkey.c | 18 +- openssh/auth2.c | 17 +- openssh/authfd.c | 29 +- openssh/authfd.h | 4 +- openssh/authfile.c | 32 +- openssh/authfile.h | 5 +- openssh/bufaux.c | 187 +- openssh/bufaux.h | 55 - openssh/bufbn.c | 221 + openssh/buffer.c | 87 +- openssh/buffer.h | 51 +- openssh/buildpkg.sh.in | 200 +- openssh/canohost.c | 29 +- openssh/canohost.h | 2 +- openssh/channels.c | 300 +- openssh/channels.h | 10 +- openssh/cipher-3des1.c | 8 +- openssh/cipher-acss.c | 3 +- openssh/cipher-aes.c | 6 +- openssh/cipher-bf1.c | 8 +- openssh/cipher-ctr.c | 9 +- openssh/cipher.c | 11 +- openssh/cipher.h | 2 +- openssh/cleanup.c | 8 +- openssh/clientloop.c | 93 +- openssh/clientloop.h | 4 +- openssh/compat.c | 11 +- openssh/compat.h | 2 +- openssh/compress.c | 8 +- openssh/compress.h | 2 +- openssh/configure.ac | 712 ++- openssh/contrib/aix/buildbff.sh | 44 +- openssh/contrib/caldera/openssh.spec | 2 +- openssh/contrib/cygwin/ssh-host-config | 41 +- openssh/contrib/redhat/openssh.spec | 2 +- openssh/contrib/redhat/sshd.init | 9 + openssh/contrib/suse/openssh.spec | 2 +- openssh/crc32.c | 4 +- openssh/crc32.h | 2 +- openssh/deattack.c | 76 +- openssh/deattack.h | 5 +- openssh/defines.h | 60 +- openssh/dh.c | 39 +- openssh/dh.h | 2 +- openssh/dispatch.c | 10 +- openssh/dispatch.h | 7 +- openssh/dns.c | 11 +- openssh/dns.h | 4 +- openssh/entropy.c | 17 +- openssh/fatal.c | 7 +- openssh/getput.h | 58 - openssh/groupaccess.c | 15 +- openssh/groupaccess.h | 4 +- openssh/gss-genr.c | 167 +- openssh/gss-serv-gsi.c | 31 +- openssh/gss-serv-krb5.c | 26 +- openssh/gss-serv.c | 92 +- openssh/hostfile.c | 20 +- openssh/hostfile.h | 2 +- openssh/includes.h | 66 +- openssh/kex.c | 52 +- openssh/kex.h | 13 +- openssh/kexdh.c | 9 +- openssh/kexdhc.c | 22 +- openssh/kexdhs.c | 23 +- openssh/kexgex.c | 8 +- openssh/kexgexc.c | 22 +- openssh/kexgexs.c | 24 +- openssh/kexgssc.c | 68 +- openssh/kexgsss.c | 69 +- openssh/key.c | 54 +- openssh/key.h | 2 +- openssh/log.c | 27 +- openssh/log.h | 5 +- openssh/loginrec.c | 22 +- openssh/loginrec.h | 6 - openssh/logintest.c | 6 +- openssh/mac.c | 14 +- openssh/mac.h | 2 +- openssh/match.c | 11 +- openssh/match.h | 2 +- openssh/md-sha256.c | 86 + openssh/md5crypt.c | 6 +- openssh/misc.c | 157 +- openssh/misc.h | 47 +- openssh/moduli.c | 80 +- openssh/monitor.c | 94 +- openssh/monitor.h | 2 +- openssh/monitor_fdpass.c | 11 +- openssh/monitor_fdpass.h | 2 +- openssh/monitor_mm.c | 11 +- openssh/monitor_mm.h | 3 +- openssh/monitor_wrap.c | 57 +- openssh/monitor_wrap.h | 10 +- openssh/msg.c | 18 +- openssh/msg.h | 2 +- openssh/myproposal.h | 18 +- openssh/nchan.c | 9 +- openssh/openbsd-compat/Makefile.in | 4 +- openssh/openbsd-compat/basename.c | 2 + openssh/openbsd-compat/bindresvport.c | 8 +- openssh/openbsd-compat/bsd-arc4random.c | 8 +- openssh/openbsd-compat/bsd-asprintf.c | 4 + openssh/openbsd-compat/bsd-closefrom.c | 25 +- openssh/openbsd-compat/bsd-cray.c | 3 + openssh/openbsd-compat/bsd-cygwin_util.c | 29 +- openssh/openbsd-compat/bsd-getpeereid.c | 7 +- openssh/openbsd-compat/bsd-misc.c | 14 +- openssh/openbsd-compat/bsd-nextstep.c | 2 - openssh/openbsd-compat/bsd-openpty.c | 19 + openssh/openbsd-compat/bsd-snprintf.c | 13 +- openssh/openbsd-compat/bsd-waitpid.c | 2 - openssh/openbsd-compat/daemon.c | 14 + openssh/openbsd-compat/fake-rfc2553.c | 6 +- openssh/openbsd-compat/fake-rfc2553.h | 5 +- openssh/openbsd-compat/getrrsetbyname.c | 13 + openssh/openbsd-compat/glob.c | 17 +- openssh/openbsd-compat/glob.h | 3 +- openssh/openbsd-compat/mktemp.c | 8 + openssh/openbsd-compat/openbsd-compat.h | 29 +- openssh/openbsd-compat/openssl-compat.c | 18 +- openssh/openbsd-compat/openssl-compat.h | 18 +- openssh/openbsd-compat/port-aix.c | 28 +- openssh/openbsd-compat/port-aix.h | 13 - openssh/openbsd-compat/port-irix.c | 4 + openssh/openbsd-compat/port-linux.c | 169 + openssh/openbsd-compat/port-linux.h | 27 + openssh/openbsd-compat/port-solaris.c | 199 + openssh/openbsd-compat/port-solaris.h | 27 + openssh/openbsd-compat/port-tun.c | 20 +- openssh/openbsd-compat/port-tun.h | 2 +- openssh/openbsd-compat/port-uw.c | 15 +- openssh/openbsd-compat/readpassphrase.c | 6 + openssh/openbsd-compat/regress/Makefile.in | 38 + .../openbsd-compat/regress/closefromtest.c | 60 + openssh/openbsd-compat/regress/snprintftest.c | 73 + openssh/openbsd-compat/regress/strduptest.c | 45 + openssh/openbsd-compat/regress/strtonumtest.c | 66 + openssh/openbsd-compat/rresvport.c | 10 + openssh/openbsd-compat/setproctitle.c | 5 +- openssh/openbsd-compat/sha2.c | 882 +++ openssh/openbsd-compat/sha2.h | 133 + openssh/openbsd-compat/strtonum.c | 3 + openssh/openbsd-compat/xcrypt.c | 4 + openssh/openbsd-compat/xmmap.c | 12 +- openssh/openssh.xml.in | 87 + openssh/packet.c | 80 +- openssh/packet.h | 4 +- openssh/pathnames.h | 2 +- openssh/platform.c | 46 + openssh/platform.h | 23 + openssh/progressmeter.c | 17 +- openssh/progressmeter.h | 2 +- openssh/readconf.c | 75 +- openssh/readconf.h | 7 +- openssh/readpass.c | 20 +- openssh/regress/Makefile | 10 +- openssh/regress/agent-getpeereid.sh | 7 +- openssh/regress/cfgmatch.sh | 106 + openssh/regress/cipher-speed.sh | 47 + openssh/regress/forcecommand.sh | 42 + openssh/regress/forwarding.sh | 32 +- openssh/rsa.c | 25 +- openssh/rsa.h | 2 +- openssh/scard-opensc.c | 8 +- openssh/scard.c | 31 +- openssh/scard.h | 4 +- openssh/scard/Makefile.in | 1 + openssh/scard/Ssh.bin | Bin 0 -> 600 bytes openssh/scp.1 | 7 +- openssh/scp.c | 96 +- openssh/servconf.c | 602 ++- openssh/servconf.h | 21 +- openssh/serverloop.c | 64 +- openssh/serverloop.h | 2 +- openssh/session.c | 103 +- openssh/session.h | 7 +- openssh/sftp-client.c | 42 +- openssh/sftp-common.c | 16 +- openssh/sftp-common.h | 2 +- openssh/sftp-glob.c | 15 +- openssh/sftp-server.8 | 38 +- openssh/sftp-server.c | 352 +- openssh/sftp.c | 38 +- openssh/sftp.h | 2 +- openssh/ssh-add.c | 37 +- openssh/ssh-agent.1 | 6 +- openssh/ssh-agent.c | 66 +- openssh/ssh-dss.c | 13 +- openssh/ssh-gss.h | 27 +- openssh/ssh-keygen.c | 126 +- openssh/ssh-keyscan.1 | 4 +- openssh/ssh-keyscan.c | 46 +- openssh/ssh-keysign.8 | 10 +- openssh/ssh-keysign.c | 22 +- openssh/ssh-rand-helper.c | 36 +- openssh/ssh-rsa.c | 13 +- openssh/ssh.1 | 141 +- openssh/ssh.c | 231 +- openssh/ssh.h | 16 +- openssh/ssh1.h | 2 +- openssh/ssh2.h | 2 +- openssh/ssh_config | 6 +- openssh/ssh_config.5 | 313 +- openssh/sshconnect.c | 152 +- openssh/sshconnect.h | 26 +- openssh/sshconnect1.c | 50 +- openssh/sshconnect2.c | 131 +- openssh/sshd.8 | 556 +- openssh/sshd.c | 821 +-- openssh/sshd_config | 33 +- openssh/sshd_config.5 | 340 +- openssh/sshlogin.c | 26 +- openssh/sshlogin.h | 11 +- openssh/sshpty.c | 31 +- openssh/sshpty.h | 11 +- openssh/sshtty.c | 8 +- openssh/ttymodes.c | 28 +- openssh/ttymodes.h | 2 +- openssh/uidswap.c | 52 +- openssh/uidswap.h | 8 +- openssh/uuencode.c | 14 +- openssh/uuencode.h | 5 +- openssh/version.h | 13 +- openssh/xmalloc.c | 48 +- openssh/xmalloc.h | 13 +- 266 files changed, 10876 insertions(+), 6354 deletions(-) create mode 100644 openssh/ChangeLog.gssapi delete mode 100644 openssh/bufaux.h create mode 100644 openssh/bufbn.c delete mode 100644 openssh/getput.h create mode 100644 openssh/md-sha256.c create mode 100644 openssh/openbsd-compat/port-linux.c create mode 100644 openssh/openbsd-compat/port-linux.h create mode 100644 openssh/openbsd-compat/port-solaris.c create mode 100644 openssh/openbsd-compat/port-solaris.h create mode 100644 openssh/openbsd-compat/regress/Makefile.in create mode 100644 openssh/openbsd-compat/regress/closefromtest.c create mode 100644 openssh/openbsd-compat/regress/snprintftest.c create mode 100644 openssh/openbsd-compat/regress/strduptest.c create mode 100644 openssh/openbsd-compat/regress/strtonumtest.c create mode 100755 openssh/openbsd-compat/sha2.c create mode 100755 openssh/openbsd-compat/sha2.h create mode 100644 openssh/openssh.xml.in create mode 100644 openssh/platform.c create mode 100644 openssh/platform.h create mode 100644 openssh/regress/cfgmatch.sh create mode 100644 openssh/regress/cipher-speed.sh create mode 100644 openssh/regress/forcecommand.sh create mode 100644 openssh/scard/Ssh.bin diff --git a/openssh/CREDITS b/openssh/CREDITS index 2d067f9..5f02d71 100644 --- a/openssh/CREDITS +++ b/openssh/CREDITS @@ -25,6 +25,7 @@ Chris, the Young One - Password auth fixes Christos Zoulas - Autoconf fixes Chun-Chung Chen - RPM fixes Corinna Vinschen - Cygwin support +Chad Mynhier - Solaris Process Contract support Dan Brosemer - Autoconf support, build fixes Darren Hall - AIX patches Darren Tucker - AIX BFF package scripts diff --git a/openssh/CVSNOTES b/openssh/CVSNOTES index 9697a36..d85a9b7 100644 --- a/openssh/CVSNOTES +++ b/openssh/CVSNOTES @@ -59,6 +59,24 @@ module that contains the GSI-OpenSSH code. Consider it a living document. [ History ] + 2007/02/15 + ---------- + Action: Merge + - occurred on: GPT branch + - orig base: OPENSSH_4_3P2_20060726 + - new base: OPENSSH_4_5P1_20070215 + Conflicts: + - Makefile.in + new file bufbn.o + - configure.ac + PAM checks moved and updated. Merged by hand. + - sftp-server.c + Comment moved. + - sshd_config + UsePam description changed, and we default to yes. + - version.h + NCSA_VERSION constant added on trunk. + 2006/07/26 ---------- Action: Merge diff --git a/openssh/ChangeLog b/openssh/ChangeLog index 5bb99a7..5a6772a 100644 --- a/openssh/ChangeLog +++ b/openssh/ChangeLog @@ -1,13 +1,1759 @@ -20060211 - - (dtucker) [README] Bump release notes URL. - - (djm) Release 4.3p2 +20061107 + - (dtucker) [sshd.c] Use privsep_pw if we have it, but only require it + if we absolutely need it. Pointed out by Corinna, ok djm@ + - (dtucker) OpenBSD CVS Sync + - markus@cvs.openbsd.org 2006/11/06 21:25:28 + [auth-rsa.c kexgexc.c kexdhs.c key.c ssh-dss.c sshd.c kexgexs.c + ssh-keygen.c bufbn.c moduli.c scard.c kexdhc.c sshconnect1.c dh.c rsa.c] + add missing checks for openssl return codes; with & ok djm@ + - markus@cvs.openbsd.org 2006/11/07 10:31:31 + [monitor.c version.h] + correctly check for bad signatures in the monitor, otherwise the monitor + and the unpriv process can get out of sync. with dtucker@, ok djm@, + dtucker@ + - (dtucker) [README contrib/{caldera,redhat,contrib}/openssh.spec] Bump + versions. + - (dtucker) [dh.c] Type fix for BN_hex2bn; ok markus@ + - (dtucker) Release 4.5p1. + +20061105 + - (djm) OpenBSD CVS Sync + - otto@cvs.openbsd.org 2006/10/28 18:08:10 + [ssh.1] + correct/expand example of usage of -w; ok jmc@ stevesk@ + - markus@cvs.openbsd.org 2006/10/31 16:33:12 + [kexdhc.c kexdhs.c kexgexc.c kexgexs.c] + check DH_compute_key() for -1 even if it should not happen because of + earlier calls to dh_pub_is_valid(); report krahmer at suse.de; ok djm + +20061101 + - (dtucker) [openbsd-compat/port-solaris.c] Bug #1255: Make only hwerr + events fatal in Solaris process contract support and tell it to signal + only processes in the same process group when something happens. + Based on information from andrew.benham at thus.net and similar to + a patch from Chad Mynhier. ok djm@ + +20061027 +- (djm) [auth.c] gc some dead code + +20061023 + - (djm) OpenBSD CVS Sync + - ray@cvs.openbsd.org 2006/09/30 17:48:22 + [sftp.c] + Clear errno before calling the strtol functions. + From Paul Stoeber . + OK deraadt@. + - djm@cvs.openbsd.org 2006/10/06 02:29:19 + [ssh-agent.c ssh-keyscan.c ssh.c] + sys/resource.h needs sys/time.h; prompted by brad@ + (NB. Id sync only for portable) + - djm@cvs.openbsd.org 2006/10/09 23:36:11 + [session.c] + xmalloc -> xcalloc that was missed previously, from portable + (NB. Id sync only for portable, obviously) + - markus@cvs.openbsd.org 2006/10/10 10:12:45 + [sshconnect.c] + sleep before retrying (not after) since sleep changes errno; fixes + pr 5250; rad@twig.com; ok dtucker djm + - markus@cvs.openbsd.org 2006/10/11 12:38:03 + [clientloop.c serverloop.c] + exit instead of doing a blocking tcp send if we detect a client/server + timeout, since the tcp sendqueue might be already full (of alive + requests); ok dtucker, report mpf + - djm@cvs.openbsd.org 2006/10/22 02:25:50 + [sftp-client.c] + cancel progress meter when upload write fails; ok deraadt@ + - (tim) [Makefile.in scard/Makefile.in] Add datarootdir= lines to keep + autoconf 2.60 from complaining. + +20061018 + - (dtucker) OpenBSD CVS Sync + - ray@cvs.openbsd.org 2006/09/25 04:55:38 + [ssh-keyscan.1 ssh.1] + Change "a SSH" to "an SSH". Hurray, I'm not the only one who + pronounces "SSH" as "ess-ess-aich". + OK jmc@ and stevesk@. + - (dtucker) [sshd.c] Reshuffle storing of pw struct; prevents warnings + on older versions of OS X. ok djm@ + +20061016 + - (dtucker) [monitor_fdpass.c] Include sys/in.h, required for cmsg macros + on older (2.0) Linuxes. Based on patch from thmo-13 at gmx de. + +20061006 + - (tim) [buildpkg.sh.in] Use uname -r instead of -v in OS_VER for Solaris. + Differentiate between OpenServer 5 and OpenServer 6 + - (dtucker) [configure.ac] Set put -lselinux into $LIBS while testing for + SELinux functions so they're detected correctly. Patch from pebenito at + gentoo.org. + - (tim) [buildpkg.sh.in] Some systems have really limited nawk (OpenServer). + Allow setting alternate awk in openssh-config.local. + +20061003 + - (tim) [configure.ac] Move CHECK_HEADERS test before platform specific + section so additional platform specific CHECK_HEADER tests will work + correctly. Fixes " on FreeBSD" problem report by des AT des.no + Feedback and "seems like a good idea" dtucker@ + +20061001 + - (dtucker) [audit-bsm.c] Include errno.h. Pointed out by des at des.no. + +20060929 + - (dtucker) [configure.ac] Bug #1239: Fix configure test for OpenSSH engine + support. Patch from andrew.benham at thus net. + +20060928 + - (dtucker) [entropy.c] Bug #1238: include signal.h to fix compilation error + on Solaris 8 w/out /dev/random or prngd. Patch from rl at + math.technion.ac.il. + +20060926 + - (dtucker) [bufaux.h] nuke bufaux.h; it's already gone from OpenBSD and not + referenced any more. ok djm@ + - (dtucker) [sftp-server.8] Resync; spotted by djm@ + - (dtucker) Release 4.4p1. + +20060924 + - (tim) [configure.ac] Remove CFLAGS hack for UnixWare 1.x/2.x (added + to rev 1.308) to work around broken gcc 2.x header file. + +20060923 + - (dtucker) [configure.ac] Bug #1234: Put opensc libs into $LIBS rather than + $LDFLAGS. Patch from vapier at gentoo org. + +20060922 + - (dtucker) [packet.c canohost.c] Include arpa/inet.h for htonl macros on + some platforms (eg HP-UX 11.00). From santhi.amirta at gmail com. + +20060921 + - (dtucker) OpenBSD CVS Sync + - otto@cvs.openbsd.org 2006/09/19 05:52:23 + [sftp.c] + Use S_IS* macros insted of masking with S_IF* flags. The latter may + have multiple bits set, which lead to surprising results. Spotted by + Paul Stoeber, more to come. ok millert@ pedro@ jaredy@ djm@ + - markus@cvs.openbsd.org 2006/09/19 21:14:08 + [packet.c] + client NULL deref on protocol error; Tavis Ormandy, Google Security Team + - (dtucker) [defines.h] Include unistd.h before defining getpgrp; fixes + build error on Ultrix. From Bernhard Simon. + +20060918 + - (dtucker) [configure.ac] On AIX, check to see if the compiler will allow + macro redefinitions, and if not, remove "-qlanglvl=ansi" from the flags. + Allows build out of the box with older VAC and XLC compilers. Found by + David Bronder and Bernhard Simon. + - (dtucker) [openbsd-compat/port-aix.{c,h}] Reduce scope of includes. + Prevents macro redefinition warnings of "RDONLY". + +20060916 + - OpenBSD CVS Sync + - djm@cvs.openbsd.org 2006/09/16 19:53:37 + [deattack.c deattack.h packet.c] + limit maximum work performed by the CRC compensation attack detector, + problem reported by Tavis Ormandy, Google Security Team; + ok markus@ deraadt@ + - (djm) Add openssh.xml to .cvsignore and sort it + - (dtucker) [auth-pam.c] Propogate TZ environment variable to PAM auth + process so that any logging it does is with the right timezone. From + Scott Strickler, ok djm@. + - (dtucker) [monitor.c] Correctly handle auditing of single commands when + using Protocol 1. From jhb at freebsd. + - (djm) [sshd.c] Fix warning/API abuse; ok dtucker@ + - (dtucker) [INSTALL] Add info about audit support. + +20060912 + - (djm) [Makefile.in buildpkg.sh.in configure.ac openssh.xml.in] + Support SMF in Solaris Packages if enabled by configure. Patch from + Chad Mynhier, tested by dtucker@ + +20060911 + - (dtucker) [cipher-aes.c] Include string.h for memcpy and friends. Noted + by Pekka Savola. + +20060910 + - (dtucker) [contrib/aix/buildbff.sh] Ensure that perl is available. + - (dtucker) [configure.ac] Add -lcrypt to let DragonFly build OOTB. + +20060909 + - (dtucker) [openbsd-compat/bsd-snprintf.c] Add stdarg.h. + - (dtucker) [contrib/aix/buildbff.sh] Always create privsep user. + - (dtucker) [buildpkg.sh.in] Always create privsep user. ok djm@ + +20060908 + - (dtucker) [auth-sia.c] Add includes required for build on Tru64. Patch + from Chris Adams. + - (dtucker) [configure.ac] The BSM header test needs time.h in some cases. + +20060907 + - (djm) [sshd.c auth.c] Set up fakepw() with privsep uid/gid, so it can + be used to drop privilege to; fixes Solaris GSSAPI crash reported by + Magnus Abrante; suggestion and feedback dtucker@ + NB. this change will require that the privilege separation user must + exist on all the time, not just when UsePrivilegeSeparation=yes + - (tim) [configure.ac] s/BROKEN_UPDWTMP/BROKEN_UPDWTMPX/ on SCO OSR6 + - (dtucker) [loginrec.c] Wrap paths.h in HAVE_PATHS_H. + - (dtucker) [regress/cfgmatch.sh] stop_client is racy, so give us a better + chance of winning. + +20060905 + - (dtucker) [configure.ac] s/AC_DEFINES/AC_DEFINE/ spotted by Roumen Petrov. + - (dtucker) [loginrec.c] Include paths.h for _PATH_BTMP. + +20060904 + - (dtucker) [configure.ac] Define BROKEN_UPDWTMP on SCO OSR6 as the native + updwdtmp seems to generate invalid wtmp entries. From Roger Cornelius, + ok djm@ + +20060903 + - (dtucker) [configure.ac openbsd-compat/openbsd-compat.h] Check for + declaration of writev(2) and declare it ourselves if necessary. Makes + the atomiciov() calls build on really old systems. ok djm@ + +20060902 + - (dtucker) [openbsd-compat/port-irix.c] Add errno.h, found by Iain Morgan. + - (dtucker) [ssh-keyscan.c ssh-rand-helper.c ssh.c sshconnect.c + openbsd-compat/bindresvport.c openbsd-compat/getrrsetbyname.c + openbsd-compat/port-tun.c openbsd-compat/rresvport.c] Include + for hton* and ntoh* macros. Required on (at least) HP-UX since we define + _XOPEN_SOURCE_EXTENDED. Found by santhi.amirta at gmail com. + +20060901 + - (djm) [audit-bsm.c audit.c auth-bsdauth.c auth-chall.c auth-pam.c] + [auth-rsa.c auth-shadow.c auth-sia.c auth1.c auth2-chall.c] + [auth2-gss.c auth2-kbdint.c auth2-none.c authfd.c authfile.c] + [cipher-3des1.c cipher-aes.c cipher-bf1.c cipher-ctr.c clientloop.c] + [dh.c dns.c entropy.c gss-serv-krb5.c gss-serv.c hostfile.c kex.c] + [kexdhc.c kexdhs.c kexgexc.c kexgexs.c key.c loginrec.c mac.c] + [md5crypt.c monitor.c monitor_wrap.c readconf.c rsa.c] + [scard-opensc.c scard.c session.c ssh-add.c ssh-agent.c ssh-dss.c] + [ssh-keygen.c ssh-keysign.c ssh-rsa.c ssh.c sshconnect.c] + [sshconnect1.c sshconnect2.c sshd.c] + [openbsd-compat/bsd-cray.c openbsd-compat/port-aix.c] + [openbsd-compat/port-linux.c openbsd-compat/port-solaris.c] + [openbsd-compat/port-uw.c] + Lots of headers for SCO OSR6, mainly adding stdarg.h for log.h; + compile problems reported by rac AT tenzing.org + - (djm) [includes.h monitor.c openbsd-compat/bindresvport.c] + [openbsd-compat/rresvport.c] Some more headers: netinet/in.h + sys/socket.h and unistd.h in various places + - (dtucker) [openbsd-compat/bsd-cygwin_util.c] Fix implict declaration + warnings for binary_open and binary_close. Patch from Corinna Vinschen. + - (dtucker) [configure.ac includes.h openbsd-compat/glob.{c,h}] Explicitly + test for GLOB_NOMATCH and use our glob functions if it's not found. + Stops sftp from segfaulting when attempting to get a nonexistent file on + Cygwin (previous versions of OpenSSH didn't use the native glob). Partly + from and tested by Corinna Vinschen. + - (dtucker) [README contrib/{caldera,redhat,suse}/openssh.spec] Crank + versions. + +20060831 + - (djm) [CREDITS LICENCE Makefile.in auth.c configure.ac includes.h ] + [platform.c platform.h sshd.c openbsd-compat/Makefile.in] + [openbsd-compat/openbsd-compat.h openbsd-compat/port-solaris.c] + [openbsd-compat/port-solaris.h] Add support for Solaris process + contracts, enabled with --use-solaris-contracts. Patch from Chad + Mynhier, tweaked by dtucker@ and myself; ok dtucker@ + - (dtucker) [contrib/cygwin/ssh-host-config] Add SeTcbPrivilege privilege + while setting up the ssh service account. Patch from Corinna Vinschen. + +20060830 + - (djm) OpenBSD CVS Sync + - dtucker@cvs.openbsd.org 2006/08/21 08:14:01 + [sshd_config.5] + Document HostbasedUsesNameFromPacketOnly. Corrections from jmc@, + ok jmc@ djm@ + - dtucker@cvs.openbsd.org 2006/08/21 08:15:57 + [sshd.8] + Add more detail about what permissions are and aren't accepted for + authorized_keys files. Corrections jmc@, ok djm@, "looks good" jmc@ + - djm@cvs.openbsd.org 2006/08/29 10:40:19 + [channels.c session.c] + normalise some inconsistent (but harmless) NULL pointer checks + spotted by the Stanford SATURN tool, via Isil Dillig; + ok markus@ deraadt@ + - dtucker@cvs.openbsd.org 2006/08/29 12:02:30 + [gss-genr.c] + Work around a problem in Heimdal that occurs when KRB5CCNAME file is + missing, by checking whether or not kerberos allocated us a context + before attempting to free it. Patch from Simon Wilkinson, tested by + biorn@, ok djm@ + - dtucker@cvs.openbsd.org 2006/08/30 00:06:51 + [sshconnect2.c] + Fix regression where SSH2 banner is printed at loglevels ERROR and FATAL + where previously it weren't. bz #1221, found by Dean Kopesky, ok djm@ + - djm@cvs.openbsd.org 2006/08/30 00:14:37 + [version.h] + crank to 4.4 + - (djm) [openbsd-compat/xcrypt.c] needs unistd.h + - (dtucker) [auth.c openbsd-compat/port-aix.c] Bug #1207: always call + loginsuccess on AIX immediately after authentication to clear the failed + login count. Previously this would only happen when an interactive + session starts (ie when a pty is allocated) but this means that accounts + that have primarily non-interactive sessions (eg scp's) may gradually + accumulate enough failures to lock out an account. This change may have + a side effect of creating two audit records, one with a tty of "ssh" + corresponding to the authentication and one with the allocated pty per + interactive session. + +20060824 + - (dtucker) [openbsd-compat/basename.c] Include errno.h. + - (dtucker) [openbsd-compat/bsd-misc.c] Add includes needed for select(2) on + older systems. + - (dtucker) [openbsd-compat/bsd-misc.c] Include for select(2) + on POSIX systems. + - (dtucker) [openbsd-compat/bsd-openpty.c] Include for ioctl(2). + - (dtucker) [openbsd-compat/rresvport.c] Include for malloc. + - (dtucker) [openbsd-compat/xmmap.c] Move #define HAVE_MMAP to prevent + unused variable warning when we have a broken or missing mmap(2). + +20060822 + - (dtucker) [Makefile.in] Bug #1177: fix incorrect path for sshrc in + Makefile. Patch from santhi.amirta at gmail, ok djm. + +20060820 + - (dtucker) [log.c] Move ifdef to prevent unused variable warning. + - (dtucker) [configure.ac] Save $LIBS during PAM library tests and restore + afterward. Removes the need to mangle $LIBS later to remove -lpam and -ldl. + - (dtucker) [configure.ac] Relocate --with-pam parts in preparation for + fixing bug #1181. No changes yet. + - (dtucker) [configure.ac] Bug #1181: Explicitly test to see if OpenSSL + (0.9.8a and presumably newer) requires -ldl to successfully link. + - (dtucker) [configure.ac] Remove errant "-". + +20060819 + - (djm) OpenBSD CVS Sync + - djm@cvs.openbsd.org 2006/08/18 22:41:29 + [gss-genr.c] + GSSAPI error code should be 0 and not -1; from simon@sxw.org.uk + - (dtucker) [openbsd-compat/regress/Makefile.in] Add $(EXEEXT) and add a + single rule for the test progs. + +20060818 + - (dtucker) [configure.ac openbsd-compat/bsd-closefrom.c] Resync with + closefrom.c from sudo. + - (dtucker) [openbsd-compat/bsd-closefrom.c] Comment out rcsid. + - (dtucker) [openbsd-compat/regress/snprintftest.c] Newline on error. + - (dtucker) [openbsd-compat/regress/Makefile.in] Use implicit rules for the + test progs instead; they work better than what we have. + - (djm) OpenBSD CVS Sync + - stevesk@cvs.openbsd.org 2006/08/06 01:13:32 + [compress.c monitor.c monitor_wrap.c] + "zlib.h" can be ; ok djm@ markus@ + - miod@cvs.openbsd.org 2006/08/12 20:46:46 + [monitor.c monitor_wrap.c] + Revert previous include file ordering change, for ssh to compile under + gcc2 (or until openssl include files are cleaned of parameter names + in function prototypes) + - dtucker@cvs.openbsd.org 2006/08/14 12:40:25 + [servconf.c servconf.h sshd_config.5] + Add ability to match groups to Match keyword in sshd_config. Feedback + djm@, stevesk@, ok stevesk@. + - djm@cvs.openbsd.org 2006/08/16 11:47:15 + [sshd.c] + factor inetd connection, TCP listen and main TCP accept loop out of + main() into separate functions to improve readability; ok markus@ + - deraadt@cvs.openbsd.org 2006/08/18 09:13:26 + [log.c log.h sshd.c] + make signal handler termination path shorter; risky code pointed out by + mark dowd; ok djm markus + - markus@cvs.openbsd.org 2006/08/18 09:15:20 + [auth.h session.c sshd.c] + delay authentication related cleanups until we're authenticated and + all alarms have been cancelled; ok deraadt + - djm@cvs.openbsd.org 2006/08/18 10:27:16 + [misc.h] + reorder so prototypes are sorted by the files they refer to; no + binary change + - djm@cvs.openbsd.org 2006/08/18 13:54:54 + [gss-genr.c ssh-gss.h sshconnect2.c] + bz #1218 - disable SPNEGO as per RFC4462; diff from simon AT sxw.org.uk + ok markus@ + - djm@cvs.openbsd.org 2006/08/18 14:40:34 + [gss-genr.c ssh-gss.h] + constify host argument to match the rest of the GSSAPI functions and + unbreak compilation with -Werror + - (djm) Disable sigdie() for platforms that cannot safely syslog inside + a signal handler (basically all of them, excepting OpenBSD); + ok dtucker@ + +20060817 + - (dtucker) [openbsd-compat/fake-rfc2553.c openbsd-compat/setproctitle.c] + Include stdlib.h for malloc and friends. + - (dtucker) [configure.ac openbsd-compat/bsd-closefrom.c] Use F_CLOSEM fcntl + for closefrom() on AIX. Pointed out by William Ahern. + - (dtucker) [openbsd-compat/regress/{Makefile.in,closefromtest.c}] Regress + test for closefrom() in compat code. + +20060816 + - (djm) [audit-bsm.c] Sprinkle in some headers + +20060815 + - (dtucker) [LICENCE] Add Reyk to the list for the compat dir. + +20060806 + - (djm) [openbsd-compat/bsd-getpeereid.c] Add some headers to quiet warnings + on Solaris 10 + +20060806 + - (dtucker) [defines.h] With the includes.h changes we no longer get the + name clash on "YES" so we can remove the workaround for it. + - (dtucker) [openbsd-compat/{bsd-asprintf.c,bsd-openpty.c,bsd-snprintf.c, + glob.c}] Include stdlib.h for malloc and friends in compat code. + +20060805 + - (djm) OpenBSD CVS Sync + - stevesk@cvs.openbsd.org 2006/07/24 13:58:22 + [sshconnect.c] + disable tunnel forwarding when no strict host key checking + and key changed; ok djm@ markus@ dtucker@ + - stevesk@cvs.openbsd.org 2006/07/25 02:01:34 + [scard.c] + need #include + - stevesk@cvs.openbsd.org 2006/07/25 02:59:21 + [channels.c clientloop.c packet.c scp.c serverloop.c sftp-client.c] + [sftp-server.c ssh-agent.c ssh-keyscan.c sshconnect.c sshd.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/26 02:35:17 + [atomicio.c auth.c dh.c authfile.c buffer.c clientloop.c kex.c] + [groupaccess.c gss-genr.c kexgexs.c misc.c monitor.c monitor_mm.c] + [packet.c scp.c serverloop.c session.c sftp-client.c sftp-common.c] + [sftp-server.c sftp.c ssh-add.c ssh-agent.c ssh-keygen.c sshlogin.c] + [uidswap.c xmalloc.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/26 13:57:17 + [authfd.c authfile.c dh.c canohost.c channels.c clientloop.c compat.c] + [hostfile.c kex.c log.c misc.c moduli.c monitor.c packet.c readpass.c] + [scp.c servconf.c session.c sftp-server.c sftp.c ssh-add.c ssh-agent.c] + [ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh.c sshconnect.c] + [sshconnect1.c sshd.c xmalloc.c] + move #include out of includes.h + - jmc@cvs.openbsd.org 2006/07/27 08:00:50 + [ssh_config.5] + avoid confusing wording in HashKnownHosts: + originally spotted by alan amesbury; + ok deraadt + - jmc@cvs.openbsd.org 2006/07/27 08:00:50 + [ssh_config.5] + avoid confusing wording in HashKnownHosts: + originally spotted by alan amesbury; + ok deraadt + - dtucker@cvs.openbsd.org 2006/08/01 11:34:36 + [sshconnect.c] + Allow fallback to known_hosts entries without port qualifiers for + non-standard ports too, so that all existing known_hosts entries will be + recognised. Requested by, feedback and ok markus@ + - stevesk@cvs.openbsd.org 2006/08/01 23:22:48 + [auth-passwd.c auth-rhosts.c auth-rsa.c auth.c auth.h auth1.c] + [auth2-chall.c auth2-pubkey.c authfile.c buffer.c canohost.c] + [channels.c clientloop.c dh.c dns.c dns.h hostfile.c kex.c kexdhc.c] + [kexgexc.c kexgexs.c key.c key.h log.c misc.c misc.h moduli.c] + [monitor_wrap.c packet.c progressmeter.c readconf.c readpass.c scp.c] + [servconf.c session.c sftp-client.c sftp-common.c sftp-server.c sftp.c] + [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keyscan.c ssh.c sshconnect.c] + [sshconnect1.c sshconnect2.c sshd.c sshlogin.c sshtty.c uuencode.c] + [uuencode.h xmalloc.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/08/01 23:36:12 + [authfile.c channels.c progressmeter.c scard.c servconf.c ssh.c] + clean extra spaces + - deraadt@cvs.openbsd.org 2006/08/03 03:34:42 + [OVERVIEW atomicio.c atomicio.h auth-bsdauth.c auth-chall.c auth-krb5.c] + [auth-options.c auth-options.h auth-passwd.c auth-rh-rsa.c auth-rhosts.c] + [auth-rsa.c auth-skey.c auth.c auth.h auth1.c auth2-chall.c auth2-gss.c] + [auth2-hostbased.c auth2-kbdint.c auth2-none.c auth2-passwd.c ] + [auth2-pubkey.c auth2.c authfd.c authfd.h authfile.c bufaux.c bufbn.c] + [buffer.c buffer.h canohost.c channels.c channels.h cipher-3des1.c] + [cipher-bf1.c cipher-ctr.c cipher.c cleanup.c clientloop.c compat.c] + [compress.c deattack.c dh.c dispatch.c dns.c dns.h fatal.c groupaccess.c] + [groupaccess.h gss-genr.c gss-serv-krb5.c gss-serv.c hostfile.c kex.c] + [kex.h kexdh.c kexdhc.c kexdhs.c kexgex.c kexgexc.c kexgexs.c key.c] + [key.h log.c log.h mac.c match.c md-sha256.c misc.c misc.h moduli.c] + [monitor.c monitor_fdpass.c monitor_mm.c monitor_mm.h monitor_wrap.c] + [monitor_wrap.h msg.c nchan.c packet.c progressmeter.c readconf.c] + [readconf.h readpass.c rsa.c scard.c scard.h scp.c servconf.c servconf.h] + [serverloop.c session.c session.h sftp-client.c sftp-common.c] + [sftp-common.h sftp-glob.c sftp-server.c sftp.c ssh-add.c ssh-agent.c] + [ssh-dss.c ssh-gss.h ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh-rsa.c] + [ssh.c ssh.h sshconnect.c sshconnect.h sshconnect1.c sshconnect2.c] + [sshd.c sshlogin.c sshlogin.h sshpty.c sshpty.h sshtty.c ttymodes.c] + [uidswap.c uidswap.h uuencode.c uuencode.h xmalloc.c xmalloc.h] + [loginrec.c loginrec.h openbsd-compat/port-aix.c openbsd-compat/port-tun.h] + almost entirely get rid of the culture of ".h files that include .h files" + ok djm, sort of ok stevesk + makes the pain stop in one easy step + NB. portable commit contains everything *except* removing includes.h, as + that will take a fair bit more work as we move headers that are required + for portability workarounds to defines.h. (also, this step wasn't "easy") + - stevesk@cvs.openbsd.org 2006/08/04 20:46:05 + [monitor.c session.c ssh-agent.c] + spaces + - (djm) [auth-pam.c defines.h] Move PAM related bits to auth-pam.c + - (djm) [auth-pam.c auth.c bufaux.h entropy.c openbsd-compat/port-tun.c] + remove last traces of bufaux.h - it was merged into buffer.h in the big + includes.h commit + - (djm) [auth.c loginrec.c] Missing netinet/in.h for loginrec + - (djm) [openbsd-compat/regress/snprintftest.c] + [openbsd-compat/regress/strduptest.c] Add missing includes so they pass + compilation with "-Wall -Werror" + - (djm) [auth-pam.c auth-shadow.c auth2-none.c cleanup.c sshd.c] + [openbsd-compat/port-tun.c openbsd-compat/port-tun.h] Sprinkle more + includes for Linux in + - (dtucker) [cleanup.c] Need defines.h for __dead. + - (dtucker) [auth2-gss.c] We still need the #ifdef GSSAPI in -portable. + - (dtucker) [openbsd-compat/{bsd-arc4random.c,port-tun.c,xmmap.c}] Lots of + #include stdarg.h, needed for log.h. + - (dtucker) [entropy.c] Needs unistd.h too. + - (dtucker) [ssh-rand-helper.c] Needs stdarg.h for log.h. + - (dtucker) [openbsd-compat/getrrsetbyname.c] Nees stdlib.h for malloc. + - (dtucker) [openbsd-compat/strtonum.c] Include stdlib.h for strtoll, + otherwise it is implicitly declared as returning an int. + - (dtucker) OpenBSD CVS Sync + - dtucker@cvs.openbsd.org 2006/08/05 07:52:52 + [auth2-none.c sshd.c monitor_wrap.c] + Add headers required to build with KERBEROS5=no. ok djm@ + - dtucker@cvs.openbsd.org 2006/08/05 08:00:33 + [auth-skey.c] + Add headers required to build with -DSKEY. ok djm@ + - dtucker@cvs.openbsd.org 2006/08/05 08:28:24 + [monitor_wrap.c auth-skey.c auth2-chall.c] + Zap unused variables in -DSKEY code. ok djm@ + - dtucker@cvs.openbsd.org 2006/08/05 08:34:04 + [packet.c] + Typo in comment + - (dtucker) [openbsd-compat/bsd-cygwin_util.c] Add headers required to compile + on Cygwin. + - (dtucker) [openbsd-compat/fake-rfc2553.c] Add headers needed for inet_ntoa. + - (dtucker) [auth-skey.c] monitor_wrap.h needs ssh-gss.h. + - (dtucker) [audit.c audit.h] Repair headers. + - (dtucker) [audit-bsm.c] Add additional headers now required. + +20060804 + - (dtucker) [configure.ac] The "crippled AES" test does not work on recent + versions of Solaris, so use AC_LINK_IFELSE to actually link the test program + rather than just compiling it. Spotted by dlg@. + +20060802 + - (dtucker) [openbsd-compat/daemon.c] Add unistd.h for fork() prototype. + +20060725 + - (dtucker) [openbsd-compat/xmmap.c] Need fcntl.h for O_RDRW. + +20060724 + - (djm) OpenBSD CVS Sync + - jmc@cvs.openbsd.org 2006/07/12 13:39:55 + [sshd_config.5] + - new sentence, new line + - s/The the/The/ + - kill a bad comma + - stevesk@cvs.openbsd.org 2006/07/12 22:28:52 + [auth-options.c canohost.c channels.c includes.h readconf.c] + [servconf.c ssh-keyscan.c ssh.c sshconnect.c sshd.c] + move #include out of includes.h; ok djm@ + - stevesk@cvs.openbsd.org 2006/07/12 22:42:32 + [includes.h ssh.c ssh-rand-helper.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/14 01:15:28 + [monitor_wrap.h] + don't need incompletely-typed 'struct passwd' now with + #include ; ok markus@ + - stevesk@cvs.openbsd.org 2006/07/17 01:31:10 + [authfd.c authfile.c channels.c cleanup.c clientloop.c groupaccess.c] + [includes.h log.c misc.c msg.c packet.c progressmeter.c readconf.c] + [readpass.c scp.c servconf.c sftp-client.c sftp-server.c sftp.c] + [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh.c] + [sshconnect.c sshlogin.c sshpty.c uidswap.c] + move #include out of includes.h + - dtucker@cvs.openbsd.org 2006/07/17 12:02:24 + [auth-options.c] + Use '\0' rather than 0 to terminates strings; ok djm@ + - dtucker@cvs.openbsd.org 2006/07/17 12:06:00 + [channels.c channels.h servconf.c sshd_config.5] + Add PermitOpen directive to sshd_config which is equivalent to the + "permitopen" key option. Allows server admin to allow TCP port + forwarding only two specific host/port pairs. Useful when combined + with Match. + If permitopen is used in both sshd_config and a key option, both + must allow a given connection before it will be permitted. + Note that users can still use external forwarders such as netcat, + so to be those must be controlled too for the limits to be effective. + Feedback & ok djm@, man page corrections & ok jmc@. + - jmc@cvs.openbsd.org 2006/07/18 07:50:40 + [sshd_config.5] + tweak; ok dtucker + - jmc@cvs.openbsd.org 2006/07/18 07:56:28 + [scp.1] + replace DIAGNOSTICS with .Ex; + - jmc@cvs.openbsd.org 2006/07/18 08:03:09 + [ssh-agent.1 sshd_config.5] + mark up angle brackets; + - dtucker@cvs.openbsd.org 2006/07/18 08:22:23 + [sshd_config.5] + Clarify description of Match, with minor correction from jmc@ + - stevesk@cvs.openbsd.org 2006/07/18 22:27:55 + [dh.c] + remove unneeded includes; ok djm@ + - dtucker@cvs.openbsd.org 2006/07/19 08:56:41 + [servconf.c sshd_config.5] + Add support for X11Forwaring, X11DisplayOffset and X11UseLocalhost to + Match. ok djm@ + - dtucker@cvs.openbsd.org 2006/07/19 13:07:10 + [servconf.c servconf.h session.c sshd.8 sshd_config sshd_config.5] + Add ForceCommand keyword to sshd_config, equivalent to the "command=" + key option, man page entry and example in sshd_config. + Feedback & ok djm@, man page corrections & ok jmc@ + - stevesk@cvs.openbsd.org 2006/07/20 15:26:15 + [auth1.c serverloop.c session.c sshconnect2.c] + missed some needed #include when KERBEROS5=no; issue from + massimo@cedoc.mo.it + - dtucker@cvs.openbsd.org 2006/07/21 12:43:36 + [channels.c channels.h servconf.c servconf.h sshd_config.5] + Make PermitOpen take a list of permitted ports and act more like most + other keywords (ie the first match is the effective setting). This + also makes it easier to override a previously set PermitOpen. ok djm@ + - stevesk@cvs.openbsd.org 2006/07/21 21:13:30 + [channels.c] + more ARGSUSED (lint) for dispatch table-driven functions; ok djm@ + - stevesk@cvs.openbsd.org 2006/07/21 21:26:55 + [progressmeter.c] + ARGSUSED for signal handler + - stevesk@cvs.openbsd.org 2006/07/22 19:08:54 + [includes.h moduli.c progressmeter.c scp.c sftp-common.c] + [sftp-server.c ssh-agent.c sshlogin.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/22 20:48:23 + [atomicio.c auth-options.c auth-passwd.c auth-rhosts.c auth-rsa.c] + [auth.c auth1.c auth2-chall.c auth2-hostbased.c auth2-passwd.c auth2.c] + [authfd.c authfile.c bufaux.c bufbn.c buffer.c canohost.c channels.c] + [cipher-3des1.c cipher-bf1.c cipher-ctr.c cipher.c clientloop.c] + [compat.c deattack.c dh.c dns.c gss-genr.c gss-serv.c hostfile.c] + [includes.h kex.c kexdhc.c kexdhs.c kexgexc.c kexgexs.c key.c log.c] + [mac.c match.c md-sha256.c misc.c moduli.c monitor.c monitor_fdpass.c] + [monitor_mm.c monitor_wrap.c msg.c nchan.c packet.c rsa.c] + [progressmeter.c readconf.c readpass.c scp.c servconf.c serverloop.c] + [session.c sftp-client.c sftp-common.c sftp-glob.c sftp-server.c sftp.c] + [ssh-add.c ssh-agent.c ssh-dss.c ssh-keygen.c ssh-keyscan.c] + [ssh-keysign.c ssh-rsa.c ssh.c sshconnect.c sshconnect1.c sshconnect2.c] + [sshd.c sshlogin.c sshpty.c ttymodes.c uidswap.c xmalloc.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/23 01:11:05 + [auth.h dispatch.c kex.h sftp-client.c] + #include for sig_atomic_t; need this prior to + move + - (djm) [acss.c auth-krb5.c auth-options.c auth-pam.c auth-shadow.c] + [canohost.c channels.c cipher-acss.c defines.h dns.c gss-genr.c] + [gss-serv-krb5.c gss-serv.c log.h loginrec.c logintest.c readconf.c] + [servconf.c ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh-rand-helper.c] + [ssh.c sshconnect.c sshd.c openbsd-compat/bindresvport.c] + [openbsd-compat/bsd-arc4random.c openbsd-compat/bsd-misc.c] + [openbsd-compat/getrrsetbyname.c openbsd-compat/glob.c] + [openbsd-compat/mktemp.c openbsd-compat/port-linux.c] + [openbsd-compat/port-tun.c openbsd-compat/readpassphrase.c] + [openbsd-compat/setproctitle.c openbsd-compat/xmmap.c] + make the portable tree compile again - sprinkle unistd.h and string.h + back in. Don't redefine __unused, as it turned out to be used in + headers on Linux, and replace its use in auth-pam.c with ARGSUSED + - (djm) [openbsd-compat/glob.c] + Move get_arg_max() into the ifdef HAVE_GLOB block so that it compiles + on OpenBSD (or other platforms with a decent glob implementation) with + -Werror + - (djm) [uuencode.c] + Add resolv.h, is it contains the prototypes for __b64_ntop/__b64_pton on + some platforms + - (djm) [session.c] + fix compile error with -Werror -Wall: 'path' is only used in + do_setup_env() if HAVE_LOGIN_CAP is not defined + - (djm) [openbsd-compat/basename.c openbsd-compat/bsd-closefrom.c] + [openbsd-compat/bsd-cray.c openbsd-compat/bsd-openpty.c] + [openbsd-compat/bsd-snprintf.c openbsd-compat/fake-rfc2553.c] + [openbsd-compat/port-aix.c openbsd-compat/port-irix.c] + [openbsd-compat/rresvport.c] + These look to need string.h and/or unistd.h (based on a grep for function + names) + - (djm) [Makefile.in] + Remove generated openbsd-compat/regress/Makefile in distclean target + - (djm) [regress/Makefile regress/agent-getpeereid.sh regress/cfgmatch.sh] + [regress/cipher-speed.sh regress/forcecommand.sh regress/forwarding.sh] + Sync regress tests to -current; include dtucker@'s new cfgmatch and + forcecommand tests. Add cipher-speed.sh test (not linked in yet) + - (dtucker) [cleanup.c] Since config.h defines _LARGE_FILES on AIX, including + system headers before defines.h will cause conflicting definitions. + - (dtucker) [regress/forcecommand.sh] Portablize. + +20060713 + - (dtucker) [auth-krb5.c auth-pam.c] Still more errno.h + +20060712 + - (dtucker) [configure.ac defines.h] Only define SHUT_RD (and friends) and + O_NONBLOCK if they're really needed. Fixes build errors on HP-UX, old + Linuxes and probably more. + - (dtucker) [configure.ac] OpenBSD needs before + for SHUT_RD. + - (dtucker) [openbsd-compat/port-tun.c] OpenBSD needs before + . + - (dtucker) OpenBSD CVS Sync + - stevesk@cvs.openbsd.org 2006/07/10 16:01:57 + [sftp-glob.c sftp-common.h sftp.c] + buffer.h only needed in sftp-common.h and remove some unneeded + user includes; ok djm@ + - jmc@cvs.openbsd.org 2006/07/10 16:04:21 + [sshd.8] + s/and and/and/ + - stevesk@cvs.openbsd.org 2006/07/10 16:37:36 + [readpass.c log.h scp.c fatal.c xmalloc.c includes.h ssh-keyscan.c misc.c + auth.c packet.c log.c] + move #include out of includes.h; ok markus@ + - dtucker@cvs.openbsd.org 2006/07/11 10:12:07 + [ssh.c] + Only copy the part of environment variable that we actually use. Prevents + ssh bailing when SendEnv is used and an environment variable with a really + long value exists. ok djm@ + - markus@cvs.openbsd.org 2006/07/11 18:50:48 + [clientloop.c ssh.1 ssh.c channels.c ssh_config.5 readconf.h session.c + channels.h readconf.c] + add ExitOnForwardFailure: terminate the connection if ssh(1) + cannot set up all requested dynamic, local, and remote port + forwardings. ok djm, dtucker, stevesk, jmc + - stevesk@cvs.openbsd.org 2006/07/11 20:07:25 + [scp.c auth.c monitor.c serverloop.c sftp-server.c sshpty.c readpass.c + sshd.c monitor_wrap.c monitor_fdpass.c ssh-agent.c ttymodes.c atomicio.c + includes.h session.c sshlogin.c monitor_mm.c packet.c sshconnect2.c + sftp-client.c nchan.c clientloop.c sftp.c misc.c canohost.c channels.c + ssh-keygen.c progressmeter.c uidswap.c msg.c readconf.c sshconnect.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/07/11 20:16:43 + [ssh.c] + cast asterisk field precision argument to int to remove warning; + ok markus@ + - stevesk@cvs.openbsd.org 2006/07/11 20:27:56 + [authfile.c ssh.c] + need here also (it's also included in ) + - dtucker@cvs.openbsd.org 2006/07/12 11:34:58 + [sshd.c servconf.h servconf.c sshd_config.5 auth.c] + Add support for conditional directives to sshd_config via a "Match" + keyword, which works similarly to the "Host" directive in ssh_config. + Lines after a Match line override the default set in the main section + if the condition on the Match line is true, eg + AllowTcpForwarding yes + Match User anoncvs + AllowTcpForwarding no + will allow port forwarding by all users except "anoncvs". + Currently only a very small subset of directives are supported. + ok djm@ + - (dtucker) [loginrec.c openbsd-compat/xmmap.c openbsd-compat/bindresvport.c + openbsd-compat/glob.c openbsd-compat/mktemp.c openbsd-compat/port-tun.c + openbsd-compat/readpassphrase.c openbsd-compat/strtonum.c] Include . + - (dtucker) [openbsd-compat/setproctitle.c] Include stdarg.h. + - (dtucker) [ssh-keyscan.c ssh-rand-helper.c] More errno.h here too. + - (dtucker) [openbsd-compat/openbsd-compat.h] v*printf needs stdarg.h. + - (dtucker) [openbsd-compat/bsd-asprintf.c openbsd-compat/port-aix.c + openbsd-compat/rresvport.c] More errno.h. + +20060711 + - (dtucker) [configure.ac ssh-keygen.c openbsd-compat/bsd-openpty.c + openbsd-compat/daemon.c] Add includes needed by open(2). Conditionally + include paths.h. Fixes build error on Solaris. + - (dtucker) [entropy.c] More fcntl.h, this time on AIX (and probably + others). + +20060710 + - (dtucker) [INSTALL] New autoconf version: 2.60. + - OpenBSD CVS Sync + - djm@cvs.openbsd.org 2006/06/14 10:50:42 + [sshconnect.c] + limit the number of pre-banner characters we will accept; ok markus@ + - djm@cvs.openbsd.org 2006/06/26 10:36:15 + [clientloop.c] + mention optional bind_address in runtime port forwarding setup + command-line help. patch from santhi.amirta AT gmail.com + - stevesk@cvs.openbsd.org 2006/07/02 17:12:58 + [ssh.1 ssh.c ssh_config.5 sshd_config.5] + more details and clarity for tun(4) device forwarding; ok and help + jmc@ + - stevesk@cvs.openbsd.org 2006/07/02 18:36:47 + [gss-serv-krb5.c gss-serv.c] + no "servconf.h" needed here + (gss-serv-krb5.c change not applied, portable needs the server options) + - stevesk@cvs.openbsd.org 2006/07/02 22:45:59 + [groupaccess.c groupaccess.h includes.h session.c sftp-common.c sshpty.c] + move #include out of includes.h + (portable needed uidswap.c too) + - stevesk@cvs.openbsd.org 2006/07/02 23:01:55 + [clientloop.c ssh.1] + use -KR[bind_address:]port here; ok djm@ + - stevesk@cvs.openbsd.org 2006/07/03 08:54:20 + [includes.h ssh.c sshconnect.c sshd.c] + move #include "version.h" out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/07/03 17:59:32 + [channels.c includes.h] + move #include out of includes.h; old ok djm@ + (portable needed session.c too) + - stevesk@cvs.openbsd.org 2006/07/05 02:42:09 + [canohost.c hostfile.c includes.h misc.c packet.c readconf.c] + [serverloop.c sshconnect.c uuencode.c] + move #include out of includes.h; ok deraadt@ + (also ssh-rand-helper.c logintest.c loginrec.c) + - djm@cvs.openbsd.org 2006/07/06 10:47:05 + [servconf.c servconf.h session.c sshd_config.5] + support arguments to Subsystem commands; ok markus@ + - djm@cvs.openbsd.org 2006/07/06 10:47:57 + [sftp-server.8 sftp-server.c] + add commandline options to enable logging of transactions; ok markus@ + - stevesk@cvs.openbsd.org 2006/07/06 16:03:53 + [auth-options.c auth-options.h auth-passwd.c auth-rh-rsa.c] + [auth-rhosts.c auth-rsa.c auth.c auth.h auth2-hostbased.c] + [auth2-pubkey.c auth2.c includes.h misc.c misc.h monitor.c] + [monitor_wrap.c monitor_wrap.h scp.c serverloop.c session.c] + [session.h sftp-common.c ssh-add.c ssh-keygen.c ssh-keysign.c] + [ssh.c sshconnect.c sshconnect.h sshd.c sshpty.c sshpty.h uidswap.c] + [uidswap.h] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/07/06 16:22:39 + [ssh-keygen.c] + move #include "dns.h" up + - stevesk@cvs.openbsd.org 2006/07/06 17:36:37 + [monitor_wrap.h] + typo in comment + - stevesk@cvs.openbsd.org 2006/07/08 21:47:12 + [authfd.c canohost.c clientloop.c dns.c dns.h includes.h] + [monitor_fdpass.c nchan.c packet.c servconf.c sftp.c ssh-agent.c] + [ssh-keyscan.c ssh.c sshconnect.h sshd.c sshlogin.h] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/08 21:48:53 + [monitor.c session.c] + missed these from last commit: + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/08 23:30:06 + [log.c] + move user includes after /usr/include files + - stevesk@cvs.openbsd.org 2006/07/09 15:15:11 + [auth2-none.c authfd.c authfile.c includes.h misc.c monitor.c] + [readpass.c scp.c serverloop.c sftp-client.c sftp-server.c] + [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c] + [sshlogin.c sshpty.c] + move #include out of includes.h + - stevesk@cvs.openbsd.org 2006/07/09 15:27:59 + [ssh-add.c] + use O_RDONLY vs. 0 in open(); no binary change + - djm@cvs.openbsd.org 2006/07/10 11:24:54 + [sftp-server.c] + remove optind - it isn't used here + - djm@cvs.openbsd.org 2006/07/10 11:25:53 + [sftp-server.c] + don't log variables that aren't yet set + - (djm) [loginrec.c ssh-rand-helper.c sshd.c openbsd-compat/glob.c] + [openbsd-compat/mktemp.c openbsd-compat/openbsd-compat.h] + [openbsd-compat/port-tun.c openbsd-compat/readpassphrase.c] + [openbsd-compat/xcrypt.c] Fix includes.h fallout, mainly fcntl.h + - OpenBSD CVS Sync + - djm@cvs.openbsd.org 2006/07/10 12:03:20 + [scp.c] + duplicate argv at the start of main() because it gets modified later; + pointed out by deraadt@ ok markus@ + - djm@cvs.openbsd.org 2006/07/10 12:08:08 + [channels.c] + fix misparsing of SOCKS 5 packets that could result in a crash; + reported by mk@ ok markus@ + - dtucker@cvs.openbsd.org 2006/07/10 12:46:51 + [misc.c misc.h sshd.8 sshconnect.c] + Add port identifier to known_hosts for non-default ports, based originally + on a patch from Devin Nate in bz#910. + For any connection using the default port or using a HostKeyAlias the + format is unchanged, otherwise the host name or address is enclosed + within square brackets in the same format as sshd's ListenAddress. + Tested by many, ok markus@. + - (dtucker) [openbsd-compat/openbsd-compat.h] Need to include + for struct sockaddr on platforms that use the fake-rfc stuff. + +20060706 + - (dtucker) [configure.ac] Try AIX blibpath test in different order when + compiling with gcc. gcc 4.1.x will accept (but ignore) -b flags so + configure would not select the correct libpath linker flags. + - (dtucker) [INSTALL] A bit more info on autoconf. + +20060705 + - (dtucker) [ssh-rand-helper.c] Don't exit if mkdir fails because the + target already exists. + +20060630 + - (dtucker) [openbsd-compat/openbsd-compat.h] SNPRINTF_CONST for snprintf + declaration too. Patch from russ at sludge.net. + - (dtucker) [openbsd-compat/getrrsetbyname.c] Undef _res before defining it, + prevents warnings on platforms where _res is in the system headers. + - (dtucker) [INSTALL] Bug #1202: Note when autoconf is required and which + version. + +20060627 + - (dtucker) [configure.ac] Bug #1203: Add missing '[', which causes problems + with autoconf 2.60. Patch from vapier at gentoo.org. + +20060625 + - (dtucker) [channels.c serverloop.c] Apply the bug #1102 workaround to ptys + only, otherwise sshd can hang exiting non-interactive sessions. + +20060624 + - (dtucker) [configure.ac] Bug #1193: Define PASSWD_NEEDS_USERNAME on Solaris. + Works around limitation in Solaris' passwd program for changing passwords + where the username is longer than 8 characters. ok djm@ + - (dtucker) [serverloop.c] Get ifdef/ifndef the right way around for the bug + #1102 workaround. + +20060623 + - (dtucker) [README.platform configure.ac openbsd-compat/port-tun.c] Add + tunnel support for Mac OS X/Darwin via a third-party tun driver. Patch + from reyk@, tested by anil@ + - (dtucker) [channels.c configure.ac serverloop.c] Bug #1102: Around AIX + 4.3.3 ML3 or so, the AIX pty layer starting passing zero-length writes + on the pty slave as zero-length reads on the pty master, which sshd + interprets as the descriptor closing. Since most things don't do zero + length writes this rarely matters, but occasionally it happens, and when + it does the SSH pty session appears to hang, so we add a special case for + this condition. ok djm@ + +20060613 + - (djm) [getput.h] This file has been replaced by functions in misc.c + - OpenBSD CVS Sync + - djm@cvs.openbsd.org 2006/05/08 10:49:48 + [sshconnect2.c] + uint32_t -> u_int32_t (which we use everywhere else) + (Id sync only - portable already had this) + - markus@cvs.openbsd.org 2006/05/16 09:00:00 + [clientloop.c] + missing free; from Kylene Hall + - markus@cvs.openbsd.org 2006/05/17 12:43:34 + [scp.c sftp.c ssh-agent.c ssh-keygen.c sshconnect.c] + fix leak; coverity via Kylene Jo Hall + - miod@cvs.openbsd.org 2006/05/18 21:27:25 + [kexdhc.c kexgexc.c] + paramter -> parameter + - dtucker@cvs.openbsd.org 2006/05/29 12:54:08 + [ssh_config.5] + Add gssapi-with-mic to PreferredAuthentications default list; ok jmc + - dtucker@cvs.openbsd.org 2006/05/29 12:56:33 + [ssh_config] + Add GSSAPIAuthentication and GSSAPIDelegateCredentials to examples in + sample ssh_config. ok markus@ + - jmc@cvs.openbsd.org 2006/05/29 16:10:03 + [ssh_config.5] + oops - previous was too long; split the list of auths up + - mk@cvs.openbsd.org 2006/05/30 11:46:38 + [ssh-add.c] + Sync usage() with man page and reality. + ok deraadt dtucker + - jmc@cvs.openbsd.org 2006/05/29 16:13:23 + [ssh.1] + add GSSAPI to the list of authentication methods supported; + - mk@cvs.openbsd.org 2006/05/30 11:46:38 + [ssh-add.c] + Sync usage() with man page and reality. + ok deraadt dtucker + - markus@cvs.openbsd.org 2006/06/01 09:21:48 + [sshd.c] + call get_remote_ipaddr() early; fixes logging after client disconnects; + report mpf@; ok dtucker@ + - markus@cvs.openbsd.org 2006/06/06 10:20:20 + [readpass.c sshconnect.c sshconnect.h sshconnect2.c uidswap.c] + replace remaining setuid() calls with permanently_set_uid() and + check seteuid() return values; report Marcus Meissner; ok dtucker djm + - markus@cvs.openbsd.org 2006/06/08 14:45:49 + [readpass.c sshconnect.c sshconnect2.c uidswap.c uidswap.h] + do not set the gid, noted by solar; ok djm + - djm@cvs.openbsd.org 2006/06/13 01:18:36 + [ssh-agent.c] + always use a format string, even when printing a constant + - djm@cvs.openbsd.org 2006/06/13 02:17:07 + [ssh-agent.c] + revert; i am on drugs. spotted by alexander AT beard.se + +20060521 + - (dtucker) [auth.c monitor.c] Now that we don't log from both the monitor + and slave, we can remove the special-case handling in the audit hook in + auth_log. + +20060517 + - (dtucker) [ssh-rand-helper.c] Check return code of mkdir and fix file + pointer leak. From kjhall at us.ibm.com, found by coverity. + +20060515 + - (dtucker) [openbsd-compat/getrrsetbyname.c] Use _compat_res instead of + _res, prevents problems on some platforms that have _res as a global but + don't have getrrsetbyname(), eg IRIX 5.3. Found and tested by + georg.schwarz at freenet.de, ok djm@. + - (dtucker) [defines.h] Find a value for IOV_MAX or use a conservative + default. Patch originally from tim@, ok djm + - (dtucker) [auth-pam.c] Bug #1188: pass result of do_pam_account back and + do not allow kbdint again after the PAM account check fails. ok djm@ + +20060506 + - (dtucker) OpenBSD CVS Sync + - dtucker@cvs.openbsd.org 2006/04/25 08:02:27 + [authfile.c authfile.h sshconnect2.c ssh.c sshconnect1.c] + Prevent ssh from trying to open private keys with bad permissions more than + once or prompting for their passphrases (which it subsequently ignores + anyway), similar to a previous change in ssh-add. bz #1186, ok djm@ + - djm@cvs.openbsd.org 2006/05/04 14:55:23 + [dh.c] + tighter DH exponent checks here too; feedback and ok markus@ + - djm@cvs.openbsd.org 2006/04/01 05:37:46 + [OVERVIEW] + $OpenBSD$ in here too + - dtucker@cvs.openbsd.org 2006/05/06 08:35:40 + [auth-krb5.c] + Add $OpenBSD$ in comment here too + +20060504 + - (dtucker) [auth-pam.c groupaccess.c monitor.c monitor_wrap.c scard-opensc.c + session.c ssh-rand-helper.c sshd.c openbsd-compat/bsd-cygwin_util.c + openbsd-compat/setproctitle.c] Convert malloc(foo*bar) -> calloc(foo,bar) + in Portable-only code; since calloc zeros, remove now-redundant memsets. + Also add a couple of sanity checks. With & ok djm@ + +20060503 + - (dtucker) [packet.c] Remove in_systm.h since it's also in includes.h + and double including it on IRIX 5.3 causes problems. From Georg Schwarz, + "no objections" tim@ + +20060423 + - (djm) OpenBSD CVS Sync + - deraadt@cvs.openbsd.org 2006/04/01 05:42:20 + [scp.c] + minimal lint cleanup (unused crud, and some size_t); ok djm + - djm@cvs.openbsd.org 2006/04/01 05:50:29 + [scp.c] + xasprintification; ok deraadt@ + - djm@cvs.openbsd.org 2006/04/01 05:51:34 + [atomicio.c] + ANSIfy; requested deraadt@ + - dtucker@cvs.openbsd.org 2006/04/02 08:34:52 + [ssh-keysign.c] + sessionid can be 32 bytes now too when sha256 kex is used; ok djm@ + - djm@cvs.openbsd.org 2006/04/03 07:10:38 + [gss-genr.c] + GSSAPI buffers shouldn't be nul-terminated, spotted in bugzilla #1066 + by dleonard AT vintela.com. use xasprintf() to simplify code while in + there; "looks right" deraadt@ + - djm@cvs.openbsd.org 2006/04/16 00:48:52 + [buffer.c buffer.h channels.c] + Fix condition where we could exit with a fatal error when an input + buffer became too large and the remote end had advertised a big window. + The problem was a mismatch in the backoff math between the channels code + and the buffer code, so make a buffer_check_alloc() function that the + channels code can use to propsectivly check whether an incremental + allocation will succeed. bz #1131, debugged with the assistance of + cove AT wildpackets.com; ok dtucker@ deraadt@ + - djm@cvs.openbsd.org 2006/04/16 00:52:55 + [atomicio.c atomicio.h] + introduce atomiciov() function that wraps readv/writev to retry + interrupted transfers like atomicio() does for read/write; + feedback deraadt@ dtucker@ stevesk@ ok deraadt@ + - djm@cvs.openbsd.org 2006/04/16 00:54:10 + [sftp-client.c] + avoid making a tiny 4-byte write to send the packet length of sftp + commands, which would result in a separate tiny packet on the wire by + using atomiciov(writev, ...) to write the length and the command in one + pass; ok deraadt@ + - djm@cvs.openbsd.org 2006/04/16 07:59:00 + [atomicio.c] + reorder sanity test so that it cannot dereference past the end of the + iov array; well spotted canacar@! + - dtucker@cvs.openbsd.org 2006/04/18 10:44:28 + [bufaux.c bufbn.c Makefile.in] + Move Buffer bignum functions into their own file, bufbn.c. This means + that sftp and sftp-server (which use the Buffer functions in bufaux.c + but not the bignum ones) no longer need to be linked with libcrypto. + ok markus@ + - djm@cvs.openbsd.org 2006/04/20 09:27:09 + [auth.h clientloop.c dispatch.c dispatch.h kex.h] + replace the last non-sig_atomic_t flag used in a signal handler with a + sig_atomic_t, unfortunately with some knock-on effects in other (non- + signal) contexts in which it is used; ok markus@ + - markus@cvs.openbsd.org 2006/04/20 09:47:59 + [sshconnect.c] + simplify; ok djm@ + - djm@cvs.openbsd.org 2006/04/20 21:53:44 + [includes.h session.c sftp.c] + Switch from using pipes to socketpairs for communication between + sftp/scp and ssh, and between sshd and its subprocesses. This saves + a file descriptor per session and apparently makes userland ppp over + ssh work; ok markus@ deraadt@ (ID Sync only - portable makes this + decision on a per-platform basis) + - djm@cvs.openbsd.org 2006/04/22 04:06:51 + [uidswap.c] + use setres[ug]id() to permanently revoke privileges; ok deraadt@ + (ID Sync only - portable already uses setres[ug]id() whenever possible) + - stevesk@cvs.openbsd.org 2006/04/22 18:29:33 + [crc32.c] + remove extra spaces + - (djm) [auth.h dispatch.h kex.h] sprinkle in signal.h to get + sig_atomic_t + +20060421 + - (djm) [Makefile.in configure.ac session.c sshpty.c] + [contrib/redhat/sshd.init openbsd-compat/Makefile.in] + [openbsd-compat/openbsd-compat.h openbsd-compat/port-linux.c] + [openbsd-compat/port-linux.h] Add support for SELinux, setting + the execution and TTY contexts. based on patch from Daniel Walsh, + bz #880; ok dtucker@ + +20060418 + - (djm) [canohost.c] Reorder IP options check so that it isn't broken + by mapped addresses; bz #1179 reported by markw wtech-llc.com; + ok dtucker@ + +20060331 + - OpenBSD CVS Sync + - deraadt@cvs.openbsd.org 2006/03/27 01:21:18 + [xmalloc.c] + we can do the size & nmemb check before the integer overflow check; + evol + - deraadt@cvs.openbsd.org 2006/03/27 13:03:54 + [dh.c] + use strtonum() instead of atoi(), limit dhg size to 64k; ok djm + - djm@cvs.openbsd.org 2006/03/27 23:15:46 + [sftp.c] + always use a format string for addargs; spotted by mouring@ + - deraadt@cvs.openbsd.org 2006/03/28 00:12:31 + [README.tun ssh.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/28 01:52:28 + [channels.c] + do not accept unreasonable X ports numbers; ok djm + - deraadt@cvs.openbsd.org 2006/03/28 01:53:43 + [ssh-agent.c] + use strtonum() to parse the pid from the file, and range check it + better; ok djm + - djm@cvs.openbsd.org 2006/03/30 09:41:25 + [channels.c] + ARGSUSED for dispatch table-driven functions + - djm@cvs.openbsd.org 2006/03/30 09:58:16 + [authfd.c bufaux.c deattack.c gss-serv.c mac.c misc.c misc.h] + [monitor_wrap.c msg.c packet.c sftp-client.c sftp-server.c ssh-agent.c] + replace {GET,PUT}_XXBIT macros with functionally similar functions, + silencing a heap of lint warnings. also allows them to use + __bounded__ checking which can't be applied to macros; requested + by and feedback from deraadt@ + - djm@cvs.openbsd.org 2006/03/30 10:41:25 + [ssh.c ssh_config.5] + add percent escape chars to the IdentityFile option, bz #1159 based + on a patch by imaging AT math.ualberta.ca; feedback and ok dtucker@ + - dtucker@cvs.openbsd.org 2006/03/30 11:05:17 + [ssh-keygen.c] + Correctly handle truncated files while converting keys; ok djm@ + - dtucker@cvs.openbsd.org 2006/03/30 11:40:21 + [auth.c monitor.c] + Prevent duplicate log messages when privsep=yes; ok djm@ + - jmc@cvs.openbsd.org 2006/03/31 09:09:30 + [ssh_config.5] + kill trailing whitespace; + - djm@cvs.openbsd.org 2006/03/31 09:13:56 + [ssh_config.5] + remote user escape is %r not %h; spotted by jmc@ + +20060326 + - OpenBSD CVS Sync + - jakob@cvs.openbsd.org 2006/03/15 08:46:44 + [ssh-keygen.c] + if no key file are given when printing the DNS host record, use the + host key file(s) as default. ok djm@ + - biorn@cvs.openbsd.org 2006/03/16 10:31:45 + [scp.c] + Try to display errormessage even if remout == -1 + ok djm@, markus@ + - djm@cvs.openbsd.org 2006/03/17 22:31:50 + [authfd.c] + another unreachable found by lint + - djm@cvs.openbsd.org 2006/03/17 22:31:11 + [authfd.c] + unreachanble statement, found by lint + - djm@cvs.openbsd.org 2006/03/19 02:22:32 + [serverloop.c] + memory leaks detected by Coverity via elad AT netbsd.org; + ok deraadt@ dtucker@ + - djm@cvs.openbsd.org 2006/03/19 02:22:56 + [sftp.c] + more memory leaks detected by Coverity via elad AT netbsd.org; + deraadt@ ok + - djm@cvs.openbsd.org 2006/03/19 02:23:26 + [hostfile.c] + FILE* leak detected by Coverity via elad AT netbsd.org; + ok deraadt@ + - djm@cvs.openbsd.org 2006/03/19 02:24:05 + [dh.c readconf.c servconf.c] + potential NULL pointer dereferences detected by Coverity + via elad AT netbsd.org; ok deraadt@ + - djm@cvs.openbsd.org 2006/03/19 07:41:30 + [sshconnect2.c] + memory leaks detected by Coverity via elad AT netbsd.org; + deraadt@ ok + - dtucker@cvs.openbsd.org 2006/03/19 11:51:52 + [servconf.c] + Correct strdelim null test; ok djm@ + - deraadt@cvs.openbsd.org 2006/03/19 18:52:11 + [auth1.c authfd.c channels.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/19 18:53:12 + [kex.c kex.h monitor.c myproposal.h session.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/19 18:56:41 + [clientloop.c progressmeter.c serverloop.c sshd.c] + ARGSUSED for signal handlers + - deraadt@cvs.openbsd.org 2006/03/19 18:59:49 + [ssh-keyscan.c] + please lint + - deraadt@cvs.openbsd.org 2006/03/19 18:59:30 + [ssh.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/19 18:59:09 + [authfile.c] + whoever thought that break after return was a good idea needs to + get their head examimed + - djm@cvs.openbsd.org 2006/03/20 04:09:44 + [monitor.c] + memory leaks detected by Coverity via elad AT netbsd.org; + deraadt@ ok + that should be all of them now + - djm@cvs.openbsd.org 2006/03/20 11:38:46 + [key.c] + (really) last of the Coverity diffs: avoid possible NULL deref in + key_free. via elad AT netbsd.org; markus@ ok + - deraadt@cvs.openbsd.org 2006/03/20 17:10:19 + [auth.c key.c misc.c packet.c ssh-add.c] + in a switch (), break after return or goto is stupid + - deraadt@cvs.openbsd.org 2006/03/20 17:13:16 + [key.c] + djm did a typo + - deraadt@cvs.openbsd.org 2006/03/20 17:17:23 + [ssh-rsa.c] + in a switch (), break after return or goto is stupid + - deraadt@cvs.openbsd.org 2006/03/20 18:14:02 + [channels.c clientloop.c monitor_wrap.c monitor_wrap.h serverloop.c] + [ssh.c sshpty.c sshpty.h] + sprinkle u_int throughout pty subsystem, ok markus + - deraadt@cvs.openbsd.org 2006/03/20 18:17:20 + [auth1.c auth2.c sshd.c] + sprinkle some ARGSUSED for table driven functions (which sometimes + must ignore their args) + - deraadt@cvs.openbsd.org 2006/03/20 18:26:55 + [channels.c monitor.c session.c session.h ssh-agent.c ssh-keygen.c] + [ssh-rsa.c ssh.c sshlogin.c] + annoying spacing fixes getting in the way of real diffs + - deraadt@cvs.openbsd.org 2006/03/20 18:27:50 + [monitor.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/20 18:35:12 + [channels.c] + x11_fake_data is only ever used as u_char * + - deraadt@cvs.openbsd.org 2006/03/20 18:41:43 + [dns.c] + cast xstrdup to propert u_char * + - deraadt@cvs.openbsd.org 2006/03/20 18:42:27 + [canohost.c match.c ssh.c sshconnect.c] + be strict with tolower() casting + - deraadt@cvs.openbsd.org 2006/03/20 18:48:34 + [channels.c fatal.c kex.c packet.c serverloop.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/20 21:11:53 + [ttymodes.c] + spacing + - djm@cvs.openbsd.org 2006/03/25 00:05:41 + [auth-bsdauth.c auth-skey.c auth.c auth2-chall.c channels.c] + [clientloop.c deattack.c gss-genr.c kex.c key.c misc.c moduli.c] + [monitor.c monitor_wrap.c packet.c scard.c sftp-server.c ssh-agent.c] + [ssh-keyscan.c ssh.c sshconnect.c sshconnect2.c sshd.c uuencode.c] + [xmalloc.c xmalloc.h] + introduce xcalloc() and xasprintf() failure-checked allocations + functions and use them throughout openssh + + xcalloc is particularly important because malloc(nmemb * size) is a + dangerous idiom (subject to integer overflow) and it is time for it + to die + + feedback and ok deraadt@ + - djm@cvs.openbsd.org 2006/03/25 01:13:23 + [buffer.c channels.c deattack.c misc.c scp.c session.c sftp-client.c] + [sftp-server.c ssh-agent.c ssh-rsa.c xmalloc.c xmalloc.h auth-pam.c] + [uidswap.c] + change OpenSSH's xrealloc() function from being xrealloc(p, new_size) + to xrealloc(p, new_nmemb, new_itemsize). + + realloc is particularly prone to integer overflows because it is + almost always allocating "n * size" bytes, so this is a far safer + API; ok deraadt@ + - djm@cvs.openbsd.org 2006/03/25 01:30:23 + [sftp.c] + "abormally" is a perfectly cromulent word, but "abnormally" is better + - djm@cvs.openbsd.org 2006/03/25 13:17:03 + [atomicio.c auth-bsdauth.c auth-chall.c auth-options.c auth-passwd.c] + [auth-rh-rsa.c auth-rhosts.c auth-rsa.c auth-skey.c auth.c auth1.c] + [auth2-chall.c auth2-hostbased.c auth2-kbdint.c auth2-none.c] + [auth2-passwd.c auth2-pubkey.c auth2.c authfd.c authfile.c bufaux.c] + [buffer.c canohost.c channels.c cipher-3des1.c cipher-bf1.c] + [cipher-ctr.c cipher.c cleanup.c clientloop.c compat.c compress.c] + [deattack.c dh.c dispatch.c fatal.c groupaccess.c hostfile.c kex.c] + [kexdh.c kexdhc.c kexdhs.c kexgex.c kexgexc.c kexgexs.c key.c log.c] + [mac.c match.c md-sha256.c misc.c monitor.c monitor_fdpass.c] + [monitor_mm.c monitor_wrap.c msg.c nchan.c packet.c progressmeter.c] + [readconf.c readpass.c rsa.c scard.c scp.c servconf.c serverloop.c] + [session.c sftp-client.c sftp-common.c sftp-glob.c sftp-server.c] + [sftp.c ssh-add.c ssh-agent.c ssh-dss.c ssh-keygen.c ssh-keyscan.c] + [ssh-keysign.c ssh-rsa.c ssh.c sshconnect.c sshconnect1.c] + [sshconnect2.c sshd.c sshlogin.c sshpty.c sshtty.c ttymodes.c] + [uidswap.c uuencode.c xmalloc.c] + Put $OpenBSD$ tags back (as comments) to replace the RCSID()s that + Theo nuked - our scripts to sync -portable need them in the files + - deraadt@cvs.openbsd.org 2006/03/25 18:29:35 + [auth-rsa.c authfd.c packet.c] + needed casts (always will be needed) + - deraadt@cvs.openbsd.org 2006/03/25 18:30:55 + [clientloop.c serverloop.c] + spacing + - deraadt@cvs.openbsd.org 2006/03/25 18:36:15 + [sshlogin.c sshlogin.h] + nicer size_t and time_t types + - deraadt@cvs.openbsd.org 2006/03/25 18:40:14 + [ssh-keygen.c] + cast strtonum() result to right type + - deraadt@cvs.openbsd.org 2006/03/25 18:41:45 + [ssh-agent.c] + mark two more signal handlers ARGSUSED + - deraadt@cvs.openbsd.org 2006/03/25 18:43:30 + [channels.c] + use strtonum() instead of atoi() [limit X screens to 400, sorry] + - deraadt@cvs.openbsd.org 2006/03/25 18:56:55 + [bufaux.c channels.c packet.c] + remove (char *) casts to a function that accepts void * for the arg + - deraadt@cvs.openbsd.org 2006/03/25 18:58:10 + [channels.c] + delete cast not required + - djm@cvs.openbsd.org 2006/03/25 22:22:43 + [atomicio.h auth-options.h auth.h auth2-gss.c authfd.h authfile.h] + [bufaux.h buffer.h canohost.h channels.h cipher.h clientloop.h] + [compat.h compress.h crc32.c crc32.h deattack.h dh.h dispatch.h] + [dns.c dns.h getput.h groupaccess.h gss-genr.c gss-serv-krb5.c] + [gss-serv.c hostfile.h includes.h kex.h key.h log.h mac.h match.h] + [misc.h monitor.h monitor_fdpass.h monitor_mm.h monitor_wrap.h msg.h] + [myproposal.h packet.h pathnames.h progressmeter.h readconf.h rsa.h] + [scard.h servconf.h serverloop.h session.h sftp-common.h sftp.h] + [ssh-gss.h ssh.h ssh1.h ssh2.h sshconnect.h sshlogin.h sshpty.h] + [ttymodes.h uidswap.h uuencode.h xmalloc.h] + standardise spacing in $OpenBSD$ tags; requested by deraadt@ + - deraadt@cvs.openbsd.org 2006/03/26 01:31:48 + [uuencode.c] + typo + +20060325 + - OpenBSD CVS Sync + - djm@cvs.openbsd.org 2006/03/16 04:24:42 + [ssh.1] + Add RFC4419 (Diffie-Hellman group exchange KEX) to the list of SSH RFCs + that OpenSSH supports + - deraadt@cvs.openbsd.org 2006/03/19 18:51:18 + [atomicio.c auth-bsdauth.c auth-chall.c auth-krb5.c auth-options.c] + [auth-pam.c auth-passwd.c auth-rh-rsa.c auth-rhosts.c auth-rsa.c] + [auth-shadow.c auth-skey.c auth.c auth1.c auth2-chall.c] + [auth2-hostbased.c auth2-kbdint.c auth2-none.c auth2-passwd.c] + [auth2-pubkey.c auth2.c authfd.c authfile.c bufaux.c buffer.c] + [canohost.c channels.c cipher-3des1.c cipher-acss.c cipher-aes.c] + [cipher-bf1.c cipher-ctr.c cipher.c cleanup.c clientloop.c compat.c] + [compress.c deattack.c dh.c dispatch.c dns.c entropy.c fatal.c] + [groupaccess.c hostfile.c includes.h kex.c kexdh.c kexdhc.c] + [kexdhs.c kexgex.c kexgexc.c kexgexs.c key.c log.c loginrec.c] + [loginrec.h logintest.c mac.c match.c md-sha256.c md5crypt.c misc.c] + [monitor.c monitor_fdpass.c monitor_mm.c monitor_wrap.c msg.c] + [nchan.c packet.c progressmeter.c readconf.c readpass.c rsa.c] + [scard.c scp.c servconf.c serverloop.c session.c sftp-client.c] + [sftp-common.c sftp-glob.c sftp-server.c sftp.c ssh-add.c] + [ssh-agent.c ssh-dss.c ssh-keygen.c ssh-keyscan.c ssh-keysign.c] + [ssh-rand-helper.c ssh-rsa.c ssh.c sshconnect.c sshconnect1.c] + [sshconnect2.c sshd.c sshlogin.c sshpty.c sshtty.c ttymodes.c] + [uidswap.c uuencode.c xmalloc.c openbsd-compat/bsd-arc4random.c] + [openbsd-compat/bsd-closefrom.c openbsd-compat/bsd-cygwin_util.c] + [openbsd-compat/bsd-getpeereid.c openbsd-compat/bsd-misc.c] + [openbsd-compat/bsd-nextstep.c openbsd-compat/bsd-snprintf.c] + [openbsd-compat/bsd-waitpid.c openbsd-compat/fake-rfc2553.c] + RCSID() can die + - deraadt@cvs.openbsd.org 2006/03/19 18:53:12 + [kex.h myproposal.h] + spacing + - djm@cvs.openbsd.org 2006/03/20 04:07:22 + [auth2-gss.c] + GSSAPI related leaks detected by Coverity via elad AT netbsd.org; + reviewed by simon AT sxw.org.uk; deraadt@ ok + - djm@cvs.openbsd.org 2006/03/20 04:07:49 + [gss-genr.c] + more GSSAPI related leaks detected by Coverity via elad AT netbsd.org; + reviewed by simon AT sxw.org.uk; deraadt@ ok + - djm@cvs.openbsd.org 2006/03/20 04:08:18 + [gss-serv.c] + last lot of GSSAPI related leaks detected by Coverity via + elad AT netbsd.org; reviewed by simon AT sxw.org.uk; deraadt@ ok + - deraadt@cvs.openbsd.org 2006/03/20 18:14:02 + [monitor_wrap.h sshpty.h] + sprinkle u_int throughout pty subsystem, ok markus + - deraadt@cvs.openbsd.org 2006/03/20 18:26:55 + [session.h] + annoying spacing fixes getting in the way of real diffs + - deraadt@cvs.openbsd.org 2006/03/20 18:41:43 + [dns.c] + cast xstrdup to propert u_char * + - jakob@cvs.openbsd.org 2006/03/22 21:16:24 + [ssh.1] + simplify SSHFP example; ok jmc@ + - djm@cvs.openbsd.org 2006/03/22 21:27:15 + [deattack.c deattack.h] + remove IV support from the CRC attack detector, OpenSSH has never used + it - it only applied to IDEA-CFB, which we don't support. + prompted by NetBSD Coverity report via elad AT netbsd.org; + feedback markus@ "nuke it" deraadt@ + +20060318 + - (djm) [auth-pam.c] Fix memleak in error path, from Coverity via + elad AT NetBSD.org + - (dtucker) [openbsd-compat/bsd-snprintf.c] Bug #1173: make fmtint() take + a LLONG rather than a long. Fixes scp'ing of large files on platforms + with missing/broken snprintfs. Patch from e.borovac at bom.gov.au. + +20060316 + - (dtucker) [entropy.c] Add headers for WIFEXITED and friends. + - (dtucker) [configure.ac md-sha256.c] NetBSD has sha2.h in + /usr/include/crypto. Hint from djm@. + - (tim) [kex.c myproposal.h md-sha256.c openbsd-compat/sha2.c,h] + Disable sha256 when openssl < 0.9.7. Patch from djm@. + - (djm) [kex.c] Slightly more clean deactivation of dhgex-sha256 on old + OpenSSL; ok tim + +20060315 + - (djm) OpenBSD CVS Sync: + - msf@cvs.openbsd.org 2006/02/06 15:54:07 + [ssh.1] + - typo fix + ok jmc@ + - jmc@cvs.openbsd.org 2006/02/06 21:44:47 + [ssh.1] + make this a little less ambiguous... + - stevesk@cvs.openbsd.org 2006/02/07 01:08:04 + [auth-rhosts.c includes.h] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/07 01:18:09 + [includes.h ssh-agent.c ssh-keyscan.c sshconnect2.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/07 01:42:00 + [channels.c clientloop.c clientloop.h includes.h packet.h] + [serverloop.c sshpty.c sshpty.h sshtty.c ttymodes.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/07 01:52:50 + [sshtty.c] + "log.h" not needed + - stevesk@cvs.openbsd.org 2006/02/07 03:47:05 + [hostfile.c] + "packet.h" not needed + - stevesk@cvs.openbsd.org 2006/02/07 03:59:20 + [deattack.c] + duplicate #include + - stevesk@cvs.openbsd.org 2006/02/08 12:15:27 + [auth.c clientloop.c includes.h misc.c monitor.c readpass.c] + [session.c sftp.c ssh-agent.c ssh-keysign.c ssh.c sshconnect.c] + [sshd.c sshpty.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/08 12:32:49 + [includes.h misc.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/08 13:15:44 + [gss-serv.c monitor.c] + small KNF + - stevesk@cvs.openbsd.org 2006/02/08 14:16:59 + [sshconnect.c] + not needed + - stevesk@cvs.openbsd.org 2006/02/08 14:31:30 + [includes.h ssh-agent.c ssh-keyscan.c ssh.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/08 14:38:18 + [includes.h packet.c] + move #include and out of + includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/08 23:51:24 + [includes.h scp.c sftp-glob.c sftp-server.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/09 00:32:07 + [includes.h] + #include not needed; ok djm@ + NB. ID Sync only - we still need this (but it may move later) + - jmc@cvs.openbsd.org 2006/02/09 10:10:47 + [sshd.8] + - move some text into a CAVEATS section + - merge the COMMAND EXECUTION... section into AUTHENTICATION + - stevesk@cvs.openbsd.org 2006/02/10 00:27:13 + [channels.c clientloop.c includes.h misc.c progressmeter.c sftp.c] + [ssh.c sshd.c sshpty.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/10 01:44:27 + [includes.h monitor.c readpass.c scp.c serverloop.c session.c] + [sftp.c sshconnect.c sshconnect2.c sshd.c] + move #include out of includes.h; ok markus@ + - otto@cvs.openbsd.org 2006/02/11 19:31:18 + [atomicio.c] + type correctness; from Ray Lai in PR 5011; ok millert@ + - djm@cvs.openbsd.org 2006/02/12 06:45:34 + [ssh.c ssh_config.5] + add a %l expansion code to the ControlPath, which is filled in with the + local hostname at runtime. Requested by henning@ to avoid some problems + with /home on NFS; ok dtucker@ + - djm@cvs.openbsd.org 2006/02/12 10:44:18 + [readconf.c] + raise error when the user specifies a RekeyLimit that is smaller than 16 + (the smallest of our cipher's blocksize) or big enough to cause integer + wraparound; ok & feedback dtucker@ + - jmc@cvs.openbsd.org 2006/02/12 10:49:44 + [ssh_config.5] + slight rewording; ok djm + - jmc@cvs.openbsd.org 2006/02/12 10:52:41 + [sshd.8] + rework the description of authorized_keys a little; + - jmc@cvs.openbsd.org 2006/02/12 17:57:19 + [sshd.8] + sort the list of options permissable w/ authorized_keys; + ok djm dtucker + - jmc@cvs.openbsd.org 2006/02/13 10:16:39 + [sshd.8] + no need to subsection the authorized_keys examples - instead, convert + this to look like an actual file. also use proto 2 keys, and use IETF + example addresses; + - jmc@cvs.openbsd.org 2006/02/13 10:21:25 + [sshd.8] + small tweaks for the ssh_known_hosts section; + - jmc@cvs.openbsd.org 2006/02/13 11:02:26 + [sshd.8] + turn this into an example ssh_known_hosts file; ok djm + - jmc@cvs.openbsd.org 2006/02/13 11:08:43 + [sshd.8] + - avoid nasty line split + - `*' does not need to be escaped + - jmc@cvs.openbsd.org 2006/02/13 11:27:25 + [sshd.8] + sort FILES and use a -compact list; + - david@cvs.openbsd.org 2006/02/15 05:08:24 + [sftp-client.c] + typo in comment; ok djm@ + - jmc@cvs.openbsd.org 2006/02/15 16:53:20 + [ssh.1] + remove the IETF draft references and replace them with some updated RFCs; + - jmc@cvs.openbsd.org 2006/02/15 16:55:33 + [sshd.8] + remove ietf draft references; RFC list now maintained in ssh.1; + - jmc@cvs.openbsd.org 2006/02/16 09:05:34 + [sshd.8] + sync some of the FILES entries w/ ssh.1; + - jmc@cvs.openbsd.org 2006/02/19 19:52:10 + [sshd.8] + move the sshrc stuff out of FILES, and into its own section: + FILES is not a good place to document how stuff works; + - jmc@cvs.openbsd.org 2006/02/19 20:02:17 + [sshd.8] + sync the (s)hosts.equiv FILES entries w/ those from ssh.1; + - jmc@cvs.openbsd.org 2006/02/19 20:05:00 + [sshd.8] + grammar; + - jmc@cvs.openbsd.org 2006/02/19 20:12:25 + [ssh_config.5] + add some vertical space; + - stevesk@cvs.openbsd.org 2006/02/20 16:36:15 + [authfd.c channels.c includes.h session.c ssh-agent.c ssh.c] + move #include out of includes.h; ok djm@ + - stevesk@cvs.openbsd.org 2006/02/20 17:02:44 + [clientloop.c includes.h monitor.c progressmeter.c scp.c] + [serverloop.c session.c sftp.c ssh-agent.c ssh.c sshd.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/20 17:19:54 + [auth-rhosts.c auth-rsa.c auth.c auth2-none.c auth2-pubkey.c] + [authfile.c clientloop.c includes.h readconf.c scp.c session.c] + [sftp-client.c sftp-common.c sftp-common.h sftp-glob.c] + [sftp-server.c sftp.c ssh-add.c ssh-keygen.c ssh.c sshconnect.c] + [sshconnect2.c sshd.c sshpty.c] + move #include out of includes.h; ok markus@ + - stevesk@cvs.openbsd.org 2006/02/22 00:04:45 + [canohost.c clientloop.c includes.h match.c readconf.c scp.c ssh.c] + [sshconnect.c] + move #include out of includes.h; ok djm@ + - jmc@cvs.openbsd.org 2006/02/24 10:25:14 + [ssh_config.5] + add section on patterns; + from dtucker + myself + - jmc@cvs.openbsd.org 2006/02/24 10:33:54 + [sshd_config.5] + signpost to PATTERNS; + - jmc@cvs.openbsd.org 2006/02/24 10:37:07 + [ssh_config.5] + tidy up the refs to PATTERNS; + - jmc@cvs.openbsd.org 2006/02/24 10:39:52 + [sshd.8] + signpost to PATTERNS section; + - jmc@cvs.openbsd.org 2006/02/24 20:22:16 + [ssh-keysign.8 ssh_config.5 sshd_config.5] + some consistency fixes; + - jmc@cvs.openbsd.org 2006/02/24 20:31:31 + [ssh.1 ssh_config.5 sshd.8 sshd_config.5] + more consistency fixes; + - jmc@cvs.openbsd.org 2006/02/24 23:20:07 + [ssh_config.5] + some grammar/wording fixes; + - jmc@cvs.openbsd.org 2006/02/24 23:43:57 + [sshd_config.5] + some grammar/wording fixes; + - jmc@cvs.openbsd.org 2006/02/24 23:51:17 + [sshd_config.5] + oops - bits i missed; + - jmc@cvs.openbsd.org 2006/02/25 12:26:17 + [ssh_config.5] + document the possible values for KbdInteractiveDevices; + help/ok dtucker + - jmc@cvs.openbsd.org 2006/02/25 12:28:34 + [sshd_config.5] + document the order in which allow/deny directives are processed; + help/ok dtucker + - jmc@cvs.openbsd.org 2006/02/26 17:17:18 + [ssh_config.5] + move PATTERNS to the end of the main body; requested by dtucker + - jmc@cvs.openbsd.org 2006/02/26 18:01:13 + [sshd_config.5] + subsection is pointless here; + - jmc@cvs.openbsd.org 2006/02/26 18:03:10 + [ssh_config.5] + comma; + - djm@cvs.openbsd.org 2006/02/28 01:10:21 + [session.c] + fix logout recording when privilege separation is disabled, analysis and + patch from vinschen at redhat.com; tested by dtucker@ ok deraadt@ + NB. ID sync only - patch already in portable + - djm@cvs.openbsd.org 2006/03/04 04:12:58 + [serverloop.c] + move a debug() outside of a signal handler; ok markus@ a little while back + - djm@cvs.openbsd.org 2006/03/12 04:23:07 + [ssh.c] + knf nit + - djm@cvs.openbsd.org 2006/03/13 08:16:00 + [sshd.c] + don't log that we are listening on a socket before the listen() call + actually succeeds, bz #1162 reported by Senthil Kumar; ok dtucker@ + - dtucker@cvs.openbsd.org 2006/03/13 08:33:00 + [packet.c] + Set TCP_NODELAY for all connections not just "interactive" ones. Fixes + poor performance and protocol stalls under some network conditions (mindrot + bugs #556 and #981). Patch originally from markus@, ok djm@ + - dtucker@cvs.openbsd.org 2006/03/13 08:43:16 + [ssh-keygen.c] + Make ssh-keygen handle CR and CRLF line termination when converting IETF + format keys, in adition to vanilla LF. mindrot #1157, tested by Chris + Pepper, ok djm@ + - dtucker@cvs.openbsd.org 2006/03/13 10:14:29 + [misc.c ssh_config.5 sshd_config.5] + Allow config directives to contain whitespace by surrounding them by double + quotes. mindrot #482, man page help from jmc@, ok djm@ + - dtucker@cvs.openbsd.org 2006/03/13 10:26:52 + [authfile.c authfile.h ssh-add.c] + Make ssh-add check file permissions before attempting to load private + key files multiple times; it will fail anyway and this prevents confusing + multiple prompts and warnings. mindrot #1138, ok djm@ + - djm@cvs.openbsd.org 2006/03/14 00:15:39 + [canohost.c] + log the originating address and not just the name when a reverse + mapping check fails, requested by linux AT linuon.com + - markus@cvs.openbsd.org 2006/03/14 16:32:48 + [ssh_config.5 sshd_config.5] + *AliveCountMax applies to protcol v2 only; ok dtucker, djm + - djm@cvs.openbsd.org 2006/03/07 09:07:40 + [kex.c kex.h monitor.c myproposal.h ssh-keyscan.c sshconnect2.c sshd.c] + Implement the diffie-hellman-group-exchange-sha256 key exchange method + using the SHA256 code in libc (and wrapper to make it into an OpenSSL + EVP), interop tested against CVS PuTTY + NB. no portability bits committed yet + - (djm) [configure.ac defines.h kex.c md-sha256.c] + [openbsd-compat/sha2.h openbsd-compat/openbsd-compat.h] + [openbsd-compat/sha2.c] First stab at portability glue for SHA256 + KEX support, should work with libc SHA256 support or OpenSSL + EVP_sha256 if present + - (djm) [includes.h] Restore accidentally dropped netinet/in.h + - (djm) [Makefile.in openbsd-compat/Makefile.in] Add added files + - (djm) [md-sha256.c configure.ac] md-sha256.c needs sha2.h if present + - (djm) [regress/.cvsignore] Ignore Makefile here + - (djm) [loginrec.c] Need stat.h + - (djm) [openbsd-compat/sha2.h] Avoid include macro clash with + system sha2.h + - (djm) [ssh-rand-helper.c] Needs a bunch of headers + - (djm) [ssh-agent.c] Restore dropped stat.h + - (djm) [openbsd-compat/sha2.h openbsd-compat/sha2.c] Comment out + SHA384, which we don't need and doesn't compile without tweaks + - (djm) [auth-pam.c clientloop.c includes.h monitor.c session.c] + [sftp-client.c ssh-keysign.c ssh.c sshconnect.c sshconnect2.c] + [sshd.c openbsd-compat/bsd-misc.c openbsd-compat/bsd-openpty.c] + [openbsd-compat/glob.c openbsd-compat/mktemp.c] + [openbsd-compat/readpassphrase.c] Lots of include fixes for + OpenSolaris + - (tim) [includes.h] put sys/stat.h back in to quiet some "macro redefined:" + - (tim) [openssh/sshpty.c openssh/openbsd-compat/port-tun.c] put in some + includes removed from includes.h + - (dtucker) [configure.ac] Fix glob test conversion to AC_TRY_COMPILE + - (djm) [includes.h] Put back paths.h, it is needed in defines.h + - (dtucker) [openbsd-compat/openbsd-compat.h] AIX (at least) needs + sys/ioctl.h for struct winsize. + - (dtucker) [configure.ac] login_cap.h requires sys/types.h on NetBSD. + +20060313 + - (dtucker) [configure.ac] Bug #1171: Don't use printf("%lld", longlong) + since not all platforms support it. Instead, use internal equivalent while + computing LLONG_MIN and LLONG_MAX. Remove special case for alpha-dec-osf* + as it's no longer required. Tested by Bernhard Simon, ok djm@ + +20060304 + - (dtucker) [contrib/cygwin/ssh-host-config] Require use of lastlog as a + file rather than directory, required as Cygwin will be importing lastlog(1). + Also tightens up permissions on the file. Patch from vinschen@redhat.com. + - (dtucker) [gss-serv-krb5.c] Bug #1166: Correct #ifdefs for gssapi_krb5.h + includes. Patch from gentoo.riverrat at gmail.com. + +20060226 + - (dtucker) [configure.ac] Bug #1156: QNX apparently needs SSHD_ACQUIRES_CTTY + patch from kraai at ftbfs.org. + +20060223 + - (dtucker) [sshd_config sshd_config.5] Update UsePAM to reflect current + reality. Pointed out by tryponraj at gmail.com. + +20060222 + - (dtucker) [openbsd-compat/openssl-compat.{c,h}] Minor tidy up: only + compile in compat code if required. + +20060221 + - (dtucker) [openbsd-compat/openssl-compat.h] Prevent warning about + redefinition of SSLeay_add_all_algorithms. + +20060220 + - (dtucker) [INSTALL configure.ac openbsd-compat/openssl-compat.{c,h}] + Add optional enabling of OpenSSL's (hardware) Engine support, via + configure --with-ssl-engine. Based in part on a diff by michal at + logix.cz. + +20060219 + - (dtucker) [Makefile.in configure.ac, added openbsd-compat/regress/] + Add first attempt at regress tests for compat library. ok djm@ + +20060214 + - (tim) [buildpkg.sh.in] Make the names consistent. + s/pkg_post_make_install_fixes.sh/pkg-post-make-install-fixes.sh/ OK dtucker@ + +20060212 + - (dtucker) [openbsd-compat/bsd-cygwin_util.c] Make loop counter unsigned + to silence compiler warning, from vinschen at redhat.com. + - (tim) [configure.ac] Bug #1149. Disable /etc/default/login check for QNX. + - (dtucker) [README version.h contrib/caldera/openssh.spec + contrib/redhat/openssh.spec contrib/suse/openssh.spec] Bump version + strings to match 4.3p2 release. 20060208 - (tim) [session.c] Logout records were not updated on systems with post auth privsep disabled due to bug 1086 changes. Analysis and patch by vinschen at redhat.com. OK tim@, dtucker@. - (dtucker) [configure.ac] Typo in Ultrix and NewsOS sections (NEED_SETPRGP - -> NEED_SETPGRP), reported by Berhard Simon. ok tim@ + -> NEED_SETPGRP), reported by Bernhard Simon. ok tim@ 20060206 - (tim) [configure.ac] Remove unnecessary tests for net/if.h and @@ -860,2995 +2606,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -20050901 - - (djm) Update RPM spec file versions - -20050831 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2005/08/30 22:08:05 - [gss-serv.c sshconnect2.c] - destroy credentials if krb5_kuserok() call fails. Stops credentials being - delegated to users who are not authorised for GSSAPIAuthentication when - GSSAPIDeletegateCredentials=yes and another authentication mechanism - succeeds; bz#1073 reported by paul.moore AT centrify.com, fix by - simon AT sxw.org.uk, tested todd@ biorn@ jakob@; ok deraadt@ - - markus@cvs.openbsd.org 2005/08/31 09:28:42 - [version.h] - 4.2 - - (dtucker) [README] Update release note URL to 4.2 - - (tim) [configure.ac auth.c defines.h session.c openbsd-compat/port-uw.c - openbsd-compat/port-uw.h openbsd-compat/xcrypt.c] libiaf cleanup. Disable - libiaf bits for OpenServer6. Free memory allocated by ia_get_logpwd(). - Feedback and OK dtucker@ - -20050830 - - (tim) [configure.ac] Back out last change. It needs to be done differently. - -20050829 - - (tim) [configure.ac] ia_openinfo() seems broken on OSR6. Limit UW long - password support to 7.x for now. - -20050826 - - (tim) [CREDITS LICENCE auth.c configure.ac defines.h includes.h session.c - openbsd-compat/Makefile.in openbsd-compat/openbsd-compat.h - openbsd-compat/xcrypt.c] New files [openssh/openbsd-compat/port-uw.c - openssh/openbsd-compat/port-uw.h] Support long passwords (> 8-char) - on UnixWare 7 from Dhiraj Gulati and Ahsan Rashid. Cleanup and testing - by tim@. Feedback and OK dtucker@ - -20050823 - - (dtucker) [regress/test-exec.sh] Do not prepend an extra "/" to a fully- - qualified sshd pathname since some systems (eg Cygwin) may consider "/foo" - and "//foo" to be different. Spotted by vinschen at redhat.com. - - (tim) [configure.ac] Not all gcc's support -Wsign-compare. Enhancements - and OK dtucker@ - - (tim) [defines.h] PATH_MAX bits for OpenServer OK dtucker@ - -20050821 - - (dtucker) [configure.ac defines.h includes.h sftp.c] Add support for - LynxOS, patch from Olli Savia (ops at iki.fi). ok djm@ - -20050816 - - (djm) [ttymodes.c] bugzilla #1025: Fix encoding of _POSIX_VDISABLE, - from Jacob Nevins; ok dtucker@ - -20050815 - - (tim) [sftp.c] wrap el_end() in #ifdef USE_LIBEDIT - - (tim) [configure.ac] corrections to libedit tests. Report and patches - by skeleten AT shillest.net - -20050812 - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2005/07/28 17:36:22 - [packet.c] - missing packet_init_compression(); from solar - - djm@cvs.openbsd.org 2005/07/30 01:26:16 - [ssh.c] - fix -D listen_host initialisation, so it picks up gateway_ports setting - correctly - - djm@cvs.openbsd.org 2005/07/30 02:03:47 - [readconf.c] - listen_hosts initialisation here too; spotted greg AT y2005.nest.cx - - dtucker@cvs.openbsd.org 2005/08/06 10:03:12 - [servconf.c] - Unbreak sshd ListenAddress for bare IPv6 addresses. - Report from Janusz Mucka; ok djm@ - - jaredy@cvs.openbsd.org 2005/08/08 13:22:48 - [sftp.c] - sftp prompt enhancements: - - in non-interactive mode, do not print an empty prompt at the end - before finishing - - print newline after EOF in editline mode - - call el_end() in editline mode - ok dtucker djm - -20050810 - - (dtucker) [configure.ac] Test libedit library and headers for compatibility. - Report from skeleten AT shillest.net, ok djm@ - - (dtucker) [LICENCE configure.ac defines.h openbsd-compat/realpath.c] - Sync current (thread-safe) version of realpath.c from OpenBSD (which is - in turn based on FreeBSD's). ok djm@ - -20050809 - - (tim) [configure.ac] Allow --with-audit=no. OK dtucker@ - Report by skeleten AT shillest.net - -20050803 - - (dtucker) [openbsd-compat/fake-rfc2553.h] Check for EAI_* defines - individually and use a value less likely to collide with real values from - netdb.h. Fixes compile warnings on FreeBSD 5.3. ok djm@ - - (dtucker) [openbsd-compat/fake-rfc2553.h] MAX_INT -> INT_MAX since the - latter is specified in the standard. - -20050802 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2005/07/27 10:39:03 - [scp.c hostfile.c sftp-client.c] - Silence bogus -Wuninitialized warnings; ok djm@ - - (dtucker) [configure.ac] Enable -Wuninitialized by default when compiling - with gcc. ok djm@ - - (dtucker) [configure.ac] Add a --with-Werror option to configure for - adding -Werror to CFLAGS when all of the configure tests are done. ok djm@ - -20050726 - - (dtucker) [configure.ac] Update zlib warning message too, pointed out by - tim@. - - (djm) OpenBSD CVS Sync - - otto@cvs.openbsd.org 2005/07/19 15:32:26 - [auth-passwd.c] - auth_usercheck(3) can return NULL, so check for that. Report from - mpech@. ok markus@ - - markus@cvs.openbsd.org 2005/07/25 11:59:40 - [kex.c kex.h myproposal.h packet.c packet.h servconf.c session.c] - [sshconnect2.c sshd.c sshd_config sshd_config.5] - add a new compression method that delays compression until the user - has been authenticated successfully and set compression to 'delayed' - for sshd. - this breaks older openssh clients (< 3.5) if they insist on - compression, so you have to re-enable compression in sshd_config. - ok djm@ - -20050725 - - (dtucker) [configure.ac] Update zlib version check for CAN-2005-2096. - -20050717 -- OpenBSD CVS Sync - - djm@cvs.openbsd.org 2005/07/16 01:35:24 - [auth1.c channels.c cipher.c clientloop.c kex.c session.c ssh.c] - [sshconnect.c] - spacing - - (djm) [acss.c auth-pam.c auth-shadow.c auth-skey.c auth1.c canohost.c] - [cipher-acss.c loginrec.c ssh-rand-helper.c sshd.c] Fix whitespace at EOL - in portable too ("perl -p -i -e 's/\s+$/\n/' *.[ch]") - - (djm) [auth-pam.c sftp.c] spaces vs. tabs at start of line - - djm@cvs.openbsd.org 2005/07/17 06:49:04 - [channels.c channels.h session.c session.h] - Fix a number of X11 forwarding channel leaks: - 1. Refuse multiple X11 forwarding requests on the same session - 2. Clean up all listeners after a single_connection X11 forward, not just - the one that made the single connection - 3. Destroy X11 listeners when the session owning them goes away - testing and ok dtucker@ - - djm@cvs.openbsd.org 2005/07/17 07:17:55 - [auth-rh-rsa.c auth-rhosts.c auth2-chall.c auth2-gss.c channels.c] - [cipher-ctr.c gss-genr.c gss-serv.c kex.c moduli.c readconf.c] - [serverloop.c session.c sftp-client.c sftp.c ssh-add.c ssh-keygen.c] - [sshconnect.c sshconnect2.c] - knf says that a 2nd level indent is four (not three or five) spaces - -(djm) [audit.c auth1.c auth2.c entropy.c loginrec.c serverloop.c] - [ssh-rand-helper.c] fix portable 2nd level indents at 4 spaces too - - (djm) [monitor.c monitor_wrap.c] -Wsign-compare for PAM monitor calls - -20050716 - - (dtucker) [auth-pam.c] Ensure that only one side of the authentication - socketpair stays open on in both the monitor and PAM process. Patch from - Joerg Sonnenberger. - -20050714 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2005/07/06 09:33:05 - [ssh.1] - clarify meaning of ssh -b ; with & ok jmc@ - - dtucker@cvs.openbsd.org 2005/07/08 09:26:18 - [misc.c] - Make comment match code; ok djm@ - - markus@cvs.openbsd.org 2005/07/08 09:41:33 - [channels.h] - race when efd gets closed while there is still buffered data: - change CHANNEL_EFD_OUTPUT_ACTIVE() - 1) c->efd must always be valid AND - 2a) no EOF has been seen OR - 2b) there is buffered data - report, initial fix and testing Chuck Cranor - - dtucker@cvs.openbsd.org 2005/07/08 10:20:41 - [ssh_config.5] - change BindAddress to match recent ssh -b change; prompted by markus@ - - jmc@cvs.openbsd.org 2005/07/08 12:53:10 - [ssh_config.5] - new sentence, new line; - - dtucker@cvs.openbsd.org 2005/07/14 04:00:43 - [misc.h] - use __sentinel__ attribute; ok deraadt@ djm@ markus@ - - (dtucker) [configure.ac defines.h] Define __sentinel__ to nothing if the - compiler doesn't understand it to prevent warnings. If any mainstream - compiler versions acquire it we can test for those versions. Based on - discussion with djm@. - -20050707 - - dtucker [auth-krb5.c auth.h gss-serv-krb5.c] Move KRB5CCNAME generation for - the MIT Kerberos code path into a common function and expand mkstemp - template to be consistent with the rest of OpenSSH. From sxw at - inf.ed.ac.uk, ok djm@ - - (dtucker) [auth-krb5.c] There's no guarantee that snprintf will set errno - in the case where the buffer is insufficient, so always return ENOMEM. - Also pointed out by sxw at inf.ed.ac.uk. - - (dtucker) [acconfig.h auth-krb5.c configure.ac gss-serv-krb5.c] Remove - calls to krb5_init_ets, which has not been required since krb-1.1.x and - most Kerberos versions no longer export in their public API. From sxw - at inf.ed.ac.uk, ok djm@ - -20050706 - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2005/07/01 13:19:47 - [channels.c] - don't free() if getaddrinfo() fails; report mpech@ - - djm@cvs.openbsd.org 2005/07/04 00:58:43 - [channels.c clientloop.c clientloop.h misc.c misc.h ssh.c ssh_config.5] - implement support for X11 and agent forwarding over multiplex slave - connections. Because of protocol limitations, the slave connections inherit - the master's DISPLAY and SSH_AUTH_SOCK rather than distinctly forwarding - their own. - ok dtucker@ "put it in" deraadt@ - - jmc@cvs.openbsd.org 2005/07/04 11:29:51 - [ssh_config.5] - fix Xr and a little grammar; - - markus@cvs.openbsd.org 2005/07/04 14:04:11 - [channels.c] - don't forget to set x11_saved_display - -20050626 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2005/06/17 22:53:47 - [ssh.c sshconnect.c] - Fix ControlPath's %p expanding to "0" for a default port, - spotted dwmw2 AT infradead.org; ok markus@ - - djm@cvs.openbsd.org 2005/06/18 04:30:36 - [ssh.c ssh_config.5] - allow ControlPath=none, patch from dwmw2 AT infradead.org; ok dtucker@ - - djm@cvs.openbsd.org 2005/06/25 22:47:49 - [ssh.c] - do the default port filling code a few lines earlier, so it really - does fix %p - -20050618 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2005/05/20 12:57:01; - [auth1.c] split protocol 1 auth methods into separate functions, makes - authloop much more readable; fixes and ok markus@ (portable ok & - polish dtucker@) - - djm@cvs.openbsd.org 2005/06/17 02:44:33 - [auth1.c] make this -Wsign-compare clean; ok avsm@ markus@ - - (djm) [loginrec.c ssh-rand-helper.c] Fix -Wsign-compare for portable, - tested and fixes tim@ - -20050617 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2005/06/16 03:38:36 - [channels.c channels.h clientloop.c clientloop.h ssh.c] - move x11_get_proto from ssh.c to clientloop.c, to make muliplexed xfwd - easier later; ok deraadt@ - - markus@cvs.openbsd.org 2005/06/16 08:00:00 - [canohost.c channels.c sshd.c] - don't exit if getpeername fails for forwarded ports; bugzilla #1054; - ok djm - - djm@cvs.openbsd.org 2005/06/17 02:44:33 - [auth-rsa.c auth.c auth1.c auth2-chall.c auth2-gss.c authfd.c authfile.c] - [bufaux.c canohost.c channels.c cipher.c clientloop.c dns.c gss-serv.c] - [kex.c kex.h key.c mac.c match.c misc.c packet.c packet.h scp.c] - [servconf.c session.c session.h sftp-client.c sftp-server.c sftp.c] - [ssh-keyscan.c ssh-rsa.c sshconnect.c sshconnect1.c sshconnect2.c sshd.c] - make this -Wsign-compare clean; ok avsm@ markus@ - NB. auth1.c changes not committed yet (conflicts with uncommitted sync) - NB2. more work may be needed to make portable Wsign-compare clean - - (dtucker) [cipher.c openbsd-compat/openbsd-compat.h - openbsd-compat/openssl-compat.c] only include openssl compat stuff where - it's needed as it can cause conflicts elsewhere (eg xcrypt.c). Found by - and ok tim@ - -20050616 - - (djm) OpenBSD CVS Sync - - jaredy@cvs.openbsd.org 2005/06/07 13:25:23 - [progressmeter.c] - catch SIGWINCH and resize progress meter accordingly; ok markus dtucker - - djm@cvs.openbsd.org 2005/06/06 11:20:36 - [auth.c auth.h misc.c misc.h ssh.c ssh_config.5 sshconnect.c] - introduce a generic %foo expansion function. replace existing % expansion - and add expansion to ControlPath; ok markus@ - - djm@cvs.openbsd.org 2005/06/08 03:50:00 - [ssh-keygen.1 ssh-keygen.c sshd.8] - increase default rsa/dsa key length from 1024 to 2048 bits; - ok markus@ deraadt@ - - djm@cvs.openbsd.org 2005/06/08 11:25:09 - [clientloop.c readconf.c readconf.h ssh.c ssh_config.5] - add ControlMaster=auto/autoask options to support opportunistic - multiplexing; tested avsm@ and jakob@, ok markus@ - - dtucker@cvs.openbsd.org 2005/06/09 13:43:49 - [cipher.c] - Correctly initialize end of array sentinel; ok djm@ - (Id sync only, change already in portable) - -20050609 - - (dtucker) [cipher.c openbsd-compat/Makefile.in - openbsd-compat/openbsd-compat.h openbsd-compat/openssl-compat.{c,h}] - Move compatibility code for supporting older OpenSSL versions to the - compat layer. Suggested by and "no objection" djm@ - -20050607 - - (dtucker) [configure.ac] Continue the hunt for LLONG_MIN and LLONG_MAX: - in today's episode we attempt to coax it from limits.h where it may be - hiding, failing that we take the DIY approach. Tested by tim@ - -20050603 - - (dtucker) [configure.ac] Only try gcc -std=gnu99 if LLONG_MAX isn't - defined, and check that it helps before keeping it in CFLAGS. Some old - gcc's don't set an error code when encountering an unknown value in -std. - Found and tested by tim@. - - (dtucker) [configure.ac] Point configure's reporting address at the - openssh-unix-dev list. ok tim@ djm@ - -20050602 - - (tim) [configure.ac] Some platforms need sys/types.h for arpa/nameser.h. - Take AC_CHECK_HEADERS test out of ultrix section. It caused other platforms - to skip builtin standard includes tests. (first AC_CHECK_HEADERS test - must be run on all platforms) Add missing ;; to case statement. OK dtucker@ - -20050601 - - (dtucker) [configure.ac] Look for _getshort and _getlong in - arpa/nameser.h. - - (dtucker) [configure.ac openbsd-compat/Makefile.in openbsd-compat/strtoll.c] - Add strtoll to the compat library, from OpenBSD. - - (dtucker) OpenBSD CVS Sync - - avsm@cvs.openbsd.org 2005/05/26 02:08:05 - [scp.c] - If copying multiple files to a target file (which normally fails, as it - must be a target directory), kill the spawned ssh child before exiting. - This stops it trying to authenticate and spewing lots of output. - deraadt@ ok - - dtucker@cvs.openbsd.org 2005/05/26 09:08:12 - [ssh-keygen.c] - uint32_t -> u_int32_t for consistency; ok djm@ - - djm@cvs.openbsd.org 2005/05/27 08:30:37 - [ssh.c] - fix -O for cases where no ControlPath has been specified or socket at - ControlPath is not contactable; spotted by and ok avsm@ - - (tim) [config.guess config.sub] Update to '2005-05-27' version. - - (tim) [configure.ac] set TEST_SHELL for OpenServer 6 - -20050531 - - (dtucker) [contrib/aix/pam.conf] Correct comments. From davidl at - vintela.com. - - (dtucker) [mdoc2man.awk] Teach it to understand .Ox. - -20050530 - - (dtucker) [README] Link to new release notes. Beter late than never... - -20050529 - - (dtucker) [openbsd-compat/port-aix.c] Bug #1046: AIX 5.3 expects the - argument to passwdexpired to be initialized to NULL. Suggested by tim@ - While at it, initialize the other arguments to auth functions in case they - ever acquire this behaviour. - - (dtucker) [openbsd-compat/port-aix.c] Whitespace cleanups while there. - - (dtucker) [openbsd-compat/port-aix.c] Minor correction to debug message, - spotted by tim@. - -20050528 - - (dtucker) [configure.ac] For AC_CHECK_HEADERS() and AC_CHECK_FUNCS() have - one entry per line to make it easier to merge changes. ok djm@ - - (dtucker) [configure.ac] strsep() may be defined in string.h, so check - for its presence and include it in the strsep check. - - (dtucker) [configure.ac] getpgrp may be defined in unistd.h, so check for - its presence before doing AC_FUNC_GETPGRP. - - (dtucker) [configure.ac] Merge HP-UX blocks into a common block with minor - version-specific variations as required. - - (dtucker) [openbsd-compat/port-aix.h] Use the HAVE_DECL_* definitions as - per the autoconf man page. Configure should always define them but it - doesn't hurt to check. - -20050527 - - (djm) [defines.h] Use our realpath if we have to define PATH_MAX, spotted by - David Leach; ok dtucker@ - - (dtucker) [acconfig.h configure.ac defines.h includes.h sshpty.c - openbsd-compat/bsd-misc.c] Add support for Ultrix. No, that's not a typo. - Required changes from Bernhard Simon, integrated by me. ok djm@ - -20050525 - - (djm) [mpaux.c mpaux.h Makefile.in] Remove old mpaux.[ch] code, it has not - been used for a while - - (djm) OpenBSD CVS Sync - - otto@cvs.openbsd.org 2005/04/05 13:45:31 - [ssh-keygen.c] - - djm@cvs.openbsd.org 2005/04/06 09:43:59 - [sshd.c] - avoid harmless logspam by not performing setsockopt() on non-socket; - ok markus@ - - dtucker@cvs.openbsd.org 2005/04/06 12:26:06 - [ssh.c] - Fix debug call for port forwards; patch from pete at seebeyond.com, - ok djm@ (ID sync only - change already in portable) - - djm@cvs.openbsd.org 2005/04/09 04:32:54 - [misc.c misc.h tildexpand.c Makefile.in] - replace tilde_expand_filename with a simpler implementation, ahead of - more whacking; ok deraadt@ - - jmc@cvs.openbsd.org 2005/04/14 12:30:30 - [ssh.1] - arg to -b is an address, not if_name; - ok markus@ - - jakob@cvs.openbsd.org 2005/04/20 10:05:45 - [dns.c] - do not try to look up SSHFP for numerical hostname. ok djm@ - - djm@cvs.openbsd.org 2005/04/21 06:17:50 - [ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh.1 ssh_config.5 sshd.8] - [sshd_config.5] OpenSSH doesn't ever look at the $HOME environment - variable, so don't say that we do (bz #623); ok deraadt@ - - djm@cvs.openbsd.org 2005/04/21 11:47:19 - [ssh.c] - don't allocate a pty when -n flag (/dev/null stdin) is set, patch from - ignasi.roca AT fujitsu-siemens.com (bz #829); ok dtucker@ - - dtucker@cvs.openbsd.org 2005/04/23 23:43:47 - [readpass.c] - Add debug message if read_passphrase can't open /dev/tty; bz #471; - ok djm@ - - jmc@cvs.openbsd.org 2005/04/26 12:59:02 - [sftp-client.h] - spelling correction in comment from wiz@netbsd; - - jakob@cvs.openbsd.org 2005/04/26 13:08:37 - [ssh.c ssh_config.5] - fallback gracefully if client cannot connect to ControlPath. ok djm@ - - moritz@cvs.openbsd.org 2005/04/28 10:17:56 - [progressmeter.c ssh-keyscan.c] - add snprintf checks. ok djm@ markus@ - - markus@cvs.openbsd.org 2005/05/02 21:13:22 - [readpass.c] - missing {} - - djm@cvs.openbsd.org 2005/05/10 10:28:11 - [ssh.c] - print nice error message for EADDRINUSE as well (ID sync only) - - djm@cvs.openbsd.org 2005/05/10 10:30:43 - [ssh.c] - report real errors on fallback from ControlMaster=no to normal connect - - markus@cvs.openbsd.org 2005/05/16 15:30:51 - [readconf.c servconf.c] - check return value from strdelim() for NULL (AddressFamily); mpech - - djm@cvs.openbsd.org 2005/05/19 02:39:55 - [sshd_config.5] - sort config options, from grunk AT pestilenz.org; ok jmc@ - - djm@cvs.openbsd.org 2005/05/19 02:40:52 - [sshd_config] - whitespace nit, from grunk AT pestilenz.org - - djm@cvs.openbsd.org 2005/05/19 02:42:26 - [includes.h] - fix cast, from grunk AT pestilenz.org - - djm@cvs.openbsd.org 2005/05/20 10:50:55 - [ssh_config.5] - give a ProxyCommand example using nc(1), with and ok jmc@ - - jmc@cvs.openbsd.org 2005/05/20 11:23:32 - [ssh_config.5] - oops - article and spacing; - - avsm@cvs.openbsd.org 2005/05/23 22:44:01 - [moduli.c ssh-keygen.c] - - removes signed/unsigned comparisons in moduli generation - - use strtonum instead of atoi where its easier - - check some strlcpy overflow and fatal instead of truncate - - djm@cvs.openbsd.org 2005/05/23 23:32:46 - [cipher.c myproposal.h ssh.1 ssh_config.5 sshd_config.5] - add support for draft-harris-ssh-arcfour-fixes-02 improved arcfour modes; - ok markus@ - - avsm@cvs.openbsd.org 2005/05/24 02:05:09 - [ssh-keygen.c] - some style nits from dmiller@, and use a fatal() instead of a printf()/exit - - avsm@cvs.openbsd.org 2005/05/24 17:32:44 - [atomicio.c atomicio.h authfd.c monitor_wrap.c msg.c scp.c sftp-client.c] - [ssh-keyscan.c sshconnect.c] - Switch atomicio to use a simpler interface; it now returns a size_t - (containing number of bytes read/written), and indicates error by - returning 0. EOF is signalled by errno==EPIPE. - Typical use now becomes: - - if (atomicio(read, ..., len) != len) - err(1,"read"); - - ok deraadt@, cloder@, djm@ - - (dtucker) [regress/reexec.sh] Add ${EXEEXT} so this test also works on - Cygwin. - - (dtucker) [auth-pam.c] Bug #1033: Fix warnings building with PAM on Linux: - warning: dereferencing type-punned pointer will break strict-aliasing rules - warning: passing arg 3 of `pam_get_item' from incompatible pointer type - The type-punned pointer fix is based on a patch from SuSE's rpm. ok djm@ - - (dtucker) [configure.ac openbsd-compat/getrrsetbyname.c] Bug #1033: Provide - templates for _getshort and _getlong if missing to prevent compiler warnings - on Linux. - - (djm) [configure.ac openbsd-compat/Makefile.in] - [openbsd-compat/openbsd-compat.h openbsd-compat/strtonum.c] - Add strtonum(3) from OpenBSD libc, new code needs it. - Unfortunately Linux forces us to do a bizarre dance with compiler - options to get LLONG_MIN/MAX; Spotted by and ok dtucker@ - -20050524 - - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec] - [contrib/suse/openssh.spec] Update spec file versions to 4.1p1 - - (dtucker) [auth-pam.c] Since people don't seem to be getting the message - that USE_POSIX_THREADS is unsupported, not recommended and generally a bad - idea, it is now known as UNSUPPORTED_POSIX_THREADS_HACK. Attempting to use - USE_POSIX_THREADS will now generate an error so we don't silently change - behaviour. ok djm@ - - (dtucker) [openbsd-compat/bsd-cygwin_util.c] Ensure sufficient memory - allocation when retrieving core Windows environment. Add CYGWIN variable - to propagated variables. Patch from vinschen at redhat.com, ok djm@ - - Release 4.1p1 - -20050524 - - (djm) [openbsd-compat/readpassphrase.c] bz #950: Retry tcsetattr to ensure - terminal modes are reset correctly. Fix from peak AT argo.troja.mff.cuni.cz; - "looks ok" dtucker@ - -20050512 - - (tim) [buildpkg.sh.in] missing ${PKG_INSTALL_ROOT} in init script - hard link section. Bug 1038. - -20050509 - - (dtucker) [contrib/cygwin/ssh-host-config] Add a test and warning for a - user-mode mounts in Cygwin installation. Patch from vinschen at redhat.com. - -20050504 - - (djm) [ssh.c] some systems return EADDRINUSE on a bind to an already-used - unix domain socket, so catch that too; from jakob@ ok dtucker@ - -20050503 - - (dtucker) [canohost.c] normalise socket addresses returned by - get_remote_hostname(). This means that IPv4 addresses in log messages - on IPv6 enabled machines will no longer be prefixed by "::ffff:" and - AllowUsers, DenyUsers, AllowGroups, DenyGroups will match IPv4-style - addresses only for 4-in-6 mapped connections, regardless of whether - or not the machine is IPv6 enabled. ok djm@ - -20050425 - - (dtucker) [regress/multiplex.sh] Use "kill -0 $pid" to check for the - existence of a process since it's more portable. Found by jbasney at - ncsa.uiuc.edu; ok tim@ - - (dtucker) [regress/multiplex.sh] Remove cleanup call since test-exec.sh - will clean up anyway. From tim@ - - (dtucker) [regress/multiplex.sh] Put control socket in /tmp so running - "make tests" works even if you're building on a filesystem that doesn't - support sockets. From deengert at anl.gov, ok djm@ - -20050424 - - (dtucker) [INSTALL configure.ac] Make zlib version check test for 1.1.4 or - 1.2.1.2 or higher. With tim@, ok djm@ - -20050423 - - (tim) [config.guess] Add support for OpenServer 6. - -20050421 - - (dtucker) [session.c] Bug #1024: Don't check pam_session_is_open if - UseLogin is set as PAM is not used to establish credentials in that - case. Found by Michael Selvesteen, ok djm@ - -20050419 - - (dtucker) [INSTALL] Reference README.privsep for the privilege separation - requirements. Pointed out by Bengt Svensson. - - (dtucker) [INSTALL] Put the s/key text and URL back together. - - (dtucker) [INSTALL] Fix s/key text too. - -20050411 - - (tim) [configure.ac] UnixWare needs PASSWD_NEEDS_USERNAME - -20050405 - - (dtucker) [configure.ac] Define HAVE_SO_PEERCRED if we have it. ok djm@ - - (dtucker) [auth-sia.c] Constify sys_auth_passwd, fixes build error on - Tru64. Patch from cmadams at hiwaay.net. - - (dtucker) [auth-passwd.c auth-sia.h] Remove duplicate definitions of - sys_auth_passwd, pointed out by cmadams at hiwaay.net. - -20050403 - - (djm) OpenBSD CVS Sync - - deraadt@cvs.openbsd.org 2005/03/31 18:39:21 - [scp.c] - copy argv[] element instead of smashing the one that ps will see; ok otto - - djm@cvs.openbsd.org 2005/04/02 12:41:16 - [scp.c] - since ssh has xstrdup, use it instead of strdup+test. unbreaks -Werror - build - - (dtucker) [monitor.c] Don't free buffers in audit functions, monitor_read - will free as needed. ok tim@ djm@ - -20050331 - - (dtucker) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2005/03/16 11:10:38 - [ssh_config.5] - get the syntax right for {Local,Remote}Forward; - based on a diff from markus; - problem report from ponraj; - ok dtucker@ markus@ deraadt@ - - markus@cvs.openbsd.org 2005/03/16 21:17:39 - [version.h] - 4.1 - - jmc@cvs.openbsd.org 2005/03/18 17:05:00 - [sshd_config.5] - typo; - - (dtucker) [auth.h sshd.c openbsd-compat/port-aix.c] Bug #1006: fix bug in - handling of password expiry messages returned by AIX's authentication - routines, originally reported by robvdwal at sara.nl. - - (dtucker) [ssh.c] Prevent null pointer deref in port forwarding debug - message on some platforms. Patch from pete at seebeyond.com via djm. - - (dtucker) [monitor.c] Remaining part of fix for bug #1006. - -20050329 - - (dtucker) [contrib/aix/buildbff.sh] Bug #1005: Look up only the user we're - interested in which is much faster in large (eg LDAP or NIS) environments. - Patch from dleonard at vintela.com. - -20050321 - - (dtucker) [configure.ac] Prevent configure --with-zlib from adding -Iyes - and -Lyes to CFLAGS and LIBS. Pointed out by peter at slagheap.net, - with & ok tim@ - - (dtucker) [configure.ac] Make configure error out if the user specifies - --with-libedit but the required libs can't be found, rather than silently - ignoring and continuing. ok tim@ - - (dtucker) [configure.ac openbsd-compat/port-aix.h] Prevent redefinitions - of setauthdb on AIX 5.3, reported by anders.liljegren at its.uu.se. - -20050317 - - (tim) [configure.ac] Bug 998. Make path for --with-opensc optional. - Make --without-opensc work. - - (tim) [configure.ac] portability changes on test statements. Some shells - have problems with -a operator. - - (tim) [configure.ac] make some configure options a little more error proof. - - (tim) [configure.ac] remove trailing white space. - -20050314 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2005/03/10 10:15:02 - [readconf.c] - Check listen addresses for null, prevents xfree from dying during - ClearAllForwardings (bz #996). From Craig Leres, ok markus@ - - deraadt@cvs.openbsd.org 2005/03/10 22:01:05 - [misc.c ssh-keygen.c servconf.c clientloop.c auth-options.c ssh-add.c - monitor.c sftp-client.c bufaux.h hostfile.c ssh.c sshconnect.c channels.c - readconf.c bufaux.c sftp.c] - spacing - - deraadt@cvs.openbsd.org 2005/03/10 22:40:38 - [auth-options.c] - spacing - - markus@cvs.openbsd.org 2005/03/11 14:59:06 - [ssh-keygen.c] - typo, missing \n; mpech - - jmc@cvs.openbsd.org 2005/03/12 11:55:03 - [ssh_config.5] - escape `.' at eol to avoid double spacing issues; - - dtucker@cvs.openbsd.org 2005/03/14 10:09:03 - [ssh-keygen.1] - Correct description of -H (bz #997); ok markus@, punctuation jmc@ - - dtucker@cvs.openbsd.org 2005/03/14 11:44:42 - [auth.c] - Populate host for log message for logins denied by AllowUsers and - DenyUsers (bz #999); ok markus@ (patch by tryponraj at gmail.com) - - markus@cvs.openbsd.org 2005/03/14 11:46:56 - [buffer.c buffer.h channels.c] - limit input buffer size for channels; bugzilla #896; with and ok dtucker@ - - (tim) [contrib/caldera/openssh.spec] links in rc?.d were getting trashed - with a rpm -F - -20050313 - - (dtucker) [contrib/cygwin/ssh-host-config] Makes the query for the - localized name of the local administrators group more reliable. From - vinschen at redhat.com. - -20050312 - - (dtucker) [regress/test-exec.sh] DEBUG can cause problems where debug - output ends up in the client's output, causing regress failures. Found - by Corinna Vinschen. - -20050309 - - (dtucker) [regress/test-exec.sh] Set BIN_SH=xpg4 on OSF1/Digital Unix/Tru64 - so that regress tests behave. From Chris Adams. - - (djm) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2005/03/07 23:41:54 - [ssh.1 ssh_config.5] - more macro simplification; - - djm@cvs.openbsd.org 2005/03/08 23:49:48 - [version.h] - OpenSSH 4.0 - - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec] - [contrib/suse/openssh.spec] Update spec file versions - - (djm) [log.c] Fix dumb syntax error; ok dtucker@ - - (djm) Release OpenSSH 4.0p1 - -20050307 - - (dtucker) [configure.ac] Disable gettext search when configuring with - BSM audit support for the time being. ok djm@ - - (dtucker) OpenBSD CVS Sync (regress/) - - fgsch@cvs.openbsd.org 2004/12/10 01:31:30 - [Makefile sftp-glob.sh] - some globbing regress; prompted and ok djm@ - - david@cvs.openbsd.org 2005/01/14 04:21:18 - [Makefile test-exec.sh] - pass the SUDO make variable to the individual sh tests; ok dtucker@ markus@ - - dtucker@cvs.openbsd.org 2005/02/27 11:33:30 - [multiplex.sh test-exec.sh sshd-log-wrapper.sh] - Add optional capability to log output from regress commands; ok markus@ - Use with: make TEST_SSH_LOGFILE=/tmp/regress.log - - djm@cvs.openbsd.org 2005/02/27 23:13:36 - [login-timeout.sh] - avoid nameservice lookups in regress test; ok dtucker@ - - djm@cvs.openbsd.org 2005/03/04 08:48:46 - [Makefile envpass.sh] - regress test for SendEnv config parsing bug; ok dtucker@ - - (dtucker) [regress/test-exec.sh] Put SUDO in the right place. - - (tim) [configure.ac] SCO 3.2v4.2 no longer supported. - -20050306 - - (dtucker) [monitor.c] Bug #125 comment #47: fix errors returned by monitor - when attempting to audit disconnect events. Reported by Phil Dibowitz. - - (dtucker) [session.c sshd.c] Bug #125 comment #49: Send disconnect audit - events earlier, prevents mm_request_send errors reported by Matt Goebel. - -20050305 - - (djm) [contrib/cygwin/README] Improve Cygwin build documentation. Patch - from vinschen at redhat.com - - (djm) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2005/03/02 11:45:01 - [ssh.1] - missing word; - - djm@cvs.openbsd.org 2005/03/04 08:48:06 - [readconf.c] - fix SendEnv config parsing bug found by Roumen Petrov; ok dtucker@ - -20050302 - - (djm) OpenBSD CVS sync: - - jmc@cvs.openbsd.org 2005/03/01 14:47:58 - [ssh.1] - remove some unneccesary macros; - do not mark up punctuation; - - jmc@cvs.openbsd.org 2005/03/01 14:55:23 - [ssh_config.5] - do not mark up punctuation; - whitespace; - - jmc@cvs.openbsd.org 2005/03/01 14:59:49 - [sshd.8] - new sentence, new line; - whitespace; - - jmc@cvs.openbsd.org 2005/03/01 15:05:00 - [ssh-keygen.1] - whitespace; - - jmc@cvs.openbsd.org 2005/03/01 15:47:14 - [ssh-keyscan.1 ssh-keyscan.c] - sort options and sync usage(); - - jmc@cvs.openbsd.org 2005/03/01 17:19:35 - [scp.1 sftp.1] - add HashKnownHosts to -o list; - ok markus@ - - jmc@cvs.openbsd.org 2005/03/01 17:22:06 - [ssh.c] - sync usage() w/ man SYNOPSIS; - ok markus@ - - jmc@cvs.openbsd.org 2005/03/01 17:32:19 - [ssh-add.1] - sort options; - - jmc@cvs.openbsd.org 2005/03/01 18:15:56 - [ssh-keygen.1] - sort options (no attempt made at synopsis clean up though); - spelling (occurance -> occurrence); - use prompt before examples; - grammar; - - djm@cvs.openbsd.org 2005/03/02 01:00:06 - [sshconnect.c] - fix addition of new hashed hostnames when CheckHostIP=yes; - found and ok dtucker@ - - djm@cvs.openbsd.org 2005/03/02 01:27:41 - [ssh-keygen.c] - ignore hostnames with metachars when hashing; ok deraadt@ - - djm@cvs.openbsd.org 2005/03/02 02:21:07 - [ssh.1] - bz#987: mention ForwardX11Trusted in ssh.1, - reported by andrew.benham AT thus.net; ok deraadt@ - - (tim) [regress/agent-ptrace.sh] add another possible gdb error. - -20050301 - - (djm) OpenBSD CVS sync: - - otto@cvs.openbsd.org 2005/02/16 09:56:44 - [ssh.c] - Better diagnostic if an identity file is not accesible. ok markus@ djm@ - - djm@cvs.openbsd.org 2005/02/18 03:05:53 - [canohost.c] - better error messages for getnameinfo failures; ok dtucker@ - - djm@cvs.openbsd.org 2005/02/20 22:59:06 - [sftp.c] - turn on ssh batch mode when in sftp batch mode, patch from - jdmossh AT nand.net; - ok markus@ - - jmc@cvs.openbsd.org 2005/02/25 10:55:13 - [sshd.8] - add /etc/motd and $HOME/.hushlogin to FILES; - from michael knudsen; - - djm@cvs.openbsd.org 2005/02/28 00:54:10 - [ssh_config.5] - bz#849: document timeout on untrusted x11 forwarding sessions. Reported by - orion AT cora.nwra.com; ok markus@ - - djm@cvs.openbsd.org 2005/03/01 10:09:52 - [auth-options.c channels.c channels.h clientloop.c compat.c compat.h] - [misc.c misc.h readconf.c readconf.h servconf.c ssh.1 ssh.c ssh_config.5] - [sshd_config.5] - bz#413: allow optional specification of bind address for port forwardings. - Patch originally by Dan Astorian, but worked on by several people - Adds GatewayPorts=clientspecified option on server to allow remote - forwards to bind to client-specified ports. - - djm@cvs.openbsd.org 2005/03/01 10:40:27 - [hostfile.c hostfile.h readconf.c readconf.h ssh.1 ssh_config.5] - [sshconnect.c sshd.8] - add support for hashing host names and addresses added to known_hosts - files, to improve privacy of which hosts user have been visiting; ok - markus@ deraadt@ - - djm@cvs.openbsd.org 2005/03/01 10:41:28 - [ssh-keyscan.1 ssh-keyscan.c] - option to hash hostnames output by ssh-keyscan; ok markus@ deraadt@ - - djm@cvs.openbsd.org 2005/03/01 10:42:49 - [ssh-keygen.1 ssh-keygen.c ssh_config.5] - add tools for managing known_hosts files with hashed hostnames, including - hashing existing files and deleting hosts by name; ok markus@ deraadt@ - -20050226 - - (dtucker) [openbsd-compat/bsd-openpty.c openbsd-compat/inet_ntop.c] - Remove two obsolete Cygwin #ifdefs. Patch from vinschen at redhat.com. - - (dtucker) [acconfig.h configure.ac openbsd-compat/bsd-misc.{c,h}] - Remove SETGROUPS_NOOP, was only used by Cygwin, which doesn't need it any - more. Patch from vinschen at redhat.com. - - (dtucker) [Makefile.in] Add a install-nosysconf target for installing the - binaries without the config files. Primarily useful for packaging. - Patch from phil at usc.edu. ok djm@ - -20050224 - - (djm) [configure.ac] in_addr_t test needs sys/types.h too - -20050222 - - (dtucker) [uidswap.c] Skip uid restore test on Cygwin. Patch from - vinschen at redhat.com. - -20050220 - - (dtucker) [LICENCE Makefile.in README.platform audit-bsm.c configure.ac - defines.h] Bug #125: Add *EXPERIMENTAL* BSM audit support. Configure - --with-audit=bsm to enable. Patch originally from Sun Microsystems, - parts by John R. Jackson. ok djm@ - - (dtucker) [configure.ac] Missing comma in AIX section, somehow causes - unrelated platforms to be configured incorrectly. - -20050216 - - (djm) write seed to temporary file and atomically rename into place; - ok dtucker@ - - (dtucker) [ssh-rand-helper.c] Provide seed_rng since it may be called - via mkstemp in some configurations. ok djm@ - - (dtucker) [auth-shadow.c] Prevent compiler warnings if "DAY" is defined - by the system headers. - - (dtucker) [configure.ac] Bug #893: check for libresolv early on Reliant - Unix; prevents problems relating to the location of -lresolv in the - link order. - - (dtucker) [session.c] Bug #918: store credentials from gssapi-with-mic - authentication early enough to be available to PAM session modules when - privsep=yes. Patch from deengert at anl.gov, ok'ed in principle by Sam - Hartman and similar to Debian's ssh-krb5 package. - - (dtucker) [configure.ac openbsd-compat/port-aix.{c,h}] Silence some more - compiler warnings on AIX. - -20050215 - - (dtucker) [config.sh.in] Collect oslevel -r too. - - (dtucker) [README.platform auth.c configure.ac loginrec.c - openbsd-compat/port-aix.c openbsd-compat/port-aix.h] Bug #835: enable IPv6 - on AIX where possible (see README.platform for details) and work around - a misfeature of AIX's getnameinfo. ok djm@ - - (dtucker) [loginrec.c] Add missing #include. - -20050211 - - (dtucker) [configure.ac] Tidy up configure --help output. - - (dtucker) [openbsd-compat/fake-rfc2553.h] We now need EAI_SYSTEM too. - -20050210 - - (dtucker) [configure.ac] Bug #919: Provide visible feedback for the - --disable-etc-default-login configure option. - -20050209 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2005/01/28 09:45:53 - [ssh_config] - Make it clear that the example entries in ssh_config are only some of the - commonly-used options and refer the user to ssh_config(5) for more - details; ok djm@ - - jmc@cvs.openbsd.org 2005/01/28 15:05:43 - [ssh_config.5] - grammar; - - jmc@cvs.openbsd.org 2005/01/28 18:14:09 - [ssh_config.5] - wording; - ok markus@ - - dtucker@cvs.openbsd.org 2005/01/30 11:18:08 - [monitor.c] - Make code match intent; ok djm@ - - dtucker@cvs.openbsd.org 2005/02/08 22:24:57 - [sshd.c] - Provide reason in error message if getnameinfo fails; ok markus@ - - (dtucker) [auth-passwd.c openbsd-compat/port-aix.c] Don't call - disable_forwarding() from compat library. Prevent linker errrors trying - to resolve it for binaries other than sshd. ok djm@ - - (dtucker) [configure.ac] Bug #854: prepend pwd to relative --with-ssl-dir - paths. ok djm@ - - (dtucker) [configure.ac session.c] Some platforms (eg some SCO) require - the username to be passed to the passwd command when changing expired - passwords. ok djm@ - -20050208 - - (dtucker) [regress/test-exec.sh] Bug #912: Set _POSIX2_VERSION for the - regress tests so newer versions of GNU head(1) behave themselves. Patch - by djm, so ok me. - - (dtucker) [openbsd-compat/port-aix.c] Silence compiler warnings. - - (dtucker) [audit.c audit.h auth.c auth1.c auth2.c loginrec.c monitor.c - monitor_wrap.c monitor_wrap.h session.c sshd.c]: Prepend all of the audit - defines and enums with SSH_ to prevent namespace collisions on some - platforms (eg AIX). - -20050204 - - (dtucker) [monitor.c] Permit INVALID_USER audit events from slave too. - - (dtucker) [auth.c] Fix parens in audit log check. - -20050202 - - (dtucker) [configure.ac openbsd-compat/realpath.c] Sync up with realpath - rev 1.11 from OpenBSD and make it use fchdir if available. ok djm@ - - (dtucker) [auth.c loginrec.h openbsd-compat/{bsd-cray,port-aix}.{c,h}] - Make record_failed_login() call provide hostname rather than having the - implementations having to do lookups themselves. Only affects AIX and - UNICOS (the latter only uses the "user" parameter anyway). ok djm@ - - (dtucker) [session.c sshd.c] Bug #445: Propogate KRB5CCNAME if set to child - the process. Since we also unset KRB5CCNAME at startup, if it's set after - authentication it must have been set by the platform's native auth system. - This was already done for AIX; this enables it for the general case. - - (dtucker) [auth.c canohost.c canohost.h configure.ac defines.h loginrec.c] - Bug #974: Teach sshd to write failed login records to btmp for failed auth - attempts (currently only for password, kbdint and C/R, only on Linux and - HP-UX), based on code from login.c from util-linux. With ashok_kovai at - hotmail.com, ok djm@ - - (dtucker) [Makefile.in auth.c auth.h auth1.c auth2.c loginrec.c monitor.c - monitor.h monitor_wrap.c monitor_wrap.h session.c sshd.c] Bug #125: - (first stage) Add audit instrumentation to sshd, currently disabled by - default. with suggestions from and ok djm@ - -20050201 - - (dtucker) [log.c] Bug #973: force log_init() to open syslog, since on some - platforms syslog will revert to its default values. This may result in - messages from external libraries (eg libwrap) being sent to a different - facility. - - (dtucker) [sshd_config.5] Bug #701: remove warning about - keyboard-interactive since this is no longer the case. - -20050124 - - (dtucker) OpenBSD CVS Sync - - otto@cvs.openbsd.org 2005/01/21 08:32:02 - [auth-passwd.c sshd.c] - Warn in advance for password and account expiry; initialize loginmsg - buffer earlier and clear it after privsep fork. ok and help dtucker@ - markus@ - - dtucker@cvs.openbsd.org 2005/01/22 08:17:59 - [auth.c] - Log source of connections denied by AllowUsers, DenyUsers, AllowGroups and - DenyGroups. bz #909, ok djm@ - - djm@cvs.openbsd.org 2005/01/23 10:18:12 - [cipher.c] - config option "Ciphers" should be case-sensitive; ok dtucker@ - - dtucker@cvs.openbsd.org 2005/01/24 10:22:06 - [scp.c sftp.c] - Have scp and sftp wait for the spawned ssh to exit before they exit - themselves. This prevents ssh from being unable to restore terminal - modes (not normally a problem on OpenBSD but common with -Portable - on POSIX platforms). From peak at argo.troja.mff.cuni.cz (bz#950); - ok djm@ markus@ - - dtucker@cvs.openbsd.org 2005/01/24 10:29:06 - [moduli] - Import new moduli; requested by deraadt@ a week ago - - dtucker@cvs.openbsd.org 2005/01/24 11:47:13 - [auth-passwd.c] - #if -> #ifdef so builds without HAVE_LOGIN_CAP work too; ok djm@ otto@ - -20050120 - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/12/23 17:35:48 - [session.c] - check for NULL; from mpech - - markus@cvs.openbsd.org 2004/12/23 17:38:07 - [ssh-keygen.c] - leak; from mpech - - djm@cvs.openbsd.org 2004/12/23 23:11:00 - [servconf.c servconf.h sshd.c sshd_config sshd_config.5] - bz #898: support AddressFamily in sshd_config. from - peak@argo.troja.mff.cuni.cz; ok deraadt@ - - markus@cvs.openbsd.org 2005/01/05 08:51:32 - [sshconnect.c] - remove dead code, log connect() failures with level error, ok djm@ - - jmc@cvs.openbsd.org 2005/01/08 00:41:19 - [sshd_config.5] - `login'(n) -> `log in'(v); - - dtucker@cvs.openbsd.org 2005/01/17 03:25:46 - [moduli.c] - Correct spelling: SCHNOOR->SCHNORR; ok djm@ - - dtucker@cvs.openbsd.org 2005/01/17 22:48:39 - [sshd.c] - Make debugging output continue after reexec; ok djm@ - - dtucker@cvs.openbsd.org 2005/01/19 13:11:47 - [auth-bsdauth.c auth2-chall.c] - Have keyboard-interactive code call the drivers even for responses for - invalid logins. This allows the drivers themselves to decide how to - handle them and prevent leaking information where possible. Existing - behaviour for bsdauth is maintained by checking authctxt->valid in the - bsdauth driver. Note that any third-party kbdint drivers will now need - to be able to handle responses for invalid logins. ok markus@ - - djm@cvs.openbsd.org 2004/12/22 02:13:19 - [cipher-ctr.c cipher.c] - remove fallback AES support for old OpenSSL, as OpenBSD has had it for - many years now; ok deraadt@ - (Id sync only: Portable will continue to support older OpenSSLs) - - (dtucker) [auth-pam.c] Bug #971: Prevent leaking information about user - existence via keyboard-interactive/pam, in conjunction with previous - auth2-chall.c change; with Colin Watson and djm. - - (dtucker) [loginrec.h] Bug #952: Increase size of username field to 128 - bytes to prevent errors from login_init_entry() when the username is - exactly 64 bytes(!) long. From brhamon at cisco.com, ok djm@ - - (dtucker) [auth-chall.c auth.h auth2-chall.c] Bug #936: Remove pam from - the list of available kbdint devices if UsePAM=no. ok djm@ - -20050118 - - (dtucker) [INSTALL Makefile.in configure.ac survey.sh.in] Implement - "make survey" and "make send-survey". This will provide data on the - configure parameters, platform and platform features to the development - team, which will allow (among other things) better targetting of testing. - It's entirely voluntary and is off be default. ok djm@ - - (dtucker) [survey.sh.in] Remove any blank lines from the output of - ccver-v and ccver-V. - -20041220 - - (dtucker) [ssh-rand-helper.c] Fall back to command-based seeding if reading - from prngd is enabled at compile time but fails at run time, eg because - prngd is not running. Note that if you have prngd running when OpenSSH is - built, OpenSSL will consider itself internally seeded and rand-helper won't - be built at all unless explicitly enabled via --with-rand-helper. ok djm@ - - (dtucker) [regress/rekey.sh] Touch datafile before filling with dd, since - on some wacky platforms (eg old AIXes), dd will refuse to create an output - file if it doesn't exist. - -20041213 - - (dtucker) [contrib/findssh.sh] Clean up on interrupt; from - amarendra.godbole at ge com. - -20041211 - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/12/06 16:00:43 - [bufaux.c] - use 0x00 not \0 since buf[] is a bignum - - fgsch@cvs.openbsd.org 2004/12/10 03:10:42 - [sftp.c] - - fix globbed ls for paths the same lenght as the globbed path when - we have a unique matching. - - fix globbed ls in case of a directory when we have a unique matching. - - as a side effect, if the path does not exist error (used to silently - ignore). - - don't do extra do_lstat() if we only have one matching file. - djm@ ok - - dtucker@cvs.openbsd.org 2004/12/11 01:48:56 - [auth-rsa.c auth2-pubkey.c authfile.c misc.c misc.h] - Fix debug call in error path of authorized_keys processing and fix related - warnings; ok djm@ - -20041208 - - (tim) [configure.ac] Comment some non obvious platforms in the - target-specific case statement. Suggested and OK by dtucker@ - -20041207 - - (dtucker) [regress/scp.sh] Use portable-friendly $DIFFOPTs in new test. - -20041206 - - (dtucker) [TODO WARNING.RNG] Update to reflect current reality. ok djm@ - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/11/25 22:22:14 - [sftp-client.c sftp.c] - leak; from mpech - - jmc@cvs.openbsd.org 2004/11/29 00:05:17 - [sftp.1] - missing full stop; - - djm@cvs.openbsd.org 2004/11/29 07:41:24 - [sftp-client.h sftp.c] - Some small fixes from moritz@jodeit.org. ok deraadt@ - - jaredy@cvs.openbsd.org 2004/12/05 23:55:07 - [sftp.1] - - explain that patterns can be used as arguments in get/put/ls/etc - commands (prodded by Michael Knudsen) - - describe ls flags as a list - - other minor improvements - ok jmc, djm - - dtucker@cvs.openbsd.org 2004/12/06 11:41:03 - [auth-rsa.c auth2-pubkey.c authfile.c misc.c misc.h ssh.h sshd.8] - Discard over-length authorized_keys entries rather than complaining when - they don't decode. bz #884, with & ok djm@ - - (dtucker) OpenBSD CVS Sync (regress/) - - djm@cvs.openbsd.org 2004/06/26 06:16:07 - [reexec.sh] - don't change the name of the copied sshd for the reexec fallback test, - makes life simpler for portable - - dtucker@cvs.openbsd.org 2004/07/08 12:59:35 - [scp.sh] - Regress test for bz #863 (scp double-error), requires $SUDO. ok markus@ - - david@cvs.openbsd.org 2004/07/09 19:45:43 - [Makefile] - add a missing CLEANFILES used in the re-exec test - - djm@cvs.openbsd.org 2004/10/08 02:01:50 - [reexec.sh] - shrink and tidy; ok dtucker@ - - djm@cvs.openbsd.org 2004/10/29 23:59:22 - [Makefile added brokenkeys.sh] - regression test for handling of corrupt keys in authorized_keys file - - djm@cvs.openbsd.org 2004/11/07 00:32:41 - [multiplex.sh] - regression tests for new multiplex commands - - dtucker@cvs.openbsd.org 2004/11/25 09:39:27 - [test-exec.sh] - Remove obsolete RhostsAuthentication from test config; ok markus@ - - dtucker@cvs.openbsd.org 2004/12/06 10:49:56 - [test-exec.sh] - Check if TEST_SSH_SSHD is a full path to sshd before searching; ok markus@ - -20041203 - - (dtucker) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2004/11/07 17:42:36 - [ssh.1] - options sort, and whitespace; - - jmc@cvs.openbsd.org 2004/11/07 17:57:30 - [ssh.c] - usage(): - - add -O - - sync -S w/ manpage - - remove -h - - (dtucker) [auth1.c auth2.c] If the user successfully authenticates but is - subsequently denied by the PAM auth stack, send the PAM message to the - user via packet_disconnect (Protocol 1) or userauth_banner (Protocol 2). - ok djm@ - -20041107 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/11/05 12:19:56 - [sftp.c] - command editing and history support via libedit; ok markus@ - thanks to hshoexer@ and many testers on tech@ too - - djm@cvs.openbsd.org 2004/11/07 00:01:46 - [clientloop.c clientloop.h ssh.1 ssh.c] - add basic control of a running multiplex master connection; including the - ability to check its status and request it to exit; ok markus@ - - (dtucker) [INSTALL Makefile.in configure.ac] Add --with-libedit configure - option and supporting makefile bits and documentation. - -20041105 - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/08/30 09:18:08 - [LICENCE] - s/keygen/keyscan/ - - jmc@cvs.openbsd.org 2004/08/30 21:22:49 - [ssh-add.1 ssh.1] - .Xsession -> .xsession; - originally from a pr from f at obiit dot org, but missed by myself; - ok markus@ matthieu@ - - djm@cvs.openbsd.org 2004/09/07 23:41:30 - [clientloop.c ssh.c] - cleanup multiplex control socket on SIGHUP too, spotted by sturm@ - ok markus@ deraadt@ - - deraadt@cvs.openbsd.org 2004/09/15 00:46:01 - [ssh.c] - /* fallthrough */ is something a programmer understands. But - /* FALLTHROUGH */ is also understood by lint, so that is better. - - jaredy@cvs.openbsd.org 2004/09/15 03:25:41 - [sshd_config.5] - mention PrintLastLog only prints last login time for interactive - sessions, like PrintMotd mentions. - From Michael Knudsen, with wording changed slightly to match the - PrintMotd description. - ok djm - - mickey@cvs.openbsd.org 2004/09/15 18:42:27 - [sshd.c] - use less doubles in daemons; markus@ ok - - deraadt@cvs.openbsd.org 2004/09/15 18:46:04 - [scp.c] - scratch that do { } while (0) wrapper in this case - - djm@cvs.openbsd.org 2004/09/23 13:00:04 - [ssh.c] - correctly honour -n in multiplex client mode; spotted by sturm@ ok markus@ - - djm@cvs.openbsd.org 2004/09/25 03:45:14 - [sshd.c] - these printf args are no longer double; ok deraadt@ markus@ - - djm@cvs.openbsd.org 2004/10/07 10:10:24 - [scp.1 sftp.1 ssh.1 ssh_config.5] - document KbdInteractiveDevices; ok markus@ - - djm@cvs.openbsd.org 2004/10/07 10:12:36 - [ssh-agent.c] - don't unlink agent socket when bind() fails, spotted by rich AT - rich-paul.net, ok markus@ - - markus@cvs.openbsd.org 2004/10/20 11:48:53 - [packet.c ssh1.h] - disconnect for invalid (out of range) message types. - - djm@cvs.openbsd.org 2004/10/29 21:47:15 - [channels.c channels.h clientloop.c] - fix some window size change bugs for multiplexed connections: windows sizes - were not being updated if they had changed after ~^Z suspends and SIGWINCH - was not being processed unless the first connection had requested a tty; - ok markus - - djm@cvs.openbsd.org 2004/10/29 22:53:56 - [clientloop.c misc.h readpass.c ssh-agent.c] - factor out common permission-asking code to separate function; ok markus@ - - djm@cvs.openbsd.org 2004/10/29 23:56:17 - [bufaux.c bufaux.h buffer.c buffer.h] - introduce a new buffer API that returns an error rather than fatal()ing - when presented with bad data; ok markus@ - - djm@cvs.openbsd.org 2004/10/29 23:57:05 - [key.c] - use new buffer API to avoid fatal errors on corrupt keys in authorized_keys - files; ok markus@ - -20041102 - - (dtucker) [configure.ac includes.h] Bug #947: Fix compile error on HP-UX - 10.x by testing for conflicts in shadow.h and undef'ing _INCLUDE__STDC__ - only if a conflict is detected. - -20041019 - - (dtucker) [uidswap.c] Don't test dropping of gids for the root user or - on Cygwin. Cygwin parts from vinschen at redhat com; ok djm@ - -20041016 - - (djm) [auth-pam.c] snprintf->strl*, fix server message length calculations; - ok dtucker@ - -20041006 - - (dtucker) [README.privsep] Bug #939: update info about HP-UX Trusted Mode - and other PAM platforms. - - (dtucker) [monitor_mm.c openbsd-compat/xmmap.c] Bug #940: cast constants - to void * to appease picky compilers (eg Tru64's "cc -std1"). - -20040930 - - (dtucker) [configure.ac] Set AC_PACKAGE_NAME. ok djm@ - -20040923 - - (dtucker) [openbsd-compat/bsd-snprintf.c] Previous change was off by one, - which could have caused the justification to be wrong. ok djm@ - -20040921 - - (dtucker) [openbsd-compat/bsd-snprintf.c] Check for max length too. - ok djm@ - - (dtucker) [contrib/cygwin/ssh-host-config] Update to match current Cygwin - install process. Patch from vinschen at redhat.com. - -20040912 - - (djm) [loginrec.c] Start KNF and tidy up of this long-neglected file. - No change in resultant binary - - (djm) [loginrec.c] __func__ifiy - - (djm) [loginrec.c] xmalloc - - (djm) [ssh.c sshd.c version.h] Don't divulge portable version in protocol - banner. Suggested by deraadt@, ok mouring@, dtucker@ - - (dtucker) [configure.ac] Fix incorrect quoting and tests for cross-compile. - Partly by & ok djm@. - -20040911 - - (djm) [ssh-agent.c] unifdef some cygwin code; ok dtucker@ - - (dtucker) [auth-pam.c auth-pam.h session.c] Bug #890: Send output from - failing PAM session modules to user then exit, similar to the way - /etc/nologin is handled. ok djm@ - - (dtucker) [auth-pam.c] Relocate sshpam_store_conv(), no code change. - - (djm) [auth2-kbdint.c auth2-none.c auth2-passwd.c auth2-pubkey.c] - Make cygwin code more consistent with that which surrounds it - - (dtucker) [auth-pam.c auth.h auth2-none.c auth2.c monitor.c monitor_wrap.c] - Bug #892: Send messages from failing PAM account modules to the client via - SSH2_MSG_USERAUTH_BANNER messages. Note that this will not happen with - SSH2 kbdint authentication, which need to be dealt with separately. ok djm@ - - (dtucker) [session.c] Bug #927: make .hushlogin silent again. ok djm@ - - (dtucker) [configure.ac] Bug #321: Add cross-compile support to configure. - Parts by chua at ayrnetworks.com, astrand at lysator.liu.se and me. ok djm@ - - (dtucker) [auth-krb5.c] Bug #922: Pass KRB5CCNAME to PAM. From deengert - at anl.gov, ok djm@ - -20040830 - - (dtucker) [session.c openbsd-compat/bsd-cygwin_util.{c,h}] Bug #915: only - copy required environment variables on Cygwin. Patch from vinschen at - redhat.com, ok djm@ - - (dtucker) [regress/Makefile] Clean scp-ssh-wrapper.scp too. Patch from - vinschen at redhat.com. - - (dtucker) [Makefile.in contrib/ssh-copy-id] Bug #894: Improve portability - of shell constructs. Patch from cjwatson at debian.org. - -20040829 - - (dtucker) [openbsd-compat/getrrsetbyname.c] Prevent getrrsetbyname from - failing with NOMEMORY if no sigs are returned and malloc(0) returns NULL. - From Martin.Kraemer at Fujitsu-Siemens.com; ok djm@ - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/08/23 11:48:09 - [authfile.c] - fix error path, spotted by Martin.Kraemer AT Fujitsu-Siemens.com; ok markus - - djm@cvs.openbsd.org 2004/08/23 11:48:47 - [channels.c] - typo, spotted by Martin.Kraemer AT Fujitsu-Siemens.com; ok markus - - dtucker@cvs.openbsd.org 2004/08/23 14:26:38 - [ssh-keysign.c ssh.c] - Use permanently_set_uid() in ssh and ssh-keysign for consistency, matches - change in Portable; ok markus@ (CVS ID sync only) - - dtucker@cvs.openbsd.org 2004/08/23 14:29:23 - [ssh-keysign.c] - Remove duplicate getuid(), suggested by & ok markus@ - - markus@cvs.openbsd.org 2004/08/26 16:00:55 - [ssh.1 sshd.8] - get rid of references to rhosts authentication; with jmc@ - - djm@cvs.openbsd.org 2004/08/28 01:01:48 - [sshd.c] - don't erroneously close stdin for !reexec case, from Dave Johnson; - ok markus@ - - (dtucker) [configure.ac] Include sys/stream.h in sys/ptms.h header check, - fixes configure warning on Solaris reported by wknox at mitre.org. - - (dtucker) [regress/multiplex.sh] Skip test on platforms that do not - support FD passing since multiplex requires it. Noted by tim@ - - (dtucker) [regress/dynamic-forward.sh] Allow time for connections to be torn - down, needed on some platforms, should be harmless on others. Patch from - jason at devrandom.org. - - (dtucker) [regress/scp.sh] Make this work on Cygwin too, which doesn't like - files ending in .exe that aren't binaries; patch from vinschen at redhat.com. - - (dtucker) [Makefile.in] Get regress/Makefile symlink right for out-of-tree - builds too, from vinschen at redhat.com. - - (dtucker) [regress/agent-ptrace.sh] Skip ptrace test on OSF1/DUnix/Tru64 - too; patch from cmadams at hiwaay.net. - - (dtucker) [configure.ac] Replace non-portable echo \n with extra echo. - - (dtucker) [openbsd-compat/port-aix.c] Bug #712: Explicitly check for - accounts with authentication configs that sshd can't support (ie - SYSTEM=NONE and AUTH1=something). - -20040828 - - (dtucker) [openbsd-compat/mktemp.c] Remove superfluous Cygwin #ifdef; from - vinschen at redhat.com. - -20040823 - - (djm) [ssh-rand-helper.c] Typo. Found by - Martin.Kraemer AT Fujitsu-Siemens.com - - (djm) [loginrec.c] Typo and bad args in error messages; Spotted by - Martin.Kraemer AT Fujitsu-Siemens.com - -20040817 - - (dtucker) [regress/README.regress] Note compatibility issues with GNU head. - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/08/16 08:17:01 - [version.h] - 3.9 - - (djm) Crank RPM spec version numbers - - (djm) Release 3.9p1 - -20040816 - - (dtucker) [acconfig.h auth-pam.c configure.ac] Set real uid to non-root - to convince Solaris PAM to honour password complexity rules. ok djm@ - -20040815 - - (dtucker) [Makefile.in ssh-keysign.c ssh.c] Use permanently_set_uid() since - it does the right thing on all platforms. ok djm@ - - (djm) [acconfig.h configure.ac openbsd-compat/Makefile.in - openbsd-compat/bsd-closefrom.c openbsd-compat/bsd-misc.c - openbsd-compat/bsd-misc.h openbsd-compat/openbsd-compat.h] Use smarter - closefrom() replacement from sudo; ok dtucker@ - - (djm) [loginrec.c] Check that seek succeeded here too; ok dtucker - - (dtucker) [Makefile.in] Fix typo. - -20040814 - - (dtucker) [auth-krb5.c gss-serv-krb5.c openbsd-compat/xmmap.c] - Explicitly set umask for mkstemp; ok djm@ - - (dtucker) [includes.h] Undef _INCLUDE__STDC__ on HP-UX, otherwise - prot.h and shadow.h provide conflicting declarations of getspnam. ok djm@ - - (dtucker) [loginrec.c openbsd-compat/port-aix.c openbsd-compat/port-aix.h] - Plug AIX login recording into login_write so logins will be recorded for - all auth types. - -20040813 - - (dtucker) [openbsd-compat/bsd-misc.c] Typo in #ifdef; from vinschen at - redhat.com -- (dtucker) OpenBSD CVS Sync - - avsm@cvs.openbsd.org 2004/08/11 21:43:05 - [channels.c channels.h clientloop.c misc.c misc.h serverloop.c ssh-agent.c] - some signed/unsigned int comparison cleanups; markus@ ok - - avsm@cvs.openbsd.org 2004/08/11 21:44:32 - [authfd.c scp.c ssh-keyscan.c] - use atomicio instead of homegrown equivalents or read/write. - markus@ ok - - djm@cvs.openbsd.org 2004/08/12 09:18:24 - [sshlogin.c] - typo in error message, spotted by moritz AT jodeit.org (Id sync only) - - jakob@cvs.openbsd.org 2004/08/12 21:41:13 - [ssh-keygen.1 ssh.1] - improve SSHFP documentation; ok deraadt@ - - jmc@cvs.openbsd.org 2004/08/13 00:01:43 - [ssh-keygen.1] - kill whitespace at eol; - - djm@cvs.openbsd.org 2004/08/13 02:51:48 - [monitor_fdpass.c] - extra check for no message case; ok markus, deraadt, hshoexer, henning - - dtucker@cvs.openbsd.org 2004/08/13 11:09:24 - [servconf.c] - Fix line numbers off-by-one in error messages, from tortay at cc.in2p3.fr - ok markus@, djm@ - -20040812 - - (dtucker) [sshd.c] Remove duplicate variable imported during sync. - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/07/28 08:56:22 - [sshd.c] - call setsid() _before_ re-exec - - markus@cvs.openbsd.org 2004/07/28 09:40:29 - [auth.c auth1.c auth2.c cipher.c cipher.h key.c session.c ssh.c - sshconnect1.c] - more s/illegal/invalid/ - - djm@cvs.openbsd.org 2004/08/04 10:37:52 - [dh.c] - return group14 when no primes found - fixes hang on empty /etc/moduli; - ok markus@ - - dtucker@cvs.openbsd.org 2004/08/11 11:09:54 - [servconf.c] - Fix minor leak; "looks right" deraadt@ - - dtucker@cvs.openbsd.org 2004/08/11 11:50:09 - [sshd.c] - Don't try to close startup_pipe if it's not open; ok djm@ - - djm@cvs.openbsd.org 2004/08/11 11:59:22 - [sshlogin.c] - check that lseek went were we told it to; ok markus@ - (Id sync only, but similar changes are needed in loginrec.c) - - djm@cvs.openbsd.org 2004/08/11 12:01:16 - [sshlogin.c] - make store_lastlog_message() static to appease -Wall; ok markus - - (dtucker) [sshd.c] Clear loginmsg in postauth monitor, prevents doubling - messages generated before the postauth privsep split. - -20040720 - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/07/21 08:56:12 - [auth.c] - s/Illegal user/Invalid user/; many requests; ok djm, millert, niklas, - miod, ... - - djm@cvs.openbsd.org 2004/07/21 10:33:31 - [auth1.c auth2.c] - bz#899: Don't display invalid usernames in setproctitle - from peak AT argo.troja.mff.cuni.cz; ok markus@ - - djm@cvs.openbsd.org 2004/07/21 10:36:23 - [gss-serv-krb5.c] - fix function declaration - - djm@cvs.openbsd.org 2004/07/21 11:51:29 - [canohost.c] - bz#902: cache remote port so we don't fatal() in auth_log when remote - connection goes away quickly. from peak AT argo.troja.mff.cuni.cz; - ok markus@ - - (djm) [auth-pam.c] Portable parts of bz#899: Don't display invalid - usernames in setproctitle from peak AT argo.troja.mff.cuni.cz; - -20040720 - - (djm) [log.c] bz #111: Escape more control characters when sending data - to syslog; from peak AT argo.troja.mff.cuni.cz - - (djm) [contrib/redhat/sshd.pam] bz #903: Remove redundant entries; from - peak AT argo.troja.mff.cuni.cz - - (djm) [regress/README.regress] Remove caveat regarding TCP wrappers, now - that sshd is fixed to behave better; suggested by tim - -20040719 - - (djm) [openbsd-compat/bsd-arc4random.c] Discard early keystream, like OpenBSD - ok dtucker@ - - (djm) [auth-pam.c] Avoid use of xstrdup and friends in conversation function, - instead return PAM_CONV_ERR, avoiding another path to fatal(); ok dtucker@ - - (tim) [configure.ac] updwtmpx() on OpenServer seems to add duplicate entry. - Report by rac AT tenzing.org - -20040717 - - (dtucker) [logintest.c scp.c sftp-server.c sftp.c ssh-add.c ssh-agent.c - ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh-rand-helper.c ssh.c sshd.c - openbsd-compat/bsd-misc.c] Move "char *__progname" to bsd-misc.c. Reduces - diff vs OpenBSD; ok mouring@, tested by tim@ too. - - (dtucker) OpenBSD CVS Sync - - deraadt@cvs.openbsd.org 2004/07/11 17:48:47 - [channels.c cipher.c clientloop.c clientloop.h compat.h moduli.c - readconf.c nchan.c pathnames.h progressmeter.c readconf.h servconf.c - session.c sftp-client.c sftp.c ssh-agent.1 ssh-keygen.c ssh.c ssh1.h - sshd.c ttymodes.h] - spaces - - brad@cvs.openbsd.org 2004/07/12 23:34:25 - [ssh-keyscan.1] - Fix incorrect macro, .I -> .Em - From: Eric S. Raymond - ok jmc@ - - dtucker@cvs.openbsd.org 2004/07/17 05:31:41 - [monitor.c monitor_wrap.c session.c session.h sshd.c sshlogin.c] - Move "Last logged in at.." message generation to the monitor, right - before recording the new login. Fixes missing lastlog message when - /var/log/lastlog is not world-readable and incorrect datestamp when - multiple sessions are used (bz #463); much assistance & ok markus@ - -20040711 - - (dtucker) [auth-pam.c] Check for zero from waitpid() too, which allows - the monitor to properly clean up the PAM thread (Debian bug #252676). - -20040709 - - (tim) [contrib/cygwin/README] add minires-devel requirement. Patch from - vinschen AT redhat.com - -20040708 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2004/07/03 05:11:33 - [sshlogin.c] (RCSID sync only, the corresponding code is not in Portable) - Use '\0' not 0 for string; ok djm@, deraadt@ - - dtucker@cvs.openbsd.org 2004/07/03 11:02:25 - [monitor_wrap.c] - Put s/key functions inside #ifdef SKEY same as monitor.c, - from des@freebsd via bz #330, ok markus@ - - dtucker@cvs.openbsd.org 2004/07/08 12:47:21 - [scp.c] - Prevent scp from skipping the file following a double-error. - bz #863, ok markus@ - -20040702 - - (dtucker) [mdoc2man.awk] Teach it to ignore .Bk -words, reported by - strube at physik3.gwdg.de a long time ago. - -20040701 - - (dtucker) [session.c] Call display_loginmsg again after do_pam_session. - Ensures messages from PAM modules are displayed when privsep=no. - - (dtucker) [auth-pam.c] Bug #705: Make arguments match PAM specs, fixes - warnings on compliant platforms. From paul.a.bolton at bt.com. ok djm@ - - (dtucker) [auth-pam.c] Bug #559 (last piece): Pass DISALLOW_NULL_AUTHTOK - to pam_authenticate for challenge-response auth too. Originally from - fcusack at fcusack.com, ok djm@ - - (tim) [buildpkg.sh.in] Add $REV to bump the package revision within - the same version. Handle the case where someone uses --with-privsep-user= - and the user name does not match the group name. ok dtucker@ - -20040630 - - (dtucker) [auth-pam.c] Check for buggy PAM modules that return a NULL - appdata_ptr to the conversation function. ok djm@ - - (djm) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2004/06/26 09:03:21 - [ssh.1] - - remove double word - - rearrange .Bk to keep SYNOPSIS nice - - -M before -m in options description - - jmc@cvs.openbsd.org 2004/06/26 09:11:14 - [ssh_config.5] - punctuation and grammar fixes. also, keep the options in order. - - jmc@cvs.openbsd.org 2004/06/26 09:14:40 - [sshd_config.5] - new sentence, new line; - - avsm@cvs.openbsd.org 2004/06/26 20:07:16 - [sshd.c] - initialise some fd variables to -1, djm@ ok - - djm@cvs.openbsd.org 2004/06/30 08:36:59 - [session.c] - unbreak TTY break, diagnosed by darren AT dazwin.com; ok markus@ - -20040627 - - (tim) update README files. - - (dtucker) [mdoc2man.awk] Bug #883: correctly recognise .Pa and .Ev macros. - - (dtucker) [regress/README.regress] Document new variables. - - (dtucker) [acconfig.h configure.ac sftp-server.c] Bug #823: add sftp - rename handling for Linux which returns EPERM for link() on (at least some) - filesystems that do not support hard links. sftp-server will fall back to - stat+rename() in such cases. - - (dtucker) [openbsd-compat/port-aix.c] Missing __func__. - -20040626 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/06/25 18:43:36 - [sshd.c] - fix broken fd handling in the re-exec fallback path, particularly when - /dev/crypto is in use; ok deraadt@ markus@ - - djm@cvs.openbsd.org 2004/06/25 23:21:38 - [sftp.c] - bz #875: fix bad escape char error message; reported by f_mohr AT yahoo.de - -20040625 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/06/24 19:30:54 - [servconf.c servconf.h sshd.c] - re-exec sshd on accept(); initial work, final debugging and ok markus@ - - djm@cvs.openbsd.org 2004/06/25 01:16:09 - [sshd.c] - only perform tcp wrappers checks when the incoming connection is on a - socket. silences useless warnings from regress tests that use - proxycommand="sshd -i". prompted by david@ ok markus@ - - djm@cvs.openbsd.org 2004/06/24 19:32:00 - [regress/Makefile regress/test-exec.sh, added regress/reexec.sh] - regress test for re-exec corner cases - - djm@cvs.openbsd.org 2004/06/25 01:25:12 - [regress/test-exec.sh] - clean reexec-specific junk out of text-exec.sh and simplify; idea markus@ - - dtucker@cvs.openbsd.org 2004/06/25 05:38:48 - [sftp-server.c] - Fall back to stat+rename if filesystem doesn't doesn't support hard - links. bz#823, ok djm@ - - (dtucker) [configure.ac openbsd-compat/misc.c [openbsd-compat/misc.h] - Add closefrom() for platforms that don't have it. - - (dtucker) [sshd.c] add line missing from reexec sync. - -20040623 - - (dtucker) [auth1.c] Ensure do_pam_account is called for Protocol 1 - connections with empty passwords. Patch from davidwu at nbttech.com, - ok djm@ - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2004/06/22 22:42:02 - [regress/envpass.sh] - Add quoting for test -z; ok markus@ - - dtucker@cvs.openbsd.org 2004/06/22 22:45:52 - [regress/test-exec.sh] - Add TEST_SSH_SSHD_CONFOPTS and TEST_SSH_SSH_CONFOPTS to allow adding - arbitary options to sshd_config and ssh_config during tests. ok markus@ - - dtucker@cvs.openbsd.org 2004/06/22 22:55:56 - [regress/dynamic-forward.sh regress/test-exec.sh] - Allow setting of port for regress from TEST_SSH_PORT variable; ok markus@ - - mouring@cvs.openbsd.org 2004/06/23 00:39:38 - [rijndael.c] - -Wshadow fix up s/encrypt/do_encrypt/. OK djm@, markus@ - - dtucker@cvs.openbsd.org 2004/06/23 14:31:01 - [ssh.c] - Fix counting in master/slave when passing environment variables; ok djm@ - - (dtucker) [cipher.c] encrypt->do_encrypt inside SSH_OLD_EVP to match - -Wshadow change. - - (bal) [Makefile.in] Remove opensshd.init on 'make distclean' - - (dtucker) [auth.c openbsd-compat/port-aix.c openbsd-compat/port-aix.h] - Move loginrestrictions test to port-aix.c, replace with a generic hook. - - (tim) [regress/try-ciphers.sh] "if ! some_command" is not portable. - - (bal) [contrib/README] Removed "mdoc2man.pl" reference and added - reference to "findssl.sh" - -20040622 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/06/20 17:36:59 - [ssh.c] - filter passed env vars at slave in connection sharing case; ok markus@ - - djm@cvs.openbsd.org 2004/06/20 18:53:39 - [sftp.c] - make "ls -l" listings print user/group names, add "ls -n" to show uid/gid - (like /bin/ls); idea & ok markus@ - - djm@cvs.openbsd.org 2004/06/20 19:28:12 - [sftp.1] - mention new -n flag - - avsm@cvs.openbsd.org 2004/06/21 17:36:31 - [auth-rsa.c auth2-gss.c auth2-pubkey.c authfile.c canohost.c channels.c - cipher.c dns.c kex.c monitor.c monitor_fdpass.c monitor_wrap.c - monitor_wrap.h nchan.c packet.c progressmeter.c scp.c sftp-server.c sftp.c - ssh-gss.h ssh-keygen.c ssh.c sshconnect.c sshconnect1.c sshlogin.c - sshpty.c] - make ssh -Wshadow clean, no functional changes - markus@ ok - - djm@cvs.openbsd.org 2004/06/21 17:53:03 - [session.c] - fix fd leak for multiple subsystem connections; with markus@ - - djm@cvs.openbsd.org 2004/06/21 22:02:58 - [log.h] - mark fatal and cleanup exit as __dead; ok markus@ - - djm@cvs.openbsd.org 2004/06/21 22:04:50 - [sftp.c] - introduce sorting for ls, same options as /bin/ls; ok markus@ - - djm@cvs.openbsd.org 2004/06/21 22:30:45 - [sftp.c] - prefix ls option flags with LS_ - - djm@cvs.openbsd.org 2004/06/21 22:41:31 - [sftp.1] - document sort options - - djm@cvs.openbsd.org 2004/06/22 01:16:39 - [sftp.c] - don't show .files by default in ls, add -a option to turn them back on; - ok markus - - markus@cvs.openbsd.org 2004/06/22 03:12:13 - [regress/envpass.sh regress/multiplex.sh] - more portable env passing tests - - dtucker@cvs.openbsd.org 2004/06/22 05:05:45 - [monitor.c monitor_wrap.c] - Change login->username, will prevent -Wshadow errors in Portable; - ok markus@ - - (dtucker) [monitor.c] Fix Portable-specific -Wshadow warnings on "socket". - - (dtucker) [defines.h] Define __dead if not already defined. - - (bal) [auth-passwd.c auth1.c] Clean up unused variables. - -20040620 - - (tim) [configure.ac Makefile.in] Only change TEST_SHELL on broken platforms. - -20040619 - - (dtucker) [auth-pam.c] Don't use PAM namespace for - pam_password_change_required either. - - (tim) [configure.ac buildpkg.sh.in contrib/solaris/README] move opensshd - init script to top level directory. Add opensshd.init.in. - Remove contrib/solaris/buildpkg.sh, contrib/solaris/opensshd.in - -20040618 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/06/17 14:52:48 - [clientloop.c clientloop.h ssh.c] - support environment passing over shared connections; ok markus@ - - djm@cvs.openbsd.org 2004/06/17 15:10:14 - [clientloop.c misc.h readconf.c readpass.c ssh.c ssh_config.5] - Add option for confirmation (ControlMaster=ask) via ssh-askpass before - opening shared connections; ok markus@ - - djm@cvs.openbsd.org 2004/06/17 14:53:27 - [regress/multiplex.sh] - shared connection env passing regress test - - (dtucker) [regress/README.regress] Add detail on how to run a single - test from the top-level Makefile. - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/06/17 23:56:57 - [ssh.1 ssh.c] - sync usage() and SYNPOSIS with connection sharing changes - - dtucker@cvs.openbsd.org 2004/06/18 06:13:25 - [sftp.c] - Use execvp instead of execv so sftp -S ssh works. "makes sense" markus@ - - dtucker@cvs.openbsd.org 2004/06/18 06:15:51 - [multiplex.sh] - Use -S for scp/sftp to force the use of the ssh being tested. - ok djm@,markus@ - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/06/18 10:40:19 - [ssh.c] - delay signal handler setup until we have finished talking to the master. - allow interrupting of setup (e.g. if master is stuck); ok markus@ - - markus@cvs.openbsd.org 2004/06/18 10:55:43 - [ssh.1 ssh.c] - trim synopsis for -S, allow -S and -oControlMaster, -MM means 'ask'; - ok djm - - djm@cvs.openbsd.org 2004/06/18 11:11:54 - [channels.c clientloop.c] - Don't explode in clientloop when we receive a bogus channel id, but - also don't generate them to begin with; ok markus@ - -20040617 - - (dtucker) [regress/scp.sh] diff -N is not portable (but needed for some - platforms), so test if diff understands it. Pointed out by tim@, ok djm@ - - (dtucker) OpenBSD CVS Sync regress/ - - dtucker@cvs.openbsd.org 2004/06/17 05:51:59 - [regress/multiplex.sh] - Remove datafile between and after tests, kill sshd rather than wait; - ok djm@ - - dtucker@cvs.openbsd.org 2004/06/17 06:00:05 - [regress/multiplex.sh] - Use DATA and COPY for test data rather than hard-coded paths; ok djm@ - - dtucker@cvs.openbsd.org 2004/06/17 06:19:06 - [regress/multiplex.sh] - Add small description of failing test to failure message; ok djm@ - - (dtucker) [regress/multiplex.sh] add EXEEXT for those platforms that need - it. - - (dtucker) [regress/multiplex.sh] Increase sleep time to 120 sec (60 is not - enough for slow systems, especially if they don't have a kernel RNG). - -20040616 - - (dtucker) [openbsd-compat/port-aix.c] Expand whitespace -> tabs. No - code changes. - - (dtucker) OpenBSD CVS Sync regress/ - - djm@cvs.openbsd.org 2004/04/27 09:47:30 - [regress/Makefile regress/test-exec.sh, added regress/envpass.sh] - regress test for environment passing, SendEnv & AcceptEnv options; - ok markus@ - - dtucker@cvs.openbsd.org 2004/06/13 13:51:02 - [regress/Makefile regress/test-exec.sh, added regress/scp-ssh-wrapper.sh - regress/scp.sh] - Add scp regression test; with & ok markus@ - - djm@cvs.openbsd.org 2004/06/13 15:04:08 - [regress/Makefile regress/test-exec.sh, added regress/envpass.sh] - regress test for client multiplexing; ok markus@ - - djm@cvs.openbsd.org 2004/06/13 15:16:54 - [regress/test-exec.sh] - remove duplicate setting of $SCP; spotted by markus@ - - dtucker@cvs.openbsd.org 2004/06/16 13:15:09 - [regress/scp.sh] - Make scp -r tests use diff -rN not cmp (which won't do dirs. ok markus@ - - dtucker@cvs.openbsd.org 2004/06/16 13:16:40 - [regress/multiplex.sh] - Silence multiplex sftp and scp tests. ok markus@ - - (dtucker) [regress/test-exec.sh] - Move Portable-only StrictModes to top of list to make syncs easier. - - (dtucker) [regress/README.regress] - Add $TEST_SHELL to readme. - -20040615 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/05/26 08:59:57 - [sftp.c] - exit -> _exit in forked child on error; from andrushock AT korovino.net - - markus@cvs.openbsd.org 2004/05/26 23:02:39 - [channels.c] - missing freeaddrinfo; Andrey Matveev - - dtucker@cvs.openbsd.org 2004/05/27 00:50:13 - [readconf.c] - Kill dead code after fatal(); ok djm@ - - dtucker@cvs.openbsd.org 2004/06/01 14:20:45 - [auth2-chall.c] - Remove redundant #include; ok markus@ - - pedro@cvs.openbsd.org 2004/06/03 12:22:20 - [sftp-client.c sftp.c] - initialize pointers, ok markus@ - - djm@cvs.openbsd.org 2004/06/13 12:53:24 - [dh.c dh.h kex.c kex.h kexdhc.c kexdhs.c monitor.c myproposal.h] - [ssh-keyscan.c sshconnect2.c sshd.c] - implement diffie-hellman-group14-sha1 kex method (trivial extension to - existing diffie-hellman-group1-sha1); ok markus@ - - dtucker@cvs.openbsd.org 2004/06/13 14:01:42 - [ssh.1 ssh_config.5 sshd_config.5] - List supported ciphers in man pages, tidy up ssh -c; - "looks fine" jmc@, ok markus@ - - djm@cvs.openbsd.org 2004/06/13 15:03:02 - [channels.c channels.h clientloop.c clientloop.h includes.h readconf.c] - [readconf.h scp.1 sftp.1 ssh.1 ssh.c ssh_config.5] - implement session multiplexing in the client (the server has supported - this since 2.0); ok markus@ - - djm@cvs.openbsd.org 2004/06/14 01:44:39 - [channels.c clientloop.c misc.c misc.h packet.c ssh-agent.c ssh-keyscan.c] - [sshd.c] - set_nonblock() instead of fnctl(...,O_NONBLOCK); "looks sane" deraadt@ - - djm@cvs.openbsd.org 2004/06/15 05:45:04 - [clientloop.c] - missed one unset_nonblock; spotted by Tim Rice - - (djm) Fix Makefile.in for connection sharing changes - - (djm) [ssh.c] Use separate var for address length - -20040603 - - (dtucker) [auth-pam.c] Don't use pam_* namespace for sshd's PAM functions. - ok djm@ - -20040601 - - (djm) [auth-pam.c] Add copyright for local changes - -20040530 - - (dtucker) [auth-pam.c auth-pam.h auth-passwd.c] Bug #874: Re-add PAM - support for PasswordAuthentication=yes. ok djm@ - - (dtucker) [auth-pam.c] Use an invalid password for root if - PermitRootLogin != yes or the login is invalid, to prevent leaking - information. Based on Openwall's owl-always-auth patch. ok djm@ - - (tim) [configure.ac Makefile.in] Add support for "make package" ok djm@ - - (tim) [buildpkg.sh.in] New file. A more flexible version of - contrib/solaris/buildpkg.sh used for "make package". - - (tim) [buildpkg.sh.in] Last minute fix didn't make it in the .in file. - -20040527 - - (dtucker) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec - contrib/README CREDITS INSTALL] Bug #873: Correct URLs for x11-ssh-askpass - and Jim Knoble's email address , from Jim himself. - -20040524 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/05/19 12:17:33 - [sftp-client.c sftp.c] - gracefully abort transfers on receipt of SIGINT, also ignore SIGINT while - waiting for a command; ok markus@ - - dtucker@cvs.openbsd.org 2004/05/20 10:58:05 - [clientloop.c] - Trivial type fix 0 -> '\0'; ok markus@ - - markus@cvs.openbsd.org 2004/05/21 08:43:03 - [kex.h moduli.c tildexpand.c] - add prototypes for -Wall; ok djm - - djm@cvs.openbsd.org 2004/05/21 11:33:11 - [channels.c channels.h clientloop.c serverloop.c ssh.1] - bz #756: add support for the cancel-tcpip-forward request for the server - and the client (through the ~C commandline). reported by z3p AT - twistedmatrix.com; ok markus@ - - djm@cvs.openbsd.org 2004/05/22 06:32:12 - [clientloop.c ssh.1] - use '-h' for help in ~C commandline instead of '-?'; inspired by jmc@ - - jmc@cvs.openbsd.org 2004/05/22 16:01:05 - [ssh.1] - kill whitespace at eol; - - dtucker@cvs.openbsd.org 2004/05/23 23:59:53 - [auth.c auth.h auth1.c auth2.c servconf.c servconf.h sshd_config - sshd_config.5] - Add MaxAuthTries sshd config option; ok markus@ - - (dtucker) [auth-pam.c] Bug #839: Ensure that pam authentication "thread" - is terminated if the privsep slave exits during keyboard-interactive - authentication. ok djm@ - - (dtucker) [sshd.c] Fix typo in comment. - -20040523 - - (djm) [sshd_config] Explain consequences of UsePAM=yes a little better in - sshd_config; ok dtucker@ - - (djm) [configure.ac] Warn if the system has no known way of figuring out - which user is on the other end of a Unix domain socket; ok dtucker@ - - (bal) [openbsd-compat/sys-queue.h] Reintroduce machinary to handle - old/broken/incomplete . - -20040513 - - (dtucker) [configure.ac] Bug #867: Additional tests for res_query in - libresolv, fixes problems detecting it on some platforms - (eg Linux/x86-64). From Kurt Roeckx via Debian, ok mouring@ - - (dtucker) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2004/05/04 18:36:07 - [scp.1] - SendEnv here too; - - jmc@cvs.openbsd.org 2004/05/06 11:24:23 - [ssh_config.5] - typo from John Cosimano (PR 3770); - - deraadt@cvs.openbsd.org 2004/05/08 00:01:37 - [auth.c clientloop.c misc.h servconf.c ssh.c sshpty.h sshtty.c - tildexpand.c], removed: sshtty.h tildexpand.h - make two tiny header files go away; djm ok - - djm@cvs.openbsd.org 2004/05/08 00:21:31 - [clientloop.c misc.h readpass.c scard.c ssh-add.c ssh-agent.c ssh-keygen.c - sshconnect.c sshconnect1.c sshconnect2.c] removed: readpass.h - kill a tiny header; ok deraadt@ - - djm@cvs.openbsd.org 2004/05/09 00:06:47 - [moduli.c ssh-keygen.c] removed: moduli.h - zap another tiny header; ok deraadt@ - - djm@cvs.openbsd.org 2004/05/09 01:19:28 - [OVERVIEW auth-rsa.c auth1.c kex.c monitor.c session.c sshconnect1.c - sshd.c] removed: mpaux.c mpaux.h - kill some more tiny files; ok deraadt@ - - djm@cvs.openbsd.org 2004/05/09 01:26:48 - [kex.c] - don't overwrite what we are trying to compute - - deraadt@cvs.openbsd.org 2004/05/11 19:01:43 - [auth.c auth2-none.c authfile.c channels.c monitor.c monitor_mm.c - packet.c packet.h progressmeter.c session.c openbsd-compat/xmmap.c] - improve some code lint did not like; djm millert ok - - dtucker@cvs.openbsd.org 2004/05/13 02:47:50 - [ssh-agent.1] - Add examples to ssh-agent.1, bz#481 from Ralf Hauser; ok deraadt@ - - (dtucker) [sshd.8] Bug #843: Add warning about PasswordAuthentication to - UsePAM section. Parts from djm@ and jmc@. - - (dtucker) [auth-pam.c scard-opensc.c] Tinderbox says auth-pam.c uses - readpass.h, grep says scard-opensc.c does too. Replace with misc.h. - - (dtucker) [openbsd-compat/getrrsetbyname.c] Check that HAVE_DECL_H_ERROR - is defined before using. - - (dtucker) [openbsd-compat/getrrsetbyname.c] Fix typo too: HAVE_DECL_H_ERROR - -> HAVE_DECL_H_ERRNO. - -20040502 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/04/22 11:56:57 - [moduli.c] - Bugzilla #850: Sophie Germain is the correct name of the French - mathematician, "Sophie Germaine" isn't; from Luc.Maisonobe@c-s.fr - - djm@cvs.openbsd.org 2004/04/27 09:46:37 - [readconf.c readconf.h servconf.c servconf.h session.c session.h ssh.c - ssh_config.5 sshd_config.5] - bz #815: implement ability to pass specified environment variables from - the client to the server; ok markus@ - - djm@cvs.openbsd.org 2004/04/28 05:17:10 - [ssh_config.5 sshd_config.5] - manpage fixes in envpass stuff from Brian Poole (raj AT cerias.purdue.edu) - - jmc@cvs.openbsd.org 2004/04/28 07:02:56 - [sshd_config.5] - remove unnecessary .Pp; - - jmc@cvs.openbsd.org 2004/04/28 07:13:42 - [sftp.1 ssh.1] - add SendEnv to -o list; - - dtucker@cvs.openbsd.org 2004/05/02 11:54:31 - [sshd.8] - Man page grammar fix (bz #858), from damerell at chiark.greenend.org.uk - via Debian; ok djm@ - - dtucker@cvs.openbsd.org 2004/05/02 11:57:52 - [ssh.1] - ConnectionTimeout -> ConnectTimeout, from m.a.ellis at ncl.ac.uk via - Debian. ok djm@ - - dtucker@cvs.openbsd.org 2004/05/02 23:02:17 - [sftp.1] - ConnectionTimeout -> ConnectTimeout here too, pointed out by jmc@ - - dtucker@cvs.openbsd.org 2004/05/02 23:17:51 - [scp.1] - ConnectionTimeout -> ConnectTimeout for scp.1 too. - -20040423 - - (dtucker) [configure.ac openbsd-compat/getrrsetbyname.c] Declare h_errno - as extern int if not already declared. Fixes compile errors on old SCO - platforms. ok tim@ - - (dtucker) [README.platform] List prereqs for building on Cygwin. - -20040421 - - (djm) Update config.guess and config.sub to autoconf-2.59 versions; ok tim@ - -20040420 - - (djm) OpenBSD CVS Sync - - henning@cvs.openbsd.org 2004/04/08 16:08:21 - [sshconnect2.c] - swap the last two parameters to TAILQ_FOREACH_REVERSE. matches what - FreeBSD and NetBSD do. - ok millert@ mcbride@ markus@ ho@, checked to not affect ports by naddy@ - - djm@cvs.openbsd.org 2004/04/18 23:10:26 - [readconf.c readconf.h ssh-keysign.c ssh.c] - perform strict ownership and modes checks for ~/.ssh/config files, - as these can be used to execute arbitrary programs; ok markus@ - NB. ssh will now exit when it detects a config with poor permissions - - djm@cvs.openbsd.org 2004/04/19 13:02:40 - [ssh.1 ssh_config.5] - document strict permission checks on ~/.ssh/config; prompted by, - with & ok jmc@ - - jmc@cvs.openbsd.org 2004/04/19 16:12:14 - [ssh_config.5] - kill whitespace at eol; - - djm@cvs.openbsd.org 2004/04/19 21:51:49 - [ssh.c] - fix idiot typo that i introduced in my last commit; - spotted by cschneid AT cschneid.com - - (djm) [openbsd-compat/sys-queue.h] Sync with OpenBSD, needed for - above change - - (djm) [configure.ac] Check whether libroken is required when building - with Heimdal - -20040419 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2004/02/29 22:04:45 - [regress/login-timeout.sh] - Use sudo when restarting daemon during test. ok markus@ - - dtucker@cvs.openbsd.org 2004/03/08 10:17:12 - [regress/login-timeout.sh] - Missing OBJ, from tim@. ok markus@ (Already fixed, ID sync only) - - djm@cvs.openbsd.org 2004/03/30 12:41:56 - [sftp-client.c] - sync comment with reality - - djm@cvs.openbsd.org 2004/03/31 21:58:47 - [canohost.c] - don't skip ip options check when UseDNS=no; ok markus@ (ID sync only) - - markus@cvs.openbsd.org 2004/04/01 12:19:57 - [scp.c] - limit trust between local and remote rcp/scp process, - noticed by lcamtuf; ok deraadt@, djm@ - -20040418 - - (dtucker) [auth-pam.c] Log username and source host for failed PAM - authentication attempts. With & ok djm@ - - (djm) [openbsd-compat/bsd-cygwin_util.c] Recent versions of Cygwin allow - change of user context without a password, so relax auth method - restrictions; from vinschen AT redhat.com; ok dtucker@ - -20040416 - - (dtucker) [regress/sftp-cmds.sh] Skip quoting test on Cygwin, since - FAT/NTFS does not permit quotes in filenames. From vinschen at redhat.com - - (djm) [auth-krb5.c auth.h session.c] Explicitly refer to Kerberos ccache - file using FILE: method, fixes problems on Mac OSX. - Patch from simon@sxw.org.uk; ok dtucker@ - - (tim) [configure.ac] Set SETEUID_BREAKS_SETUID, BROKEN_SETREUID and - BROKEN_SETREGID for SCO OpenServer 3 - -20040412 - - (dtucker) [sshd_config.5] Add PermitRootLogin without-password warning - from bug #701 (text from jfh at cise.ufl.edu). - - (dtucker) [acconfig.h configure.ac defines.h] Bug #673: check for 4-arg - skeychallenge(), eg on NetBSD. ok mouring@ - - (dtucker) [auth-skey.c defines.h monitor.c] Make skeychallenge explicitly - 4-arg, with compatibility for 3-arg versions. From djm@, ok me. - - (djm) [configure.ac] Fix detection of libwrap on OpenBSD; ok dtucker@ - -20040408 - - (dtucker) [loginrec.c] Use UT_LINESIZE if available, prevents truncating - pty name on Linux 2.6.x systems. Patch from jpe at eisenmenger.org. - - (bal) [monitor.c monitor_wrap.c] Second try. Put the zlib.h headers - back and #undef TARGET_OS_MAC instead. (Bug report pending with Apple) - - (dtucker) [defines.h loginrec.c] Define UT_LINESIZE if not defined and - simplify loginrec.c. ok tim@ - - (bal) [monitor.c monitor_wrap.c] Ok.. Last time. Promise. Tim suggested - limiting scope and dtucker@ agreed. - -20040407 - - (dtucker) [session.c] Flush stdout after displaying loginmsg. From - f_mohr at yahoo.de. - - (bal) [acconfig.h auth-krb5.c configure.ac gss-serv-krb5.c] Check to see - if Krb5 library exports krb5_init_etc() since some OSes (like MacOS/X) - are starting to restrict it as internal since it is not needed by - developers any more. (Patch based on Apple tree) - - (bal) [monitor.c monitor_wrap.c] monitor_wrap.c] moved zlib.h higher since - krb5 on MacOS/X conflicts. There may be a better solution, but this will - work for now. - -20040406 - - (dtucker) [acconfig.h configure.ac defines.h] Bug #820: don't use - updwtmpx() on IRIX since it seems to clobber utmp. ok djm@ - - (dtucker) [configure.ac] Bug #816, #748 (again): Attempt to detect - broken getaddrinfo and friends on HP-UX. ok djm@ - -20040330 - - (dtucker) [configure.ac] Bug #811: Use "!" for LOCKED_PASSWD_PREFIX on - Linuxes, since that's what many use. ok djm@ - - (dtucker) [auth-pam.c] rename the_authctxt to sshpam_authctxt in auth-pam.c - to reduce potential confusion with the one in sshd.c. ok djm@ - - (djm) Bug #825: Fix ip_options_check() for mapped IPv4/IPv6 connection; - with & ok dtucker@ - -20040327 - - (dtucker) [session.c] Bug #817: Clear loginmsg after fork to prevent - duplicate login messages for mutli-session logins. ok djm@ - -20040322 - - (djm) [sshd.c] Drop supplemental groups if started as root - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/03/09 22:11:05 - [ssh.c] - increase x11 cookie lifetime to 20 minutes; ok djm - - markus@cvs.openbsd.org 2004/03/10 09:45:06 - [ssh.c] - trim usage to match ssh(1) and look more like unix. ok djm@ - - markus@cvs.openbsd.org 2004/03/11 08:36:26 - [sshd.c] - trim usage; ok deraadt - - markus@cvs.openbsd.org 2004/03/11 10:21:17 - [ssh.c sshd.c] - ssh, sshd: sync version output, ok djm - - markus@cvs.openbsd.org 2004/03/20 10:40:59 - [version.h] - 3.8.1 - - (djm) Crank RPM spec versions - -20040311 - - (djm) [configure.ac] Add standard license to configure.ac; ok ben, dtucker - -20040310 - - (dtucker) [openbsd-compat/fake-rfc2553.h] Bug #812: #undef getaddrinfo - before redefining it, silences warnings on Tru64. - -20040308 - - (dtucker) [sshd.c] Back out rev 1.270 as it caused problems on some - platforms (eg SCO, HP-UX) with logging in the wrong TZ. ok djm@ - - (dtucker) [configure.ac sshd.c openbsd-compat/bsd-misc.h - openbsd-compat/setenv.c] Unset KRB5CCNAME on AIX to prevent it from being - inherited by the child. ok djm@ - - (dtucker) [auth-pam.c auth-pam.h auth1.c auth2.c monitor.c monitor_wrap.c - monitor_wrap.h] Bug #808: Ensure force_pwchange is correctly initialized - even if keyboard-interactive is not used by the client. Prevents - segfaults in some cases where the user's password is expired (note this - is not considered a security exposure). ok djm@ - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/03/03 06:47:52 - [sshd.c] - change proctiltle after accept(2); ok henning, deraadt, djm - - djm@cvs.openbsd.org 2004/03/03 09:30:42 - [sftp-client.c] - Don't print duplicate messages when progressmeter is off - Spotted by job317 AT mailvault.com; ok markus@ - - djm@cvs.openbsd.org 2004/03/03 09:31:20 - [sftp.c] - Fix initialisation of progress meter; ok markus@ - - markus@cvs.openbsd.org 2004/03/05 10:53:58 - [readconf.c readconf.h scp.1 sftp.1 ssh.1 ssh_config.5 sshconnect2.c] - add IdentitiesOnly; ok djm@, pb@ - - djm@cvs.openbsd.org 2004/03/08 09:38:05 - [ssh-keyscan.c] - explicitly initialise remote_major and remote_minor. - from cjwatson AT debian.org; ok markus@ - - dtucker@cvs.openbsd.org 2004/03/08 10:18:57 - [sshd_config.5] - Document KerberosGetAFSToken; ok markus@ - - (tim) [regress/README.regress] Document ssh-rand-helper issue. ok bal - -20040307 - - (tim) [regress/login-timeout.sh] fix building outside of source tree. - -20040304 - - (dtucker) [auth-pam.c] Don't try to export PAM when compiled with - -DUSE_POSIX_THREADS. From antoine.verheijen at ualbert ca. ok djm@ - - (dtucker) [auth-pam.c] Reset signal status when starting pam auth thread, - prevent hanging during PAM keyboard-interactive authentications. ok djm@ - - (dtucker) [auth-passwd.c auth-sia.c auth-sia.h defines.h - openbsd-compat/xcrypt.c] Bug #802: Fix build error on Tru64 when - configured --with-osfsia. ok djm@ - -20040303 - - (djm) [configure.ac ssh-agent.c] Use prctl to prevent ptrace on ssh-agent - ok dtucker - -20040229 - - (tim) [configure.ac] Put back bits mistakenly removed from Rev 1.188 - -20040229 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/02/25 00:22:45 - [sshd.c] - typo in comment - - dtucker@cvs.openbsd.org 2004/02/27 22:42:47 - [dh.c] - Prevent sshd from sending DH groups with a primitive generator of zero or - one, even if they are listed in /etc/moduli. ok markus@ - - dtucker@cvs.openbsd.org 2004/02/27 22:44:56 - [dh.c] - Make /etc/moduli line buffer big enough for 8kbit primes, in case anyone - ever uses one. ok markus@ - - dtucker@cvs.openbsd.org 2004/02/27 22:49:27 - [dh.c] - Reset bit counter at the right time, fixes debug output in the case where - the DH group is rejected. ok markus@ - - dtucker@cvs.openbsd.org 2004/02/17 08:23:20 - [regress/Makefile regress/login-timeout.sh] - Add regression test for LoginGraceTime; ok markus@ - - markus@cvs.openbsd.org 2004/02/24 16:56:30 - [regress/test-exec.sh] - allow arguments in ${TEST_SSH_XXX} - - markus@cvs.openbsd.org 2004/02/24 17:06:52 - [regress/ssh-com-client.sh regress/ssh-com-keygen.sh - regress/ssh-com-sftp.sh regress/ssh-com.sh] - test against recent ssh.com releases - - dtucker@cvs.openbsd.org 2004/02/28 12:16:57 - [regress/dynamic-forward.sh] - Make dynamic-forward understand nc's new output. ok markus@ - - dtucker@cvs.openbsd.org 2004/02/28 13:44:45 - [regress/try-ciphers.sh] - Test acss too; ok markus@ - - (dtucker) [regress/try-ciphers.sh] Skip acss if not compiled in (eg if we - built with openssl < 0.9.7) - -20040226 - - (bal) KNF our sshlogin.c even if the code looks nothing like upstream - code due to diversity issues. - -20040225 - - (djm) Trim ChangeLog - - (djm) Don't specify path to PAM modules in Redhat sshd.pam; from Fedora - -20040224 - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/02/19 21:15:04 - [sftp-server.c] - switch to new license.template - - markus@cvs.openbsd.org 2004/02/23 12:02:33 - [sshd.c] - backout revision 1.279; set listen socket to non-block; ok henning. - - markus@cvs.openbsd.org 2004/02/23 15:12:46 - [bufaux.c] - encode 0 correctly in buffer_put_bignum2; noted by Mikulas Patocka - and drop support for negative BNs; ok otto@ - - markus@cvs.openbsd.org 2004/02/23 15:16:46 - [version.h] - enter 3.8 - - (dtucker) [configure.ac gss-serv-krb5.c ssh-gss.h] Define GSSAPI when found - with krb5-config, hunt down gssapi.h and friends. Based partially on patch - from deengert at anl.gov. ok djm@ - - (djm) [groupaccess.c uidswap.c] Bug #787: Size group arrays at runtime - using sysconf() if available Based on patches from - holger AT van-lengerich.de and openssh_bugzilla AT hockin.org - - (dtucker) [uidswap.c] Minor KNF. ok djm@ - - (tim) [openbsd-compat/getrrsetbyname.c] Make gcc 2.7.2.3 happy. ok djm@ - - (djm) Crank RPM spec versions - - (dtucker) [README] Add pointer to release notes. ok djm@ - - (dtucker) {README.platform] Add platform-specific notes. - - (tim) [configure.ac] SCO3 needs -lcrypt_i for -lprot - - (djm) Release 3.8p1 - -20040223 - - (dtucker) [session.c] Bug #789: Only make setcred call for !privsep in the - non-interactive path. ok djm@ - -20040222 - - (dtucker) [auth-shadow.c auth.c auth.h] Move shadow account expiry test - to auth-shadow.c, no functional change. ok djm@ - - (dtucker) [auth-shadow.c auth.h] Provide warnings of impending account or - password expiry. ok djm@ - - (dtucker) [auth-passwd.c] Only check password expiry once. Prevents - multiple warnings if a wrong password is entered. - - (dtucker) [configure.ac] Apply krb5-config --libs fix to non-gssapi path - too. - -20040220 - - (djm) [openbsd-compat/setproctitle.c] fix comments; from grange@ - -20040218 - - (dtucker) [configure.ac] Handle case where krb5-config --libs returns a - path with a "-" in it. From Sergio.Gelato at astro.su.se. - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/02/17 07:17:29 - [sftp-glob.c sftp.c] - Remove useless headers; ok deraadt@ - - djm@cvs.openbsd.org 2004/02/17 11:03:08 - [sftp.c] - sftp.c and sftp-int.c, together at last; ok markus@ - - jmc@cvs.openbsd.org 2004/02/17 19:35:21 - [sshd_config.5] - remove cruft left over from RhostsAuthentication removal; - ok markus@ - - (djm) [log.c] Correct use of HAVE_OPENLOG_R - - (djm) [log.c] Tighten openlog_r tests - -20040217 - - (djm) Simplify the license on code I have written. No code changes. - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/02/17 05:39:51 - [sftp-client.c sftp-client.h sftp-glob.c sftp-glob.h sftp-int.c] - [sftp-int.h sftp.c] - switch to license.template for code written by me (belated, I know...) - - (djm) Bug #698: Specify FILE: for KRB5CCNAME; patch from - stadal@suse.cz and simon@sxw.org.uk - - (dtucker) [auth-pam.c] Tidy up PAM debugging. ok djm@ - - (dtucker) [auth-pam.c] Store output from pam_session and pam_setcred for - display after login. Should fix problems like pam_motd not displaying - anything, noticed by cjwatson at debian.org. ok djm@ - -20040212 - - (tim) [Makefile.in regress/sftp-badcmds.sh regress/test-exec.sh] - Portablity fixes. Data sftp transfers needs to be world readable. Some - older shells hang on while loops when doing sh -n some_script. OK dtucker@ - - (tim) [configure.ac] Make sure -lcrypto is before -lsocket for sco3. - ok mouring@ - -20040211 - - (dtucker) [auth-passwd.c auth-shadow.c] Only enable shadow expiry check - if HAS_SHADOW_EXPIRY is set. - - (tim) [configure.ac] Fix comment to match code changes in ver 1.117 - -20040210 - - (dtucker) [auth-passwd.c auth.h openbsd-compat/port-aix.c - openbsd-compat/port-aix.h] Bug #14: Use do_pwchange to support AIX's - native password expiry. - - (dtucker) [LICENCE Makefile.in auth-passwd.c auth-shadow.c auth.c auth.h - defines.h] Bug #14: Use do_pwchange to support password expiry and force - change for platforms using /etc/shadow. ok djm@ - - (dtucker) [openbsd-compat/fake-rfc2553.h] Bug #563: Prepend ssh_ to compat - functions to avoid conflicts with Heimdal's libroken. ok djm@ - - (dtucker) [auth-pam.c auth-pam.h session.c] Bug #14: Use do_pwchange to - change expired PAM passwords for SSHv1 connections without privsep. - pam_chauthtok is still used when privsep is disabled. ok djm@ - - (dtucker) [openbsd-compat/port-aix.c openbsd-compat/port-aix.h] Move - include from port-aix.h to port-aix.c and remove unnecessary function - definition. Fixes build errors on AIX. - - (dtucker) [configure.ac loginrec.c] Bug #464: Use updwtmpx on platforms - that support it. from & ok mouring@ - - (dtucker) [configure.ac] Bug #345: Do not disable utmp on HP-UX 10.x. - ok djm@ - -20040207 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2004/02/06 23:41:13 - [cipher-ctr.c] - Use EVP_CIPHER_CTX_key_length for key length. ok markus@ - (This will fix builds with OpenSSL 0.9.5) - - (dtucker) [cipher.c] enable AES counter modes with OpenSSL 0.9.5. - ok djm@, markus@ - -20040206 - - (dtucker) [acss.c acss.h] Fix $Id tags. - - (dtucker) [cipher-acss.c cipher.c] Enable acss only if building with - OpenSSL >= 0.9.7. ok djm@ - - (dtucker) [session.c] Bug #789: Do not call do_pam_setcred as a non-root - user, since some modules might fail due to lack of privilege. ok djm@ - - (dtucker) [configure.ac] Bug #748: Always define BROKEN_GETADDRINFO - for HP-UX 11.11. If there are known-good configs where this is not - required, please report them. ok djm@ - - (dtucker) [sshd.c] Bug #757: Clear child's environment to prevent - accidentally inheriting from root's environment. ok djm@ - - (dtucker) [openbsd-compat/port-aix.c openbsd-compat/port-aix.h] Bug #796: - Restore previous authdb setting after auth calls. Fixes problems with - setpcred failing on accounts that use AFS or NIS password registries. - - (dtucker) [configure.ac includes.h] Include if present, - required on Solaris 2.5.1 for queue_t, which is used by . - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2004/01/30 09:48:57 - [auth-passwd.c auth.h pathnames.h session.c] - support for password change; ok dtucker@ - (set password-dead=1w in login.conf to use this). - In -Portable, this is currently only platforms using bsdauth. - - dtucker@cvs.openbsd.org 2004/02/05 05:37:17 - [monitor.c sshd.c] - Pass SIGALRM through to privsep child if LoginGraceTime expires. ok markus@ - - markus@cvs.openbsd.org 2004/02/05 15:33:33 - [progressmeter.c] - fix ETA for > 4GB; bugzilla #791; ok henning@ deraadt@ - -20040129 - - (dtucker) OpenBSD CVS Sync regress/ - - dtucker@cvs.openbsd.org 2003/10/11 11:49:49 - [Makefile banner.sh] - Test missing banner file, suppression of banner with ssh -q, check return - code from ssh. ok markus@ - - jmc@cvs.openbsd.org 2003/11/07 10:16:44 - [ssh-com.sh] - adress -> address, and a few more; all from Jonathon Gray; - - djm@cvs.openbsd.org 2004/01/13 09:49:06 - [sftp-batch.sh] - - (dtucker) [configure.ac] Add --without-zlib-version-check. Feedback from - tim@, ok several - - (dtucker) [configure.ac openbsd-compat/bsd-cray.c openbsd-compat/bsd-cray.h] - Bug #775: Cray fixes from wendy at cray.com - -20040128 - - (dtucker) [regress/README.regress] Add tcpwrappers issue, noted by tim@ - - (dtucker) [moduli] Import new moduli file from OpenBSD. - -20040127 - - (djm) OpenBSD CVS Sync - - hshoexer@cvs.openbsd.org 2004/01/23 17:06:03 - [cipher.c] - enable acss for ssh - ok deraadt@ markus@ - - mouring@cvs.openbsd.org 2004/01/23 17:57:48 - [sftp-int.c] - Fix issue pointed out with ls not handling large directories - with embeded paths correctly. OK damien@ - - hshoexer@cvs.openbsd.org 2004/01/23 19:26:33 - [cipher.c] - rename acss@opebsd.org to acss@openssh.org - ok deraadt@ - - djm@cvs.openbsd.org 2004/01/25 03:49:09 - [sshconnect.c] - reset nonblocking flag after ConnectTimeout > 0 connect; (bugzilla #785) - from jclonguet AT free.fr; ok millert@ - - djm@cvs.openbsd.org 2004/01/27 10:08:10 - [sftp.c] - reorder parsing so user:skey@host:file works (bugzilla #777) - patch from admorten AT umich.edu; ok markus@ - - (djm) [acss.c acss.h cipher-acss.c] Portable support for ACSS - if libcrypto lacks it - -20040126 - - (tim) Typo in regress/README.regress - - (tim) [regress/test-exec.sh] RhostsAuthentication is deprecated. - - (tim) [defines.h] Add defines for HFIXEDSZ and T_SIG - - (tim) [configure.ac includes.h] add for grantpt() and friends. - - (tim) [defines.h openbsd-compat/getrrsetbyname.h] Move defines for HFIXEDSZ - and T_SIG to getrrsetbyname.h - -20040124 - - (djm) Typo in openbsd-compat/bsd-openpty.c; from wendyp AT cray.com - -20040123 - - (djm) Do pam_session processing for systems with HAVE_LOGIN_CAP; from - ralf.hack AT pipex.net; ok dtucker@ - - (djm) Bug #776: Update contrib/redhat/openssh.spec to dynamically detect - Kerberos location (and thus work with Fedora Core 1); - from jason AT devrandom.org - - (dtucker) [configure.ac] Bug #788: Test for zlib.h presence and for - zlib >= 1.1.4. Partly from jbasney at ncsa.uiuc.edu. ok djm@ - - (dtucker) [contrib/cygwin/README] Document new ssh-host-config options. - Patch from vinschen at redhat.com. - - (dtucker) [acconfig.h configure.ac includes.h servconf.c session.c] - Change AFS symbol to USE_AFS to prevent namespace collisions, do not - include kafs.h unless necessary. From deengert at anl.gov. - - (tim) [configure.ac] Remove hard coded -L/usr/local/lib and - -I/usr/local/include. Users can do LDFLAGS="-L/usr/local/lib" \ - CPPFLAGS="-I/usr/local/include" ./configure if needed. - -20040122 - - (dtucker) [configure.ac] Use krb5-config where available for Kerberos/ - GSSAPI detection, libs and includes. ok djm@ - - (dtucker) [session.c] Enable AFS support in conjunction with KRB5 not - just HEIMDAL. - - (tim) [contrib/solaris/buildpkg.sh] Allow for the possibility of - /usr/local being a symbolic link. Fixes problem reported by Henry Grebler. - -20040121 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2004/01/13 09:25:05 - [sftp-int.c sftp.1 sftp.c] - Tidy sftp batchmode handling, eliminate junk to stderr (bugzilla #754) and - enable use of "-b -" to accept batchfile from stdin; ok markus@ - - jmc@cvs.openbsd.org 2004/01/13 12:17:33 - [sftp.1] - remove unnecessary Ic's; - kill whitespace at EOL; - ok djm@ - - markus@cvs.openbsd.org 2004/01/13 19:23:15 - [compress.c session.c] - -Wall; ok henning - - markus@cvs.openbsd.org 2004/01/13 19:45:15 - [compress.c] - cast for portability; millert@ - - markus@cvs.openbsd.org 2004/01/19 09:24:21 - [channels.c] - fake consumption for half closed channels since the peer is waiting for - window adjust messages; bugzilla #790 Matthew Dillon; test + ok dtucker@ - reproduce with sh -c 'ulimit -f 10; ssh host -n od /bsd | cat > foo' - - markus@cvs.openbsd.org 2004/01/19 21:25:15 - [auth2-hostbased.c auth2-pubkey.c serverloop.c ssh-keysign.c sshconnect2.c] - fix mem leaks; some fixes from Pete Flugstad; tested dtucker@ - - djm@cvs.openbsd.org 2004/01/21 03:07:59 - [sftp.c] - initialise infile in main, rather than statically - from portable - - deraadt@cvs.openbsd.org 2004/01/11 21:55:06 - [sshpty.c] - for pty opening, only use the openpty() path. the other stuff only needs - to be in openssh-p; markus ok - - (djm) [openbsd-compat/bsd-openpty.c] Rework old sshpty.c code into an - openpty() replacement - -20040114 - - (dtucker) [auth-pam.c] Have monitor die if PAM authentication thread exits - unexpectedly. with & ok djm@ - - (dtucker) [auth-pam.c] Reset signal handler in pthread_cancel too, add - test for case where cleanup has already run. - - (dtucker) [auth-pam.c] Add minor debugging. - -20040113 - - (dtucker) [auth-pam.c] Relocate struct pam_ctxt and prototypes. No - functional changes. - -20040108 - - (dtucker) [auth-pam.c defines.h] Bug #783: move __unused to defines.h and - only define if not already. From des at freebsd.org. - - (dtucker) [configure.ac] Remove extra (typo) comma. - -20040105 - - (dtucker) [contrib/ssh-copy-id] Bug #781: exit if ssh fails. Patch from - cjwatson at debian.org. - - (dtucker) [acconfig.h configure.ac includes.h servconf.c session.c] - Only enable KerberosGetAFSToken if Heimdal's libkafs is found. with jakob@ - -20040102 - - (djm) OSX/Darwin needs BIND_8_COMPAT to build getrrsetbyname. Report from - jakob@ - - (djm) Remove useless DNS support configure summary message. from jakob@ - - (djm) OSX/Darwin put the PAM headers in a different place, detect this. - Report from jakob@ - -20031231 - - (dtucker) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2003/12/22 09:16:58 - [moduli.c ssh-keygen.1 ssh-keygen.c] - tidy up moduli generation debugging, add -v (verbose/debug) option to - ssh-keygen; ok markus@ - - markus@cvs.openbsd.org 2003/12/22 20:29:55 - [cipher-3des1.c] - EVP_CIPHER_CTX_cleanup() for the des contexts; pruiksma@freesurf.fr - - jakob@cvs.openbsd.org 2003/12/23 16:12:10 - [servconf.c servconf.h session.c sshd_config] - implement KerberosGetAFSToken server option. ok markus@, beck@ - - millert@cvs.openbsd.org 2003/12/29 16:39:50 - [sshd_config] - KeepAlive has been obsoleted, use TCPKeepAlive instead; markus@ OK - - dtucker@cvs.openbsd.org 2003/12/31 00:24:50 - [auth2-passwd.c] - Ignore password change request during password auth (which we currently - don't support) and discard proposed new password. corrections/ok markus@ - - (dtucker) [configure.ac] Only test setresuid and setresgid if they exist. - -20031219 - - (dtucker) [defines.h] Bug #458: Define SIZE_T_MAX as UINT_MAX if we - typedef size_t ourselves. - -20031218 - - (dtucker) [configure.ac] Don't use setre[ug]id on DG-UX, from Tom Orban. - - (dtucker) [auth-pam.c] Do PAM chauthtok during SSH2 keyboard-interactive - authentication. Partially fixes bug #423. Feedback & ok djm@ - -20031217 - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2003/12/09 15:28:43 - [serverloop.c] - make ClientKeepAlive work for ssh -N, too (no login shell requested). - 1) send a bogus channel request if we find a channel - 2) send a bogus global request if we don't have a channel - ok + test beck@ - - markus@cvs.openbsd.org 2003/12/09 17:29:04 - [sshd.c] - fix -o and HUP; ok henning@ - - markus@cvs.openbsd.org 2003/12/09 17:30:05 - [ssh.c] - don't modify argv for ssh -o; similar to sshd.c 1.283 - - markus@cvs.openbsd.org 2003/12/09 21:53:37 - [readconf.c readconf.h scp.1 servconf.c servconf.h sftp.1 ssh.1] - [ssh_config.5 sshconnect.c sshd.c sshd_config.5] - rename keepalive to tcpkeepalive; the old name causes too much - confusion; ok djm, dtucker; with help from jmc@ - - dtucker@cvs.openbsd.org 2003/12/09 23:45:32 - [clientloop.c] - Clear exit code when ssh -N is terminated with a SIGTERM. ok markus@ - - markus@cvs.openbsd.org 2003/12/14 12:37:21 - [ssh_config.5] - we don't support GSS KEX; from Simon Wilkinson - - markus@cvs.openbsd.org 2003/12/16 15:49:51 - [clientloop.c clientloop.h readconf.c readconf.h scp.1 sftp.1 ssh.1] - [ssh.c ssh_config.5] - application layer keep alive (ServerAliveInterval ServerAliveCountMax) - for ssh(1), similar to the sshd(8) option; ok beck@; with help from - jmc and dtucker@ - - markus@cvs.openbsd.org 2003/12/16 15:51:54 - [dh.c] - use <= instead of < in dh_estimate; ok provos/hshoexer; - do not return < DH_GRP_MIN - - (dtucker) [acconfig.h configure.ac uidswap.c] Bug #645: Check for - setres[ug]id() present but not implemented (eg some Linux/glibc - combinations). - - (bal) [openbsd-compat/bsd-misc.c] unset 'signal' defined if we are - using a real 'signal()' (Noticed by a NeXT Compile) - -20031209 - - (dtucker) OpenBSD CVS Sync - - matthieu@cvs.openbsd.org 2003/11/25 23:10:08 - [ssh-add.1] - ssh-add doesn't need to be a descendant of ssh-agent. Ok markus@, jmc@. - - djm@cvs.openbsd.org 2003/11/26 21:44:29 - [cipher-aes.c] - fix #ifdef before #define; ok markus@ - (RCS ID sync only, Portable already had this) - - markus@cvs.openbsd.org 2003/12/02 12:15:10 - [progressmeter.c] - improvments from andreas@: - * saner speed estimate for transfers that takes less than a second by - rounding the time to 1 second. - * when the transfer is finished calculate the actual total speed - rather than the current speed which is given during the transfer - - markus@cvs.openbsd.org 2003/12/02 17:01:15 - [channels.c session.c ssh-agent.c ssh.h sshd.c] - use SSH_LISTEN_BACKLOG (=128) in listen(2). - - djm@cvs.openbsd.org 2003/12/07 06:34:18 - [moduli.c] - remove unused debugging #define templates - - markus@cvs.openbsd.org 2003/12/08 11:00:47 - [kexgexc.c] - print requested group size in debug; ok djm - - dtucker@cvs.openbsd.org 2003/12/09 13:52:55 - [moduli.c] - Prevent ssh-keygen -T from outputting moduli with a generator of 0, since - they can't be used for Diffie-Hellman. Assistance and ok djm@ - - (dtucker) [ssh-keyscan.c] Sync RCSIDs, missed in SSH_SSFDMAX change below. - -20031208 - - (tim) [configure.ac] Bug 770. Fix --without-rpath. - -20031123 - - (djm) [canohost.c] Move IPv4inV6 mapped address normalisation to its own - function and call it unconditionally - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2003/11/23 23:17:34 - [ssh-keyscan.c] - from portable - use sysconf to detect fd limit; ok markus@ - (tidy diff by adding SSH_SSFDMAX macro to defines.h) - - djm@cvs.openbsd.org 2003/11/23 23:18:45 - [ssh-keygen.c] - consistency PATH_MAX -> MAXPATHLEN; ok markus@ - (RCS ID sync only) - - djm@cvs.openbsd.org 2003/11/23 23:21:21 - [scp.c] - from portable: rename clashing variable limit-> limit_rate; ok markus@ - (RCS ID sync only) - - dtucker@cvs.openbsd.org 2003/11/24 00:16:35 - [ssh.1 ssh.c] - Make ssh -k mean GSSAPIDelegateCredentials=no. Suggestion & ok markus@ - - (djm) Annotate OpenBSD-derived files in openbsd-compat/ with original - source file path (in OpenBSD tree). - -20031122 - - (dtucker) [channels.c] Make AIX write limit code clearer. Suggested by djm@ - - (dtucker) [auth-passwd.c openbsd-compat/port-aix.c openbsd-compat/port-aix.h] - Move AIX specific password authentication code to port-aix.c, call - authenticate() until reenter flag is clear. - - (dtucker) [auth-sia.c configure.ac] Tru64 update from cmadams at hiwaay.net. - Use permanently_set_uid for SIA, only define DISABLE_FD_PASSING when SIA - is enabled, rely on SIA to check for locked accounts if enabled. ok djm@ - - (djm) [scp.c] Rename limitbw -> limit_rate to match upstreamed patch - - (djm) [sftp-int.c] Remove duplicated code from bogus sync - - (djm) [packet.c] Shuffle #ifdef to reduce conditionally compiled code - -20031121 - - (djm) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2003/11/20 11:39:28 - [progressmeter.c] - fix rounding errors; from andreas@ - - djm@cvs.openbsd.org 2003/11/21 11:57:03 - [everything] - unexpand and delete whitespace at EOL; ok markus@ - (done locally and RCS IDs synced) - -20031118 - - (djm) Fix early exit for root auth success when UsePAM=yes and - PermitRootLogin=no - - (dtucker) [auth-pam.c] Convert chauthtok_conv into a generic tty_conv, - and use it for do_pam_session. Fixes problems like pam_motd not - displaying anything. ok djm@ - - (dtucker) [auth-pam.c] Only use pam_putenv if our platform has it. ok djm@ - - (djm) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2003/11/18 00:40:05 - [serverloop.c] - Correct check for authctxt->valid. ok djm@ - - djm@cvs.openbsd.org 2003/11/18 10:53:07 - [monitor.c] - unbreak fake authloop for non-existent users (my screwup). Spotted and - tested by dtucker@; ok markus@ - -20031117 - - (djm) OpenBSD CVS Sync - - djm@cvs.openbsd.org 2003/11/03 09:03:37 - [auth-chall.c] - make this a little more idiot-proof; ok markus@ - (includes portable-specific changes) - - jakob@cvs.openbsd.org 2003/11/03 09:09:41 - [sshconnect.c] - move changed key warning into warn_changed_key(). ok markus@ - - jakob@cvs.openbsd.org 2003/11/03 09:37:32 - [sshconnect.c] - do not free static type pointer in warn_changed_key() - - djm@cvs.openbsd.org 2003/11/04 08:54:09 - [auth1.c auth2.c auth2-pubkey.c auth.h auth-krb5.c auth-passwd.c] - [auth-rhosts.c auth-rh-rsa.c auth-rsa.c monitor.c serverloop.c] - [session.c] - standardise arguments to auth methods - they should all take authctxt. - check authctxt->valid rather then pw != NULL; ok markus@ - - jakob@cvs.openbsd.org 2003/11/08 16:02:40 - [auth1.c] - remove unused variable (pw). ok djm@ - (id sync only - still used in portable) - - jmc@cvs.openbsd.org 2003/11/08 19:17:29 - [sftp-int.c] - typos from Jonathon Gray; - - jakob@cvs.openbsd.org 2003/11/10 16:23:41 - [bufaux.c bufaux.h cipher.c cipher.h hostfile.c hostfile.h key.c] - [key.h sftp-common.c sftp-common.h sftp-server.c sshconnect.c sshd.c] - [ssh-dss.c ssh-rsa.c uuencode.c uuencode.h] - constify. ok markus@ & djm@ - - dtucker@cvs.openbsd.org 2003/11/12 10:12:15 - [scp.c] - When called with -q, pass -q to ssh; suppresses SSH2 banner. ok markus@ - - jakob@cvs.openbsd.org 2003/11/12 16:39:58 - [dns.c dns.h readconf.c ssh_config.5 sshconnect.c] - update SSHFP validation. ok markus@ - - jmc@cvs.openbsd.org 2003/11/12 20:14:51 - [ssh_config.5] - make verb agree with subject, and kill some whitespace; - - markus@cvs.openbsd.org 2003/11/14 13:19:09 - [sshconnect2.c] - cleanup and minor fixes for the client code; from Simon Wilkinson - - djm@cvs.openbsd.org 2003/11/17 09:45:39 - [msg.c msg.h sshconnect2.c ssh-keysign.c] - return error on msg send/receive failure (rather than fatal); ok markus@ - - markus@cvs.openbsd.org 2003/11/17 11:06:07 - [auth2-gss.c gss-genr.c gss-serv.c monitor.c monitor.h monitor_wrap.c] - [monitor_wrap.h sshconnect2.c ssh-gss.h] - replace "gssapi" with "gssapi-with-mic"; from Simon Wilkinson; - test + ok jakob. - - (djm) Bug #632: Don't call pam_end indirectly from within kbd-int - conversation function - - (djm) Export environment variables from authentication subprocess to - parent. Part of Bug #717 - -20031115 - - (dtucker) [regress/agent-ptrace.sh] Test for GDB output from Solaris and - HP-UX, skip test on AIX. - -20031113 - - (dtucker) [auth-pam.c] Append newlines to lines output by the - pam_chauthtok_conv(). - - (dtucker) [README ssh-host-config ssh-user-config Makefile] (All - contrib/cygwin). Major update from vinschen at redhat.com. - - Makefile provides a `cygwin-postinstall' target to run right after - `make install'. - - Better support for Windows 2003 Server. - - Try to get permissions as correct as possible. - - New command line options to allow full automated host configuration. - - Create configs from skeletons in /etc/defaults/etc. - - Use /bin/bash, allows reading user input with readline support. - - Remove really old configs from /usr/local. - - (dtucker) [auth-pam.c] Add newline to accumulated PAM_TEXT_INFO and - PAM_ERROR_MSG messages. - -20031106 - - (djm) Clarify UsePAM consequences a little more - -20031103 - - (dtucker) [contrib/cygwin/ssh-host-config] Ensure entries in /etc/services - are created correctly with CRLF line terminations. Patch from vinschen at - redhat.com. - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2003/10/15 09:48:45 - [monitor_wrap.c] - check pmonitor != NULL - - markus@cvs.openbsd.org 2003/10/21 09:50:06 - [auth2-gss.c] - make sure the doid is larger than 2 - - avsm@cvs.openbsd.org 2003/10/26 16:57:43 - [sshconnect2.c] - rename 'supported' static var in userauth_gssapi() to 'gss_supported' - to avoid shadowing the global version. markus@ ok - - markus@cvs.openbsd.org 2003/10/28 09:08:06 - [misc.c] - error->debug for getsockopt+TCP_NODELAY; several requests - - markus@cvs.openbsd.org 2003/11/02 11:01:03 - [auth2-gss.c compat.c compat.h sshconnect2.c] - remove support for SSH_BUG_GSSAPI_BER; simon@sxw.org.uk - - (dtucker) [regress/agent-ptrace.sh] Use numeric uid and gid. - -20031021 - - (dtucker) [INSTALL] Some system crypt() functions support MD5 passwords - directly. Noted by Darren.Moffat at sun.com. - - (dtucker) [regress/agent-ptrace.sh] Skip agent-test unless SUDO is set, - make agent setgid during test. - -20031017 - - (dtucker) [INSTALL] Note that --with-md5 is now required on platforms with - MD5 passwords even if PAM support is enabled. From steev at detritus.net. - -20031015 - - (dtucker) OpenBSD CVS Sync - - jmc@cvs.openbsd.org 2003/10/08 08:27:36 - [scp.1 scp.c sftp-server.8 sftp.1 sftp.c ssh.1 sshd.8] - scp and sftp: add options list and sort options. options list requested - by deraadt@ - sshd: use same format as ssh - ssh: remove wrong option from list - sftp-server: Subsystem is documented in ssh_config(5), not sshd(8) - ok deraadt@ markus@ - - markus@cvs.openbsd.org 2003/10/08 15:21:24 - [readconf.c ssh_config.5] - default GSS API to no in client, too; ok jakob, deraadt@ - - markus@cvs.openbsd.org 2003/10/11 08:24:08 - [readconf.c readconf.h ssh.1 ssh.c ssh_config.5] - remote x11 clients are now untrusted by default, uses xauth(8) to generate - untrusted cookies; ForwardX11Trusted=yes restores old behaviour. - ok deraadt; feedback and ok djm/fries - - markus@cvs.openbsd.org 2003/10/11 08:26:43 - [sshconnect2.c] - search keys in reverse order; fixes #684 - - markus@cvs.openbsd.org 2003/10/11 11:36:23 - [monitor_wrap.c] - return NULL for missing banner; ok djm@ - - jmc@cvs.openbsd.org 2003/10/12 13:12:13 - [ssh_config.5] - note that EnableSSHKeySign should be in the non-hostspecific section; - remove unnecessary .Pp; - ok markus@ - - markus@cvs.openbsd.org 2003/10/13 08:22:25 - [scp.1 sftp.1] - don't refer to options related to forwarding; ok jmc@ - - jakob@cvs.openbsd.org 2003/10/14 19:42:10 - [dns.c dns.h readconf.c ssh-keygen.c sshconnect.c] - include SSHFP lookup code (not enabled by default). ok markus@ - - jakob@cvs.openbsd.org 2003/10/14 19:43:23 - [README.dns] - update - - markus@cvs.openbsd.org 2003/10/14 19:54:39 - [session.c ssh-agent.c] - 10X for mkdtemp; djm@ - - (dtucker) [acconfig.h configure.ac dns.c openbsd-compat/getrrsetbyname.c - openbsd-compat/getrrsetbyname.h] DNS fingerprint support is now always - compiled in but disabled in config. - - (dtucker) [auth.c] Check for disabled password expiry on HP-UX Trusted Mode. - - (tim) [regress/banner.sh] portability fix. - -20031009 - - (dtucker) [sshd_config.5] UsePAM defaults to "no". ok djm@ - -20031008 - - (dtucker) OpenBSD CVS Sync - - dtucker@cvs.openbsd.org 2003/10/07 01:47:27 - [sshconnect2.c] - Don't use logit for banner, since it truncates to MSGBUFSIZ; bz #668 & - #707. ok markus@ - - djm@cvs.openbsd.org 2003/10/07 07:04:16 - [sftp-int.c] - sftp quoting fix from admorten AT umich.edu; ok markus@ - - deraadt@cvs.openbsd.org 2003/10/07 21:58:28 - [sshconnect2.c] - set ptr to NULL after free - - dtucker@cvs.openbsd.org 2003/10/07 01:52:13 - [regress/Makefile regress/banner.sh] - Test SSH2 banner. ok markus@ - - djm@cvs.openbsd.org 2003/10/07 07:04:52 - [regress/sftp-cmds.sh] - more sftp quoting regress tests; ok markus - -20031007 - - (djm) Delete autom4te.cache after autoreconf - - (dtucker) [auth-pam.c auth-pam.h session.c] Make PAM use the new static - cleanup functions. With & ok djm@ - - (dtucker) [contrib/redhat/openssh.spec] Bug #714: Now that UsePAM is a - run-time switch, always build --with-md5-passwords. - - (dtucker) [configure.ac openbsd-compat/Makefile.in openbsd-compat/strtoul.c] - Bug #670: add strtoul() to openbsd-compat for platforms lacking it. ok djm@ - - (dtucker) [configure.ac] Bug #715: Set BROKEN_SETREUID and BROKEN_SETREGID - on Reliant Unix. Patch from Robert.Dahlem at siemens.com. - - (dtucker) [configure.ac] Bug #710: Check for dlsym() in libdl on - Reliant Unix. Based on patch from Robert.Dahlem at siemens.com. - -20031003 - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2003/10/02 10:41:59 - [sshd.c] - print openssl version, too, several requests; ok henning/djm. - - markus@cvs.openbsd.org 2003/10/02 08:26:53 - [ssh-gss.h] - missing $OpenBSD:; dtucker - - (tim) [contrib/caldera/openssh.spec] Remove obsolete --with-ipv4-default - option. - -20031002 - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2003/09/23 20:17:11 - [Makefile.in auth1.c auth2.c auth.c auth.h auth-krb5.c canohost.c - cleanup.c clientloop.c fatal.c gss-serv.c log.c log.h monitor.c monitor.h - monitor_wrap.c monitor_wrap.h packet.c serverloop.c session.c session.h - ssh-agent.c sshd.c] - replace fatal_cleanup() and linked list of fatal callbacks with static - cleanup_exit() function. re-refine cleanup_exit() where appropriate, - allocate sshd's authctxt eary to allow simpler cleanup in sshd. - tested by many, ok deraadt@ - - markus@cvs.openbsd.org 2003/09/23 20:18:52 - [progressmeter.c] - don't print trailing \0; bug #709; Robert.Dahlem@siemens.com - ok millert/deraadt@ - - markus@cvs.openbsd.org 2003/09/23 20:41:11 - [channels.c channels.h clientloop.c] - move client only agent code to clientloop.c - - markus@cvs.openbsd.org 2003/09/26 08:19:29 - [sshd.c] - no need to set the listen sockets to non-block; ok deraadt@ - - jmc@cvs.openbsd.org 2003/09/29 11:40:51 - [ssh.1] - - add list of options to -o and .Xr ssh_config(5) - - some other cleanup - requested by deraadt@; - ok deraadt@ markus@ - - markus@cvs.openbsd.org 2003/09/29 20:19:57 - [servconf.c sshd_config] - GSSAPICleanupCreds -> GSSAPICleanupCredentials - - (dtucker) [configure.ac] Don't set DISABLE_SHADOW when configuring - --with-pam. ok djm@ - - (dtucker) [ssh-gss.h] Prototype change missed in sync. - - (dtucker) [session.c] Fix bus errors on some 64-bit Solaris configurations. - Based on patches by Matthias Koeppe and Thomas Baden. ok djm@ - -20030930 - - (bal) Fix issues in openbsd-compat/realpath.c - -20030925 - - (dtucker) [configure.ac openbsd-compat/xcrypt.c] Bug #633: Remove - DISABLE_SHADOW for HP-UX, use getspnam instead of getprpwnam. Patch from - michael_steffens at hp.com, ok djm@ - - (tim) [sshd_config] UsePAM defaults to no. - -20030924 - - (djm) Update version.h and spec files for HEAD - - (dtucker) [configure.ac] IRIX5 needs the same setre[ug]id defines as IRIX6. - -20030923 - - (dtucker) [Makefile.in] Bug #644: Fix "make clean" for out-of-tree - builds. Portability corrections from tim@. - - (dtucker) [configure.ac] Bug #665: uid swapping issues on Mac OS X. - Patch from max at quendi.de. - - (dtucker) [configure.ac] Bug #657: uid swapping issues on BSDi. - - (dtucker) [configure.ac] Bug #653: uid swapping issues on Tru64. - - (dtucker) [configure.ac] Bug #693: uid swapping issues on NCR MP-RAS. - Patch from david.haughton at ncr.com - - (dtucker) [configure.ac] Bug #659: uid swapping issues on IRIX 6. - Part of patch supplied by bugzilla-openssh at thewrittenword.com - - (dtucker) [configure.ac openbsd-compat/fake-rfc2553.c - openbsd-compat/fake-rfc2553.h] Bug #659: Test for and handle systems with - where gai_strerror is defined as "const char *". Part of patch supplied - by bugzilla-openssh at thewrittenword.com - - (dtucker) [contrib/cygwin/README contrib/cygwin/ssh-host-config] Update - ssh-host-config to match current defaults, bump README version. Patch from - vinschen at redhat.com. - - (dtucker) [uidswap.c] Don't test restoration of uid on Cygwin since the - OS does not support permanently dropping privileges. Patch from - vinschen at redhat.com. - - (dtucker) [openbsd-compat/port-aix.c] Use correct include for xmalloc.h, - add canohost.h to stop warning. Based on patch from openssh-unix-dev at - thewrittenword.com - - (dtucker) [INSTALL] Bug #686: Document requirement for zlib 1.1.4 or - higher. - - (tim) Fix typo. s/SETEIUD_BREAKS_SETUID/SETEUID_BREAKS_SETUID/ - - (tim) [configure.ac] Bug 665: move 3 new AC_DEFINES outside of AC_TRY_RUN. - Report by distler AT golem ph utexas edu. - - (dtucker) [contrib/aix/pam.conf] Include example pam.conf for AIX from - article by genty at austin.ibm.com, included with the author's permission. - - (dtucker) OpenBSD CVS Sync - - markus@cvs.openbsd.org 2003/09/18 07:52:54 - [sshconnect.c] - missing {}; bug #656; jclonguet at free.fr - - markus@cvs.openbsd.org 2003/09/18 07:54:48 - [buffer.c] - protect against double free; #660; zardoz at users.sf.net - - markus@cvs.openbsd.org 2003/09/18 07:56:05 - [authfile.c] - missing buffer_free(&encrypted); #662; zardoz at users.sf.net - - markus@cvs.openbsd.org 2003/09/18 08:49:45 - [deattack.c misc.c session.c ssh-agent.c] - more buffer allocation fixes; from Solar Designer; CAN-2003-0682; - ok millert@ - - miod@cvs.openbsd.org 2003/09/18 13:02:21 - [authfd.c bufaux.c dh.c mac.c ssh-keygen.c] - A few signedness fixes for harmless situations; markus@ ok - - markus@cvs.openbsd.org 2003/09/19 09:02:02 - [packet.c] - buffer_dump only if PACKET_DEBUG is defined; Jedi/Sector One; pr 3471 - - markus@cvs.openbsd.org 2003/09/19 09:03:00 - [buffer.c] - sign fix in buffer_dump; Jedi/Sector One; pr 3473 - - markus@cvs.openbsd.org 2003/09/19 11:29:40 - [ssh-agent.c] - provide a ssh-agent specific fatal() function; ok deraadt - - markus@cvs.openbsd.org 2003/09/19 11:30:39 - [ssh-keyscan.c] - avoid fatal_cleanup, just call exit(); ok deraadt - - markus@cvs.openbsd.org 2003/09/19 11:31:33 - [channels.c] - do not call channel_free_all on fatal; ok deraadt - - markus@cvs.openbsd.org 2003/09/19 11:33:09 - [packet.c sshd.c] - do not call packet_close on fatal; ok deraadt - - markus@cvs.openbsd.org 2003/09/19 17:40:20 - [scp.c] - error handling for remote-remote copy; #638; report Harald Koenig; - ok millert, fgs, henning, deraadt - - markus@cvs.openbsd.org 2003/09/19 17:43:35 - [clientloop.c sshtty.c sshtty.h] - remove fatal callbacks from client code; ok deraadt - - (bal) "extration" -> "extraction" in ssh-rand-helper.c; repoted by john - on #unixhelp@efnet - - (tim) [configure.ac] add --disable-etc-default-login option. ok djm - - (djm) Sync with V_3_7 branch: - - (djm) Fix SSH1 challenge kludge - - (djm) Bug #671: Fix builds on OpenBSD - - (djm) Bug #676: Fix PAM stack corruption - - (djm) Fix bad free() in PAM code - - (djm) Don't call pam_end before pam_init - - (djm) Enable build with old OpenSSL again - - (djm) Trim deprecated options from INSTALL. Mention UsePAM - - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu - $Id$ diff --git a/openssh/ChangeLog.gssapi b/openssh/ChangeLog.gssapi new file mode 100644 index 0000000..cf9a482 --- /dev/null +++ b/openssh/ChangeLog.gssapi @@ -0,0 +1,60 @@ + +20060910 + - [ gss-genr.c kexgssc.c kexgsss.c kex.h monitor.c sshconnect2.c sshd.c + ssh-gss.h ] + add support for gss-group14-sha1 key exchange mechanisms + - [ gss-serv.c servconf.c servconf.h sshd_config sshd_config.5 ] + Add GSSAPIStrictAcceptorCheck option to allow the disabling of + acceptor principal checking on multi-homed machines. + + - [ sshd_config ssh_config ] + Add settings for GSSAPIKeyExchange and GSSAPITrustDNS to the sample + configuration files + - [ kexgss.c kegsss.c sshconnect2.c sshd.c ] + Code cleanup. Replace strlen/xmalloc/snprintf sequences with xasprintf() + Limit length of error messages displayed by client + +20060909 + - [ gss-genr.c gss-serv.c ] + move ssh_gssapi_acquire_cred() and ssh_gssapi_server_ctx to be server + only, where they belong + + +20060829 + - [ gss-serv-krb5.c ] + Fix CCAPI credentials cache name when creating KRB5CCNAME environment + variable + +20060828 + - [ gss-genr.c ] + Avoid Heimdal context freeing problem + + +20060818 + - [ gss-genr.c ssh-gss.h sshconnect2.c ] + Make sure that SPENGO is disabled + + +20060421 + - [ gssgenr.c, sshconnect2.c ] + a few type changes (signed versus unsigned, int versus size_t) to + fix compiler errors/warnings + (from jbasney AT ncsa.uiuc.edu) + - [ kexgssc.c, sshconnect2.c ] + fix uninitialized variable warnings + (from jbasney AT ncsa.uiuc.edu) + - [ gssgenr.c ] + pass oid to gss_display_status (helpful when using GSSAPI mechglue) + (from jbasney AT ncsa.uiuc.edu) + + - [ gss-serv-krb5.c ] + #ifdef HAVE_GSSAPI_KRB5 should be #ifdef HAVE_GSSAPI_KRB5_H + (from jbasney AT ncsa.uiuc.edu) + + - [ readconf.c, readconf.h, ssh_config.5, sshconnect2.c + add client-side GssapiKeyExchange option + (from jbasney AT ncsa.uiuc.edu) + - [ sshconnect2.c ] + add support for GssapiTrustDns option for gssapi-with-mic + (from jbasney AT ncsa.uiuc.edu) + diff --git a/openssh/HPN12-README b/openssh/HPN12-README index 01f46aa..8140a90 100644 --- a/openssh/HPN12-README +++ b/openssh/HPN12-README @@ -41,3 +41,5 @@ with nonHPN SSH installations. Conceptually this is similar to the TcpRcvBuf option as applied to the internal SSH flow control. This value can range from 1KB to 14MB (1-14336). Use of oversized or undersized buffers can cause performance problems depending on the length of the network path. The default size of this buffer +is 2MB. TcpRcvBufPoll, if set to yes, will override this value. This behaviour may +change in future versions. diff --git a/openssh/INSTALL b/openssh/INSTALL index 9def158..73b4cc5 100644 --- a/openssh/INSTALL +++ b/openssh/INSTALL @@ -12,6 +12,8 @@ http://www.openssl.org/ (OpenSSL 0.9.5a is partially supported, but some ciphers (SSH protocol 1 Blowfish) do not work correctly.) +The remaining items are optional. + OpenSSH can utilise Pluggable Authentication Modules (PAM) if your system supports it. PAM is standard on Redhat and Debian Linux, Solaris and HP-UX 11. @@ -57,13 +59,29 @@ installed. No other S/Key library is currently known to be supported. http://www.sparc.spb.su/solaris/skey/ LibEdit: -sftp now supports command-line editing via NetBSD's libedit. If your -platform has it available natively you can use that, alternatively -you might try these multi-platform ports: + +sftp supports command-line editing via NetBSD's libedit. If your platform +has it available natively you can use that, alternatively you might try +these multi-platform ports: http://www.thrysoee.dk/editline/ http://sourceforge.net/projects/libedit/ +Autoconf: + +If you modify configure.ac or configure doesn't exist (eg if you checked +the code out of CVS yourself) then you will need autoconf-2.60 to rebuild +the automatically generated files by running "autoreconf". + +http://www.gnu.org/software/autoconf/ + +Basic Security Module (BSM): + +Native BSM support is know to exist in Solaris from at least 2.5.1, +FreeBSD 6.1 and OS X. Alternatively, you may use the OpenBSM +implementation (http://www.openbsm.org). + + 2. Building / Installation -------------------------- @@ -113,6 +131,10 @@ name). There are a few other options to the configure script: +--with-audit=[module] enable additional auditing via the specified module. +Currently, drivers for "debug" (additional info via syslog) and "bsm" +(Sun's Basic Security Module) are supported. + --with-pam enables PAM support. If PAM support is compiled in, it must also be enabled in sshd_config (refer to the UsePAM directive). @@ -165,6 +187,8 @@ created. --with-ssl-dir=DIR allows you to specify where your OpenSSL libraries are installed. +--with-ssl-engine enables OpenSSL's (hardware) ENGINE support + --with-4in6 Check for IPv4 in IPv6 mapped addresses and convert them to real (AF_INET) IPv4 addresses. Works around some quirks on Linux. @@ -208,7 +232,8 @@ for sshd, ssh and ssh-agent. ------------------------- $ make survey -[check the contents and make sure there's no sensitive information] +[check the contents of the file "survey" to ensure there's no information +that you consider sensitive] $ make send-survey This will send configuration information for the currently configured diff --git a/openssh/LICENCE b/openssh/LICENCE index ac3634f..0c2ff06 100644 --- a/openssh/LICENCE +++ b/openssh/LICENCE @@ -287,6 +287,8 @@ OpenSSH contains no GPL code. Internet Software Consortium. Todd C. Miller + Reyk Floeter + Chad Mynhier * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/openssh/Makefile.in b/openssh/Makefile.in index 2e874f1..ed23efa 100644 --- a/openssh/Makefile.in +++ b/openssh/Makefile.in @@ -14,6 +14,7 @@ bindir=@bindir@/ssh.d sbindir=@sbindir@ libexecdir=@libexecdir@ datadir=@datadir@ +datarootdir=@datarootdir@ mandir=@mandir@ mansubdir=@mansubdir@ sysconfdir=$$GLOBUS_LOCATION/etc/ssh @@ -42,6 +43,8 @@ LD=@LD@ CFLAGS=@CFLAGS@ CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@ LIBS=@LIBS@ +LIBSELINUX=@LIBSELINUX@ +SSHDLIBS=@SSHDLIBS@ LIBEDIT=@LIBEDIT@ LIBPAM=@LIBPAM@ LIBWRAP=@LIBWRAP@ @@ -66,11 +69,11 @@ TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keys # pathnames.o # -LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o buffer.o \ +LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \ canohost.o channels.o cipher.o cipher-acss.o cipher-aes.o \ cipher-bf1.o cipher-ctr.o cipher-3des1.o cleanup.o \ compat.o compress.o crc32.o deattack.o fatal.o hostfile.o \ - log.o match.o moduli.o nchan.o packet.o \ + log.o match.o md-sha256.o moduli.o nchan.o packet.o \ readpass.o rsa.o ttymodes.o xmalloc.o \ atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \ monitor_fdpass.o rijndael.o ssh-dss.o ssh-rsa.o dh.o kexdh.o \ @@ -92,7 +95,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \ auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o\ gss-serv-gsi.o \ loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ - audit.o audit-bsm.o + audit.o audit-bsm.o platform.o MANPAGES = scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-rand-helper.8.out ssh-keysign.8.out sshd_config.5.out ssh_config.5.out MANPAGES_IN = scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-rand-helper.8 ssh-keysign.8 sshd_config.5 ssh_config.5 @@ -113,7 +116,7 @@ PATHSUBS = \ -e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \ -e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \ -e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \ - -e 's|/etc/sshrc|$(sysconfdir)/sshrc|g' \ + -e 's|/etc/ssh/sshrc|$(sysconfdir)/sshrc|g' \ -e 's|/usr/X11R6/bin/xauth|$(XAUTH_PATH)|g' \ -e 's|/var/empty|$(PRIVSEP_PATH)|g' \ -e 's|/usr/bin:/bin:/usr/sbin:/sbin|@user_path@|g' @@ -145,7 +148,7 @@ ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS) - $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBWRAP) $(LIBPAM) $(LIBS) + $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBWRAP) $(LIBPAM) $(LIBSELINUX) $(SSHDLIBS) $(LIBS) scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o $(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) @@ -210,8 +213,9 @@ clean: regressclean distclean: regressclean rm -f *.o *.a $(TARGETS) logintest config.cache config.log - rm -f *.out core opensshd.init - rm -f Makefile buildpkg.sh config.h config.status ssh_prng_cmds survey.sh *~ + rm -f *.out core opensshd.init openssh.xml + rm -f Makefile buildpkg.sh config.h config.status ssh_prng_cmds + rm -f survey.sh openbsd-compat/regress/Makefile *~ rm -rf autom4te.cache (cd openbsd-compat && $(MAKE) distclean) (cd scard && $(MAKE) distclean) @@ -558,6 +562,9 @@ tests: $(TARGETS) EXEEXT="$(EXEEXT)" \ $@ +compat-tests: $(LIBCOMPAT) + (cd openbsd-compat/regress && $(MAKE)) + regressclean: if [ -f regress/Makefile ] && [ -r regress/Makefile ]; then \ (cd regress && $(MAKE) clean) \ diff --git a/openssh/OVERVIEW b/openssh/OVERVIEW index d1a768c..2e1cc0b 100644 --- a/openssh/OVERVIEW +++ b/openssh/OVERVIEW @@ -162,8 +162,7 @@ these programs. - There are several other files in the distribution that contain various auxiliary routines: ssh.h the main header file for ssh (various definitions) - getput.h byte-order independent storage of integers - includes.h includes most system headers. Lots of #ifdefs. - tildexpand.c expand tilde in file names uidswap.c uid-swapping xmalloc.c "safe" malloc routines + +$OpenBSD: OVERVIEW,v 1.11 2006/08/03 03:34:41 deraadt Exp $ diff --git a/openssh/README b/openssh/README index 0567aa8..2c2c9aa 100644 --- a/openssh/README +++ b/openssh/README @@ -1,4 +1,4 @@ -See http://www.openssh.com/txt/release-4.3p2 for the release notes. +See http://www.openssh.com/txt/release-4.5 for the release notes. - A Japanese translation of this document and of the OpenSSH FAQ is - available at http://www.unixuser.org/~haruyama/security/openssh/index.html diff --git a/openssh/README.platform b/openssh/README.platform index 7356c10..5724b68 100644 --- a/openssh/README.platform +++ b/openssh/README.platform @@ -30,6 +30,18 @@ gcc, gcc-mingw-core, mingw-runtime, binutils, make, openssl, openssl-devel, zlib, minres, minires-devel. +Darwin and MacOS X +------------------ +Darwin does not provide a tun(4) driver required for OpenSSH-based +virtual private networks. The BSD manpage still exists, but the driver +has been removed in recent releases of Darwin and MacOS X. + +Nevertheless, tunnel support is known to work with Darwin 8 and +MacOS X 10.4 in Point-to-Point (Layer 3) and Ethernet (Layer 2) mode +using a third party driver. More information is available at: + http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ + + Solaris ------- If you enable BSM auditing on Solaris, you need to update audit_event(4) diff --git a/openssh/README.tun b/openssh/README.tun index d814f39..5e1cb07 100644 --- a/openssh/README.tun +++ b/openssh/README.tun @@ -87,12 +87,12 @@ combination with layer 2 tunneling and Ethernet bridging. | Client |------( Internet )-----| access.somewhere.net | +--------+ ( ) +----------------------+ : 192.168.1.78 | - :............................. +-------+ + :............................. +-------+ Forwarded ssh connection : | dmzgw | Layer 2 tunnel : +-------+ : | : | - : +------------+ + : +------------+ :......| sshgateway | | +------------+ --- real connection Bridge -> | +----------+ @@ -104,7 +104,7 @@ combination with layer 2 tunneling and Ethernet bridging. Finally connect to the OpenSSH server to establish the tunnel by using the following command: - + ssh sshgateway It is also possible to tell the client to fork into the background after @@ -129,4 +129,4 @@ interconnect corporate networks. Reyk Floeter -$OpenBSD: README.tun,v 1.3 2005/12/08 18:34:10 reyk Exp $ +$OpenBSD: README.tun,v 1.4 2006/03/28 00:12:31 deraadt Exp $ diff --git a/openssh/acss.c b/openssh/acss.c index c46d28b..37a07dd 100644 --- a/openssh/acss.c +++ b/openssh/acss.c @@ -16,6 +16,9 @@ */ #include "includes.h" + +#include + #include #if !defined(EVP_CTRL_SET_ACSS_MODE) && (OPENSSL_VERSION_NUMBER >= 0x00906000L) diff --git a/openssh/atomicio.c b/openssh/atomicio.c index 12abbda..f651a29 100644 --- a/openssh/atomicio.c +++ b/openssh/atomicio.c @@ -1,4 +1,6 @@ +/* $OpenBSD: atomicio.c,v 1.23 2006/08/03 03:34:41 deraadt Exp $ */ /* + * Copyright (c) 2006 Damien Miller. All rights reserved. * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. * Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. * All rights reserved. @@ -25,7 +27,12 @@ */ #include "includes.h" -RCSID("$OpenBSD: atomicio.c,v 1.13 2005/05/24 17:32:43 avsm Exp $"); + +#include +#include + +#include +#include #include "atomicio.h" @@ -33,11 +40,7 @@ RCSID("$OpenBSD: atomicio.c,v 1.13 2005/05/24 17:32:43 avsm Exp $"); * ensure all of data on socket comes through. f==read || f==vwrite */ size_t -atomicio(f, fd, _s, n) - ssize_t (*f) (int, void *, size_t); - int fd; - void *_s; - size_t n; +atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n) { char *s = _s; size_t pos = 0; @@ -58,8 +61,60 @@ atomicio(f, fd, _s, n) errno = EPIPE; return pos; default: - pos += (u_int)res; + pos += (size_t)res; } } return (pos); } + +/* + * ensure all of data on socket comes through. f==readv || f==writev + */ +size_t +atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd, + const struct iovec *_iov, int iovcnt) +{ + size_t pos = 0, rem; + ssize_t res; + struct iovec iov_array[IOV_MAX], *iov = iov_array; + + if (iovcnt > IOV_MAX) { + errno = EINVAL; + return 0; + } + /* Make a copy of the iov array because we may modify it below */ + memcpy(iov, _iov, iovcnt * sizeof(*_iov)); + + for (; iovcnt > 0 && iov[0].iov_len > 0;) { + res = (f) (fd, iov, iovcnt); + switch (res) { + case -1: + if (errno == EINTR || errno == EAGAIN) + continue; + return 0; + case 0: + errno = EPIPE; + return pos; + default: + rem = (size_t)res; + pos += rem; + /* skip completed iov entries */ + while (iovcnt > 0 && rem >= iov[0].iov_len) { + rem -= iov[0].iov_len; + iov++; + iovcnt--; + } + /* This shouldn't happen... */ + if (rem > 0 && (iovcnt <= 0 || rem > iov[0].iov_len)) { + errno = EFAULT; + return 0; + } + if (iovcnt == 0) + break; + /* update pointer in partially complete iov */ + iov[0].iov_base = ((char *)iov[0].iov_base) + rem; + iov[0].iov_len -= rem; + } + } + return pos; +} diff --git a/openssh/atomicio.h b/openssh/atomicio.h index 7eccf20..2fcd25d 100644 --- a/openssh/atomicio.h +++ b/openssh/atomicio.h @@ -1,6 +1,7 @@ -/* $OpenBSD: atomicio.h,v 1.6 2005/05/24 17:32:43 avsm Exp $ */ +/* $OpenBSD: atomicio.h,v 1.10 2006/08/03 03:34:41 deraadt Exp $ */ /* + * Copyright (c) 2006 Damien Miller. All rights reserved. * Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. * All rights reserved. * @@ -25,9 +26,20 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _ATOMICIO_H +#define _ATOMICIO_H + /* * Ensure all of data on socket comes through. f==read || f==vwrite */ size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); #define vwrite (ssize_t (*)(int, void *, size_t))write + +/* + * ensure all of data on socket comes through. f==readv || f==writev + */ +size_t atomiciov(ssize_t (*)(int, const struct iovec *, int), + int, const struct iovec *, int); + +#endif /* _ATOMICIO_H */ diff --git a/openssh/audit-bsm.c b/openssh/audit-bsm.c index 41a8ed0..6e8bc49 100644 --- a/openssh/audit-bsm.c +++ b/openssh/audit-bsm.c @@ -37,8 +37,16 @@ #include "includes.h" #if defined(USE_BSM_AUDIT) +#include + +#include +#include +#include + #include "ssh.h" #include "log.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "xmalloc.h" diff --git a/openssh/audit.c b/openssh/audit.c index 6bc9f92..bb386d8 100644 --- a/openssh/audit.c +++ b/openssh/audit.c @@ -26,10 +26,15 @@ #include "includes.h" +#include +#include + #ifdef SSH_AUDIT_EVENTS #include "audit.h" #include "log.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" /* diff --git a/openssh/audit.h b/openssh/audit.h index 9e49e91..eeb373a 100644 --- a/openssh/audit.h +++ b/openssh/audit.h @@ -24,8 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "auth.h" - #ifndef _SSH_AUDIT_H # define _SSH_AUDIT_H enum ssh_audit_event_type { diff --git a/openssh/auth-bsdauth.c b/openssh/auth-bsdauth.c index 920c977..37d527d 100644 --- a/openssh/auth-bsdauth.c +++ b/openssh/auth-bsdauth.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-bsdauth.c,v 1.10 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -21,13 +22,23 @@ * (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: auth-bsdauth.c,v 1.6 2005/01/19 13:11:47 dtucker Exp $"); + +#include + +#include #ifdef BSD_AUTH #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "log.h" +#include "buffer.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" static void * @@ -69,9 +80,8 @@ bsdauth_query(void *ctx, char **name, char **infotxt, *name = xstrdup(""); *infotxt = xstrdup(""); *numprompts = 1; - *prompts = xmalloc(*numprompts * sizeof(char *)); - *echo_on = xmalloc(*numprompts * sizeof(u_int)); - (*echo_on)[0] = 0; + *prompts = xcalloc(*numprompts, sizeof(char *)); + *echo_on = xcalloc(*numprompts, sizeof(u_int)); (*prompts)[0] = xstrdup(challenge); return 0; diff --git a/openssh/auth-chall.c b/openssh/auth-chall.c index e4f7830..919b1ea 100644 --- a/openssh/auth-chall.c +++ b/openssh/auth-chall.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-chall.c,v 1.12 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,11 +24,16 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-chall.c,v 1.9 2003/11/03 09:03:37 djm Exp $"); +#include + +#include + +#include "xmalloc.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "log.h" -#include "xmalloc.h" #include "servconf.h" /* limited protocol v1 interface to kbd-interactive authentication */ diff --git a/openssh/auth-krb5.c b/openssh/auth-krb5.c index bc37675..38164fd 100644 --- a/openssh/auth-krb5.c +++ b/openssh/auth-krb5.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-krb5.c,v 1.19 2006/08/03 03:34:41 deraadt Exp $ */ /* * Kerberos v5 authentication and ticket-passing routines. * @@ -28,18 +29,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-krb5.c,v 1.16 2005/11/21 09:42:10 dtucker Exp $"); +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" #include "packet.h" -#include "xmalloc.h" #include "log.h" +#include "buffer.h" #include "servconf.h" #include "uidswap.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #ifdef KRB5 +#include +#include +#include #include extern ServerOptions options; diff --git a/openssh/auth-options.c b/openssh/auth-options.c index ad97e61..ca5e1c9 100644 --- a/openssh/auth-options.c +++ b/openssh/auth-options.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-options.c,v 1.40 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -10,18 +11,31 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-options.c,v 1.33 2005/12/08 18:34:11 reyk Exp $"); + +#include + +#include +#include +#include +#include +#include #include "xmalloc.h" #include "match.h" #include "log.h" #include "canohost.h" +#include "buffer.h" #include "channels.h" #include "auth-options.h" #include "servconf.h" #include "misc.h" -#include "monitor_wrap.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif +#include "monitor_wrap.h" /* Flags set authorized_keys flags */ int no_port_forwarding_flag = 0; @@ -131,7 +145,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) forced_command = NULL; goto bad_option; } - forced_command[i] = 0; + forced_command[i] = '\0'; auth_debug_add("Forced command: %.900s", forced_command); opts++; goto next_option; @@ -163,7 +177,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) xfree(s); goto bad_option; } - s[i] = 0; + s[i] = '\0'; auth_debug_add("Adding to environment: %.900s", s); debug("Adding to environment: %.900s", s); opts++; @@ -200,7 +214,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) xfree(patterns); goto bad_option; } - patterns[i] = 0; + patterns[i] = '\0'; opts++; if (match_host_and_ip(remote_host, remote_ip, patterns) != 1) { @@ -245,7 +259,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) xfree(patterns); goto bad_option; } - patterns[i] = 0; + patterns[i] = '\0'; opts++; p = patterns; host = hpdelim(&p); @@ -293,7 +307,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) forced_tun_device = -1; goto bad_option; } - tun[i] = 0; + tun[i] = '\0'; forced_tun_device = a2tun(tun, NULL); xfree(tun); if (forced_tun_device == SSH_TUNID_ERR) { diff --git a/openssh/auth-options.h b/openssh/auth-options.h index 3cd02a7..853f8b5 100644 --- a/openssh/auth-options.h +++ b/openssh/auth-options.h @@ -1,4 +1,4 @@ -/* $OpenBSD: auth-options.h,v 1.13 2005/12/06 22:38:27 reyk Exp $ */ +/* $OpenBSD: auth-options.h,v 1.16 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/auth-pam.c b/openssh/auth-pam.c index 8ff3320..c08d472 100644 --- a/openssh/auth-pam.c +++ b/openssh/auth-pam.c @@ -47,7 +47,16 @@ /* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */ #include "includes.h" -RCSID("$Id$"); + +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef USE_PAM #if defined(HAVE_SECURITY_PAM_APPL_H) @@ -63,20 +72,31 @@ RCSID("$Id$"); # define sshpam_const const /* LinuxPAM, OpenPAM */ #endif +/* Ambiguity in spec: is it an array of pointers or a pointer to an array? */ +#ifdef PAM_SUN_CODEBASE +# define PAM_MSG_MEMBER(msg, n, member) ((*(msg))[(n)].member) +#else +# define PAM_MSG_MEMBER(msg, n, member) ((msg)[(n)]->member) +#endif + +#include "xmalloc.h" +#include "buffer.h" +#include "key.h" +#include "hostfile.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 "misc.h" #include "servconf.h" #include "ssh2.h" -#include "xmalloc.h" #include "auth-options.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif +#include "monitor_wrap.h" extern ServerOptions options; extern Buffer loginmsg; @@ -146,14 +166,16 @@ sshpam_sigchld_handler(int sig) fatal("PAM: authentication thread exited uncleanly"); } +/* ARGSUSED */ static void -pthread_exit(void *value __unused) +pthread_exit(void *value) { _exit(0); } +/* ARGSUSED */ static int -pthread_create(sp_pthread_t *thread, const void *attr __unused, +pthread_create(sp_pthread_t *thread, const void *attr, void *(*thread_start)(void *), void *arg) { pid_t pid; @@ -185,8 +207,9 @@ pthread_cancel(sp_pthread_t thread) return (kill(thread, SIGTERM)); } +/* ARGSUSED */ static int -pthread_join(sp_pthread_t thread, void **value __unused) +pthread_join(sp_pthread_t thread, void **value) { int status; @@ -284,7 +307,10 @@ import_environments(Buffer *b) /* Import environment from subprocess */ num_env = buffer_get_int(b); - sshpam_env = xmalloc((num_env + 1) * sizeof(*sshpam_env)); + if (num_env > 1024) + fatal("%s: received %u environment variables, expected <= 1024", + __func__, num_env); + sshpam_env = xcalloc(num_env + 1, sizeof(*sshpam_env)); debug3("PAM: num env strings %d", num_env); for(i = 0; i < num_env; i++) sshpam_env[i] = buffer_get_string(b, NULL); @@ -331,9 +357,8 @@ sshpam_thread_conv(int n, sshpam_const struct pam_message **msg, if (n <= 0 || n > PAM_MAX_NUM_MSG) return (PAM_CONV_ERR); - if ((reply = malloc(n * sizeof(*reply))) == NULL) + if ((reply = calloc(n, sizeof(*reply))) == NULL) return (PAM_CONV_ERR); - memset(reply, 0, n * sizeof(*reply)); buffer_init(&buffer); for (i = 0; i < n; ++i) { @@ -412,10 +437,16 @@ sshpam_thread(void *ctxtp) u_int i; const char *pam_user; const char **ptr_pam_user = &pam_user; + char *tz = getenv("TZ"); pam_get_item(sshpam_handle, PAM_USER, (sshpam_const void **)ptr_pam_user); + environ[0] = NULL; + if (tz != NULL) + if (setenv("TZ", tz, 1) == -1) + error("PAM: could not set TZ environment: %s", + strerror(errno)); if (sshpam_authctxt != NULL) { setproctitle("%s [pam]", @@ -439,8 +470,10 @@ sshpam_thread(void *ctxtp) goto auth_fail; if (compat20) { - if (!do_pam_account()) + if (!do_pam_account()) { + sshpam_err = PAM_ACCT_EXPIRED; goto auth_fail; + } if (sshpam_authctxt->force_pwchange) { sshpam_err = pam_chauthtok(sshpam_handle, PAM_CHANGE_EXPIRED_AUTHTOK); @@ -482,7 +515,10 @@ sshpam_thread(void *ctxtp) buffer_put_cstring(&buffer, pam_strerror(sshpam_handle, sshpam_err)); /* XXX - can't do much about an error here */ - ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer); + if (sshpam_err == PAM_ACCT_EXPIRED) + ssh_msg_send(ctxt->pam_csock, PAM_ACCT_EXPIRED, &buffer); + else + ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer); buffer_free(&buffer); pthread_exit(NULL); @@ -529,9 +565,8 @@ sshpam_store_conv(int n, sshpam_const struct pam_message **msg, if (n <= 0 || n > PAM_MAX_NUM_MSG) return (PAM_CONV_ERR); - if ((reply = malloc(n * sizeof(*reply))) == NULL) + if ((reply = calloc(n, sizeof(*reply))) == NULL) return (PAM_CONV_ERR); - memset(reply, 0, n * sizeof(*reply)); for (i = 0; i < n; ++i) { switch (PAM_MSG_MEMBER(msg, i, msg_style)) { @@ -638,8 +673,11 @@ sshpam_init_ctx(Authctxt *authctxt) int socks[2]; debug3("PAM: %s entering", __func__); - /* Refuse to start if we don't have PAM enabled */ - if (!options.use_pam) + /* + * Refuse to start if we don't have PAM enabled or do_pam_account + * has previously failed. + */ + if (!options.use_pam || sshpam_account_status == 0) return NULL; /* Initialize PAM */ @@ -699,7 +737,7 @@ sshpam_query(void *ctx, char **name, char **info, case PAM_PROMPT_ECHO_OFF: *num = 1; len = plen + mlen + 1; - **prompts = xrealloc(**prompts, len); + **prompts = xrealloc(**prompts, 1, len); strlcpy(**prompts + plen, msg, len - plen); plen += mlen; **echo_on = (type == PAM_PROMPT_ECHO_ON); @@ -709,21 +747,25 @@ sshpam_query(void *ctx, char **name, char **info, case PAM_TEXT_INFO: /* accumulate messages */ len = plen + mlen + 2; - **prompts = xrealloc(**prompts, len); + **prompts = xrealloc(**prompts, 1, len); strlcpy(**prompts + plen, msg, len - plen); plen += mlen; strlcat(**prompts + plen, "\n", len - plen); plen++; xfree(msg); break; + case PAM_ACCT_EXPIRED: + sshpam_account_status = 0; + /* FALLTHROUGH */ case PAM_AUTH_ERR: - debug3("PAM: PAM_AUTH_ERR"); + debug3("PAM: %s", pam_strerror(sshpam_handle, type)); if (**prompts != NULL && strlen(**prompts) != 0) { *info = **prompts; **prompts = NULL; *num = 0; **echo_on = 0; ctxt->pam_done = -1; + xfree(msg); return 0; } /* FALLTHROUGH */ @@ -930,9 +972,8 @@ sshpam_tty_conv(int n, sshpam_const struct pam_message **msg, if (n <= 0 || n > PAM_MAX_NUM_MSG || !isatty(STDIN_FILENO)) return (PAM_CONV_ERR); - if ((reply = malloc(n * sizeof(*reply))) == NULL) + if ((reply = calloc(n, sizeof(*reply))) == NULL) return (PAM_CONV_ERR); - memset(reply, 0, n * sizeof(*reply)); for (i = 0; i < n; ++i) { switch (PAM_MSG_MEMBER(msg, i, msg_style)) { diff --git a/openssh/auth-passwd.c b/openssh/auth-passwd.c index 6e6d0d7..be62837 100644 --- a/openssh/auth-passwd.c +++ b/openssh/auth-passwd.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-passwd.c,v 1.40 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -36,12 +37,20 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-passwd.c,v 1.34 2005/07/19 15:32:26 otto Exp $"); + +#include + +#include +#include +#include +#include #include "packet.h" #include "buffer.h" #include "log.h" #include "servconf.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "auth-options.h" diff --git a/openssh/auth-rh-rsa.c b/openssh/auth-rh-rsa.c index c31f2b9..eca7502 100644 --- a/openssh/auth-rh-rsa.c +++ b/openssh/auth-rh-rsa.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-rh-rsa.c,v 1.42 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -13,18 +14,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-rh-rsa.c,v 1.38 2005/07/17 07:17:54 djm Exp $"); + +#include + +#include +#include #include "packet.h" #include "uidswap.h" #include "log.h" +#include "buffer.h" #include "servconf.h" #include "key.h" #include "hostfile.h" #include "pathnames.h" #include "auth.h" #include "canohost.h" - +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" /* import */ diff --git a/openssh/auth-rhosts.c b/openssh/auth-rhosts.c index aaba855..cd0a796 100644 --- a/openssh/auth-rhosts.c +++ b/openssh/auth-rhosts.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-rhosts.c,v 1.41 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -14,14 +15,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-rhosts.c,v 1.33 2005/07/17 07:17:54 djm Exp $"); + +#include +#include + +#ifdef HAVE_NETGROUP_H +# include +#endif +#include +#include +#include +#include #include "packet.h" +#include "buffer.h" #include "uidswap.h" #include "pathnames.h" #include "log.h" #include "servconf.h" #include "canohost.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" /* import */ diff --git a/openssh/auth-rsa.c b/openssh/auth-rsa.c index d9c9652..69f9a58 100644 --- a/openssh/auth-rsa.c +++ b/openssh/auth-rsa.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-rsa.c,v 1.72 2006/11/06 21:25:27 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -14,23 +15,35 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-rsa.c,v 1.63 2005/06/17 02:44:32 djm Exp $"); + +#include +#include #include #include +#include +#include +#include +#include + +#include "xmalloc.h" #include "rsa.h" #include "packet.h" -#include "xmalloc.h" #include "ssh1.h" #include "uidswap.h" #include "match.h" +#include "buffer.h" #include "auth-options.h" #include "pathnames.h" #include "log.h" #include "servconf.h" -#include "auth.h" +#include "key.h" #include "hostfile.h" +#include "auth.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "ssh.h" #include "misc.h" @@ -63,10 +76,12 @@ auth_rsa_generate_challenge(Key *key) if ((challenge = BN_new()) == NULL) fatal("auth_rsa_generate_challenge: BN_new() failed"); /* Generate a random challenge. */ - BN_rand(challenge, 256, 0, 0); + if (BN_rand(challenge, 256, 0, 0) == 0) + fatal("auth_rsa_generate_challenge: BN_rand failed"); if ((ctx = BN_CTX_new()) == NULL) - fatal("auth_rsa_generate_challenge: BN_CTX_new() failed"); - BN_mod(challenge, challenge, key->rsa->n, ctx); + fatal("auth_rsa_generate_challenge: BN_CTX_new failed"); + if (BN_mod(challenge, challenge, key->rsa->n, ctx) == 0) + fatal("auth_rsa_generate_challenge: BN_mod failed"); BN_CTX_free(ctx); return challenge; @@ -137,7 +152,7 @@ auth_rsa_challenge_dialog(Key *key) /* Wait for a response. */ packet_read_expect(SSH_CMSG_AUTH_RSA_RESPONSE); for (i = 0; i < 16; i++) - response[i] = packet_get_char(); + response[i] = (u_char)packet_get_char(); packet_check_eom(); success = PRIVSEP(auth_rsa_verify_response(key, challenge, response)); diff --git a/openssh/auth-shadow.c b/openssh/auth-shadow.c index 3e27b46..8b3160a 100644 --- a/openssh/auth-shadow.c +++ b/openssh/auth-shadow.c @@ -23,11 +23,14 @@ */ #include "includes.h" -RCSID("$Id$"); #if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE) #include +#include +#include +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "buffer.h" #include "log.h" diff --git a/openssh/auth-sia.c b/openssh/auth-sia.c index af7182b..a9e1c25 100644 --- a/openssh/auth-sia.c +++ b/openssh/auth-sia.c @@ -25,14 +25,6 @@ #include "includes.h" #ifdef HAVE_OSF_SIA -#include "ssh.h" -#include "auth.h" -#include "auth-sia.h" -#include "log.h" -#include "servconf.h" -#include "canohost.h" -#include "uidswap.h" - #include #include #include @@ -40,8 +32,19 @@ #include #include #include +#include #include +#include "ssh.h" +#include "key.h" +#include "hostfile.h" +#include "auth.h" +#include "auth-sia.h" +#include "log.h" +#include "servconf.h" +#include "canohost.h" +#include "uidswap.h" + extern ServerOptions options; extern int saved_argc; extern char **saved_argv; diff --git a/openssh/auth-skey.c b/openssh/auth-skey.c index f676dbe..25073db 100644 --- a/openssh/auth-skey.c +++ b/openssh/auth-skey.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth-skey.c,v 1.26 2006/08/05 08:28:24 dtucker Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -21,15 +22,23 @@ * (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: auth-skey.c,v 1.20 2002/06/30 21:59:45 deraadt Exp $"); #ifdef SKEY +#include + +#include +#include + #include #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" +#include "ssh-gss.h" #include "monitor_wrap.h" static void * @@ -43,8 +52,7 @@ skey_query(void *ctx, char **name, char **infotxt, u_int* numprompts, char ***prompts, u_int **echo_on) { Authctxt *authctxt = ctx; - char challenge[1024], *p; - int len; + char challenge[1024]; struct skey skey; if (_compat_skeychallenge(&skey, authctxt->user, challenge, @@ -54,15 +62,10 @@ skey_query(void *ctx, char **name, char **infotxt, *name = xstrdup(""); *infotxt = xstrdup(""); *numprompts = 1; - *prompts = xmalloc(*numprompts * sizeof(char *)); - *echo_on = xmalloc(*numprompts * sizeof(u_int)); - (*echo_on)[0] = 0; - - len = strlen(challenge) + strlen(SKEY_PROMPT) + 1; - p = xmalloc(len); - strlcpy(p, challenge, len); - strlcat(p, SKEY_PROMPT, len); - (*prompts)[0] = p; + *prompts = xcalloc(*numprompts, sizeof(char *)); + *echo_on = xcalloc(*numprompts, sizeof(u_int)); + + xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT); return 0; } diff --git a/openssh/auth.c b/openssh/auth.c index 7bcbfad..c745098 100644 --- a/openssh/auth.c +++ b/openssh/auth.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth.c,v 1.75 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,39 +24,56 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth.c,v 1.60 2005/06/17 02:44:32 djm Exp $"); +#include +#include +#include + +#include + +#include +#ifdef HAVE_PATHS_H +# include +#endif +#include #ifdef HAVE_LOGIN_H #include #endif #ifdef USE_SHADOW #include #endif - #ifdef HAVE_LIBGEN_H #include #endif +#include +#include +#include #include "xmalloc.h" #include "match.h" #include "groupaccess.h" #include "log.h" +#include "buffer.h" #include "servconf.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "auth-options.h" #include "canohost.h" -#include "buffer.h" -#include "bufaux.h" #include "uidswap.h" #include "misc.h" -#include "bufaux.h" #include "packet.h" #include "loginrec.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" /* import */ extern ServerOptions options; +extern int use_privsep; extern Buffer loginmsg; +extern struct passwd *privsep_pw; /* Debugging messages */ Buffer auth_debug; @@ -231,6 +249,9 @@ auth_log(Authctxt *authctxt, int authenticated, char *method, char *info) void (*authlog) (const char *fmt,...) = verbose; char *authmsg; + if (use_privsep && !mm_is_monitor() && !authctxt->postponed) + return; + /* Raise logging level */ if (authenticated == 1 || !authctxt->valid || @@ -260,44 +281,15 @@ auth_log(Authctxt *authctxt, int authenticated, char *method, char *info) strcmp(method, "challenge-response") == 0)) record_failed_login(authctxt->user, get_canonical_hostname(options.use_dns), "ssh"); +# ifdef WITH_AIXAUTHENTICATE + if (authenticated) + sys_auth_record_login(authctxt->user, + get_canonical_hostname(options.use_dns), "ssh", &loginmsg); +# endif #endif #ifdef SSH_AUDIT_EVENTS - if (authenticated == 0 && !authctxt->postponed) { - ssh_audit_event_t event; - - debug3("audit failed auth attempt, method %s euid %d", - method, (int)geteuid()); - /* - * Because the auth loop is used in both monitor and slave, - * we must be careful to send each event only once and with - * enough privs to write the event. - */ - event = audit_classify_auth(method); - switch(event) { - case SSH_AUTH_FAIL_NONE: - case SSH_AUTH_FAIL_PASSWD: - case SSH_AUTH_FAIL_KBDINT: - if (geteuid() == 0) - audit_event(event); - break; - case SSH_AUTH_FAIL_PUBKEY: - case SSH_AUTH_FAIL_HOSTBASED: - case SSH_AUTH_FAIL_GSSAPI: - /* - * This is required to handle the case where privsep - * is enabled but it's root logging in, since - * use_privsep won't be cleared until after a - * successful login. - */ - if (geteuid() == 0) - audit_event(event); - else - PRIVSEP(audit_event(event)); - break; - default: - error("unknown authentication audit event %d", event); - } - } + if (authenticated == 0 && !authctxt->postponed) + audit_event(audit_classify_auth(method)); #endif } @@ -310,7 +302,6 @@ auth_root_allowed(char *method) switch (options.permit_root_login) { case PERMIT_YES: return 1; - break; case PERMIT_NO_PASSWD: if (strcmp(method, "password") != 0) return 1; @@ -334,10 +325,11 @@ auth_root_allowed(char *method) * * This returns a buffer allocated by xmalloc. */ -static char * +char * expand_authorized_keys(const char *filename, struct passwd *pw) { - char *file, *ret; + char *file, ret[MAXPATHLEN]; + int i; file = percent_expand(filename, "h", pw->pw_dir, "u", pw->pw_name, (char *)NULL); @@ -349,14 +341,11 @@ expand_authorized_keys(const char *filename, struct passwd *pw) if (*file == '/') return (file); - ret = xmalloc(MAXPATHLEN); - if (strlcpy(ret, pw->pw_dir, MAXPATHLEN) >= MAXPATHLEN || - strlcat(ret, "/", MAXPATHLEN) >= MAXPATHLEN || - strlcat(ret, file, MAXPATHLEN) >= MAXPATHLEN) + i = snprintf(ret, sizeof(ret), "%s/%s", pw->pw_dir, file); + if (i < 0 || (size_t)i >= sizeof(ret)) fatal("expand_authorized_keys: path too long"); - xfree(file); - return (ret); + return (xstrdup(ret)); } char * @@ -493,6 +482,9 @@ getpwnamallow(const char *user) #endif struct passwd *pw; + parse_server_match_config(&options, user, + get_canonical_hostname(options.use_dns), get_remote_ipaddr()); + pw = getpwnam(user); if (pw == NULL) { logit("Invalid user %.100s from %.100s", @@ -579,8 +571,8 @@ fakepw(void) fake.pw_passwd = "$2a$06$r3.juUaHZDlIbQaO2dS9FuYxL1W9M81R1Tc92PoSNmzvpEqLkLGrK"; fake.pw_gecos = "NOUSER"; - fake.pw_uid = (uid_t)-1; - fake.pw_gid = (gid_t)-1; + fake.pw_uid = privsep_pw->pw_uid; + fake.pw_gid = privsep_pw->pw_gid; #ifdef HAVE_PW_CLASS_IN_PASSWD fake.pw_class = ""; #endif diff --git a/openssh/auth.h b/openssh/auth.h index 4114fa3..f63c3ee 100644 --- a/openssh/auth.h +++ b/openssh/auth.h @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.h,v 1.51 2005/06/06 11:20:36 djm Exp $ */ +/* $OpenBSD: auth.h,v 1.58 2006/08/18 09:15:20 markus Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -28,9 +28,8 @@ #ifndef AUTH_H #define AUTH_H -#include "key.h" -#include "hostfile.h" -#include "buffer.h" +#include + #include #ifdef HAVE_LOGIN_CAP @@ -51,7 +50,8 @@ typedef struct Authmethod Authmethod; typedef struct KbdintDevice KbdintDevice; struct Authctxt { - int success; + sig_atomic_t success; + int authenticated; /* authenticated and alarms cancelled */ int postponed; /* authentication needs another step */ int valid; /* user exists and is allowed to login */ int attempt; diff --git a/openssh/auth1.c b/openssh/auth1.c index 4bc2bf7..b9d6b11 100644 --- a/openssh/auth1.c +++ b/openssh/auth1.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth1.c,v 1.70 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved @@ -10,7 +11,14 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth1.c,v 1.62 2005/07/16 01:35:24 djm Exp $"); + +#include + +#include +#include +#include +#include +#include #include "xmalloc.h" #include "rsa.h" @@ -20,10 +28,15 @@ RCSID("$OpenBSD: auth1.c,v 1.62 2005/07/16 01:35:24 djm Exp $"); #include "log.h" #include "servconf.h" #include "compat.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "channels.h" #include "session.h" #include "uidswap.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "buffer.h" @@ -77,7 +90,7 @@ static const struct AuthMethod1 { int i; - for(i = 0; auth1_methods[i].name != NULL; i++) + for (i = 0; auth1_methods[i].name != NULL; i++) if (auth1_methods[i].type == type) return (&(auth1_methods[i])); @@ -96,6 +109,7 @@ get_authname(int type) return (buf); } +/*ARGSUSED*/ static int auth1_process_password(Authctxt *authctxt, char *info, size_t infolen) { @@ -120,6 +134,7 @@ auth1_process_password(Authctxt *authctxt, char *info, size_t infolen) return (authenticated); } +/*ARGSUSED*/ static int auth1_process_rsa(Authctxt *authctxt, char *info, size_t infolen) { @@ -137,6 +152,7 @@ auth1_process_rsa(Authctxt *authctxt, char *info, size_t infolen) return (authenticated); } +/*ARGSUSED*/ static int auth1_process_rhosts_rsa(Authctxt *authctxt, char *info, size_t infolen) { @@ -175,6 +191,7 @@ auth1_process_rhosts_rsa(Authctxt *authctxt, char *info, size_t infolen) return (authenticated); } +/*ARGSUSED*/ static int auth1_process_tis_challenge(Authctxt *authctxt, char *info, size_t infolen) { @@ -193,6 +210,7 @@ auth1_process_tis_challenge(Authctxt *authctxt, char *info, size_t infolen) return (-1); } +/*ARGSUSED*/ static int auth1_process_tis_response(Authctxt *authctxt, char *info, size_t infolen) { diff --git a/openssh/auth2-chall.c b/openssh/auth2-chall.c index b147cad..b78b739 100644 --- a/openssh/auth2-chall.c +++ b/openssh/auth2-chall.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2-chall.c,v 1.31 2006/08/05 08:28:24 dtucker Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Per Allansson. All rights reserved. @@ -22,14 +23,22 @@ * (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: auth2-chall.c,v 1.24 2005/07/17 07:17:54 djm Exp $"); +#include + +#include +#include +#include + +#include "xmalloc.h" #include "ssh2.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "buffer.h" #include "packet.h" -#include "xmalloc.h" #include "dispatch.h" #include "log.h" #include "servconf.h" @@ -291,7 +300,7 @@ input_userauth_info_response(int type, u_int32_t seq, void *ctxt) if (nresp > 100) fatal("input_userauth_info_response: too many replies"); if (nresp > 0) { - response = xmalloc(nresp * sizeof(char *)); + response = xcalloc(nresp, sizeof(char *)); for (i = 0; i < nresp; i++) response[i] = packet_get_string(NULL); } diff --git a/openssh/auth2-gss.c b/openssh/auth2-gss.c index 6fcecb8..fab7cc2 100644 --- a/openssh/auth2-gss.c +++ b/openssh/auth2-gss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-gss.c,v 1.12 2005/10/13 22:24:31 stevesk Exp $ */ +/* $OpenBSD: auth2-gss.c,v 1.15 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. @@ -28,16 +28,22 @@ #ifdef GSSAPI +#include + +#include + +#include "xmalloc.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "ssh2.h" -#include "xmalloc.h" #include "log.h" #include "dispatch.h" +#include "buffer.h" #include "servconf.h" #include "packet.h" -#include "monitor_wrap.h" - #include "ssh-gss.h" +#include "monitor_wrap.h" extern ServerOptions options; @@ -165,6 +171,8 @@ userauth_gssapi(Authctxt *authctxt) } if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt, &goid)))) { + if (ctxt != NULL) + ssh_gssapi_delete_ctx(&ctxt); xfree(doid); authctxt->server_caused_failure = 1; return (0); diff --git a/openssh/auth2-hostbased.c b/openssh/auth2-hostbased.c index 1111ed6..663dec5 100644 --- a/openssh/auth2-hostbased.c +++ b/openssh/auth2-hostbased.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2-hostbased.c,v 1.11 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,19 +24,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-hostbased.c,v 1.6 2004/01/19 21:25:15 markus Exp $"); -#include "ssh2.h" +#include + +#include +#include +#include + #include "xmalloc.h" +#include "ssh2.h" #include "packet.h" #include "buffer.h" #include "log.h" #include "servconf.h" #include "compat.h" -#include "bufaux.h" -#include "auth.h" #include "key.h" +#include "hostfile.h" +#include "auth.h" #include "canohost.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "pathnames.h" diff --git a/openssh/auth2-kbdint.c b/openssh/auth2-kbdint.c index fa83649..a4fc9e6 100644 --- a/openssh/auth2-kbdint.c +++ b/openssh/auth2-kbdint.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2-kbdint.c,v 1.5 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,13 +24,19 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-kbdint.c,v 1.2 2002/05/31 11:35:15 markus Exp $"); +#include + +#include + +#include "xmalloc.h" #include "packet.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "log.h" +#include "buffer.h" #include "servconf.h" -#include "xmalloc.h" /* import */ extern ServerOptions options; diff --git a/openssh/auth2-none.c b/openssh/auth2-none.c index 1c30a32..952b448 100644 --- a/openssh/auth2-none.c +++ b/openssh/auth2-none.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2-none.c,v 1.13 2006/08/05 07:52:52 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,16 +24,29 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-none.c,v 1.7 2004/05/11 19:01:43 deraadt Exp $"); -#include "auth.h" +#include +#include +#include + +#include +#include +#include + #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" +#include "auth.h" #include "packet.h" #include "log.h" +#include "buffer.h" #include "servconf.h" #include "atomicio.h" #include "compat.h" #include "ssh2.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" /* import */ diff --git a/openssh/auth2-passwd.c b/openssh/auth2-passwd.c index 2321ef4..421c5c2 100644 --- a/openssh/auth2-passwd.c +++ b/openssh/auth2-passwd.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2-passwd.c,v 1.9 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,12 +24,22 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-passwd.c,v 1.5 2003/12/31 00:24:50 dtucker Exp $"); + +#include + +#include +#include #include "xmalloc.h" #include "packet.h" #include "log.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" +#include "buffer.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "servconf.h" diff --git a/openssh/auth2-pubkey.c b/openssh/auth2-pubkey.c index a97d0f4..9863cd9 100644 --- a/openssh/auth2-pubkey.c +++ b/openssh/auth2-pubkey.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2-pubkey.c,v 1.15 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,23 +24,32 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-pubkey.c,v 1.9 2004/12/11 01:48:56 dtucker Exp $"); +#include +#include + +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "ssh2.h" -#include "xmalloc.h" #include "packet.h" #include "buffer.h" #include "log.h" #include "servconf.h" #include "compat.h" -#include "bufaux.h" -#include "auth.h" #include "key.h" +#include "hostfile.h" +#include "auth.h" #include "pathnames.h" #include "uidswap.h" #include "auth-options.h" #include "canohost.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "misc.h" diff --git a/openssh/auth2.c b/openssh/auth2.c index 65c1dc8..a660c83 100644 --- a/openssh/auth2.c +++ b/openssh/auth2.c @@ -1,3 +1,4 @@ +/* $OpenBSD: auth2.c,v 1.113 2006/08/03 03:34:41 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,23 +24,31 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2.c,v 1.107 2004/07/28 09:40:29 markus Exp $"); -#include "ssh2.h" +#include + +#include +#include +#include + #include "xmalloc.h" +#include "ssh2.h" #include "packet.h" #include "log.h" +#include "buffer.h" #include "servconf.h" #include "compat.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "dispatch.h" #include "pathnames.h" -#include "monitor_wrap.h" #include "buffer.h" #ifdef GSSAPI #include "ssh-gss.h" #endif +#include "monitor_wrap.h" /* import */ extern ServerOptions options; @@ -102,6 +111,7 @@ do_authentication2(Authctxt *authctxt) dispatch_run(DISPATCH_BLOCK, &authctxt->success, authctxt); } +/*ARGSUSED*/ static void input_service_request(int type, u_int32_t seq, void *ctxt) { @@ -135,6 +145,7 @@ input_service_request(int type, u_int32_t seq, void *ctxt) xfree(service); } +/*ARGSUSED*/ static void input_userauth_request(int type, u_int32_t seq, void *ctxt) { diff --git a/openssh/authfd.c b/openssh/authfd.c index 8976616..61faad1 100644 --- a/openssh/authfd.c +++ b/openssh/authfd.c @@ -1,3 +1,4 @@ +/* $OpenBSD: authfd.c,v 1.80 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,16 +36,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: authfd.c,v 1.66 2005/06/17 02:44:32 djm Exp $"); + +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "rsa.h" #include "buffer.h" -#include "bufaux.h" -#include "xmalloc.h" -#include "getput.h" #include "key.h" #include "authfd.h" #include "cipher.h" @@ -52,6 +62,7 @@ RCSID("$OpenBSD: authfd.c,v 1.66 2005/06/17 02:44:32 djm Exp $"); #include "compat.h" #include "log.h" #include "atomicio.h" +#include "misc.h" static int agent_present = 0; @@ -103,7 +114,7 @@ ssh_get_authentication_socket(void) close(sock); return -1; } - if (connect(sock, (struct sockaddr *) &sunaddr, sizeof sunaddr) < 0) { + if (connect(sock, (struct sockaddr *)&sunaddr, sizeof sunaddr) < 0) { close(sock); return -1; } @@ -119,7 +130,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply /* Get the length of the message, and format it in the buffer. */ len = buffer_len(request); - PUT_32BIT(buf, len); + put_u32(buf, len); /* Send the length and then the packet to the agent. */ if (atomicio(vwrite, auth->fd, buf, 4) != 4 || @@ -138,7 +149,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply } /* Extract the length, and check it for sanity. */ - len = GET_32BIT(buf); + len = get_u32(buf); if (len > 256 * 1024) fatal("Authentication response too long: %u", len); @@ -335,7 +346,6 @@ ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int versio break; default: return NULL; - break; } /* Decrement the number of remaining entries. */ auth->howmany--; @@ -394,7 +404,7 @@ ssh_decrypt_challenge(AuthenticationConnection *auth, * fatal error if the packet is corrupt. */ for (i = 0; i < 16; i++) - response[i] = buffer_get_char(&buffer); + response[i] = (u_char)buffer_get_char(&buffer); } buffer_free(&buffer); return success; @@ -517,7 +527,6 @@ ssh_add_identity_constrained(AuthenticationConnection *auth, Key *key, default: buffer_free(&msg); return 0; - break; } if (constrained) { if (life != 0) { diff --git a/openssh/authfd.h b/openssh/authfd.h index 0a6a4e3..3da2561 100644 --- a/openssh/authfd.h +++ b/openssh/authfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: authfd.h,v 1.34 2003/11/21 11:57:03 djm Exp $ */ +/* $OpenBSD: authfd.h,v 1.36 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -16,8 +16,6 @@ #ifndef AUTHFD_H #define AUTHFD_H -#include "buffer.h" - /* Messages for the authentication agent connection. */ #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 #define SSH_AGENT_RSA_IDENTITIES_ANSWER 2 diff --git a/openssh/authfile.c b/openssh/authfile.c index 420813f..735c647 100644 --- a/openssh/authfile.c +++ b/openssh/authfile.c @@ -1,3 +1,4 @@ +/* $OpenBSD: authfile.c,v 1.76 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -36,16 +37,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: authfile.c,v 1.61 2005/06/17 02:44:32 djm Exp $"); + +#include +#include +#include +#include #include #include #include -#include "cipher.h" +#include +#include +#include +#include +#include +#include +#include + #include "xmalloc.h" +#include "cipher.h" #include "buffer.h" -#include "bufaux.h" #include "key.h" #include "ssh.h" #include "log.h" @@ -184,7 +196,7 @@ key_save_private_pem(Key *key, const char *filename, const char *_passphrase, return 0; } fp = fdopen(fd, "w"); - if (fp == NULL ) { + if (fp == NULL) { error("fdopen %s failed: %s.", filename, strerror(errno)); close(fd); return 0; @@ -211,12 +223,10 @@ key_save_private(Key *key, const char *filename, const char *passphrase, case KEY_RSA1: return key_save_private_rsa1(key, filename, passphrase, comment); - break; case KEY_DSA: case KEY_RSA: return key_save_private_pem(key, filename, passphrase, comment); - break; default: break; } @@ -507,7 +517,7 @@ key_load_private_pem(int fd, int type, const char *passphrase, return prv; } -static int +int key_perm_ok(int fd, const char *filename) { struct stat st; @@ -537,7 +547,7 @@ key_perm_ok(int fd, const char *filename) Key * key_load_private_type(int type, const char *filename, const char *passphrase, - char **commentp) + char **commentp, int *perm_ok) { int fd; @@ -545,22 +555,24 @@ key_load_private_type(int type, const char *filename, const char *passphrase, if (fd < 0) return NULL; if (!key_perm_ok(fd, filename)) { + if (perm_ok != NULL) + *perm_ok = 0; error("bad permissions: ignore key: %s", filename); close(fd); return NULL; } + if (perm_ok != NULL) + *perm_ok = 1; switch (type) { case KEY_RSA1: return key_load_private_rsa1(fd, filename, passphrase, commentp); /* closes fd */ - break; case KEY_DSA: case KEY_RSA: case KEY_UNSPEC: return key_load_private_pem(fd, type, passphrase, commentp); /* closes fd */ - break; default: close(fd); break; diff --git a/openssh/authfile.h b/openssh/authfile.h index 7f92701..a6c7493 100644 --- a/openssh/authfile.h +++ b/openssh/authfile.h @@ -1,4 +1,4 @@ -/* $OpenBSD: authfile.h,v 1.10 2002/05/23 19:24:30 markus Exp $ */ +/* $OpenBSD: authfile.h,v 1.13 2006/04/25 08:02:27 dtucker Exp $ */ /* * Author: Tatu Ylonen @@ -19,7 +19,8 @@ int key_save_private(Key *, const char *, const char *, const char *); Key *key_load_public(const char *, char **); Key *key_load_public_type(int, const char *, char **); Key *key_load_private(const char *, const char *, char **); -Key *key_load_private_type(int, const char *, const char *, char **); +Key *key_load_private_type(int, const char *, const char *, char **, int *); Key *key_load_private_pem(int, int, const char *, char **); +int key_perm_ok(int, const char *); #endif diff --git a/openssh/bufaux.c b/openssh/bufaux.c index 106a3a0..cbdc22c 100644 --- a/openssh/bufaux.c +++ b/openssh/bufaux.c @@ -1,3 +1,4 @@ +/* $OpenBSD: bufaux.c,v 1.44 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -37,176 +38,18 @@ */ #include "includes.h" -RCSID("$OpenBSD: bufaux.c,v 1.37 2005/11/05 05:01:15 djm Exp $"); -#include -#include "bufaux.h" -#include "xmalloc.h" -#include "getput.h" -#include "log.h" - -/* - * Stores an BIGNUM in the buffer with a 2-byte msb first bit count, followed - * by (bits+7)/8 bytes of binary data, msb first. - */ -int -buffer_put_bignum_ret(Buffer *buffer, const BIGNUM *value) -{ - int bits = BN_num_bits(value); - int bin_size = (bits + 7) / 8; - u_char *buf = xmalloc(bin_size); - int oi; - char msg[2]; - - /* Get the value of in binary */ - oi = BN_bn2bin(value, buf); - if (oi != bin_size) { - error("buffer_put_bignum_ret: BN_bn2bin() failed: oi %d != bin_size %d", - oi, bin_size); - xfree(buf); - return (-1); - } - - /* Store the number of bits in the buffer in two bytes, msb first. */ - PUT_16BIT(msg, bits); - buffer_append(buffer, msg, 2); - /* Store the binary data. */ - buffer_append(buffer, (char *)buf, oi); - - memset(buf, 0, bin_size); - xfree(buf); - - return (0); -} - -void -buffer_put_bignum(Buffer *buffer, const BIGNUM *value) -{ - if (buffer_put_bignum_ret(buffer, value) == -1) - fatal("buffer_put_bignum: buffer error"); -} +#include -/* - * Retrieves an BIGNUM from the buffer. - */ -int -buffer_get_bignum_ret(Buffer *buffer, BIGNUM *value) -{ - u_int bits, bytes; - u_char buf[2], *bin; - - /* Get the number for bits. */ - if (buffer_get_ret(buffer, (char *) buf, 2) == -1) { - error("buffer_get_bignum_ret: invalid length"); - return (-1); - } - bits = GET_16BIT(buf); - /* Compute the number of binary bytes that follow. */ - bytes = (bits + 7) / 8; - if (bytes > 8 * 1024) { - error("buffer_get_bignum_ret: cannot handle BN of size %d", bytes); - return (-1); - } - if (buffer_len(buffer) < bytes) { - error("buffer_get_bignum_ret: input buffer too small"); - return (-1); - } - bin = buffer_ptr(buffer); - BN_bin2bn(bin, bytes, value); - if (buffer_consume_ret(buffer, bytes) == -1) { - error("buffer_get_bignum_ret: buffer_consume failed"); - return (-1); - } - return (0); -} - -void -buffer_get_bignum(Buffer *buffer, BIGNUM *value) -{ - if (buffer_get_bignum_ret(buffer, value) == -1) - fatal("buffer_get_bignum: buffer error"); -} - -/* - * Stores an BIGNUM in the buffer in SSH2 format. - */ -int -buffer_put_bignum2_ret(Buffer *buffer, const BIGNUM *value) -{ - u_int bytes; - u_char *buf; - int oi; - u_int hasnohigh = 0; - - if (BN_is_zero(value)) { - buffer_put_int(buffer, 0); - return 0; - } - if (value->neg) { - error("buffer_put_bignum2_ret: negative numbers not supported"); - return (-1); - } - bytes = BN_num_bytes(value) + 1; /* extra padding byte */ - if (bytes < 2) { - error("buffer_put_bignum2_ret: BN too small"); - return (-1); - } - buf = xmalloc(bytes); - buf[0] = 0x00; - /* Get the value of in binary */ - oi = BN_bn2bin(value, buf+1); - if (oi < 0 || (u_int)oi != bytes - 1) { - error("buffer_put_bignum2_ret: BN_bn2bin() failed: " - "oi %d != bin_size %d", oi, bytes); - xfree(buf); - return (-1); - } - hasnohigh = (buf[1] & 0x80) ? 0 : 1; - buffer_put_string(buffer, buf+hasnohigh, bytes-hasnohigh); - memset(buf, 0, bytes); - xfree(buf); - return (0); -} - -void -buffer_put_bignum2(Buffer *buffer, const BIGNUM *value) -{ - if (buffer_put_bignum2_ret(buffer, value) == -1) - fatal("buffer_put_bignum2: buffer error"); -} - -int -buffer_get_bignum2_ret(Buffer *buffer, BIGNUM *value) -{ - u_int len; - u_char *bin; - - if ((bin = buffer_get_string_ret(buffer, &len)) == NULL) { - error("buffer_get_bignum2_ret: invalid bignum"); - return (-1); - } +#include - if (len > 0 && (bin[0] & 0x80)) { - error("buffer_get_bignum2_ret: negative numbers not supported"); - xfree(bin); - return (-1); - } - if (len > 8 * 1024) { - error("buffer_get_bignum2_ret: cannot handle BN of size %d", len); - xfree(bin); - return (-1); - } - BN_bin2bn(bin, len, value); - xfree(bin); - return (0); -} +#include +#include -void -buffer_get_bignum2(Buffer *buffer, BIGNUM *value) -{ - if (buffer_get_bignum2_ret(buffer, value) == -1) - fatal("buffer_get_bignum2: buffer error"); -} +#include "xmalloc.h" +#include "buffer.h" +#include "log.h" +#include "misc.h" /* * Returns integers from the buffer (msb first). @@ -219,7 +62,7 @@ buffer_get_short_ret(u_short *ret, Buffer *buffer) if (buffer_get_ret(buffer, (char *) buf, 2) == -1) return (-1); - *ret = GET_16BIT(buf); + *ret = get_u16(buf); return (0); } @@ -241,7 +84,7 @@ buffer_get_int_ret(u_int *ret, Buffer *buffer) if (buffer_get_ret(buffer, (char *) buf, 4) == -1) return (-1); - *ret = GET_32BIT(buf); + *ret = get_u32(buf); return (0); } @@ -263,7 +106,7 @@ buffer_get_int64_ret(u_int64_t *ret, Buffer *buffer) if (buffer_get_ret(buffer, (char *) buf, 8) == -1) return (-1); - *ret = GET_64BIT(buf); + *ret = get_u64(buf); return (0); } @@ -286,7 +129,7 @@ buffer_put_short(Buffer *buffer, u_short value) { char buf[2]; - PUT_16BIT(buf, value); + put_u16(buf, value); buffer_append(buffer, buf, 2); } @@ -295,7 +138,7 @@ buffer_put_int(Buffer *buffer, u_int value) { char buf[4]; - PUT_32BIT(buf, value); + put_u32(buf, value); buffer_append(buffer, buf, 4); } @@ -304,7 +147,7 @@ buffer_put_int64(Buffer *buffer, u_int64_t value) { char buf[8]; - PUT_64BIT(buf, value); + put_u64(buf, value); buffer_append(buffer, buf, 8); } diff --git a/openssh/bufaux.h b/openssh/bufaux.h deleted file mode 100644 index f5efaed..0000000 --- a/openssh/bufaux.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: bufaux.h,v 1.21 2005/03/10 22:01:05 deraadt Exp $ */ - -/* - * Author: Tatu Ylonen - * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland - * All rights reserved - * - * 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". - */ - -#ifndef BUFAUX_H -#define BUFAUX_H - -#include "buffer.h" -#include - -void buffer_put_bignum(Buffer *, const BIGNUM *); -void buffer_put_bignum2(Buffer *, const BIGNUM *); -void buffer_get_bignum(Buffer *, BIGNUM *); -void buffer_get_bignum2(Buffer *, BIGNUM *); - -u_short buffer_get_short(Buffer *); -void buffer_put_short(Buffer *, u_short); - -u_int buffer_get_int(Buffer *); -void buffer_put_int(Buffer *, u_int); - -u_int64_t buffer_get_int64(Buffer *); -void buffer_put_int64(Buffer *, u_int64_t); - -int buffer_get_char(Buffer *); -void buffer_put_char(Buffer *, int); - -void *buffer_get_string(Buffer *, u_int *); -void buffer_put_string(Buffer *, const void *, u_int); -void buffer_put_cstring(Buffer *, const char *); - -#define buffer_skip_string(b) \ - do { u_int l = buffer_get_int(b); buffer_consume(b, l); } while (0) - -int buffer_put_bignum_ret(Buffer *, const BIGNUM *); -int buffer_get_bignum_ret(Buffer *, BIGNUM *); -int buffer_put_bignum2_ret(Buffer *, const BIGNUM *); -int buffer_get_bignum2_ret(Buffer *, BIGNUM *); -int buffer_get_short_ret(u_short *, Buffer *); -int buffer_get_int_ret(u_int *, Buffer *); -int buffer_get_int64_ret(u_int64_t *, Buffer *); -void *buffer_get_string_ret(Buffer *, u_int *); -int buffer_get_char_ret(char *, Buffer *); - -#endif /* BUFAUX_H */ diff --git a/openssh/bufbn.c b/openssh/bufbn.c new file mode 100644 index 0000000..9706ba8 --- /dev/null +++ b/openssh/bufbn.c @@ -0,0 +1,221 @@ +/* $OpenBSD: bufbn.c,v 1.4 2006/11/06 21:25:28 markus Exp $*/ +/* + * Author: Tatu Ylonen + * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland + * All rights reserved + * Auxiliary functions for storing and retrieving various data types to/from + * Buffers. + * + * 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". + * + * + * SSH2 packet format added by Markus Friedl + * 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" + +#include + +#include + +#include +#include + +#include "xmalloc.h" +#include "buffer.h" +#include "log.h" +#include "misc.h" + +/* + * Stores an BIGNUM in the buffer with a 2-byte msb first bit count, followed + * by (bits+7)/8 bytes of binary data, msb first. + */ +int +buffer_put_bignum_ret(Buffer *buffer, const BIGNUM *value) +{ + int bits = BN_num_bits(value); + int bin_size = (bits + 7) / 8; + u_char *buf = xmalloc(bin_size); + int oi; + char msg[2]; + + /* Get the value of in binary */ + oi = BN_bn2bin(value, buf); + if (oi != bin_size) { + error("buffer_put_bignum_ret: BN_bn2bin() failed: oi %d != bin_size %d", + oi, bin_size); + xfree(buf); + return (-1); + } + + /* Store the number of bits in the buffer in two bytes, msb first. */ + put_u16(msg, bits); + buffer_append(buffer, msg, 2); + /* Store the binary data. */ + buffer_append(buffer, buf, oi); + + memset(buf, 0, bin_size); + xfree(buf); + + return (0); +} + +void +buffer_put_bignum(Buffer *buffer, const BIGNUM *value) +{ + if (buffer_put_bignum_ret(buffer, value) == -1) + fatal("buffer_put_bignum: buffer error"); +} + +/* + * Retrieves an BIGNUM from the buffer. + */ +int +buffer_get_bignum_ret(Buffer *buffer, BIGNUM *value) +{ + u_int bits, bytes; + u_char buf[2], *bin; + + /* Get the number for bits. */ + if (buffer_get_ret(buffer, (char *) buf, 2) == -1) { + error("buffer_get_bignum_ret: invalid length"); + return (-1); + } + bits = get_u16(buf); + /* Compute the number of binary bytes that follow. */ + bytes = (bits + 7) / 8; + if (bytes > 8 * 1024) { + error("buffer_get_bignum_ret: cannot handle BN of size %d", bytes); + return (-1); + } + if (buffer_len(buffer) < bytes) { + error("buffer_get_bignum_ret: input buffer too small"); + return (-1); + } + bin = buffer_ptr(buffer); + if (BN_bin2bn(bin, bytes, value) == NULL) { + error("buffer_get_bignum_ret: BN_bin2bn failed"); + return (-1); + } + if (buffer_consume_ret(buffer, bytes) == -1) { + error("buffer_get_bignum_ret: buffer_consume failed"); + return (-1); + } + return (0); +} + +void +buffer_get_bignum(Buffer *buffer, BIGNUM *value) +{ + if (buffer_get_bignum_ret(buffer, value) == -1) + fatal("buffer_get_bignum: buffer error"); +} + +/* + * Stores an BIGNUM in the buffer in SSH2 format. + */ +int +buffer_put_bignum2_ret(Buffer *buffer, const BIGNUM *value) +{ + u_int bytes; + u_char *buf; + int oi; + u_int hasnohigh = 0; + + if (BN_is_zero(value)) { + buffer_put_int(buffer, 0); + return 0; + } + if (value->neg) { + error("buffer_put_bignum2_ret: negative numbers not supported"); + return (-1); + } + bytes = BN_num_bytes(value) + 1; /* extra padding byte */ + if (bytes < 2) { + error("buffer_put_bignum2_ret: BN too small"); + return (-1); + } + buf = xmalloc(bytes); + buf[0] = 0x00; + /* Get the value of in binary */ + oi = BN_bn2bin(value, buf+1); + if (oi < 0 || (u_int)oi != bytes - 1) { + error("buffer_put_bignum2_ret: BN_bn2bin() failed: " + "oi %d != bin_size %d", oi, bytes); + xfree(buf); + return (-1); + } + hasnohigh = (buf[1] & 0x80) ? 0 : 1; + buffer_put_string(buffer, buf+hasnohigh, bytes-hasnohigh); + memset(buf, 0, bytes); + xfree(buf); + return (0); +} + +void +buffer_put_bignum2(Buffer *buffer, const BIGNUM *value) +{ + if (buffer_put_bignum2_ret(buffer, value) == -1) + fatal("buffer_put_bignum2: buffer error"); +} + +int +buffer_get_bignum2_ret(Buffer *buffer, BIGNUM *value) +{ + u_int len; + u_char *bin; + + if ((bin = buffer_get_string_ret(buffer, &len)) == NULL) { + error("buffer_get_bignum2_ret: invalid bignum"); + return (-1); + } + + if (len > 0 && (bin[0] & 0x80)) { + error("buffer_get_bignum2_ret: negative numbers not supported"); + xfree(bin); + return (-1); + } + if (len > 8 * 1024) { + error("buffer_get_bignum2_ret: cannot handle BN of size %d", len); + xfree(bin); + return (-1); + } + if (BN_bin2bn(bin, len, value) == NULL) { + error("buffer_get_bignum2_ret: BN_bin2bn failed"); + return (-1); + } + xfree(bin); + return (0); +} + +void +buffer_get_bignum2(Buffer *buffer, BIGNUM *value) +{ + if (buffer_get_bignum2_ret(buffer, value) == -1) + fatal("buffer_get_bignum2: buffer error"); +} diff --git a/openssh/buffer.c b/openssh/buffer.c index 83e3881..705155c 100644 --- a/openssh/buffer.c +++ b/openssh/buffer.c @@ -1,3 +1,4 @@ +/* $OpenBSD: buffer.c,v 1.31 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,12 +13,23 @@ */ #include "includes.h" -RCSID("$OpenBSD: buffer.c,v 1.23 2005/03/14 11:46:56 markus Exp $"); + +#include + +#include +#include +#include #include "xmalloc.h" #include "buffer.h" #include "log.h" +#define BUFFER_MAX_CHUNK 0x100000 +#define BUFFER_MAX_LEN 0xa00000 +/* try increasing to 256k in hpnxfers */ +#define BUFFER_ALLOCSZ 0x008000 /* 32k */ +#define BUFFER_ALLOCSZ_HPN 0x040000 /* 256k */ + /* Initializes the buffer structure. */ void @@ -66,6 +78,23 @@ buffer_append(Buffer *buffer, const void *data, u_int len) memcpy(p, data, len); } +static int +buffer_compact(Buffer *buffer) +{ + /* + * If the buffer is quite empty, but all data is at the end, move the + * data to the beginning. + */ + if (buffer->offset > MIN(buffer->alloc, BUFFER_MAX_CHUNK)) { + memmove(buffer->buf, buffer->buf + buffer->offset, + buffer->end - buffer->offset); + buffer->end -= buffer->offset; + buffer->offset = 0; + return (1); + } + return (0); +} + /* * Appends space to the buffer, expanding the buffer if necessary. This does * not actually copy the data into the buffer, but instead returns a pointer @@ -76,6 +105,8 @@ void * buffer_append_space(Buffer *buffer, u_int len) { u_int newlen; + u_int buf_max; + u_int buf_alloc_sz; void *p; if (len > BUFFER_MAX_CHUNK) @@ -93,29 +124,57 @@ restart: buffer->end += len; return p; } - /* - * If the buffer is quite empty, but all data is at the end, move the - * data to the beginning and retry. - */ - if (buffer->offset > MIN(buffer->alloc, BUFFER_MAX_CHUNK)) { - memmove(buffer->buf, buffer->buf + buffer->offset, - buffer->end - buffer->offset); - buffer->end -= buffer->offset; - buffer->offset = 0; + + /* Compact data back to the start of the buffer if necessary */ + if (buffer_compact(buffer)) goto restart; - } + + /* if hpn is disabled use the smaller buffer size */ + buf_max = BUFFER_MAX_LEN_HPN; + buf_alloc_sz = BUFFER_ALLOCSZ_HPN; + /* Increase the size of the buffer and retry. */ + newlen = roundup(buffer->alloc + len, buf_alloc_sz); - newlen = buffer->alloc + len + 32768; - if (newlen > BUFFER_MAX_HPN_LEN) + + if (newlen > buf_max) fatal("buffer_append_space: alloc %u not supported", newlen); - buffer->buf = xrealloc(buffer->buf, newlen); + buffer->buf = xrealloc(buffer->buf, 1, newlen); buffer->alloc = newlen; goto restart; /* NOTREACHED */ } +/* + * Check whether an allocation of 'len' will fit in the buffer + * This must follow the same math as buffer_append_space + */ +int +buffer_check_alloc(Buffer *buffer, u_int len) +{ + u_int buf_max; + u_int buf_alloc_sz; + + if (buffer->offset == buffer->end) { + buffer->offset = 0; + buffer->end = 0; + } + restart: + if (buffer->end + len < buffer->alloc) + return (1); + if (buffer_compact(buffer)) + goto restart; + + /* if hpn is disabled use the smaller buffer size */ + buf_max = BUFFER_MAX_LEN_HPN; + buf_alloc_sz = BUFFER_ALLOCSZ_HPN; + + if (roundup(buffer->alloc + len, buf_alloc_sz) <= buf_max) + return (1); + return (0); +} + /* Returns the number of bytes of data in the buffer. */ u_int diff --git a/openssh/buffer.h b/openssh/buffer.h index 62e43d1..c062bc0 100644 --- a/openssh/buffer.h +++ b/openssh/buffer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.h,v 1.13 2005/03/14 11:46:56 markus Exp $ */ +/* $OpenBSD: buffer.h,v 1.16 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -15,6 +15,7 @@ #ifndef BUFFER_H #define BUFFER_H +#define BUFFER_MAX_LEN_HPN 0x4000000 /* 64MB */ typedef struct { u_char *buf; /* Buffer for data. */ @@ -23,16 +24,6 @@ typedef struct { u_int end; /* Offset of last byte containing data. */ } Buffer; -#define BUFFER_MAX_CHUNK 0x100000 /*1MB*/ -#define BUFFER_MAX_LEN 0xa00000 /*10MB*/ - -/* this value for BUFFER_MAX_HPN_LEN is */ -/* still undersized for the faster networks */ -/* it might make sense to have yet another */ -/* MAX_LEN for 10+GB networks. Something closer to */ -/* 128MB or 192MB -cjr*/ -#define BUFFER_MAX_HPN_LEN 0x2000000 /*32MB*/ - void buffer_init(Buffer *); void buffer_clear(Buffer *); void buffer_free(Buffer *); @@ -43,6 +34,8 @@ void *buffer_ptr(Buffer *); void buffer_append(Buffer *, const void *, u_int); void *buffer_append_space(Buffer *, u_int); +int buffer_check_alloc(Buffer *, u_int); + void buffer_get(Buffer *, void *, u_int); void buffer_consume(Buffer *, u_int); @@ -54,4 +47,40 @@ int buffer_get_ret(Buffer *, void *, u_int); int buffer_consume_ret(Buffer *, u_int); int buffer_consume_end_ret(Buffer *, u_int); +#include + +void buffer_put_bignum(Buffer *, const BIGNUM *); +void buffer_put_bignum2(Buffer *, const BIGNUM *); +void buffer_get_bignum(Buffer *, BIGNUM *); +void buffer_get_bignum2(Buffer *, BIGNUM *); + +u_short buffer_get_short(Buffer *); +void buffer_put_short(Buffer *, u_short); + +u_int buffer_get_int(Buffer *); +void buffer_put_int(Buffer *, u_int); + +u_int64_t buffer_get_int64(Buffer *); +void buffer_put_int64(Buffer *, u_int64_t); + +int buffer_get_char(Buffer *); +void buffer_put_char(Buffer *, int); + +void *buffer_get_string(Buffer *, u_int *); +void buffer_put_string(Buffer *, const void *, u_int); +void buffer_put_cstring(Buffer *, const char *); + +#define buffer_skip_string(b) \ + do { u_int l = buffer_get_int(b); buffer_consume(b, l); } while (0) + +int buffer_put_bignum_ret(Buffer *, const BIGNUM *); +int buffer_get_bignum_ret(Buffer *, BIGNUM *); +int buffer_put_bignum2_ret(Buffer *, const BIGNUM *); +int buffer_get_bignum2_ret(Buffer *, BIGNUM *); +int buffer_get_short_ret(u_short *, Buffer *); +int buffer_get_int_ret(u_int *, Buffer *); +int buffer_get_int64_ret(u_int64_t *, Buffer *); +void *buffer_get_string_ret(Buffer *, u_int *); +int buffer_get_char_ret(char *, Buffer *); + #endif /* BUFFER_H */ diff --git a/openssh/buildpkg.sh.in b/openssh/buildpkg.sh.in index cb9eb30..17349f7 100644 --- a/openssh/buildpkg.sh.in +++ b/openssh/buildpkg.sh.in @@ -24,6 +24,7 @@ PKGNAME=OpenSSH # revisions within the same version (REV=a) #REV= SYSVINIT_NAME=opensshd +AWK=${AWK:="nawk"} MAKE=${MAKE:="make"} SSHDUID=67 # Default privsep uid SSHDGID=67 # Default privsep gid @@ -35,7 +36,7 @@ SSHDGID=67 # Default privsep gid SYSVINITSTART=S98 SYSVINITSTOPT=K30 # We will source these if they exist -POST_MAKE_INSTALL_FIXES=./pkg_post_make_install_fixes.sh +POST_MAKE_INSTALL_FIXES=./pkg-post-make-install-fixes.sh POST_PROTOTYPE_EDITS=./pkg-post-prototype-edit.sh # We'll be one level deeper looking for these PKG_PREINSTALL_LOCAL=../pkg-preinstall.local @@ -46,6 +47,8 @@ PKG_REQUEST_LOCAL=../pkg-request.local # end of sourced files # OPENSSHD=opensshd.init +OPENSSH_MANIFEST=openssh.xml +OPENSSH_FMRI=svc:/site/openssh:default PATH_GROUPADD_PROG=@PATH_GROUPADD_PROG@ PATH_USERADD_PROG=@PATH_USERADD_PROG@ @@ -60,6 +63,10 @@ SYSTEM_DIR="/etc \ /etc/rc1.d \ /etc/rc2.d \ /etc/opt \ +/lib \ +/lib/svc \ +/lib/svc/method \ +/lib/svc/method/site \ /opt \ /opt/bin \ /usr \ @@ -82,6 +89,9 @@ SYSTEM_DIR="/etc \ /var \ /var/opt \ /var/run \ +/var/svc \ +/var/svc/manifest \ +/var/svc/manifest/site \ /var/tmp \ /tmp" @@ -119,6 +129,12 @@ do eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2` done +## Are we using Solaris' SMF? +DO_SMF=0 +if egrep "^#define USE_SOLARIS_PROCESS_CONTRACTS" config.h > /dev/null 2>&1 +then + DO_SMF=1 +fi ## Collect value of privsep user for confvar in SSH_PRIVSEP_USER @@ -139,15 +155,22 @@ ARCH=`uname -m` DEF_MSG="\n" OS_VER=`uname -v` SCRIPT_SHELL=/sbin/sh +UNAME_R=`uname -r` UNAME_S=`uname -s` case ${UNAME_S} in SunOS) UNAME_S=Solaris + OS_VER=${UNAME_R} ARCH=`uname -p` RCS_D=yes DEF_MSG="(default: n)" ;; - SCO_SV) UNAME_S=OpenServer + SCO_SV) case ${UNAME_R} in + 3.2) UNAME_S=OpenServer5 OS_VER=`uname -X | grep Release | sed -e 's/^Rel.*3.2v//'` + ;; + 5) UNAME_S=OpenServer6 + ;; + esac SCRIPT_SHELL=/bin/sh RC1_D=no DEF_MSG="(default: n)" @@ -168,10 +191,25 @@ then fi ## Setup our run level stuff while we are at it. -mkdir -p $FAKE_ROOT${TEST_DIR}/etc/init.d +if [ $DO_SMF -eq 1 ] +then + # For Solaris' SMF, /lib/svc/method/site is the preferred place + # for start/stop scripts that aren't supplied with the OS, and + # similarly /var/svc/manifest/site for manifests. + mkdir -p $FAKE_ROOT${TEST_DIR}/lib/svc/method/site + mkdir -p $FAKE_ROOT${TEST_DIR}/var/svc/manifest/site + + cp ${OPENSSHD} $FAKE_ROOT${TEST_DIR}/lib/svc/method/site/${SYSVINIT_NAME} + chmod 744 $FAKE_ROOT${TEST_DIR}/lib/svc/method/site/${SYSVINIT_NAME} -cp ${OPENSSHD} $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} -chmod 744 $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} + cp ${OPENSSH_MANIFEST} $FAKE_ROOT${TEST_DIR}/var/svc/manifest/site + chmod 644 $FAKE_ROOT${TEST_DIR}/var/svc/manifest/site/${OPENSSH_MANIFEST} +else + mkdir -p $FAKE_ROOT${TEST_DIR}/etc/init.d + + cp ${OPENSSHD} $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} + chmod 744 $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} +fi [ "${PERMIT_ROOT_LOGIN}" = no ] && \ perl -p -i -e "s/#PermitRootLogin yes/PermitRootLogin no/" \ @@ -221,15 +259,22 @@ touch depend ## Build space file echo "Building space file..." -cat > space << _EOF -# extra space required by start/stop links added by installf in postinstall +if [ $DO_SMF -eq 1 ] +then + # XXX Is this necessary? If not, remove space line from mk-proto.awk. + touch space +else + cat > space << _EOF +# extra space required by start/stop links added by installf +# in postinstall $TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1 $TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME} 0 1 _EOF -[ "$RC1_D" = no ] || \ -echo "$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space -[ "$RCS_D" = yes ] && \ -echo "$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space + [ "$RC1_D" = no ] || \ + echo "$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space + [ "$RCS_D" = yes ] && \ + echo "$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space +fi ## Build preinstall file echo "Building preinstall file..." @@ -243,7 +288,16 @@ _EOF cat >> preinstall << _EOF # -[ "\${PRE_INS_STOP}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop +if [ "\${PRE_INS_STOP}" = "yes" ] +then + if [ $DO_SMF -eq 1 ] + then + svcadm disable $OPENSSH_FMRI + else + ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop + fi +fi + exit 0 _EOF @@ -265,28 +319,41 @@ cat > postinstall << _EOF } # make rc?.d dirs only if we are doing a test install -[ -n "${TEST_DIR}" ] && { +[ -n "${TEST_DIR}" ] && [ $DO_SMF -ne 1 ] && { [ "$RCS_D" = yes ] && mkdir -p ${TEST_DIR}/etc/rcS.d mkdir -p ${TEST_DIR}/etc/rc0.d [ "$RC1_D" = no ] || mkdir -p ${TEST_DIR}/etc/rc1.d mkdir -p ${TEST_DIR}/etc/rc2.d } -if [ "\${USE_SYM_LINKS}" = yes ] +if [ $DO_SMF -eq 1 ] then - [ "$RCS_D" = yes ] && \ -installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s - installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s - [ "$RC1_D" = no ] || \ - installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s - installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s + # Delete the existing service, if it exists, then import the + # new one. + if svcs $OPENSSH_FMRI > /dev/null 2>&1 + then + svccfg delete -f $OPENSSH_FMRI + fi + # NOTE, if manifest enables sshd by default, this will actually + # start the daemon, which may not be what the user wants. + svccfg import ${TEST_DIR}/var/svc/manifest/site/$OPENSSH_MANIFEST else - [ "$RCS_D" = yes ] && \ -installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l - installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l - [ "$RC1_D" = no ] || \ - installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l - installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l + if [ "\${USE_SYM_LINKS}" = yes ] + then + [ "$RCS_D" = yes ] && \ + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s + [ "$RC1_D" = no ] || \ + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s + else + [ "$RCS_D" = yes ] && \ + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l + [ "$RC1_D" = no ] || \ + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l + installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l + fi fi # If piddir doesn't exist we add it. (Ie. --with-pid-dir=/var/opt/ssh) @@ -311,14 +378,7 @@ then chroot=echo fi -if egrep '^[ \t]*UsePrivilegeSeparation[ \t]+no' \${PKG_INSTALL_ROOT}/$sysconfdir/sshd_config >/dev/null -then - echo "UsePrivilegeSeparation disabled in config, not creating PrivSep user" - echo "or group." -else - echo "UsePrivilegeSeparation enabled in config (or defaulting to on)." - - # user required? + echo "PrivilegeSeparation user always required." if cut -f1 -d: \${PKG_INSTALL_ROOT}/etc/passwd | egrep '^'$SSH_PRIVSEP_USER'\$' >/dev/null then echo "PrivSep user $SSH_PRIVSEP_USER already exists." @@ -363,9 +423,18 @@ else \$chroot ${PATH_USERADD_PROG} -c 'SSHD PrivSep User' -s /bin/false -g $SSH_PRIVSEP_USER \$sshduid $SSH_PRIVSEP_USER \$chroot ${PATH_PASSWD_PROG} -l $SSH_PRIVSEP_USER } -fi -[ "\${POST_INS_START}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} start +if [ "\${POST_INS_START}" = "yes" ] +then + if [ $DO_SMF -eq 1 ] + then + # See svccfg import note above. The service may already + # be started. + svcadm enable $OPENSSH_FMRI + else + ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} start + fi +fi exit 0 _EOF @@ -374,7 +443,12 @@ echo "Building preremove file..." cat > preremove << _EOF #! ${SCRIPT_SHELL} # -${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop +if [ $DO_SMF -eq 1 ] +then + svcadm disable $OPENSSH_FMRI +else + ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop +fi _EOF # local preremove changes here @@ -389,6 +463,13 @@ echo "Building postremove file..." cat > postremove << _EOF #! ${SCRIPT_SHELL} # +if [ $DO_SMF -eq 1 ] +then + if svcs $OPENSSH_FMRI > /dev/null 2>&1 + then + svccfg delete -f $OPENSSH_FMRI + fi +fi _EOF # local postremove changes here @@ -408,7 +489,7 @@ _EOF [ -x /usr/bin/ckyorn ] || cat >> request << _EOF ckyorn() { -# for some strange reason OpenServer has no ckyorn +# for some strange reason OpenServer5 has no ckyorn # We build a striped down version here DEFAULT=n @@ -454,7 +535,45 @@ done _EOF -cat >> request << _EOF +if [ $DO_SMF -eq 1 ] +then + # This could get hairy, as the running sshd may not be under SMF. + # We'll assume an earlier version of OpenSSH started via SMF. + cat >> request << _EOF +PRE_INS_STOP=no +POST_INS_START=no +# determine if should restart the daemon +if [ -s ${piddir}/sshd.pid ] && \ + /usr/bin/svcs $OPENSSH_FMRI 2>&1 | egrep "^online" > /dev/null 2>&1 +then + ans=\`ckyorn -d n \ +-p "Should the running sshd daemon be restarted? ${DEF_MSG}"\` || exit \$? + case \$ans in + [y,Y]*) PRE_INS_STOP=yes + POST_INS_START=yes + ;; + esac + +else + +# determine if we should start sshd + ans=\`ckyorn -d n \ +-p "Start the sshd daemon after installing this package? ${DEF_MSG}"\` || exit \$? + case \$ans in + [y,Y]*) POST_INS_START=yes ;; + esac +fi + +# make parameters available to installation service, +# and so to any other packaging scripts +cat >\$1 <> request << _EOF USE_SYM_LINKS=no PRE_INS_STOP=no POST_INS_START=no @@ -495,6 +614,7 @@ POST_INS_START='\$POST_INS_START' ! _EOF +fi # local request changes here [ -s "${PKG_REQUEST_LOCAL}" ] && . ${PKG_REQUEST_LOCAL} @@ -526,7 +646,7 @@ cat >mk-proto.awk << _EOF _EOF find . | egrep -v "prototype|pkginfo|mk-proto.awk" | sort | \ - pkgproto $PROTO_ARGS | nawk -f mk-proto.awk > prototype + pkgproto $PROTO_ARGS | ${AWK} -f mk-proto.awk > prototype # /usr/local is a symlink on some systems [ "${USR_LOCAL_IS_SYMLINK}" = yes ] && { diff --git a/openssh/canohost.c b/openssh/canohost.c index 3e6f482..99da72d 100644 --- a/openssh/canohost.c +++ b/openssh/canohost.c @@ -1,3 +1,4 @@ +/* $OpenBSD: canohost.c,v 1.61 2006/08/03 03:34:41 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,10 +13,24 @@ */ #include "includes.h" -RCSID("$OpenBSD: canohost.c,v 1.48 2005/12/28 22:46:06 stevesk Exp $"); -#include "packet.h" +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + #include "xmalloc.h" +#include "packet.h" #include "log.h" #include "canohost.h" @@ -43,6 +58,9 @@ get_remote_hostname(int sock, int use_dns) cleanup_exit(255); } + if (from.ss_family == AF_INET) + check_ip_options(sock, ntop); + ipv64_normalise_mapped(&from, &fromlen); if (from.ss_family == AF_INET6) @@ -52,9 +70,6 @@ get_remote_hostname(int sock, int use_dns) NULL, 0, NI_NUMERICHOST) != 0) fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed"); - if (from.ss_family == AF_INET) - check_ip_options(sock, ntop); - if (!use_dns) return xstrdup(ntop); @@ -87,7 +102,7 @@ get_remote_hostname(int sock, int use_dns) */ for (i = 0; name[i]; i++) if (isupper(name[i])) - name[i] = tolower(name[i]); + name[i] = (char)tolower(name[i]); /* * Map it back to an IP address and check that the given * address actually is an address of this host. This is @@ -102,7 +117,7 @@ get_remote_hostname(int sock, int use_dns) hints.ai_socktype = SOCK_STREAM; if (getaddrinfo(name, NULL, &hints, &aitop) != 0) { logit("reverse mapping checking getaddrinfo for %.700s " - "failed - POSSIBLE BREAK-IN ATTEMPT!", name); + "[%s] failed - POSSIBLE BREAK-IN ATTEMPT!", name, ntop); return xstrdup(ntop); } /* Look for the address from the list of addresses. */ diff --git a/openssh/canohost.h b/openssh/canohost.h index 937abd2..0a293e7 100644 --- a/openssh/canohost.h +++ b/openssh/canohost.h @@ -1,4 +1,4 @@ -/* $OpenBSD: canohost.h,v 1.8 2001/06/26 17:27:23 markus Exp $ */ +/* $OpenBSD: canohost.h,v 1.9 2006/03/25 22:22:42 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/channels.c b/openssh/channels.c index 9311643..639e69c 100644 --- a/openssh/channels.c +++ b/openssh/channels.c @@ -1,3 +1,4 @@ +/* $OpenBSD: channels.c,v 1.266 2006/08/29 10:40:18 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -39,22 +40,41 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.232 2006/01/30 12:22:22 reyk Exp $"); +#include +#include +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" #include "ssh2.h" #include "packet.h" -#include "xmalloc.h" #include "log.h" #include "misc.h" +#include "buffer.h" #include "channels.h" #include "compat.h" #include "canohost.h" #include "key.h" #include "authfd.h" #include "pathnames.h" -#include "bufaux.h" /* -- channel core */ @@ -92,11 +112,18 @@ typedef struct { u_short listen_port; /* Remote side should listen port number. */ } ForwardPermission; -/* List of all permitted host/port pairs to connect. */ +/* List of all permitted host/port pairs to connect by the user. */ static ForwardPermission permitted_opens[SSH_MAX_FORWARDS_PER_DIRECTION]; -/* Number of permitted host/port pairs in the array. */ +/* List of all permitted host/port pairs to connect by the admin. */ +static ForwardPermission permitted_adm_opens[SSH_MAX_FORWARDS_PER_DIRECTION]; + +/* Number of permitted host/port pairs in the array permitted by the user. */ static int num_permitted_opens = 0; + +/* Number of permitted host/port pair in the array permitted by the admin. */ +static int num_adm_permitted_opens = 0; + /* * If this is true, all opens are permitted. This is the case on the server * on which we have to trust the client anyway, and the user could do @@ -124,7 +151,7 @@ static u_int x11_saved_data_len = 0; * Fake X11 authentication data. This is what the server will be sending us; * we should replace any occurrences of this by the real data. */ -static char *x11_fake_data = NULL; +static u_char *x11_fake_data = NULL; static u_int x11_fake_data_len; @@ -169,7 +196,7 @@ channel_lookup(int id) if ((c = channel_by_id(id)) == NULL) return (NULL); - switch(c->type) { + switch (c->type) { case SSH_CHANNEL_X11_OPEN: case SSH_CHANNEL_LARVAL: case SSH_CHANNEL_CONNECTING: @@ -179,7 +206,6 @@ channel_lookup(int id) case SSH_CHANNEL_INPUT_DRAINING: case SSH_CHANNEL_OUTPUT_DRAINING: return (c); - break; } logit("Non-public channel %d, type %d.", id, c->type); return (NULL); @@ -189,7 +215,6 @@ channel_lookup(int id) * Register filedescriptors for a channel, used when allocating a channel or * when the channel consumer/producer is ready, e.g. shell exec'd */ - static void channel_register_fds(Channel *c, int rfd, int wfd, int efd, int extusage, int nonblock) @@ -236,7 +261,6 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, * Allocate a new channel object and set its type and socket. This will cause * remote_name to be freed. */ - Channel * channel_new(char *ctype, int type, int rfd, int wfd, int efd, u_int window, u_int maxpack, int extusage, char *remote_name, int nonblock) @@ -248,7 +272,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd, /* Do initial allocation if this is the first call. */ if (channels_alloc == 0) { channels_alloc = 10; - channels = xmalloc(channels_alloc * sizeof(Channel *)); + channels = xcalloc(channels_alloc, sizeof(Channel *)); for (i = 0; i < channels_alloc; i++) channels[i] = NULL; } @@ -265,16 +289,15 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd, if (channels_alloc > 10000) fatal("channel_new: internal error: channels_alloc %d " "too big.", channels_alloc); - channels = xrealloc(channels, - (channels_alloc + 10) * sizeof(Channel *)); + channels = xrealloc(channels, channels_alloc + 10, + sizeof(Channel *)); channels_alloc += 10; debug2("channel: expanding %d", channels_alloc); for (i = found; i < channels_alloc; i++) channels[i] = NULL; } /* Initialize and return new channel. */ - c = channels[found] = xmalloc(sizeof(Channel)); - memset(c, 0, sizeof(Channel)); + c = channels[found] = xcalloc(1, sizeof(Channel)); buffer_init(&c->input); buffer_init(&c->output); buffer_init(&c->extended); @@ -339,7 +362,6 @@ channel_close_fd(int *fdp) } /* Close all channel fd/socket. */ - static void channel_close_fds(Channel *c) { @@ -354,7 +376,6 @@ channel_close_fds(Channel *c) } /* Free the channel and close its fd/socket. */ - void channel_free(Channel *c) { @@ -401,7 +422,6 @@ channel_free_all(void) * Closes the sockets/fds of all channels. This is used to close extra file * descriptors after a fork. */ - void channel_close_all(void) { @@ -415,7 +435,6 @@ channel_close_all(void) /* * Stop listening to channels. */ - void channel_stop_listening(void) { @@ -442,7 +461,6 @@ channel_stop_listening(void) * Returns true if no channel has too much buffered data, and false if one or * more channel is overfull. */ - int channel_not_very_much_buffered_data(void) { @@ -472,7 +490,6 @@ channel_not_very_much_buffered_data(void) } /* Returns true if any channel is still open. */ - int channel_still_open(void) { @@ -515,7 +532,6 @@ channel_still_open(void) } /* Returns the id of an open channel suitable for keepaliving */ - int channel_find_open(void) { @@ -560,7 +576,6 @@ channel_find_open(void) * suitable for sending to the client. The message contains crlf pairs for * newlines. */ - char * channel_open_message(void) { @@ -645,6 +660,7 @@ channel_request_start(int id, char *service, int wantconfirm) packet_put_cstring(service); packet_put_char(wantconfirm); } + void channel_register_confirm(int id, channel_callback_fn *fn, void *ctx) { @@ -657,6 +673,7 @@ channel_register_confirm(int id, channel_callback_fn *fn, void *ctx) c->confirm = fn; c->confirm_ctx = ctx; } + void channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) { @@ -669,6 +686,7 @@ channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) c->detach_user = fn; c->detach_close = do_close; } + void channel_cancel_cleanup(int id) { @@ -681,6 +699,7 @@ channel_cancel_cleanup(int id) c->detach_user = NULL; c->detach_close = 0; } + void channel_register_filter(int id, channel_infilter_fn *ifn, channel_outfilter_fn *ofn) @@ -720,25 +739,27 @@ channel_set_fds(int id, int rfd, int wfd, int efd, * 'channel_post*': perform any appropriate operations for channels which * have events pending. */ -typedef void chan_fn(Channel *c, fd_set * readset, fd_set * writeset); +typedef void chan_fn(Channel *c, fd_set *readset, fd_set *writeset); chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; +/* ARGSUSED */ static void -channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_listener(Channel *c, fd_set *readset, fd_set *writeset) { FD_SET(c->sock, readset); } +/* ARGSUSED */ static void -channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_connecting(Channel *c, fd_set *readset, fd_set *writeset) { debug3("channel %d: waiting for connection", c->self); FD_SET(c->sock, writeset); } static void -channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_open_13(Channel *c, fd_set *readset, fd_set *writeset) { if (buffer_len(&c->input) < packet_get_maxsize()) FD_SET(c->sock, readset); @@ -749,33 +770,35 @@ channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) int channel_tcpwinsz () { u_int32_t tcpwinsz = 0; socklen_t optsz = sizeof(tcpwinsz); - int ret = -1; + int ret = -1; if(!packet_connection_is_on_socket()) - return(131072); - ret = getsockopt(packet_get_connection_in(), - SOL_SOCKET, SO_RCVBUF, &tcpwinsz, &optsz); - if ((ret == 0) && tcpwinsz > BUFFER_MAX_HPN_LEN) - tcpwinsz = BUFFER_MAX_HPN_LEN; - debug2("tcpwinsz: %d for connection: %d", tcpwinsz, packet_get_connection_in()); + return(131072); + ret = getsockopt(packet_get_connection_in(), + SOL_SOCKET, SO_RCVBUF, &tcpwinsz, &optsz); + if ((ret == 0) && tcpwinsz > BUFFER_MAX_LEN_HPN) + tcpwinsz = BUFFER_MAX_LEN_HPN; + debug2("tcpwinsz: %d for connection: %d", tcpwinsz, + packet_get_connection_in()); return(tcpwinsz); } static void -channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_open(Channel *c, fd_set *readset, fd_set *writeset) { u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); - /* check buffer limits */ + /* check buffer limits */ if (!c->tcpwinsz) - c->tcpwinsz = channel_tcpwinsz(); + c->tcpwinsz = channel_tcpwinsz(); if (c->dynamic_window > 0) - c->tcpwinsz = channel_tcpwinsz(); - + c->tcpwinsz = channel_tcpwinsz(); + limit = MIN(limit, 2 * c->tcpwinsz); - + if (c->istate == CHAN_INPUT_OPEN && limit > 0 && - buffer_len(&c->input) < limit) + buffer_len(&c->input) < limit && + buffer_check_alloc(&c->input, CHAN_RBUF)) FD_SET(c->rfd, readset); if (c->ostate == CHAN_OUTPUT_OPEN || c->ostate == CHAN_OUTPUT_WAIT_DRAIN) { @@ -805,8 +828,9 @@ channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) FD_SET(c->ctl_fd, readset); } +/* ARGSUSED */ static void -channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_input_draining(Channel *c, fd_set *readset, fd_set *writeset) { if (buffer_len(&c->input) == 0) { packet_start(SSH_MSG_CHANNEL_CLOSE); @@ -817,8 +841,9 @@ channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) } } +/* ARGSUSED */ static void -channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_output_draining(Channel *c, fd_set *readset, fd_set *writeset) { if (buffer_len(&c->output) == 0) chan_mark_dead(c); @@ -894,7 +919,7 @@ x11_open_helper(Buffer *b) } static void -channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_x11_open_13(Channel *c, fd_set *readset, fd_set *writeset) { int ret = x11_open_helper(&c->output); @@ -920,7 +945,7 @@ channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) } static void -channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_x11_open(Channel *c, fd_set *readset, fd_set *writeset) { int ret = x11_open_helper(&c->output); @@ -946,8 +971,9 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) } /* try to decode a socks4 header */ +/* ARGSUSED */ static int -channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) +channel_decode_socks4(Channel *c, fd_set *readset, fd_set *writeset) { char *p, *host; u_int len, have, i, found; @@ -1011,7 +1037,7 @@ channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) s4_rsp.command = 90; /* cd: req granted */ s4_rsp.dest_port = 0; /* ignored */ s4_rsp.dest_addr.s_addr = INADDR_ANY; /* ignored */ - buffer_append(&c->output, (char *)&s4_rsp, sizeof(s4_rsp)); + buffer_append(&c->output, &s4_rsp, sizeof(s4_rsp)); return 1; } @@ -1024,8 +1050,9 @@ channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) #define SSH_SOCKS5_CONNECT 0x01 #define SSH_SOCKS5_SUCCESS 0x00 +/* ARGSUSED */ static int -channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) +channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset) { struct { u_int8_t version; @@ -1035,7 +1062,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) } s5_req, s5_rsp; u_int16_t dest_port; u_char *p, dest_addr[255+1]; - u_int have, i, found, nmethods, addrlen, af; + u_int have, need, i, found, nmethods, addrlen, af; debug2("channel %d: decode socks5", c->self); p = buffer_ptr(&c->input); @@ -1051,7 +1078,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) return 0; /* look for method: "NO AUTHENTICATION REQUIRED" */ for (found = 0, i = 2 ; i < nmethods + 2; i++) { - if (p[i] == SSH_SOCKS5_NOAUTH ) { + if (p[i] == SSH_SOCKS5_NOAUTH) { found = 1; break; } @@ -1072,7 +1099,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) debug2("channel %d: socks5 post auth", c->self); if (have < sizeof(s5_req)+1) return 0; /* need more */ - memcpy((char *)&s5_req, p, sizeof(s5_req)); + memcpy(&s5_req, p, sizeof(s5_req)); if (s5_req.version != 0x05 || s5_req.command != SSH_SOCKS5_CONNECT || s5_req.reserved != 0x00) { @@ -1096,7 +1123,10 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) debug2("channel %d: bad socks5 atyp %d", c->self, s5_req.atyp); return -1; } - if (have < 4 + addrlen + 2) + need = sizeof(s5_req) + addrlen + 2; + if (s5_req.atyp == SSH_SOCKS5_DOMAIN) + need++; + if (have < need) return 0; buffer_consume(&c->input, sizeof(s5_req)); if (s5_req.atyp == SSH_SOCKS5_DOMAIN) @@ -1120,15 +1150,15 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) ((struct in_addr *)&dest_addr)->s_addr = INADDR_ANY; dest_port = 0; /* ignored */ - buffer_append(&c->output, (char *)&s5_rsp, sizeof(s5_rsp)); - buffer_append(&c->output, (char *)&dest_addr, sizeof(struct in_addr)); - buffer_append(&c->output, (char *)&dest_port, sizeof(dest_port)); + buffer_append(&c->output, &s5_rsp, sizeof(s5_rsp)); + buffer_append(&c->output, &dest_addr, sizeof(struct in_addr)); + buffer_append(&c->output, &dest_port, sizeof(dest_port)); return 1; } /* dynamic port forwarding */ static void -channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) +channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset) { u_char *p; u_int have; @@ -1171,8 +1201,9 @@ channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) } /* This is our fake X11 server socket. */ +/* ARGSUSED */ static void -channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) +channel_post_x11_listener(Channel *c, fd_set *readset, fd_set *writeset) { Channel *nc; struct sockaddr addr; @@ -1296,8 +1327,9 @@ channel_set_reuseaddr(int fd) /* * This socket is listening for connections to a forwarded TCP/IP port. */ +/* ARGSUSED */ static void -channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) +channel_post_port_listener(Channel *c, fd_set *readset, fd_set *writeset) { Channel *nc; struct sockaddr addr; @@ -1353,8 +1385,9 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) * This is the authentication agent socket listening for connections from * clients. */ +/* ARGSUSED */ static void -channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) +channel_post_auth_listener(Channel *c, fd_set *readset, fd_set *writeset) { Channel *nc; int newsock; @@ -1386,8 +1419,9 @@ channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) } } +/* ARGSUSED */ static void -channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) +channel_post_connecting(Channel *c, fd_set *readset, fd_set *writeset) { int err = 0; socklen_t sz = sizeof(err); @@ -1432,18 +1466,25 @@ channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) } } +/* ARGSUSED */ static int -channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) +channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset) { char buf[CHAN_RBUF]; int len; if (c->rfd != -1 && FD_ISSET(c->rfd, readset)) { + errno = 0; len = read(c->rfd, buf, sizeof(buf)); if (len < 0 && (errno == EINTR || errno == EAGAIN)) return 1; +#ifndef PTY_ZEROREAD if (len <= 0) { +#else + if ((!c->isatty && len <= 0) || + (c->isatty && (len < 0 || (len == 0 && errno != 0)))) { +#endif debug2("channel %d: read<=0 rfd %d len %d", c->self, c->rfd, len); if (c->type != SSH_CHANNEL_OPEN) { @@ -1472,8 +1513,10 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) } return 1; } + +/* ARGSUSED */ static int -channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) +channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset) { struct termios tio; u_char *data = NULL, *buf; @@ -1559,8 +1602,9 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) } return 1; } + static int -channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) +channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset) { char buf[CHAN_RBUF]; int len; @@ -1602,8 +1646,10 @@ channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) } return 1; } + +/* ARGSUSED */ static int -channel_handle_ctl(Channel *c, fd_set * readset, fd_set * writeset) +channel_handle_ctl(Channel *c, fd_set *readset, fd_set *writeset) { char buf[16]; int len; @@ -1629,6 +1675,7 @@ channel_handle_ctl(Channel *c, fd_set * readset, fd_set * writeset) } return 1; } + static int channel_check_window(Channel *c) { @@ -1656,7 +1703,7 @@ channel_check_window(Channel *c) } static void -channel_post_open(Channel *c, fd_set * readset, fd_set * writeset) +channel_post_open(Channel *c, fd_set *readset, fd_set *writeset) { if (c->delayed) return; @@ -1669,8 +1716,9 @@ channel_post_open(Channel *c, fd_set * readset, fd_set * writeset) channel_check_window(c); } +/* ARGSUSED */ static void -channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) +channel_post_output_drain_13(Channel *c, fd_set *readset, fd_set *writeset) { int len; @@ -1787,7 +1835,7 @@ channel_garbage_collect(Channel *c) } static void -channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) +channel_handler(chan_fn *ftab[], fd_set *readset, fd_set *writeset) { static int did_init = 0; u_int i; @@ -1815,15 +1863,20 @@ void channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp, u_int *nallocp, int rekeying) { - u_int n, sz; + u_int n, sz, nfdset; n = MAX(*maxfdp, channel_max_fd); - sz = howmany(n+1, NFDBITS) * sizeof(fd_mask); + nfdset = howmany(n+1, NFDBITS); + /* Explicitly test here, because xrealloc isn't always called */ + if (nfdset && SIZE_T_MAX / nfdset < sizeof(fd_mask)) + fatal("channel_prepare_select: max_fd (%d) is too large", n); + sz = nfdset * sizeof(fd_mask); + /* perhaps check sz < nalloc/2 and shrink? */ if (*readsetp == NULL || sz > *nallocp) { - *readsetp = xrealloc(*readsetp, sz); - *writesetp = xrealloc(*writesetp, sz); + *readsetp = xrealloc(*readsetp, nfdset, sizeof(fd_mask)); + *writesetp = xrealloc(*writesetp, nfdset, sizeof(fd_mask)); *nallocp = sz; } *maxfdp = n; @@ -1839,14 +1892,13 @@ channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp, * events pending. */ void -channel_after_select(fd_set * readset, fd_set * writeset) +channel_after_select(fd_set *readset, fd_set *writeset) { channel_handler(channel_post, readset, writeset); } /* If there is data to send to the connection, enqueue some of it now. */ - void channel_output_poll(void) { @@ -1967,6 +2019,7 @@ channel_output_poll(void) /* -- protocol input */ +/* ARGSUSED */ void channel_input_data(int type, u_int32_t seq, void *ctxt) { @@ -2026,6 +2079,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt) xfree(data); } +/* ARGSUSED */ void channel_input_extended_data(int type, u_int32_t seq, void *ctxt) { @@ -2072,6 +2126,7 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt) xfree(data); } +/* ARGSUSED */ void channel_input_ieof(int type, u_int32_t seq, void *ctxt) { @@ -2095,6 +2150,7 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt) } +/* ARGSUSED */ void channel_input_close(int type, u_int32_t seq, void *ctxt) { @@ -2133,6 +2189,7 @@ channel_input_close(int type, u_int32_t seq, void *ctxt) } /* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */ +/* ARGSUSED */ void channel_input_oclose(int type, u_int32_t seq, void *ctxt) { @@ -2145,6 +2202,7 @@ channel_input_oclose(int type, u_int32_t seq, void *ctxt) chan_rcvd_oclose(c); } +/* ARGSUSED */ void channel_input_close_confirmation(int type, u_int32_t seq, void *ctxt) { @@ -2161,6 +2219,7 @@ channel_input_close_confirmation(int type, u_int32_t seq, void *ctxt) channel_free(c); } +/* ARGSUSED */ void channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt) { @@ -2208,6 +2267,7 @@ reason2txt(int reason) return "unknown reason"; } +/* ARGSUSED */ void channel_input_open_failure(int type, u_int32_t seq, void *ctxt) { @@ -2239,6 +2299,7 @@ channel_input_open_failure(int type, u_int32_t seq, void *ctxt) channel_free(c); } +/* ARGSUSED */ void channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) { @@ -2263,6 +2324,7 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) c->remote_window += adjust; } +/* ARGSUSED */ void channel_input_port_open(int type, u_int32_t seq, void *ctxt) { @@ -2490,7 +2552,7 @@ channel_setup_remote_fwd_listener(const char *listen_address, * the secure channel to host:port from local side. */ -void +int channel_request_remote_forwarding(const char *listen_host, u_short listen_port, const char *host_to_connect, u_short port_to_connect) { @@ -2534,7 +2596,6 @@ channel_request_remote_forwarding(const char *listen_host, u_short listen_port, success = 1; break; case SSH_SMSG_FAILURE: - logit("Warning: Server denied remote port forwarding."); break; default: /* Unknown packet */ @@ -2548,6 +2609,7 @@ channel_request_remote_forwarding(const char *listen_host, u_short listen_port, permitted_opens[num_permitted_opens].listen_port = listen_port; num_permitted_opens++; } + return (success ? 0 : -1); } /* @@ -2587,14 +2649,14 @@ channel_request_rforward_cancel(const char *host, u_short port) /* * This is called after receiving CHANNEL_FORWARDING_REQUEST. This initates * listening for the port, and sends back a success reply (or disconnect - * message if there was an error). This never returns if there was an error. + * message if there was an error). */ - -void -channel_input_port_forward_request(int is_root, int gateway_ports, - int hpn_disabled, int hpn_buffer_size) +int +channel_input_port_forward_request(int is_root, int gateway_ports, + int hpn_disabled, int hpn_buffer_size) { u_short port, host_port; + int success = 0; char *hostname; /* Get arguments from the packet. */ @@ -2616,11 +2678,13 @@ channel_input_port_forward_request(int is_root, int gateway_ports, #endif /* Initiate forwarding */ - channel_setup_local_fwd_listener(NULL, port, hostname, + success = channel_setup_local_fwd_listener(NULL, port, hostname, host_port, gateway_ports, hpn_disabled, hpn_buffer_size); /* Free the argument string. */ xfree(hostname); + + return (success ? 0 : -1); } /* @@ -2639,7 +2703,7 @@ void channel_add_permitted_opens(char *host, int port) { if (num_permitted_opens >= SSH_MAX_FORWARDS_PER_DIRECTION) - fatal("channel_request_remote_forwarding: too many forwards"); + fatal("channel_add_permitted_opens: too many forwards"); debug("allow port forwarding to host %s port %d", host, port); permitted_opens[num_permitted_opens].host_to_connect = xstrdup(host); @@ -2649,6 +2713,19 @@ channel_add_permitted_opens(char *host, int port) all_opens_permitted = 0; } +int +channel_add_adm_permitted_opens(char *host, int port) +{ + if (num_adm_permitted_opens >= SSH_MAX_FORWARDS_PER_DIRECTION) + fatal("channel_add_adm_permitted_opens: too many forwards"); + debug("config allows port forwarding to host %s port %d", host, port); + + permitted_adm_opens[num_adm_permitted_opens].host_to_connect + = xstrdup(host); + permitted_adm_opens[num_adm_permitted_opens].port_to_connect = port; + return ++num_adm_permitted_opens; +} + void channel_clear_permitted_opens(void) { @@ -2658,9 +2735,18 @@ channel_clear_permitted_opens(void) if (permitted_opens[i].host_to_connect != NULL) xfree(permitted_opens[i].host_to_connect); num_permitted_opens = 0; - } +void +channel_clear_adm_permitted_opens(void) +{ + int i; + + for (i = 0; i < num_adm_permitted_opens; i++) + if (permitted_adm_opens[i].host_to_connect != NULL) + xfree(permitted_adm_opens[i].host_to_connect); + num_adm_permitted_opens = 0; +} /* return socket to remote host, port */ static int @@ -2738,7 +2824,7 @@ channel_connect_by_listen_address(u_short listen_port) int channel_connect_to(const char *host, u_short port) { - int i, permit; + int i, permit, permit_adm = 1; permit = all_opens_permitted; if (!permit) { @@ -2747,9 +2833,19 @@ channel_connect_to(const char *host, u_short port) permitted_opens[i].port_to_connect == port && strcmp(permitted_opens[i].host_to_connect, host) == 0) permit = 1; + } + if (num_adm_permitted_opens > 0) { + permit_adm = 0; + for (i = 0; i < num_adm_permitted_opens; i++) + if (permitted_adm_opens[i].host_to_connect != NULL && + permitted_adm_opens[i].port_to_connect == port && + strcmp(permitted_adm_opens[i].host_to_connect, host) + == 0) + permit_adm = 1; } - if (!permit) { + + if (!permit || !permit_adm) { logit("Received request to connect to host %.100s port %d, " "but the request was denied.", host, port); return -1; @@ -2770,10 +2866,10 @@ channel_send_window_changes(void) if (ioctl(channels[i]->rfd, TIOCGWINSZ, &ws) < 0) continue; channel_request_start(i, "window-change", 0); - packet_put_int(ws.ws_col); - packet_put_int(ws.ws_row); - packet_put_int(ws.ws_xpixel); - packet_put_int(ws.ws_ypixel); + packet_put_int((u_int)ws.ws_col); + packet_put_int((u_int)ws.ws_row); + packet_put_int((u_int)ws.ws_xpixel); + packet_put_int((u_int)ws.ws_ypixel); packet_send(); } } @@ -2882,7 +2978,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost, } /* Allocate a channel for each socket. */ - *chanids = xmalloc(sizeof(**chanids) * (num_socks + 1)); + *chanids = xcalloc(num_socks + 1, sizeof(**chanids)); for (n = 0; n < num_socks; n++) { sock = socks[n]; if (hpn_disabled) @@ -2917,7 +3013,7 @@ connect_local_xsocket(u_int dnr) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; snprintf(addr.sun_path, sizeof addr.sun_path, _PATH_UNIX_X, dnr); - if (connect(sock, (struct sockaddr *) & addr, sizeof(addr)) == 0) + if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) return sock; close(sock); error("connect %.100s: %.100s", addr.sun_path, strerror(errno)); @@ -2927,12 +3023,12 @@ connect_local_xsocket(u_int dnr) int x11_connect_display(void) { - int display_number, sock = 0; + u_int display_number; const char *display; char buf[1024], *cp; struct addrinfo hints, *ai, *aitop; char strport[NI_MAXSERV]; - int gaierr; + int gaierr, sock = 0; /* Try to open a socket for the local X server. */ display = getenv("DISPLAY"); @@ -2952,7 +3048,7 @@ x11_connect_display(void) if (strncmp(display, "unix:", 5) == 0 || display[0] == ':') { /* Connect to the unix domain socket. */ - if (sscanf(strrchr(display, ':') + 1, "%d", &display_number) != 1) { + if (sscanf(strrchr(display, ':') + 1, "%u", &display_number) != 1) { error("Could not parse display number from DISPLAY: %.100s", display); return -1; @@ -2977,7 +3073,7 @@ x11_connect_display(void) } *cp = 0; /* buf now contains the host name. But first we parse the display number. */ - if (sscanf(cp + 1, "%d", &display_number) != 1) { + if (sscanf(cp + 1, "%u", &display_number) != 1) { error("Could not parse display number from DISPLAY: %.100s", display); return -1; @@ -2987,7 +3083,7 @@ x11_connect_display(void) memset(&hints, 0, sizeof(hints)); hints.ai_family = IPv4or6; hints.ai_socktype = SOCK_STREAM; - snprintf(strport, sizeof strport, "%d", 6000 + display_number); + snprintf(strport, sizeof strport, "%u", 6000 + display_number); if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) { error("%.100s: unknown host. (%s)", buf, gai_strerror(gaierr)); return -1; @@ -3001,7 +3097,7 @@ x11_connect_display(void) } /* Connect it to the display. */ if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0) { - debug2("connect %.100s port %d: %.100s", buf, + debug2("connect %.100s port %u: %.100s", buf, 6000 + display_number, strerror(errno)); close(sock); continue; @@ -3011,7 +3107,7 @@ x11_connect_display(void) } freeaddrinfo(aitop); if (!ai) { - error("connect %.100s port %d: %.100s", buf, 6000 + display_number, + error("connect %.100s port %u: %.100s", buf, 6000 + display_number, strerror(errno)); return -1; } @@ -3025,6 +3121,7 @@ x11_connect_display(void) * with either SSH_MSG_OPEN_CONFIRMATION or SSH_MSG_OPEN_FAILURE. */ +/* ARGSUSED */ void x11_input_open(int type, u_int32_t seq, void *ctxt) { @@ -3068,6 +3165,7 @@ x11_input_open(int type, u_int32_t seq, void *ctxt) } /* dummy protocol handler that denies SSH-1 requests (agent/x11) */ +/* ARGSUSED */ void deny_input_open(int type, u_int32_t seq, void *ctxt) { @@ -3114,13 +3212,11 @@ x11_request_forwarding_with_spoofing(int client_session_id, const char *disp, return; } - cp = disp; - if (disp) - cp = strchr(disp, ':'); + cp = strchr(disp, ':'); if (cp) cp = strchr(cp, '.'); if (cp) - screen_number = atoi(cp + 1); + screen_number = (u_int)strtonum(cp + 1, 0, 400, NULL); else screen_number = 0; diff --git a/openssh/channels.h b/openssh/channels.h index f380531..91bc0ae 100644 --- a/openssh/channels.h +++ b/openssh/channels.h @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.h,v 1.83 2005/12/30 15:56:37 reyk Exp $ */ +/* $OpenBSD: channels.h,v 1.88 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -38,8 +38,6 @@ #ifndef CHANNEL_H #define CHANNEL_H -#include "buffer.h" - /* Definitions for channel types. */ #define SSH_CHANNEL_X11_LISTENER 1 /* Listening for inet X11 conn. */ #define SSH_CHANNEL_PORT_LISTENER 2 /* Listening on a port. */ @@ -214,11 +212,13 @@ int channel_find_open(void); void channel_set_af(int af); void channel_permit_all_opens(void); void channel_add_permitted_opens(char *, int); +int channel_add_adm_permitted_opens(char *, int); void channel_clear_permitted_opens(void); -void channel_input_port_forward_request(int, int, int, int); +void channel_clear_adm_permitted_opens(void); +int channel_input_port_forward_request(int, int, int, int); int channel_connect_to(const char *, u_short); int channel_connect_by_listen_address(u_short); -void channel_request_remote_forwarding(const char *, u_short, +int channel_request_remote_forwarding(const char *, u_short, const char *, u_short); int channel_setup_local_fwd_listener(const char *, u_short, const char *, u_short, int, int, int); diff --git a/openssh/cipher-3des1.c b/openssh/cipher-3des1.c index f815e8a..fc16e20 100644 --- a/openssh/cipher-3des1.c +++ b/openssh/cipher-3des1.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cipher-3des1.c,v 1.6 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Markus Friedl. All rights reserved. * @@ -23,9 +24,14 @@ */ #include "includes.h" -RCSID("$OpenBSD: cipher-3des1.c,v 1.2 2003/12/22 20:29:55 markus Exp $"); + +#include #include + +#include +#include + #include "xmalloc.h" #include "log.h" diff --git a/openssh/cipher-acss.c b/openssh/cipher-acss.c index 103f2d6..cb0bf73 100644 --- a/openssh/cipher-acss.c +++ b/openssh/cipher-acss.c @@ -15,9 +15,10 @@ */ #include "includes.h" + #include -RCSID("$Id$"); +#include #if !defined(EVP_CTRL_SET_ACSS_MODE) && (OPENSSL_VERSION_NUMBER >= 0x00907000L) diff --git a/openssh/cipher-aes.c b/openssh/cipher-aes.c index 228ddb1..3ea5949 100644 --- a/openssh/cipher-aes.c +++ b/openssh/cipher-aes.c @@ -28,9 +28,13 @@ #include "openbsd-compat/openssl-compat.h" #ifdef USE_BUILTIN_RIJNDAEL -RCSID("$OpenBSD: cipher-aes.c,v 1.2 2003/11/26 21:44:29 djm Exp $"); +#include #include + +#include +#include + #include "rijndael.h" #include "xmalloc.h" #include "log.h" diff --git a/openssh/cipher-bf1.c b/openssh/cipher-bf1.c index 5af695c..292488c 100644 --- a/openssh/cipher-bf1.c +++ b/openssh/cipher-bf1.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cipher-bf1.c,v 1.5 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Markus Friedl. All rights reserved. * @@ -23,9 +24,14 @@ */ #include "includes.h" -RCSID("$OpenBSD: cipher-bf1.c,v 1.1 2003/05/15 03:08:29 markus Exp $"); + +#include #include + +#include +#include + #include "xmalloc.h" #include "log.h" diff --git a/openssh/cipher-ctr.c b/openssh/cipher-ctr.c index 8a98f3c..b24f3a4 100644 --- a/openssh/cipher-ctr.c +++ b/openssh/cipher-ctr.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cipher-ctr.c,v 1.10 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Markus Friedl * @@ -14,12 +15,16 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "includes.h" -RCSID("$OpenBSD: cipher-ctr.c,v 1.6 2005/07/17 07:17:55 djm Exp $"); + +#include + +#include +#include #include -#include "log.h" #include "xmalloc.h" +#include "log.h" /* compatibility with old or broken OpenSSL versions */ #include "openbsd-compat/openssl-compat.h" diff --git a/openssh/cipher.c b/openssh/cipher.c index 9a5f984..ddbf97c 100644 --- a/openssh/cipher.c +++ b/openssh/cipher.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cipher.c,v 1.81 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,14 +36,18 @@ */ #include "includes.h" -RCSID("$OpenBSD: cipher.c,v 1.77 2005/07/16 01:35:24 djm Exp $"); + +#include + +#include + +#include +#include #include "xmalloc.h" #include "log.h" #include "cipher.h" -#include - /* compatibility with old or broken OpenSSL versions */ #include "openbsd-compat/openssl-compat.h" diff --git a/openssh/cipher.h b/openssh/cipher.h index 6bb5719..49bbc16 100644 --- a/openssh/cipher.h +++ b/openssh/cipher.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cipher.h,v 1.35 2004/07/28 09:40:29 markus Exp $ */ +/* $OpenBSD: cipher.h,v 1.36 2006/03/25 22:22:42 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/cleanup.c b/openssh/cleanup.c index 11d1d4d..238f965 100644 --- a/openssh/cleanup.c +++ b/openssh/cleanup.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cleanup.c,v 1.5 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Markus Friedl * @@ -13,8 +14,13 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include "includes.h" -RCSID("$OpenBSD: cleanup.c,v 1.1 2003/09/23 20:17:11 markus Exp $"); + +#include + +#include +#include #include "log.h" diff --git a/openssh/clientloop.c b/openssh/clientloop.c index 3089bcf..2f7ce2b 100644 --- a/openssh/clientloop.c +++ b/openssh/clientloop.c @@ -1,3 +1,4 @@ +/* $OpenBSD: clientloop.c,v 1.176 2006/10/11 12:38:03 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -59,20 +60,43 @@ */ #include "includes.h" -RCSID("$OpenBSD: clientloop.c,v 1.149 2005/12/30 15:56:37 reyk Exp $"); +#include +#include +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include + +#include +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" #include "ssh2.h" -#include "xmalloc.h" #include "packet.h" #include "buffer.h" #include "compat.h" #include "channels.h" #include "dispatch.h" -#include "buffer.h" -#include "bufaux.h" #include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "readconf.h" @@ -118,7 +142,7 @@ static volatile sig_atomic_t received_signal = 0; static int in_non_blocking_mode = 0; /* Common data for the client loop code. */ -static int quit_pending; /* Set to non-zero to quit the client loop. */ +static volatile sig_atomic_t quit_pending; /* Set non-zero to quit the loop. */ static int escape_char; /* Escape character. */ static int escape_pending; /* Last character was the escape character */ static int last_was_cr; /* Last character was a newline. */ @@ -178,7 +202,7 @@ enter_non_blocking(void) * Signal handler for the window change signal (SIGWINCH). This just sets a * flag indicating that the window has changed. */ - +/*ARGSUSED */ static void window_change_handler(int sig) { @@ -190,7 +214,7 @@ window_change_handler(int sig) * Signal handler for signals that cause the program to terminate. These * signals must be trapped to restore terminal modes. */ - +/*ARGSUSED */ static void signal_handler(int sig) { @@ -422,10 +446,10 @@ client_check_window_change(void) if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) < 0) return; packet_start(SSH_CMSG_WINDOW_SIZE); - packet_put_int(ws.ws_row); - packet_put_int(ws.ws_col); - packet_put_int(ws.ws_xpixel); - packet_put_int(ws.ws_ypixel); + packet_put_int((u_int)ws.ws_row); + packet_put_int((u_int)ws.ws_col); + packet_put_int((u_int)ws.ws_xpixel); + packet_put_int((u_int)ws.ws_ypixel); packet_send(); } } @@ -440,8 +464,10 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt) static void server_alive_check(void) { - if (++server_alive_timeouts > options.server_alive_count_max) - packet_disconnect("Timeout, server not responding."); + if (++server_alive_timeouts > options.server_alive_count_max) { + logit("Timeout, server not responding."); + cleanup_exit(255); + } packet_start(SSH2_MSG_GLOBAL_REQUEST); packet_put_cstring("keepalive@openssh.com"); packet_put_char(1); /* boolean: want reply */ @@ -569,7 +595,7 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr) } static void -client_process_net_input(fd_set * readset) +client_process_net_input(fd_set *readset) { int len; char buf[8192]; @@ -677,7 +703,7 @@ client_extra_session2_setup(int id, void *arg) } static void -client_process_control(fd_set * readset) +client_process_control(fd_set *readset) { Buffer m; Channel *c; @@ -844,8 +870,7 @@ client_process_control(fd_set * readset) return; } - cctx = xmalloc(sizeof(*cctx)); - memset(cctx, 0, sizeof(*cctx)); + cctx = xcalloc(1, sizeof(*cctx)); cctx->want_tty = (flags & SSHMUX_FLAG_TTY) != 0; cctx->want_subsys = (flags & SSHMUX_FLAG_SUBSYS) != 0; cctx->want_x_fwd = (flags & SSHMUX_FLAG_X11_FWD) != 0; @@ -860,7 +885,7 @@ client_process_control(fd_set * readset) env_len = MIN(env_len, 4096); debug3("%s: receiving %d env vars", __func__, env_len); if (env_len != 0) { - cctx->env = xmalloc(sizeof(*cctx->env) * (env_len + 1)); + cctx->env = xcalloc(env_len + 1, sizeof(*cctx->env)); for (i = 0; i < env_len; i++) cctx->env[i] = buffer_get_string(&m, &len); cctx->env[i] = NULL; @@ -868,6 +893,7 @@ client_process_control(fd_set * readset) debug2("%s: accepted tty %d, subsys %d, cmd %s", __func__, cctx->want_tty, cctx->want_subsys, cmd); + xfree(cmd); /* Gather fds from client */ new_fd[0] = mm_receive_fd(client_fd); @@ -953,12 +979,16 @@ process_cmdline(void) if (*s == 'h' || *s == 'H' || *s == '?') { logit("Commands:"); - logit(" -Lport:host:hostport Request local forward"); - logit(" -Rport:host:hostport Request remote forward"); - logit(" -KRhostport Cancel remote forward"); + logit(" -L[bind_address:]port:host:hostport " + "Request local forward"); + logit(" -R[bind_address:]port:host:hostport " + "Request remote forward"); + logit(" -KR[bind_address:]port " + "Cancel remote forward"); if (!options.permit_local_command) goto out; - logit(" !args Execute local command"); + logit(" !args " + "Execute local command"); goto out; } @@ -1020,9 +1050,12 @@ process_cmdline(void) goto out; } } else { - channel_request_remote_forwarding(fwd.listen_host, + if (channel_request_remote_forwarding(fwd.listen_host, fwd.listen_port, fwd.connect_host, - fwd.connect_port); + fwd.connect_port) < 0) { + logit("Port forwarding failed."); + goto out; + } } logit("Forwarding port."); @@ -1214,7 +1247,7 @@ Supported escape sequences:\r\n\ } static void -client_process_input(fd_set * readset) +client_process_input(fd_set *readset) { int len; char buf[8192]; @@ -1267,7 +1300,7 @@ client_process_input(fd_set * readset) } static void -client_process_output(fd_set * writeset) +client_process_output(fd_set *writeset) { int len; char buf[100]; @@ -1928,10 +1961,10 @@ client_session2_setup(int id, int want_tty, int want_subsystem, channel_request_start(id, "pty-req", 0); packet_put_cstring(term != NULL ? term : ""); - packet_put_int(ws.ws_col); - packet_put_int(ws.ws_row); - packet_put_int(ws.ws_xpixel); - packet_put_int(ws.ws_ypixel); + packet_put_int((u_int)ws.ws_col); + packet_put_int((u_int)ws.ws_row); + packet_put_int((u_int)ws.ws_xpixel); + packet_put_int((u_int)ws.ws_ypixel); tio = get_saved_tio(); tty_make_modes(-1, tiop != NULL ? tiop : &tio); packet_send(); diff --git a/openssh/clientloop.h b/openssh/clientloop.h index 1845663..0be32b4 100644 --- a/openssh/clientloop.h +++ b/openssh/clientloop.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.h,v 1.14 2005/07/04 00:58:43 djm Exp $ */ +/* $OpenBSD: clientloop.h,v 1.16 2006/03/25 22:22:42 djm Exp $ */ /* * Author: Tatu Ylonen @@ -35,6 +35,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + /* Client side main loop for the interactive session. */ int client_loop(int, int, int); void client_x11_get_proto(const char *, const char *, u_int, diff --git a/openssh/compat.c b/openssh/compat.c index a331014..dca641b 100644 --- a/openssh/compat.c +++ b/openssh/compat.c @@ -1,3 +1,4 @@ +/* $OpenBSD: compat.c,v 1.76 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. * @@ -23,11 +24,16 @@ */ #include "includes.h" -RCSID("$OpenBSD: compat.c,v 1.71 2005/03/01 10:09:52 djm Exp $"); +#include + +#include +#include +#include + +#include "xmalloc.h" #include "buffer.h" #include "packet.h" -#include "xmalloc.h" #include "compat.h" #include "log.h" #include "match.h" @@ -168,6 +174,7 @@ compat_datafellows(const char *version) if (strstr(version,"hpn") == NULL) { datafellows |= SSH_BUG_LARGEWINDOW; + debug("Remote is NON-HPN aware"); } } return; diff --git a/openssh/compat.h b/openssh/compat.h index 9c0f062..9123201 100644 --- a/openssh/compat.h +++ b/openssh/compat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.h,v 1.39 2005/03/01 10:09:52 djm Exp $ */ +/* $OpenBSD: compat.h,v 1.40 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Markus Friedl. All rights reserved. diff --git a/openssh/compress.c b/openssh/compress.c index 0d1c7e5..c058d22 100644 --- a/openssh/compress.c +++ b/openssh/compress.c @@ -1,3 +1,4 @@ +/* $OpenBSD: compress.c,v 1.25 2006/08/06 01:13:32 stevesk Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,11 +13,14 @@ */ #include "includes.h" -RCSID("$OpenBSD: compress.c,v 1.21 2004/01/13 19:45:15 markus Exp $"); + +#include + +#include +#include #include "log.h" #include "buffer.h" -#include "zlib.h" #include "compress.h" z_stream incoming_stream; diff --git a/openssh/compress.h b/openssh/compress.h index e364f4b..418d6fd 100644 --- a/openssh/compress.h +++ b/openssh/compress.h @@ -1,4 +1,4 @@ -/* $OpenBSD: compress.h,v 1.11 2002/03/04 17:27:39 stevesk Exp $ */ +/* $OpenBSD: compress.h,v 1.12 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/configure.ac b/openssh/configure.ac index d6c9275..3b97314 100644 --- a/openssh/configure.ac +++ b/openssh/configure.ac @@ -127,15 +127,175 @@ AC_ARG_WITH(rpath, ] ) +# Allow user to specify flags +AC_ARG_WITH(cflags, + [ --with-cflags Specify additional flags to pass to compiler], + [ + if test -n "$withval" && test "x$withval" != "xno" && \ + test "x${withval}" != "xyes"; then + CFLAGS="$CFLAGS $withval" + fi + ] +) +AC_ARG_WITH(cppflags, + [ --with-cppflags Specify additional flags to pass to preprocessor] , + [ + if test -n "$withval" && test "x$withval" != "xno" && \ + test "x${withval}" != "xyes"; then + CPPFLAGS="$CPPFLAGS $withval" + fi + ] +) +AC_ARG_WITH(ldflags, + [ --with-ldflags Specify additional flags to pass to linker], + [ + if test -n "$withval" && test "x$withval" != "xno" && \ + test "x${withval}" != "xyes"; then + LDFLAGS="$LDFLAGS $withval" + fi + ] +) +AC_ARG_WITH(libs, + [ --with-libs Specify additional libraries to link with], + [ + if test -n "$withval" && test "x$withval" != "xno" && \ + test "x${withval}" != "xyes"; then + LIBS="$LIBS $withval" + fi + ] +) +AC_ARG_WITH(Werror, + [ --with-Werror Build main code with -Werror], + [ + if test -n "$withval" && test "x$withval" != "xno"; then + werror_flags="-Werror" + if test "x${withval}" != "xyes"; then + werror_flags="$withval" + fi + fi + ] +) + +AC_CHECK_HEADERS( \ + bstring.h \ + crypt.h \ + crypto/sha2.h \ + dirent.h \ + endian.h \ + features.h \ + fcntl.h \ + floatingpoint.h \ + getopt.h \ + glob.h \ + ia.h \ + iaf.h \ + limits.h \ + login.h \ + maillock.h \ + ndir.h \ + net/if_tun.h \ + netdb.h \ + netgroup.h \ + pam/pam_appl.h \ + paths.h \ + pty.h \ + readpassphrase.h \ + rpc/types.h \ + security/pam_appl.h \ + sha2.h \ + shadow.h \ + stddef.h \ + stdint.h \ + string.h \ + strings.h \ + sys/audit.h \ + sys/bitypes.h \ + sys/bsdtty.h \ + sys/cdefs.h \ + sys/dir.h \ + sys/mman.h \ + sys/ndir.h \ + sys/prctl.h \ + sys/pstat.h \ + sys/select.h \ + sys/stat.h \ + sys/stream.h \ + sys/stropts.h \ + sys/strtio.h \ + sys/sysmacros.h \ + sys/time.h \ + sys/timers.h \ + sys/un.h \ + time.h \ + tmpdir.h \ + ttyent.h \ + unistd.h \ + usersec.h \ + util.h \ + utime.h \ + utmp.h \ + utmpx.h \ + vis.h \ +) + +# lastlog.h requires sys/time.h to be included first on Solaris +AC_CHECK_HEADERS(lastlog.h, [], [], [ +#ifdef HAVE_SYS_TIME_H +# include +#endif +]) + +# sys/ptms.h requires sys/stream.h to be included first on Solaris +AC_CHECK_HEADERS(sys/ptms.h, [], [], [ +#ifdef HAVE_SYS_STREAM_H +# include +#endif +]) + +# login_cap.h requires sys/types.h on NetBSD +AC_CHECK_HEADERS(login_cap.h, [], [], [ +#include +]) + +# Messages for features tested for in target-specific section +SIA_MSG="no" +SPC_MSG="no" + # Check for some target-specific stuff case "$host" in *-*-aix*) + # Some versions of VAC won't allow macro redefinitions at + # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that + # particularly with older versions of vac or xlc. + # It also throws errors about null macro argments, but these are + # not fatal. + AC_MSG_CHECKING(if compiler allows macro redefinitions) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[ +#define testmacro foo +#define testmacro bar +int main(void) { exit(0); } + ]])], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no) + CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`" + LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`" + CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`" + CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`" + ] + ) + AC_MSG_CHECKING([how to specify blibpath for linker ($LD)]) if (test -z "$blibpath"); then blibpath="/usr/lib:/lib" fi saved_LDFLAGS="$LDFLAGS" - for tryflags in -blibpath: -Wl,-blibpath: -Wl,-rpath, ;do + if test "$GCC" = "yes"; then + flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:" + else + flags="-blibpath: -Wl,-blibpath: -Wl,-rpath," + fi + for tryflags in $flags ;do if (test -z "$blibflags"); then LDFLAGS="$saved_LDFLAGS $tryflags$blibpath" AC_TRY_LINK([], [], [blibflags=$tryflags]) @@ -175,6 +335,12 @@ case "$host" in [#include ] ) AC_CHECK_FUNCS(setauthdb) + AC_CHECK_DECL(F_CLOSEM, + AC_DEFINE(HAVE_FCNTL_CLOSEM, 1, [Use F_CLOSEM fcntl for closefrom]), + [], + [ #include + #include ] + ) check_for_aix_broken_getaddrinfo=1 AC_DEFINE(BROKEN_REALPATH, 1, [Define if you have a broken realpath.]) AC_DEFINE(SETEUID_BREAKS_SETUID, 1, @@ -190,6 +356,7 @@ case "$host" in supported by bsd-setproctitle.c]) AC_DEFINE(SSHPAM_CHAUTHTOK_NEEDS_RUID, 1, [AIX 5.2 and 5.3 (and presumably newer) require this]) + AC_DEFINE(PTY_ZEROREAD, 1, [read(1) can return 0 for a non-closed fd]) ;; *-*-cygwin*) check_for_libcrypt_later=1 @@ -222,30 +389,38 @@ case "$host" in AC_DEFINE(BROKEN_SETREGID) AC_DEFINE_UNQUOTED(BIND_8_COMPAT, 1, [Define if your resolver libs need this for getrrsetbyname]) - AC_MSG_CHECKING(if we have the Security Authorization Session API) - AC_TRY_COMPILE([#include ], - [SessionCreate(0, 0);], - [ac_cv_use_security_session_api="yes" - AC_DEFINE(USE_SECURITY_SESSION_API, 1, + AC_DEFINE(SSH_TUN_FREEBSD, 1, [Open tunnel devices the FreeBSD way]) + AC_DEFINE(SSH_TUN_COMPAT_AF, 1, + [Use tunnel device compatibility to OpenBSD]) + AC_DEFINE(SSH_TUN_PREPEND_AF, 1, + [Prepend the address family to IP tunnel traffic]) + AC_MSG_CHECKING(if we have the Security Authorization Session API) + AC_TRY_COMPILE([#include ], + [SessionCreate(0, 0);], + [ac_cv_use_security_session_api="yes" + AC_DEFINE(USE_SECURITY_SESSION_API, 1, [platform has the Security Authorization Session API]) - LIBS="$LIBS -framework Security" - AC_MSG_RESULT(yes)], - [ac_cv_use_security_session_api="no" - AC_MSG_RESULT(no)]) - AC_MSG_CHECKING(if we have an in-memory credentials cache) - AC_TRY_COMPILE( - [#include ], - [cc_context_t c; - (void) cc_initialize (&c, 0, NULL, NULL);], - [AC_DEFINE(USE_CCAPI, 1, + LIBS="$LIBS -framework Security" + AC_MSG_RESULT(yes)], + [ac_cv_use_security_session_api="no" + AC_MSG_RESULT(no)]) + AC_MSG_CHECKING(if we have an in-memory credentials cache) + AC_TRY_COMPILE( + [#include ], + [cc_context_t c; + (void) cc_initialize (&c, 0, NULL, NULL);], + [AC_DEFINE(USE_CCAPI, 1, [platform uses an in-memory credentials cache]) - LIBS="$LIBS -framework Security" - AC_MSG_RESULT(yes) - if test "x$ac_cv_use_security_session_api" = "xno"; then - AC_MSG_ERROR(*** Need a security framework to use the credentials cache API ***) - fi], - [AC_MSG_RESULT(no)] - ) + LIBS="$LIBS -framework Security" + AC_MSG_RESULT(yes) + if test "x$ac_cv_use_security_session_api" = "xno"; then + AC_MSG_ERROR(*** Need a security framework to use the credentials cache API ***) + fi], + [AC_MSG_RESULT(no)] + ) + ;; +*-*-dragonfly*) + SSHDLIBS="$SSHDLIBS -lcrypt" ;; *-*-hpux*) # first we define all of the options common to all HP-UX releases @@ -400,6 +575,8 @@ mips-sony-bsd|mips-sony-newsos4) AC_DEFINE(HAVE_ATTRIBUTE__SENTINEL__, 1, [OpenBSD's gcc has sentinel]) AC_DEFINE(HAVE_ATTRIBUTE__BOUNDED__, 1, [OpenBSD's gcc has bounded]) AC_DEFINE(SSH_TUN_OPENBSD, 1, [Open tunnel devices the OpenBSD way]) + AC_DEFINE(SYSLOG_R_SAFE_IN_SIGHAND, 1, + [syslog_r function is safe to use in in a signal handler]) ;; *-*-solaris*) if test "x$withval" != "xno" ; then @@ -419,6 +596,8 @@ mips-sony-bsd|mips-sony-newsos4) AC_DEFINE(SSHD_ACQUIRES_CTTY, 1, [Define if sshd somehow reacquires a controlling TTY after setsid()]) + AC_DEFINE(PASSWD_NEEDS_USERNAME, 1, [must supply username to passwd + in case the name is longer than 8 chars]) external_path_file=/etc/default/login # hardwire lastlog location (can't detect it on some versions) conf_lastlog_location="/var/adm/lastlog" @@ -432,6 +611,17 @@ mips-sony-bsd|mips-sony-newsos4) else AC_MSG_RESULT(no) fi + AC_ARG_WITH(solaris-contracts, + [ --with-solaris-contracts Enable Solaris process contracts (experimental)], + [ + AC_CHECK_LIB(contract, ct_tmpl_activate, + [ AC_DEFINE(USE_SOLARIS_PROCESS_CONTRACTS, 1, + [Define if you have Solaris process contracts]) + SSHDLIBS="$SSHDLIBS -lcontract" + AC_SUBST(SSHDLIBS) + SPC_MSG="yes" ], ) + ], + ) ;; *-*-sunos4*) CPPFLAGS="$CPPFLAGS -DSUNOS4" @@ -469,7 +659,6 @@ mips-sony-bsd|mips-sony-newsos4) ;; # UnixWare 1.x, UnixWare 2.x, and others based on code from Univel. *-*-sysv4.2*) - CFLAGS="$CFLAGS -Dva_list=_VA_LIST" AC_DEFINE(USE_PIPES) AC_DEFINE(SETEUID_BREAKS_SETUID) AC_DEFINE(BROKEN_SETREUID) @@ -491,6 +680,7 @@ mips-sony-bsd|mips-sony-newsos4) TEST_SHELL=/u95/bin/sh AC_DEFINE(BROKEN_LIBIAF, 1, [ia_uinfo routines not supported by OS yet]) + AC_DEFINE(BROKEN_UPDWTMPX) ;; *) AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*") ;; @@ -580,6 +770,7 @@ mips-sony-bsd|mips-sony-newsos4) system's login() call]) AC_DEFINE(DISABLE_FD_PASSING) LIBS="$LIBS -lsecurity -ldb -lm -laud" + SIA_MSG="yes" else AC_MSG_RESULT(no) AC_DEFINE(LOCKED_PASSWD_SUBSTR, "Nologin", @@ -599,6 +790,8 @@ mips-sony-bsd|mips-sony-newsos4) AC_DEFINE(MISSING_HOWMANY, 1, [Define on *nto-qnx systems]) AC_DEFINE(MISSING_FD_MASK, 1, [Define on *nto-qnx systems]) AC_DEFINE(DISABLE_LASTLOG) + AC_DEFINE(SSHD_ACQUIRES_CTTY) + enable_etc_default_login=no # has incompatible /etc/default/login ;; *-*-ultrix*) @@ -615,55 +808,6 @@ mips-sony-bsd|mips-sony-newsos4) ;; esac -# Allow user to specify flags -AC_ARG_WITH(cflags, - [ --with-cflags Specify additional flags to pass to compiler], - [ - if test -n "$withval" && test "x$withval" != "xno" && \ - test "x${withval}" != "xyes"; then - CFLAGS="$CFLAGS $withval" - fi - ] -) -AC_ARG_WITH(cppflags, - [ --with-cppflags Specify additional flags to pass to preprocessor] , - [ - if test -n "$withval" && test "x$withval" != "xno" && \ - test "x${withval}" != "xyes"; then - CPPFLAGS="$CPPFLAGS $withval" - fi - ] -) -AC_ARG_WITH(ldflags, - [ --with-ldflags Specify additional flags to pass to linker], - [ - if test -n "$withval" && test "x$withval" != "xno" && \ - test "x${withval}" != "xyes"; then - LDFLAGS="$LDFLAGS $withval" - fi - ] -) -AC_ARG_WITH(libs, - [ --with-libs Specify additional libraries to link with], - [ - if test -n "$withval" && test "x$withval" != "xno" && \ - test "x${withval}" != "xyes"; then - LIBS="$LIBS $withval" - fi - ] -) -AC_ARG_WITH(Werror, - [ --with-Werror Build main code with -Werror], - [ - if test -n "$withval" && test "x$withval" != "xno"; then - werror_flags="-Werror" - if test "x${withval}" != "xyes"; then - werror_flags="$withval" - fi - fi - ] -) - AC_MSG_CHECKING(compiler and flags for sanity) AC_RUN_IFELSE( [AC_LANG_SOURCE([ @@ -679,79 +823,6 @@ int main(){exit(0);} ) dnl Checks for header files. -AC_CHECK_HEADERS( \ - bstring.h \ - crypt.h \ - dirent.h \ - endian.h \ - features.h \ - floatingpoint.h \ - getopt.h \ - glob.h \ - ia.h \ - iaf.h \ - limits.h \ - login.h \ - login_cap.h \ - maillock.h \ - ndir.h \ - netdb.h \ - netgroup.h \ - pam/pam_appl.h \ - paths.h \ - pty.h \ - readpassphrase.h \ - rpc/types.h \ - security/pam_appl.h \ - shadow.h \ - stddef.h \ - stdint.h \ - string.h \ - strings.h \ - sys/audit.h \ - sys/bitypes.h \ - sys/bsdtty.h \ - sys/cdefs.h \ - sys/dir.h \ - sys/mman.h \ - sys/ndir.h \ - sys/prctl.h \ - sys/pstat.h \ - sys/select.h \ - sys/stat.h \ - sys/stream.h \ - sys/stropts.h \ - sys/strtio.h \ - sys/sysmacros.h \ - sys/time.h \ - sys/timers.h \ - sys/un.h \ - time.h \ - tmpdir.h \ - ttyent.h \ - unistd.h \ - usersec.h \ - util.h \ - utime.h \ - utmp.h \ - utmpx.h \ - vis.h \ -) - -# lastlog.h requires sys/time.h to be included first on Solaris -AC_CHECK_HEADERS(lastlog.h, [], [], [ -#ifdef HAVE_SYS_TIME_H -# include -#endif -]) - -# sys/ptms.h requires sys/stream.h to be included first on Solaris -AC_CHECK_HEADERS(sys/ptms.h, [], [], [ -#ifdef HAVE_SYS_STREAM_H -# include -#endif -]) - # Checks for libraries. AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match)) AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt)) @@ -936,11 +1007,9 @@ AC_EGREP_CPP(FOUNDIT, # Check for g.gl_matchc glob() extension AC_MSG_CHECKING(for gl_matchc field in glob_t) -AC_EGREP_CPP(FOUNDIT, - [ - #include - int main(void){glob_t g; g.gl_matchc = 1;} - ], +AC_TRY_COMPILE( + [ #include ], + [glob_t g; g.gl_matchc = 1;], [ AC_DEFINE(GLOB_HAS_GL_MATCHC, 1, [Define if your system glob() function has @@ -952,6 +1021,8 @@ AC_EGREP_CPP(FOUNDIT, ] ) +AC_CHECK_DECLS(GLOB_NOMATCH, , , [#include ]) + AC_MSG_CHECKING([whether struct dirent allocates space for d_name]) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ @@ -1309,7 +1380,13 @@ AC_ARG_WITH(audit, AUDIT_MODULE=bsm dnl Checks for headers, libs and functions AC_CHECK_HEADERS(bsm/audit.h, [], - [AC_MSG_ERROR(BSM enabled and bsm/audit.h not found)]) + [AC_MSG_ERROR(BSM enabled and bsm/audit.h not found)], + [ +#ifdef HAVE_TIME_H +# include +#endif + ] +) AC_CHECK_LIB(bsm, getaudit, [], [AC_MSG_ERROR(BSM enabled and required library not found)]) AC_CHECK_FUNCS(getaudit, [], @@ -1455,6 +1532,29 @@ AC_CHECK_DECL(tcsendbreak, AC_CHECK_DECLS(h_errno, , ,[#include ]) +AC_CHECK_DECLS(SHUT_RD, , , + [ +#include +#include + ]) + +AC_CHECK_DECLS(O_NONBLOCK, , , + [ +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_FCNTL_H +# include +#endif + ]) + +AC_CHECK_DECLS(writev, , , [ +#include +#include +#include + ]) + AC_CHECK_FUNCS(setresuid, [ dnl Some platorms have setresuid that isn't implemented, test for this AC_MSG_CHECKING(if setresuid seems to work) @@ -1799,6 +1899,7 @@ main(void) AC_MSG_RESULT(no) AC_DEFINE(BROKEN_GETADDRINFO) ], + [ AC_MSG_RESULT(cross-compiling, assuming no) ] ) @@ -1824,83 +1925,6 @@ fi AC_FUNC_GETPGRP -# Check for PAM libs -PAM_MSG="no" -AC_ARG_WITH(pam, - [ --with-pam Enable PAM support ], - [ - if test "x$withval" != "xno" ; then - if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \ - test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then - AC_MSG_ERROR([PAM headers not found]) - fi - - 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) - - PAM_MSG="yes" - - AC_DEFINE(USE_PAM, 1, - [Define if you want to enable PAM support]) - if test $ac_cv_lib_dl_dlopen = yes; then - LIBPAM="-lpam -ldl" - else - LIBPAM="-lpam" - fi - - AC_SUBST(LIBPAM) - fi - ], - [ - AC_CHECK_LIB(dl, dlopen, , ) - AC_CHECK_LIB(pam, pam_set_item, , ) - AC_CHECK_FUNCS(pam_getenvlist) - AC_CHECK_FUNCS(pam_putenv) - - if (test "x$ac_cv_header_security_pam_appl_h" = "xyes" || \ - test "x$ac_cv_header_pam_pam_appl_h" = "xyes") && - test "x$ac_cv_lib_pam_pam_set_item" = "xyes" ; then - - PAM_MSG="yes" - - AC_DEFINE(USE_PAM) - if test $ac_cv_lib_dl_dlopen = yes; then - LIBPAM="-lpam -ldl" - else - LIBPAM="-lpam" - fi - AC_SUBST(LIBPAM) - fi - ] -) - -# Check for older PAM -if test "x$PAM_MSG" = "xyes" ; then - # Check PAM strerror arguments (old PAM) - AC_MSG_CHECKING([whether pam_strerror takes only one argument]) - AC_TRY_COMPILE( - [ -#include -#if defined(HAVE_SECURITY_PAM_APPL_H) -#include -#elif defined (HAVE_PAM_PAM_APPL_H) -#include -#endif - ], - [(void)pam_strerror((pam_handle_t *)NULL, -1);], - [AC_MSG_RESULT(no)], - [ - AC_DEFINE(HAVE_OLD_PAM, 1, - [Define if you have an old version of PAM - which takes only one argument to pam_strerror]) - AC_MSG_RESULT(yes) - PAM_MSG="yes (old library)" - ] - ) -fi - # Search for OpenSSL saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" @@ -2049,9 +2073,57 @@ Also see contrib/findssl.sh for help identifying header/library mismatches.]) ] ) +AC_MSG_CHECKING([if programs using OpenSSL functions will link]) +AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main(void) { SSLeay_add_all_algorithms(); } + ]])], + [ + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + saved_LIBS="$LIBS" + LIBS="$LIBS -ldl" + AC_MSG_CHECKING([if programs using OpenSSL need -ldl]) + AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main(void) { SSLeay_add_all_algorithms(); } + ]])], + [ + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + LIBS="$saved_LIBS" + ] + ) + ] +) + +AC_ARG_WITH(ssl-engine, + [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ], + [ if test "x$withval" != "xno" ; then + AC_MSG_CHECKING(for OpenSSL ENGINE support) + AC_TRY_COMPILE( + [ #include ], + [ +ENGINE_load_builtin_engines();ENGINE_register_all_complete(); + ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(USE_OPENSSL_ENGINE, 1, + [Enable OpenSSL engine support]) + ], + [ AC_MSG_ERROR(OpenSSL ENGINE support not found)] + ) + fi ] +) + # Check for OpenSSL without EVP_aes_{192,256}_cbc AC_MSG_CHECKING([whether OpenSSL has crippled AES support]) -AC_COMPILE_IFELSE( +AC_LINK_IFELSE( [AC_LANG_SOURCE([[ #include #include @@ -2079,6 +2151,9 @@ if test "x$check_for_libcrypt_later" = "x1"; then AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt") fi +# Search for SHA256 support in libc and/or OpenSSL +AC_CHECK_FUNCS(SHA256_Update EVP_sha256) + AC_CHECK_LIB(iaf, ia_openinfo) ### Configure cryptographic random number support @@ -2109,6 +2184,98 @@ int main(void) { exit(RAND_status() == 1 ? 0 : 1); } ] ) +# Check for PAM libs +PAM_MSG="no" +AC_ARG_WITH(pam, + [ --with-pam Enable PAM support ], + [ + if test "x$withval" != "xno" ; then + if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \ + test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then + AC_MSG_ERROR([PAM headers not found]) + fi + + saved_LIBS="$LIBS" + 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) + LIBS="$saved_LIBS" + + PAM_MSG="yes" + + LIBPAM="-lpam" + AC_DEFINE(USE_PAM, 1, + [Define if you want to enable PAM support]) + + if test $ac_cv_lib_dl_dlopen = yes; then + case "$LIBS" in + *-ldl*) + # libdl already in LIBS + ;; + *) + LIBPAM="$LIBPAM -ldl" + ;; + esac + fi + AC_SUBST(LIBPAM) + fi + ], + [ + saved_LIBS="$LIBS" + AC_CHECK_LIB(dl, dlopen, , ) + AC_CHECK_LIB(pam, pam_set_item, , ) + AC_CHECK_FUNCS(pam_getenvlist) + AC_CHECK_FUNCS(pam_putenv) + LIBS="$saved_LIBS" + + if (test "x$ac_cv_header_security_pam_appl_h" = "xyes" || \ + test "x$ac_cv_header_pam_pam_appl_h" = "xyes") && + test "x$ac_cv_lib_pam_pam_set_item" = "xyes" ; then + + PAM_MSG="yes" + + LIBPAM="-lpam" + + if test $ac_cv_lib_dl_dlopen = yes; then + case "$LIBS" in + *-ldl*) + # libdl already in LIBS + ;; + *) + LIBPAM="$LIBPAM -ldl" + ;; + esac + fi + AC_SUBST(LIBPAM) + fi + ] +) + +# Check for older PAM +if test "x$PAM_MSG" = "xyes" ; then + # Check PAM strerror arguments (old PAM) + AC_MSG_CHECKING([whether pam_strerror takes only one argument]) + AC_TRY_COMPILE( + [ +#include +#if defined(HAVE_SECURITY_PAM_APPL_H) +#include +#elif defined (HAVE_PAM_PAM_APPL_H) +#include +#endif + ], + [(void)pam_strerror((pam_handle_t *)NULL, -1);], + [AC_MSG_RESULT(no)], + [ + AC_DEFINE(HAVE_OLD_PAM, 1, + [Define if you have an old version of PAM + which takes only one argument to pam_strerror]) + AC_MSG_RESULT(yes) + PAM_MSG="yes (old library)" + ] + ) +fi # Do we want to force the use of the rand helper? AC_ARG_WITH(rand-helper, @@ -2328,6 +2495,34 @@ if test -z "$have_llong_max"; then #define __USE_ISOC99 #include #define DATA "conftest.llminmax" +#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a)) + +/* + * printf in libc on some platforms (eg old Tru64) does not understand %lld so + * we do this the hard way. + */ +static int +fprint_ll(FILE *f, long long n) +{ + unsigned int i; + int l[sizeof(long long) * 8]; + + if (n < 0) + if (fprintf(f, "-") < 0) + return -1; + for (i = 0; n != 0; i++) { + l[i] = my_abs(n % 10); + n /= 10; + } + do { + if (fprintf(f, "%d", l[--i]) < 0) + return -1; + } while (i != 0); + if (fprintf(f, " ") < 0) + return -1; + return 0; +} + int main(void) { FILE *f; long long i, llmin, llmax = 0; @@ -2349,14 +2544,18 @@ int main(void) { /* Sanity check */ if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax - || llmax - 1 > llmax) { + || llmax - 1 > llmax || llmin == llmax || llmin == 0 + || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) { fprintf(f, "unknown unknown\n"); exit(2); } - if (fprintf(f ,"%lld %lld", llmin, llmax) < 0) + if (fprint_ll(f, llmin) < 0) exit(3); - + if (fprint_ll(f, llmax) < 0) + exit(4); + if (fclose(f) < 0) + exit(5); exit(0); } ]])], @@ -2364,17 +2563,6 @@ int main(void) { llong_min=`$AWK '{print $1}' conftest.llminmax` llong_max=`$AWK '{print $2}' conftest.llminmax` - # snprintf on some Tru64s doesn't understand "%lld" - case "$host" in - alpha-dec-osf*) - if test "x$ac_cv_sizeof_long_long_int" = "x8" && - test "x$llong_max" = "xld"; then - llong_min="-9223372036854775808" - llong_max="9223372036854775807" - fi - ;; - esac - AC_MSG_RESULT($llong_max) AC_DEFINE_UNQUOTED(LLONG_MAX, [${llong_max}LL], [max value of long long calculated by configure]) @@ -3120,7 +3308,7 @@ AC_ARG_WITH(opensc, LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags` LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs` CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS" - LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS" + LIBS="$LIBS $LIBOPENSC_LIBS" AC_DEFINE(SMARTCARD) AC_DEFINE(USE_OPENSC, 1, [Define if you want smartcard support @@ -3168,6 +3356,26 @@ int main() [#include ]) ]) +# Check whether user wants SELinux support +SELINUX_MSG="no" +LIBSELINUX="" +AC_ARG_WITH(selinux, + [ --with-selinux Enable SELinux support], + [ if test "x$withval" != "xno" ; then + AC_DEFINE(WITH_SELINUX,1,[Define if you want SELinux support.]) + SELINUX_MSG="yes" + AC_CHECK_HEADER([selinux/selinux.h], , + AC_MSG_ERROR(SELinux support requires selinux.h header)) + AC_CHECK_LIB(selinux, setexeccon, [ LIBSELINUX="-lselinux" ], + AC_MSG_ERROR(SELinux support requires libselinux library)) + save_LIBS="$LIBS" + LIBS="$LIBS $LIBSELINUX" + AC_CHECK_FUNCS(getseuserbyname get_default_context_with_level) + LIBS="$save_LIBS" + fi ] +) +AC_SUBST(LIBSELINUX) + # Check whether user wants Kerberos 5 support KRB5_MSG="no" AC_ARG_WITH(kerberos5, @@ -3964,20 +4172,13 @@ if test ! -z "$blibpath" ; then AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile]) fi -dnl remove pam and dl because they are in $LIBPAM -if test "$PAM_MSG" = yes ; then - LIBS=`echo $LIBS | sed 's/-lpam //'` -fi -if test "$ac_cv_lib_pam_pam_set_item" = yes ; then - LIBS=`echo $LIBS | sed 's/-ldl //'` -fi - dnl Adding -Werror to CFLAGS early prevents configure tests from running. dnl Add now. CFLAGS="$CFLAGS $werror_flags" AC_EXEEXT -AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openbsd-compat/Makefile \ +AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \ + openbsd-compat/Makefile openbsd-compat/regress/Makefile \ scard/Makefile ssh_prng_cmds survey.sh]) AC_OUTPUT @@ -4017,12 +4218,15 @@ echo " sshd superuser user PATH: $J" fi echo " Manpage format: $MANTYPE" echo " PAM support: $PAM_MSG" +echo " OSF SIA support: $SIA_MSG" echo " KerberosV support: $KRB5_MSG" +echo " SELinux support: $SELINUX_MSG" echo " Smartcard support: $SCARD_MSG" echo " S/KEY support: $SKEY_MSG" echo " TCP Wrappers support: $TCPW_MSG" echo " MD5 password support: $MD5_MSG" echo " libedit support: $LIBEDIT_MSG" +echo " Solaris process contract support: $SPC_MSG" echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" echo " BSD Auth support: $BSD_AUTH_MSG" diff --git a/openssh/contrib/aix/buildbff.sh b/openssh/contrib/aix/buildbff.sh index 5410fea..6b283a1 100755 --- a/openssh/contrib/aix/buildbff.sh +++ b/openssh/contrib/aix/buildbff.sh @@ -23,6 +23,8 @@ umask 022 startdir=`pwd` +perl -v >/dev/null || (echo perl required; exit 1) + # Path to inventory.sh: same place as buildbff.sh if echo $0 | egrep '^/' then @@ -200,33 +202,29 @@ do done echo -# Create PrivSep user if PrivSep not disabled in config -echo Creating PrivSep prereqs if required. -if egrep '^[ \t]*UsePrivilegeSeparation[ \t]+no' $sysconfdir/sshd_config >/dev/null +# Create PrivilegeSeparation user and group if not present +echo Checking for PrivilegeSeparation user and group. +if cut -f1 -d: /etc/group | egrep '^'$SSH_PRIVSEP_USER'\$' >/dev/null then - echo "UsePrivilegeSeparation disabled in config, not creating PrivSep user," - echo "group or chroot directory." + echo "PrivSep group $SSH_PRIVSEP_USER already exists." else - echo "UsePrivilegeSeparation enabled in config (or defaulting to on)." - - # create group if required - if cut -f1 -d: /etc/group | egrep '^'$SSH_PRIVSEP_USER'\$' >/dev/null - then - echo "PrivSep group $SSH_PRIVSEP_USER already exists." - else - echo "Creating PrivSep group $SSH_PRIVSEP_USER." - mkgroup -A $SSH_PRIVSEP_USER - fi + echo "Creating PrivSep group $SSH_PRIVSEP_USER." + mkgroup -A $SSH_PRIVSEP_USER +fi - # Create user if required - if lsuser "$SSH_PRIVSEP_USER" >/dev/null - then - echo "PrivSep user $SSH_PRIVSEP_USER already exists." - else - echo "Creating PrivSep user $SSH_PRIVSEP_USER." - mkuser gecos='SSHD PrivSep User' login=false rlogin=false account_locked=true pgrp=$SSH_PRIVSEP_USER $SSH_PRIVSEP_USER - fi +# Create user if required +if lsuser "$SSH_PRIVSEP_USER" >/dev/null +then + echo "PrivSep user $SSH_PRIVSEP_USER already exists." +else + echo "Creating PrivSep user $SSH_PRIVSEP_USER." + mkuser gecos='SSHD PrivSep User' login=false rlogin=false account_locked=true pgrp=$SSH_PRIVSEP_USER $SSH_PRIVSEP_USER +fi +if egrep '^[ \t]*UsePrivilegeSeparation[ \t]+no' $sysconfdir/sshd_config >/dev/null +then + echo UsePrivilegeSeparation not enabled, privsep directory not required. +else # create chroot directory if required if [ -d $PRIVSEP_PATH ] then diff --git a/openssh/contrib/caldera/openssh.spec b/openssh/contrib/caldera/openssh.spec index 1748d9e..54c584d 100644 --- a/openssh/contrib/caldera/openssh.spec +++ b/openssh/contrib/caldera/openssh.spec @@ -17,7 +17,7 @@ #old cvs stuff. please update before use. may be deprecated. %define use_stable 1 %if %{use_stable} - %define version 4.3p2 + %define version 4.5p1 %define cvs %{nil} %define release 1 %else diff --git a/openssh/contrib/cygwin/ssh-host-config b/openssh/contrib/cygwin/ssh-host-config index 0540890..e2ad69f 100644 --- a/openssh/contrib/cygwin/ssh-host-config +++ b/openssh/contrib/cygwin/ssh-host-config @@ -153,22 +153,31 @@ fi # Create /var/log and /var/log/lastlog if not already existing -if [ -f ${LOCALSTATEDIR}/log ] +if [ -e ${LOCALSTATEDIR}/log -a ! -d ${LOCALSTATEDIR}/log ] then - echo "Creating ${LOCALSTATEDIR}/log failed!" -else - if [ ! -d ${LOCALSTATEDIR}/log ] - then - mkdir -p ${LOCALSTATEDIR}/log - fi - if [ -d ${LOCALSTATEDIR}/log/lastlog ] - then - chmod 777 ${LOCALSTATEDIR}/log/lastlog - elif [ ! -f ${LOCALSTATEDIR}/log/lastlog ] - then - cat /dev/null > ${LOCALSTATEDIR}/log/lastlog - chmod 666 ${LOCALSTATEDIR}/log/lastlog - fi + echo + echo "${LOCALSTATEDIR}/log is existant but not a directory." + echo "Cannot create ssh host configuration." + echo + exit 1 +fi +if [ ! -e ${LOCALSTATEDIR}/log ] +then + mkdir -p ${LOCALSTATEDIR}/log +fi + +if [ -e ${LOCALSTATEDIR}/log/lastlog -a ! -f ${LOCALSTATEDIR}/log/lastlog ] +then + echo + echo "${LOCALSTATEDIR}/log/lastlog exists, but is not a file." + echo "Cannot create ssh host configuration." + echo + exit 1 +fi +if [ ! -e ${LOCALSTATEDIR}/log/lastlog ] +then + cat /dev/null > ${LOCALSTATEDIR}/log/lastlog + chmod 644 ${LOCALSTATEDIR}/log/lastlog fi # Create /var/empty file used as chroot jail for privilege separation @@ -507,6 +516,7 @@ then fi editrights -a SeAssignPrimaryTokenPrivilege -u sshd_server && editrights -a SeCreateTokenPrivilege -u sshd_server && + editrights -a SeTcbPrivilege -u sshd_server && editrights -a SeDenyInteractiveLogonRight -u sshd_server && editrights -a SeDenyNetworkLogonRight -u sshd_server && editrights -a SeDenyRemoteInteractiveLogonRight -u sshd_server && @@ -578,6 +588,7 @@ then fi chown "${_user}" ${SYSCONFDIR}/ssh* chown "${_user}".544 ${LOCALSTATEDIR}/empty + chown "${_user}".544 ${LOCALSTATEDIR}/log/lastlog if [ -f ${LOCALSTATEDIR}/log/sshd.log ] then chown "${_user}".544 ${LOCALSTATEDIR}/log/sshd.log diff --git a/openssh/contrib/redhat/openssh.spec b/openssh/contrib/redhat/openssh.spec index cbdf7bb..52e8676 100644 --- a/openssh/contrib/redhat/openssh.spec +++ b/openssh/contrib/redhat/openssh.spec @@ -1,4 +1,4 @@ -%define ver 4.3p2 +%define ver 4.5p1 %define rel 1 # OpenSSH privilege separation requires a user & group ID diff --git a/openssh/contrib/redhat/sshd.init b/openssh/contrib/redhat/sshd.init index 4ee8630..e5d837c 100755 --- a/openssh/contrib/redhat/sshd.init +++ b/openssh/contrib/redhat/sshd.init @@ -35,6 +35,9 @@ do_rsa1_keygen() { if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then chmod 600 $RSA1_KEY chmod 644 $RSA1_KEY.pub + if [ -x /sbin/restorecon ]; then + /sbin/restorecon $RSA1_KEY.pub + fi success $"RSA1 key generation" echo else @@ -51,6 +54,9 @@ do_rsa_keygen() { if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then chmod 600 $RSA_KEY chmod 644 $RSA_KEY.pub + if [ -x /sbin/restorecon ]; then + /sbin/restorecon $RSA_KEY.pub + fi success $"RSA key generation" echo else @@ -67,6 +73,9 @@ do_dsa_keygen() { if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then chmod 600 $DSA_KEY chmod 644 $DSA_KEY.pub + if [ -x /sbin/restorecon ]; then + /sbin/restorecon $DSA_KEY.pub + fi success $"DSA key generation" echo else diff --git a/openssh/contrib/suse/openssh.spec b/openssh/contrib/suse/openssh.spec index b49e78c..797964c 100644 --- a/openssh/contrib/suse/openssh.spec +++ b/openssh/contrib/suse/openssh.spec @@ -13,7 +13,7 @@ Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation Name: openssh -Version: 4.3p2 +Version: 4.5p1 URL: http://www.openssh.com/ Release: 1 Source0: openssh-%{version}.tar.gz diff --git a/openssh/crc32.c b/openssh/crc32.c index ac627b5..c192eb4 100644 --- a/openssh/crc32.c +++ b/openssh/crc32.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crc32.c,v 1.9 2003/02/12 21:39:50 markus Exp $ */ +/* $OpenBSD: crc32.c,v 1.11 2006/04/22 18:29:33 stevesk Exp $ */ /* * Copyright (c) 2003 Markus Friedl. All rights reserved. @@ -99,7 +99,7 @@ ssh_crc32(const u_char *buf, u_int32_t size) u_int32_t i, crc; crc = 0; - for (i = 0; i < size; i++) + for (i = 0; i < size; i++) crc = crc32tab[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); return crc; } diff --git a/openssh/crc32.h b/openssh/crc32.h index a2fb584..5d7131a 100644 --- a/openssh/crc32.h +++ b/openssh/crc32.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crc32.h,v 1.14 2003/02/12 21:39:50 markus Exp $ */ +/* $OpenBSD: crc32.h,v 1.15 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2003 Markus Friedl. All rights reserved. diff --git a/openssh/deattack.c b/openssh/deattack.c index 8b55d66..1b37e4d 100644 --- a/openssh/deattack.c +++ b/openssh/deattack.c @@ -1,3 +1,4 @@ +/* $OpenBSD: deattack.c,v 1.30 2006/09/16 19:53:37 djm Exp $ */ /* * Cryptographic attack detector for ssh - source code * @@ -18,14 +19,36 @@ */ #include "includes.h" -RCSID("$OpenBSD: deattack.c,v 1.19 2003/09/18 08:49:45 markus Exp $"); +#include + +#include +#include +#include + +#include "xmalloc.h" #include "deattack.h" #include "log.h" #include "crc32.h" -#include "getput.h" -#include "xmalloc.h" -#include "deattack.h" +#include "misc.h" + +/* + * CRC attack detection has a worst-case behaviour that is O(N^3) over + * the number of identical blocks in a packet. This behaviour can be + * exploited to create a limited denial of service attack. + * + * However, because we are dealing with encrypted data, identical + * blocks should only occur every 2^35 maximally-sized packets or so. + * Consequently, we can detect this DoS by looking for identical blocks + * in a packet. + * + * The parameter below determines how many identical blocks we will + * accept in a single packet, trading off between attack detection and + * likelihood of terminating a legitimate connection. A value of 32 + * corresponds to an average of 2^40 messages before an attack is + * misdetected + */ +#define MAX_IDENTICAL 32 /* SSH Constants */ #define SSH_MAXBLOCKS (32 * 1024) @@ -43,7 +66,7 @@ RCSID("$OpenBSD: deattack.c,v 1.19 2003/09/18 08:49:45 markus Exp $"); /* Hash function (Input keys are cipher results) */ -#define HASH(x) GET_32BIT(x) +#define HASH(x) get_u32(x) #define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE)) @@ -51,22 +74,17 @@ static void crc_update(u_int32_t *a, u_int32_t b) { b ^= *a; - *a = ssh_crc32((u_char *) &b, sizeof(b)); + *a = ssh_crc32((u_char *)&b, sizeof(b)); } /* detect if a block is used in a particular pattern */ static int -check_crc(u_char *S, u_char *buf, u_int32_t len, - u_char *IV) +check_crc(u_char *S, u_char *buf, u_int32_t len) { u_int32_t crc; u_char *c; crc = 0; - if (IV && !CMP(S, IV)) { - crc_update(&crc, 1); - crc_update(&crc, 0); - } for (c = buf; c < buf + len; c += SSH_BLOCKSIZE) { if (!CMP(S, c)) { crc_update(&crc, 1); @@ -82,12 +100,12 @@ check_crc(u_char *S, u_char *buf, u_int32_t len, /* Detect a crc32 compensation attack on a packet */ int -detect_attack(u_char *buf, u_int32_t len, u_char *IV) +detect_attack(u_char *buf, u_int32_t len) { static u_int16_t *h = (u_int16_t *) NULL; static u_int32_t n = HASH_MINSIZE / HASH_ENTRYSIZE; u_int32_t i, j; - u_int32_t l; + u_int32_t l, same; u_char *c; u_char *d; @@ -100,26 +118,20 @@ detect_attack(u_char *buf, u_int32_t len, u_char *IV) if (h == NULL) { debug("Installing crc compensation attack detector."); - h = (u_int16_t *) xmalloc(l * HASH_ENTRYSIZE); + h = (u_int16_t *) xcalloc(l, HASH_ENTRYSIZE); n = l; } else { if (l > n) { - h = (u_int16_t *) xrealloc(h, l * HASH_ENTRYSIZE); + h = (u_int16_t *)xrealloc(h, l, HASH_ENTRYSIZE); n = l; } } if (len <= HASH_MINBLOCKS) { for (c = buf; c < buf + len; c += SSH_BLOCKSIZE) { - if (IV && (!CMP(c, IV))) { - if ((check_crc(c, buf, len, IV))) - return (DEATTACK_DETECTED); - else - break; - } for (d = buf; d < c; d += SSH_BLOCKSIZE) { if (!CMP(c, d)) { - if ((check_crc(c, buf, len, IV))) + if ((check_crc(c, buf, len))) return (DEATTACK_DETECTED); else break; @@ -130,21 +142,13 @@ detect_attack(u_char *buf, u_int32_t len, u_char *IV) } memset(h, HASH_UNUSEDCHAR, n * HASH_ENTRYSIZE); - if (IV) - h[HASH(IV) & (n - 1)] = HASH_IV; - - for (c = buf, j = 0; c < (buf + len); c += SSH_BLOCKSIZE, j++) { + for (c = buf, same = j = 0; c < (buf + len); c += SSH_BLOCKSIZE, j++) { for (i = HASH(c) & (n - 1); h[i] != HASH_UNUSED; i = (i + 1) & (n - 1)) { - if (h[i] == HASH_IV) { - if (!CMP(c, IV)) { - if (check_crc(c, buf, len, IV)) - return (DEATTACK_DETECTED); - else - break; - } - } else if (!CMP(c, buf + h[i] * SSH_BLOCKSIZE)) { - if (check_crc(c, buf, len, IV)) + if (!CMP(c, buf + h[i] * SSH_BLOCKSIZE)) { + if (++same > MAX_IDENTICAL) + return (DEATTACK_DOS_DETECTED); + if (check_crc(c, buf, len)) return (DEATTACK_DETECTED); else break; diff --git a/openssh/deattack.h b/openssh/deattack.h index ddccdea..0316fb2 100644 --- a/openssh/deattack.h +++ b/openssh/deattack.h @@ -1,4 +1,4 @@ -/* $OpenBSD: deattack.h,v 1.7 2001/06/26 17:27:23 markus Exp $ */ +/* $OpenBSD: deattack.h,v 1.10 2006/09/16 19:53:37 djm Exp $ */ /* * Cryptographic attack detector for ssh - Header file @@ -25,6 +25,7 @@ /* Return codes */ #define DEATTACK_OK 0 #define DEATTACK_DETECTED 1 +#define DEATTACK_DOS_DETECTED 2 -int detect_attack(u_char *, u_int32_t, u_char[8]); +int detect_attack(u_char *, u_int32_t); #endif diff --git a/openssh/defines.h b/openssh/defines.h index 3a24eaa..143ede9 100644 --- a/openssh/defines.h +++ b/openssh/defines.h @@ -30,7 +30,7 @@ /* Constants */ -#ifndef SHUT_RDWR +#if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0 enum { SHUT_RD = 0, /* No more receptions. */ @@ -90,8 +90,8 @@ enum #endif #endif -#ifndef O_NONBLOCK /* Non Blocking Open */ -# define O_NONBLOCK 00004 +#if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0 +# define O_NONBLOCK 00004 /* Non Blocking Open */ #endif #ifndef S_ISDIR @@ -143,16 +143,11 @@ including rpc/rpc.h breaks Solaris 6 #define INADDR_LOOPBACK ((u_long)0x7f000001) #endif -#ifndef __unused -#define __unused -#endif - /* Types */ /* If sys/types.h does not supply intXX_t, supply them ourselves */ /* (or die trying) */ - #ifndef HAVE_U_INT typedef unsigned int u_int; #endif @@ -496,6 +491,22 @@ struct winsize { # define offsetof(type, member) ((size_t) &((type *)0)->member) #endif +/* Set up BSD-style BYTE_ORDER definition if it isn't there already */ +/* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */ +#ifndef BYTE_ORDER +# ifndef LITTLE_ENDIAN +# define LITTLE_ENDIAN 1234 +# endif /* LITTLE_ENDIAN */ +# ifndef BIG_ENDIAN +# define BIG_ENDIAN 4321 +# endif /* BIG_ENDIAN */ +# ifdef WORDS_BIGENDIAN +# define BYTE_ORDER BIG_ENDIAN +# else /* WORDS_BIGENDIAN */ +# define BYTE_ORDER LITTLE_ENDIAN +# endif /* WORDS_BIGENDIAN */ +#endif /* BYTE_ORDER */ + /* Function replacement / compatibility hacks */ #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO)) @@ -517,19 +528,6 @@ struct winsize { # define optarg BSDoptarg #endif -/* In older versions of libpam, pam_strerror takes a single argument */ -#ifdef HAVE_OLD_PAM -# define PAM_STRERROR(a,b) pam_strerror((b)) -#else -# define PAM_STRERROR(a,b) pam_strerror((a),(b)) -#endif - -#ifdef PAM_SUN_CODEBASE -# define PAM_MSG_MEMBER(msg, n, member) ((*(msg))[(n)].member) -#else -# define PAM_MSG_MEMBER(msg, n, member) ((msg)[(n)]->member) -#endif - #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) # undef HAVE_GETADDRINFO #endif @@ -544,6 +542,11 @@ struct winsize { # undef HAVE_UPDWTMPX #endif +#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \ + defined(SYSLOG_R_SAFE_IN_SIGHAND) +# define DO_LOG_SAFE_IN_SIGHAND +#endif + #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) # define memmove(s1, s2, n) bcopy((s2), (s1), (n)) #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ @@ -553,6 +556,7 @@ struct winsize { #endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */ #ifndef GETPGRP_VOID +# include # define getpgrp() getpgrp(0) #endif @@ -715,12 +719,14 @@ struct winsize { # undef HAVE_MMAP #endif -/* some system headers on HP-UX define YES/NO */ -#ifdef YES -# undef YES -#endif -#ifdef NO -# undef NO +#ifndef IOV_MAX +# if defined(_XOPEN_IOV_MAX) +# define IOV_MAX _XOPEN_IOV_MAX +# elif defined(DEF_IOV_MAX) +# define IOV_MAX DEF_IOV_MAX +# else +# define IOV_MAX 16 +# endif #endif #endif /* _DEFINES_H */ diff --git a/openssh/dh.c b/openssh/dh.c index 044d869..02b9a40 100644 --- a/openssh/dh.c +++ b/openssh/dh.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dh.c,v 1.43 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * @@ -23,17 +24,17 @@ */ #include "includes.h" -RCSID("$OpenBSD: dh.c,v 1.31 2004/08/04 10:37:52 djm Exp $"); -#include "xmalloc.h" +#include #include #include -#include -#include "buffer.h" -#include "cipher.h" -#include "kex.h" +#include +#include +#include +#include + #include "dh.h" #include "pathnames.h" #include "log.h" @@ -44,9 +45,11 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg) { char *cp, *arg; char *strsize, *gen, *prime; + const char *errstr = NULL; cp = line; - arg = strdelim(&cp); + if ((arg = strdelim(&cp)) == NULL) + return 0; /* Ignore leading whitespace */ if (*arg == '\0') arg = strdelim(&cp); @@ -67,7 +70,8 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg) goto fail; strsize = strsep(&cp, " "); /* size */ if (cp == NULL || *strsize == '\0' || - (dhg->size = atoi(strsize)) == 0) + (dhg->size = (u_int)strtonum(strsize, 0, 64*1024, &errstr)) == 0 || + errstr) goto fail; /* The whole group is one bit larger */ dhg->size++; @@ -178,19 +182,36 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub) int i; int n = BN_num_bits(dh_pub); int bits_set = 0; + BIGNUM *tmp; if (dh_pub->neg) { logit("invalid public DH value: negativ"); return 0; } + if (BN_cmp(dh_pub, BN_value_one()) != 1) { /* pub_exp <= 1 */ + logit("invalid public DH value: <= 1"); + return 0; + } + + if ((tmp = BN_new()) == NULL) + return (-1); + if (!BN_sub(tmp, dh->p, BN_value_one()) || + BN_cmp(dh_pub, tmp) != -1) { /* pub_exp > p-2 */ + BN_clear_free(tmp); + logit("invalid public DH value: >= p-1"); + return 0; + } + BN_clear_free(tmp); + for (i = 0; i <= n; i++) if (BN_is_bit_set(dh_pub, i)) bits_set++; debug2("bits set: %d/%d", bits_set, BN_num_bits(dh->p)); /* if g==2 and bits_set==1 then computing log_g(dh_pub) is trivial */ - if (bits_set > 1 && (BN_cmp(dh_pub, dh->p) == -1)) + if (bits_set > 1) return 1; + logit("invalid public DH value (%d/%d)", bits_set, BN_num_bits(dh->p)); return 0; } diff --git a/openssh/dh.h b/openssh/dh.h index 723dd08..8e580ee 100644 --- a/openssh/dh.h +++ b/openssh/dh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.h,v 1.8 2004/06/13 12:53:24 djm Exp $ */ +/* $OpenBSD: dh.h,v 1.9 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. diff --git a/openssh/dispatch.c b/openssh/dispatch.c index c5ff650..d6b63be 100644 --- a/openssh/dispatch.c +++ b/openssh/dispatch.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dispatch.c,v 1.21 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -21,8 +22,13 @@ * (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: dispatch.c,v 1.16 2003/04/08 20:21:28 itojun Exp $"); + +#include + +#include +#include #include "ssh1.h" #include "ssh2.h" @@ -76,7 +82,7 @@ dispatch_set(int type, dispatch_fn *fn) dispatch[type] = fn; } void -dispatch_run(int mode, int *done, void *ctxt) +dispatch_run(int mode, volatile sig_atomic_t *done, void *ctxt) { for (;;) { int type; diff --git a/openssh/dispatch.h b/openssh/dispatch.h index a82e216..3e3d1a1 100644 --- a/openssh/dispatch.h +++ b/openssh/dispatch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.h,v 1.9 2002/01/11 13:39:36 markus Exp $ */ +/* $OpenBSD: dispatch.h,v 1.11 2006/04/20 09:27:09 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -23,6 +23,9 @@ * (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 + enum { DISPATCH_BLOCK, DISPATCH_NONBLOCK @@ -33,6 +36,6 @@ typedef void dispatch_fn(int, u_int32_t, void *); void dispatch_init(dispatch_fn *); void dispatch_set(int, dispatch_fn *); void dispatch_range(u_int, u_int, dispatch_fn *); -void dispatch_run(int, int *, void *); +void dispatch_run(int, volatile sig_atomic_t *, void *); void dispatch_protocol_error(int, u_int32_t, void *); void dispatch_protocol_ignore(int, u_int32_t, void *); diff --git a/openssh/dns.c b/openssh/dns.c index a71dd9b..92623de 100644 --- a/openssh/dns.c +++ b/openssh/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.16 2005/10/17 14:13:35 stevesk Exp $ */ +/* $OpenBSD: dns.c,v 1.23 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Wesley Griffin. All rights reserved. @@ -26,9 +26,14 @@ */ #include "includes.h" -RCSID("$OpenBSD: dns.c,v 1.16 2005/10/17 14:13:35 stevesk Exp $"); + +#include +#include #include +#include +#include +#include #include "xmalloc.h" #include "key.h" @@ -122,7 +127,7 @@ dns_read_rdata(u_int8_t *algorithm, u_int8_t *digest_type, *digest = (u_char *) xmalloc(*digest_len); memcpy(*digest, rdata + 2, *digest_len); } else { - *digest = xstrdup(""); + *digest = (u_char *)xstrdup(""); } success = 1; diff --git a/openssh/dns.h b/openssh/dns.h index 0aa1c28..b2633a1 100644 --- a/openssh/dns.h +++ b/openssh/dns.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.h,v 1.6 2005/10/17 14:13:35 stevesk Exp $ */ +/* $OpenBSD: dns.h,v 1.10 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Wesley Griffin. All rights reserved. @@ -25,8 +25,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "includes.h" - #ifndef DNS_H #define DNS_H diff --git a/openssh/entropy.c b/openssh/entropy.c index fc90c51..ccabb13 100644 --- a/openssh/entropy.c +++ b/openssh/entropy.c @@ -24,6 +24,20 @@ #include "includes.h" +#include +#include + +#ifdef HAVE_SYS_STAT_H +# include +#endif + +#ifdef HAVE_FCNTL_H +# include +#endif +#include +#include +#include + #include #include #include @@ -35,7 +49,6 @@ #include "pathnames.h" #include "log.h" #include "buffer.h" -#include "bufaux.h" /* * Portable OpenSSH PRNG seeding: @@ -48,8 +61,6 @@ * XXX: we should tell the child how many bytes we need. */ -RCSID("$Id$"); - #ifndef OPENSSL_PRNG_ONLY #define RANDOM_SEED_SIZE 48 static uid_t original_uid, original_euid; diff --git a/openssh/fatal.c b/openssh/fatal.c index ae1aaac..5e5aa3f 100644 --- a/openssh/fatal.c +++ b/openssh/fatal.c @@ -1,3 +1,4 @@ +/* $OpenBSD: fatal.c,v 1.7 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -23,7 +24,10 @@ */ #include "includes.h" -RCSID("$OpenBSD: fatal.c,v 1.2 2003/09/23 20:17:11 markus Exp $"); + +#include + +#include #include "log.h" @@ -33,6 +37,7 @@ void fatal(const char *fmt,...) { va_list args; + va_start(args, fmt); do_log(SYSLOG_LEVEL_FATAL, fmt, args); va_end(args); diff --git a/openssh/getput.h b/openssh/getput.h deleted file mode 100644 index 20cf8f2..0000000 --- a/openssh/getput.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: getput.h,v 1.8 2002/03/04 17:27:39 stevesk Exp $ */ - -/* - * Author: Tatu Ylonen - * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland - * All rights reserved - * Macros for storing and retrieving data in msb first and lsb first order. - * - * 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". - */ - -#ifndef GETPUT_H -#define GETPUT_H - -/*------------ macros for storing/extracting msb first words -------------*/ - -#define GET_64BIT(cp) (((u_int64_t)(u_char)(cp)[0] << 56) | \ - ((u_int64_t)(u_char)(cp)[1] << 48) | \ - ((u_int64_t)(u_char)(cp)[2] << 40) | \ - ((u_int64_t)(u_char)(cp)[3] << 32) | \ - ((u_int64_t)(u_char)(cp)[4] << 24) | \ - ((u_int64_t)(u_char)(cp)[5] << 16) | \ - ((u_int64_t)(u_char)(cp)[6] << 8) | \ - ((u_int64_t)(u_char)(cp)[7])) - -#define GET_32BIT(cp) (((u_long)(u_char)(cp)[0] << 24) | \ - ((u_long)(u_char)(cp)[1] << 16) | \ - ((u_long)(u_char)(cp)[2] << 8) | \ - ((u_long)(u_char)(cp)[3])) - -#define GET_16BIT(cp) (((u_long)(u_char)(cp)[0] << 8) | \ - ((u_long)(u_char)(cp)[1])) - -#define PUT_64BIT(cp, value) do { \ - (cp)[0] = (value) >> 56; \ - (cp)[1] = (value) >> 48; \ - (cp)[2] = (value) >> 40; \ - (cp)[3] = (value) >> 32; \ - (cp)[4] = (value) >> 24; \ - (cp)[5] = (value) >> 16; \ - (cp)[6] = (value) >> 8; \ - (cp)[7] = (value); } while (0) - -#define PUT_32BIT(cp, value) do { \ - (cp)[0] = (value) >> 24; \ - (cp)[1] = (value) >> 16; \ - (cp)[2] = (value) >> 8; \ - (cp)[3] = (value); } while (0) - -#define PUT_16BIT(cp, value) do { \ - (cp)[0] = (value) >> 8; \ - (cp)[1] = (value); } while (0) - -#endif /* GETPUT_H */ diff --git a/openssh/groupaccess.c b/openssh/groupaccess.c index f50879f..e73f62b 100644 --- a/openssh/groupaccess.c +++ b/openssh/groupaccess.c @@ -1,3 +1,4 @@ +/* $OpenBSD: groupaccess.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Kevin Steves. All rights reserved. * @@ -23,10 +24,16 @@ */ #include "includes.h" -RCSID("$OpenBSD: groupaccess.c,v 1.6 2003/04/08 20:21:28 itojun Exp $"); -#include "groupaccess.h" +#include +#include + +#include +#include +#include + #include "xmalloc.h" +#include "groupaccess.h" #include "match.h" #include "log.h" @@ -52,8 +59,8 @@ ga_init(const char *user, gid_t base) ngroups = MAX(NGROUPS_MAX, sysconf(_SC_NGROUPS_MAX)); #endif - groups_bygid = xmalloc(ngroups * sizeof(*groups_bygid)); - groups_byname = xmalloc(ngroups * sizeof(*groups_byname)); + groups_bygid = xcalloc(ngroups, sizeof(*groups_bygid)); + groups_byname = xcalloc(ngroups, sizeof(*groups_byname)); if (getgrouplist(user, base, groups_bygid, &ngroups) == -1) logit("getgrouplist: groups list too small"); diff --git a/openssh/groupaccess.h b/openssh/groupaccess.h index ede4805..04b4498 100644 --- a/openssh/groupaccess.h +++ b/openssh/groupaccess.h @@ -1,4 +1,4 @@ -/* $OpenBSD: groupaccess.h,v 1.4 2001/06/26 17:27:23 markus Exp $ */ +/* $OpenBSD: groupaccess.h,v 1.7 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Kevin Steves. All rights reserved. @@ -27,8 +27,6 @@ #ifndef GROUPACCESS_H #define GROUPACCESS_H -#include - int ga_init(const char *, gid_t); int ga_match(char * const *, int); void ga_free(void); diff --git a/openssh/gss-genr.c b/openssh/gss-genr.c index 9bc2a84..4a7bd47 100644 --- a/openssh/gss-genr.c +++ b/openssh/gss-genr.c @@ -1,7 +1,7 @@ -/* $OpenBSD: gss-genr.c,v 1.6 2005/10/13 22:24:31 stevesk Exp $ */ +/* $OpenBSD: gss-genr.c,v 1.17 2006/08/29 12:02:30 dtucker Exp $ */ /* - * Copyright (c) 2001-2005 Simon Wilkinson. All rights reserved. + * Copyright (c) 2001-2006 Simon Wilkinson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,11 +28,21 @@ #ifdef GSSAPI +#include +#include + +#include +#include +#include + #include "xmalloc.h" -#include "bufaux.h" +#include "buffer.h" #include "log.h" #include "canohost.h" #include "ssh2.h" +#include "cipher.h" +#include "key.h" +#include "kex.h" #include #include "ssh-gss.h" @@ -66,7 +76,6 @@ ssh_gssapi_oid_table_ok() { * a key exchange with a bad mechanism */ - char * ssh_gssapi_client_mechanisms(const char *host) { gss_OID_set gss_supported; @@ -75,12 +84,12 @@ ssh_gssapi_client_mechanisms(const char *host) { gss_indicate_mechs(&min_status, &gss_supported); return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism, - (void *)host)); + host)); } char * ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check, - void *data) { + const char *data) { Buffer buf; size_t i; int oidpos, enclen; @@ -91,20 +100,20 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check, EVP_MD_CTX md; if (gss_enc2oid != NULL) { - for (i=0;gss_enc2oid[i].encoded!=NULL;i++) + for (i = 0; gss_enc2oid[i].encoded != NULL; i++) xfree(gss_enc2oid[i].encoded); xfree(gss_enc2oid); } - gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping)* - (gss_supported->count+1)); + gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) * + (gss_supported->count + 1)); buffer_init(&buf); oidpos = 0; - for (i = 0;i < gss_supported->count;i++) { + for (i = 0; i < gss_supported->count; i++) { if (gss_supported->elements[i].length < 128 && - (*check)(&(gss_supported->elements[i]), data)) { + (*check)(NULL, &(gss_supported->elements[i]), data)) { deroid[0] = SSH_GSS_OIDTYPE; deroid[1] = gss_supported->elements[i].length; @@ -116,19 +125,23 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check, gss_supported->elements[i].length); EVP_DigestFinal(&md, digest, NULL); - encoded = xmalloc(EVP_MD_size(evp_md)*2); + encoded = xmalloc(EVP_MD_size(evp_md) * 2); enclen = __b64_ntop(digest, EVP_MD_size(evp_md), - encoded, EVP_MD_size(evp_md)*2); + encoded, EVP_MD_size(evp_md) * 2); if (oidpos != 0) - buffer_put_char(&buf, ','); + buffer_put_char(&buf, ','); buffer_append(&buf, KEX_GSS_GEX_SHA1_ID, - sizeof(KEX_GSS_GEX_SHA1_ID)-1); + sizeof(KEX_GSS_GEX_SHA1_ID) - 1); buffer_append(&buf, encoded, enclen); - buffer_put_char(&buf,','); + buffer_put_char(&buf, ','); buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, - sizeof(KEX_GSS_GRP1_SHA1_ID)-1); + sizeof(KEX_GSS_GRP1_SHA1_ID) - 1); + buffer_append(&buf, encoded, enclen); + buffer_put_char(&buf, ','); + buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID, + sizeof(KEX_GSS_GRP14_SHA1_ID) - 1); buffer_append(&buf, encoded, enclen); gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]); @@ -154,25 +167,26 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check, } gss_OID -ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int *gex) { +ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int kex_type) { int i = 0; - - if (strncmp(name, KEX_GSS_GRP1_SHA1_ID, - sizeof(KEX_GSS_GRP1_SHA1_ID)-1) == 0) { - name+=sizeof(KEX_GSS_GRP1_SHA1_ID)-1; - *gex = 0; - } else if (strncmp(name, KEX_GSS_GEX_SHA1_ID, - sizeof(KEX_GSS_GEX_SHA1_ID)-1) == 0) { - name+=sizeof(KEX_GSS_GEX_SHA1_ID)-1; - *gex = 1; - } else { - return NULL; + + switch (kex_type) { + case KEX_GSS_GRP1_SHA1: + name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1; + break; + case KEX_GSS_GRP14_SHA1: + name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1; + break; + case KEX_GSS_GEX_SHA1: + name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1; + break; + default: + return GSS_C_NO_OID; } while (gss_enc2oid[i].encoded != NULL && - strcmp(name, gss_enc2oid[i].encoded) != 0) { + strcmp(name, gss_enc2oid[i].encoded) != 0) i++; - } if (gss_enc2oid[i].oid != NULL && ctx != NULL) ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid); @@ -214,7 +228,11 @@ ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid) void ssh_gssapi_error(Gssctxt *ctxt) { - debug("%s", ssh_gssapi_last_error(ctxt, NULL, NULL)); + char *s; + + s = ssh_gssapi_last_error(ctxt, NULL, NULL); + debug("%s", s); + xfree(s); } char * @@ -273,9 +291,7 @@ ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *major_status, void ssh_gssapi_build_ctx(Gssctxt **ctx) { - *ctx = xmalloc(sizeof (Gssctxt)); - (*ctx)->major = 0; - (*ctx)->minor = 0; + *ctx = xcalloc(1, sizeof (Gssctxt)); (*ctx)->context = GSS_C_NO_CONTEXT; (*ctx)->name = GSS_C_NO_NAME; (*ctx)->oid = GSS_C_NO_OID; @@ -350,6 +366,7 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) { gss_buffer_desc gssbuf; char *xhost; + char *val; /* Make a copy of the host name, in case it was returned by a * previous call to gethostbyname(). */ @@ -359,9 +376,9 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) * this for us themselves */ resolve_localhost(&xhost); - gssbuf.length = sizeof("host@") + strlen(xhost); - gssbuf.value = xmalloc(gssbuf.length); - snprintf(gssbuf.value, gssbuf.length, "host@%s", xhost); + xasprintf(&val, "host@%s", xhost); + gssbuf.value = val; + gssbuf.length = strlen(gssbuf.value); if ((ctx->major = gss_import_name(&ctx->minor, &gssbuf, GSS_C_NT_HOSTBASED_SERVICE, &ctx->name))) @@ -372,35 +389,6 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) return (ctx->major); } -/* Acquire credentials for a server running on the current host. - * Requires that the context structure contains a valid OID - */ - -/* Returns a GSSAPI error code */ -OM_uint32 -ssh_gssapi_acquire_cred(Gssctxt *ctx) -{ - OM_uint32 status; - char lname[MAXHOSTNAMELEN]; - gss_OID_set oidset; - - gss_create_empty_oid_set(&status, &oidset); - gss_add_oid_set_member(&status, ctx->oid, &oidset); - - if (gethostname(lname, MAXHOSTNAMELEN)) - return (-1); - - if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) - return (ctx->major); - - if ((ctx->major = gss_acquire_cred(&ctx->minor, - ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds, NULL, NULL))) - ssh_gssapi_error(ctx); - - gss_release_oid_set(&status, &oidset); - return (ctx->major); -} - OM_uint32 ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash) { @@ -439,28 +427,37 @@ ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service, buffer_put_cstring(b, context); } -OM_uint32 -ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid) +int +ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) { - if (*ctx) - ssh_gssapi_delete_ctx(ctx); + gss_buffer_desc token = GSS_C_EMPTY_BUFFER; + OM_uint32 major, minor; + gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"}; + Gssctxt *intctx = NULL; + + if (ctx == NULL) + ctx = &intctx; + + /* RFC 4462 says we MUST NOT do SPNEGO */ + if (oid->length == spnego_oid.length && + (memcmp(oid->elements, spnego_oid.elements, oid->length) == 0)) + return 0; /* false */ + ssh_gssapi_build_ctx(ctx); ssh_gssapi_set_oid(*ctx, oid); - return (ssh_gssapi_acquire_cred(*ctx)); -} + major = ssh_gssapi_import_name(*ctx, host); + if (!GSS_ERROR(major)) { + major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token, + NULL); + gss_release_buffer(&minor, &token); + if ((*ctx)->context != GSS_C_NO_CONTEXT) + gss_delete_sec_context(&minor, &(*ctx)->context, + GSS_C_NO_BUFFER); + } + + if (GSS_ERROR(major) || intctx != NULL) + ssh_gssapi_delete_ctx(ctx); -int -ssh_gssapi_check_mechanism(gss_OID oid, void *host) { - Gssctxt * ctx = NULL; - gss_buffer_desc token = GSS_C_EMPTY_BUFFER; - OM_uint32 major, minor; - - ssh_gssapi_build_ctx(&ctx); - ssh_gssapi_set_oid(ctx, oid); - ssh_gssapi_import_name(ctx, host); - major = ssh_gssapi_init_ctx(ctx, 0, GSS_C_NO_BUFFER, &token, NULL); - gss_release_buffer(&minor, &token); - ssh_gssapi_delete_ctx(&ctx); return (!GSS_ERROR(major)); } diff --git a/openssh/gss-serv-gsi.c b/openssh/gss-serv-gsi.c index c152e79..7eec054 100644 --- a/openssh/gss-serv-gsi.c +++ b/openssh/gss-serv-gsi.c @@ -27,12 +27,19 @@ #ifdef GSSAPI #ifdef GSI -#include "auth.h" -#include "auth-pam.h" +#include + +#include +#include + #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" +#include "auth.h" #include "log.h" #include "servconf.h" +#include "buffer.h" #include "ssh-gss.h" extern ServerOptions options; @@ -192,17 +199,25 @@ ssh_gssapi_gsi_storecreds(ssh_gssapi_client *client) } else { client->store.envvar = strdup((char *)export_cred.value); } + if (access(p, R_OK) == 0) { + if (client->store.filename) { + if (rename(p, client->store.filename) < 0) { + logit("Failed to rename %s to %s: %s", p, + client->store.filename, strerror(errno)); + xfree(client->store.filename); + client->store.filename = strdup(p); + } else { + p = client->store.filename; + } + } else { + client->store.filename = strdup(p); + } + } client->store.envval = strdup(p); #ifdef USE_PAM if (options.use_pam) do_pam_putenv(client->store.envvar, client->store.envval); #endif - if (strncmp(p, "FILE:", 5) == 0) { - p += 5; - } - if (access(p, R_OK) == 0) { - client->store.filename = strdup(p); - } gss_release_buffer(&minor_status, &export_cred); } diff --git a/openssh/gss-serv-krb5.c b/openssh/gss-serv-krb5.c index 17e7ab6..243fbd5 100644 --- a/openssh/gss-serv-krb5.c +++ b/openssh/gss-serv-krb5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gss-serv-krb5.c,v 1.4 2005/10/13 19:08:08 stevesk Exp $ */ +/* $OpenBSD: gss-serv-krb5.c,v 1.7 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. @@ -29,11 +29,19 @@ #ifdef GSSAPI #ifdef KRB5 -#include "auth.h" +#include + +#include +#include + #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" +#include "auth.h" #include "log.h" #include "servconf.h" +#include "buffer.h" #include "ssh-gss.h" extern ServerOptions options; @@ -156,6 +164,7 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) OM_uint32 maj_status, min_status; gss_cred_id_t krb5_cred_handle; int len; + const char* new_ccname; if (client->creds == NULL) { debug("No credentials stored"); @@ -212,11 +221,16 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) return; } - client->store.filename = xstrdup(krb5_cc_get_name(krb_context, ccache)); + new_ccname = krb5_cc_get_name(krb_context, ccache); + client->store.envvar = "KRB5CCNAME"; - len = strlen(client->store.filename) + 6; - client->store.envval = xmalloc(len); - snprintf(client->store.envval, len, "FILE:%s", client->store.filename); +#ifdef USE_CCAPI + xasprintf(&client->store.envval, "API:%s", new_ccname); + client->store.filename = NULL; +#else + xasprintf(&client->store.envval, "FILE:%s", new_ccname); + client->store.filename = xstrdup(new_ccname); +#endif #ifdef USE_PAM if (options.use_pam) diff --git a/openssh/gss-serv.c b/openssh/gss-serv.c index 90c3ef1..39184d7 100644 --- a/openssh/gss-serv.c +++ b/openssh/gss-serv.c @@ -1,7 +1,7 @@ -/* $OpenBSD: gss-serv.c,v 1.13 2005/10/13 22:24:31 stevesk Exp $ */ +/* $OpenBSD: gss-serv.c,v 1.20 2006/08/03 03:34:42 deraadt Exp $ */ /* - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. + * Copyright (c) 2001-2006 Simon Wilkinson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,19 +28,29 @@ #ifdef GSSAPI -#include "bufaux.h" +#include + +#include +#include +#include + +#include "xmalloc.h" +#include "buffer.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "log.h" #include "channels.h" #include "session.h" +#include "misc.h" #include "servconf.h" -#include "xmalloc.h" -#include "getput.h" -#include "monitor_wrap.h" +#include "xmalloc.h" #include "ssh-gss.h" +#include "monitor_wrap.h" extern ServerOptions options; +extern Authctxt *the_authctxt; static ssh_gssapi_client gssapi_client = { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER, @@ -82,8 +92,8 @@ ssh_gssapi_server_mechanisms() { /* Unprivileged */ int -ssh_gssapi_server_check_mech(gss_OID oid, void *data) { - Gssctxt * ctx = NULL; +ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data) { + Gssctxt *ctx = NULL; int res; res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid))); @@ -114,6 +124,58 @@ ssh_gssapi_supported_oids(gss_OID_set *oidset) &supported_mechs[i]->oid, oidset); i++; } + + gss_release_oid_set(&min_status, &supported); +} + +OM_uint32 +ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid) +{ + if (*ctx) + ssh_gssapi_delete_ctx(ctx); + ssh_gssapi_build_ctx(ctx); + ssh_gssapi_set_oid(*ctx, oid); + return (ssh_gssapi_acquire_cred(*ctx)); +} + +/* Acquire credentials for a server running on the current host. + * Requires that the context structure contains a valid OID + */ + +/* Returns a GSSAPI error code */ +OM_uint32 +ssh_gssapi_acquire_cred(Gssctxt *ctx) +{ + OM_uint32 status; + char lname[MAXHOSTNAMELEN]; + gss_OID_set oidset; + + if (options.gss_strict_acceptor) { + gss_create_empty_oid_set(&status, &oidset); + gss_add_oid_set_member(&status, ctx->oid, &oidset); + + if (gethostname(lname, MAXHOSTNAMELEN)) { + gss_release_oid_set(&status, &oidset); + return (-1); + } + + if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) { + gss_release_oid_set(&status, &oidset); + return (ctx->major); + } + + if ((ctx->major = gss_acquire_cred(&ctx->minor, + ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds, + NULL, NULL))) + ssh_gssapi_error(ctx); + + gss_release_oid_set(&status, &oidset); + return (ctx->major); + } else { + ctx->name = GSS_C_NO_NAME; + ctx->creds = GSS_C_NO_CREDENTIAL; + } + return GSS_S_COMPLETE; } @@ -202,7 +264,7 @@ ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name) * second without. */ - oidl = GET_16BIT(tok+2); /* length including next two bytes */ + oidl = get_u16(tok+2); /* length including next two bytes */ oidl = oidl-2; /* turn it into the _real_ length of the variable OID */ /* @@ -219,14 +281,14 @@ ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name) if (ename->length < offset+4) return GSS_S_FAILURE; - name->length = GET_32BIT(tok+offset); + name->length = get_u32(tok+offset); offset += 4; if (ename->length < offset+name->length) return GSS_S_FAILURE; name->value = xmalloc(name->length+1); - memcpy(name->value, tok+offset,name->length); + memcpy(name->value, tok+offset, name->length); ((char *)name->value)[name->length] = 0; return GSS_S_COMPLETE; @@ -289,7 +351,8 @@ ssh_gssapi_cleanup_creds(void) { if (gssapi_client.store.filename != NULL) { /* Unlink probably isn't sufficient */ - debug("removing gssapi cred file\"%s\"", gssapi_client.store.filename); + debug("removing gssapi cred file\"%s\"", + gssapi_client.store.filename); unlink(gssapi_client.store.filename); } } @@ -299,6 +362,11 @@ void ssh_gssapi_storecreds(void) { if (gssapi_client.mech && gssapi_client.mech->storecreds) { + if (options.gss_creds_path) { + gssapi_client.store.filename = + expand_authorized_keys(options.gss_creds_path, + the_authctxt->pw); + } (*gssapi_client.mech->storecreds)(&gssapi_client); } else debug("ssh_gssapi_storecreds: Not a GSSAPI mechanism"); diff --git a/openssh/hostfile.c b/openssh/hostfile.c index 3ed6462..2cceb35 100644 --- a/openssh/hostfile.c +++ b/openssh/hostfile.c @@ -1,3 +1,4 @@ +/* $OpenBSD: hostfile.c,v 1.45 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -36,18 +37,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: hostfile.c,v 1.36 2005/11/22 03:36:03 dtucker Exp $"); -#include +#include + +#include + #include #include -#include "packet.h" +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "match.h" #include "key.h" #include "hostfile.h" #include "log.h" -#include "xmalloc.h" static int extract_salt(const char *s, u_int l, char *salt, size_t salt_len) @@ -254,8 +262,10 @@ check_host_in_hostfile_by_key_or_type(const char *filename, if (key == NULL) { /* we found a key of the requested type */ - if (found->type == keytype) + if (found->type == keytype) { + fclose(f); return HOST_FOUND; + } continue; } diff --git a/openssh/hostfile.h b/openssh/hostfile.h index d633075..d1983b3 100644 --- a/openssh/hostfile.h +++ b/openssh/hostfile.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hostfile.h,v 1.15 2005/03/01 10:40:26 djm Exp $ */ +/* $OpenBSD: hostfile.h,v 1.16 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/includes.h b/openssh/includes.h index 5208174..967fcc2 100644 --- a/openssh/includes.h +++ b/openssh/includes.h @@ -1,4 +1,4 @@ -/* $OpenBSD: includes.h,v 1.22 2006/01/01 08:59:27 stevesk Exp $ */ +/* $OpenBSD: includes.h,v 1.54 2006/07/22 20:48:23 stevesk Exp $ */ /* * Author: Tatu Ylonen @@ -16,44 +16,24 @@ #ifndef INCLUDES_H #define INCLUDES_H -#define RCSID(msg) \ -static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg } - #include "config.h" #define _GNU_SOURCE /* activate extra prototypes for glibc */ -#include -#include -#include -#include -#include /* For O_NONBLOCK */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include /* For CMSG_* */ #ifdef HAVE_LIMITS_H # include /* For PATH_MAX */ #endif -#ifdef HAVE_GETOPT_H -# include -#endif #ifdef HAVE_BSTRING_H # include #endif #if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \ - defined(GLOB_HAS_GL_MATCHC) + defined(GLOB_HAS_GL_MATCHC) && \ + defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 # include #endif -#ifdef HAVE_NETGROUP_H -# include -#endif #ifdef HAVE_ENDIAN_H # include #endif @@ -67,10 +47,11 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg } # include /* For _PATH_MAILDIR */ #endif #ifdef HAVE_NEXT -# include +# include +#endif +#ifdef HAVE_PATHS +# include #endif -#include /* For STDIN_FILENO, etc */ -#include /* Struct winsize */ /* *-*-nto-qnx needs these headers for strcasecmp and LASTLOG_FILE respectively @@ -86,39 +67,22 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg } # include #endif #ifdef HAVE_UTMPX_H -# ifdef HAVE_TV_IN_UTMPX -# include -# endif # include #endif #ifdef HAVE_LASTLOG_H # include #endif -#ifdef HAVE_PATHS_H -# include /* For _PATH_XXX */ -#endif -#include -#include -#include -#include -#ifdef HAVE_SYS_TIME_H -# include /* For timersub */ -#endif -#include #ifdef HAVE_SYS_SELECT_H # include #endif #ifdef HAVE_SYS_BSDTTY_H # include #endif -#include /* For MAXPATHLEN and roundup() */ -#ifdef HAVE_SYS_UN_H -# include /* For sockaddr_un */ -#endif #ifdef HAVE_STDINT_H # include #endif +#include #ifdef HAVE_SYS_BITYPES_H # include /* For u_intXX_t */ #endif @@ -144,14 +108,8 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg } #include /* for grantpt() and friends */ #endif +#include #include /* For typedefs */ -#include /* For IPv6 macros */ -#include /* For IPTOS macros */ -#include -#include -#if defined(HAVE_NETDB_H) -# include -#endif #ifdef HAVE_RPC_TYPES_H # include /* For INADDR_LOOPBACK */ #endif @@ -205,7 +163,7 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg } #include "defines.h" -#include "version.h" +#include "platform.h" #include "openbsd-compat/openbsd-compat.h" #include "openbsd-compat/bsd-nextstep.h" diff --git a/openssh/kex.c b/openssh/kex.c index 59327f0..ac74079 100644 --- a/openssh/kex.c +++ b/openssh/kex.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kex.c,v 1.76 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * @@ -23,19 +24,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: kex.c,v 1.65 2005/11/04 05:15:59 djm Exp $"); + +#include + +#include +#include +#include +#include +#include #include -#include "ssh2.h" #include "xmalloc.h" +#include "ssh2.h" #include "buffer.h" -#include "bufaux.h" #include "packet.h" #include "compat.h" #include "cipher.h" -#include "kex.h" #include "key.h" +#include "kex.h" #include "log.h" #include "mac.h" #include "match.h" @@ -48,6 +55,14 @@ RCSID("$OpenBSD: kex.c,v 1.65 2005/11/04 05:15:59 djm Exp $"); #define KEX_COOKIE_LEN 16 +#if OPENSSL_VERSION_NUMBER >= 0x00907000L +# if defined(HAVE_EVP_SHA256) +# define evp_ssh_sha256 EVP_sha256 +# else +extern const EVP_MD *evp_ssh_sha256(void); +# endif +#endif + /* prototype */ static void kex_kexinit_finish(Kex *); static void kex_choose_conf(Kex *); @@ -79,7 +94,7 @@ kex_buf2prop(Buffer *raw, int *first_kex_follows) int i; char **proposal; - proposal = xmalloc(PROPOSAL_MAX * sizeof(char *)); + proposal = xcalloc(PROPOSAL_MAX, sizeof(char *)); buffer_init(&b); buffer_append(&b, buffer_ptr(raw), buffer_len(raw)); @@ -214,8 +229,7 @@ kex_setup(char *proposal[PROPOSAL_MAX]) { Kex *kex; - kex = xmalloc(sizeof(*kex)); - memset(kex, 0, sizeof(*kex)); + kex = xcalloc(1, sizeof(*kex)); buffer_init(&kex->peer); buffer_init(&kex->my); kex_prop2buf(&kex->my, proposal); @@ -258,6 +272,7 @@ choose_enc(Enc *enc, char *client, char *server) enc->key_len = cipher_keylen(enc->cipher); enc->block_size = cipher_blocksize(enc->cipher); } + static void choose_mac(Mac *mac, char *client, char *server) { @@ -273,6 +288,7 @@ choose_mac(Mac *mac, char *client, char *server) mac->key = NULL; mac->enabled = 0; } + static void choose_comp(Comp *comp, char *client, char *server) { @@ -290,6 +306,7 @@ choose_comp(Comp *comp, char *client, char *server) } comp->name = name; } + static void choose_kex(Kex *k, char *client, char *server) { @@ -305,15 +322,24 @@ choose_kex(Kex *k, char *client, char *server) } else if (strcmp(k->name, KEX_DHGEX_SHA1) == 0) { k->kex_type = KEX_DH_GEX_SHA1; k->evp_md = EVP_sha1(); +#if OPENSSL_VERSION_NUMBER >= 0x00907000L + } else if (strcmp(k->name, KEX_DHGEX_SHA256) == 0) { + k->kex_type = KEX_DH_GEX_SHA256; + k->evp_md = evp_ssh_sha256(); +#endif #ifdef GSSAPI } else if (strncmp(k->name, KEX_GSS_GEX_SHA1_ID, - sizeof(KEX_GSS_GEX_SHA1_ID)-1) == 0) { + sizeof(KEX_GSS_GEX_SHA1_ID) - 1) == 0) { k->kex_type = KEX_GSS_GEX_SHA1; k->evp_md = EVP_sha1(); } else if (strncmp(k->name, KEX_GSS_GRP1_SHA1_ID, - sizeof(KEX_GSS_GRP1_SHA1_ID)-1) == 0) { + sizeof(KEX_GSS_GRP1_SHA1_ID) - 1) == 0) { k->kex_type = KEX_GSS_GRP1_SHA1; k->evp_md = EVP_sha1(); + } else if (strncmp(k->name, KEX_GSS_GRP14_SHA1_ID, + sizeof(KEX_GSS_GRP14_SHA1_ID) - 1) == 0) { + k->kex_type = KEX_GSS_GRP14_SHA1; + k->evp_md = EVP_sha1(); #endif } else fatal("bad kex alg %s", k->name); @@ -378,8 +404,7 @@ kex_choose_conf(Kex *kex) /* Algorithm Negotiation */ for (mode = 0; mode < MODE_MAX; mode++) { - newkeys = xmalloc(sizeof(*newkeys)); - memset(newkeys, 0, sizeof(*newkeys)); + newkeys = xcalloc(1, sizeof(*newkeys)); kex->newkeys[mode] = newkeys; ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN); nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; @@ -434,7 +459,7 @@ derive_key(Kex *kex, int id, u_int need, u_char *hash, u_int hashlen, if ((mdsz = EVP_MD_size(kex->evp_md)) <= 0) fatal("bad kex md size %d", mdsz); - digest = xmalloc(roundup(need, mdsz)); + digest = xmalloc(roundup(need, mdsz)); buffer_init(&b); buffer_put_bignum2(&b, shared_secret); @@ -487,7 +512,8 @@ kex_derive_keys(Kex *kex, u_char *hash, u_int hashlen, BIGNUM *shared_secret) for (mode = 0; mode < MODE_MAX; mode++) { current_keys[mode] = kex->newkeys[mode]; kex->newkeys[mode] = NULL; - ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN); + ctos = (!kex->server && mode == MODE_OUT) || + (kex->server && mode == MODE_IN); current_keys[mode]->enc.iv = keys[ctos ? 0 : 1]; current_keys[mode]->enc.key = keys[ctos ? 2 : 3]; current_keys[mode]->mac.key = keys[ctos ? 4 : 5]; diff --git a/openssh/kex.h b/openssh/kex.h index 6181fde..c024402 100644 --- a/openssh/kex.h +++ b/openssh/kex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kex.h,v 1.38 2005/11/04 05:15:59 djm Exp $ */ +/* $OpenBSD: kex.h,v 1.44 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. @@ -26,14 +26,13 @@ #ifndef KEX_H #define KEX_H +#include #include -#include "buffer.h" -#include "cipher.h" -#include "key.h" #define KEX_DH1 "diffie-hellman-group1-sha1" #define KEX_DH14 "diffie-hellman-group14-sha1" #define KEX_DHGEX_SHA1 "diffie-hellman-group-exchange-sha1" +#define KEX_DHGEX_SHA256 "diffie-hellman-group-exchange-sha256" #define COMP_NONE 0 #define COMP_ZLIB 1 @@ -63,7 +62,9 @@ enum kex_exchange { KEX_DH_GRP1_SHA1, KEX_DH_GRP14_SHA1, KEX_DH_GEX_SHA1, + KEX_DH_GEX_SHA256, KEX_GSS_GRP1_SHA1, + KEX_GSS_GRP14_SHA1, KEX_GSS_GEX_SHA1, KEX_MAX }; @@ -115,7 +116,7 @@ struct Kex { int kex_type; Buffer my; Buffer peer; - int done; + sig_atomic_t done; int flags; const EVP_MD *evp_md; #ifdef GSSAPI @@ -157,7 +158,7 @@ kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int, BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *); void kexgex_hash(const EVP_MD *, char *, char *, char *, int, char *, - int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *, + int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *); void diff --git a/openssh/kexdh.c b/openssh/kexdh.c index f79d878..56e22f5 100644 --- a/openssh/kexdh.c +++ b/openssh/kexdh.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kexdh.c,v 1.23 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,13 +24,17 @@ */ #include "includes.h" -RCSID("$OpenBSD: kexdh.c,v 1.20 2005/11/04 05:15:59 djm Exp $"); + +#include + +#include #include #include "buffer.h" -#include "bufaux.h" #include "ssh2.h" +#include "key.h" +#include "cipher.h" #include "kex.h" void diff --git a/openssh/kexdhc.c b/openssh/kexdhc.c index d8a2fa3..d384c80 100644 --- a/openssh/kexdhc.c +++ b/openssh/kexdhc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kexdhc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,10 +24,18 @@ */ #include "includes.h" -RCSID("$OpenBSD: kexdhc.c,v 1.3 2005/11/04 05:15:59 djm Exp $"); + +#include + +#include +#include +#include +#include #include "xmalloc.h" +#include "buffer.h" #include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "packet.h" @@ -41,7 +50,8 @@ kexdh_client(Kex *kex) Key *server_host_key; u_char *server_host_key_blob = NULL, *signature = NULL; u_char *kbuf, *hash; - u_int klen, kout, slen, sbloblen, hashlen; + u_int klen, slen, sbloblen, hashlen; + int kout; /* generate and send 'e', client DH public key */ switch (kex->kex_type) { @@ -82,7 +92,7 @@ kexdh_client(Kex *kex) if (kex->verify_host_key(server_host_key) == -1) fatal("server_host_key verification failed"); - /* DH paramter f, server public DH key */ + /* DH parameter f, server public DH key */ if ((dh_server_pub = BN_new()) == NULL) fatal("dh_server_pub == NULL"); packet_get_bignum2(dh_server_pub); @@ -103,13 +113,15 @@ kexdh_client(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_server_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_server_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexdh_client: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexdh_client: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/openssh/kexdhs.c b/openssh/kexdhs.c index 26c8cdf..8617088 100644 --- a/openssh/kexdhs.c +++ b/openssh/kexdhs.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kexdhs.c,v 1.9 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,15 +24,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: kexdhs.c,v 1.3 2005/11/04 05:15:59 djm Exp $"); + +#include + +#include +#include +#include #include "xmalloc.h" +#include "buffer.h" #include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "packet.h" #include "dh.h" #include "ssh2.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" void @@ -41,8 +52,8 @@ kexdh_server(Kex *kex) DH *dh; Key *server_host_key; u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; - u_int sbloblen, klen, kout, hashlen; - u_int slen; + u_int sbloblen, klen, hashlen, slen; + int kout; /* generate server DH public key */ switch (kex->kex_type) { @@ -90,13 +101,15 @@ kexdh_server(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_client_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_client_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexdh_server: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexdh_server: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/openssh/kexgex.c b/openssh/kexgex.c index 705484a..b60ab5c 100644 --- a/openssh/kexgex.c +++ b/openssh/kexgex.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kexgex.c,v 1.27 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -24,12 +25,15 @@ */ #include "includes.h" -RCSID("$OpenBSD: kexgex.c,v 1.24 2005/11/04 05:15:59 djm Exp $"); + +#include #include +#include #include "buffer.h" -#include "bufaux.h" +#include "key.h" +#include "cipher.h" #include "kex.h" #include "ssh2.h" diff --git a/openssh/kexgexc.c b/openssh/kexgexc.c index a6ff875..adb973d 100644 --- a/openssh/kexgexc.c +++ b/openssh/kexgexc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kexgexc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -24,10 +25,18 @@ */ #include "includes.h" -RCSID("$OpenBSD: kexgexc.c,v 1.3 2005/11/04 05:15:59 djm Exp $"); + +#include + +#include +#include +#include +#include #include "xmalloc.h" +#include "buffer.h" #include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "packet.h" @@ -42,7 +51,8 @@ kexgex_client(Kex *kex) BIGNUM *p = NULL, *g = NULL; Key *server_host_key; u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; - u_int klen, kout, slen, sbloblen, hashlen; + u_int klen, slen, sbloblen, hashlen; + int kout; int min, max, nbits; DH *dh; @@ -120,7 +130,7 @@ kexgex_client(Kex *kex) if (kex->verify_host_key(server_host_key) == -1) fatal("server_host_key verification failed"); - /* DH paramter f, server public DH key */ + /* DH parameter f, server public DH key */ if ((dh_server_pub = BN_new()) == NULL) fatal("dh_server_pub == NULL"); packet_get_bignum2(dh_server_pub); @@ -141,13 +151,15 @@ kexgex_client(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_server_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_server_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexgex_client: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexgex_client: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/openssh/kexgexs.c b/openssh/kexgexs.c index c48b27a..a037f57 100644 --- a/openssh/kexgexs.c +++ b/openssh/kexgexs.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kexgexs.c,v 1.10 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -24,16 +25,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: kexgexs.c,v 1.2 2005/11/04 05:15:59 djm Exp $"); + +#include + +#include +#include +#include +#include #include "xmalloc.h" +#include "buffer.h" #include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "packet.h" #include "dh.h" #include "ssh2.h" #include "compat.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" void @@ -43,8 +55,8 @@ kexgex_server(Kex *kex) Key *server_host_key; DH *dh; u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; - u_int sbloblen, klen, kout, slen, hashlen; - int min = -1, max = -1, nbits = -1, type; + u_int sbloblen, klen, slen, hashlen; + int min = -1, max = -1, nbits = -1, type, kout; if (kex->load_host_key == NULL) fatal("Cannot load hostkey"); @@ -122,13 +134,15 @@ kexgex_server(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_client_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_client_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexgex_server: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexgex_server: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/openssh/kexgssc.c b/openssh/kexgssc.c index 8793f40..1cadb2a 100644 --- a/openssh/kexgssc.c +++ b/openssh/kexgssc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2005 Simon Wilkinson. All rights reserved. + * Copyright (c) 2001-2006 Simon Wilkinson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,21 +29,24 @@ #include #include +#include + #include "xmalloc.h" #include "buffer.h" -#include "bufaux.h" +#include "ssh2.h" +#include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "packet.h" #include "dh.h" -#include "canohost.h" -#include "ssh2.h" + #include "ssh-gss.h" void kexgss_client(Kex *kex) { gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; - gss_buffer_desc recv_tok, gssbuf, msg_tok, *token_ptr; + gss_buffer_desc recv_tok, gssbuf, msg_tok, *token_ptr; Gssctxt *ctxt; OM_uint32 maj_status, min_status, ret_flags; u_int klen, kout, slen = 0, hashlen, strlen; @@ -58,18 +61,25 @@ kexgss_client(Kex *kex) { char *lang; int type = 0; int first = 1; - int gex = 0; int nbits = 0, min = DH_GRP_MIN, max = DH_GRP_MAX; /* Initialise our GSSAPI world */ ssh_gssapi_build_ctx(&ctxt); - if (ssh_gssapi_id_kex(ctxt, kex->name, &gex) == NULL) + if (ssh_gssapi_id_kex(ctxt, kex->name, kex->kex_type) + == GSS_C_NO_OID) fatal("Couldn't identify host exchange"); if (ssh_gssapi_import_name(ctxt, kex->gss_host)) fatal("Couldn't import hostname"); - if (gex) { + switch (kex->kex_type) { + case KEX_GSS_GRP1_SHA1: + dh = dh_new_group1(); + break; + case KEX_GSS_GRP14_SHA1: + dh = dh_new_group14(); + break; + case KEX_GSS_GEX_SHA1: debug("Doing group exchange\n"); nbits = dh_estimate(kex->we_need * 8); packet_start(SSH2_MSG_KEXGSS_GROUPREQ); @@ -94,8 +104,9 @@ kexgss_client(Kex *kex) { min, BN_num_bits(p), max); dh = dh_new_group(g, p); - } else { - dh = dh_new_group1(); + break; + default: + fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type); } /* Step 1 - e is dh->pub_key */ @@ -203,7 +214,7 @@ kexgss_client(Kex *kex) { min_status = packet_get_int(); msg = packet_get_string(NULL); lang = packet_get_string(NULL); - fatal("GSSAPI Key Exchange Error: \n%s",msg); + fatal("GSSAPI Error: \n%.400s",msg); default: packet_disconnect("Protocol error: didn't expect packet type %d", type); @@ -238,7 +249,21 @@ kexgss_client(Kex *kex) { memset(kbuf, 0, klen); xfree(kbuf); - if (gex) { + switch (kex->kex_type) { + case KEX_GSS_GRP1_SHA1: + case KEX_GSS_GRP14_SHA1: + kex_dh_hash( kex->client_version_string, + kex->server_version_string, + buffer_ptr(&kex->my), buffer_len(&kex->my), + buffer_ptr(&kex->peer), buffer_len(&kex->peer), + serverhostkey, slen, /* server host key */ + dh->pub_key, /* e */ + dh_server_pub, /* f */ + shared_secret, /* K */ + &hash, &hashlen + ); + break; + case KEX_GSS_GEX_SHA1: kexgex_hash( kex->evp_md, kex->client_version_string, @@ -253,24 +278,15 @@ kexgss_client(Kex *kex) { shared_secret, &hash, &hashlen ); - } else { - /* The GSS hash is identical to the DH one */ - kex_dh_hash( kex->client_version_string, - kex->server_version_string, - buffer_ptr(&kex->my), buffer_len(&kex->my), - buffer_ptr(&kex->peer), buffer_len(&kex->peer), - serverhostkey, slen, /* server host key */ - dh->pub_key, /* e */ - dh_server_pub, /* f */ - shared_secret, /* K */ - &hash, &hashlen - ); - } + break; + default: + fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type); + } gssbuf.value = hash; gssbuf.length = hashlen; - /* Verify that the hash matches the MIC we just got. */ + /* Verify that the hash matches the MIC we just got. */ if (GSS_ERROR(ssh_gssapi_checkmic(ctxt, &gssbuf, &msg_tok))) packet_disconnect("Hash's MIC didn't verify"); diff --git a/openssh/kexgsss.c b/openssh/kexgsss.c index 9f51705..ae58cac 100644 --- a/openssh/kexgsss.c +++ b/openssh/kexgsss.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2005 Simon Wilkinson. All rights reserved. + * Copyright (c) 2001-2006 Simon Wilkinson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,17 +26,20 @@ #ifdef GSSAPI +#include + #include #include #include "xmalloc.h" #include "buffer.h" -#include "bufaux.h" +#include "ssh2.h" +#include "key.h" +#include "cipher.h" #include "kex.h" #include "log.h" #include "packet.h" #include "dh.h" -#include "ssh2.h" #include "ssh-gss.h" #include "monitor_wrap.h" @@ -65,31 +68,37 @@ kexgss_server(Kex *kex) BIGNUM *shared_secret = NULL; BIGNUM *dh_client_pub = NULL; int type = 0; - int gex; gss_OID oid; - + /* Initialise GSSAPI */ /* If we're rekeying, privsep means that some of the private structures * in the GSSAPI code are no longer available. This kludges them back - * into life + * into life */ if (!ssh_gssapi_oid_table_ok()) ssh_gssapi_server_mechanisms(); debug2("%s: Identifying %s", __func__, kex->name); - oid = ssh_gssapi_id_kex(NULL, kex->name, &gex); - if (oid == NULL) + oid = ssh_gssapi_id_kex(NULL, kex->name, kex->kex_type); + if (oid == GSS_C_NO_OID) fatal("Unknown gssapi mechanism"); debug2("%s: Acquiring credentials", __func__); if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt, oid)))) { kex_gss_send_error(ctxt); - fatal("Unable to acquire credentials for the server"); - } - - if (gex) { + fatal("Unable to acquire credentials for the server"); + } + + switch (kex->kex_type) { + case KEX_GSS_GRP1_SHA1: + dh = dh_new_group1(); + break; + case KEX_GSS_GRP14_SHA1: + dh = dh_new_group14(); + break; + case KEX_GSS_GEX_SHA1: debug("Doing group exchange"); packet_read_expect(SSH2_MSG_KEXGSS_GROUPREQ); min = packet_get_int(); @@ -111,10 +120,11 @@ kexgss_server(Kex *kex) packet_send(); packet_write_wait(); - - } else { - dh = dh_new_group1(); + break; + default: + fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type); } + dh_gen_key(dh, kex->we_need * 8); do { @@ -192,7 +202,19 @@ kexgss_server(Kex *kex) memset(kbuf, 0, klen); xfree(kbuf); - if (gex) { + switch (kex->kex_type) { + case KEX_GSS_GRP1_SHA1: + case KEX_GSS_GRP14_SHA1: + kex_dh_hash( + kex->client_version_string, kex->server_version_string, + buffer_ptr(&kex->peer), buffer_len(&kex->peer), + buffer_ptr(&kex->my), buffer_len(&kex->my), + NULL, 0, /* Change this if we start sending host keys */ + dh_client_pub, dh->pub_key, shared_secret, + &hash, &hashlen + ); + break; + case KEX_GSS_GEX_SHA1: kexgex_hash( kex->evp_md, kex->client_version_string, kex->server_version_string, @@ -206,18 +228,11 @@ kexgss_server(Kex *kex) shared_secret, &hash, &hashlen ); + break; + default: + fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type); } - else { - /* The GSSAPI hash is identical to the Diffie Helman one */ - kex_dh_hash( - kex->client_version_string, kex->server_version_string, - buffer_ptr(&kex->peer), buffer_len(&kex->peer), - buffer_ptr(&kex->my), buffer_len(&kex->my), - NULL, 0, /* Change this if we start sending host keys */ - dh_client_pub, dh->pub_key, shared_secret, - &hash, &hashlen - ); - } + BN_free(dh_client_pub); if (kex->session_id == NULL) { diff --git a/openssh/key.c b/openssh/key.c index 239a359..5563608 100644 --- a/openssh/key.c +++ b/openssh/key.c @@ -1,3 +1,4 @@ +/* $OpenBSD: key.c,v 1.68 2006/11/06 21:25:28 markus Exp $ */ /* * read_bignum(): * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -31,17 +32,22 @@ * (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: key.c,v 1.58 2005/06/17 02:44:32 djm Exp $"); + +#include #include +#include +#include +#include + #include "xmalloc.h" #include "key.h" #include "rsa.h" #include "uuencode.h" #include "buffer.h" -#include "bufaux.h" #include "log.h" Key * @@ -50,9 +56,8 @@ key_new(int type) Key *k; RSA *rsa; DSA *dsa; - k = xmalloc(sizeof(*k)); + k = xcalloc(1, sizeof(*k)); k->type = type; - k->flags = 0; k->dsa = NULL; k->rsa = NULL; switch (k->type) { @@ -123,6 +128,8 @@ key_new_private(int type) void key_free(Key *k) { + if (k == NULL) + fatal("key_free: key is NULL"); switch (k->type) { case KEY_RSA1: case KEY_RSA: @@ -155,14 +162,12 @@ key_equal(const Key *a, const Key *b) return a->rsa != NULL && b->rsa != NULL && BN_cmp(a->rsa->e, b->rsa->e) == 0 && BN_cmp(a->rsa->n, b->rsa->n) == 0; - break; case KEY_DSA: return a->dsa != NULL && b->dsa != NULL && BN_cmp(a->dsa->p, b->dsa->p) == 0 && BN_cmp(a->dsa->q, b->dsa->q) == 0 && BN_cmp(a->dsa->g, b->dsa->g) == 0 && BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0; - break; default: fatal("key_equal: bad key type %d", a->type); break; @@ -209,7 +214,6 @@ key_fingerprint_raw(const Key *k, enum fp_type dgst_type, break; case KEY_UNSPEC: return retval; - break; default: fatal("key_fingerprint_raw: bad key type %d", k->type); break; @@ -233,8 +237,7 @@ key_fingerprint_hex(u_char *dgst_raw, u_int dgst_raw_len) char *retval; u_int i; - retval = xmalloc(dgst_raw_len * 3 + 1); - retval[0] = '\0'; + retval = xcalloc(1, dgst_raw_len * 3 + 1); for (i = 0; i < dgst_raw_len; i++) { char hex[4]; snprintf(hex, sizeof(hex), "%02x:", dgst_raw[i]); @@ -256,7 +259,7 @@ key_fingerprint_bubblebabble(u_char *dgst_raw, u_int dgst_raw_len) char *retval; rounds = (dgst_raw_len / 2) + 1; - retval = xmalloc(sizeof(char) * (rounds*6)); + retval = xcalloc((rounds * 6), sizeof(char)); retval[j++] = 'x'; for (i = 0; i < rounds; i++) { u_int idx0, idx1, idx2, idx3, idx4; @@ -530,13 +533,10 @@ key_type(const Key *k) switch (k->type) { case KEY_RSA1: return "RSA1"; - break; case KEY_RSA: return "RSA"; - break; case KEY_DSA: return "DSA"; - break; } return "unknown"; } @@ -547,10 +547,8 @@ key_ssh_name(const Key *k) switch (k->type) { case KEY_RSA: return "ssh-rsa"; - break; case KEY_DSA: return "ssh-dss"; - break; } return "ssh-unknown"; } @@ -562,10 +560,8 @@ key_size(const Key *k) case KEY_RSA1: case KEY_RSA: return BN_num_bits(k->rsa->n); - break; case KEY_DSA: return BN_num_bits(k->dsa->p); - break; } return 0; } @@ -574,6 +570,7 @@ static RSA * rsa_generate_private_key(u_int bits) { RSA *private; + private = RSA_generate_key(bits, 35, NULL, NULL); if (private == NULL) fatal("rsa_generate_private_key: key generation failed."); @@ -584,6 +581,7 @@ static DSA* dsa_generate_private_key(u_int bits) { DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); + if (private == NULL) fatal("dsa_generate_private_key: DSA_generate_parameters failed"); if (!DSA_generate_key(private)) @@ -619,16 +617,18 @@ key_from_private(const Key *k) switch (k->type) { case KEY_DSA: n = key_new(k->type); - BN_copy(n->dsa->p, k->dsa->p); - BN_copy(n->dsa->q, k->dsa->q); - BN_copy(n->dsa->g, k->dsa->g); - BN_copy(n->dsa->pub_key, k->dsa->pub_key); + if ((BN_copy(n->dsa->p, k->dsa->p) == NULL) || + (BN_copy(n->dsa->q, k->dsa->q) == NULL) || + (BN_copy(n->dsa->g, k->dsa->g) == NULL) || + (BN_copy(n->dsa->pub_key, k->dsa->pub_key) == NULL)) + fatal("key_from_private: BN_copy failed"); break; case KEY_RSA: case KEY_RSA1: n = key_new(k->type); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("key_from_private: BN_copy failed"); break; default: fatal("key_from_private: unknown type %d", k->type); @@ -795,14 +795,11 @@ key_sign( switch (key->type) { case KEY_DSA: return ssh_dss_sign(key, sigp, lenp, data, datalen); - break; case KEY_RSA: return ssh_rsa_sign(key, sigp, lenp, data, datalen); - break; default: error("key_sign: invalid key type %d", key->type); return -1; - break; } } @@ -822,14 +819,11 @@ key_verify( switch (key->type) { case KEY_DSA: return ssh_dss_verify(key, signature, signaturelen, data, datalen); - break; case KEY_RSA: return ssh_rsa_verify(key, signature, signaturelen, data, datalen); - break; default: error("key_verify: invalid key type %d", key->type); return -1; - break; } } @@ -839,7 +833,7 @@ key_demote(const Key *k) { Key *pk; - pk = xmalloc(sizeof(*pk)); + pk = xcalloc(1, sizeof(*pk)); pk->type = k->type; pk->flags = k->flags; pk->dsa = NULL; diff --git a/openssh/key.h b/openssh/key.h index 6358e95..40576f3 100644 --- a/openssh/key.h +++ b/openssh/key.h @@ -1,4 +1,4 @@ -/* $OpenBSD: key.h,v 1.23 2003/11/10 16:23:41 jakob Exp $ */ +/* $OpenBSD: key.h,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. diff --git a/openssh/log.c b/openssh/log.c index 96ab24b..7f88674 100644 --- a/openssh/log.c +++ b/openssh/log.c @@ -1,3 +1,4 @@ +/* $OpenBSD: log.c,v 1.39 2006/08/18 09:13:25 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -34,16 +35,22 @@ */ #include "includes.h" -RCSID("$OpenBSD: log.c,v 1.29 2003/09/23 20:17:11 markus Exp $"); -#include "log.h" -#include "xmalloc.h" +#include +#include +#include +#include +#include #include +#include #if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) # include #endif +#include "xmalloc.h" +#include "log.h" + static LogLevel log_level = SYSLOG_LEVEL_INFO; static int log_on_stderr = 1; static int log_facility = LOG_AUTH; @@ -130,6 +137,20 @@ error(const char *fmt,...) va_end(args); } +void +sigdie(const char *fmt,...) +{ +#ifdef DO_LOG_SAFE_IN_SIGHAND + va_list args; + + va_start(args, fmt); + do_log(SYSLOG_LEVEL_FATAL, fmt, args); + va_end(args); +#endif + _exit(1); +} + + /* Log this message (information that usually should go to the log). */ void diff --git a/openssh/log.h b/openssh/log.h index 2b3c309..7a8c570 100644 --- a/openssh/log.h +++ b/openssh/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.11 2004/06/21 22:02:58 djm Exp $ */ +/* $OpenBSD: log.h,v 1.15 2006/08/18 09:13:25 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -15,8 +15,6 @@ #ifndef SSH_LOG_H #define SSH_LOG_H -#include /* Needed for LOG_AUTHPRIV (if present) */ - /* Supported syslog facilities and levels. */ typedef enum { SYSLOG_FACILITY_DAEMON, @@ -55,6 +53,7 @@ LogLevel log_level_number(char *); void fatal(const char *, ...) __dead __attribute__((format(printf, 1, 2))); void error(const char *, ...) __attribute__((format(printf, 1, 2))); +void sigdie(const char *, ...) __attribute__((format(printf, 1, 2))); void logit(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))); diff --git a/openssh/loginrec.c b/openssh/loginrec.c index 101544e..e591277 100644 --- a/openssh/loginrec.c +++ b/openssh/loginrec.c @@ -147,8 +147,26 @@ #include "includes.h" -#include "ssh.h" +#include +#include +#include + +#include + +#include +#include +#ifdef HAVE_PATHS_H +# include +#endif +#include +#include +#include +#include + #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" +#include "ssh.h" #include "loginrec.h" #include "log.h" #include "atomicio.h" @@ -165,8 +183,6 @@ # include #endif -RCSID("$Id$"); - /** ** prototypes for helper functions in this file **/ diff --git a/openssh/loginrec.h b/openssh/loginrec.h index a6a53c8..859e1a6 100644 --- a/openssh/loginrec.h +++ b/openssh/loginrec.h @@ -31,12 +31,6 @@ #include "includes.h" -#include -#include -#include - -/* RCSID("$Id$"); */ - /** ** you should use the login_* calls to work around platform dependencies **/ diff --git a/openssh/logintest.c b/openssh/logintest.c index 52f6fce..2950edb 100644 --- a/openssh/logintest.c +++ b/openssh/logintest.c @@ -31,6 +31,10 @@ #include #include +#include + +#include + #include #include #include @@ -43,8 +47,6 @@ #include "loginrec.h" -RCSID("$Id$"); - extern char *__progname; #define PAUSE_BEFORE_LOGOUT 3 diff --git a/openssh/mac.c b/openssh/mac.c index 2bda5a1..e5d5bfa 100644 --- a/openssh/mac.c +++ b/openssh/mac.c @@ -1,3 +1,4 @@ +/* $OpenBSD: mac.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,16 +24,23 @@ */ #include "includes.h" -RCSID("$OpenBSD: mac.c,v 1.7 2005/06/17 02:44:32 djm Exp $"); + +#include #include +#include +#include +#include + #include "xmalloc.h" -#include "getput.h" #include "log.h" #include "cipher.h" +#include "buffer.h" +#include "key.h" #include "kex.h" #include "mac.h" +#include "misc.h" struct { char *name; @@ -83,7 +91,7 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen) if (mac->mac_len > sizeof(m)) fatal("mac_compute: mac too long"); HMAC_Init(&c, mac->key, mac->key_len, mac->md); - PUT_32BIT(b, seqno); + put_u32(b, seqno); HMAC_Update(&c, b, sizeof(b)); HMAC_Update(&c, data, datalen); HMAC_Final(&c, m, NULL); diff --git a/openssh/mac.h b/openssh/mac.h index 43b485d..960cc5c 100644 --- a/openssh/mac.h +++ b/openssh/mac.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mac.h,v 1.3 2001/06/26 17:27:24 markus Exp $ */ +/* $OpenBSD: mac.h,v 1.4 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * diff --git a/openssh/match.c b/openssh/match.c index 29fb7da..e3c9930 100644 --- a/openssh/match.c +++ b/openssh/match.c @@ -1,3 +1,4 @@ +/* $OpenBSD: match.c,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,10 +36,14 @@ */ #include "includes.h" -RCSID("$OpenBSD: match.c,v 1.20 2005/06/17 02:44:32 djm Exp $"); -#include "match.h" +#include + +#include +#include + #include "xmalloc.h" +#include "match.h" /* * Returns true if the given string matches the pattern (which may contain ? @@ -136,7 +141,7 @@ match_pattern_list(const char *string, const char *pattern, u_int len, i < len && subi < sizeof(sub) - 1 && pattern[i] != ','; subi++, i++) sub[subi] = dolower && isupper(pattern[i]) ? - tolower(pattern[i]) : pattern[i]; + (char)tolower(pattern[i]) : pattern[i]; /* If subpattern too long, return failure (no match). */ if (subi >= sizeof(sub) - 1) return 0; diff --git a/openssh/match.h b/openssh/match.h index a0764e0..d1d5386 100644 --- a/openssh/match.h +++ b/openssh/match.h @@ -1,4 +1,4 @@ -/* $OpenBSD: match.h,v 1.12 2002/03/01 13:12:10 markus Exp $ */ +/* $OpenBSD: match.h,v 1.13 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/md-sha256.c b/openssh/md-sha256.c new file mode 100644 index 0000000..8c1b3b9 --- /dev/null +++ b/openssh/md-sha256.c @@ -0,0 +1,86 @@ +/* $OpenBSD: md-sha256.c,v 1.5 2006/08/03 03:34:42 deraadt Exp $ */ +/* + * Copyright (c) 2005 Damien 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +/* EVP wrapper for SHA256 */ + +#include "includes.h" + +#include +#include + +#if !defined(HAVE_EVP_SHA256) && (OPENSSL_VERSION_NUMBER >= 0x00907000L) + +#include +#include +#ifdef HAVE_SHA256_UPDATE +# ifdef HAVE_SHA2_H +# include +# elif defined(HAVE_CRYPTO_SHA2_H) +# include +# endif +#endif + +const EVP_MD *evp_ssh_sha256(void); + +static int +ssh_sha256_init(EVP_MD_CTX *ctxt) +{ + SHA256_Init(ctxt->md_data); + return (1); +} + +static int +ssh_sha256_update(EVP_MD_CTX *ctxt, const void *data, unsigned long len) +{ + SHA256_Update(ctxt->md_data, data, len); + return (1); +} + +static int +ssh_sha256_final(EVP_MD_CTX *ctxt, unsigned char *digest) +{ + SHA256_Final(digest, ctxt->md_data); + return (1); +} + +static int +ssh_sha256_cleanup(EVP_MD_CTX *ctxt) +{ + memset(ctxt->md_data, 0, sizeof(SHA256_CTX)); + return (1); +} + +const EVP_MD * +evp_ssh_sha256(void) +{ + static EVP_MD ssh_sha256; + + memset(&ssh_sha256, 0, sizeof(ssh_sha256)); + ssh_sha256.type = NID_undef; + ssh_sha256.md_size = SHA256_DIGEST_LENGTH; + ssh_sha256.init = ssh_sha256_init; + ssh_sha256.update = ssh_sha256_update; + ssh_sha256.final = ssh_sha256_final; + ssh_sha256.cleanup = ssh_sha256_cleanup; + ssh_sha256.block_size = SHA256_BLOCK_LENGTH; + ssh_sha256.ctx_size = sizeof(SHA256_CTX); + + return (&ssh_sha256); +} + +#endif /* !defined(HAVE_EVP_SHA256) && (OPENSSL_VERSION_NUMBER >= 0x00907000L) */ + diff --git a/openssh/md5crypt.c b/openssh/md5crypt.c index 2833698..22ef989 100644 --- a/openssh/md5crypt.c +++ b/openssh/md5crypt.c @@ -11,9 +11,11 @@ #include "includes.h" #if defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) -#include +#include + +#include -RCSID("$Id$"); +#include /* 0 ... 63 => ascii - 64 */ static unsigned char itoa64[] = diff --git a/openssh/misc.c b/openssh/misc.c index fd9c392..d3f9003 100644 --- a/openssh/misc.c +++ b/openssh/misc.c @@ -1,6 +1,7 @@ +/* $OpenBSD: misc.c,v 1.64 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. - * Copyright (c) 2005 Damien Miller. All rights reserved. + * Copyright (c) 2005,2006 Damien Miller. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -24,15 +25,35 @@ */ #include "includes.h" -RCSID("$OpenBSD: misc.c,v 1.42 2006/01/31 10:19:02 djm Exp $"); +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#ifdef HAVE_PATHS_H +# include +#include +#endif #ifdef SSH_TUN_OPENBSD #include #endif +#include "xmalloc.h" #include "misc.h" #include "log.h" -#include "xmalloc.h" +#include "ssh.h" /* remove newline at end of string */ char * @@ -123,6 +144,7 @@ set_nodelay(int fd) /* Characters considered whitespace in strsep calls. */ #define WHITESPACE " \t\r\n" +#define QUOTE "\"" /* Characters considered as quotations. */ #define QUOTES "'\"" @@ -154,15 +176,27 @@ strdelim(char **s) return (old); } - *s = strpbrk(*s, WHITESPACE "="); + *s = strpbrk(*s, WHITESPACE QUOTE "="); if (*s == NULL) return (old); + if (*s[0] == '\"') { + memmove(*s, *s + 1, strlen(*s)); /* move nul too */ + /* Find matching quote */ + if ((*s = strpbrk(*s, QUOTE)) == NULL) { + return (NULL); /* no matching quote */ + } else { + *s[0] = '\0'; + return (old); + } + } + /* Allow only one '=' to be skipped */ if (*s[0] == '=') wspace = 1; *s[0] = '\0'; + /* Skip any extra whitespace after first token */ *s += strspn(*s + 1, WHITESPACE) + 1; if (*s[0] == '=' && !wspace) *s += strspn(*s + 1, WHITESPACE) + 1; @@ -173,9 +207,8 @@ strdelim(char **s) struct passwd * pwcopy(struct passwd *pw) { - struct passwd *copy = xmalloc(sizeof(*copy)); + struct passwd *copy = xcalloc(1, sizeof(*copy)); - memset(copy, 0, sizeof(*copy)); copy->pw_name = xstrdup(pw->pw_name); copy->pw_passwd = xstrdup(pw->pw_passwd); copy->pw_gecos = xstrdup(pw->pw_gecos); @@ -298,6 +331,7 @@ convtime(const char *s) switch (*endp++) { case '\0': endp--; + break; case 's': case 'S': break; @@ -329,6 +363,23 @@ convtime(const char *s) return total; } +/* + * Returns a standardized host+port identifier string. + * Caller must free returned string. + */ +char * +put_host_port(const char *host, u_short port) +{ + char *hoststr; + + if (port == 0 || port == SSH_DEFAULT_PORT) + return(xstrdup(host)); + if (asprintf(&hoststr, "[%s]:%d", host, (int)port) < 0) + fatal("put_host_port: asprintf: %s", strerror(errno)); + debug3("put_host_port: %s", hoststr); + return hoststr; +} + /* * Search for next delimiter between hostnames/addresses and ports. * Argument may be modified (for termination). @@ -426,7 +477,7 @@ addargs(arglist *args, char *fmt, ...) } else if (args->num+2 >= nalloc) nalloc *= 2; - args->list = xrealloc(args->list, nalloc * sizeof(char *)); + args->list = xrealloc(args->list, nalloc, sizeof(char *)); args->nalloc = nalloc; args->list[args->num++] = cp; args->list[args->num] = NULL; @@ -691,18 +742,100 @@ sanitise_stdfd(void) } char * -tohex(const u_char *d, u_int l) +tohex(const void *vp, size_t l) { + const u_char *p = (const u_char *)vp; char b[3], *r; - u_int i, hl; + size_t i, hl; + + if (l > 65536) + return xstrdup("tohex: length > 65536"); hl = l * 2 + 1; - r = xmalloc(hl); - *r = '\0'; + r = xcalloc(1, hl); for (i = 0; i < l; i++) { - snprintf(b, sizeof(b), "%02x", d[i]); + snprintf(b, sizeof(b), "%02x", p[i]); strlcat(r, b, hl); } return (r); } +u_int64_t +get_u64(const void *vp) +{ + const u_char *p = (const u_char *)vp; + u_int64_t v; + + v = (u_int64_t)p[0] << 56; + v |= (u_int64_t)p[1] << 48; + v |= (u_int64_t)p[2] << 40; + v |= (u_int64_t)p[3] << 32; + v |= (u_int64_t)p[4] << 24; + v |= (u_int64_t)p[5] << 16; + v |= (u_int64_t)p[6] << 8; + v |= (u_int64_t)p[7]; + + return (v); +} + +u_int32_t +get_u32(const void *vp) +{ + const u_char *p = (const u_char *)vp; + u_int32_t v; + + v = (u_int32_t)p[0] << 24; + v |= (u_int32_t)p[1] << 16; + v |= (u_int32_t)p[2] << 8; + v |= (u_int32_t)p[3]; + + return (v); +} + +u_int16_t +get_u16(const void *vp) +{ + const u_char *p = (const u_char *)vp; + u_int16_t v; + + v = (u_int16_t)p[0] << 8; + v |= (u_int16_t)p[1]; + + return (v); +} + +void +put_u64(void *vp, u_int64_t v) +{ + u_char *p = (u_char *)vp; + + p[0] = (u_char)(v >> 56) & 0xff; + p[1] = (u_char)(v >> 48) & 0xff; + p[2] = (u_char)(v >> 40) & 0xff; + p[3] = (u_char)(v >> 32) & 0xff; + p[4] = (u_char)(v >> 24) & 0xff; + p[5] = (u_char)(v >> 16) & 0xff; + p[6] = (u_char)(v >> 8) & 0xff; + p[7] = (u_char)v & 0xff; +} + +void +put_u32(void *vp, u_int32_t v) +{ + u_char *p = (u_char *)vp; + + p[0] = (u_char)(v >> 24) & 0xff; + p[1] = (u_char)(v >> 16) & 0xff; + p[2] = (u_char)(v >> 8) & 0xff; + p[3] = (u_char)v & 0xff; +} + + +void +put_u16(void *vp, u_int16_t v) +{ + u_char *p = (u_char *)vp; + + p[0] = (u_char)(v >> 8) & 0xff; + p[1] = (u_char)v & 0xff; +} diff --git a/openssh/misc.h b/openssh/misc.h index 0a1a09a..f175b44 100644 --- a/openssh/misc.h +++ b/openssh/misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.h,v 1.29 2006/01/31 10:19:02 djm Exp $ */ +/* $OpenBSD: misc.h,v 1.36 2006/08/18 10:27:16 djm Exp $ */ /* * Author: Tatu Ylonen @@ -12,6 +12,9 @@ * called by a name other than "ssh" or "Secure Shell". */ +#ifndef _MISC_H +#define _MISC_H + /* misc.c */ char *chop(char *); @@ -21,13 +24,14 @@ int unset_nonblock(int); void set_nodelay(int); int a2port(const char *); int a2tun(const char *, int *); +char *put_host_port(const char *, u_short); char *hpdelim(char **); char *cleanhostname(char *); char *colon(char *); long convtime(const char *); char *tilde_expand_filename(const char *, uid_t); char *percent_expand(const char *, ...) __attribute__((__sentinel__)); -char *tohex(const u_char *, u_int); +char *tohex(const void *, size_t); void sanitise_stdfd(void); struct passwd *pwcopy(struct passwd *); @@ -44,17 +48,6 @@ void replacearg(arglist *, u_int, char *, ...) __attribute__((format(printf, 3, 4))); void freeargs(arglist *); -/* readpass.c */ - -#define RP_ECHO 0x0001 -#define RP_ALLOW_STDIN 0x0002 -#define RP_ALLOW_EOF 0x0004 -#define RP_USE_ASKPASS 0x0008 - -char *read_passphrase(const char *, int); -int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2))); -int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *); - int tun_open(int, int); /* Common definitions for ssh tunnel device forwarding */ @@ -67,3 +60,31 @@ int tun_open(int, int); #define SSH_TUNID_ANY 0x7fffffff #define SSH_TUNID_ERR (SSH_TUNID_ANY - 1) #define SSH_TUNID_MAX (SSH_TUNID_ANY - 2) + +/* Functions to extract or store big-endian words of various sizes */ +u_int64_t get_u64(const void *) + __attribute__((__bounded__( __minbytes__, 1, 8))); +u_int32_t get_u32(const void *) + __attribute__((__bounded__( __minbytes__, 1, 4))); +u_int16_t get_u16(const void *) + __attribute__((__bounded__( __minbytes__, 1, 2))); +void put_u64(void *, u_int64_t) + __attribute__((__bounded__( __minbytes__, 1, 8))); +void put_u32(void *, u_int32_t) + __attribute__((__bounded__( __minbytes__, 1, 4))); +void put_u16(void *, u_int16_t) + __attribute__((__bounded__( __minbytes__, 1, 2))); + + +/* readpass.c */ + +#define RP_ECHO 0x0001 +#define RP_ALLOW_STDIN 0x0002 +#define RP_ALLOW_EOF 0x0004 +#define RP_USE_ASKPASS 0x0008 + +char *read_passphrase(const char *, int); +int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2))); +int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *); + +#endif /* _MISC_H */ diff --git a/openssh/moduli.c b/openssh/moduli.c index d53806e..44e5ddf 100644 --- a/openssh/moduli.c +++ b/openssh/moduli.c @@ -1,4 +1,4 @@ -/* $OpenBSD: moduli.c,v 1.12 2005/07/17 07:17:55 djm Exp $ */ +/* $OpenBSD: moduli.c,v 1.19 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright 1994 Phil Karn * Copyright 1996-1998, 2003 William Allen Simpson @@ -38,11 +38,20 @@ */ #include "includes.h" -#include "xmalloc.h" -#include "log.h" + +#include #include +#include +#include +#include +#include +#include + +#include "xmalloc.h" +#include "log.h" + /* * File output defines */ @@ -301,21 +310,10 @@ gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start) largewords = (largememory << SHIFT_MEGAWORD); } - TinySieve = calloc(tinywords, sizeof(u_int32_t)); - if (TinySieve == NULL) { - error("Insufficient memory for tiny sieve: need %u bytes", - tinywords << SHIFT_BYTE); - exit(1); - } + TinySieve = xcalloc(tinywords, sizeof(u_int32_t)); tinybits = tinywords << SHIFT_WORD; - SmallSieve = calloc(smallwords, sizeof(u_int32_t)); - if (SmallSieve == NULL) { - error("Insufficient memory for small sieve: need %u bytes", - smallwords << SHIFT_BYTE); - xfree(TinySieve); - exit(1); - } + SmallSieve = xcalloc(smallwords, sizeof(u_int32_t)); smallbits = smallwords << SHIFT_WORD; /* @@ -329,20 +327,26 @@ gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start) /* validation check: count the number of primes tried */ largetries = 0; - q = BN_new(); + if ((q = BN_new()) == NULL) + fatal("BN_new failed"); /* * Generate random starting point for subprime search, or use * specified parameter. */ - largebase = BN_new(); - if (start == NULL) - BN_rand(largebase, power, 1, 1); - else - BN_copy(largebase, start); + if ((largebase = BN_new()) == NULL) + fatal("BN_new failed"); + if (start == NULL) { + if (BN_rand(largebase, power, 1, 1) == 0) + fatal("BN_rand failed"); + } else { + if (BN_copy(largebase, start) == NULL) + fatal("BN_copy: failed"); + } /* ensure odd */ - BN_set_bit(largebase, 0); + if (BN_set_bit(largebase, 0) == 0) + fatal("BN_set_bit: failed"); time(&time_start); @@ -426,8 +430,10 @@ gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start) continue; /* Definitely composite, skip */ debug2("test q = largebase+%u", 2 * j); - BN_set_word(q, 2 * j); - BN_add(q, q, largebase); + if (BN_set_word(q, 2 * j) == 0) + fatal("BN_set_word failed"); + if (BN_add(q, q, largebase) == 0) + fatal("BN_add failed"); if (qfileout(out, QTYPE_SOPHIE_GERMAIN, QTEST_SIEVE, largetries, (power - 1) /* MSB */, (0), q) == -1) { ret = -1; @@ -472,9 +478,12 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted) time(&time_start); - p = BN_new(); - q = BN_new(); - ctx = BN_CTX_new(); + if ((p = BN_new()) == NULL) + fatal("BN_new failed"); + if ((q = BN_new()) == NULL) + fatal("BN_new failed"); + if ((ctx = BN_CTX_new()) == NULL) + fatal("BN_CTX_new failed"); debug2("%.24s Final %u Miller-Rabin trials (%x generator)", ctime(&time_start), trials, generator_wanted); @@ -522,10 +531,13 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted) case QTYPE_SOPHIE_GERMAIN: debug2("%10u: (%u) Sophie-Germain", count_in, in_type); a = q; - BN_hex2bn(&a, cp); + if (BN_hex2bn(&a, cp) == 0) + fatal("BN_hex2bn failed"); /* p = 2*q + 1 */ - BN_lshift(p, q, 1); - BN_add_word(p, 1); + if (BN_lshift(p, q, 1) == 0) + fatal("BN_lshift failed"); + if (BN_add_word(p, 1) == 0) + fatal("BN_add_word failed"); in_size += 1; generator_known = 0; break; @@ -536,9 +548,11 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted) case QTYPE_UNKNOWN: debug2("%10u: (%u)", count_in, in_type); a = p; - BN_hex2bn(&a, cp); + if (BN_hex2bn(&a, cp) == 0) + fatal("BN_hex2bn failed"); /* q = (p-1) / 2 */ - BN_rshift(q, p, 1); + if (BN_rshift(q, p, 1) == 0) + fatal("BN_rshift failed"); break; default: debug2("Unknown prime type"); diff --git a/openssh/monitor.c b/openssh/monitor.c index 0c93d7d..17c5e00 100644 --- a/openssh/monitor.c +++ b/openssh/monitor.c @@ -1,3 +1,4 @@ +/* $OpenBSD: monitor.c,v 1.89 2006/11/07 10:31:31 markus Exp $ */ /* * Copyright 2002 Niels Provos * Copyright 2002 Markus Friedl @@ -25,16 +26,38 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor.c,v 1.64 2005/10/13 22:24:31 stevesk Exp $"); -#include +#include +#include +#include +#include "openbsd-compat/sys-tree.h" +#include + +#include +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include #ifdef SKEY #include #endif +#include + +#include "xmalloc.h" #include "ssh.h" +#include "key.h" +#include "buffer.h" +#include "hostfile.h" #include "auth.h" +#include "cipher.h" #include "kex.h" #include "dh.h" #ifdef TARGET_OS_MAC /* XXX Broken krb5 headers on Mac */ @@ -55,17 +78,16 @@ RCSID("$OpenBSD: monitor.c,v 1.64 2005/10/13 22:24:31 stevesk Exp $"); #include "servconf.h" #include "monitor.h" #include "monitor_mm.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "monitor_fdpass.h" -#include "xmalloc.h" #include "misc.h" -#include "buffer.h" -#include "bufaux.h" #include "compat.h" #include "ssh2.h" #ifdef GSSAPI -#include "ssh-gss.h" static Gssctxt *gsscontext = NULL; #endif @@ -175,6 +197,7 @@ struct mon_table { #define MON_ISAUTH 0x0004 /* Required for Authentication */ #define MON_AUTHDECIDE 0x0008 /* Decides Authentication */ #define MON_ONCE 0x0010 /* Disable after calling */ +#define MON_ALOG 0x0020 /* Log auth attempt without authenticating */ #define MON_AUTH (MON_ISAUTH|MON_AUTHDECIDE) @@ -200,7 +223,7 @@ struct mon_table mon_dispatch_proto20[] = { #endif #ifdef BSD_AUTH {MONITOR_REQ_BSDAUTHQUERY, MON_ISAUTH, mm_answer_bsdauthquery}, - {MONITOR_REQ_BSDAUTHRESPOND, MON_AUTH,mm_answer_bsdauthrespond}, + {MONITOR_REQ_BSDAUTHRESPOND, MON_AUTH, mm_answer_bsdauthrespond}, #endif #ifdef SKEY {MONITOR_REQ_SKEYQUERY, MON_ISAUTH, mm_answer_skeyquery}, @@ -246,13 +269,13 @@ struct mon_table mon_dispatch_proto15[] = { {MONITOR_REQ_SESSKEY, MON_ONCE, mm_answer_sesskey}, {MONITOR_REQ_SESSID, MON_ONCE, mm_answer_sessid}, {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, - {MONITOR_REQ_RSAKEYALLOWED, MON_ISAUTH, mm_answer_rsa_keyallowed}, - {MONITOR_REQ_KEYALLOWED, MON_ISAUTH, mm_answer_keyallowed}, + {MONITOR_REQ_RSAKEYALLOWED, MON_ISAUTH|MON_ALOG, mm_answer_rsa_keyallowed}, + {MONITOR_REQ_KEYALLOWED, MON_ISAUTH|MON_ALOG, mm_answer_keyallowed}, {MONITOR_REQ_RSACHALLENGE, MON_ONCE, mm_answer_rsa_challenge}, {MONITOR_REQ_RSARESPONSE, MON_ONCE|MON_AUTHDECIDE, mm_answer_rsa_response}, #ifdef BSD_AUTH {MONITOR_REQ_BSDAUTHQUERY, MON_ISAUTH, mm_answer_bsdauthquery}, - {MONITOR_REQ_BSDAUTHRESPOND, MON_AUTH,mm_answer_bsdauthrespond}, + {MONITOR_REQ_BSDAUTHRESPOND, MON_AUTH, mm_answer_bsdauthrespond}, #endif #ifdef SKEY {MONITOR_REQ_SKEYQUERY, MON_ISAUTH, mm_answer_skeyquery}, @@ -285,7 +308,7 @@ struct mon_table mon_dispatch_postauth15[] = { {MONITOR_REQ_TERM, 0, mm_answer_term}, #ifdef SSH_AUDIT_EVENTS {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, - {MONITOR_REQ_AUDIT_COMMAND, MON_ONCE, mm_answer_audit_command}, + {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, #endif {0, 0, NULL} }; @@ -354,7 +377,8 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) /* The first few requests do not require asynchronous access */ while (!authenticated) { - authenticated = monitor_read(pmonitor, mon_dispatch, &ent); + auth_method = "unknown"; + authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); if (authenticated) { if (!(ent->flags & MON_AUTHDECIDE)) fatal("%s: unexpected authentication from %d", @@ -376,7 +400,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) #endif } - if (ent->flags & MON_AUTHDECIDE) { + if (ent->flags & (MON_AUTHDECIDE|MON_ALOG)) { auth_log(authctxt, authenticated, auth_method, compat20 ? " ssh2" : ""); if (!authenticated) @@ -386,6 +410,8 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) if (!authctxt->valid) fatal("%s: authenticated invalid user", __func__); + if (strcmp(auth_method, "unknown") == 0) + fatal("%s: authentication method name unknown", __func__); debug("%s: %s has been authenticated by privileged process", __func__, authctxt->user); @@ -576,7 +602,11 @@ mm_answer_sign(int sock, Buffer *m) keyid = buffer_get_int(m); p = buffer_get_string(m, &datlen); - if (datlen != 20) + /* + * Supported KEX types will only return SHA1 (20 byte) or + * SHA256 (32 byte) hashes + */ + if (datlen != 20 && datlen != 32) fatal("%s: data length incorrect: %u", __func__, datlen); /* save session id, it will be passed on the first call */ @@ -667,9 +697,6 @@ mm_answer_pwnamallow(int sock, Buffer *m) if (options.use_pam) monitor_permit(mon_dispatch, MONITOR_REQ_PAM_START, 1); #endif -#ifdef SSH_AUDIT_EVENTS - monitor_permit(mon_dispatch, MONITOR_REQ_AUDIT_COMMAND, 1); -#endif return (0); } @@ -930,6 +957,7 @@ mm_answer_pam_query(int sock, Buffer *m) xfree(prompts); if (echo_on != NULL) xfree(echo_on); + auth_method = "keyboard-interactive/pam"; mm_request_send(sock, MONITOR_ANS_PAM_QUERY, m); return (0); } @@ -945,7 +973,7 @@ mm_answer_pam_respond(int sock, Buffer *m) sshpam_authok = NULL; num = buffer_get_int(m); if (num > 0) { - resp = xmalloc(num * sizeof(char *)); + resp = xcalloc(num, sizeof(char *)); for (i = 0; i < num; ++i) resp[i] = buffer_get_string(m, NULL); ret = (sshpam_device.respond)(sshpam_ctxt, num, resp); @@ -972,6 +1000,7 @@ mm_answer_pam_free_ctx(int sock, Buffer *m) (sshpam_device.free_ctx)(sshpam_ctxt); buffer_clear(m); mm_request_send(sock, MONITOR_ANS_PAM_FREE_CTX, m); + auth_method = "keyboard-interactive/pam"; return (sshpam_authok == sshpam_ctxt); } #endif @@ -1017,17 +1046,20 @@ mm_answer_keyallowed(int sock, Buffer *m) case MM_USERKEY: allowed = options.pubkey_authentication && user_key_allowed(authctxt->pw, key); + auth_method = "publickey"; break; case MM_HOSTKEY: allowed = options.hostbased_authentication && hostbased_key_allowed(authctxt->pw, cuser, chost, key); + auth_method = "hostbased"; break; case MM_RSAHOSTKEY: key->type = KEY_RSA1; /* XXX */ allowed = options.rhosts_rsa_authentication && auth_rhosts_rsa_key_allowed(authctxt->pw, cuser, chost, key); + auth_method = "rsa"; break; default: fatal("%s: unknown key type %d", __func__, type); @@ -1047,6 +1079,12 @@ mm_answer_keyallowed(int sock, Buffer *m) key_blobtype = type; hostbased_cuser = cuser; hostbased_chost = chost; + } else { + /* Log failed attempt */ + auth_log(authctxt, 0, auth_method, compat20 ? " ssh2" : ""); + xfree(blob); + xfree(cuser); + xfree(chost); } debug3("%s: key %p is %s", @@ -1216,7 +1254,7 @@ mm_answer_keyverify(int sock, Buffer *m) verified = key_verify(key, signature, signaturelen, data, datalen); debug3("%s: key %p signature %s", - __func__, key, verified ? "verified" : "unverified"); + __func__, key, (verified == 1) ? "verified" : "unverified"); key_free(key); xfree(blob); @@ -1231,7 +1269,7 @@ mm_answer_keyverify(int sock, Buffer *m) buffer_put_int(m, verified); mm_request_send(sock, MONITOR_ANS_KEYVERIFY, m); - return (verified); + return (verified == 1); } static void @@ -1248,7 +1286,7 @@ mm_record_login(Session *s, struct passwd *pw) fromlen = sizeof(from); if (packet_connection_is_on_socket()) { if (getpeername(packet_get_connection_in(), - (struct sockaddr *) & from, &fromlen) < 0) { + (struct sockaddr *)&from, &fromlen) < 0) { debug("getpeername: %.100s", strerror(errno)); cleanup_exit(255); } @@ -1264,7 +1302,7 @@ mm_session_close(Session *s) { debug3("%s: session %d pid %ld", __func__, s->self, (long)s->pid); if (s->ttyfd != -1) { - debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ptyfd); + debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ptyfd); session_pty_cleanup2(s); } s->used = 0; @@ -1324,7 +1362,7 @@ mm_answer_pty(int sock, Buffer *m) /* no need to dup() because nobody closes ptyfd */ s->ptymaster = s->ptyfd; - debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ttyfd); + debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ttyfd); return (0); @@ -1411,6 +1449,7 @@ mm_answer_rsa_keyallowed(int sock, Buffer *m) debug3("%s entering", __func__); + auth_method = "rsa"; if (options.rsa_authentication && authctxt->valid) { if ((client_n = BN_new()) == NULL) fatal("%s: BN_new", __func__); @@ -1647,8 +1686,7 @@ mm_get_kex(Buffer *m) void *blob; u_int bloblen; - kex = xmalloc(sizeof(*kex)); - memset(kex, 0, sizeof(*kex)); + kex = xcalloc(1, sizeof(*kex)); kex->session_id = buffer_get_string(m, &kex->session_id_len); if ((session_id2 == NULL) || (kex->session_id_len != session_id2_len) || @@ -1658,8 +1696,10 @@ mm_get_kex(Buffer *m) kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; + kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; #ifdef GSSAPI kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; #endif kex->server = 1; @@ -1821,9 +1861,8 @@ monitor_init(void) struct monitor *mon; int pair[2]; - mon = xmalloc(sizeof(*mon)); + mon = xcalloc(1, sizeof(*mon)); - mon->m_pid = 0; monitor_socketpair(pair); mon->m_recvfd = pair[0]; @@ -2057,5 +2096,4 @@ mm_answer_gss_localname(int socket, Buffer *m) { return(0); } - #endif /* GSSAPI */ diff --git a/openssh/monitor.h b/openssh/monitor.h index cb92f14..c1b32a3 100644 --- a/openssh/monitor.h +++ b/openssh/monitor.h @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.h,v 1.13 2003/11/17 11:06:07 markus Exp $ */ +/* $OpenBSD: monitor.h,v 1.14 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright 2002 Niels Provos diff --git a/openssh/monitor_fdpass.c b/openssh/monitor_fdpass.c index dd1a139..9f8e9cd 100644 --- a/openssh/monitor_fdpass.c +++ b/openssh/monitor_fdpass.c @@ -1,3 +1,4 @@ +/* $OpenBSD: monitor_fdpass.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright 2001 Niels Provos * All rights reserved. @@ -24,9 +25,17 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor_fdpass.c,v 1.6 2004/08/13 02:51:48 djm Exp $"); +#include +#include #include +#ifdef HAVE_SYS_UN_H +#include +#endif + +#include +#include +#include #include "log.h" #include "monitor_fdpass.h" diff --git a/openssh/monitor_fdpass.h b/openssh/monitor_fdpass.h index 31d080e..12c67ec 100644 --- a/openssh/monitor_fdpass.h +++ b/openssh/monitor_fdpass.h @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_fdpass.h,v 1.2 2002/03/26 03:24:01 stevesk Exp $ */ +/* $OpenBSD: monitor_fdpass.h,v 1.3 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright 2002 Niels Provos diff --git a/openssh/monitor_mm.c b/openssh/monitor_mm.c index b0ec37c..dab7475 100644 --- a/openssh/monitor_mm.c +++ b/openssh/monitor_mm.c @@ -1,3 +1,4 @@ +/* $OpenBSD: monitor_mm.c,v 1.15 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -24,14 +25,20 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor_mm.c,v 1.9 2004/05/11 19:01:43 deraadt Exp $"); +#include #ifdef HAVE_SYS_MMAN_H #include #endif +#include +#include "openbsd-compat/sys-tree.h" + +#include +#include +#include -#include "ssh.h" #include "xmalloc.h" +#include "ssh.h" #include "log.h" #include "monitor_mm.h" diff --git a/openssh/monitor_mm.h b/openssh/monitor_mm.h index a1323b9..36a07a0 100644 --- a/openssh/monitor_mm.h +++ b/openssh/monitor_mm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_mm.h,v 1.2 2002/03/26 03:24:01 stevesk Exp $ */ +/* $OpenBSD: monitor_mm.h,v 1.4 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright 2002 Niels Provos @@ -27,7 +27,6 @@ #ifndef _MM_H_ #define _MM_H_ -#include "openbsd-compat/sys-tree.h" struct mm_share { RB_ENTRY(mm_share) next; diff --git a/openssh/monitor_wrap.c b/openssh/monitor_wrap.c index efd13f9..6366075 100644 --- a/openssh/monitor_wrap.c +++ b/openssh/monitor_wrap.c @@ -1,3 +1,4 @@ +/* $OpenBSD: monitor_wrap.c,v 1.54 2006/08/12 20:46:46 miod Exp $ */ /* * Copyright 2002 Niels Provos * Copyright 2002 Markus Friedl @@ -25,18 +26,31 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor_wrap.c,v 1.40 2005/05/24 17:32:43 avsm Exp $"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include #include #include +#include "xmalloc.h" #include "ssh.h" #include "dh.h" +#include "buffer.h" +#include "key.h" +#include "cipher.h" #include "kex.h" +#include "hostfile.h" #include "auth.h" #include "auth-options.h" -#include "buffer.h" -#include "bufaux.h" #include "packet.h" #include "mac.h" #include "log.h" @@ -48,21 +62,18 @@ RCSID("$OpenBSD: monitor_wrap.c,v 1.40 2005/05/24 17:32:43 avsm Exp $"); #include "zlib.h" #endif #include "monitor.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" -#include "xmalloc.h" #include "atomicio.h" #include "monitor_fdpass.h" -#include "getput.h" +#include "misc.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[]; @@ -91,7 +102,7 @@ mm_request_send(int sock, enum monitor_reqtype type, Buffer *m) debug3("%s entering: type %d", __func__, type); - PUT_32BIT(buf, mlen + 1); + put_u32(buf, mlen + 1); buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) fatal("%s: write: %s", __func__, strerror(errno)); @@ -112,7 +123,7 @@ mm_request_receive(int sock, Buffer *m) cleanup_exit(255); fatal("%s: read: %s", __func__, strerror(errno)); } - msg_len = GET_32BIT(buf); + msg_len = get_u32(buf); if (msg_len > 256 * 1024) fatal("%s: read: bad msg_len %d", __func__, msg_len); buffer_clear(m); @@ -637,7 +648,7 @@ mm_send_keystate(struct monitor *monitor) } int -mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) +mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen) { Buffer m; char *p, *msg; @@ -776,8 +787,11 @@ mm_sshpam_query(void *ctx, char **name, char **info, *name = buffer_get_string(&m, NULL); *info = buffer_get_string(&m, NULL); *num = buffer_get_int(&m); - *prompts = xmalloc((*num + 1) * sizeof(char *)); - *echo_on = xmalloc((*num + 1) * sizeof(u_int)); + if (*num > PAM_MAX_NUM_MSG) + fatal("%s: recieved %u PAM messages, expected <= %u", + __func__, *num, PAM_MAX_NUM_MSG); + *prompts = xcalloc((*num + 1), sizeof(char *)); + *echo_on = xcalloc((*num + 1), sizeof(u_int)); for (i = 0; i < *num; ++i) { (*prompts)[i] = buffer_get_string(&m, NULL); (*echo_on)[i] = buffer_get_int(&m); @@ -860,8 +874,8 @@ mm_chall_setup(char **name, char **infotxt, u_int *numprompts, *name = xstrdup(""); *infotxt = xstrdup(""); *numprompts = 1; - *prompts = xmalloc(*numprompts * sizeof(char *)); - *echo_on = xmalloc(*numprompts * sizeof(u_int)); + *prompts = xcalloc(*numprompts, sizeof(char *)); + *echo_on = xcalloc(*numprompts, sizeof(u_int)); (*echo_on)[0] = 0; } @@ -928,9 +942,8 @@ mm_skey_query(void *ctx, char **name, char **infotxt, u_int *numprompts, char ***prompts, u_int **echo_on) { Buffer m; - int len; u_int success; - char *p, *challenge; + char *challenge; debug3("%s: entering", __func__); @@ -954,11 +967,7 @@ mm_skey_query(void *ctx, char **name, char **infotxt, mm_chall_setup(name, infotxt, numprompts, prompts, echo_on); - len = strlen(challenge) + strlen(SKEY_PROMPT) + 1; - p = xmalloc(len); - strlcpy(p, challenge, len); - strlcat(p, SKEY_PROMPT, len); - (*prompts)[0] = p; + xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT); xfree(challenge); return (0); diff --git a/openssh/monitor_wrap.h b/openssh/monitor_wrap.h index ab05333..46fd2a5 100644 --- a/openssh/monitor_wrap.h +++ b/openssh/monitor_wrap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_wrap.h,v 1.14 2004/06/21 17:36:31 avsm Exp $ */ +/* $OpenBSD: monitor_wrap.h,v 1.20 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright 2002 Niels Provos @@ -27,8 +27,6 @@ #ifndef _MM_WRAP_H_ #define _MM_WRAP_H_ -#include "key.h" -#include "buffer.h" extern int use_privsep; #define PRIVSEP(x) (use_privsep ? mm_##x : x) @@ -37,7 +35,6 @@ enum mm_keytype {MM_NOKEY, MM_HOSTKEY, MM_USERKEY, MM_RSAHOSTKEY, MM_RSAUSERKEY} struct monitor; struct mm_master; -struct passwd; struct Authctxt; int mm_is_monitor(void); @@ -57,7 +54,6 @@ 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 **, gss_OID); OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *, gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); @@ -87,7 +83,7 @@ void mm_audit_run_command(const char *); struct Session; void mm_terminate(void); -int mm_pty_allocate(int *, int *, char *, int); +int mm_pty_allocate(int *, int *, char *, size_t); void mm_session_pty_cleanup2(struct Session *); /* SSHv1 interfaces */ @@ -116,4 +112,4 @@ void *mm_zalloc(struct mm_master *, u_int, u_int); void mm_zfree(struct mm_master *, void *); void mm_init_compression(struct mm_master *); -#endif /* _MM_H_ */ +#endif /* _MM_WRAP_H_ */ diff --git a/openssh/msg.c b/openssh/msg.c index 3e4c288..cd5f98c 100644 --- a/openssh/msg.c +++ b/openssh/msg.c @@ -1,3 +1,4 @@ +/* $OpenBSD: msg.c,v 1.15 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -21,14 +22,23 @@ * (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: msg.c,v 1.8 2005/05/24 17:32:43 avsm Exp $"); + +#include +#include + +#include +#include +#include +#include +#include #include "buffer.h" -#include "getput.h" #include "log.h" #include "atomicio.h" #include "msg.h" +#include "misc.h" int ssh_msg_send(int fd, u_char type, Buffer *m) @@ -38,7 +48,7 @@ ssh_msg_send(int fd, u_char type, Buffer *m) debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); - PUT_32BIT(buf, mlen + 1); + put_u32(buf, mlen + 1); buf[4] = type; /* 1st byte of payload is mesg-type */ if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { error("ssh_msg_send: write"); @@ -64,7 +74,7 @@ ssh_msg_recv(int fd, Buffer *m) error("ssh_msg_recv: read: header"); return (-1); } - msg_len = GET_32BIT(buf); + msg_len = get_u32(buf); if (msg_len > 256 * 1024) { error("ssh_msg_recv: read: bad msg_len %u", msg_len); return (-1); diff --git a/openssh/msg.h b/openssh/msg.h index 0d3ea06..b0cb9b5 100644 --- a/openssh/msg.h +++ b/openssh/msg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: msg.h,v 1.3 2003/11/17 09:45:39 djm Exp $ */ +/* $OpenBSD: msg.h,v 1.4 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * diff --git a/openssh/myproposal.h b/openssh/myproposal.h index 129d98c..f56ec50 100644 --- a/openssh/myproposal.h +++ b/openssh/myproposal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: myproposal.h,v 1.18 2005/07/25 11:59:39 markus Exp $ */ +/* $OpenBSD: myproposal.h,v 1.21 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -23,9 +23,23 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define KEX_DEFAULT_KEX "diffie-hellman-group-exchange-sha1," \ + +#include + +/* Old OpenSSL doesn't support what we need for DHGEX-sha256 */ +#if OPENSSL_VERSION_NUMBER < 0x00907000L +# define KEX_DEFAULT_KEX \ + "diffie-hellman-group-exchange-sha1," \ "diffie-hellman-group14-sha1," \ "diffie-hellman-group1-sha1" +#else +# define KEX_DEFAULT_KEX \ + "diffie-hellman-group-exchange-sha256," \ + "diffie-hellman-group-exchange-sha1," \ + "diffie-hellman-group14-sha1," \ + "diffie-hellman-group1-sha1" +#endif + #define KEX_DEFAULT_PK_ALG "ssh-rsa,ssh-dss" #define KEX_DEFAULT_ENCRYPT \ "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc," \ diff --git a/openssh/nchan.c b/openssh/nchan.c index aee3f37..ad461f4 100644 --- a/openssh/nchan.c +++ b/openssh/nchan.c @@ -1,3 +1,4 @@ +/* $OpenBSD: nchan.c,v 1.57 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. * @@ -23,7 +24,13 @@ */ #include "includes.h" -RCSID("$OpenBSD: nchan.c,v 1.51 2004/07/11 17:48:47 deraadt Exp $"); + +#include +#include + +#include +#include +#include #include "ssh1.h" #include "ssh2.h" diff --git a/openssh/openbsd-compat/Makefile.in b/openssh/openbsd-compat/Makefile.in index f164c6b..be1926b 100644 --- a/openssh/openbsd-compat/Makefile.in +++ b/openssh/openbsd-compat/Makefile.in @@ -16,11 +16,11 @@ RANLIB=@RANLIB@ INSTALL=@INSTALL@ LDFLAGS=-L. @LDFLAGS@ -OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o +OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o -PORTS=port-irix.o port-aix.o port-uw.o port-tun.o +PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) -c $< diff --git a/openssh/openbsd-compat/basename.c b/openssh/openbsd-compat/basename.c index ad040e1..ffa5c89 100644 --- a/openssh/openbsd-compat/basename.c +++ b/openssh/openbsd-compat/basename.c @@ -20,6 +20,8 @@ #include "includes.h" #ifndef HAVE_BASENAME +#include +#include char * basename(const char *path) diff --git a/openssh/openbsd-compat/bindresvport.c b/openssh/openbsd-compat/bindresvport.c index 7f48fd0..65afed1 100644 --- a/openssh/openbsd-compat/bindresvport.c +++ b/openssh/openbsd-compat/bindresvport.c @@ -33,8 +33,14 @@ #include "includes.h" #ifndef HAVE_BINDRESVPORT_SA +#include +#include -#include "includes.h" +#include +#include + +#include +#include #define STARTPORT 600 #define ENDPORT (IPPORT_RESERVED - 1) diff --git a/openssh/openbsd-compat/bsd-arc4random.c b/openssh/openbsd-compat/bsd-arc4random.c index 7c0f34d..d45fb18 100644 --- a/openssh/openbsd-compat/bsd-arc4random.c +++ b/openssh/openbsd-compat/bsd-arc4random.c @@ -15,9 +15,13 @@ */ #include "includes.h" -#include "log.h" -RCSID("$Id$"); +#include + +#include +#include + +#include "log.h" #ifndef HAVE_ARC4RANDOM diff --git a/openssh/openbsd-compat/bsd-asprintf.c b/openssh/openbsd-compat/bsd-asprintf.c index 5ca01f8..6748013 100644 --- a/openssh/openbsd-compat/bsd-asprintf.c +++ b/openssh/openbsd-compat/bsd-asprintf.c @@ -21,6 +21,10 @@ #ifndef HAVE_VASPRINTF +#include +#include +#include + #ifndef VA_COPY # ifdef HAVE_VA_COPY # define VA_COPY(dest, src) va_copy(dest, src) diff --git a/openssh/openbsd-compat/bsd-closefrom.c b/openssh/openbsd-compat/bsd-closefrom.c index 3d39447..9380b33 100644 --- a/openssh/openbsd-compat/bsd-closefrom.c +++ b/openssh/openbsd-compat/bsd-closefrom.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004 Todd C. Miller + * Copyright (c) 2004-2005 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 @@ -22,9 +22,14 @@ #include #include #include +#ifdef HAVE_FCNTL_H +# include +#endif #include #include #include +#include +#include #ifdef HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) @@ -46,15 +51,20 @@ # define OPEN_MAX 256 #endif -RCSID("$Id$"); - -#ifndef lint -static const char sudorcsid[] = "$Sudo: closefrom.c,v 1.6 2004/06/01 20:51:56 millert Exp $"; +#if 0 +__unused static const char rcsid[] = "$Sudo: closefrom.c,v 1.11 2006/08/17 15:26:54 millert Exp $"; #endif /* lint */ /* * Close all file descriptors greater than or equal to lowfd. */ +#ifdef HAVE_FCNTL_CLOSEM +void +closefrom(int lowfd) +{ + (void) fcntl(lowfd, F_CLOSEM, 0); +} +#else void closefrom(int lowfd) { @@ -67,7 +77,7 @@ closefrom(int lowfd) /* Check for a /proc/$$/fd directory. */ len = snprintf(fdpath, sizeof(fdpath), "/proc/%ld/fd", (long)getpid()); - if (len >= 0 && (u_int)len <= sizeof(fdpath) && (dirp = opendir(fdpath))) { + if (len > 0 && (size_t)len <= sizeof(fdpath) && (dirp = opendir(fdpath))) { while ((dent = readdir(dirp)) != NULL) { fd = strtol(dent->d_name, &endp, 10); if (dent->d_name != endp && *endp == '\0' && @@ -95,6 +105,5 @@ closefrom(int lowfd) (void) close((int) fd); } } - +#endif /* !HAVE_FCNTL_CLOSEM */ #endif /* HAVE_CLOSEFROM */ - diff --git a/openssh/openbsd-compat/bsd-cray.c b/openssh/openbsd-compat/bsd-cray.c index 8439d9b..fda00da 100644 --- a/openssh/openbsd-compat/bsd-cray.c +++ b/openssh/openbsd-compat/bsd-cray.c @@ -52,7 +52,10 @@ #include #include #include +#include #include +#include +#include #include #include #include diff --git a/openssh/openbsd-compat/bsd-cygwin_util.c b/openssh/openbsd-compat/bsd-cygwin_util.c index 94f63f1..dbf8176 100644 --- a/openssh/openbsd-compat/bsd-cygwin_util.c +++ b/openssh/openbsd-compat/bsd-cygwin_util.c @@ -29,15 +29,25 @@ #include "includes.h" -RCSID("$Id$"); - #ifdef HAVE_CYGWIN -#include -#include +#if defined(open) && open == binary_open +# undef open +#endif +#if defined(pipe) && open == binary_pipe +# undef pipe +#endif + +#include +#include #include #include + +#include +#include +#include #include + #include "xmalloc.h" #define is_winnt (GetVersion() < 0x80000000) @@ -45,13 +55,6 @@ RCSID("$Id$"); #define ntsec_off(c) ((c) && strstr((c),"nontsec")) #define ntea_on(c) ((c) && strstr((c),"ntea") && !strstr((c),"nontea")) -#if defined(open) && open == binary_open -# undef open -#endif -#if defined(pipe) && open == binary_pipe -# undef pipe -#endif - int binary_open(const char *filename, int flags, ...) { @@ -268,9 +271,9 @@ char ** fetch_windows_environment(void) { char **e, **p; - int i, idx = 0; + unsigned int i, idx = 0; - p = xmalloc((WENV_SIZ + 1) * sizeof(char *)); + p = xcalloc(WENV_SIZ + 1, sizeof(char *)); for (e = environ; *e != NULL; ++e) { for (i = 0; i < WENV_SIZ; ++i) { if (!strncmp(*e, wenv_arr[i].name, wenv_arr[i].namelen)) diff --git a/openssh/openbsd-compat/bsd-getpeereid.c b/openssh/openbsd-compat/bsd-getpeereid.c index 8a3779f..bdae8b6 100644 --- a/openssh/openbsd-compat/bsd-getpeereid.c +++ b/openssh/openbsd-compat/bsd-getpeereid.c @@ -16,10 +16,13 @@ #include "includes.h" -RCSID("$Id$"); - #if !defined(HAVE_GETPEEREID) +#include +#include + +#include + #if defined(SO_PEERCRED) int getpeereid(int s, uid_t *euid, gid_t *gid) diff --git a/openssh/openbsd-compat/bsd-misc.c b/openssh/openbsd-compat/bsd-misc.c index b921524..17d731b 100644 --- a/openssh/openbsd-compat/bsd-misc.c +++ b/openssh/openbsd-compat/bsd-misc.c @@ -16,9 +16,19 @@ */ #include "includes.h" -#include "xmalloc.h" -RCSID("$Id$"); +#ifdef HAVE_SYS_SELECT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include +#include + +#include "xmalloc.h" #ifndef HAVE___PROGNAME char *__progname; diff --git a/openssh/openbsd-compat/bsd-nextstep.c b/openssh/openbsd-compat/bsd-nextstep.c index 0be1c2b..8195af8 100644 --- a/openssh/openbsd-compat/bsd-nextstep.c +++ b/openssh/openbsd-compat/bsd-nextstep.c @@ -24,8 +24,6 @@ #include "includes.h" -RCSID("$Id$"); - #ifdef HAVE_NEXT #include #include diff --git a/openssh/openbsd-compat/bsd-openpty.c b/openssh/openbsd-compat/bsd-openpty.c index 8eb62b7..9777eb5 100644 --- a/openssh/openbsd-compat/bsd-openpty.c +++ b/openssh/openbsd-compat/bsd-openpty.c @@ -35,6 +35,21 @@ #include "includes.h" #if !defined(HAVE_OPENPTY) +#include + +#include + +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_IOCTL_H +# include +#endif + +#ifdef HAVE_FCNTL_H +# include +#endif + #ifdef HAVE_UTIL_H # include #endif /* HAVE_UTIL_H */ @@ -46,6 +61,10 @@ # include #endif +#include +#include +#include + #ifndef O_NOCTTY #define O_NOCTTY 0 #endif diff --git a/openssh/openbsd-compat/bsd-snprintf.c b/openssh/openbsd-compat/bsd-snprintf.c index 2324c9e..04651e1 100644 --- a/openssh/openbsd-compat/bsd-snprintf.c +++ b/openssh/openbsd-compat/bsd-snprintf.c @@ -89,8 +89,6 @@ #include "includes.h" -RCSID("$Id$"); - #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF @@ -110,6 +108,11 @@ RCSID("$Id$"); #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) +#include +#include +#include +#include + #ifdef HAVE_LONG_DOUBLE # define LDOUBLE long double #else @@ -161,7 +164,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags); + LLONG value, int base, int min, int max, int flags); static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); @@ -468,10 +471,10 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags) + LLONG value, int base, int min, int max, int flags) { int signvalue = 0; - unsigned long uvalue; + unsigned LLONG uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ diff --git a/openssh/openbsd-compat/bsd-waitpid.c b/openssh/openbsd-compat/bsd-waitpid.c index 918ce35..40e6ffa 100644 --- a/openssh/openbsd-compat/bsd-waitpid.c +++ b/openssh/openbsd-compat/bsd-waitpid.c @@ -24,8 +24,6 @@ #include "includes.h" -RCSID("$Id$"); - #ifndef HAVE_WAITPID #include #include diff --git a/openssh/openbsd-compat/daemon.c b/openssh/openbsd-compat/daemon.c index f8a0680..e3a6886 100644 --- a/openssh/openbsd-compat/daemon.c +++ b/openssh/openbsd-compat/daemon.c @@ -34,6 +34,20 @@ #ifndef HAVE_DAEMON +#include + +#ifdef HAVE_SYS_STAT_H +# include +#endif + +#ifdef HAVE_FCNTL_H +# include +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif + int daemon(int nochdir, int noclose) { diff --git a/openssh/openbsd-compat/fake-rfc2553.c b/openssh/openbsd-compat/fake-rfc2553.c index a8a9dd7..b6ea3d2 100644 --- a/openssh/openbsd-compat/fake-rfc2553.c +++ b/openssh/openbsd-compat/fake-rfc2553.c @@ -37,7 +37,11 @@ #include "includes.h" -RCSID("$Id$"); +#include +#include + +#include +#include #ifndef HAVE_GETNAMEINFO int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, diff --git a/openssh/openbsd-compat/fake-rfc2553.h b/openssh/openbsd-compat/fake-rfc2553.h index 9a9f756..8431a42 100644 --- a/openssh/openbsd-compat/fake-rfc2553.h +++ b/openssh/openbsd-compat/fake-rfc2553.h @@ -41,7 +41,10 @@ #define _FAKE_RFC2553_H #include "includes.h" -#include "sys/types.h" +#include +#if defined(HAVE_NETDB_H) +# include +#endif /* * First, socket and INET6 related definitions diff --git a/openssh/openbsd-compat/getrrsetbyname.c b/openssh/openbsd-compat/getrrsetbyname.c index bea6aea..6c86e02 100644 --- a/openssh/openbsd-compat/getrrsetbyname.c +++ b/openssh/openbsd-compat/getrrsetbyname.c @@ -49,6 +49,12 @@ #ifndef HAVE_GETRRSETBYNAME +#include +#include + +#include +#include + #include "getrrsetbyname.h" #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO @@ -60,6 +66,13 @@ extern int h_errno; # undef _THREAD_PRIVATE #endif #define _THREAD_PRIVATE(a,b,c) (c) + +/* to avoid conflicts where a platform already has _res */ +#ifdef _res +# undef _res +#endif +#define _res _compat_res + struct __res_state _res; /* Necessary functions and macros */ diff --git a/openssh/openbsd-compat/glob.c b/openssh/openbsd-compat/glob.c index f6a04ea..b3dd2b1 100644 --- a/openssh/openbsd-compat/glob.c +++ b/openssh/openbsd-compat/glob.c @@ -34,7 +34,21 @@ /* OPENBSD ORIGINAL: lib/libc/gen/glob.c */ #include "includes.h" + +#include +#include + +#include #include +#include +#include +#include +#include +#include + +#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ + !defined(GLOB_HAS_GL_MATCHC) || \ + !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 static long get_arg_max(void) @@ -48,9 +62,6 @@ get_arg_max(void) #endif } -#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ - !defined(GLOB_HAS_GL_MATCHC) - /* * glob(3) -- a superset of the one defined in POSIX 1003.2. * diff --git a/openssh/openbsd-compat/glob.h b/openssh/openbsd-compat/glob.h index 4fdbfc1..9ba07f7 100644 --- a/openssh/openbsd-compat/glob.h +++ b/openssh/openbsd-compat/glob.h @@ -38,7 +38,8 @@ /* OPENBSD ORIGINAL: include/glob.h */ #if !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || \ - !defined(GLOB_HAS_GL_MATCHC) + !defined(GLOB_HAS_GL_MATCHC) || \ + !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 #ifndef _GLOB_H_ #define _GLOB_H_ diff --git a/openssh/openbsd-compat/mktemp.c b/openssh/openbsd-compat/mktemp.c index 88e04c5..2285c84 100644 --- a/openssh/openbsd-compat/mktemp.c +++ b/openssh/openbsd-compat/mktemp.c @@ -35,6 +35,14 @@ #include "includes.h" +#include +#include + +#include +#include +#include +#include + #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) static int _gettemp(char *, int *, int, int); diff --git a/openssh/openbsd-compat/openbsd-compat.h b/openssh/openbsd-compat/openbsd-compat.h index 2428528..6fe30fe 100644 --- a/openssh/openbsd-compat/openbsd-compat.h +++ b/openssh/openbsd-compat/openbsd-compat.h @@ -31,6 +31,11 @@ #include "includes.h" +#include +#include + +#include + /* OpenBSD function replacements */ #include "base64.h" #include "sigact.h" @@ -38,7 +43,7 @@ #include "readpassphrase.h" #include "vis.h" #include "getrrsetbyname.h" - +#include "sha2.h" #ifndef HAVE_BASENAME char *basename(const char *path); @@ -126,13 +131,16 @@ int getgrouplist(const char *, gid_t, gid_t *, int *); int BSDgetopt(int argc, char * const *argv, const char *opts); #endif +#if defined(HAVE_DECL_WRITEV) && HAVE_DECL_WRITEV == 0 +# include +# include +int writev(int, struct iovec *, int); +#endif /* Home grown routines */ #include "bsd-misc.h" #include "bsd-waitpid.h" -/*#include XXX Still needed? * For uid_t, gid_t * */ - #ifndef HAVE_GETPEEREID int getpeereid(int , uid_t *, gid_t *); #endif @@ -147,13 +155,14 @@ int asprintf(char **, const char *, ...); #endif #ifndef HAVE_OPENPTY +# include /* for struct winsize */ int openpty(int *, int *, char *, struct termios *, struct winsize *); #endif /* HAVE_OPENPTY */ /* #include XXX needed? For size_t */ #ifndef HAVE_SNPRINTF -int snprintf(char *, size_t, const char *, ...); +int snprintf(char *, size_t, SNPRINTF_CONST char *, ...); #endif #ifndef HAVE_STRTOLL @@ -164,6 +173,10 @@ long long strtoll(const char *, char **, int); long long strtonum(const char *, long long, long long, const char **); #endif +#if !defined(HAVE_VASPRINTF) || !defined(HAVE_VSNPRINTF) +# include +#endif + #ifndef HAVE_VASPRINTF int vasprintf(char **, const char *, va_list); #endif @@ -176,16 +189,18 @@ void *xmmap(size_t size); char *xcrypt(const char *password, const char *salt); char *shadow_pw(struct passwd *pw); - /* rfc2553 socket API replacements */ #include "fake-rfc2553.h" /* Routines for a single OS platform */ #include "bsd-cray.h" #include "bsd-cygwin_util.h" -#include "port-irix.h" + #include "port-aix.h" -#include "port-uw.h" +#include "port-irix.h" +#include "port-linux.h" +#include "port-solaris.h" #include "port-tun.h" +#include "port-uw.h" #endif /* _OPENBSD_COMPAT_H */ diff --git a/openssh/openbsd-compat/openssl-compat.c b/openssh/openbsd-compat/openssl-compat.c index 957be81..5644909 100644 --- a/openssh/openbsd-compat/openssl-compat.c +++ b/openssh/openbsd-compat/openssl-compat.c @@ -18,7 +18,11 @@ #include "includes.h" -#define SSH_DONT_REDEF_EVP +#ifdef USE_OPENSSL_ENGINE +# include +#endif + +#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS #include "openssl-compat.h" #ifdef SSH_OLD_EVP @@ -44,3 +48,15 @@ ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *evp) return 1; } #endif + +#ifdef USE_OPENSSL_ENGINE +void +ssh_SSLeay_add_all_algorithms(void) +{ + SSLeay_add_all_algorithms(); + + /* Enable use of crypto hardware */ + ENGINE_load_builtin_engines(); + ENGINE_register_all_complete(); +} +#endif diff --git a/openssh/openbsd-compat/openssl-compat.h b/openssh/openbsd-compat/openssl-compat.h index 09e2e7e..36a09f6 100644 --- a/openssh/openbsd-compat/openssl-compat.h +++ b/openssh/openbsd-compat/openssl-compat.h @@ -54,21 +54,27 @@ extern const EVP_CIPHER *evp_acss(void); * define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and * implement the ssh_* equivalents. */ -#ifdef SSH_OLD_EVP - -# ifndef SSH_DONT_REDEF_EVP +#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS +# ifdef SSH_OLD_EVP # ifdef EVP_Cipher # undef EVP_Cipher # endif - # define EVP_CipherInit(a,b,c,d,e) ssh_EVP_CipherInit((a),(b),(c),(d),(e)) # define EVP_Cipher(a,b,c,d) ssh_EVP_Cipher((a),(b),(c),(d)) # define EVP_CIPHER_CTX_cleanup(a) ssh_EVP_CIPHER_CTX_cleanup((a)) -# endif +# endif /* SSH_OLD_EVP */ + +# ifdef USE_OPENSSL_ENGINE +# ifdef SSLeay_add_all_algorithms +# undef SSLeay_add_all_algorithms +# endif +# define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms() +#endif int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, unsigned char *, int); int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); -#endif +void ssh_SSLeay_add_all_algorithms(void); +#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */ diff --git a/openssh/openbsd-compat/port-aix.c b/openssh/openbsd-compat/port-aix.c index 81d8124..b9fabf6 100644 --- a/openssh/openbsd-compat/port-aix.c +++ b/openssh/openbsd-compat/port-aix.c @@ -25,16 +25,36 @@ * */ #include "includes.h" + +#include "xmalloc.h" +#include "buffer.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" #include "ssh.h" #include "log.h" -#include "xmalloc.h" -#include "buffer.h" #ifdef _AIX +#include +#if defined(HAVE_NETDB_H) +# include +#endif #include +#include +#include +#include #include + +#ifdef WITH_AIXAUTHENTICATE +# include +# include +# if defined(HAVE_SYS_AUDIT_H) && defined(AIX_LOGINFAILED_4ARG) +# include +# endif +# include +#endif + #include "port-aix.h" # ifdef HAVE_SETAUTHDB @@ -256,15 +276,17 @@ sys_auth_record_login(const char *user, const char *host, const char *ttynm, Buffer *loginmsg) { char *msg = NULL; + static int msg_done = 0; int success = 0; aix_setauthdb(user); if (loginsuccess((char *)user, (char *)host, (char *)ttynm, &msg) == 0) { success = 1; - if (msg != NULL) { + if (msg != NULL && loginmsg != NULL && !msg_done) { debug("AIX/loginsuccess: msg %s", msg); buffer_append(loginmsg, msg, strlen(msg)); xfree(msg); + msg_done = 1; } } aix_restoreauthdb(); diff --git a/openssh/openbsd-compat/port-aix.h b/openssh/openbsd-compat/port-aix.h index 15bdcf5..eae82a9 100644 --- a/openssh/openbsd-compat/port-aix.h +++ b/openssh/openbsd-compat/port-aix.h @@ -31,19 +31,6 @@ #ifdef HAVE_SYS_SOCKET_H # include #endif -#ifdef HAVE_UNISTD_H -# include /* for seteuid() */ -#endif - -#ifdef WITH_AIXAUTHENTICATE -# include -# include -# if defined(HAVE_SYS_AUDIT_H) && defined(AIX_LOGINFAILED_4ARG) -# undef T_NULL -# include -# endif -# include -#endif #include "buffer.h" diff --git a/openssh/openbsd-compat/port-irix.c b/openssh/openbsd-compat/port-irix.c index aa6db1c..ba751a5 100644 --- a/openssh/openbsd-compat/port-irix.c +++ b/openssh/openbsd-compat/port-irix.c @@ -29,6 +29,10 @@ defined(WITH_IRIX_JOBS) || \ defined(WITH_IRIX_ARRAY) +#include +#include +#include + #ifdef WITH_IRIX_PROJECT # include #endif /* WITH_IRIX_PROJECT */ diff --git a/openssh/openbsd-compat/port-linux.c b/openssh/openbsd-compat/port-linux.c new file mode 100644 index 0000000..5386d9d --- /dev/null +++ b/openssh/openbsd-compat/port-linux.c @@ -0,0 +1,169 @@ +/* $Id$ */ + +/* + * Copyright (c) 2005 Daniel Walsh + * Copyright (c) 2006 Damien 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +/* + * Linux-specific portability code - just SELinux support at present + */ + +#include "includes.h" + +#include +#include +#include + +#ifdef WITH_SELINUX +#include "log.h" +#include "port-linux.h" + +#include +#include +#include + +/* Wrapper around is_selinux_enabled() to log its return value once only */ +static int +ssh_selinux_enabled(void) +{ + static int enabled = -1; + + if (enabled == -1) { + enabled = is_selinux_enabled(); + debug("SELinux support %s", enabled ? "enabled" : "disabled"); + } + + return (enabled); +} + +/* Return the default security context for the given username */ +static security_context_t +ssh_selinux_getctxbyname(char *pwname) +{ + security_context_t sc; + char *sename = NULL, *lvl = NULL; + int r; + +#ifdef HAVE_GETSEUSERBYNAME + if (getseuserbyname(pwname, &sename, &lvl) != 0) + return NULL; +#else + sename = pwname; + lvl = NULL; +#endif + +#ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL + r = get_default_context_with_level(sename, lvl, NULL, &sc); +#else + r = get_default_context(sename, NULL, &sc); +#endif + + if (r != 0) { + switch (security_getenforce()) { + case -1: + fatal("%s: ssh_selinux_getctxbyname: " + "security_getenforce() failed", __func__); + case 0: + error("%s: Failed to get default SELinux security " + "context for %s", __func__, pwname); + default: + fatal("%s: Failed to get default SELinux security " + "context for %s (in enforcing mode)", + __func__, pwname); + } + } + +#ifdef HAVE_GETSEUSERBYNAME + if (sename != NULL) + xfree(sename); + if (lvl != NULL) + xfree(lvl); +#endif + + return (sc); +} + +/* Set the execution context to the default for the specified user */ +void +ssh_selinux_setup_exec_context(char *pwname) +{ + security_context_t user_ctx = NULL; + + if (!ssh_selinux_enabled()) + return; + + debug3("%s: setting execution context", __func__); + + user_ctx = ssh_selinux_getctxbyname(pwname); + if (setexeccon(user_ctx) != 0) { + switch (security_getenforce()) { + case -1: + fatal("%s: security_getenforce() failed", __func__); + case 0: + error("%s: Failed to set SELinux execution " + "context for %s", __func__, pwname); + default: + fatal("%s: Failed to set SELinux execution context " + "for %s (in enforcing mode)", __func__, pwname); + } + } + if (user_ctx != NULL) + freecon(user_ctx); + + debug3("%s: done", __func__); +} + +/* Set the TTY context for the specified user */ +void +ssh_selinux_setup_pty(char *pwname, const char *tty) +{ + security_context_t new_tty_ctx = NULL; + security_context_t user_ctx = NULL; + security_context_t old_tty_ctx = NULL; + + if (!ssh_selinux_enabled()) + return; + + debug3("%s: setting TTY context on %s", __func__, tty); + + user_ctx = ssh_selinux_getctxbyname(pwname); + + /* XXX: should these calls fatal() upon failure in enforcing mode? */ + + if (getfilecon(tty, &old_tty_ctx) == -1) { + error("%s: getfilecon: %s", __func__, strerror(errno)); + goto out; + } + + if (security_compute_relabel(user_ctx, old_tty_ctx, + SECCLASS_CHR_FILE, &new_tty_ctx) != 0) { + error("%s: security_compute_relabel: %s", + __func__, strerror(errno)); + goto out; + } + + if (setfilecon(tty, new_tty_ctx) != 0) + error("%s: setfilecon: %s", __func__, strerror(errno)); + out: + if (new_tty_ctx != NULL) + freecon(new_tty_ctx); + if (old_tty_ctx != NULL) + freecon(old_tty_ctx); + if (user_ctx != NULL) + freecon(user_ctx); + debug3("%s: done", __func__); +} +#endif /* WITH_SELINUX */ diff --git a/openssh/openbsd-compat/port-linux.h b/openssh/openbsd-compat/port-linux.h new file mode 100644 index 0000000..ccb42df --- /dev/null +++ b/openssh/openbsd-compat/port-linux.h @@ -0,0 +1,27 @@ +/* $Id$ */ + +/* + * Copyright (c) 2006 Damien 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#ifndef _PORT_LINUX_H +#define _PORT_LINUX_H + +#ifdef WITH_SELINUX +void ssh_selinux_setup_pty(char *, const char *); +void ssh_selinux_setup_exec_context(char *); +#endif + +#endif /* ! _PORT_LINUX_H */ diff --git a/openssh/openbsd-compat/port-solaris.c b/openssh/openbsd-compat/port-solaris.c new file mode 100644 index 0000000..ca08a15 --- /dev/null +++ b/openssh/openbsd-compat/port-solaris.c @@ -0,0 +1,199 @@ +/* $Id$ */ + +/* + * Copyright (c) 2006 Chad Mynhier. + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#include "config.h" +#include "includes.h" + +#ifdef USE_SOLARIS_PROCESS_CONTRACTS + +#include +#include +#include + +#include +#ifdef HAVE_FCNTL_H +# include +#endif +#include +#include +#include + +#include +#include +#include + +#include "log.h" + +#define CT_TEMPLATE CTFS_ROOT "/process/template" +#define CT_LATEST CTFS_ROOT "/process/latest" + +static int tmpl_fd = -1; + +/* Lookup the latest process contract */ +static ctid_t +get_active_process_contract_id(void) +{ + int stat_fd; + ctid_t ctid = -1; + ct_stathdl_t stathdl; + + if ((stat_fd = open64(CT_LATEST, O_RDONLY)) == -1) { + error("%s: Error opening 'latest' process " + "contract: %s", __func__, strerror(errno)); + return -1; + } + if (ct_status_read(stat_fd, CTD_COMMON, &stathdl) != 0) { + error("%s: Error reading process contract " + "status: %s", __func__, strerror(errno)); + goto out; + } + if ((ctid = ct_status_get_id(stathdl)) < 0) { + error("%s: Error getting process contract id: %s", + __func__, strerror(errno)); + goto out; + } + + ct_status_free(stathdl); + out: + close(stat_fd); + return ctid; +} + +void +solaris_contract_pre_fork(void) +{ + if ((tmpl_fd = open64(CT_TEMPLATE, O_RDWR)) == -1) { + error("%s: open %s: %s", __func__, + CT_TEMPLATE, strerror(errno)); + return; + } + + debug2("%s: setting up process contract template on fd %d", + __func__, tmpl_fd); + + /* First we set the template parameters and event sets. */ + if (ct_pr_tmpl_set_param(tmpl_fd, CT_PR_PGRPONLY) != 0) { + error("%s: Error setting process contract parameter set " + "(pgrponly): %s", __func__, strerror(errno)); + goto fail; + } + if (ct_pr_tmpl_set_fatal(tmpl_fd, CT_PR_EV_HWERR) != 0) { + error("%s: Error setting process contract template " + "fatal events: %s", __func__, strerror(errno)); + goto fail; + } + if (ct_tmpl_set_critical(tmpl_fd, 0) != 0) { + error("%s: Error setting process contract template " + "critical events: %s", __func__, strerror(errno)); + goto fail; + } + if (ct_tmpl_set_informative(tmpl_fd, CT_PR_EV_HWERR) != 0) { + error("%s: Error setting process contract template " + "informative events: %s", __func__, strerror(errno)); + goto fail; + } + + /* Now make this the active template for this process. */ + if (ct_tmpl_activate(tmpl_fd) != 0) { + error("%s: Error activating process contract " + "template: %s", __func__, strerror(errno)); + goto fail; + } + return; + + fail: + if (tmpl_fd != -1) { + close(tmpl_fd); + tmpl_fd = -1; + } +} + +void +solaris_contract_post_fork_child() +{ + debug2("%s: clearing process contract template on fd %d", + __func__, tmpl_fd); + + /* Clear the active template. */ + if (ct_tmpl_clear(tmpl_fd) != 0) + error("%s: Error clearing active process contract " + "template: %s", __func__, strerror(errno)); + + close(tmpl_fd); + tmpl_fd = -1; +} + +void +solaris_contract_post_fork_parent(pid_t pid) +{ + ctid_t ctid; + char ctl_path[256]; + int r, ctl_fd = -1, stat_fd = -1; + + debug2("%s: clearing template (fd %d)", __func__, tmpl_fd); + + if (tmpl_fd == -1) + return; + + /* First clear the active template. */ + if ((r = ct_tmpl_clear(tmpl_fd)) != 0) + error("%s: Error clearing active process contract " + "template: %s", __func__, strerror(errno)); + + close(tmpl_fd); + tmpl_fd = -1; + + /* + * If either the fork didn't succeed (pid < 0), or clearing + * th active contract failed (r != 0), then we have nothing + * more do. + */ + if (r != 0 || pid <= 0) + return; + + /* Now lookup and abandon the contract we've created. */ + ctid = get_active_process_contract_id(); + + debug2("%s: abandoning contract id %ld", __func__, ctid); + + snprintf(ctl_path, sizeof(ctl_path), + CTFS_ROOT "/process/%ld/ctl", ctid); + if ((ctl_fd = open64(ctl_path, O_WRONLY)) < 0) { + error("%s: Error opening process contract " + "ctl file: %s", __func__, strerror(errno)); + goto fail; + } + if (ct_ctl_abandon(ctl_fd) < 0) { + error("%s: Error abandoning process contract: %s", + __func__, strerror(errno)); + goto fail; + } + close(ctl_fd); + return; + + fail: + if (tmpl_fd != -1) { + close(tmpl_fd); + tmpl_fd = -1; + } + if (stat_fd != -1) + close(stat_fd); + if (ctl_fd != -1) + close(ctl_fd); +} +#endif diff --git a/openssh/openbsd-compat/port-solaris.h b/openssh/openbsd-compat/port-solaris.h new file mode 100644 index 0000000..62b525e --- /dev/null +++ b/openssh/openbsd-compat/port-solaris.h @@ -0,0 +1,27 @@ +/* $Id$ */ + +/* + * Copyright (c) 2006 Chad Mynhier. + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#ifndef _PORT_SOLARIS_H + +#include + +void solaris_contract_pre_fork(void); +void solaris_contract_post_fork_child(void); +void solaris_contract_post_fork_parent(pid_t pid); + +#endif diff --git a/openssh/openbsd-compat/port-tun.c b/openssh/openbsd-compat/port-tun.c index 3192161..276474d 100644 --- a/openssh/openbsd-compat/port-tun.c +++ b/openssh/openbsd-compat/port-tun.c @@ -16,9 +16,23 @@ #include "includes.h" +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + #include "log.h" #include "misc.h" -#include "bufaux.h" +#include "buffer.h" +#include "channels.h" /* * This is the portable version of the SSH tunnel forwarding, it @@ -26,6 +40,7 @@ * settings. * * SSH_TUN_LINUX Use the (newer) Linux tun/tap device + * SSH_TUN_FREEBSD Use the FreeBSD tun/tap device * SSH_TUN_COMPAT_AF Translate the OpenBSD address family * SSH_TUN_PREPEND_AF Prepend/remove the address family */ @@ -93,7 +108,10 @@ sys_tun_open(int tun, int mode) #ifdef SSH_TUN_FREEBSD #include #include + +#ifdef HAVE_NET_IF_TUN_H #include +#endif int sys_tun_open(int tun, int mode) diff --git a/openssh/openbsd-compat/port-tun.h b/openssh/openbsd-compat/port-tun.h index 86d9272..c53df01 100644 --- a/openssh/openbsd-compat/port-tun.h +++ b/openssh/openbsd-compat/port-tun.h @@ -17,7 +17,7 @@ #ifndef _PORT_TUN_H #define _PORT_TUN_H -#include "channels.h" +struct Channel; #if defined(SSH_TUN_LINUX) || defined(SSH_TUN_FREEBSD) # define CUSTOM_SYS_TUN_OPEN diff --git a/openssh/openbsd-compat/port-uw.c b/openssh/openbsd-compat/port-uw.c index c644271..6f35239 100644 --- a/openssh/openbsd-compat/port-uw.c +++ b/openssh/openbsd-compat/port-uw.c @@ -26,15 +26,26 @@ #include "includes.h" #ifdef HAVE_LIBIAF +#include #ifdef HAVE_CRYPT_H -#include +# include #endif +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "packet.h" #include "buffer.h" +#include "auth-options.h" #include "log.h" #include "servconf.h" +#include "key.h" +#include "hostfile.h" #include "auth.h" -#include "auth-options.h" +#include "ssh.h" int nischeck(char *); diff --git a/openssh/openbsd-compat/readpassphrase.c b/openssh/openbsd-compat/readpassphrase.c index 919c017..11bd8f6 100644 --- a/openssh/openbsd-compat/readpassphrase.c +++ b/openssh/openbsd-compat/readpassphrase.c @@ -27,7 +27,13 @@ #ifndef HAVE_READPASSPHRASE #include +#include +#include +#include #include +#include +#include +#include #ifdef TCSASOFT # define _T_FLUSH (TCSAFLUSH|TCSASOFT) diff --git a/openssh/openbsd-compat/regress/Makefile.in b/openssh/openbsd-compat/regress/Makefile.in new file mode 100644 index 0000000..46d9bb9 --- /dev/null +++ b/openssh/openbsd-compat/regress/Makefile.in @@ -0,0 +1,38 @@ +# $Id$ + +sysconfdir=@sysconfdir@ +piddir=@piddir@ +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ + +VPATH=@srcdir@ +CC=@CC@ +LD=@LD@ +CFLAGS=@CFLAGS@ +CPPFLAGS=-I. -I.. -I$(srcdir) -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ +EXEEXT=@EXEEXT@ +LIBCOMPAT=../libopenbsd-compat.a +LIBS=@LIBS@ +LDFLAGS=@LDFLAGS@ $(LIBCOMPAT) + +TESTPROGS=closefromtest$(EXEEXT) snprintftest$(EXEEXT) strduptest$(EXEEXT) \ + strtonumtest$(EXEEXT) + +all: t-exec ${OTHERTESTS} + +%$(EXEEXT): %.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< $(LIBCOMPAT) $(LIBS) + +t-exec: $(TESTPROGS) + @echo running compat regress tests + @for TEST in ""$?; do \ + echo "run test $${TEST}" ... 1>&2; \ + ./$${TEST}$(EXEEXT) || exit $$? ; \ + done + @echo finished compat regress tests + +clean: + rm -f *.o *.a core $(TESTPROGS) valid.out + +distclean: clean + rm -f Makefile *~ diff --git a/openssh/openbsd-compat/regress/closefromtest.c b/openssh/openbsd-compat/regress/closefromtest.c new file mode 100644 index 0000000..feb1b56 --- /dev/null +++ b/openssh/openbsd-compat/regress/closefromtest.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2006 Darren Tucker + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#include +#include + +#include +#include +#include +#include + +#define NUM_OPENS 10 + +void +fail(char *msg) +{ + fprintf(stderr, "closefrom: %s\n", msg); + exit(1); +} + +int +main(void) +{ + int i, max, fds[NUM_OPENS]; + char buf[512]; + + for (i = 0; i < NUM_OPENS; i++) + if ((fds[i] = open("/dev/null", "r")) == -1) + exit(0); /* can't test */ + max = i - 1; + + /* should close last fd only */ + closefrom(fds[max]); + if (close(fds[max]) != -1) + fail("failed to close highest fd"); + + /* make sure we can still use remaining descriptors */ + for (i = 0; i < max; i++) + if (read(fds[i], buf, sizeof(buf)) == -1) + fail("closed descriptors it should not have"); + + /* should close all fds */ + closefrom(fds[0]); + for (i = 0; i < NUM_OPENS; i++) + if (close(fds[i]) != -1) + fail("failed to close from lowest fd"); +} diff --git a/openssh/openbsd-compat/regress/snprintftest.c b/openssh/openbsd-compat/regress/snprintftest.c new file mode 100644 index 0000000..4ca63e1 --- /dev/null +++ b/openssh/openbsd-compat/regress/snprintftest.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2005 Darren Tucker + * Copyright (c) 2005 Damien 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#define BUFSZ 2048 + +#include +#include +#include +#include +#include + +static int failed = 0; + +static void +fail(const char *m) +{ + fprintf(stderr, "snprintftest: %s\n", m); + failed = 1; +} + +int x_snprintf(char *str, size_t count, const char *fmt, ...) +{ + size_t ret; + va_list ap; + + va_start(ap, fmt); + ret = vsnprintf(str, count, fmt, ap); + va_end(ap); + return ret; +} + +int +main(void) +{ + char b[5]; + char *src; + + snprintf(b,5,"123456789"); + if (b[4] != '\0') + fail("snprintf does not correctly terminate long strings"); + + /* check for read overrun on unterminated string */ + if ((src = malloc(BUFSZ)) == NULL) { + fail("malloc failed"); + } else { + memset(src, 'a', BUFSZ); + snprintf(b, sizeof(b), "%.*s", 1, src); + if (strcmp(b, "a") != 0) + fail("failed with length limit '%%.s'"); + } + + /* check that snprintf and vsnprintf return sane values */ + if (snprintf(b, 1, "%s %d", "hello", 12345) != 11) + fail("snprintf does not return required length"); + if (x_snprintf(b, 1, "%s %d", "hello", 12345) != 11) + fail("vsnprintf does not return required length"); + + return failed; +} diff --git a/openssh/openbsd-compat/regress/strduptest.c b/openssh/openbsd-compat/regress/strduptest.c new file mode 100644 index 0000000..7f6d779 --- /dev/null +++ b/openssh/openbsd-compat/regress/strduptest.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2005 Darren Tucker + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#include +#include + +static int fail = 0; + +void +test(const char *a) +{ + char *b; + + b = strdup(a); + if (b == 0) { + fail = 1; + return; + } + if (strcmp(a, b) != 0) + fail = 1; + free(b); +} + +int +main(void) +{ + test(""); + test("a"); + test("\0"); + test("abcdefghijklmnopqrstuvwxyz"); + return fail; +} diff --git a/openssh/openbsd-compat/regress/strtonumtest.c b/openssh/openbsd-compat/regress/strtonumtest.c new file mode 100644 index 0000000..cb85851 --- /dev/null +++ b/openssh/openbsd-compat/regress/strtonumtest.c @@ -0,0 +1,66 @@ +/* $OpenBSD: strtonumtest.c,v 1.1 2004/08/03 20:38:36 otto Exp $ */ +/* + * Copyright (c) 2004 Otto Moerbeek + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +/* OPENBSD ORIGINAL: regress/lib/libc/strtonum/strtonumtest.c */ + +#include +#include +#include + +int fail; + +void +test(const char *p, long long lb, long long ub, int ok) +{ + long long val; + const char *q; + + val = strtonum(p, lb, ub, &q); + if (ok && q != NULL) { + fprintf(stderr, "%s [%lld-%lld] ", p, lb, ub); + fprintf(stderr, "NUMBER NOT ACCEPTED %s\n", q); + fail = 1; + } else if (!ok && q == NULL) { + fprintf(stderr, "%s [%lld-%lld] %lld ", p, lb, ub, val); + fprintf(stderr, "NUMBER ACCEPTED\n"); + fail = 1; + } +} + +int main(int argc, char *argv[]) +{ + test("1", 0, 10, 1); + test("0", -2, 5, 1); + test("0", 2, 5, 0); + test("0", 2, LLONG_MAX, 0); + test("-2", 0, LLONG_MAX, 0); + test("0", -5, LLONG_MAX, 1); + test("-3", -3, LLONG_MAX, 1); + test("-9223372036854775808", LLONG_MIN, LLONG_MAX, 1); + test("9223372036854775807", LLONG_MIN, LLONG_MAX, 1); + test("-9223372036854775809", LLONG_MIN, LLONG_MAX, 0); + test("9223372036854775808", LLONG_MIN, LLONG_MAX, 0); + test("1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0); + test("-1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0); + test("-2", 10, -1, 0); + test("-2", -10, -1, 1); + test("-20", -10, -1, 0); + test("20", -10, -1, 0); + + return (fail); +} + diff --git a/openssh/openbsd-compat/rresvport.c b/openssh/openbsd-compat/rresvport.c index 71cf6e6..5b0275c 100644 --- a/openssh/openbsd-compat/rresvport.c +++ b/openssh/openbsd-compat/rresvport.c @@ -35,6 +35,16 @@ #ifndef HAVE_RRESVPORT_AF +#include +#include + +#include +#include + +#include +#include +#include + #if 0 int rresvport(int *alport) diff --git a/openssh/openbsd-compat/setproctitle.c b/openssh/openbsd-compat/setproctitle.c index 6e2b19b..b511f66 100644 --- a/openssh/openbsd-compat/setproctitle.c +++ b/openssh/openbsd-compat/setproctitle.c @@ -35,10 +35,13 @@ #ifndef HAVE_SETPROCTITLE +#include +#include #include #ifdef HAVE_SYS_PSTAT_H #include #endif +#include #define SPT_NONE 0 /* don't use it at all */ #define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */ @@ -80,7 +83,7 @@ compat_init_setproctitle(int argc, char *argv[]) /* Fail if we can't allocate room for the new environment */ for (i = 0; envp[i] != NULL; i++) ; - if ((environ = malloc(sizeof(*environ) * (i + 1))) == NULL) { + if ((environ = calloc(i + 1, sizeof(*environ))) == NULL) { environ = envp; /* put it back */ return; } diff --git a/openssh/openbsd-compat/sha2.c b/openssh/openbsd-compat/sha2.c new file mode 100755 index 0000000..cf8e0ad --- /dev/null +++ b/openssh/openbsd-compat/sha2.c @@ -0,0 +1,882 @@ +/* $OpenBSD: sha2.c,v 1.11 2005/08/08 08:05:35 espie Exp $ */ + +/* + * FILE: sha2.c + * AUTHOR: Aaron D. Gifford + * + * Copyright (c) 2000-2001, Aaron D. Gifford + * 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. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``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 CONTRIBUTOR(S) 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. + * + * $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ + */ + +/* OPENBSD ORIGINAL: lib/libc/hash/sha2.c */ + +#include "includes.h" + +#include + +#if !defined(HAVE_EVP_SHA256) && !defined(HAVE_SHA256_UPDATE) && \ + (OPENSSL_VERSION_NUMBER >= 0x00907000L) +#include +#include +#include "sha2.h" + +/* + * UNROLLED TRANSFORM LOOP NOTE: + * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform + * loop version for the hash transform rounds (defined using macros + * later in this file). Either define on the command line, for example: + * + * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c + * + * or define below: + * + * #define SHA2_UNROLL_TRANSFORM + * + */ + +/*** SHA-256/384/512 Machine Architecture Definitions *****************/ +/* + * BYTE_ORDER NOTE: + * + * Please make sure that your system defines BYTE_ORDER. If your + * architecture is little-endian, make sure it also defines + * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are + * equivilent. + * + * If your system does not define the above, then you can do so by + * hand like this: + * + * #define LITTLE_ENDIAN 1234 + * #define BIG_ENDIAN 4321 + * + * And for little-endian machines, add: + * + * #define BYTE_ORDER LITTLE_ENDIAN + * + * Or for big-endian machines: + * + * #define BYTE_ORDER BIG_ENDIAN + * + * The FreeBSD machine this was written on defines BYTE_ORDER + * appropriately by including (which in turn includes + * where the appropriate definitions are actually + * made). + */ +#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) +#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +#endif + + +/*** SHA-256/384/512 Various Length Definitions ***********************/ +/* NOTE: Most of these are in sha2.h */ +#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) +#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16) +#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) + +/*** ENDIAN SPECIFIC COPY MACROS **************************************/ +#define BE_8_TO_32(dst, cp) do { \ + (dst) = (u_int32_t)(cp)[3] | ((u_int32_t)(cp)[2] << 8) | \ + ((u_int32_t)(cp)[1] << 16) | ((u_int32_t)(cp)[0] << 24); \ +} while(0) + +#define BE_8_TO_64(dst, cp) do { \ + (dst) = (u_int64_t)(cp)[7] | ((u_int64_t)(cp)[6] << 8) | \ + ((u_int64_t)(cp)[5] << 16) | ((u_int64_t)(cp)[4] << 24) | \ + ((u_int64_t)(cp)[3] << 32) | ((u_int64_t)(cp)[2] << 40) | \ + ((u_int64_t)(cp)[1] << 48) | ((u_int64_t)(cp)[0] << 56); \ +} while (0) + +#define BE_64_TO_8(cp, src) do { \ + (cp)[0] = (src) >> 56; \ + (cp)[1] = (src) >> 48; \ + (cp)[2] = (src) >> 40; \ + (cp)[3] = (src) >> 32; \ + (cp)[4] = (src) >> 24; \ + (cp)[5] = (src) >> 16; \ + (cp)[6] = (src) >> 8; \ + (cp)[7] = (src); \ +} while (0) + +#define BE_32_TO_8(cp, src) do { \ + (cp)[0] = (src) >> 24; \ + (cp)[1] = (src) >> 16; \ + (cp)[2] = (src) >> 8; \ + (cp)[3] = (src); \ +} while (0) + +/* + * Macro for incrementally adding the unsigned 64-bit integer n to the + * unsigned 128-bit integer (represented using a two-element array of + * 64-bit words): + */ +#define ADDINC128(w,n) do { \ + (w)[0] += (u_int64_t)(n); \ + if ((w)[0] < (n)) { \ + (w)[1]++; \ + } \ +} while (0) + +/*** THE SIX LOGICAL FUNCTIONS ****************************************/ +/* + * Bit shifting and rotation (used by the six SHA-XYZ logical functions: + * + * NOTE: The naming of R and S appears backwards here (R is a SHIFT and + * S is a ROTATION) because the SHA-256/384/512 description document + * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this + * same "backwards" definition. + */ +/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ +#define R(b,x) ((x) >> (b)) +/* 32-bit Rotate-right (used in SHA-256): */ +#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) +/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ +#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) + +/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ +#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +/* Four of six logical functions used in SHA-256: */ +#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) +#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) +#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) +#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) + +/* Four of six logical functions used in SHA-384 and SHA-512: */ +#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) +#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) +#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) +#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) + + +/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ +/* Hash constant words K for SHA-256: */ +const static u_int32_t K256[64] = { + 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, + 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, + 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, + 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, + 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, + 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, + 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, + 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, + 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, + 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, + 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, + 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, + 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, + 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, + 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, + 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL +}; + +/* Initial hash value H for SHA-256: */ +const static u_int32_t sha256_initial_hash_value[8] = { + 0x6a09e667UL, + 0xbb67ae85UL, + 0x3c6ef372UL, + 0xa54ff53aUL, + 0x510e527fUL, + 0x9b05688cUL, + 0x1f83d9abUL, + 0x5be0cd19UL +}; + +/* Hash constant words K for SHA-384 and SHA-512: */ +const static u_int64_t K512[80] = { + 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, + 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, + 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, + 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, + 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, + 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, + 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, + 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, + 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, + 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, + 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, + 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, + 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, + 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, + 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, + 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, + 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, + 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, + 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, + 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, + 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, + 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, + 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, + 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, + 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, + 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, + 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, + 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, + 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, + 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, + 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, + 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, + 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, + 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, + 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, + 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, + 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, + 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, + 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, + 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL +}; + +/* Initial hash value H for SHA-384 */ +const static u_int64_t sha384_initial_hash_value[8] = { + 0xcbbb9d5dc1059ed8ULL, + 0x629a292a367cd507ULL, + 0x9159015a3070dd17ULL, + 0x152fecd8f70e5939ULL, + 0x67332667ffc00b31ULL, + 0x8eb44a8768581511ULL, + 0xdb0c2e0d64f98fa7ULL, + 0x47b5481dbefa4fa4ULL +}; + +/* Initial hash value H for SHA-512 */ +const static u_int64_t sha512_initial_hash_value[8] = { + 0x6a09e667f3bcc908ULL, + 0xbb67ae8584caa73bULL, + 0x3c6ef372fe94f82bULL, + 0xa54ff53a5f1d36f1ULL, + 0x510e527fade682d1ULL, + 0x9b05688c2b3e6c1fULL, + 0x1f83d9abfb41bd6bULL, + 0x5be0cd19137e2179ULL +}; + + +/*** SHA-256: *********************************************************/ +void +SHA256_Init(SHA256_CTX *context) +{ + if (context == NULL) + return; + memcpy(context->state, sha256_initial_hash_value, + sizeof(sha256_initial_hash_value)); + memset(context->buffer, 0, sizeof(context->buffer)); + context->bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-256 round macros: */ + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) do { \ + BE_8_TO_32(W256[j], data); \ + data += 4; \ + T1 = (h) + Sigma1_256((e)) + Ch((e), (f), (g)) + K256[j] + W256[j]; \ + (d) += T1; \ + (h) = T1 + Sigma0_256((a)) + Maj((a), (b), (c)); \ + j++; \ +} while(0) + +#define ROUND256(a,b,c,d,e,f,g,h) do { \ + s0 = W256[(j+1)&0x0f]; \ + s0 = sigma0_256(s0); \ + s1 = W256[(j+14)&0x0f]; \ + s1 = sigma1_256(s1); \ + T1 = (h) + Sigma1_256((e)) + Ch((e), (f), (g)) + K256[j] + \ + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_256((a)) + Maj((a), (b), (c)); \ + j++; \ +} while(0) + +void +SHA256_Transform(u_int32_t state[8], const u_int8_t data[SHA256_BLOCK_LENGTH]) +{ + u_int32_t a, b, c, d, e, f, g, h, s0, s1; + u_int32_t T1, W256[16]; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + j = 0; + do { + /* Rounds 0 to 15 (unrolled): */ + ROUND256_0_TO_15(a,b,c,d,e,f,g,h); + ROUND256_0_TO_15(h,a,b,c,d,e,f,g); + ROUND256_0_TO_15(g,h,a,b,c,d,e,f); + ROUND256_0_TO_15(f,g,h,a,b,c,d,e); + ROUND256_0_TO_15(e,f,g,h,a,b,c,d); + ROUND256_0_TO_15(d,e,f,g,h,a,b,c); + ROUND256_0_TO_15(c,d,e,f,g,h,a,b); + ROUND256_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds up to 63: */ + do { + ROUND256(a,b,c,d,e,f,g,h); + ROUND256(h,a,b,c,d,e,f,g); + ROUND256(g,h,a,b,c,d,e,f); + ROUND256(f,g,h,a,b,c,d,e); + ROUND256(e,f,g,h,a,b,c,d); + ROUND256(d,e,f,g,h,a,b,c); + ROUND256(c,d,e,f,g,h,a,b); + ROUND256(b,c,d,e,f,g,h,a); + } while (j < 64); + + /* Compute the current intermediate hash value */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void +SHA256_Transform(u_int32_t state[8], const u_int8_t data[SHA256_BLOCK_LENGTH]) +{ + u_int32_t a, b, c, d, e, f, g, h, s0, s1; + u_int32_t T1, T2, W256[16]; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + j = 0; + do { + BE_8_TO_32(W256[j], data); + data += 4; + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W256[(j+1)&0x0f]; + s0 = sigma0_256(s0); + s1 = W256[(j+14)&0x0f]; + s1 = sigma1_256(s1); + + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 64); + + /* Compute the current intermediate hash value */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void +SHA256_Update(SHA256_CTX *context, const u_int8_t *data, size_t len) +{ + size_t freespace, usedspace; + + /* Calling with no data is valid (we do nothing) */ + if (len == 0) + return; + + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA256_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + memcpy(&context->buffer[usedspace], data, freespace); + context->bitcount += freespace << 3; + len -= freespace; + data += freespace; + SHA256_Transform(context->state, context->buffer); + } else { + /* The buffer is not yet full */ + memcpy(&context->buffer[usedspace], data, len); + context->bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA256_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + SHA256_Transform(context->state, data); + context->bitcount += SHA256_BLOCK_LENGTH << 3; + len -= SHA256_BLOCK_LENGTH; + data += SHA256_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + memcpy(context->buffer, data, len); + context->bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void +SHA256_Pad(SHA256_CTX *context) +{ + unsigned int usedspace; + + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->buffer[usedspace++] = 0x80; + + if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) { + /* Set-up for the last transform: */ + memset(&context->buffer[usedspace], 0, + SHA256_SHORT_BLOCK_LENGTH - usedspace); + } else { + if (usedspace < SHA256_BLOCK_LENGTH) { + memset(&context->buffer[usedspace], 0, + SHA256_BLOCK_LENGTH - usedspace); + } + /* Do second-to-last transform: */ + SHA256_Transform(context->state, context->buffer); + + /* Prepare for last transform: */ + memset(context->buffer, 0, SHA256_SHORT_BLOCK_LENGTH); + } + } else { + /* Set-up for the last transform: */ + memset(context->buffer, 0, SHA256_SHORT_BLOCK_LENGTH); + + /* Begin padding with a 1 bit: */ + *context->buffer = 0x80; + } + /* Store the length of input data (in bits) in big endian format: */ + BE_64_TO_8(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], + context->bitcount); + + /* Final transform: */ + SHA256_Transform(context->state, context->buffer); + + /* Clean up: */ + usedspace = 0; +} + +void +SHA256_Final(u_int8_t digest[SHA256_DIGEST_LENGTH], SHA256_CTX *context) +{ + SHA256_Pad(context); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != NULL) { +#if BYTE_ORDER == LITTLE_ENDIAN + int i; + + /* Convert TO host byte order */ + for (i = 0; i < 8; i++) + BE_32_TO_8(digest + i * 4, context->state[i]); +#else + memcpy(digest, context->state, SHA256_DIGEST_LENGTH); +#endif + memset(context, 0, sizeof(*context)); + } +} + + +/*** SHA-512: *********************************************************/ +void +SHA512_Init(SHA512_CTX *context) +{ + if (context == NULL) + return; + memcpy(context->state, sha512_initial_hash_value, + sizeof(sha512_initial_hash_value)); + memset(context->buffer, 0, sizeof(context->buffer)); + context->bitcount[0] = context->bitcount[1] = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-512 round macros: */ + +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) do { \ + BE_8_TO_64(W512[j], data); \ + data += 8; \ + T1 = (h) + Sigma1_512((e)) + Ch((e), (f), (g)) + K512[j] + W512[j]; \ + (d) += T1; \ + (h) = T1 + Sigma0_512((a)) + Maj((a), (b), (c)); \ + j++; \ +} while(0) + + +#define ROUND512(a,b,c,d,e,f,g,h) do { \ + s0 = W512[(j+1)&0x0f]; \ + s0 = sigma0_512(s0); \ + s1 = W512[(j+14)&0x0f]; \ + s1 = sigma1_512(s1); \ + T1 = (h) + Sigma1_512((e)) + Ch((e), (f), (g)) + K512[j] + \ + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_512((a)) + Maj((a), (b), (c)); \ + j++; \ +} while(0) + +void +SHA512_Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH]) +{ + u_int64_t a, b, c, d, e, f, g, h, s0, s1; + u_int64_t T1, W512[16]; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + j = 0; + do { + /* Rounds 0 to 15 (unrolled): */ + ROUND512_0_TO_15(a,b,c,d,e,f,g,h); + ROUND512_0_TO_15(h,a,b,c,d,e,f,g); + ROUND512_0_TO_15(g,h,a,b,c,d,e,f); + ROUND512_0_TO_15(f,g,h,a,b,c,d,e); + ROUND512_0_TO_15(e,f,g,h,a,b,c,d); + ROUND512_0_TO_15(d,e,f,g,h,a,b,c); + ROUND512_0_TO_15(c,d,e,f,g,h,a,b); + ROUND512_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds up to 79: */ + do { + ROUND512(a,b,c,d,e,f,g,h); + ROUND512(h,a,b,c,d,e,f,g); + ROUND512(g,h,a,b,c,d,e,f); + ROUND512(f,g,h,a,b,c,d,e); + ROUND512(e,f,g,h,a,b,c,d); + ROUND512(d,e,f,g,h,a,b,c); + ROUND512(c,d,e,f,g,h,a,b); + ROUND512(b,c,d,e,f,g,h,a); + } while (j < 80); + + /* Compute the current intermediate hash value */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void +SHA512_Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH]) +{ + u_int64_t a, b, c, d, e, f, g, h, s0, s1; + u_int64_t T1, T2, W512[16]; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + j = 0; + do { + BE_8_TO_64(W512[j], data); + data += 8; + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W512[(j+1)&0x0f]; + s0 = sigma0_512(s0); + s1 = W512[(j+14)&0x0f]; + s1 = sigma1_512(s1); + + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 80); + + /* Compute the current intermediate hash value */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void +SHA512_Update(SHA512_CTX *context, const u_int8_t *data, size_t len) +{ + size_t freespace, usedspace; + + /* Calling with no data is valid (we do nothing) */ + if (len == 0) + return; + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA512_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + memcpy(&context->buffer[usedspace], data, freespace); + ADDINC128(context->bitcount, freespace << 3); + len -= freespace; + data += freespace; + SHA512_Transform(context->state, context->buffer); + } else { + /* The buffer is not yet full */ + memcpy(&context->buffer[usedspace], data, len); + ADDINC128(context->bitcount, len << 3); + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA512_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + SHA512_Transform(context->state, data); + ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); + len -= SHA512_BLOCK_LENGTH; + data += SHA512_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + memcpy(context->buffer, data, len); + ADDINC128(context->bitcount, len << 3); + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void +SHA512_Pad(SHA512_CTX *context) +{ + unsigned int usedspace; + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->buffer[usedspace++] = 0x80; + + if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) { + /* Set-up for the last transform: */ + memset(&context->buffer[usedspace], 0, SHA512_SHORT_BLOCK_LENGTH - usedspace); + } else { + if (usedspace < SHA512_BLOCK_LENGTH) { + memset(&context->buffer[usedspace], 0, SHA512_BLOCK_LENGTH - usedspace); + } + /* Do second-to-last transform: */ + SHA512_Transform(context->state, context->buffer); + + /* And set-up for the last transform: */ + memset(context->buffer, 0, SHA512_BLOCK_LENGTH - 2); + } + } else { + /* Prepare for final transform: */ + memset(context->buffer, 0, SHA512_SHORT_BLOCK_LENGTH); + + /* Begin padding with a 1 bit: */ + *context->buffer = 0x80; + } + /* Store the length of input data (in bits) in big endian format: */ + BE_64_TO_8(&context->buffer[SHA512_SHORT_BLOCK_LENGTH], + context->bitcount[1]); + BE_64_TO_8(&context->buffer[SHA512_SHORT_BLOCK_LENGTH + 8], + context->bitcount[0]); + + /* Final transform: */ + SHA512_Transform(context->state, context->buffer); + + /* Clean up: */ + usedspace = 0; +} + +void +SHA512_Final(u_int8_t digest[SHA512_DIGEST_LENGTH], SHA512_CTX *context) +{ + SHA512_Pad(context); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != NULL) { +#if BYTE_ORDER == LITTLE_ENDIAN + int i; + + /* Convert TO host byte order */ + for (i = 0; i < 8; i++) + BE_64_TO_8(digest + i * 8, context->state[i]); +#else + memcpy(digest, context->state, SHA512_DIGEST_LENGTH); +#endif + memset(context, 0, sizeof(*context)); + } +} + + +#if 0 +/*** SHA-384: *********************************************************/ +void +SHA384_Init(SHA384_CTX *context) +{ + if (context == NULL) + return; + memcpy(context->state, sha384_initial_hash_value, + sizeof(sha384_initial_hash_value)); + memset(context->buffer, 0, sizeof(context->buffer)); + context->bitcount[0] = context->bitcount[1] = 0; +} + +__weak_alias(SHA384_Transform, SHA512_Transform); +__weak_alias(SHA384_Update, SHA512_Update); +__weak_alias(SHA384_Pad, SHA512_Pad); + +void +SHA384_Final(u_int8_t digest[SHA384_DIGEST_LENGTH], SHA384_CTX *context) +{ + SHA384_Pad(context); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != NULL) { +#if BYTE_ORDER == LITTLE_ENDIAN + int i; + + /* Convert TO host byte order */ + for (i = 0; i < 6; i++) + BE_64_TO_8(digest + i * 8, context->state[i]); +#else + memcpy(digest, context->state, SHA384_DIGEST_LENGTH); +#endif + } + + /* Zero out state data */ + memset(context, 0, sizeof(*context)); +} +#endif + +#endif /* !defined(HAVE_EVP_SHA256) && !defined(HAVE_SHA256_UPDATE) && \ + (OPENSSL_VERSION_NUMBER >= 0x00907000L) */ diff --git a/openssh/openbsd-compat/sha2.h b/openssh/openbsd-compat/sha2.h new file mode 100755 index 0000000..821f2dd --- /dev/null +++ b/openssh/openbsd-compat/sha2.h @@ -0,0 +1,133 @@ +/* $OpenBSD: sha2.h,v 1.6 2004/06/22 01:57:30 jfb Exp $ */ + +/* + * FILE: sha2.h + * AUTHOR: Aaron D. Gifford + * + * Copyright (c) 2000-2001, Aaron D. Gifford + * 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. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``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 CONTRIBUTOR(S) 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. + * + * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ + */ + +/* OPENBSD ORIGINAL: include/sha2.h */ + +#ifndef _SSHSHA2_H +#define _SSHSHA2_H + +#include "includes.h" + +#include + +#if !defined(HAVE_EVP_SHA256) && !defined(HAVE_SHA256_UPDATE) && \ + (OPENSSL_VERSION_NUMBER >= 0x00907000L) + +/*** SHA-256/384/512 Various Length Definitions ***********************/ +#define SHA256_BLOCK_LENGTH 64 +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_BLOCK_LENGTH 128 +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + + +/*** SHA-256/384/512 Context Structures *******************************/ +typedef struct _SHA256_CTX { + u_int32_t state[8]; + u_int64_t bitcount; + u_int8_t buffer[SHA256_BLOCK_LENGTH]; +} SHA256_CTX; +typedef struct _SHA512_CTX { + u_int64_t state[8]; + u_int64_t bitcount[2]; + u_int8_t buffer[SHA512_BLOCK_LENGTH]; +} SHA512_CTX; + +#if 0 +typedef SHA512_CTX SHA384_CTX; +#endif + +void SHA256_Init(SHA256_CTX *); +void SHA256_Transform(u_int32_t state[8], const u_int8_t [SHA256_BLOCK_LENGTH]); +void SHA256_Update(SHA256_CTX *, const u_int8_t *, size_t) + __attribute__((__bounded__(__string__,2,3))); +void SHA256_Pad(SHA256_CTX *); +void SHA256_Final(u_int8_t [SHA256_DIGEST_LENGTH], SHA256_CTX *) + __attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH))); +char *SHA256_End(SHA256_CTX *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH))); +char *SHA256_File(const char *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH))); +char *SHA256_FileChunk(const char *, char *, off_t, off_t) + __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH))); +char *SHA256_Data(const u_int8_t *, size_t, char *) + __attribute__((__bounded__(__string__,1,2))) + __attribute__((__bounded__(__minbytes__,3,SHA256_DIGEST_STRING_LENGTH))); + +#if 0 +void SHA384_Init(SHA384_CTX *); +void SHA384_Transform(u_int64_t state[8], const u_int8_t [SHA384_BLOCK_LENGTH]); +void SHA384_Update(SHA384_CTX *, const u_int8_t *, size_t) + __attribute__((__bounded__(__string__,2,3))); +void SHA384_Pad(SHA384_CTX *); +void SHA384_Final(u_int8_t [SHA384_DIGEST_LENGTH], SHA384_CTX *) + __attribute__((__bounded__(__minbytes__,1,SHA384_DIGEST_LENGTH))); +char *SHA384_End(SHA384_CTX *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH))); +char *SHA384_File(const char *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH))); +char *SHA384_FileChunk(const char *, char *, off_t, off_t) + __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH))); +char *SHA384_Data(const u_int8_t *, size_t, char *) + __attribute__((__bounded__(__string__,1,2))) + __attribute__((__bounded__(__minbytes__,3,SHA384_DIGEST_STRING_LENGTH))); +#endif /* 0 */ + +void SHA512_Init(SHA512_CTX *); +void SHA512_Transform(u_int64_t state[8], const u_int8_t [SHA512_BLOCK_LENGTH]); +void SHA512_Update(SHA512_CTX *, const u_int8_t *, size_t) + __attribute__((__bounded__(__string__,2,3))); +void SHA512_Pad(SHA512_CTX *); +void SHA512_Final(u_int8_t [SHA512_DIGEST_LENGTH], SHA512_CTX *) + __attribute__((__bounded__(__minbytes__,1,SHA512_DIGEST_LENGTH))); +char *SHA512_End(SHA512_CTX *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH))); +char *SHA512_File(const char *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH))); +char *SHA512_FileChunk(const char *, char *, off_t, off_t) + __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH))); +char *SHA512_Data(const u_int8_t *, size_t, char *) + __attribute__((__bounded__(__string__,1,2))) + __attribute__((__bounded__(__minbytes__,3,SHA512_DIGEST_STRING_LENGTH))); + +#endif /* !defined(HAVE_EVP_SHA256) && !defined(HAVE_SHA256_UPDATE) && \ + (OPENSSL_VERSION_NUMBER >= 0x00907000L) */ + +#endif /* _SSHSHA2_H */ diff --git a/openssh/openbsd-compat/strtonum.c b/openssh/openbsd-compat/strtonum.c index 8ad0d00..87f2f24 100644 --- a/openssh/openbsd-compat/strtonum.c +++ b/openssh/openbsd-compat/strtonum.c @@ -20,8 +20,11 @@ /* OPENBSD ORIGINAL: lib/libc/stdlib/strtonum.c */ #include "includes.h" + #ifndef HAVE_STRTONUM +#include #include +#include #define INVALID 1 #define TOOSMALL 2 diff --git a/openssh/openbsd-compat/xcrypt.c b/openssh/openbsd-compat/xcrypt.c index 9afa0b9..1489932 100644 --- a/openssh/openbsd-compat/xcrypt.c +++ b/openssh/openbsd-compat/xcrypt.c @@ -24,6 +24,10 @@ #include "includes.h" +#include +#include +#include + # ifdef HAVE_CRYPT_H # include # endif diff --git a/openssh/openbsd-compat/xmmap.c b/openssh/openbsd-compat/xmmap.c index d853031..4239d0e 100644 --- a/openssh/openbsd-compat/xmmap.c +++ b/openssh/openbsd-compat/xmmap.c @@ -27,17 +27,27 @@ #include "includes.h" +#include #ifdef HAVE_SYS_MMAN_H #include #endif +#include + +#ifdef HAVE_FCNTL_H +# include +#endif +#include +#include +#include +#include #include "log.h" void *xmmap(size_t size) { +#ifdef HAVE_MMAP void *address; -#ifdef HAVE_MMAP # ifdef MAP_ANON address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, -1, (off_t)0); diff --git a/openssh/openssh.xml.in b/openssh/openssh.xml.in new file mode 100644 index 0000000..655ee5c --- /dev/null +++ b/openssh/openssh.xml.in @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openssh/packet.c b/openssh/packet.c index ee81f68..64970e8 100644 --- a/openssh/packet.c +++ b/openssh/packet.c @@ -1,3 +1,4 @@ +/* $OpenBSD: packet.c,v 1.145 2006/09/19 21:14:08 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -37,26 +38,40 @@ */ #include "includes.h" -RCSID("$OpenBSD: packet.c,v 1.120 2005/10/30 08:52:17 djm Exp $"); - + +#include #include "openbsd-compat/sys-queue.h" +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #include "xmalloc.h" #include "buffer.h" #include "packet.h" -#include "bufaux.h" #include "crc32.h" -#include "getput.h" - #include "compress.h" #include "deattack.h" #include "channels.h" - #include "compat.h" #include "ssh1.h" #include "ssh2.h" - #include "cipher.h" +#include "key.h" #include "kex.h" #include "mac.h" #include "log.h" @@ -258,6 +273,7 @@ packet_get_keyiv_len(int mode) return (cipher_get_keyiv_len(cc)); } + void packet_set_iv(int mode, u_char *dat) { @@ -270,6 +286,7 @@ packet_set_iv(int mode, u_char *dat) cipher_set_keyiv(cc, dat); } + int packet_get_ssh1_cipher(void) { @@ -471,31 +488,37 @@ packet_put_char(int value) buffer_append(&outgoing_packet, &ch, 1); } + void packet_put_int(u_int value) { buffer_put_int(&outgoing_packet, value); } + void packet_put_string(const void *buf, u_int len) { buffer_put_string(&outgoing_packet, buf, len); } + void packet_put_cstring(const char *str) { buffer_put_cstring(&outgoing_packet, str); } + void packet_put_raw(const void *buf, u_int len) { buffer_append(&outgoing_packet, buf, len); } + void packet_put_bignum(BIGNUM * value) { buffer_put_bignum(&outgoing_packet, value); } + void packet_put_bignum2(BIGNUM * value) { @@ -549,7 +572,7 @@ packet_send1(void) /* Add check bytes. */ checksum = ssh_crc32(buffer_ptr(&outgoing_packet), buffer_len(&outgoing_packet)); - PUT_32BIT(buf, checksum); + put_u32(buf, checksum); buffer_append(&outgoing_packet, buf, 4); #ifdef PACKET_DEBUG @@ -558,7 +581,7 @@ packet_send1(void) #endif /* Append to output. */ - PUT_32BIT(buf, len); + put_u32(buf, len); buffer_append(&output, buf, 4); cp = buffer_append_space(&output, buffer_len(&outgoing_packet)); cipher_crypt(&send_context, cp, buffer_ptr(&outgoing_packet), @@ -654,7 +677,7 @@ set_newkeys(int mode) /* * Delayed compression for SSH2 is enabled after authentication: - * This happans on the server side after a SSH2_MSG_USERAUTH_SUCCESS is sent, + * This happens on the server side after a SSH2_MSG_USERAUTH_SUCCESS is sent, * and on the client side after a SSH2_MSG_USERAUTH_SUCCESS is received. */ static void @@ -669,6 +692,9 @@ packet_enable_delayed_compress(void) */ after_authentication = 1; for (mode = 0; mode < MODE_MAX; mode++) { + /* protocol error: USERAUTH_SUCCESS received before NEWKEYS */ + if (newkeys[mode] == NULL) + continue; comp = &newkeys[mode]->comp; if (comp && !comp->enabled && comp->type == COMP_DELAYED) { packet_init_compression(); @@ -761,7 +787,7 @@ packet_send2_wrapped(void) /* packet_length includes payload, padding and padding length field */ packet_length = buffer_len(&outgoing_packet) - 4; cp = buffer_ptr(&outgoing_packet); - PUT_32BIT(cp, packet_length); + put_u32(cp, packet_length); cp[4] = padlen; DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); @@ -778,7 +804,7 @@ packet_send2_wrapped(void) buffer_len(&outgoing_packet)); /* append unencrypted MAC */ if (mac && mac->enabled) - buffer_append(&output, (char *)macbuf, mac->mac_len); + buffer_append(&output, macbuf, mac->mac_len); #ifdef PACKET_DEBUG fprintf(stderr, "encrypted: "); buffer_dump(&output); @@ -868,7 +894,7 @@ packet_read_seqnr(u_int32_t *seqnr_p) char buf[8192]; DBG(debug("packet_read()")); - setp = (fd_set *)xmalloc(howmany(connection_in+1, NFDBITS) * + setp = (fd_set *)xcalloc(howmany(connection_in+1, NFDBITS), sizeof(fd_mask)); /* Since we are blocking, ensure that all written packets have been sent. */ @@ -959,7 +985,7 @@ packet_read_poll1(void) return SSH_MSG_NONE; /* Get length of incoming packet. */ cp = buffer_ptr(&input); - len = GET_32BIT(cp); + len = get_u32(cp); if (len < 1 + 2 + 2 || len > 256 * 1024) packet_disconnect("Bad packet length %u.", len); padded_len = (len + 8) & ~7; @@ -978,9 +1004,16 @@ packet_read_poll1(void) * (C)1998 CORE-SDI, Buenos Aires Argentina * Ariel Futoransky(futo@core-sdi.com) */ - if (!receive_context.plaintext && - detect_attack(buffer_ptr(&input), padded_len, NULL) == DEATTACK_DETECTED) - packet_disconnect("crc32 compensation attack: network attack detected"); + if (!receive_context.plaintext) { + switch (detect_attack(buffer_ptr(&input), padded_len)) { + case DEATTACK_DETECTED: + packet_disconnect("crc32 compensation attack: " + "network attack detected"); + case DEATTACK_DOS_DETECTED: + packet_disconnect("deattack denial of " + "service detected"); + } + } /* Decrypt data to incoming_packet. */ buffer_clear(&incoming_packet); @@ -1007,7 +1040,7 @@ packet_read_poll1(void) len, buffer_len(&incoming_packet)); cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; - stored_checksum = GET_32BIT(cp); + stored_checksum = get_u32(cp); if (checksum != stored_checksum) packet_disconnect("Corrupted check bytes on input."); buffer_consume_end(&incoming_packet, 4); @@ -1056,7 +1089,7 @@ packet_read_poll2(u_int32_t *seqnr_p) cipher_crypt(&receive_context, cp, buffer_ptr(&input), block_size); cp = buffer_ptr(&incoming_packet); - packet_length = GET_32BIT(cp); + packet_length = get_u32(cp); if (packet_length < 1 + 4 || packet_length > 256 * 1024) { #ifdef PACKET_DEBUG buffer_dump(&incoming_packet); @@ -1187,7 +1220,6 @@ packet_read_poll_seqnr(u_int32_t *seqnr_p) break; default: return type; - break; } } else { type = packet_read_poll1(); @@ -1210,7 +1242,6 @@ packet_read_poll_seqnr(u_int32_t *seqnr_p) if (type) DBG(debug("received packet type %d", type)); return type; - break; } } } @@ -1412,7 +1443,7 @@ packet_write_wait(void) { fd_set *setp; - setp = (fd_set *)xmalloc(howmany(connection_out + 1, NFDBITS) * + setp = (fd_set *)xcalloc(howmany(connection_out + 1, NFDBITS), sizeof(fd_mask)); packet_write_poll(); while (packet_have_data_to_write()) { @@ -1480,8 +1511,7 @@ packet_set_interactive(int interactive) /* Only set socket options if using a socket. */ if (!packet_connection_is_on_socket()) return; - if (interactive) - set_nodelay(connection_in); + set_nodelay(connection_in); packet_set_tos(interactive); } @@ -1542,7 +1572,7 @@ packet_send_ignore(int nbytes) for (i = 0; i < nbytes; i++) { if (i % 4 == 0) rnd = arc4random(); - packet_put_char(rnd & 0xff); + packet_put_char((u_char)rnd & 0xff); rnd >>= 8; } } diff --git a/openssh/packet.h b/openssh/packet.h index 3b711cd..6e5cc07 100644 --- a/openssh/packet.h +++ b/openssh/packet.h @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.h,v 1.43 2005/07/25 11:59:40 markus Exp $ */ +/* $OpenBSD: packet.h,v 1.45 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen @@ -16,6 +16,8 @@ #ifndef PACKET_H #define PACKET_H +#include + #include void diff --git a/openssh/pathnames.h b/openssh/pathnames.h index db504e2..9051d3c 100644 --- a/openssh/pathnames.h +++ b/openssh/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.15 2004/07/11 17:48:47 deraadt Exp $ */ +/* $OpenBSD: pathnames.h,v 1.16 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/platform.c b/openssh/platform.c new file mode 100644 index 0000000..abfa9f1 --- /dev/null +++ b/openssh/platform.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* + * Copyright (c) 2006 Darren Tucker. All rights reserved. + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#include "config.h" +#include "platform.h" + +#include "openbsd-compat/openbsd-compat.h" + +void +platform_pre_fork(void) +{ +#ifdef USE_SOLARIS_PROCESS_CONTRACTS + solaris_contract_pre_fork(); +#endif +} + +void +platform_post_fork_parent(pid_t child_pid) +{ +#ifdef USE_SOLARIS_PROCESS_CONTRACTS + solaris_contract_post_fork_parent(child_pid); +#endif +} + +void +platform_post_fork_child(void) +{ +#ifdef USE_SOLARIS_PROCESS_CONTRACTS + solaris_contract_post_fork_child(); +#endif +} diff --git a/openssh/platform.h b/openssh/platform.h new file mode 100644 index 0000000..47e6aad --- /dev/null +++ b/openssh/platform.h @@ -0,0 +1,23 @@ +/* $Id$ */ + +/* + * Copyright (c) 2006 Darren Tucker. All rights reserved. + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + */ + +#include + +void platform_pre_fork(void); +void platform_post_fork_parent(pid_t child_pid); +void platform_post_fork_child(void); diff --git a/openssh/progressmeter.c b/openssh/progressmeter.c index 13c51d8..0f95222 100644 --- a/openssh/progressmeter.c +++ b/openssh/progressmeter.c @@ -1,3 +1,4 @@ +/* $OpenBSD: progressmeter.c,v 1.37 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2003 Nils Nordman. All rights reserved. * @@ -23,7 +24,17 @@ */ #include "includes.h" -RCSID("$OpenBSD: progressmeter.c,v 1.24 2005/06/07 13:25:23 jaredy Exp $"); + +#include +#include +#include + +#include +#include +#include +#include +#include +#include #include "progressmeter.h" #include "atomicio.h" @@ -154,7 +165,7 @@ refresh_progress_meter(void) len = 0; if (len >= file_len + 1) len = file_len; - for (i = len; i < file_len; i++ ) + for (i = len; i < file_len; i++) buf[i] = ' '; buf[file_len] = '\0'; } @@ -215,6 +226,7 @@ refresh_progress_meter(void) last_update = now; } +/*ARGSUSED*/ static void update_progress_meter(int ignore) { @@ -269,6 +281,7 @@ stop_progress_meter(void) atomicio(vwrite, STDOUT_FILENO, "\n", 1); } +/*ARGSUSED*/ static void sig_winch(int sig) { diff --git a/openssh/progressmeter.h b/openssh/progressmeter.h index bfb9a0b..10bab99 100644 --- a/openssh/progressmeter.h +++ b/openssh/progressmeter.h @@ -1,4 +1,4 @@ -/* $OpenBSD: progressmeter.h,v 1.1 2003/01/10 08:19:07 fgsch Exp $ */ +/* $OpenBSD: progressmeter.h,v 1.2 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2002 Nils Nordman. All rights reserved. * diff --git a/openssh/readconf.c b/openssh/readconf.c index c5b0b8e..de7635e 100644 --- a/openssh/readconf.c +++ b/openssh/readconf.c @@ -1,3 +1,4 @@ +/* $OpenBSD: readconf.c,v 1.159 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,17 +13,33 @@ */ #include "includes.h" -RCSID("$OpenBSD: readconf.c,v 1.145 2005/12/08 18:34:11 reyk Exp $"); -#include "ssh.h" +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + #include "xmalloc.h" +#include "ssh.h" #include "compat.h" #include "cipher.h" #include "pathnames.h" #include "log.h" +#include "key.h" #include "readconf.h" #include "match.h" #include "misc.h" +#include "buffer.h" #include "kex.h" #include "mac.h" @@ -94,6 +111,7 @@ RCSID("$OpenBSD: readconf.c,v 1.145 2005/12/08 18:34:11 reyk Exp $"); typedef enum { oBadOption, oForwardAgent, oForwardX11, oForwardX11Trusted, oGatewayPorts, + oExitOnForwardFailure, oPasswordAuthentication, oRSAAuthentication, oChallengeResponseAuthentication, oXAuthLocation, oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward, @@ -128,6 +146,7 @@ static struct { { "forwardagent", oForwardAgent }, { "forwardx11", oForwardX11 }, { "forwardx11trusted", oForwardX11Trusted }, + { "exitonforwardfailure", oExitOnForwardFailure }, { "xauthlocation", oXAuthLocation }, { "gatewayports", oGatewayPorts }, { "useprivilegedport", oUsePrivilegedPort }, @@ -320,7 +339,8 @@ process_config_line(Options *options, const char *host, int *activep) { char *s, **charptr, *endofnumber, *keyword, *arg, *arg2, fwdarg[256]; - int opcode, *intptr, value, value2; + int opcode, *intptr, value, value2, scale; + long long orig, val64; size_t len; Forward fwd; @@ -333,7 +353,8 @@ process_config_line(Options *options, const char *host, s = line; /* Get the keyword. (Each line is supposed to begin with a keyword). */ - keyword = strdelim(&s); + if ((keyword = strdelim(&s)) == NULL) + return 0; /* Ignore leading whitespace. */ if (*keyword == '\0') keyword = strdelim(&s); @@ -390,6 +411,10 @@ parse_flag: intptr = &options->gateway_ports; goto parse_flag; + case oExitOnForwardFailure: + intptr = &options->exit_on_forward_failure; + goto parse_flag; + case oUsePrivilegedPort: intptr = &options->use_privileged_port; goto parse_flag; @@ -522,22 +547,36 @@ parse_yesnoask: 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); + orig = val64 = strtoll(arg, &endofnumber, 10); if (arg == endofnumber) fatal("%.200s line %d: Bad number.", filename, linenum); switch (toupper(*endofnumber)) { + case '\0': + scale = 1; + break; case 'K': - value *= 1<<10; + scale = 1<<10; break; case 'M': - value *= 1<<20; + scale = 1<<20; break; case 'G': - value *= 1<<30; + scale = 1<<30; break; + default: + fatal("%.200s line %d: Invalid RekeyLimit suffix", + filename, linenum); } + val64 *= scale; + /* detect integer wrap and too-large limits */ + if ((val64 / scale) != orig || val64 > INT_MAX) + fatal("%.200s line %d: RekeyLimit too large", + filename, linenum); + if (val64 < 16) + fatal("%.200s line %d: RekeyLimit too small", + filename, linenum); if (*activep && *intptr == -1) - *intptr = value; + *intptr = (int)val64; break; case oIdentityFile: @@ -1010,6 +1049,7 @@ initialize_options(Options * options) options->forward_agent = -1; options->forward_x11 = -1; options->forward_x11_trusted = -1; + options->exit_on_forward_failure = -1; options->xauth_location = NULL; options->gateway_ports = -1; options->use_privileged_port = -1; @@ -1098,6 +1138,8 @@ fill_default_options(Options * options) options->forward_x11 = 0; if (options->forward_x11_trusted == -1) options->forward_x11_trusted = 0; + if (options->exit_on_forward_failure == -1) + options->exit_on_forward_failure = 0; if (options->xauth_location == NULL) options->xauth_location = _PATH_XAUTH; if (options->gateway_ports == -1) @@ -1208,16 +1250,19 @@ fill_default_options(Options * options) options->none_switch = 0; if (options->hpn_disabled == -1) options->hpn_disabled = 0; - if (options->hpn_buffer_size == -1) - options->hpn_buffer_size = 2*1024*1024; - else { + if (options->hpn_buffer_size > -1) + { if (options->hpn_buffer_size == 0) - options->hpn_buffer_size = 1; + options->hpn_buffer_size = 1; /*limit the buffer to 7MB*/ - if (options->hpn_buffer_size > 7168) + if (options->hpn_buffer_size > 7168) + { options->hpn_buffer_size = 7168; + debug("User requested buffer larger than 7MB. Request reverted to 7MB"); + } options->hpn_buffer_size *=1024; - } + debug("hpn_buffer_size set to %d", options->hpn_buffer_size); + } if (options->tcp_rcv_buf == 0) options->tcp_rcv_buf = 1; if (options->tcp_rcv_buf > -1) diff --git a/openssh/readconf.h b/openssh/readconf.h index 0248619..9ac0b3d 100644 --- a/openssh/readconf.h +++ b/openssh/readconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.h,v 1.68 2005/12/06 22:38:27 reyk Exp $ */ +/* $OpenBSD: readconf.h,v 1.71 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -16,8 +16,6 @@ #ifndef READCONF_H #define READCONF_H -#include "key.h" - /* Data structure for representing a forwarding request. */ typedef struct { @@ -34,6 +32,7 @@ typedef struct { int forward_agent; /* Forward authentication agent. */ int forward_x11; /* Forward X11 display. */ int forward_x11_trusted; /* Trust Forward X11 display. */ + int exit_on_forward_failure; /* Exit if bind(2) fails for -L/-R */ 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. */ @@ -45,7 +44,7 @@ typedef struct { int challenge_response_authentication; /* Try S/Key or TIS, authentication. */ int gss_authentication; /* Try GSS authentication */ - int gss_keyex; + int gss_keyex; /* Try GSS key exchange */ int gss_deleg_creds; /* Delegate GSS credentials */ int gss_trust_dns; /* Trust DNS for GSS canonicalization */ int password_authentication; /* Try password diff --git a/openssh/readpass.c b/openssh/readpass.c index 7914799..bd144c2 100644 --- a/openssh/readpass.c +++ b/openssh/readpass.c @@ -1,3 +1,4 @@ +/* $OpenBSD: readpass.c,v 1.47 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,13 +24,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: readpass.c,v 1.33 2005/05/02 21:13:22 markus Exp $"); + +#include +#include + +#include +#include +#ifdef HAVE_PATHS_H +# include +#endif +#include +#include +#include +#include +#include #include "xmalloc.h" #include "misc.h" #include "pathnames.h" #include "log.h" #include "ssh.h" +#include "uidswap.h" static char * ssh_askpass(char *askpass, const char *msg) @@ -53,8 +68,7 @@ ssh_askpass(char *askpass, const char *msg) return NULL; } if (pid == 0) { - seteuid(getuid()); - setuid(getuid()); + permanently_drop_suid(getuid()); close(p[0]); if (dup2(p[1], STDOUT_FILENO) < 0) fatal("ssh_askpass: dup2: %s", strerror(errno)); diff --git a/openssh/regress/Makefile b/openssh/regress/Makefile index 4f47bc3..5399563 100644 --- a/openssh/regress/Makefile +++ b/openssh/regress/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.36 2005/03/04 08:48:46 djm Exp $ +# $OpenBSD: Makefile,v 1.42 2006/07/19 13:34:52 dtucker Exp $ REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t-exec tests: $(REGRESS_TARGETS) @@ -40,7 +40,9 @@ LTESTS= connect \ forwarding \ multiplex \ reexec \ - brokenkeys + brokenkeys \ + cfgmatch \ + forcecommand USER!= id -un CLEANFILES= t2.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \ @@ -49,8 +51,8 @@ CLEANFILES= t2.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \ rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \ rsa-agent rsa-agent.pub rsa1-agent rsa1-agent.pub \ ls.copy banner.in banner.out empty.in \ - scp-ssh-wrapper.scp ssh_proxy_envpass \ - remote_pid + scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \ + sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv #LTESTS += ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp diff --git a/openssh/regress/agent-getpeereid.sh b/openssh/regress/agent-getpeereid.sh index 6186a8d..e5fcedd 100644 --- a/openssh/regress/agent-getpeereid.sh +++ b/openssh/regress/agent-getpeereid.sh @@ -1,4 +1,4 @@ -# $OpenBSD: agent-getpeereid.sh,v 1.2 2005/11/14 21:25:56 grunk Exp $ +# $OpenBSD: agent-getpeereid.sh,v 1.3 2006/07/06 12:01:53 grunk Exp $ # Placed in the Public Domain. tid="disallow agent attach from other uid" @@ -12,6 +12,11 @@ then echo "skipped (not supported on this platform)" exit 0 fi +if [ -z "$SUDO" ]; then + echo "skipped: need SUDO to switch to uid $UNPRIV" + exit 0 +fi + trace "start agent" eval `${SSHAGENT} -s -a ${ASOCK}` > /dev/null diff --git a/openssh/regress/cfgmatch.sh b/openssh/regress/cfgmatch.sh new file mode 100644 index 0000000..d987dcb --- /dev/null +++ b/openssh/regress/cfgmatch.sh @@ -0,0 +1,106 @@ +# $OpenBSD: cfgmatch.sh,v 1.2 2006/07/22 01:50:00 dtucker Exp $ +# Placed in the Public Domain. + +tid="sshd_config match" + +pidfile=$OBJ/remote_pid +fwdport=3301 +fwd="-L $fwdport:127.0.0.1:$PORT" + +stop_client() +{ + pid=`cat $pidfile` + if [ ! -z "$pid" ]; then + kill $pid + sleep 1 + fi +} + +cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak + +echo "PermitOpen 127.0.0.1:1" >>$OBJ/sshd_config +echo "Match Address 127.0.0.1" >>$OBJ/sshd_config +echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_config + +echo "PermitOpen 127.0.0.1:1" >>$OBJ/sshd_proxy +echo "Match Address 127.0.0.1" >>$OBJ/sshd_proxy +echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_proxy + +start_sshd + +#set -x + +# Test Match + PermitOpen in sshd_config. This should be permitted +for p in 1 2; do + rm -f $pidfile + trace "match permitopen localhost proto $p" + ${SSH} -$p $fwd -F $OBJ/ssh_config -f somehost \ + "echo \$\$ > $pidfile; exec sleep 100" >>$TEST_SSH_LOGFILE 2>&1 ||\ + fail "match permitopen proto $p sshd failed" + sleep 1; + ${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \ + fail "match permitopen permit proto $p" + stop_client +done + +# Same but from different source. This should not be permitted +for p in 1 2; do + rm -f $pidfile + trace "match permitopen proxy proto $p" + ${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \ + "echo \$\$ > $pidfile; exec sleep 100" >>$TEST_SSH_LOGFILE 2>&1 ||\ + fail "match permitopen proxy proto $p sshd failed" + sleep 1; + ${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \ + fail "match permitopen deny proto $p" + stop_client +done + +# Retry previous with key option, should also be denied. +echo -n 'permitopen="127.0.0.1:'$PORT'" ' >$OBJ/authorized_keys_$USER +cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER +echo -n 'permitopen="127.0.0.1:'$PORT'" ' >>$OBJ/authorized_keys_$USER +cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER +for p in 1 2; do + rm -f $pidfile + trace "match permitopen proxy w/key opts proto $p" + ${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \ + "echo \$\$ > $pidfile; exec sleep 100" >>$TEST_SSH_LOGFILE 2>&1 ||\ + fail "match permitopen w/key opt proto $p sshd failed" + sleep 1; + ${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \ + fail "match permitopen deny w/key opt proto $p" + stop_client +done + +# Test both sshd_config and key options permitting the same dst/port pair. +# Should be permitted. +for p in 1 2; do + rm -f $pidfile + trace "match permitopen localhost proto $p" + ${SSH} -$p $fwd -F $OBJ/ssh_config -f somehost \ + "echo \$\$ > $pidfile; exec sleep 100" >>$TEST_SSH_LOGFILE 2>&1 ||\ + fail "match permitopen proto $p sshd failed" + sleep 1; + ${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \ + fail "match permitopen permit proto $p" + stop_client +done + +cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy +echo "PermitOpen 127.0.0.1:1 127.0.0.1:$PORT 127.0.0.2:2" >>$OBJ/sshd_proxy +echo "Match User $USER" >>$OBJ/sshd_proxy +echo "PermitOpen 127.0.0.1:1 127.0.0.1:2" >>$OBJ/sshd_proxy + +# Test that a Match overrides a PermitOpen in the global section +for p in 1 2; do + rm -f $pidfile + trace "match permitopen proxy w/key opts proto $p" + ${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \ + "echo \$\$ > $pidfile; exec sleep 100" >>$TEST_SSH_LOGFILE 2>&1 ||\ + fail "match override permitopen proto $p sshd failed" + sleep 1; + ${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \ + fail "match override permitopen proto $p" + stop_client +done diff --git a/openssh/regress/cipher-speed.sh b/openssh/regress/cipher-speed.sh new file mode 100644 index 0000000..5925111 --- /dev/null +++ b/openssh/regress/cipher-speed.sh @@ -0,0 +1,47 @@ +# $OpenBSD: cipher-speed.sh,v 1.2 2005/05/24 04:09:54 djm Exp $ +# Placed in the Public Domain. + +tid="cipher speed" + +getbytes () +{ + sed -n '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p' +} + +tries="1 2" +DATA=/bin/ls +DATA=/bsd + +macs="hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96" +ciphers="aes128-cbc 3des-cbc blowfish-cbc cast128-cbc + arcfour128 arcfour256 arcfour aes192-cbc aes256-cbc aes128-ctr" + +for c in $ciphers; do for m in $macs; do + trace "proto 2 cipher $c mac $m" + for x in $tries; do + echo -n "$c/$m:\t" + ( ${SSH} -o 'compression no' \ + -F $OBJ/ssh_proxy -2 -m $m -c $c somehost \ + exec sh -c \'"dd of=/dev/null obs=32k"\' \ + < ${DATA} ) 2>&1 | getbytes + + if [ $? -ne 0 ]; then + fail "ssh -2 failed with mac $m cipher $c" + fi + done +done; done + +ciphers="3des blowfish" +for c in $ciphers; do + trace "proto 1 cipher $c" + for x in $tries; do + echo -n "$c:\t" + ( ${SSH} -o 'compression no' \ + -F $OBJ/ssh_proxy -1 -c $c somehost \ + exec sh -c \'"dd of=/dev/null obs=32k"\' \ + < ${DATA} ) 2>&1 | getbytes + if [ $? -ne 0 ]; then + fail "ssh -1 failed with cipher $c" + fi + done +done diff --git a/openssh/regress/forcecommand.sh b/openssh/regress/forcecommand.sh new file mode 100644 index 0000000..99e51a6 --- /dev/null +++ b/openssh/regress/forcecommand.sh @@ -0,0 +1,42 @@ +# $OpenBSD: forcecommand.sh,v 1.1 2006/07/19 13:09:28 dtucker Exp $ +# Placed in the Public Domain. + +tid="forced command" + +cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak + +echon 'command="true" ' >$OBJ/authorized_keys_$USER +cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER +echon 'command="true" ' >>$OBJ/authorized_keys_$USER +cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER + +for p in 1 2; do + trace "forced command in key option proto $p" + ${SSH} -$p -F $OBJ/ssh_proxy somehost false \ || + fail "forced command in key proto $p" +done + +echon 'command="false" ' >$OBJ/authorized_keys_$USER +cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER +echon 'command="false" ' >>$OBJ/authorized_keys_$USER +cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER + +cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy +echo "ForceCommand true" >> $OBJ/sshd_proxy + +for p in 1 2; do + trace "forced command in sshd_config overrides key option proto $p" + ${SSH} -$p -F $OBJ/ssh_proxy somehost false \ || + fail "forced command in key proto $p" +done + +cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy +echo "ForceCommand false" >> $OBJ/sshd_proxy +echo "Match User $USER" >> $OBJ/sshd_proxy +echo " ForceCommand true" >> $OBJ/sshd_proxy + +for p in 1 2; do + trace "forced command with match proto $p" + ${SSH} -$p -F $OBJ/ssh_proxy somehost false \ || + fail "forced command in key proto $p" +done diff --git a/openssh/regress/forwarding.sh b/openssh/regress/forwarding.sh index 3b17114..9ffbb3d 100644 --- a/openssh/regress/forwarding.sh +++ b/openssh/regress/forwarding.sh @@ -1,4 +1,4 @@ -# $OpenBSD: forwarding.sh,v 1.5 2005/03/10 10:20:39 dtucker Exp $ +# $OpenBSD: forwarding.sh,v 1.6 2006/07/11 18:51:21 markus Exp $ # Placed in the Public Domain. tid="local and remote forwarding" @@ -33,6 +33,36 @@ for p in 1 2; do sleep 10 done +for p in 1 2; do +for d in L R; do + trace "exit on -$d forward failure, proto $p" + + # this one should succeed + ${SSH} -$p -F $OBJ/ssh_config \ + -$d ${base}01:127.0.0.1:$PORT \ + -$d ${base}02:127.0.0.1:$PORT \ + -$d ${base}03:127.0.0.1:$PORT \ + -$d ${base}04:127.0.0.1:$PORT \ + -oExitOnForwardFailure=yes somehost true + if [ $? != 0 ]; then + fail "connection failed, should not" + else + # this one should fail + ${SSH} -q -$p -F $OBJ/ssh_config \ + -$d ${base}01:127.0.0.1:$PORT \ + -$d ${base}02:127.0.0.1:$PORT \ + -$d ${base}03:127.0.0.1:$PORT \ + -$d ${base}01:127.0.0.1:$PORT \ + -$d ${base}04:127.0.0.1:$PORT \ + -oExitOnForwardFailure=yes somehost true + r=$? + if [ $r != 255 ]; then + fail "connection not termintated, but should ($r)" + fi + fi +done +done + for p in 1 2; do trace "simple clear forwarding proto $p" ${SSH} -$p -F $OBJ/ssh_config -oClearAllForwardings=yes somehost true diff --git a/openssh/rsa.c b/openssh/rsa.c index 66561a4..bec1d19 100644 --- a/openssh/rsa.c +++ b/openssh/rsa.c @@ -1,3 +1,4 @@ +/* $OpenBSD: rsa.c,v 1.29 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -60,11 +61,15 @@ */ #include "includes.h" -RCSID("$OpenBSD: rsa.c,v 1.24 2001/12/27 18:22:16 markus Exp $"); +#include + +#include +#include + +#include "xmalloc.h" #include "rsa.h" #include "log.h" -#include "xmalloc.h" void rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key) @@ -86,7 +91,8 @@ rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key) RSA_PKCS1_PADDING)) <= 0) fatal("rsa_public_encrypt() failed"); - BN_bin2bn(outbuf, len, out); + if (BN_bin2bn(outbuf, len, out) == NULL) + fatal("rsa_public_encrypt: BN_bin2bn failed"); memset(outbuf, 0, olen); memset(inbuf, 0, ilen); @@ -111,7 +117,8 @@ rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key) RSA_PKCS1_PADDING)) <= 0) { error("rsa_private_decrypt() failed"); } else { - BN_bin2bn(outbuf, len, out); + if (BN_bin2bn(outbuf, len, out) == NULL) + fatal("rsa_private_decrypt: BN_bin2bn failed"); } memset(outbuf, 0, olen); memset(inbuf, 0, ilen); @@ -132,11 +139,11 @@ rsa_generate_additional_parameters(RSA *rsa) if ((ctx = BN_CTX_new()) == NULL) fatal("rsa_generate_additional_parameters: BN_CTX_new failed"); - BN_sub(aux, rsa->q, BN_value_one()); - BN_mod(rsa->dmq1, rsa->d, aux, ctx); - - BN_sub(aux, rsa->p, BN_value_one()); - BN_mod(rsa->dmp1, rsa->d, aux, ctx); + if ((BN_sub(aux, rsa->q, BN_value_one()) == 0) || + (BN_mod(rsa->dmq1, rsa->d, aux, ctx) == 0) || + (BN_sub(aux, rsa->p, BN_value_one()) == 0) || + (BN_mod(rsa->dmp1, rsa->d, aux, ctx) == 0)) + fatal("rsa_generate_additional_parameters: BN_sub/mod failed"); BN_clear_free(aux); BN_CTX_free(ctx); diff --git a/openssh/rsa.h b/openssh/rsa.h index 957d865..b841ea4 100644 --- a/openssh/rsa.h +++ b/openssh/rsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.h,v 1.15 2002/03/04 17:27:39 stevesk Exp $ */ +/* $OpenBSD: rsa.h,v 1.16 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/scard-opensc.c b/openssh/scard-opensc.c index dd2c28d..4751ea2 100644 --- a/openssh/scard-opensc.c +++ b/openssh/scard-opensc.c @@ -26,9 +26,13 @@ #include "includes.h" #if defined(SMARTCARD) && defined(USE_OPENSC) +#include + #include #include +#include + #include #include @@ -455,7 +459,9 @@ sc_get_keys(const char *id, const char *pin) } key_count = r; } - keys = xmalloc(sizeof(Key *) * (key_count*2+1)); + if (key_count > 1024) + fatal("Too many keys (%u), expected <= 1024", key_count); + keys = xcalloc(key_count * 2 + 1, sizeof(Key *)); for (i = 0; i < key_count; i++) { sc_pkcs15_object_t *tmp_obj = NULL; cert_id = ((sc_pkcs15_cert_info_t *)(certs[i]->data))->id; diff --git a/openssh/scard.c b/openssh/scard.c index b3d2505..9fd3ca1 100644 --- a/openssh/scard.c +++ b/openssh/scard.c @@ -1,3 +1,4 @@ +/* $OpenBSD: scard.c,v 1.36 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -24,14 +25,18 @@ #include "includes.h" #if defined(SMARTCARD) && defined(USE_SECTOK) -RCSID("$OpenBSD: scard.c,v 1.29 2004/05/08 00:21:31 djm Exp $"); -#include +#include + #include +#include +#include + +#include +#include "xmalloc.h" #include "key.h" #include "log.h" -#include "xmalloc.h" #include "misc.h" #include "scard.h" @@ -125,7 +130,7 @@ sc_init(void) if (status == SCARD_ERROR_NOCARD) { return SCARD_ERROR_NOCARD; } - if (status < 0 ) { + if (status < 0) { error("sc_open failed"); return status; } @@ -215,7 +220,7 @@ sc_private_decrypt(int flen, u_char *from, u_char *to, RSA *rsa, olen = len = sw = 0; if (sc_fd < 0) { status = sc_init(); - if (status < 0 ) + if (status < 0) goto err; } if (padding != RSA_PKCS1_PADDING) @@ -255,7 +260,7 @@ sc_private_encrypt(int flen, u_char *from, u_char *to, RSA *rsa, len = sw = 0; if (sc_fd < 0) { status = sc_init(); - if (status < 0 ) + if (status < 0) goto err; } if (padding != RSA_PKCS1_PADDING) @@ -378,23 +383,25 @@ sc_get_keys(const char *id, const char *pin) key_free(k); return NULL; } - if (status < 0 ) { + if (status < 0) { error("sc_read_pubkey failed"); key_free(k); return NULL; } - keys = xmalloc((nkeys+1) * sizeof(Key *)); + keys = xcalloc((nkeys+1), sizeof(Key *)); n = key_new(KEY_RSA1); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[0] = n; n = key_new(KEY_RSA); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[1] = n; diff --git a/openssh/scard.h b/openssh/scard.h index 9ba20a3..82efe48 100644 --- a/openssh/scard.h +++ b/openssh/scard.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scard.h,v 1.12 2003/06/12 19:12:03 markus Exp $ */ +/* $OpenBSD: scard.h,v 1.14 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -27,8 +27,6 @@ #ifndef SCARD_H #define SCARD_H -#include "key.h" - #define SCARD_ERROR_FAIL -1 #define SCARD_ERROR_NOCARD -2 #define SCARD_ERROR_APPLET -3 diff --git a/openssh/scard/Makefile.in b/openssh/scard/Makefile.in index 07433c1..9a3a553 100644 --- a/openssh/scard/Makefile.in +++ b/openssh/scard/Makefile.in @@ -2,6 +2,7 @@ prefix=@prefix@ datadir=@datadir@ +datarootdir=@datarootdir@ srcdir=@srcdir@ top_srcdir=@top_srcdir@ diff --git a/openssh/scard/Ssh.bin b/openssh/scard/Ssh.bin new file mode 100644 index 0000000000000000000000000000000000000000..edbadc6186c13f8f554bd76ce0e47a8b116b94fc GIT binary patch literal 600 zcmYjNO=}ZT6g~I789VdZnmFlTLq2FwPzVvJh?|NGQWwoe0)A9XG8VzOun5`YPYC{m z7X1PJ3GQ^^q7VfCg5V-dz~vjyZ529j&fItJIp|F|NhkEannOubPK5!dH^hIMJEd54t0AW= zhEoSllfX~rTQ+N0(2~n{AZr#Ca;xZ&+eH;vRLdeXmqZ+pBfFjk_4soivHQs5O`e`Y zzu!bymgN`ze-U)z4zWdiC2kWRh;8C$YU|M+BM#3ZR_YGr{Z5WYi8kM8(>);fyK$l% z=6Ku;)&skT%j-doCplhFQ+tVa8YO8o!Z@Pv^#GH9J~y4HF~{4udbg8W%kkk^L?5eq zp!Q0^T|8T3*L-iw!Xs8fybC_fD7F=c|~q5Rn)WaQ+heSk$yI{!^9b9!sA%QzEv}AmFL-tmsy8s$p=L}R_+tiyLpYX4EGt87u$=X{ V<{0%M-Ma6!-TzNk8=0 if an error occurred. +.Pp +.Ex -std scp .Sh SEE ALSO .Xr rcp 1 , .Xr sftp 1 , diff --git a/openssh/scp.c b/openssh/scp.c index 49bb47b..abf4f7d 100644 --- a/openssh/scp.c +++ b/openssh/scp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: scp.c,v 1.155 2006/08/03 03:34:42 deraadt Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -71,7 +72,30 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.130 2006/01/31 10:35:43 djm Exp $"); + +#include +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "xmalloc.h" #include "atomicio.h" @@ -82,6 +106,8 @@ RCSID("$OpenBSD: scp.c,v 1.130 2006/01/31 10:35:43 djm Exp $"); extern char *__progname; +int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout); + void bwlimit(int); /* Struct for addargs */ @@ -167,7 +193,7 @@ do_local_cmd(arglist *a) */ int -do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) +do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout) { int pin[2], pout[2], reserved[2]; @@ -181,7 +207,8 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) * Reserve two descriptors so that the real pipes won't get * descriptors 0 and 1 because that will screw up dup2 below. */ - pipe(reserved); + if (pipe(reserved) < 0) + fatal("pipe: %s", strerror(errno)); /* Create a socket pair for communicating with ssh. */ if (pipe(pin) < 0) @@ -234,7 +261,6 @@ typedef struct { BUF *allocbuf(BUF *, int, int); void lostconn(int); -void nospace(void); int okname(char *); void run_err(const char *,...); void verifydir(char *); @@ -258,15 +284,21 @@ void usage(void); int main(int argc, char **argv) { - int ch, fflag, tflag, status; + int ch, fflag, tflag, status, n; double speed; - char *targ, *endp; + char *targ, *endp, **newargv; extern char *optarg; extern int optind; /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ sanitise_stdfd(); + /* Copy argv, because we modify it */ + newargv = xcalloc(MAX(argc + 1, 1), sizeof(*newargv)); + for (n = 0; n < argc; n++) + newargv[n] = xstrdup(argv[n]); + argv = newargv; + __progname = ssh_get_progname(argv[0]); init_pathnames(); ssh_program = _PATH_SSH_PROGRAM; @@ -280,7 +312,7 @@ main(int argc, char **argv) addargs(&args, "-oClearAllForwardings yes"); fflag = tflag = 0; - while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246zS:o:F:w:")) != -1) + while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1) switch (ch) { /* User-visible flags. */ case '1': @@ -288,9 +320,8 @@ main(int argc, char **argv) case '4': case '6': case 'C': - case 'z': - addargs(&args, "-%c", ch); - break; + addargs(&args, "-%c", ch); + break; case 'o': case 'c': case 'i': @@ -342,9 +373,6 @@ main(int argc, char **argv) setmode(0, O_BINARY); #endif break; - case 'w': - addargs(&args, "-w%s", optarg); - break; default: usage(); } @@ -415,9 +443,9 @@ main(int argc, char **argv) void toremote(char *targ, int argc, char **argv) { - int i, len; char *bp, *host, *src, *suser, *thost, *tuser, *arg; arglist alist; + int i; memset(&alist, '\0', sizeof(alist)); alist.list = NULL; @@ -482,12 +510,10 @@ toremote(char *targ, int argc, char **argv) errs = 1; } else { /* local to remote */ if (remin == -1) { - len = strlen(targ) + CMDNEEDS + 20; - bp = xmalloc(len); - (void) snprintf(bp, len, "%s -t %s", cmd, targ); + xasprintf(&bp, "%s -t %s", cmd, targ); host = cleanhostname(thost); if (do_cmd(host, tuser, bp, &remin, - &remout, argc) < 0) + &remout) < 0) exit(1); if (response() < 0) exit(1); @@ -496,14 +522,15 @@ toremote(char *targ, int argc, char **argv) source(1, argv + i); } } + xfree(arg); } void tolocal(int argc, char **argv) { - int i, len; char *bp, *host, *src, *suser; arglist alist; + int i; memset(&alist, '\0', sizeof(alist)); alist.list = NULL; @@ -535,10 +562,8 @@ tolocal(int argc, char **argv) suser = pwd->pw_name; } host = cleanhostname(host); - len = strlen(src) + CMDNEEDS + 20; - bp = xmalloc(len); - (void) snprintf(bp, len, "%s -f %s", cmd, src); - if (do_cmd(host, suser, bp, &remin, &remout, argc) < 0) { + xasprintf(&bp, "%s -f %s", cmd, src); + if (do_cmd(host, suser, bp, &remin, &remout) < 0) { (void) xfree(bp); ++errs; continue; @@ -783,7 +808,8 @@ sink(int argc, char **argv) BUF *bp; off_t i; size_t j, count; - int amt, exists, first, mask, mode, ofd, omode; + int amt, exists, first, ofd; + mode_t mode, omode, mask; off_t size, statbytes; int setimes, targisdir, wrerrno = 0; char ch, *cp, *np, *targ, *why, *vect[1], buf[16384]; @@ -1091,7 +1117,7 @@ usage(void) { (void) fprintf(stderr, "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n" - " [-l limit] [-o ssh_option] [-P port] [-w buffer size] [-S program]\n" + " [-l limit] [-o ssh_option] [-P port] [-S program]\n" " [[user@]host1:]file1 [...] [[user@]host2:]file2\n"); exit(1); } @@ -1103,15 +1129,15 @@ run_err(const char *fmt,...) va_list ap; ++errs; - if (fp == NULL && !(fp = fdopen(remout, "w"))) - return; - (void) fprintf(fp, "%c", 0x01); - (void) fprintf(fp, "scp: "); - va_start(ap, fmt); - (void) vfprintf(fp, fmt, ap); - va_end(ap); - (void) fprintf(fp, "\n"); - (void) fflush(fp); + if (fp != NULL || (remout != -1 && (fp = fdopen(remout, "w")))) { + (void) fprintf(fp, "%c", 0x01); + (void) fprintf(fp, "scp: "); + va_start(ap, fmt); + (void) vfprintf(fp, fmt, ap); + va_end(ap); + (void) fprintf(fp, "\n"); + (void) fflush(fp); + } if (!iamremote) { va_start(ap, fmt); @@ -1187,7 +1213,7 @@ allocbuf(BUF *bp, int fd, int blksize) if (bp->buf == NULL) bp->buf = xmalloc(size); else - bp->buf = xrealloc(bp->buf, size); + bp->buf = xrealloc(bp->buf, 1, size); memset(bp->buf, 0, size); bp->cnt = size; return (bp); diff --git a/openssh/servconf.c b/openssh/servconf.c index 9442a56..78766ee 100644 --- a/openssh/servconf.c +++ b/openssh/servconf.c @@ -1,3 +1,4 @@ +/* $OpenBSD: servconf.c,v 1.165 2006/08/14 12:40:25 dtucker Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved @@ -10,24 +11,41 @@ */ #include "includes.h" -RCSID("$OpenBSD: servconf.c,v 1.146 2005/12/08 18:34:11 reyk Exp $"); +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "log.h" +#include "buffer.h" #include "servconf.h" -#include "xmalloc.h" #include "compat.h" #include "pathnames.h" #include "misc.h" #include "cipher.h" +#include "key.h" #include "kex.h" #include "mac.h" +#include "match.h" +#include "channels.h" +#include "groupaccess.h" static void add_listen_addr(ServerOptions *, char *, u_short); static void add_one_listen_addr(ServerOptions *, char *, u_short); /* Use of privilege separation or not */ extern int use_privsep; +extern Buffer cfg; /* Initializes the server options to their default values. */ @@ -79,6 +97,7 @@ initialize_server_options(ServerOptions *options) options->gss_authentication=-1; options->gss_keyex = -1; options->gss_cleanup_creds = -1; + options->gss_strict_acceptor = -1; options->gsi_allow_limited_proxy = -1; options->password_authentication = -1; options->kbd_interactive_authentication = -1; @@ -109,18 +128,20 @@ initialize_server_options(ServerOptions *options) options->authorized_keys_file2 = NULL; options->num_accept_env = 0; options->permit_tun = -1; + options->num_permitted_opens = -1; + options->adm_forced_command = NULL; options->none_enabled = -1; options->tcp_rcv_buf_poll = -1; - options->hpn_disabled = -1; - options->hpn_buffer_size = -1; - - /* Needs to be accessable in many places */ - use_privsep = -1; + options->hpn_disabled = -1; + options->hpn_buffer_size = -1; } void fill_default_server_options(ServerOptions *options) { + int sock; + int socksize; + int socksizelen = sizeof(int); /* Portable-specific options */ if (options->use_pam == -1) @@ -203,6 +224,8 @@ fill_default_server_options(ServerOptions *options) options->gss_keyex = 1; if (options->gss_cleanup_creds == -1) options->gss_cleanup_creds = 1; + if (options->gss_strict_acceptor == -1) + options->gss_strict_acceptor = 1; if (options->gsi_allow_limited_proxy == -1) options->gsi_allow_limited_proxy = 0; if (options->password_authentication == -1) @@ -252,15 +275,43 @@ fill_default_server_options(ServerOptions *options) if (options->hpn_disabled == -1) options->hpn_disabled = 0; - if (options->hpn_buffer_size == -1) - options->hpn_buffer_size = 2*1024*1024; - else { - if (options->hpn_buffer_size == 0) - options->hpn_buffer_size = 1; - /* limit the maximum buffer to 7MB */ - if (options->hpn_buffer_size > 7168) - options->hpn_buffer_size = 7168; - options->hpn_buffer_size *=1024; + if (options->hpn_buffer_size == -1) + { + /* option not explicitly set. Now we have to figure out */ + /* what value to use */ + if (options->hpn_disabled == 1) + { + options->hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT; + } + else + { + /* get the current RCV size and set it to that */ + /*create a socket but don't connect it */ + /* we use that the get the rcv socket size */ + sock = socket(AF_INET, SOCK_STREAM, 0); + getsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &socksize, &socksizelen); + close(sock); + options->hpn_buffer_size = socksize; + debug ("HPN Buffer Size: %d", options->hpn_buffer_size); + + } + } + else + { + /* we have to do this incase the user sets both values in a contradictory */ + /* manner. hpn_disabled overrrides hpn_buffer_size*/ + if (options->hpn_disabled <= 0) + { + if (options->hpn_buffer_size == 0) + options->hpn_buffer_size = 1; + /* limit the maximum buffer to 64MB */ + if (options->hpn_buffer_size > 64*1024) + options->hpn_buffer_size = 64*1024; + options->hpn_buffer_size *=1024; + } + else + options->hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT; } /* Turn privilege separation on by default */ @@ -308,128 +359,146 @@ typedef enum { sBanner, sUseDNS, sHostbasedAuthentication, sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2, + sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor, sGssKeyEx, + sGssCredsPath, sGsiAllowLimitedProxy, - sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, + sAcceptEnv, sPermitTunnel, + sMatch, sPermitOpen, sForceCommand, sUsePrivilegeSeparation, sNoneEnabled, sTcpRcvBufPoll, - sHPNDisabled, sHPNBufferSize, + sHPNDisabled, sHPNBufferSize, sDeprecated, sUnsupported } ServerOpCodes; +#define SSHCFG_GLOBAL 0x01 /* allowed in main section of sshd_config */ +#define SSHCFG_MATCH 0x02 /* allowed inside a Match section */ +#define SSHCFG_ALL (SSHCFG_GLOBAL|SSHCFG_MATCH) + /* Textual representation of the tokens. */ static struct { const char *name; ServerOpCodes opcode; + u_int flags; } keywords[] = { /* Portable-specific options */ #ifdef USE_PAM - { "usepam", sUsePAM }, + { "usepam", sUsePAM, SSHCFG_GLOBAL }, #else - { "usepam", sUnsupported }, + { "usepam", sUnsupported, SSHCFG_GLOBAL }, #endif - { "pamauthenticationviakbdint", sDeprecated }, + { "pamauthenticationviakbdint", sDeprecated, SSHCFG_GLOBAL }, /* Standard Options */ - { "port", sPort }, - { "hostkey", sHostKeyFile }, - { "hostdsakey", sHostKeyFile }, /* alias */ - { "pidfile", sPidFile }, - { "serverkeybits", sServerKeyBits }, - { "logingracetime", sLoginGraceTime }, - { "keyregenerationinterval", sKeyRegenerationTime }, - { "permitrootlogin", sPermitRootLogin }, - { "syslogfacility", sLogFacility }, - { "loglevel", sLogLevel }, - { "rhostsauthentication", sDeprecated }, - { "rhostsrsaauthentication", sRhostsRSAAuthentication }, - { "hostbasedauthentication", sHostbasedAuthentication }, - { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly }, - { "rsaauthentication", sRSAAuthentication }, - { "pubkeyauthentication", sPubkeyAuthentication }, - { "dsaauthentication", sPubkeyAuthentication }, /* alias */ + { "port", sPort, SSHCFG_GLOBAL }, + { "hostkey", sHostKeyFile, SSHCFG_GLOBAL }, + { "hostdsakey", sHostKeyFile, SSHCFG_GLOBAL }, /* alias */ + { "pidfile", sPidFile, SSHCFG_GLOBAL }, + { "serverkeybits", sServerKeyBits, SSHCFG_GLOBAL }, + { "logingracetime", sLoginGraceTime, SSHCFG_GLOBAL }, + { "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL }, + { "permitrootlogin", sPermitRootLogin, SSHCFG_GLOBAL }, + { "syslogfacility", sLogFacility, SSHCFG_GLOBAL }, + { "loglevel", sLogLevel, SSHCFG_GLOBAL }, + { "rhostsauthentication", sDeprecated, SSHCFG_GLOBAL }, + { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_GLOBAL }, + { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_GLOBAL }, + { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_GLOBAL }, + { "rsaauthentication", sRSAAuthentication, SSHCFG_GLOBAL }, + { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, + { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */ #ifdef KRB5 - { "kerberosauthentication", sKerberosAuthentication }, - { "kerberosorlocalpasswd", sKerberosOrLocalPasswd }, - { "kerberosticketcleanup", sKerberosTicketCleanup }, + { "kerberosauthentication", sKerberosAuthentication, SSHCFG_GLOBAL }, + { "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_GLOBAL }, + { "kerberosticketcleanup", sKerberosTicketCleanup, SSHCFG_GLOBAL }, #ifdef USE_AFS - { "kerberosgetafstoken", sKerberosGetAFSToken }, + { "kerberosgetafstoken", sKerberosGetAFSToken, SSHCFG_GLOBAL }, #else - { "kerberosgetafstoken", sUnsupported }, + { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL }, #endif #else - { "kerberosauthentication", sUnsupported }, - { "kerberosorlocalpasswd", sUnsupported }, - { "kerberosticketcleanup", sUnsupported }, - { "kerberosgetafstoken", sUnsupported }, + { "kerberosauthentication", sUnsupported, SSHCFG_GLOBAL }, + { "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL }, + { "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL }, + { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL }, #endif - { "kerberostgtpassing", sUnsupported }, - { "afstokenpassing", sUnsupported }, + { "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL }, + { "afstokenpassing", sUnsupported, SSHCFG_GLOBAL }, #ifdef GSSAPI - { "gssapiauthentication", sGssAuthentication }, - { "gssapikeyexchange", sGssKeyEx }, - { "gssapicleanupcredentials", sGssCleanupCreds }, + { "gssapiauthentication", sGssAuthentication, SSHCFG_GLOBAL }, + { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL }, + { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL }, + { "gssapicredentialspath", sGssCredsPath, SSHCFG_GLOBAL }, + { "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL }, #ifdef GSI - { "gsiallowlimitedproxy", sGsiAllowLimitedProxy }, + { "gsiallowlimitedproxy", sGsiAllowLimitedProxy, SSHCFG_GLOBAL }, #endif #else - { "gssapiauthentication", sUnsupported }, - { "gssapikeyexchange", sUnsupported }, - { "gssapicleanupcredentials", sUnsupported }, + { "gssapiauthentication", sUnsupported, SSHCFG_GLOBAL }, + { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL }, + { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL }, + { "gssapicredentialspath", sUnsupported, SSHCFG_GLOBAL }, + { "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL }, +#ifdef GSI + { "gsiallowlimitedproxy", sUnsupported, SSHCFG_GLOBAL }, +#endif #endif #ifdef SESSION_HOOKS - { "allowsessionhooks", sAllowSessionHooks }, - { "sessionhookstartupcmd", sSessionHookStartupCmd }, - { "sessionhookshutdowncmd", sSessionHookShutdownCmd }, + { "allowsessionhooks", sAllowSessionHooks, SSHCFG_GLOBAL }, + { "sessionhookstartupcmd", sSessionHookStartupCmd, SSHCFG_GLOBAL }, + { "sessionhookshutdowncmd", sSessionHookShutdownCmd, SSHCFG_GLOBAL }, #endif - { "passwordauthentication", sPasswordAuthentication }, - { "kbdinteractiveauthentication", sKbdInteractiveAuthentication }, - { "challengeresponseauthentication", sChallengeResponseAuthentication }, - { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */ - { "checkmail", sDeprecated }, - { "listenaddress", sListenAddress }, - { "addressfamily", sAddressFamily }, - { "printmotd", sPrintMotd }, - { "printlastlog", sPrintLastLog }, - { "ignorerhosts", sIgnoreRhosts }, - { "ignoreuserknownhosts", sIgnoreUserKnownHosts }, - { "x11forwarding", sX11Forwarding }, - { "x11displayoffset", sX11DisplayOffset }, - { "x11uselocalhost", sX11UseLocalhost }, - { "xauthlocation", sXAuthLocation }, - { "strictmodes", sStrictModes }, - { "permitemptypasswords", sEmptyPasswd }, - { "permituserenvironment", sPermitUserEnvironment }, - { "uselogin", sUseLogin }, - { "compression", sCompression }, - { "tcpkeepalive", sTCPKeepAlive }, - { "keepalive", sTCPKeepAlive }, /* obsolete alias */ - { "allowtcpforwarding", sAllowTcpForwarding }, - { "allowusers", sAllowUsers }, - { "denyusers", sDenyUsers }, - { "allowgroups", sAllowGroups }, - { "denygroups", sDenyGroups }, - { "ciphers", sCiphers }, - { "macs", sMacs }, - { "protocol", sProtocol }, - { "gatewayports", sGatewayPorts }, - { "subsystem", sSubsystem }, - { "maxstartups", sMaxStartups }, - { "maxauthtries", sMaxAuthTries }, - { "banner", sBanner }, - { "usedns", sUseDNS }, - { "verifyreversemapping", sDeprecated }, - { "reversemappingcheck", sDeprecated }, - { "clientaliveinterval", sClientAliveInterval }, - { "clientalivecountmax", sClientAliveCountMax }, - { "authorizedkeysfile", sAuthorizedKeysFile }, - { "authorizedkeysfile2", sAuthorizedKeysFile2 }, - { "useprivilegeseparation", sUsePrivilegeSeparation}, - { "acceptenv", sAcceptEnv }, - { "noneenabled", sNoneEnabled }, - { "hpndisabled", sHPNDisabled }, - { "hpnbuffersize", sHPNBufferSize }, - { "tcprcvbufpoll", sTcpRcvBufPoll }, - { "permittunnel", sPermitTunnel }, - { NULL, sBadOption } + { "passwordauthentication", sPasswordAuthentication, SSHCFG_GLOBAL }, + { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_GLOBAL }, + { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, + { "skeyauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, /* alias */ + { "checkmail", sDeprecated, SSHCFG_GLOBAL }, + { "listenaddress", sListenAddress, SSHCFG_GLOBAL }, + { "addressfamily", sAddressFamily, SSHCFG_GLOBAL }, + { "printmotd", sPrintMotd, SSHCFG_GLOBAL }, + { "printlastlog", sPrintLastLog, SSHCFG_GLOBAL }, + { "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL }, + { "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL }, + { "x11forwarding", sX11Forwarding, SSHCFG_ALL }, + { "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL }, + { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL }, + { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL }, + { "strictmodes", sStrictModes, SSHCFG_GLOBAL }, + { "permitemptypasswords", sEmptyPasswd, SSHCFG_GLOBAL }, + { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL }, + { "uselogin", sUseLogin, SSHCFG_GLOBAL }, + { "compression", sCompression, SSHCFG_GLOBAL }, + { "tcpkeepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, + { "keepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, /* obsolete alias */ + { "allowtcpforwarding", sAllowTcpForwarding, SSHCFG_ALL }, + { "allowusers", sAllowUsers, SSHCFG_GLOBAL }, + { "denyusers", sDenyUsers, SSHCFG_GLOBAL }, + { "allowgroups", sAllowGroups, SSHCFG_GLOBAL }, + { "denygroups", sDenyGroups, SSHCFG_GLOBAL }, + { "ciphers", sCiphers, SSHCFG_GLOBAL }, + { "macs", sMacs, SSHCFG_GLOBAL }, + { "protocol", sProtocol, SSHCFG_GLOBAL }, + { "gatewayports", sGatewayPorts, SSHCFG_ALL }, + { "subsystem", sSubsystem, SSHCFG_GLOBAL }, + { "maxstartups", sMaxStartups, SSHCFG_GLOBAL }, + { "maxauthtries", sMaxAuthTries, SSHCFG_GLOBAL }, + { "banner", sBanner, SSHCFG_GLOBAL }, + { "usedns", sUseDNS, SSHCFG_GLOBAL }, + { "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL }, + { "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL }, + { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL }, + { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL }, + { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_GLOBAL }, + { "authorizedkeysfile2", sAuthorizedKeysFile2, SSHCFG_GLOBAL }, + { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL }, + { "acceptenv", sAcceptEnv, SSHCFG_GLOBAL }, + { "permittunnel", sPermitTunnel, SSHCFG_GLOBAL }, + { "match", sMatch, SSHCFG_ALL }, + { "permitopen", sPermitOpen, SSHCFG_ALL }, + { "forcecommand", sForceCommand, SSHCFG_ALL }, + { "noneenabled", sNoneEnabled }, + { "hpndisabled", sHPNDisabled }, + { "hpnbuffersize", sHPNBufferSize }, + { "tcprcvbufpoll", sTcpRcvBufPoll }, + { NULL, sBadOption, 0 } }; /* @@ -438,14 +507,17 @@ static struct { static ServerOpCodes parse_token(const char *cp, const char *filename, - int linenum) + int linenum, u_int *flags) { u_int i; for (i = 0; keywords[i].name; i++) - if (strcasecmp(cp, keywords[i].name) == 0){ - debug ("TOKEN IS %s", keywords[i].name); - return keywords[i].opcode;} + if (strcasecmp(cp, keywords[i].name) == 0) { + debug ("Config token is %s", keywords[i].name); + *flags = keywords[i].flags; + return keywords[i].opcode; + } + error("%s: line %d: Bad configuration option: %s", filename, linenum, cp); return sBadOption; @@ -489,18 +561,171 @@ add_one_listen_addr(ServerOptions *options, char *addr, u_short port) options->listen_addrs = aitop; } +/* + * The strategy for the Match blocks is that the config file is parsed twice. + * + * The first time is at startup. activep is initialized to 1 and the + * directives in the global context are processed and acted on. Hitting a + * Match directive unsets activep and the directives inside the block are + * checked for syntax only. + * + * The second time is after a connection has been established but before + * authentication. activep is initialized to 2 and global config directives + * are ignored since they have already been processed. If the criteria in a + * Match block is met, activep is set and the subsequent directives + * processed and actioned until EOF or another Match block unsets it. Any + * options set are copied into the main server config. + * + * Potential additions/improvements: + * - Add Match support for pre-kex directives, eg Protocol, Ciphers. + * + * - Add a Tag directive (idea from David Leonard) ala pf, eg: + * Match Address 192.168.0.* + * Tag trusted + * Match Group wheel + * Tag trusted + * Match Tag trusted + * AllowTcpForwarding yes + * GatewayPorts clientspecified + * [...] + * + * - Add a PermittedChannelRequests directive + * Match Group shell + * PermittedChannelRequests session,forwarded-tcpip + */ + +static int +match_cfg_line_group(const char *grps, int line, const char *user) +{ + int result = 0; + u_int ngrps = 0; + char *arg, *p, *cp, *grplist[MAX_MATCH_GROUPS]; + struct passwd *pw; + + /* + * Even if we do not have a user yet, we still need to check for + * valid syntax. + */ + arg = cp = xstrdup(grps); + while ((p = strsep(&cp, ",")) != NULL && *p != '\0') { + if (ngrps >= MAX_MATCH_GROUPS) { + error("line %d: too many groups in Match Group", line); + result = -1; + goto out; + } + grplist[ngrps++] = p; + } + + if (user == NULL) + goto out; + + if ((pw = getpwnam(user)) == NULL) { + debug("Can't match group at line %d because user %.100s does " + "not exist", line, user); + } else if (ga_init(pw->pw_name, pw->pw_gid) == 0) { + debug("Can't Match group because user %.100s not in any group " + "at line %d", user, line); + } else if (ga_match(grplist, ngrps) != 1) { + debug("user %.100s does not match group %.100s at line %d", + user, arg, line); + } else { + debug("user %.100s matched group %.100s at line %d", user, + arg, line); + result = 1; + } +out: + ga_free(); + xfree(arg); + return result; +} + +static int +match_cfg_line(char **condition, int line, const char *user, const char *host, + const char *address) +{ + int result = 1; + char *arg, *attrib, *cp = *condition; + size_t len; + + if (user == NULL) + debug3("checking syntax for 'Match %s'", cp); + else + debug3("checking match for '%s' user %s host %s addr %s", cp, + user ? user : "(null)", host ? host : "(null)", + address ? address : "(null)"); + + while ((attrib = strdelim(&cp)) && *attrib != '\0') { + if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { + error("Missing Match criteria for %s", attrib); + return -1; + } + len = strlen(arg); + if (strcasecmp(attrib, "user") == 0) { + if (!user) { + result = 0; + continue; + } + if (match_pattern_list(user, arg, len, 0) != 1) + result = 0; + else + debug("user %.100s matched 'User %.100s' at " + "line %d", user, arg, line); + } else if (strcasecmp(attrib, "group") == 0) { + switch (match_cfg_line_group(arg, line, user)) { + case -1: + return -1; + case 0: + result = 0; + } + } else if (strcasecmp(attrib, "host") == 0) { + if (!host) { + result = 0; + continue; + } + if (match_hostname(host, arg, len) != 1) + result = 0; + else + debug("connection from %.100s matched 'Host " + "%.100s' at line %d", host, arg, line); + } else if (strcasecmp(attrib, "address") == 0) { + debug("address '%s' arg '%s'", address, arg); + if (!address) { + result = 0; + continue; + } + if (match_hostname(address, arg, len) != 1) + result = 0; + else + debug("connection from %.100s matched 'Address " + "%.100s' at line %d", address, arg, line); + } else { + error("Unsupported Match attribute %s", attrib); + return -1; + } + } + if (user != NULL) + debug3("match %sfound", result ? "" : "not "); + *condition = cp; + return result; +} + +#define WHITESPACE " \t\r\n" + int process_server_config_line(ServerOptions *options, char *line, - const char *filename, int linenum) + const char *filename, int linenum, int *activep, const char *user, + const char *host, const char *address) { char *cp, **charptr, *arg, *p; - int *intptr, value, n; + int cmdline = 0, *intptr, value, n; ServerOpCodes opcode; u_short port; - u_int i; + u_int i, flags = 0; + size_t len; cp = line; - arg = strdelim(&cp); + if ((arg = strdelim(&cp)) == NULL) + return 0; /* Ignore leading whitespace */ if (*arg == '\0') arg = strdelim(&cp); @@ -508,7 +733,24 @@ process_server_config_line(ServerOptions *options, char *line, return 0; intptr = NULL; charptr = NULL; - opcode = parse_token(arg, filename, linenum); + opcode = parse_token(arg, filename, linenum, &flags); + + if (activep == NULL) { /* We are processing a command line directive */ + cmdline = 1; + activep = &cmdline; + } + if (*activep && opcode != sMatch) + debug3("%s:%d setting %s %s", filename, linenum, arg, cp); + if (*activep == 0 && !(flags & SSHCFG_MATCH)) { + if (user == NULL) { + fatal("%s line %d: Directive '%s' is not allowed " + "within a Match block", filename, linenum, arg); + } else { /* this is a directive we have already processed */ + while (arg) + arg = strdelim(&cp); + return 0; + } + } switch (opcode) { /* Portable-specific options */ @@ -547,7 +789,7 @@ parse_int: fatal("%s line %d: missing integer value.", filename, linenum); value = atoi(arg); - if (*intptr == -1) + if (*activep && *intptr == -1) *intptr = value; break; @@ -627,7 +869,7 @@ parse_filename: if (!arg || *arg == '\0') fatal("%s line %d: missing file name.", filename, linenum); - if (*charptr == NULL) { + if (*activep && *charptr == NULL) { *charptr = tilde_expand_filename(arg, getuid()); /* increase optional counter */ if (intptr != NULL) @@ -678,7 +920,7 @@ parse_flag: else fatal("%s line %d: Bad yes/no argument: %s", filename, linenum, arg); - if (*intptr == -1) + if (*activep && *intptr == -1) *intptr = value; break; @@ -750,6 +992,14 @@ parse_flag: intptr = &options->gss_cleanup_creds; goto parse_flag; + case sGssStrictAcceptor: + intptr = &options->gss_strict_acceptor; + goto parse_flag; + + case sGssCredsPath: + charptr = &options->gss_creds_path; + goto parse_filename; + case sGsiAllowLimitedProxy: intptr = &options->gsi_allow_limited_proxy; goto parse_flag; @@ -914,7 +1164,7 @@ parse_flag: case sDenyUsers: while ((arg = strdelim(&cp)) && *arg != '\0') { if (options->num_deny_users >= MAX_DENY_USERS) - fatal( "%s line %d: too many deny users.", + fatal("%s line %d: too many deny users.", filename, linenum); options->deny_users[options->num_deny_users++] = xstrdup(arg); @@ -984,6 +1234,10 @@ parse_flag: if (!arg || *arg == '\0') fatal("%s line %d: Missing subsystem name.", filename, linenum); + if (!*activep) { + arg = strdelim(&cp); + break; + } for (i = 0; i < options->num_subsystems; i++) if (strcmp(arg, options->subsystem_name[i]) == 0) fatal("%s line %d: Subsystem '%s' already defined.", @@ -994,6 +1248,17 @@ parse_flag: fatal("%s line %d: Missing subsystem command.", filename, linenum); options->subsystem_command[options->num_subsystems] = xstrdup(arg); + + /* Collect arguments (separate to executable) */ + p = xstrdup(arg); + len = strlen(p) + 1; + while ((arg = strdelim(&cp)) != NULL && *arg != '\0') { + len += 1 + strlen(arg); + p = xrealloc(p, 1, len); + strlcat(p, " ", len); + strlcat(p, arg, len); + } + options->subsystem_args[options->num_subsystems] = p; options->num_subsystems++; break; @@ -1034,7 +1299,7 @@ parse_flag: */ case sAuthorizedKeysFile: case sAuthorizedKeysFile2: - charptr = (opcode == sAuthorizedKeysFile ) ? + charptr = (opcode == sAuthorizedKeysFile) ? &options->authorized_keys_file : &options->authorized_keys_file2; goto parse_filename; @@ -1055,6 +1320,8 @@ parse_flag: if (options->num_accept_env >= MAX_ACCEPT_ENV) fatal("%s line %d: too many allow env.", filename, linenum); + if (!*activep) + break; options->accept_env[options->num_accept_env++] = xstrdup(arg); } @@ -1082,6 +1349,55 @@ parse_flag: *intptr = value; break; + case sMatch: + if (cmdline) + fatal("Match directive not supported as a command-line " + "option"); + value = match_cfg_line(&cp, linenum, user, host, address); + if (value < 0) + fatal("%s line %d: Bad Match condition", filename, + linenum); + *activep = value; + break; + + case sPermitOpen: + arg = strdelim(&cp); + if (!arg || *arg == '\0') + fatal("%s line %d: missing PermitOpen specification", + filename, linenum); + if (strcmp(arg, "any") == 0) { + if (*activep) { + channel_clear_adm_permitted_opens(); + options->num_permitted_opens = 0; + } + break; + } + for (; arg != NULL && *arg != '\0'; arg = strdelim(&cp)) { + p = hpdelim(&arg); + if (p == NULL) + fatal("%s line %d: missing host in PermitOpen", + filename, linenum); + p = cleanhostname(p); + if (arg == NULL || (port = a2port(arg)) == 0) + fatal("%s line %d: bad port number in " + "PermitOpen", filename, linenum); + if (*activep && options->num_permitted_opens == -1) { + channel_clear_adm_permitted_opens(); + options->num_permitted_opens = + channel_add_adm_permitted_opens(p, port); + } + } + break; + + case sForceCommand: + if (cp == NULL) + fatal("%.200s line %d: Missing argument.", filename, + linenum); + len = strspn(cp, WHITESPACE); + if (*activep && options->adm_forced_command == NULL) + options->adm_forced_command = xstrdup(cp + len); + return 0; + case sDeprecated: logit("%s line %d: Deprecated option %s", filename, linenum, arg); @@ -1138,18 +1454,52 @@ load_server_config(const char *filename, Buffer *conf) } void -parse_server_config(ServerOptions *options, const char *filename, Buffer *conf) +parse_server_match_config(ServerOptions *options, const char *user, + const char *host, const char *address) +{ + ServerOptions mo; + + initialize_server_options(&mo); + parse_server_config(&mo, "reprocess config", &cfg, user, host, address); + copy_set_server_options(options, &mo); +} + +/* Copy any (supported) values that are set */ +void +copy_set_server_options(ServerOptions *dst, ServerOptions *src) +{ + if (src->allow_tcp_forwarding != -1) + dst->allow_tcp_forwarding = src->allow_tcp_forwarding; + if (src->gateway_ports != -1) + dst->gateway_ports = src->gateway_ports; + if (src->adm_forced_command != NULL) { + if (dst->adm_forced_command != NULL) + xfree(dst->adm_forced_command); + dst->adm_forced_command = src->adm_forced_command; + } + if (src->x11_display_offset != -1) + dst->x11_display_offset = src->x11_display_offset; + if (src->x11_forwarding != -1) + dst->x11_forwarding = src->x11_forwarding; + if (src->x11_use_localhost != -1) + dst->x11_use_localhost = src->x11_use_localhost; +} + +void +parse_server_config(ServerOptions *options, const char *filename, Buffer *conf, + const char *user, const char *host, const char *address) { - int linenum, bad_options = 0; + int active, linenum, bad_options = 0; char *cp, *obuf, *cbuf; debug2("%s: config %s len %d", __func__, filename, buffer_len(conf)); obuf = cbuf = xstrdup(buffer_ptr(conf)); + active = user ? 0 : 1; linenum = 1; while ((cp = strsep(&cbuf, "\n")) != NULL) { if (process_server_config_line(options, cp, filename, - linenum++) != 0) + linenum++, &active, user, host, address) != 0) bad_options++; } xfree(obuf); diff --git a/openssh/servconf.h b/openssh/servconf.h index 3cf98c5..cfac800 100644 --- a/openssh/servconf.h +++ b/openssh/servconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: servconf.h,v 1.72 2005/12/06 22:38:27 reyk Exp $ */ +/* $OpenBSD: servconf.h,v 1.79 2006/08/14 12:40:25 dtucker Exp $ */ /* * Author: Tatu Ylonen @@ -16,8 +16,6 @@ #ifndef SERVCONF_H #define SERVCONF_H -#include "buffer.h" - #define MAX_PORTS 256 /* Max # ports. */ #define MAX_ALLOW_USERS 256 /* Max # users on allow list. */ @@ -27,6 +25,7 @@ #define MAX_SUBSYSTEMS 256 /* Max # subsystems. */ #define MAX_HOSTKEYS 256 /* Max # hostkeys. */ #define MAX_ACCEPT_ENV 256 /* Max # of env vars. */ +#define MAX_MATCH_GROUPS 256 /* Max # of groups for Match. */ /* permit_root_login */ #define PERMIT_NOT_SET -1 @@ -95,6 +94,8 @@ typedef struct { int gss_authentication; /* If true, permit GSSAPI authentication */ int gss_keyex; /* If true, permit GSSAPI key exchange */ int gss_cleanup_creds; /* If true, destroy cred cache on logout */ + int gss_strict_acceptor; /* If true, restrict the GSSAPI acceptor name */ + char* gss_creds_path; /* If true, destroy cred cache on logout */ int gsi_allow_limited_proxy; /* If true, accept limited proxies */ int password_authentication; /* If true, permit password * authentication. */ @@ -118,6 +119,7 @@ typedef struct { u_int num_subsystems; char *subsystem_name[MAX_SUBSYSTEMS]; char *subsystem_command[MAX_SUBSYSTEMS]; + char *subsystem_args[MAX_SUBSYSTEMS]; u_int num_accept_env; char *accept_env[MAX_ACCEPT_ENV]; @@ -141,6 +143,8 @@ typedef struct { char *authorized_keys_file; /* File containing public keys */ char *authorized_keys_file2; + char *adm_forced_command; + int use_pam; /* Enable auth via PAM */ int none_enabled; /* enable NONE cipher switch */ int tcp_rcv_buf_poll; /* poll tcp rcv window in autotuning kernels*/ @@ -148,12 +152,19 @@ typedef struct { int hpn_buffer_size; /* set the hpn buffer size - default 3MB */ int permit_tun; + + int num_permitted_opens; } ServerOptions; void initialize_server_options(ServerOptions *); void fill_default_server_options(ServerOptions *); -int process_server_config_line(ServerOptions *, char *, const char *, int); +int process_server_config_line(ServerOptions *, char *, const char *, int, + int *, const char *, const char *, const char *); void load_server_config(const char *, Buffer *); -void parse_server_config(ServerOptions *, const char *, Buffer *); +void parse_server_config(ServerOptions *, const char *, Buffer *, + const char *, const char *, const char *); +void parse_server_match_config(ServerOptions *, const char *, const char *, + const char *); +void copy_set_server_options(ServerOptions *, ServerOptions *); #endif /* SERVCONF_H */ diff --git a/openssh/serverloop.c b/openssh/serverloop.c index 5eb5fd5..b175471 100644 --- a/openssh/serverloop.c +++ b/openssh/serverloop.c @@ -1,3 +1,4 @@ +/* $OpenBSD: serverloop.c,v 1.145 2006/10/11 12:38:03 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,7 +36,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: serverloop.c,v 1.124 2005/12/13 15:03:02 reyk Exp $"); + +#include +#include +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include "xmalloc.h" #include "packet.h" @@ -48,13 +67,16 @@ RCSID("$OpenBSD: serverloop.c,v 1.124 2005/12/13 15:03:02 reyk Exp $"); #include "compat.h" #include "ssh1.h" #include "ssh2.h" +#include "key.h" +#include "cipher.h" +#include "kex.h" +#include "hostfile.h" #include "auth.h" #include "session.h" #include "dispatch.h" #include "auth-options.h" #include "serverloop.h" #include "misc.h" -#include "kex.h" extern ServerOptions options; @@ -142,11 +164,11 @@ notify_done(fd_set *readset) debug2("notify_done: reading"); } +/*ARGSUSED*/ static void sigchld_handler(int sig) { int save_errno = errno; - debug("Received SIGCHLD."); child_terminated = 1; #ifndef _UNICOS mysignal(SIGCHLD, sigchld_handler); @@ -155,6 +177,7 @@ sigchld_handler(int sig) errno = save_errno; } +/*ARGSUSED*/ static void sigterm_handler(int sig) { @@ -225,8 +248,10 @@ client_alive_check(void) int channel_id; /* timeout, check to see how many we have had */ - if (++client_alive_timeouts > options.client_alive_count_max) - packet_disconnect("Timeout, your session not responding."); + if (++client_alive_timeouts > options.client_alive_count_max) { + logit("Timeout, client not responding."); + cleanup_exit(255); + } /* * send a bogus global/channel request with "wantreply", @@ -348,7 +373,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, * in buffers and processed later. */ static void -process_input(fd_set * readset) +process_input(fd_set *readset) { int len; char buf[16384]; @@ -380,10 +405,16 @@ process_input(fd_set * readset) /* Read and buffer any available stdout data from the program. */ if (!fdout_eof && FD_ISSET(fdout, readset)) { + errno = 0; len = read(fdout, buf, sizeof(buf)); if (len < 0 && (errno == EINTR || errno == EAGAIN)) { /* do nothing */ +#ifndef PTY_ZEROREAD } else if (len <= 0) { +#else + } else if ((!isatty(fdout) && len <= 0) || + (isatty(fdout) && (len < 0 || (len == 0 && errno != 0)))) { +#endif fdout_eof = 1; } else { buffer_append(&stdout_buffer, buf, len); @@ -392,10 +423,16 @@ process_input(fd_set * readset) } /* Read and buffer any available stderr data from the program. */ if (!fderr_eof && FD_ISSET(fderr, readset)) { + errno = 0; len = read(fderr, buf, sizeof(buf)); if (len < 0 && (errno == EINTR || errno == EAGAIN)) { /* do nothing */ +#ifndef PTY_ZEROREAD } else if (len <= 0) { +#else + } else if ((!isatty(fderr) && len <= 0) || + (isatty(fderr) && (len < 0 || (len == 0 && errno != 0)))) { +#endif fderr_eof = 1; } else { buffer_append(&stderr_buffer, buf, len); @@ -407,7 +444,7 @@ process_input(fd_set * readset) * Sends data from internal buffers to client program stdin. */ static void -process_output(fd_set * writeset) +process_output(fd_set *writeset) { struct termios tio; u_char *data; @@ -749,6 +786,7 @@ collect_children(void) sigaddset(&nset, SIGCHLD); sigprocmask(SIG_BLOCK, &nset, &oset); if (child_terminated) { + debug("Received SIGCHLD."); while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || (pid < 0 && errno == EINTR)) if (pid > 0) @@ -873,10 +911,10 @@ server_input_eof(int type, u_int32_t seq, void *ctxt) static void server_input_window_size(int type, u_int32_t seq, void *ctxt) { - int row = packet_get_int(); - int col = packet_get_int(); - int xpixel = packet_get_int(); - int ypixel = packet_get_int(); + u_int row = packet_get_int(); + u_int col = packet_get_int(); + u_int xpixel = packet_get_int(); + u_int ypixel = packet_get_int(); debug("Window change received."); packet_check_eom(); @@ -942,7 +980,7 @@ server_request_tun(void) tun = packet_get_int(); if (forced_tun_device != -1) { - if (tun != SSH_TUNID_ANY && forced_tun_device != tun) + if (tun != SSH_TUNID_ANY && forced_tun_device != tun) goto done; tun = forced_tun_device; } @@ -1097,6 +1135,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt) success = channel_cancel_rport_listener(cancel_address, cancel_port); + xfree(cancel_address); } if (want_reply) { packet_start(success ? @@ -1106,6 +1145,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt) } xfree(rtype); } + static void server_input_channel_req(int type, u_int32_t seq, void *ctxt) { diff --git a/openssh/serverloop.h b/openssh/serverloop.h index f419198..7311558 100644 --- a/openssh/serverloop.h +++ b/openssh/serverloop.h @@ -1,4 +1,4 @@ -/* $OpenBSD: serverloop.h,v 1.5 2001/06/27 02:12:53 markus Exp $ */ +/* $OpenBSD: serverloop.h,v 1.6 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/session.c b/openssh/session.c index d542ed4..db0eb05 100644 --- a/openssh/session.c +++ b/openssh/session.c @@ -1,3 +1,4 @@ +/* $OpenBSD: session.c,v 1.220 2006/10/09 23:36:11 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved @@ -33,12 +34,35 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.191 2005/12/24 02:27:41 djm Exp $"); +#include +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#include +#include +#include + +#include + +#include +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" #include "ssh2.h" -#include "xmalloc.h" #include "sshpty.h" #include "packet.h" #include "buffer.h" @@ -46,7 +70,12 @@ RCSID("$OpenBSD: session.c,v 1.191 2005/12/24 02:27:41 djm Exp $"); #include "uidswap.h" #include "compat.h" #include "channels.h" -#include "bufaux.h" +#include "key.h" +#include "cipher.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif +#include "hostfile.h" #include "auth.h" #include "auth-options.h" #include "pathnames.h" @@ -63,10 +92,6 @@ RCSID("$OpenBSD: session.c,v 1.191 2005/12/24 02:27:41 djm Exp $"); #include #endif -#ifdef GSSAPI -#include "ssh-gss.h" -#endif - /* func */ Session *session_new(void); @@ -180,7 +205,7 @@ auth_input_request_forwarding(struct passwd * pw) sunaddr.sun_family = AF_UNIX; strlcpy(sunaddr.sun_path, auth_sock_name, sizeof(sunaddr.sun_path)); - if (bind(sock, (struct sockaddr *) & sunaddr, sizeof(sunaddr)) < 0) + if (bind(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) < 0) packet_disconnect("bind: %.100s", strerror(errno)); /* Restore the privileged uid. */ @@ -343,9 +368,12 @@ do_authenticated1(Authctxt *authctxt) break; } debug("Received TCP/IP port forwarding request."); - channel_input_port_forward_request(s->pw->pw_uid == 0, options.gateway_ports, - options.hpn_disabled, - options.hpn_buffer_size); + if (channel_input_port_forward_request(s->pw->pw_uid == 0, + options.gateway_ports, options.hpn_disabled, + options.hpn_buffer_size) < 0) { + debug("Port forwarding failed."); + break; + } success = 1; break; @@ -655,7 +683,7 @@ do_pre_login(Session *s) fromlen = sizeof(from); if (packet_connection_is_on_socket()) { if (getpeername(packet_get_connection_in(), - (struct sockaddr *) & from, &fromlen) < 0) { + (struct sockaddr *)&from, &fromlen) < 0) { debug("getpeername: %.100s", strerror(errno)); cleanup_exit(255); } @@ -674,10 +702,14 @@ do_pre_login(Session *s) void do_exec(Session *s, const char *command) { - if (forced_command) { + if (options.adm_forced_command) { + original_command = command; + command = options.adm_forced_command; + debug("Forced command (config) '%.900s'", command); + } else if (forced_command) { original_command = command; command = forced_command; - debug("Forced command '%.900s'", command); + debug("Forced command (key option) '%.900s'", command); } #if defined(SESSION_HOOKS) @@ -869,7 +901,7 @@ child_set_env(char ***envp, u_int *envsizep, const char *name, if (envsize >= 1000) fatal("child_set_env: too many env vars"); envsize += 50; - env = (*envp) = xrealloc(env, envsize * sizeof(char *)); + env = (*envp) = xrealloc(env, envsize, sizeof(char *)); *envsizep = envsize; } /* Need to set the NULL pointer at end of array beyond the new slot. */ @@ -1121,12 +1153,15 @@ do_setup_env(Session *s, const char *shell) { char buf[256]; u_int i, envsize; - char **env, *laddr, *path = NULL; + char **env, *laddr; struct passwd *pw = s->pw; +#ifndef HAVE_LOGIN_CAP + char *path = NULL; +#endif /* Initialize the environment. */ envsize = 100; - env = xmalloc(envsize * sizeof(char *)); + env = xcalloc(envsize, sizeof(char *)); env[0] = NULL; #ifdef HAVE_CYGWIN @@ -1515,6 +1550,10 @@ do_setusercontext(struct passwd *pw) #endif if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid) fatal("Failed to set uids to %u.", (u_int) pw->pw_uid); + +#ifdef WITH_SELINUX + ssh_selinux_setup_exec_context(pw->pw_name); +#endif } static void @@ -1781,7 +1820,7 @@ do_child(Session *s, const char *command) do_rc_files(s, shell); /* restore SIGPIPE for child */ - signal(SIGPIPE, SIG_DFL); + signal(SIGPIPE, SIG_DFL); if (options.use_login) { launch_login(pw, hostname); @@ -2045,7 +2084,7 @@ session_subsystem_req(Session *s) struct stat st; u_int len; int success = 0; - char *cmd, *subsys = packet_get_string(&len); + char *prog, *cmd, *subsys = packet_get_string(&len); u_int i; packet_check_eom(); @@ -2053,9 +2092,10 @@ session_subsystem_req(Session *s) for (i = 0; i < options.num_subsystems; i++) { if (strcmp(subsys, options.subsystem_name[i]) == 0) { - cmd = options.subsystem_command[i]; - if (stat(cmd, &st) < 0) { - error("subsystem: cannot stat %s: %s", cmd, + prog = options.subsystem_command[i]; + cmd = options.subsystem_args[i]; + if (stat(prog, &st) < 0) { + error("subsystem: cannot stat %s: %s", prog, strerror(errno)); break; } @@ -2152,8 +2192,8 @@ session_env_req(Session *s) for (i = 0; i < options.num_accept_env; i++) { if (match_pattern(name, options.accept_env[i])) { debug2("Setting env %d: %s=%s", s->num_env, name, val); - s->env = xrealloc(s->env, sizeof(*s->env) * - (s->num_env + 1)); + s->env = xrealloc(s->env, s->num_env + 1, + sizeof(*s->env)); s->env[s->num_env].name = name; s->env[s->num_env].val = val; s->num_env++; @@ -2408,7 +2448,7 @@ session_exit_message(Session *s, int status) /* * Adjust cleanup callback attachment to send close messages when - * the channel gets EOF. The session will be then be closed + * the channel gets EOF. The session will be then be closed * by session_close_by_channel when the childs close their fds. */ channel_register_cleanup(c->self, session_close_by_channel, 1); @@ -2444,12 +2484,13 @@ session_close(Session *s) if (s->auth_proto) xfree(s->auth_proto); s->used = 0; - for (i = 0; i < s->num_env; i++) { - xfree(s->env[i].name); - xfree(s->env[i].val); - } - if (s->env != NULL) + if (s->env != NULL) { + for (i = 0; i < s->num_env; i++) { + xfree(s->env[i].name); + xfree(s->env[i].val); + } xfree(s->env); + } session_proctitle(s); } @@ -2666,7 +2707,7 @@ do_cleanup(Authctxt *authctxt) return; called = 1; - if (authctxt == NULL) + if (authctxt == NULL || !authctxt->authenticated) return; #ifdef KRB5 if (options.kerberos_ticket_cleanup && diff --git a/openssh/session.h b/openssh/session.h index a2598a9..ee9338e 100644 --- a/openssh/session.h +++ b/openssh/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.25 2005/07/17 06:49:04 djm Exp $ */ +/* $OpenBSD: session.h,v 1.29 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. @@ -34,11 +34,13 @@ struct Session { struct passwd *pw; Authctxt *authctxt; pid_t pid; + /* tty */ char *term; int ptyfd, ttyfd, ptymaster; u_int row, col, xpixel, ypixel; char tty[TTYSZ]; + /* X11 */ u_int display_number; char *display; @@ -47,6 +49,7 @@ struct Session { char *auth_proto; char *auth_data; int single_connection; + /* proto 2 */ int chanid; int *x11_chanids; @@ -55,7 +58,7 @@ struct Session { struct { char *name; char *val; - } *env; + } *env; }; void do_authenticated(Authctxt *); diff --git a/openssh/sftp-client.c b/openssh/sftp-client.c index 05bce33..42eb2b4 100644 --- a/openssh/sftp-client.c +++ b/openssh/sftp-client.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sftp-client.c,v 1.75 2006/10/22 02:25:50 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -20,17 +21,32 @@ /* XXX: copy between two remote sites */ #include "includes.h" -RCSID("$OpenBSD: sftp-client.c,v 1.58 2006/01/02 01:20:31 djm Exp $"); +#include +#include #include "openbsd-compat/sys-queue.h" +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include + +#include +#include +#include +#include +#include +#include +#include -#include "buffer.h" -#include "bufaux.h" -#include "getput.h" #include "xmalloc.h" +#include "buffer.h" #include "log.h" #include "atomicio.h" #include "progressmeter.h" +#include "misc.h" #include "sftp.h" #include "sftp-common.h" @@ -39,7 +55,7 @@ RCSID("$OpenBSD: sftp-client.c,v 1.58 2006/01/02 01:20:31 djm Exp $"); extern volatile sig_atomic_t interrupted; extern int showprogress; -/* Minimum amount of data to read at at time */ +/* Minimum amount of data to read at a time */ #define MIN_READ_SIZE 512 struct sftp_conn { @@ -55,16 +71,19 @@ static void send_msg(int fd, Buffer *m) { u_char mlen[4]; + struct iovec iov[2]; if (buffer_len(m) > SFTP_MAX_MSG_LENGTH) fatal("Outbound message too long %u", buffer_len(m)); /* Send length first */ - PUT_32BIT(mlen, buffer_len(m)); - if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen)) - fatal("Couldn't send packet: %s", strerror(errno)); + put_u32(mlen, buffer_len(m)); + iov[0].iov_base = mlen; + iov[0].iov_len = sizeof(mlen); + iov[1].iov_base = buffer_ptr(m); + iov[1].iov_len = buffer_len(m); - if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) != buffer_len(m)) + if (atomiciov(writev, fd, iov, 2) != buffer_len(m) + sizeof(mlen)) fatal("Couldn't send packet: %s", strerror(errno)); buffer_clear(m); @@ -388,8 +407,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag, printf("%s\n", longname); if (dir) { - *dir = xrealloc(*dir, sizeof(**dir) * - (ents + 2)); + *dir = xrealloc(*dir, ents + 2, sizeof(**dir)); (*dir)[ents] = xmalloc(sizeof(***dir)); (*dir)[ents]->filename = xstrdup(filename); (*dir)[ents]->longname = xstrdup(longname); @@ -1116,6 +1134,8 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path, if (status != SSH2_FX_OK) { error("Couldn't write to remote file \"%s\": %s", remote_path, fx2txt(status)); + if (showprogress) + stop_progress_meter(); do_close(conn, handle, handle_len); close(local_fd); xfree(data); diff --git a/openssh/sftp-common.c b/openssh/sftp-common.c index 4cea3c3..7ebadcc 100644 --- a/openssh/sftp-common.c +++ b/openssh/sftp-common.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sftp-common.c,v 1.20 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Damien Miller. All rights reserved. @@ -24,12 +25,21 @@ */ #include "includes.h" -RCSID("$OpenBSD: sftp-common.c,v 1.10 2003/11/10 16:23:41 jakob Exp $"); +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "buffer.h" -#include "bufaux.h" #include "log.h" -#include "xmalloc.h" #include "sftp.h" #include "sftp-common.h" diff --git a/openssh/sftp-common.h b/openssh/sftp-common.h index 2b1995a..9b58484 100644 --- a/openssh/sftp-common.h +++ b/openssh/sftp-common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-common.h,v 1.6 2006/01/02 01:20:31 djm Exp $ */ +/* $OpenBSD: sftp-common.h,v 1.10 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. diff --git a/openssh/sftp-glob.c b/openssh/sftp-glob.c index 16c5e20..cdc2708 100644 --- a/openssh/sftp-glob.c +++ b/openssh/sftp-glob.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sftp-glob.c,v 1.22 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -15,14 +16,18 @@ */ #include "includes.h" -RCSID("$OpenBSD: sftp-glob.c,v 1.15 2004/02/17 07:17:29 djm Exp $"); -#include "buffer.h" -#include "bufaux.h" -#include "xmalloc.h" -#include "log.h" +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#include +#include + +#include "xmalloc.h" #include "sftp.h" +#include "buffer.h" #include "sftp-common.h" #include "sftp-client.h" diff --git a/openssh/sftp-server.8 b/openssh/sftp-server.8 index 42f5d43..199c4f3 100644 --- a/openssh/sftp-server.8 +++ b/openssh/sftp-server.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sftp-server.8,v 1.10 2003/10/08 08:27:36 jmc Exp $ +.\" $OpenBSD: sftp-server.8,v 1.11 2006/07/06 10:47:57 djm Exp $ .\" .\" Copyright (c) 2000 Markus Friedl. All rights reserved. .\" @@ -30,6 +30,8 @@ .Nd SFTP server subsystem .Sh SYNOPSIS .Nm sftp-server +.Op Fl f Ar log_facility +.Op Fl l Ar log_level .Sh DESCRIPTION .Nm is a program that speaks the server side of SFTP protocol @@ -40,9 +42,36 @@ is not intended to be called directly, but from using the .Cm Subsystem option. +.Pp +Command-line flags to +.Nm +should be specified in the +.Cm Subsystem +declaration. See .Xr sshd_config 5 for more information. +.Pp +Valid options are: +.Bl -tag -width Ds +.It Fl f Ar log_facility +Specifies the facility code that is used when logging messages from +.Nm . +The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, +LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. +The default is AUTH. +.It Fl l Ar log_level +Specifies which messages will be logged by +.Nm . +The possible values are: +QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. +INFO and VERBOSE log transactions that +.Nm +performs on behalf of the client. +DEBUG and DEBUG1 are equivalent. +DEBUG2 and DEBUG3 each specify higher levels of debugging output. +The default is ERROR. +.El .Sh SEE ALSO .Xr sftp 1 , .Xr ssh 1 , @@ -56,8 +85,9 @@ for more information. .%D January 2001 .%O work in progress material .Re -.Sh AUTHORS -.An Markus Friedl Aq markus@openbsd.org .Sh HISTORY .Nm -first appeared in OpenBSD 2.8 . +first appeared in +.Ox 2.8 . +.Sh AUTHORS +.An Markus Friedl Aq markus@openbsd.org diff --git a/openssh/sftp-server.c b/openssh/sftp-server.c index 6f1d91c..459cc34 100644 --- a/openssh/sftp-server.c +++ b/openssh/sftp-server.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sftp-server.c,v 1.70 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. * @@ -13,15 +14,33 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include "includes.h" -RCSID("$OpenBSD: sftp-server.c,v 1.50 2006/01/02 01:20:31 djm Exp $"); +#include +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "buffer.h" -#include "bufaux.h" -#include "getput.h" #include "log.h" -#include "xmalloc.h" #include "misc.h" +#include "uidswap.h" #include "sftp.h" #include "sftp-common.h" @@ -30,9 +49,13 @@ RCSID("$OpenBSD: sftp-server.c,v 1.50 2006/01/02 01:20:31 djm Exp $"); #define get_int64() buffer_get_int64(&iqueue); #define get_int() buffer_get_int(&iqueue); #define get_string(lenp) buffer_get_string(&iqueue, lenp); -#define TRACE debug -extern char *__progname; +/* Our verbosity */ +LogLevel log_level = SYSLOG_LEVEL_ERROR; + +/* Our client */ +struct passwd *pw = NULL; +char *client_addr = NULL; /* input and output queue */ Buffer iqueue; @@ -104,6 +127,33 @@ flags_from_portable(int pflags) return flags; } +static const char * +string_from_portable(int pflags) +{ + static char ret[128]; + + *ret = '\0'; + +#define PAPPEND(str) { \ + if (*ret != '\0') \ + strlcat(ret, ",", sizeof(ret)); \ + strlcat(ret, str, sizeof(ret)); \ + } + + if (pflags & SSH2_FXF_READ) + PAPPEND("READ") + if (pflags & SSH2_FXF_WRITE) + PAPPEND("WRITE") + if (pflags & SSH2_FXF_CREAT) + PAPPEND("CREATE") + if (pflags & SSH2_FXF_TRUNC) + PAPPEND("TRUNCATE") + if (pflags & SSH2_FXF_EXCL) + PAPPEND("EXCL") + + return ret; +} + static Attrib * get_attrib(void) { @@ -118,6 +168,7 @@ struct Handle { DIR *dirp; int fd; char *name; + u_int64_t bytes_read, bytes_write; }; enum { @@ -148,6 +199,7 @@ handle_new(int use, const char *name, int fd, DIR *dirp) handles[i].dirp = dirp; handles[i].fd = fd; handles[i].name = xstrdup(name); + handles[i].bytes_read = handles[i].bytes_write = 0; return i; } } @@ -167,7 +219,7 @@ handle_to_string(int handle, char **stringp, int *hlenp) if (stringp == NULL || hlenp == NULL) return -1; *stringp = xmalloc(sizeof(int32_t)); - PUT_32BIT(*stringp, handle); + put_u32(*stringp, handle); *hlenp = sizeof(int32_t); return 0; } @@ -179,7 +231,7 @@ handle_from_string(const char *handle, u_int hlen) if (hlen != sizeof(int32_t)) return -1; - val = GET_32BIT(handle); + val = get_u32(handle); if (handle_is_ok(val, HANDLE_FILE) || handle_is_ok(val, HANDLE_DIR)) return val; @@ -211,6 +263,36 @@ handle_to_fd(int handle) return -1; } +static void +handle_update_read(int handle, ssize_t bytes) +{ + if (handle_is_ok(handle, HANDLE_FILE) && bytes > 0) + handles[handle].bytes_read += bytes; +} + +static void +handle_update_write(int handle, ssize_t bytes) +{ + if (handle_is_ok(handle, HANDLE_FILE) && bytes > 0) + handles[handle].bytes_write += bytes; +} + +static u_int64_t +handle_bytes_read(int handle) +{ + if (handle_is_ok(handle, HANDLE_FILE)) + return (handles[handle].bytes_read); + return 0; +} + +static u_int64_t +handle_bytes_write(int handle) +{ + if (handle_is_ok(handle, HANDLE_FILE)) + return (handles[handle].bytes_write); + return 0; +} + static int handle_close(int handle) { @@ -230,6 +312,31 @@ handle_close(int handle) return ret; } +static void +handle_log_close(int handle, char *emsg) +{ + if (handle_is_ok(handle, HANDLE_FILE)) { + logit("%s%sclose \"%s\" bytes read %llu written %llu", + emsg == NULL ? "" : emsg, emsg == NULL ? "" : " ", + handle_to_name(handle), + handle_bytes_read(handle), handle_bytes_write(handle)); + } else { + logit("%s%sclosedir \"%s\"", + emsg == NULL ? "" : emsg, emsg == NULL ? "" : " ", + handle_to_name(handle)); + } +} + +static void +handle_log_exit(void) +{ + u_int i; + + for (i = 0; i < sizeof(handles)/sizeof(Handle); i++) + if (handles[i].use != HANDLE_UNUSED) + handle_log_close(i, "forced"); +} + static int get_handle(void) { @@ -256,10 +363,9 @@ send_msg(Buffer *m) buffer_consume(m, mlen); } -static void -send_status(u_int32_t id, u_int32_t status) +static const char * +status_to_message(u_int32_t status) { - Buffer msg; const char *status_messages[] = { "Success", /* SSH_FX_OK */ "End of file", /* SSH_FX_EOF */ @@ -272,15 +378,24 @@ send_status(u_int32_t id, u_int32_t status) "Operation unsupported", /* SSH_FX_OP_UNSUPPORTED */ "Unknown error" /* Others */ }; + return (status_messages[MIN(status,SSH2_FX_MAX)]); +} + +static void +send_status(u_int32_t id, u_int32_t status) +{ + Buffer msg; - TRACE("sent status id %u error %u", id, status); + debug3("request %u: sent status %u", id, status); + if (log_level > SYSLOG_LEVEL_VERBOSE || + (status != SSH2_FX_OK && status != SSH2_FX_EOF)) + logit("sent status %s", status_to_message(status)); buffer_init(&msg); buffer_put_char(&msg, SSH2_FXP_STATUS); buffer_put_int(&msg, id); buffer_put_int(&msg, status); if (version >= 3) { - buffer_put_cstring(&msg, - status_messages[MIN(status,SSH2_FX_MAX)]); + buffer_put_cstring(&msg, status_to_message(status)); buffer_put_cstring(&msg, ""); } send_msg(&msg); @@ -302,7 +417,7 @@ send_data_or_handle(char type, u_int32_t id, const char *data, int dlen) static void send_data(u_int32_t id, const char *data, int dlen) { - TRACE("sent data id %u len %d", id, dlen); + debug("request %u: sent data len %d", id, dlen); send_data_or_handle(SSH2_FXP_DATA, id, data, dlen); } @@ -313,7 +428,7 @@ send_handle(u_int32_t id, int handle) int hlen; handle_to_string(handle, &string, &hlen); - TRACE("sent handle id %u handle %d", id, handle); + debug("request %u: sent handle handle %d", id, handle); send_data_or_handle(SSH2_FXP_HANDLE, id, string, hlen); xfree(string); } @@ -328,7 +443,7 @@ send_names(u_int32_t id, int count, const Stat *stats) buffer_put_char(&msg, SSH2_FXP_NAME); buffer_put_int(&msg, id); buffer_put_int(&msg, count); - TRACE("sent names id %u count %d", id, count); + debug("request %u: sent names count %d", id, count); for (i = 0; i < count; i++) { buffer_put_cstring(&msg, stats[i].name); buffer_put_cstring(&msg, stats[i].long_name); @@ -343,7 +458,7 @@ send_attrib(u_int32_t id, const Attrib *a) { Buffer msg; - TRACE("sent attrib id %u have 0x%x", id, a->flags); + debug("request %u: sent attrib have 0x%x", id, a->flags); buffer_init(&msg); buffer_put_char(&msg, SSH2_FXP_ATTRS); buffer_put_int(&msg, id); @@ -360,7 +475,7 @@ process_init(void) Buffer msg; version = get_int(); - TRACE("client version %d", version); + verbose("received client version %d", version); buffer_init(&msg); buffer_put_char(&msg, SSH2_FXP_VERSION); buffer_put_int(&msg, SSH2_FILEXFER_VERSION); @@ -379,10 +494,12 @@ process_open(void) id = get_int(); name = get_string(NULL); pflags = get_int(); /* portable flags */ + debug3("request %u: open flags %d", id, pflags); a = get_attrib(); flags = flags_from_portable(pflags); mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666; - TRACE("open id %u name %s flags %d mode 0%o", id, name, pflags, mode); + logit("open \"%s\" flags %s mode 0%o", + name, string_from_portable(pflags), mode); fd = open(name, flags, mode); if (fd < 0) { status = errno_to_portable(errno); @@ -408,7 +525,8 @@ process_close(void) id = get_int(); handle = get_handle(); - TRACE("close id %u handle %d", id, handle); + debug3("request %u: close handle %u", id, handle); + handle_log_close(handle, NULL); ret = handle_close(handle); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); @@ -427,11 +545,11 @@ process_read(void) off = get_int64(); len = get_int(); - TRACE("read id %u handle %d off %llu len %d", id, handle, - (unsigned long long)off, len); + debug("request %u: read \"%s\" (handle %d) off %llu len %d", + id, handle_to_name(handle), handle, (unsigned long long)off, len); if (len > sizeof buf) { len = sizeof buf; - logit("read change len %d", len); + debug2("read change len %d", len); } fd = handle_to_fd(handle); if (fd >= 0) { @@ -447,6 +565,7 @@ process_read(void) } else { send_data(id, buf, ret); status = SSH2_FX_OK; + handle_update_read(handle, ret); } } } @@ -468,8 +587,8 @@ process_write(void) off = get_int64(); data = get_string(&len); - TRACE("write id %u handle %d off %llu len %d", id, handle, - (unsigned long long)off, len); + debug("request %u: write \"%s\" (handle %d) off %llu len %d", + id, handle_to_name(handle), handle, (unsigned long long)off, len); fd = handle_to_fd(handle); if (fd >= 0) { if (lseek(fd, off, SEEK_SET) < 0) { @@ -483,8 +602,9 @@ process_write(void) status = errno_to_portable(errno); } else if ((size_t)ret == len) { status = SSH2_FX_OK; + handle_update_write(handle, ret); } else { - logit("nothing at all written"); + debug2("nothing at all written"); } } } @@ -503,7 +623,8 @@ process_do_stat(int do_lstat) id = get_int(); name = get_string(NULL); - TRACE("%sstat id %u name %s", do_lstat ? "l" : "", id, name); + debug3("request %u: %sstat", id, do_lstat ? "l" : ""); + verbose("%sstat name \"%s\"", do_lstat ? "l" : "", name); ret = do_lstat ? lstat(name, &st) : stat(name, &st); if (ret < 0) { status = errno_to_portable(errno); @@ -539,7 +660,8 @@ process_fstat(void) id = get_int(); handle = get_handle(); - TRACE("fstat id %u handle %d", id, handle); + debug("request %u: fstat \"%s\" (handle %u)", + id, handle_to_name(handle), handle); fd = handle_to_fd(handle); if (fd >= 0) { ret = fstat(fd, &st); @@ -578,23 +700,33 @@ process_setstat(void) id = get_int(); name = get_string(NULL); a = get_attrib(); - TRACE("setstat id %u name %s", id, name); + debug("request %u: setstat name \"%s\"", id, name); if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { + logit("set \"%s\" size %llu", name, a->size); ret = truncate(name, a->size); if (ret == -1) status = errno_to_portable(errno); } if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { + logit("set \"%s\" mode %04o", name, a->perm); ret = chmod(name, a->perm & 0777); if (ret == -1) status = errno_to_portable(errno); } if (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME) { + char buf[64]; + time_t t = a->mtime; + + strftime(buf, sizeof(buf), "%Y%m%d-%H:%M:%S", + localtime(&t)); + logit("set \"%s\" modtime %s", name, buf); ret = utimes(name, attrib_to_tv(a)); if (ret == -1) status = errno_to_portable(errno); } if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) { + logit("set \"%s\" owner %lu group %lu", name, + (u_long)a->uid, (u_long)a->gid); ret = chown(name, a->uid, a->gid); if (ret == -1) status = errno_to_portable(errno); @@ -610,23 +742,25 @@ process_fsetstat(void) u_int32_t id; int handle, fd, ret; int status = SSH2_FX_OK; - char *name; id = get_int(); handle = get_handle(); a = get_attrib(); - TRACE("fsetstat id %u handle %d", id, handle); + debug("request %u: fsetstat handle %d", id, handle); fd = handle_to_fd(handle); - name = handle_to_name(handle); - if (fd < 0 || name == NULL) { + if (fd < 0) { status = SSH2_FX_FAILURE; } else { + char *name = handle_to_name(handle); + if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { + logit("set \"%s\" size %llu", name, a->size); ret = ftruncate(fd, a->size); if (ret == -1) status = errno_to_portable(errno); } if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { + logit("set \"%s\" mode %04o", name, a->perm); #ifdef HAVE_FCHMOD ret = fchmod(fd, a->perm & 0777); #else @@ -636,6 +770,12 @@ process_fsetstat(void) status = errno_to_portable(errno); } if (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME) { + char buf[64]; + time_t t = a->mtime; + + strftime(buf, sizeof(buf), "%Y%m%d-%H:%M:%S", + localtime(&t)); + logit("set \"%s\" modtime %s", name, buf); #ifdef HAVE_FUTIMES ret = futimes(fd, attrib_to_tv(a)); #else @@ -645,6 +785,8 @@ process_fsetstat(void) status = errno_to_portable(errno); } if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) { + logit("set \"%s\" owner %lu group %lu", name, + (u_long)a->uid, (u_long)a->gid); #ifdef HAVE_FCHOWN ret = fchown(fd, a->uid, a->gid); #else @@ -667,7 +809,8 @@ process_opendir(void) id = get_int(); path = get_string(NULL); - TRACE("opendir id %u path %s", id, path); + debug3("request %u: opendir", id); + logit("opendir \"%s\"", path); dirp = opendir(path); if (dirp == NULL) { status = errno_to_portable(errno); @@ -697,22 +840,23 @@ process_readdir(void) id = get_int(); handle = get_handle(); - TRACE("readdir id %u handle %d", id, handle); + debug("request %u: readdir \"%s\" (handle %d)", id, + handle_to_name(handle), handle); dirp = handle_to_dir(handle); path = handle_to_name(handle); if (dirp == NULL || path == NULL) { send_status(id, SSH2_FX_FAILURE); } else { struct stat st; - char pathname[1024]; + char pathname[MAXPATHLEN]; Stat *stats; int nstats = 10, count = 0, i; - stats = xmalloc(nstats * sizeof(Stat)); + stats = xcalloc(nstats, sizeof(Stat)); while ((dp = readdir(dirp)) != NULL) { if (count >= nstats) { nstats *= 2; - stats = xrealloc(stats, nstats * sizeof(Stat)); + stats = xrealloc(stats, nstats, sizeof(Stat)); } /* XXX OVERFLOW ? */ snprintf(pathname, sizeof pathname, "%s%s%s", path, @@ -751,7 +895,8 @@ process_remove(void) id = get_int(); name = get_string(NULL); - TRACE("remove id %u name %s", id, name); + debug3("request %u: remove", id); + logit("remove name \"%s\"", name); ret = unlink(name); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); @@ -771,7 +916,8 @@ process_mkdir(void) a = get_attrib(); mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm & 0777 : 0777; - TRACE("mkdir id %u name %s mode 0%o", id, name, mode); + debug3("request %u: mkdir", id); + logit("mkdir name \"%s\" mode 0%o", name, mode); ret = mkdir(name, mode); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); @@ -787,7 +933,8 @@ process_rmdir(void) id = get_int(); name = get_string(NULL); - TRACE("rmdir id %u name %s", id, name); + debug3("request %u: rmdir", id); + logit("rmdir name \"%s\"", name); ret = rmdir(name); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); @@ -807,7 +954,8 @@ process_realpath(void) xfree(path); path = xstrdup("."); } - TRACE("realpath id %u path %s", id, path); + debug3("request %u: realpath", id); + verbose("realpath \"%s\"", path); if (realpath(path, resolvedname) == NULL) { send_status(id, errno_to_portable(errno)); } else { @@ -830,7 +978,8 @@ process_rename(void) id = get_int(); oldpath = get_string(NULL); newpath = get_string(NULL); - TRACE("rename id %u old %s new %s", id, oldpath, newpath); + debug3("request %u: rename", id); + logit("rename old \"%s\" new \"%s\"", oldpath, newpath); status = SSH2_FX_FAILURE; if (lstat(oldpath, &sb) == -1) status = errno_to_portable(errno); @@ -885,7 +1034,8 @@ process_readlink(void) id = get_int(); path = get_string(NULL); - TRACE("readlink id %u path %s", id, path); + debug3("request %u: readlink", id); + verbose("readlink \"%s\"", path); if ((len = readlink(path, buf, sizeof(buf) - 1)) == -1) send_status(id, errno_to_portable(errno)); else { @@ -909,7 +1059,8 @@ process_symlink(void) id = get_int(); oldpath = get_string(NULL); newpath = get_string(NULL); - TRACE("symlink id %u old %s new %s", id, oldpath, newpath); + debug3("request %u: symlink", id); + logit("symlink old \"%s\" new \"%s\"", oldpath, newpath); /* this will fail if 'newpath' exists */ ret = symlink(oldpath, newpath); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; @@ -945,10 +1096,11 @@ process(void) if (buf_len < 5) return; /* Incomplete message. */ cp = buffer_ptr(&iqueue); - msg_len = GET_32BIT(cp); + msg_len = get_u32(cp); if (msg_len > SFTP_MAX_MSG_LENGTH) { - error("bad message "); - exit(11); + error("bad message from %s local user %s", + client_addr, pw->pw_name); + cleanup_exit(11); } if (buf_len < msg_len + 4) return; @@ -1022,7 +1174,7 @@ process(void) } /* discard the remaining bytes from the current packet */ if (buf_len < buffer_len(&iqueue)) - fatal("iqueue grows"); + fatal("iqueue grew unexpectedly"); consumed = buf_len - buffer_len(&iqueue); if (msg_len < consumed) fatal("msg_len %d < consumed %d", msg_len, consumed); @@ -1030,27 +1182,96 @@ process(void) buffer_consume(&iqueue, msg_len - consumed); } +/* Cleanup handler that logs active handles upon normal exit */ +void +cleanup_exit(int i) +{ + if (pw != NULL && client_addr != NULL) { + handle_log_exit(); + logit("session closed for local user %s from [%s]", + pw->pw_name, client_addr); + } + _exit(i); +} + +static void +usage(void) +{ + extern char *__progname; + + fprintf(stderr, + "usage: %s [-he] [-l log_level] [-f log_facility]\n", __progname); + exit(1); +} + int -main(int ac, char **av) +main(int argc, char **argv) { fd_set *rset, *wset; - int in, out, max; + int in, out, max, ch, skipargs = 0, log_stderr = 0; ssize_t len, olen, set_size; + SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; + char *cp; + + extern char *optarg; + extern char *__progname; /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ sanitise_stdfd(); - /* XXX should use getopt */ - - __progname = ssh_get_progname(av[0]); + __progname = ssh_get_progname(argv[0]); /* NB: No call to init_pathnames() here. The sftp-server doesn't use any fixed paths, which is good, because GLOBUS_LOCATION isn't defined in our environment. */ - handle_init(); + log_init(__progname, log_level, log_facility, log_stderr); + + while (!skipargs && (ch = getopt(argc, argv, "C:f:l:che")) != -1) { + switch (ch) { + case 'c': + /* + * Ignore all arguments if we are invoked as a + * shell using "sftp-server -c command" + */ + skipargs = 1; + break; + case 'e': + log_stderr = 1; + break; + case 'l': + log_level = log_level_number(optarg); + if (log_level == SYSLOG_LEVEL_NOT_SET) + error("Invalid log level \"%s\"", optarg); + break; + case 'f': + log_facility = log_facility_number(optarg); + if (log_level == SYSLOG_FACILITY_NOT_SET) + error("Invalid log facility \"%s\"", optarg); + break; + case 'h': + default: + usage(); + } + } -#ifdef DEBUG_SFTP_SERVER - log_init("sftp-server", SYSLOG_LEVEL_DEBUG1, SYSLOG_FACILITY_AUTH, 0); -#endif + log_init(__progname, log_level, log_facility, log_stderr); + + if ((cp = getenv("SSH_CONNECTION")) != NULL) { + client_addr = xstrdup(cp); + if ((cp = strchr(client_addr, ' ')) == NULL) + fatal("Malformed SSH_CONNECTION variable: \"%s\"", + getenv("SSH_CONNECTION")); + *cp = '\0'; + } else + client_addr = xstrdup("UNKNOWN"); + + if ((pw = getpwuid(getuid())) == NULL) + fatal("No user found for uid %lu", (u_long)getuid()); + pw = pwcopy(pw); + + logit("session opened for local user %s from [%s]", + pw->pw_name, client_addr); + + handle_init(); in = dup(STDIN_FILENO); out = dup(STDOUT_FILENO); @@ -1085,7 +1306,8 @@ main(int ac, char **av) if (select(max+1, rset, wset, NULL, NULL) < 0) { if (errno == EINTR) continue; - exit(2); + error("select: %s", strerror(errno)); + cleanup_exit(2); } /* copy stdin to iqueue */ @@ -1094,10 +1316,10 @@ main(int ac, char **av) len = read(in, buf, sizeof buf); if (len == 0) { debug("read eof"); - exit(0); + cleanup_exit(0); } else if (len < 0) { - error("read error"); - exit(1); + error("read: %s", strerror(errno)); + cleanup_exit(1); } else { buffer_append(&iqueue, buf, len); } @@ -1106,8 +1328,8 @@ main(int ac, char **av) if (FD_ISSET(out, wset)) { len = write(out, buffer_ptr(&oqueue), olen); if (len < 0) { - error("write error"); - exit(1); + error("write: %s", strerror(errno)); + cleanup_exit(1); } else { buffer_consume(&oqueue, len); } diff --git a/openssh/sftp.c b/openssh/sftp.c index c0cde23..8ffe45c 100644 --- a/openssh/sftp.c +++ b/openssh/sftp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sftp.c,v 1.93 2006/09/30 17:48:22 ray Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -16,21 +17,39 @@ #include "includes.h" -RCSID("$OpenBSD: sftp.c,v 1.70 2006/01/31 10:19:02 djm Exp $"); +#include +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#include +#include +#include + +#include +#ifdef HAVE_PATHS_H +# include +#endif #ifdef USE_LIBEDIT #include #else typedef void EditLine; #endif +#include +#include +#include +#include +#include +#include -#include "buffer.h" #include "xmalloc.h" #include "log.h" #include "pathnames.h" #include "misc.h" #include "sftp.h" +#include "buffer.h" #include "sftp-common.h" #include "sftp-client.h" @@ -235,7 +254,7 @@ local_do_shell(const char *args) if (errno != EINTR) fatal("Couldn't wait for child: %s", strerror(errno)); if (!WIFEXITED(status)) - error("Shell exited abormally"); + error("Shell exited abnormally"); else if (WEXITSTATUS(status)) error("Shell exited with status %d", WEXITSTATUS(status)); } @@ -474,7 +493,7 @@ is_dir(char *path) if (stat(path, &sb) == -1) return(0); - return(sb.st_mode & S_IFDIR); + return(S_ISDIR(sb.st_mode)); } static int @@ -498,7 +517,7 @@ remote_is_dir(struct sftp_conn *conn, char *path) return(0); if (!(a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)) return(0); - return(a->perm & S_IFDIR); + return(S_ISDIR(a->perm)); } static int @@ -538,6 +557,7 @@ process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag) if (g.gl_matchc == 1 && dst) { /* If directory specified, append filename */ + xfree(tmp); if (is_dir(dst)) { if (infer_path(g.gl_pathv[0], &tmp)) { err = 1; @@ -562,8 +582,6 @@ process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag) out: xfree(abs_src); - if (abs_dst) - xfree(abs_dst); globfree(&g); return(err); } @@ -959,6 +977,7 @@ parse_args(const char **cpp, int *pflag, int *lflag, int *iflag, case I_CHOWN: case I_CHGRP: /* Get numeric arg (mandatory) */ + errno = 0; l = strtol(cp, &cp2, base); if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || l < 0) { @@ -1280,6 +1299,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) if (parse_dispatch_command(conn, cmd, &pwd, 1) != 0) { xfree(dir); xfree(pwd); + xfree(conn); return (-1); } } else { @@ -1292,6 +1312,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) err = parse_dispatch_command(conn, cmd, &pwd, 1); xfree(dir); xfree(pwd); + xfree(conn); return (err); } xfree(dir); @@ -1356,6 +1377,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) break; } xfree(pwd); + xfree(conn); #ifdef USE_LIBEDIT if (el != NULL) @@ -1457,7 +1479,7 @@ main(int argc, char **argv) ssh_program = _PATH_SSH_PROGRAM; memset(&args, '\0', sizeof(args)); args.list = NULL; - addargs(&args, ssh_program); + addargs(&args, "%s", ssh_program); addargs(&args, "-oForwardX11 no"); addargs(&args, "-oForwardAgent no"); addargs(&args, "-oPermitLocalCommand no"); diff --git a/openssh/sftp.h b/openssh/sftp.h index 675c608..610c0b7 100644 --- a/openssh/sftp.h +++ b/openssh/sftp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.h,v 1.4 2002/02/13 00:59:23 djm Exp $ */ +/* $OpenBSD: sftp.h,v 1.5 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. diff --git a/openssh/ssh-add.c b/openssh/ssh-add.c index 17c6ee7..6ea931e 100644 --- a/openssh/ssh-add.c +++ b/openssh/ssh-add.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-add.c,v 1.89 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,15 +36,27 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-add.c,v 1.74 2005/11/12 18:37:59 deraadt Exp $"); + +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "rsa.h" #include "log.h" -#include "xmalloc.h" #include "key.h" +#include "buffer.h" #include "authfd.h" #include "authfile.h" #include "pathnames.h" @@ -124,16 +137,25 @@ delete_all(AuthenticationConnection *ac) static int add_file(AuthenticationConnection *ac, const char *filename) { - struct stat st; Key *private; char *comment = NULL; char msg[1024]; - int ret = -1; + int fd, perms_ok, ret = -1; - if (stat(filename, &st) < 0) { + if ((fd = open(filename, O_RDONLY)) < 0) { perror(filename); return -1; } + + /* + * Since we'll try to load a keyfile multiple times, permission errors + * will occur multiple times, so check perms first and bail if wrong. + */ + perms_ok = key_perm_ok(fd, filename); + close(fd); + if (!perms_ok) + return -1; + /* At first, try empty passphrase */ private = key_load_private(filename, "", &comment); if (comment == NULL) @@ -287,7 +309,7 @@ do_file(AuthenticationConnection *ac, int deleting, char *file) static void usage(void) { - fprintf(stderr, "Usage: %s [options]\n", __progname); + fprintf(stderr, "Usage: %s [options] [file ...]\n", __progname); fprintf(stderr, "Options:\n"); fprintf(stderr, " -l List fingerprints of all identities.\n"); fprintf(stderr, " -L List public key parameters of all identities.\n"); @@ -336,13 +358,11 @@ main(int argc, char **argv) if (list_identities(ac, ch == 'l' ? 1 : 0) == -1) ret = 1; goto done; - break; case 'x': case 'X': if (lock_agent(ac, ch == 'x' ? 1 : 0) == -1) ret = 1; goto done; - break; case 'c': confirm = 1; break; @@ -353,7 +373,6 @@ main(int argc, char **argv) if (delete_all(ac) == -1) ret = 1; goto done; - break; case 's': sc_reader_id = optarg; break; diff --git a/openssh/ssh-agent.1 b/openssh/ssh-agent.1 index fd6bd3f..f1b8777 100644 --- a/openssh/ssh-agent.1 +++ b/openssh/ssh-agent.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-agent.1,v 1.43 2005/11/28 06:02:56 dtucker Exp $ +.\" $OpenBSD: ssh-agent.1,v 1.44 2006/07/18 08:03:09 jmc Exp $ .\" .\" Author: Tatu Ylonen .\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -70,7 +70,7 @@ The options are as follows: Bind the agent to the unix-domain socket .Ar bind_address . The default is -.Pa /tmp/ssh-XXXXXXXXXX/agent. . +.Pa /tmp/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt . .It Fl c Generate C-shell commands on .Dv stdout . @@ -185,7 +185,7 @@ Contains the protocol version 1 RSA authentication identity of the user. Contains the protocol version 2 DSA authentication identity of the user. .It Pa ~/.ssh/id_rsa Contains the protocol version 2 RSA authentication identity of the user. -.It Pa /tmp/ssh-XXXXXXXXXX/agent. +.It Pa /tmp/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt Unix-domain sockets used to contain the connection to the authentication agent. These sockets should only be readable by the owner. diff --git a/openssh/ssh-agent.c b/openssh/ssh-agent.c index e9a1c2c..7bec3d2 100644 --- a/openssh/ssh-agent.c +++ b/openssh/ssh-agent.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-agent.c,v 1.153 2006/10/06 02:29:19 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -34,18 +35,40 @@ */ #include "includes.h" + +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_SYS_UN_H +# include +#endif #include "openbsd-compat/sys-queue.h" -RCSID("$OpenBSD: ssh-agent.c,v 1.124 2005/10/30 08:52:18 djm Exp $"); #include #include +#include +#include +#ifdef HAVE_PATHS_H +# include +#endif +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "rsa.h" #include "buffer.h" -#include "bufaux.h" -#include "xmalloc.h" -#include "getput.h" #include "key.h" #include "authfd.h" #include "compat.h" @@ -100,8 +123,8 @@ int max_fd = 0; pid_t parent_pid = -1; /* pathname and directory for AUTH_SOCKET */ -char socket_name[1024]; -char socket_dir[1024]; +char socket_name[MAXPATHLEN]; +char socket_dir[MAXPATHLEN]; /* locking */ int locked = 0; @@ -306,8 +329,8 @@ process_sign_request2(SocketEntry *e) Identity *id = lookup_identity(key, 2); if (id != NULL && (!id->confirm || confirm_key(id) == 0)) ok = key_sign(id->key, &signature, &slen, data, dlen); + key_free(key); } - key_free(key); buffer_init(&msg); if (ok == 0) { buffer_put_char(&msg, SSH2_AGENT_SIGN_RESPONSE); @@ -682,7 +705,7 @@ process_message(SocketEntry *e) if (buffer_len(&e->input) < 5) return; /* Incomplete message. */ cp = buffer_ptr(&e->input); - msg_len = GET_32BIT(cp); + msg_len = get_u32(cp); if (msg_len > 256 * 1024) { close_socket(e); return; @@ -794,10 +817,7 @@ new_socket(sock_type type, int fd) } old_alloc = sockets_alloc; new_alloc = sockets_alloc + 10; - if (sockets) - sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0])); - else - sockets = xmalloc(new_alloc * sizeof(sockets[0])); + sockets = xrealloc(sockets, new_alloc, sizeof(sockets[0])); for (i = old_alloc; i < new_alloc; i++) sockets[i].type = AUTH_UNUSED; sockets_alloc = new_alloc; @@ -878,7 +898,7 @@ after_select(fd_set *readset, fd_set *writeset) if (FD_ISSET(sockets[i].fd, readset)) { slen = sizeof(sunaddr); sock = accept(sockets[i].fd, - (struct sockaddr *) &sunaddr, &slen); + (struct sockaddr *)&sunaddr, &slen); if (sock < 0) { error("accept from AUTH_SOCKET: %s", strerror(errno)); @@ -955,6 +975,7 @@ cleanup_exit(int i) _exit(i); } +/*ARGSUSED*/ static void cleanup_handler(int sig) { @@ -962,6 +983,7 @@ cleanup_handler(int sig) _exit(2); } +/*ARGSUSED*/ static void check_parent_exists(int sig) { @@ -995,7 +1017,7 @@ int main(int ac, char **av) { int c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0; - int sock, fd, ch; + int sock, fd, ch; u_int nalloc; char *shell, *format, *pidstr, *agentsocket = NULL; fd_set *readsetp = NULL, *writesetp = NULL; @@ -1069,20 +1091,24 @@ main(int ac, char **av) if (ac == 0 && !c_flag && !s_flag) { shell = getenv("SHELL"); - if (shell != NULL && strncmp(shell + strlen(shell) - 3, "csh", 3) == 0) + if (shell != NULL && + strncmp(shell + strlen(shell) - 3, "csh", 3) == 0) c_flag = 1; } if (k_flag) { + const char *errstr = NULL; + pidstr = getenv(SSH_AGENTPID_ENV_NAME); if (pidstr == NULL) { fprintf(stderr, "%s not set, cannot kill agent\n", SSH_AGENTPID_ENV_NAME); exit(1); } - pid = atoi(pidstr); - if (pid < 1) { - fprintf(stderr, "%s=\"%s\", which is not a good PID\n", - SSH_AGENTPID_ENV_NAME, pidstr); + pid = (int)strtonum(pidstr, 2, INT_MAX, &errstr); + if (errstr) { + fprintf(stderr, + "%s=\"%s\", which is not a good PID: %s\n", + SSH_AGENTPID_ENV_NAME, pidstr, errstr); exit(1); } if (kill(pid, SIGTERM) == -1) { @@ -1126,7 +1152,7 @@ main(int ac, char **av) sunaddr.sun_family = AF_UNIX; strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path)); prev_mask = umask(0177); - if (bind(sock, (struct sockaddr *) & sunaddr, sizeof(sunaddr)) < 0) { + if (bind(sock, (struct sockaddr *) &sunaddr, sizeof(sunaddr)) < 0) { perror("bind"); *socket_name = '\0'; /* Don't unlink any existing file */ umask(prev_mask); diff --git a/openssh/ssh-dss.c b/openssh/ssh-dss.c index 381b7de..51a06e9 100644 --- a/openssh/ssh-dss.c +++ b/openssh/ssh-dss.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-dss.c,v 1.24 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,14 +24,17 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-dss.c,v 1.19 2003/11/10 16:23:41 jakob Exp $"); + +#include #include #include +#include +#include + #include "xmalloc.h" #include "buffer.h" -#include "bufaux.h" #include "compat.h" #include "log.h" #include "key.h" @@ -157,8 +161,9 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen, fatal("ssh_dss_verify: BN_new failed"); if ((sig->s = BN_new()) == NULL) fatal("ssh_dss_verify: BN_new failed"); - BN_bin2bn(sigblob, INTBLOB_LEN, sig->r); - BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s); + if ((BN_bin2bn(sigblob, INTBLOB_LEN, sig->r) == NULL) || + (BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s) == NULL)) + fatal("ssh_dss_verify: BN_bin2bn failed"); /* clean up */ memset(sigblob, 0, len); diff --git a/openssh/ssh-gss.h b/openssh/ssh-gss.h index 8b510ad..0546fe5 100644 --- a/openssh/ssh-gss.h +++ b/openssh/ssh-gss.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-gss.h,v 1.5 2004/06/21 17:36:31 avsm Exp $ */ +/* $OpenBSD: ssh-gss.h,v 1.9 2006/08/18 14:40:34 djm Exp $ */ /* * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. * @@ -28,8 +28,6 @@ #ifdef GSSAPI -#include "buffer.h" - #ifdef HAVE_GSSAPI_H #include #elif defined(HAVE_GSSAPI_GSSAPI_H) @@ -64,14 +62,15 @@ #define SSH_GSS_OIDTYPE 0x06 -#define SSH2_MSG_KEXGSS_INIT 30 -#define SSH2_MSG_KEXGSS_CONTINUE 31 -#define SSH2_MSG_KEXGSS_COMPLETE 32 -#define SSH2_MSG_KEXGSS_HOSTKEY 33 -#define SSH2_MSG_KEXGSS_ERROR 34 +#define SSH2_MSG_KEXGSS_INIT 30 +#define SSH2_MSG_KEXGSS_CONTINUE 31 +#define SSH2_MSG_KEXGSS_COMPLETE 32 +#define SSH2_MSG_KEXGSS_HOSTKEY 33 +#define SSH2_MSG_KEXGSS_ERROR 34 #define SSH2_MSG_KEXGSS_GROUPREQ 40 #define SSH2_MSG_KEXGSS_GROUP 41 #define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" +#define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" #define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" typedef struct { @@ -134,16 +133,16 @@ void ssh_gssapi_delete_ctx(Gssctxt **); OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); +int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); int ssh_gssapi_localname(char **name); -typedef int ssh_gssapi_check_fn(gss_OID, void *); +/* In the server */ +typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *); char *ssh_gssapi_client_mechanisms(const char *host); -char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, void *); -int ssh_gssapi_check_mechanism(gss_OID, void *); -gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int *); - -int ssh_gssapi_server_check_mech(gss_OID, void *); +char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *); +gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); +int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *); int ssh_gssapi_userok(char *name); OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); void ssh_gssapi_do_child(char ***, u_int *); diff --git a/openssh/ssh-keygen.c b/openssh/ssh-keygen.c index 924fe08..2d840d7 100644 --- a/openssh/ssh-keygen.c +++ b/openssh/ssh-keygen.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-keygen.c,v 1.155 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1994 Tatu Ylonen , Espoo, Finland @@ -12,28 +13,44 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keygen.c,v 1.135 2005/11/29 02:04:55 dtucker Exp $"); + +#include +#include +#include +#include #include #include +#include +#include +#include +#ifdef HAVE_PATHS_H +# include +#endif +#include +#include +#include +#include +#include +#include + #include "xmalloc.h" #include "key.h" #include "rsa.h" #include "authfile.h" #include "uuencode.h" #include "buffer.h" -#include "bufaux.h" #include "pathnames.h" #include "log.h" #include "misc.h" #include "match.h" #include "hostfile.h" +#include "dns.h" #ifdef SMARTCARD #include "scard.h" #endif -#include "dns.h" /* Number of bits in the RSA/DSA key. This value can be set on the command line. */ #define DEFAULT_BITS 2048 @@ -103,7 +120,7 @@ ask_filename(struct passwd *pw, const char *prompt) if (key_type_name == NULL) name = _PATH_SSH_CLIENT_ID_RSA; - else + else { switch (key_type_from_name(key_type_name)) { case KEY_RSA1: name = _PATH_SSH_CLIENT_IDENTITY; @@ -119,7 +136,7 @@ ask_filename(struct passwd *pw, const char *prompt) exit(1); break; } - + } snprintf(identity_file, sizeof(identity_file), "%s/%s", pw->pw_dir, name); fprintf(stderr, "%s (%s): ", prompt, identity_file); if (fgets(buf, sizeof(buf), stdin) == NULL) @@ -205,7 +222,8 @@ buffer_get_bignum_bits(Buffer *b, BIGNUM *value) if (buffer_len(b) < bytes) fatal("buffer_get_bignum_bits: input buffer too small: " "need %d have %d", bytes, buffer_len(b)); - BN_bin2bn(buffer_ptr(b), bytes, value); + if (BN_bin2bn(buffer_ptr(b), bytes, value) == NULL) + fatal("buffer_get_bignum_bits: BN_bin2bn failed"); buffer_consume(b, bytes); } @@ -302,13 +320,44 @@ do_convert_private_ssh2_from_blob(u_char *blob, u_int blen) return key; } +static int +get_line(FILE *fp, char *line, size_t len) +{ + int c; + size_t pos = 0; + + line[0] = '\0'; + while ((c = fgetc(fp)) != EOF) { + if (pos >= len - 1) { + fprintf(stderr, "input line too long.\n"); + exit(1); + } + switch (c) { + case '\r': + c = fgetc(fp); + if (c != EOF && c != '\n' && ungetc(c, fp) == EOF) { + fprintf(stderr, "unget: %s\n", strerror(errno)); + exit(1); + } + return pos; + case '\n': + return pos; + } + line[pos++] = c; + line[pos] = '\0'; + } + if (c == EOF) + return -1; + return pos; +} + static void do_convert_from_ssh2(struct passwd *pw) { Key *k; int blen; u_int len; - char line[1024], *p; + char line[1024]; u_char blob[8096]; char encoded[8096]; struct stat st; @@ -327,12 +376,8 @@ do_convert_from_ssh2(struct passwd *pw) exit(1); } encoded[0] = '\0'; - while (fgets(line, sizeof(line), fp)) { - if (!(p = strchr(line, '\n'))) { - fprintf(stderr, "input line too long.\n"); - exit(1); - } - if (p > line && p[-1] == '\\') + while ((blen = get_line(fp, line, sizeof(line))) != -1) { + if (line[blen - 1] == '\\') escaped++; if (strncmp(line, "----", 4) == 0 || strstr(line, ": ") != NULL) { @@ -349,7 +394,6 @@ do_convert_from_ssh2(struct passwd *pw) /* fprintf(stderr, "escaped: %s", line); */ continue; } - *p = '\0'; strlcat(encoded, line, sizeof(encoded)); } len = strlen(encoded); @@ -485,8 +529,10 @@ do_fingerprint(struct passwd *pw) xfree(fp); exit(0); } - if (comment) + if (comment) { xfree(comment); + comment = NULL; + } f = fopen(identity_file, "r"); if (f != NULL) { @@ -832,30 +878,32 @@ do_change_passphrase(struct passwd *pw) /* * Print the SSHFP RR. */ -static void -do_print_resource_record(struct passwd *pw, char *hname) +static int +do_print_resource_record(struct passwd *pw, char *fname, char *hname) { Key *public; char *comment = NULL; struct stat st; - if (!have_identity) + if (fname == NULL) ask_filename(pw, "Enter file in which the key is"); - if (stat(identity_file, &st) < 0) { - perror(identity_file); + if (stat(fname, &st) < 0) { + if (errno == ENOENT) + return 0; + perror(fname); exit(1); } - public = key_load_public(identity_file, &comment); + public = key_load_public(fname, &comment); if (public != NULL) { export_dns_rr(hname, public, stdout, print_generic); key_free(public); xfree(comment); - exit(0); + return 1; } if (comment) xfree(comment); - printf("failed to read v2 public key from %s.\n", identity_file); + printf("failed to read v2 public key from %s.\n", fname); exit(1); } @@ -1047,7 +1095,7 @@ main(int ac, char **av) "degiqpclBHvxXyF:b:f:t:U:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) { switch (opt) { case 'b': - bits = strtonum(optarg, 768, 32768, &errstr); + bits = (u_int32_t)strtonum(optarg, 768, 32768, &errstr); if (errstr) fatal("Bits has bad value %s (%s)", optarg, errstr); @@ -1117,6 +1165,7 @@ main(int ac, char **av) break; case 'D': download = 1; + /*FALLTHROUGH*/ case 'U': reader_id = optarg; break; @@ -1133,19 +1182,20 @@ main(int ac, char **av) rr_hostname = optarg; break; case 'W': - generator_wanted = strtonum(optarg, 1, UINT_MAX, &errstr); + generator_wanted = (u_int32_t)strtonum(optarg, 1, + UINT_MAX, &errstr); if (errstr) fatal("Desired generator has bad value: %s (%s)", optarg, errstr); break; case 'a': - trials = strtonum(optarg, 1, UINT_MAX, &errstr); + trials = (u_int32_t)strtonum(optarg, 1, UINT_MAX, &errstr); if (errstr) fatal("Invalid number of trials: %s (%s)", optarg, errstr); break; case 'M': - memory = strtonum(optarg, 1, UINT_MAX, &errstr); + memory = (u_int32_t)strtonum(optarg, 1, UINT_MAX, &errstr); if (errstr) { fatal("Memory limit is %s: %s", errstr, optarg); } @@ -1199,7 +1249,27 @@ main(int ac, char **av) if (print_public) do_print_public(pw); if (rr_hostname != NULL) { - do_print_resource_record(pw, rr_hostname); + unsigned int n = 0; + + if (have_identity) { + n = do_print_resource_record(pw, + identity_file, rr_hostname); + if (n == 0) { + perror(identity_file); + exit(1); + } + exit(0); + } else { + + n += do_print_resource_record(pw, + _PATH_HOST_RSA_KEY_FILE, rr_hostname); + n += do_print_resource_record(pw, + _PATH_HOST_DSA_KEY_FILE, rr_hostname); + + if (n == 0) + fatal("no keys found."); + exit(0); + } } if (reader_id != NULL) { #ifdef SMARTCARD diff --git a/openssh/ssh-keyscan.1 b/openssh/ssh-keyscan.1 index 80fc8cd..a3656fc 100644 --- a/openssh/ssh-keyscan.1 +++ b/openssh/ssh-keyscan.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-keyscan.1,v 1.21 2005/09/30 20:34:26 jaredy Exp $ +.\" $OpenBSD: ssh-keyscan.1,v 1.22 2006/09/25 04:55:38 ray Exp $ .\" .\" Copyright 1995, 1996 by David Mazieres . .\" @@ -102,7 +102,7 @@ Causes to print debugging messages about its progress. .El .Sh SECURITY -If a ssh_known_hosts file is constructed using +If an ssh_known_hosts file is constructed using .Nm without verifying the keys, users will be vulnerable to .Em man in the middle diff --git a/openssh/ssh-keyscan.c b/openssh/ssh-keyscan.c index 5465459..4b42896 100644 --- a/openssh/ssh-keyscan.c +++ b/openssh/ssh-keyscan.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-keyscan.c,v 1.74 2006/10/06 02:29:19 djm Exp $ */ /* * Copyright 1995, 1996 by David Mazieres . * @@ -7,24 +8,39 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keyscan.c,v 1.57 2005/10/30 04:01:03 djm Exp $"); - + #include "openbsd-compat/sys-queue.h" +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include + #include "xmalloc.h" #include "ssh.h" #include "ssh1.h" +#include "buffer.h" #include "key.h" +#include "cipher.h" #include "kex.h" #include "compat.h" #include "myproposal.h" #include "packet.h" #include "dispatch.h" -#include "buffer.h" -#include "bufaux.h" #include "log.h" #include "atomicio.h" #include "misc.h" @@ -55,7 +71,7 @@ int maxfd; extern char *__progname; fd_set *read_wait; -size_t read_wait_size; +size_t read_wait_nfdset; int ncon; int nonfatal_fatal = 0; jmp_buf kexjmp; @@ -129,7 +145,7 @@ Linebuf_alloc(const char *filename, void (*errfun) (const char *,...)) lb->stream = stdin; } - if (!(lb->buf = malloc(lb->size = LINEBUF_SIZE))) { + if (!(lb->buf = malloc((lb->size = LINEBUF_SIZE)))) { if (errfun) (*errfun) ("linebuf (%s): malloc failed\n", lb->filename); xfree(lb); @@ -351,6 +367,7 @@ keygrab_ssh2(con *c) c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; + c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; c->c_kex->verify_host_key = hostjump; if (!(j = setjmp(kexjmp))) { @@ -603,7 +620,6 @@ conread(int s) keyprint(c, keygrab_ssh1(c)); confree(s); return; - break; default: fatal("conread: invalid status %d", c->c_status); break; @@ -635,10 +651,10 @@ conloop(void) } else seltime.tv_sec = seltime.tv_usec = 0; - r = xmalloc(read_wait_size); - memcpy(r, read_wait, read_wait_size); - e = xmalloc(read_wait_size); - memcpy(e, read_wait, read_wait_size); + r = xcalloc(read_wait_nfdset, sizeof(fd_mask)); + e = xcalloc(read_wait_nfdset, sizeof(fd_mask)); + memcpy(r, read_wait, read_wait_nfdset * sizeof(fd_mask)); + memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask)); while (select(maxfd, r, NULL, e, &seltime) == -1 && (errno == EAGAIN || errno == EINTR)) @@ -806,12 +822,10 @@ main(int argc, char **argv) fatal("%s: not enough file descriptors", __progname); if (maxfd > fdlim_get(0)) fdlim_set(maxfd); - fdcon = xmalloc(maxfd * sizeof(con)); - memset(fdcon, 0, maxfd * sizeof(con)); + fdcon = xcalloc(maxfd, sizeof(con)); - read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); - read_wait = xmalloc(read_wait_size); - memset(read_wait, 0, read_wait_size); + read_wait_nfdset = howmany(maxfd, NFDBITS); + read_wait = xcalloc(read_wait_nfdset, sizeof(fd_mask)); if (fopt_count) { Linebuf *lb; diff --git a/openssh/ssh-keysign.8 b/openssh/ssh-keysign.8 index a17e8d5..4cdcb7a 100644 --- a/openssh/ssh-keysign.8 +++ b/openssh/ssh-keysign.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-keysign.8,v 1.7 2003/06/10 09:12:11 jmc Exp $ +.\" $OpenBSD: ssh-keysign.8,v 1.8 2006/02/24 20:22:16 jmc Exp $ .\" .\" Copyright (c) 2002 Markus Friedl. All rights reserved. .\" @@ -27,7 +27,7 @@ .Os .Sh NAME .Nm ssh-keysign -.Nd ssh helper program for hostbased authentication +.Nd ssh helper program for host-based authentication .Sh SYNOPSIS .Nm .Sh DESCRIPTION @@ -35,7 +35,7 @@ is used by .Xr ssh 1 to access the local host keys and generate the digital signature -required during hostbased authentication with SSH protocol version 2. +required during host-based authentication with SSH protocol version 2. .Pp .Nm is disabled by default and can only be enabled in the @@ -53,7 +53,7 @@ See .Xr ssh 1 and .Xr sshd 8 -for more information about hostbased authentication. +for more information about host-based authentication. .Sh FILES .Bl -tag -width Ds .It Pa /etc/ssh/ssh_config @@ -67,7 +67,7 @@ They should be owned by root, readable only by root, and not accessible to others. Since they are readable only by root, .Nm -must be set-uid root if hostbased authentication is used. +must be set-uid root if host-based authentication is used. .El .Sh SEE ALSO .Xr ssh 1 , diff --git a/openssh/ssh-keysign.c b/openssh/ssh-keysign.c index 870e6f8..66dc853 100644 --- a/openssh/ssh-keysign.c +++ b/openssh/ssh-keysign.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-keysign.c,v 1.29 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -21,21 +22,30 @@ * (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: ssh-keysign.c,v 1.19 2005/09/13 23:40:07 djm Exp $"); + +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include #include #include #include +#include "xmalloc.h" #include "log.h" #include "key.h" #include "ssh.h" #include "ssh2.h" #include "misc.h" -#include "xmalloc.h" #include "buffer.h" -#include "bufaux.h" #include "authfile.h" #include "msg.h" #include "canohost.h" @@ -64,9 +74,9 @@ valid_request(struct passwd *pw, char *host, Key **ret, u_char *data, buffer_init(&b); buffer_append(&b, data, datalen); - /* session id, currently limited to SHA1 (20 bytes) */ + /* session id, currently limited to SHA1 (20 bytes) or SHA256 (32) */ p = buffer_get_string(&b, &len); - if (len != 20) + if (len != 20 && len != 32) fail++; xfree(p); @@ -140,7 +150,7 @@ main(int argc, char **argv) { Buffer b; Options options; - Key *keys[2], *key; + Key *keys[2], *key = NULL; struct passwd *pw; int key_fd[2], i, found, version = 2, fd; u_char *signature, *data; diff --git a/openssh/ssh-rand-helper.c b/openssh/ssh-rand-helper.c index 3e1e0aa..2a39a24 100644 --- a/openssh/ssh-rand-helper.c +++ b/openssh/ssh-rand-helper.c @@ -24,6 +24,29 @@ #include "includes.h" +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#ifdef HAVE_SYS_UN_H +# include +#endif + +#include +#include +#include +#include +#include +#include + #include #include #include @@ -39,8 +62,6 @@ #include "pathnames.h" #include "log.h" -RCSID("$Id$"); - /* Number of bytes we write out */ #define OUTPUT_SEED_SIZE 48 @@ -562,7 +583,8 @@ prng_write_seedfile(void) /* Try to ensure that the parent directory is there */ snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir, _PATH_SSH_USER_DIR); - mkdir(filename, 0700); + if (mkdir(filename, 0700) < 0 && errno != EEXIST) + fatal("mkdir %.200s: %s", filename, strerror(errno)); snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir, SSH_PRNG_SEED_FILE); @@ -663,8 +685,7 @@ prng_read_commands(char *cmdfilename) } num_cmds = 64; - entcmd = xmalloc(num_cmds * sizeof(entropy_cmd_t)); - memset(entcmd, '\0', num_cmds * sizeof(entropy_cmd_t)); + entcmd = xcalloc(num_cmds, sizeof(entropy_cmd_t)); /* Read in file */ cur_cmd = linenum = 0; @@ -757,7 +778,7 @@ prng_read_commands(char *cmdfilename) */ if (cur_cmd == num_cmds) { num_cmds *= 2; - entcmd = xrealloc(entcmd, num_cmds * + entcmd = xrealloc(entcmd, num_cmds, sizeof(entropy_cmd_t)); } } @@ -766,12 +787,13 @@ prng_read_commands(char *cmdfilename) memset(&entcmd[cur_cmd], '\0', sizeof(entropy_cmd_t)); /* trim to size */ - entropy_cmds = xrealloc(entcmd, (cur_cmd + 1) * + entropy_cmds = xrealloc(entcmd, (cur_cmd + 1), sizeof(entropy_cmd_t)); debug("Loaded %d entropy commands from %.100s", cur_cmd, cmdfilename); + fclose(f); return cur_cmd < MIN_ENTROPY_SOURCES ? -1 : 0; } diff --git a/openssh/ssh-rsa.c b/openssh/ssh-rsa.c index eb422d0..0e16ff8 100644 --- a/openssh/ssh-rsa.c +++ b/openssh/ssh-rsa.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh-rsa.c,v 1.39 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000, 2003 Markus Friedl * @@ -13,16 +14,20 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include "includes.h" -RCSID("$OpenBSD: ssh-rsa.c,v 1.32 2005/06/17 02:44:33 djm Exp $"); + +#include #include #include +#include +#include + #include "xmalloc.h" #include "log.h" #include "buffer.h" -#include "bufaux.h" #include "key.h" #include "compat.h" #include "ssh.h" @@ -62,6 +67,7 @@ ssh_rsa_sign(const Key *key, u_char **sigp, u_int *lenp, if (ok != 1) { int ecode = ERR_get_error(); + error("ssh_rsa_sign: RSA_sign failed: %s", ERR_error_string(ecode, NULL)); xfree(sig); @@ -144,7 +150,7 @@ ssh_rsa_verify(const Key *key, const u_char *signature, u_int signaturelen, u_int diff = modlen - len; debug("ssh_rsa_verify: add padding: modlen %u > len %u", modlen, len); - sigblob = xrealloc(sigblob, modlen); + sigblob = xrealloc(sigblob, 1, modlen); memmove(sigblob + diff, sigblob, len); memset(sigblob, 0, diff); len = modlen; @@ -220,7 +226,6 @@ openssh_RSA_verify(int type, u_char *hash, u_int hashlen, break; default: goto done; - break; } if (hashlen != hlen) { error("bad hashlen"); diff --git a/openssh/ssh.1 b/openssh/ssh.1 index f4c6776..93be52f 100644 --- a/openssh/ssh.1 +++ b/openssh/ssh.1 @@ -34,7 +34,7 @@ .\" (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.253 2006/01/30 13:37:49 jmc Exp $ +.\" $OpenBSD: ssh.1,v 1.265 2006/10/28 18:08:10 otto Exp $ .Dd September 25, 1999 .Dt SSH 1 .Os @@ -78,7 +78,8 @@ .Oc .Op Fl S Ar ctl_path .Bk -words -.Op Fl w Ar tunnel : Ns Ar tunnel +.Oo Fl w Ar local_tun Ns +.Op : Ns Ar remote_tun Oc .Oo Ar user Ns @ Oc Ns Ar hostname .Op Ar command .Ek @@ -448,6 +449,7 @@ For full details of the options listed below, and their possible values, see .It ControlPath .It DynamicForward .It EscapeChar +.It ExitOnForwardFailure .It ForwardAgent .It ForwardX11 .It ForwardX11Trusted @@ -569,7 +571,7 @@ Disable pseudo-tty allocation. Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, -e.g., when implementing menu services. +e.g. when implementing menu services. Multiple .Fl t options force tty allocation, even if @@ -588,24 +590,35 @@ Multiple .Fl v options increase the verbosity. The maximum is 3. -.It Fl w Ar tunnel : Ns Ar tunnel -Requests a +.It Fl w Xo +.Ar local_tun Ns Op : Ns Ar remote_tun +.Xc +Requests +tunnel +device forwarding with the specified .Xr tun 4 -device on the client -(first -.Ar tunnel -arg) -and server -(second -.Ar tunnel -arg). +devices between the client +.Pq Ar local_tun +and the server +.Pq Ar remote_tun . +.Pp The devices may be specified by numerical ID or the keyword .Dq any , which uses the next available tunnel device. +If +.Ar remote_tun +is not specified, it defaults to +.Dq any . See also the .Cm Tunnel -directive in +and +.Cm TunnelDevice +directives in .Xr ssh_config 5 . +If the +.Cm Tunnel +directive is unset, it is set to the default tunnel mode, which is +.Dq point-to-point . .It Fl X Enables X11 forwarding. This can also be specified on a per-host basis in a configuration file. @@ -666,6 +679,7 @@ Protocol 1 lacks a strong mechanism for ensuring the integrity of the connection. .Pp The methods available for authentication are: +GSSAPI-based authentication, host-based authentication, public key authentication, challenge-response authentication, @@ -872,7 +886,9 @@ and options (see above). It also allows the cancellation of existing remote port-forwardings using -.Fl KR Ar hostport . +.Sm off +.Fl KR Oo Ar bind_address : Oc Ar port . +.Sm on .Ic !\& Ns Ar command allows the user to execute a local command if the .Ic PermitLocalCommand @@ -1025,8 +1041,7 @@ In this example, we are connecting a client to a server, The SSHFP resource records should first be added to the zonefile for host.example.com: .Bd -literal -offset indent -$ ssh-keygen -f /etc/ssh/ssh_host_rsa_key.pub -r host.example.com. -$ ssh-keygen -f /etc/ssh/ssh_host_dsa_key.pub -r host.example.com. +$ ssh-keygen -r host.example.com. .Ed .Pp The output lines will have to be added to the zonefile. @@ -1062,12 +1077,22 @@ controls whether the server supports this, and at what level (layer 2 or 3 traffic). .Pp The following example would connect client network 10.0.50.0/24 -with remote network 10.0.99.0/24, provided that the SSH server -running on the gateway to the remote network, -at 192.168.1.15, allows it: +with remote network 10.0.99.0/24 using a point-to-point connection +from 10.1.1.1 to 10.1.1.2, +provided that the SSH server running on the gateway to the remote network, +at 192.168.1.15, allows it. +.Pp +On the client: .Bd -literal -offset indent # ssh -f -w 0:1 192.168.1.15 true -# ifconfig tun0 10.0.50.1 10.0.99.1 netmask 255.255.255.252 +# ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252 +# route add 10.0.99.0/24 10.1.1.2 +.Ed +.Pp +On the server: +.Bd -literal -offset indent +# ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252 +# route add 10.0.50.0/24 10.1.1.1 .Ed .Pp Client access may be more finely tuned via the @@ -1075,11 +1100,11 @@ Client access may be more finely tuned via the file (see below) and the .Cm PermitRootLogin server option. -The following entry would permit connections on the first +The following entry would permit connections on .Xr tun 4 -device from user +device 1 from user .Dq jane -and on the second device from user +and on tun device 2 from user .Dq john , if .Cm PermitRootLogin @@ -1087,10 +1112,10 @@ is set to .Dq forced-commands-only : .Bd -literal -offset 2n tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane -tunnel="2",command="sh /etc/netstart tun1" ssh-rsa ... john +tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john .Ed .Pp -Since a SSH-based setup entails a fair amount of overhead, +Since an SSH-based setup entails a fair amount of overhead, it may be more suited to temporary setups, such as for wireless VPNs. More permanent VPNs are better provided by tools such as @@ -1178,7 +1203,7 @@ If the current session has no tty, this variable is not set. .It Ev TZ This variable is set to indicate the present time zone if it -was set when the daemon was started (i.e., the daemon passes the value +was set when the daemon was started (i.e. the daemon passes the value on to new connections). .It Ev USER Set to the name of the user logging in. @@ -1339,15 +1364,59 @@ manual page for more information. .Xr ssh-keysign 8 , .Xr sshd 8 .Rs -.%A T. Ylonen -.%A T. Kivinen -.%A M. Saarinen -.%A T. Rinne -.%A S. Lehtinen -.%T "SSH Protocol Architecture" -.%N draft-ietf-secsh-architecture-12.txt -.%D January 2002 -.%O work in progress material +.%R RFC 4250 +.%T "The Secure Shell (SSH) Protocol Assigned Numbers" +.%D 2006 +.Re +.Rs +.%R RFC 4251 +.%T "The Secure Shell (SSH) Protocol Architecture" +.%D 2006 +.Re +.Rs +.%R RFC 4252 +.%T "The Secure Shell (SSH) Authentication Protocol" +.%D 2006 +.Re +.Rs +.%R RFC 4253 +.%T "The Secure Shell (SSH) Transport Layer Protocol" +.%D 2006 +.Re +.Rs +.%R RFC 4254 +.%T "The Secure Shell (SSH) Connection Protocol" +.%D 2006 +.Re +.Rs +.%R RFC 4255 +.%T "Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints" +.%D 2006 +.Re +.Rs +.%R RFC 4256 +.%T "Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)" +.%D 2006 +.Re +.Rs +.%R RFC 4335 +.%T "The Secure Shell (SSH) Session Channel Break Extension" +.%D 2006 +.Re +.Rs +.%R RFC 4344 +.%T "The Secure Shell (SSH) Transport Layer Encryption Modes" +.%D 2006 +.Re +.Rs +.%R RFC 4345 +.%T "Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol" +.%D 2006 +.Re +.Rs +.%R RFC 4419 +.%T "Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol" +.%D 2006 .Re .Sh AUTHORS OpenSSH is a derivative of the original and free diff --git a/openssh/ssh.c b/openssh/ssh.c index 7a3804b..e3c6ce7 100644 --- a/openssh/ssh.c +++ b/openssh/ssh.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssh.c,v 1.294 2006/10/06 02:29:19 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -40,20 +41,46 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh.c,v 1.257 2005/12/20 04:41:07 dtucker Exp $"); + +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #include #include +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" #include "ssh2.h" #include "compat.h" #include "cipher.h" -#include "xmalloc.h" #include "packet.h" #include "buffer.h" -#include "bufaux.h" #include "channels.h" #include "key.h" #include "authfd.h" @@ -72,6 +99,7 @@ RCSID("$OpenBSD: ssh.c,v 1.257 2005/12/20 04:41:07 dtucker Exp $"); #include "msg.h" #include "monitor_fdpass.h" #include "uidswap.h" +#include "version.h" #ifdef SMARTCARD #include "scard.h" @@ -162,7 +190,7 @@ usage(void) " [-i identity_file] [-L [bind_address:]port:host:hostport]\n" " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" " [-R [bind_address:]port:host:hostport] [-S ctl_path]\n" -" [-w tunnel:tunnel] [user@]hostname [command]\n" +" [-w local_tun[:remote_tun]] [user@]hostname [command]\n" ); exit(255); } @@ -243,7 +271,7 @@ main(int ac, char **av) /* Parse command-line arguments. */ host = NULL; -again: + again: while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvxACD:F:I:L:MNO:PR:S:TVw:XY")) != -1) { switch (opt) { @@ -470,11 +498,6 @@ again: case 'N': no_shell_flag = 1; no_tty_flag = 1; - options.none_switch = 0; - break; - case 'T': - no_tty_flag = 1; - options.none_switch = 0; break; case 'o': dummy = 1; @@ -484,6 +507,13 @@ again: exit(255); xfree(line); break; + case 'T': + no_tty_flag = 1; + /* ensure that the user doesn't try to backdoor a */ + /* null cipher switch on an interactive session */ + /* so explicitly disable it no matter what */ + options.none_switch=0; + break; case 's': subsystem_flag = 1; break; @@ -498,14 +528,6 @@ again: case 'F': config = optarg; break; - case 'z': - /* make sure we can't turn on the none_switch */ - /* if they try to force a no tty flag on a tty session */ - if (!no_tty_flag) { - options.none_switch = 1; - } - break; - default: usage(); } @@ -653,7 +675,7 @@ again: if (options.host_key_alias != NULL) { for (p = options.host_key_alias; *p; p++) if (isupper(*p)) - *p = tolower(*p); + *p = (char)tolower(*p); } /* Get default port if port has not been set. */ @@ -670,11 +692,15 @@ again: options.control_path = NULL; if (options.control_path != NULL) { + char thishost[NI_MAXHOST]; + + if (gethostname(thishost, sizeof(thishost)) == -1) + fatal("gethostname: %s", strerror(errno)); snprintf(buf, sizeof(buf), "%d", options.port); cp = tilde_expand_filename(options.control_path, original_real_uid); options.control_path = percent_expand(cp, "p", buf, "h", host, - "r", options.user, (char *)NULL); + "r", options.user, "l", thishost, (char *)NULL); xfree(cp); } if (mux_command != 0 && options.control_path == NULL) @@ -707,16 +733,16 @@ again: if (options.rhosts_rsa_authentication || options.hostbased_authentication) { sensitive_data.nkeys = 3; - sensitive_data.keys = xmalloc(sensitive_data.nkeys * + sensitive_data.keys = xcalloc(sensitive_data.nkeys, sizeof(Key)); PRIV_START; sensitive_data.keys[0] = key_load_private_type(KEY_RSA1, - _PATH_HOST_KEY_FILE, "", NULL); + _PATH_HOST_KEY_FILE, "", NULL, NULL); sensitive_data.keys[1] = key_load_private_type(KEY_DSA, - _PATH_HOST_DSA_KEY_FILE, "", NULL); + _PATH_HOST_DSA_KEY_FILE, "", NULL, NULL); sensitive_data.keys[2] = key_load_private_type(KEY_RSA, - _PATH_HOST_RSA_KEY_FILE, "", NULL); + _PATH_HOST_RSA_KEY_FILE, "", NULL, NULL); PRIV_END; if (options.hostbased_authentication == 1 && @@ -833,6 +859,8 @@ ssh_init_forwarding(void) options.gateway_ports, options.hpn_disabled, options.hpn_buffer_size); } + if (i > 0 && success != i && options.exit_on_forward_failure) + fatal("Could not request local forwarding."); if (i > 0 && success == 0) error("Could not request local forwarding."); @@ -845,11 +873,17 @@ ssh_init_forwarding(void) options.remote_forwards[i].listen_port, options.remote_forwards[i].connect_host, options.remote_forwards[i].connect_port); - channel_request_remote_forwarding( + if (channel_request_remote_forwarding( options.remote_forwards[i].listen_host, options.remote_forwards[i].listen_port, options.remote_forwards[i].connect_host, - options.remote_forwards[i].connect_port); + options.remote_forwards[i].connect_port) < 0) { + if (options.exit_on_forward_failure) + fatal("Could not request remote forwarding."); + else + logit("Warning: Could not request remote " + "forwarding."); + } } } @@ -910,10 +944,10 @@ ssh_session(void) /* Store window size in the packet. */ if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) < 0) memset(&ws, 0, sizeof(ws)); - packet_put_int(ws.ws_row); - packet_put_int(ws.ws_col); - packet_put_int(ws.ws_xpixel); - packet_put_int(ws.ws_ypixel); + packet_put_int((u_int)ws.ws_row); + packet_put_int((u_int)ws.ws_col); + packet_put_int((u_int)ws.ws_xpixel); + packet_put_int((u_int)ws.ws_ypixel); /* Store tty modes in the packet. */ tty_make_modes(fileno(stdin), NULL); @@ -1031,9 +1065,16 @@ client_global_request_reply_fwd(int type, u_int32_t seq, void *ctxt) options.remote_forwards[i].listen_port, options.remote_forwards[i].connect_host, options.remote_forwards[i].connect_port); - if (type == SSH2_MSG_REQUEST_FAILURE) - logit("Warning: remote port forwarding failed for listen " - "port %d", options.remote_forwards[i].listen_port); + if (type == SSH2_MSG_REQUEST_FAILURE) { + if (options.exit_on_forward_failure) + fatal("Error: remote port forwarding failed for " + "listen port %d", + options.remote_forwards[i].listen_port); + else + logit("Warning: remote port forwarding failed for " + "listen port %d", + options.remote_forwards[i].listen_port); + } } static void @@ -1062,7 +1103,7 @@ ssh_control_listener(void) fatal("%s socket(): %s", __func__, strerror(errno)); old_umask = umask(0177); - if (bind(control_fd, (struct sockaddr*)&addr, addr_len) == -1) { + if (bind(control_fd, (struct sockaddr *)&addr, addr_len) == -1) { control_fd = -1; if (errno == EINVAL || errno == EADDRINUSE) fatal("ControlSocket %s already exists", @@ -1150,6 +1191,9 @@ ssh_session2_open(void) { Channel *c; int window, packetmax, in, out, err; + int sock; + int socksize; + int socksizelen = sizeof(int); if (stdin_null_flag) { in = open(_PATH_DEVNULL, O_RDONLY); @@ -1170,10 +1214,67 @@ ssh_session2_open(void) if (!isatty(err)) set_nonblock(err); + /* we need to check to see if what they want to do about buffer */ + /* sizes here. In a hpn to nonhpn connection we want to limit */ + /* the window size to something reasonable in case the far side */ + /* has the large window bug. In hpn to hpn connection we want to */ + /* use the max window size but allow the user to override it */ + /* lastly if they disabled hpn then use the ssh std window size */ + + /* so why don't we just do a getsockopt() here and set the */ + /* ssh window to that? In the case of a autotuning receive */ + /* window the window would get stuck at the initial buffer */ + /* size generally less than 96k. Therefore we need to set the */ + /* maximum ssh window size to the maximum hpn buffer size */ + /* unless the user hasspecifically set the hpnrcvbufpoll */ + /* to no. In which case we *can* just set the window to the */ + /* minimum of the hpn buffer size and tcp receive buffer size */ + if(options.hpn_disabled) - window = CHAN_SES_WINDOW_DEFAULT; - else - window = options.hpn_buffer_size; + { + options.hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT; + } + else if (datafellows & SSH_BUG_LARGEWINDOW) + { + debug("HPN to Non-HPN Connection"); + if (options.hpn_buffer_size < 0) + options.hpn_buffer_size = 2*1024*1024; + } + else + { + if (options.hpn_buffer_size < 0) + options.hpn_buffer_size = BUFFER_MAX_LEN_HPN; + + /*create a socket but don't connect it */ + /* we use that the get the rcv socket size */ + sock = socket(AF_INET, SOCK_STREAM, 0); + /* if they are using the tcp_rcv_buf option */ + /* attempt to set the buffer size to that */ + if (options.tcp_rcv_buf) + setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *)&options.tcp_rcv_buf, + sizeof(options.tcp_rcv_buf)); + getsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &socksize, &socksizelen); + close(sock); + debug("socksize %d", socksize); + if (options.tcp_rcv_buf_poll <= 0) + { + options.hpn_buffer_size = MIN(socksize,options.hpn_buffer_size); + debug ("MIN of TCP RWIN and HPNBufferSize: %d", options.hpn_buffer_size); + } + else + { + if (options.tcp_rcv_buf > 0) + options.hpn_buffer_size = MIN(options.tcp_rcv_buf, options.hpn_buffer_size); + debug ("MIN of TCPRcvBuf and HPNBufferSize: %d", options.hpn_buffer_size); + } + + } + + debug("Final hpn_buffer_size = %d", options.hpn_buffer_size); + + window = options.hpn_buffer_size; + packetmax = CHAN_SES_PACKET_DEFAULT; if (tty_flag) { window = 4*CHAN_SES_PACKET_DEFAULT; @@ -1226,15 +1327,16 @@ ssh_session2(void) static void load_public_identity_files(void) { - char *filename; + char *filename, *cp, thishost[NI_MAXHOST]; int i = 0; Key *public; + struct passwd *pw; #ifdef SMARTCARD Key **keys; if (options.smartcard_device != NULL && options.num_identity_files < SSH_MAX_IDENTITY_FILES && - (keys = sc_get_keys(options.smartcard_device, NULL)) != NULL ) { + (keys = sc_get_keys(options.smartcard_device, NULL)) != NULL) { int count = 0; for (i = 0; keys[i] != NULL; i++) { count++; @@ -1252,9 +1354,18 @@ load_public_identity_files(void) xfree(keys); } #endif /* SMARTCARD */ + if ((pw = getpwuid(original_real_uid)) == NULL) + fatal("load_public_identity_files: getpwuid failed"); + if (gethostname(thishost, sizeof(thishost)) == -1) + fatal("load_public_identity_files: gethostname: %s", + strerror(errno)); for (; i < options.num_identity_files; i++) { - filename = tilde_expand_filename(options.identity_files[i], + cp = tilde_expand_filename(options.identity_files[i], original_real_uid); + filename = percent_expand(cp, "d", pw->pw_dir, + "u", pw->pw_name, "l", thishost, "h", host, + "r", options.user, (char *)NULL); + xfree(cp); public = key_load_public(filename, NULL); debug("identity file %s type %d", filename, public ? public->type : -1); @@ -1280,14 +1391,14 @@ control_client_sigrelay(int signo) static int env_permitted(char *env) { - int i; + int i, ret; char name[1024], *cp; - strlcpy(name, env, sizeof(name)); - if ((cp = strchr(name, '=')) == NULL) + if ((cp = strchr(env, '=')) == NULL || cp == env) return (0); - - *cp = '\0'; + ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env); + if (ret <= 0 || (size_t)ret >= sizeof(name)) + fatal("env_permitted: name '%.100s...' too long", env); for (i = 0; i < options.num_send_env; i++) if (match_pattern(name, options.send_env[i])) @@ -1332,29 +1443,29 @@ control_client(const char *path) if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) fatal("%s socket(): %s", __func__, strerror(errno)); - if (connect(sock, (struct sockaddr*)&addr, addr_len) == -1) { + if (connect(sock, (struct sockaddr *)&addr, addr_len) == -1) { if (mux_command != SSHMUX_COMMAND_OPEN) { fatal("Control socket connect(%.100s): %s", path, strerror(errno)); } if (errno == ENOENT) - debug("Control socket \"%.100s\" does not exist", path); + debug("Control socket \"%.100s\" does not exist", path); else { - error("Control socket connect(%.100s): %s", path, + error("Control socket connect(%.100s): %s", path, strerror(errno)); } - close(sock); - return; - } - - if (stdin_null_flag) { - if ((fd = open(_PATH_DEVNULL, O_RDONLY)) == -1) - fatal("open(/dev/null): %s", strerror(errno)); - if (dup2(fd, STDIN_FILENO) == -1) - fatal("dup2: %s", strerror(errno)); - if (fd > STDERR_FILENO) - close(fd); - } + close(sock); + return; + } + + if (stdin_null_flag) { + if ((fd = open(_PATH_DEVNULL, O_RDONLY)) == -1) + fatal("open(/dev/null): %s", strerror(errno)); + if (dup2(fd, STDIN_FILENO) == -1) + fatal("dup2: %s", strerror(errno)); + if (fd > STDERR_FILENO) + close(fd); + } term = getenv("TERM"); diff --git a/openssh/ssh.h b/openssh/ssh.h index 0759241..186cfff 100644 --- a/openssh/ssh.h +++ b/openssh/ssh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.h,v 1.76 2004/12/06 11:41:03 dtucker Exp $ */ +/* $OpenBSD: ssh.h,v 1.78 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -12,18 +12,6 @@ * called by a name other than "ssh" or "Secure Shell". */ -#ifndef SSH_H -#define SSH_H - -#include /* For struct sockaddr_in */ -#include /* For struct pw */ -#include /* For va_list */ -#include /* For LOG_AUTH and friends */ -#include /* For struct sockaddr_storage */ -#ifdef HAVE_SYS_SELECT_H -# include -#endif - /* Cipher used for encrypting authentication files. */ #define SSH_AUTHFILE_CIPHER SSH_CIPHER_3DES @@ -112,5 +100,3 @@ /* Listen backlog for sshd, ssh-agent and forwarding sockets */ #define SSH_LISTEN_BACKLOG 128 - -#endif /* SSH_H */ diff --git a/openssh/ssh1.h b/openssh/ssh1.h index 1741c22..353d930 100644 --- a/openssh/ssh1.h +++ b/openssh/ssh1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh1.h,v 1.5 2004/10/20 11:48:53 markus Exp $ */ +/* $OpenBSD: ssh1.h,v 1.6 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/ssh2.h b/openssh/ssh2.h index fb491c9..cf56bc4 100644 --- a/openssh/ssh2.h +++ b/openssh/ssh2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh2.h,v 1.9 2003/05/14 00:52:59 markus Exp $ */ +/* $OpenBSD: ssh2.h,v 1.10 2006/03/25 22:22:43 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. diff --git a/openssh/ssh_config b/openssh/ssh_config index 71b3734..15376f7 100644 --- a/openssh/ssh_config +++ b/openssh/ssh_config @@ -1,4 +1,4 @@ -# $OpenBSD: ssh_config,v 1.21 2005/12/06 22:38:27 reyk Exp $ +# $OpenBSD: ssh_config,v 1.22 2006/05/29 12:56:33 dtucker Exp $ # This is the ssh client system-wide configuration file. See # ssh_config(5) for more information. This file provides defaults for @@ -24,6 +24,10 @@ # RSAAuthentication yes # PasswordAuthentication yes # HostbasedAuthentication no +# GSSAPIAuthentication yes +# GSSAPIDelegateCredentials yes +# GSSAPIKeyExchange yes +# GSSAPITrustDNS yes # BatchMode no # CheckHostIP yes # AddressFamily any diff --git a/openssh/ssh_config.5 b/openssh/ssh_config.5 index 38889bf..2b40781 100644 --- a/openssh/ssh_config.5 +++ b/openssh/ssh_config.5 @@ -34,7 +34,7 @@ .\" (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.76 2006/01/20 11:21:45 jmc Exp $ +.\" $OpenBSD: ssh_config.5,v 1.97 2006/07/27 08:00:50 jmc Exp $ .Dd September 25, 1999 .Dt SSH_CONFIG 5 .Os @@ -47,9 +47,10 @@ .It Pa /etc/ssh/ssh_config .El .Sh DESCRIPTION -.Nm ssh +.Xr ssh 1 obtains configuration data from the following sources in the following order: +.Pp .Bl -enum -offset indent -compact .It command-line options @@ -84,7 +85,6 @@ The configuration file has the following format: Empty lines and lines starting with .Ql # are comments. -.Pp Otherwise a line is of the format .Dq keyword arguments . Configuration options may be separated by whitespace or @@ -93,11 +93,14 @@ optional whitespace and exactly one the latter format is useful to avoid the need to quote whitespace when specifying configuration options using the .Nm ssh , -.Nm scp +.Nm scp , and .Nm sftp .Fl o option. +Arguments may optionally be enclosed in double quotes +.Pq \&" +in order to represent arguments containing spaces. .Pp The possible keywords and their meanings are as follows (note that @@ -108,25 +111,24 @@ Restricts the following declarations (up to the next .Cm Host keyword) to be only for those hosts that match one of the patterns given after the keyword. -.Ql \&* -and -.Ql \&? -can be used as wildcards in the -patterns. A single -.Ql \&* +.Ql * as a pattern can be used to provide global defaults for all hosts. The host is the .Ar hostname -argument given on the command line (i.e., the name is not converted to +argument given on the command line (i.e. the name is not converted to a canonicalized host name before matching). +.Pp +See +.Sx PATTERNS +for more information on patterns. .It Cm AddressFamily Specifies which address family to use when connecting. Valid arguments are .Dq any , .Dq inet -(use IPv4 only) or +(use IPv4 only), or .Dq inet6 (use IPv6 only). .It Cm BatchMode @@ -150,7 +152,7 @@ Note that this option does not work if is set to .Dq yes . .It Cm ChallengeResponseAuthentication -Specifies whether to use challenge response authentication. +Specifies whether to use challenge-response authentication. The argument to this keyword must be .Dq yes or @@ -160,7 +162,8 @@ The default is .It Cm CheckHostIP If this flag is set to .Dq yes , -ssh will additionally check the host IP address in the +.Xr ssh 1 +will additionally check the host IP address in the .Pa known_hosts file. This allows ssh to detect if a host key changed due to DNS spoofing. @@ -180,7 +183,7 @@ and are supported. .Ar des is only supported in the -.Nm ssh +.Xr ssh 1 client for interoperability with legacy protocol 1 implementations that do not support the .Ar 3des @@ -206,18 +209,18 @@ The supported ciphers are .Dq blowfish-cbc , and .Dq cast128-cbc . -The default is -.Bd -literal - ``aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128, - arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr, - aes192-ctr,aes256-ctr'' +The default is: +.Bd -literal -offset 3n +aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128, +arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr, +aes192-ctr,aes256-ctr .Ed .It Cm ClearAllForwardings -Specifies that all local, remote and dynamic port forwardings +Specifies that all local, remote, and dynamic port forwardings specified in the configuration files or on the command line be cleared. This option is primarily useful when used from the -.Nm ssh +.Xr ssh 1 command line to clear port forwardings set in configuration files, and is automatically set by .Xr scp 1 @@ -250,15 +253,15 @@ 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. +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 ControlMaster Enables the sharing of multiple sessions over a single network connection. When set to -.Dq yes -.Nm ssh +.Dq yes , +.Xr ssh 1 will listen for connections on a control socket specified using the .Cm ControlPath argument. @@ -275,8 +278,7 @@ if the control socket does not exist, or is not listening. .Pp Setting this to .Dq ask -will cause -.Nm ssh +will cause ssh to listen for control connections, but require confirmation using the .Ev SSH_ASKPASS program before they are accepted (see @@ -284,9 +286,8 @@ program before they are accepted (see for details). If the .Cm ControlPath -can not be opened, -.Nm ssh -will continue without connecting to a master instance. +cannot be opened, +ssh will continue without connecting to a master instance. .Pp X11 and .Xr ssh-agent 1 @@ -312,16 +313,18 @@ section above or the string .Dq none to disable connection sharing. In the path, +.Ql %l +will be substituted by the local host name, .Ql %h will be substituted by the target host name, .Ql %p -the port and +the port, and .Ql %r by the remote login username. It is recommended that any .Cm ControlPath used for opportunistic connection sharing include -all three of these escape sequences. +at least %h, %p, and %r. This ensures that shared connections are uniquely identified. .It Cm DynamicForward Specifies that a TCP port on the local machine be forwarded @@ -352,7 +355,7 @@ empty address or indicates that the port should be available from all interfaces. .Pp Currently the SOCKS4 and SOCKS5 protocols are supported, and -.Nm ssh +.Xr ssh 1 will act as a SOCKS server. Multiple forwardings may be specified, and additional forwardings can be given on the command line. @@ -388,6 +391,17 @@ followed by a letter, or to disable the escape character entirely (making the connection transparent for binary data). +.It Cm ExitOnForwardFailure +Specifies whether +.Xr ssh 1 +should terminate the connection if it cannot set up all requested +dynamic, local, and remote port forwardings. +The argument must be +.Dq yes +or +.Dq no . +The default is +.Dq no . .It Cm ForwardAgent Specifies whether the connection to the authentication agent (if any) will be forwarded to the remote machine. @@ -427,12 +441,12 @@ if the option is also enabled. .It Cm ForwardX11Trusted If this option is set to -.Dq yes -then remote X11 clients will have full access to the original X11 display. +.Dq yes , +remote X11 clients will have full access to the original X11 display. .Pp If this option is set to -.Dq no -then remote X11 clients will be considered untrusted and prevented +.Dq no , +remote X11 clients will be considered untrusted and prevented from stealing or tampering with data belonging to trusted X11 clients. Furthermore, the @@ -449,12 +463,11 @@ the restrictions imposed on untrusted clients. Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, -.Nm ssh +.Xr ssh 1 binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. .Cm GatewayPorts -can be used to specify that -.Nm ssh +can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be @@ -469,7 +482,7 @@ host key database instead of .Pa /etc/ssh/ssh_known_hosts . .It Cm GSSAPIAuthentication Specifies whether user authentication based on GSSAPI is allowed. -The default is +The default is .Dq yes . Note that this option applies to protocol version 2 only. .It Cm GSSAPIKeyExchange @@ -485,29 +498,31 @@ The default is Note that this option applies to protocol version 2 only. .It Cm GSSAPITrustDns Set to -.Dq yes to indicate that the DNS is trusted to securely canonicalize +.Dq yes +to indicate that the DNS is trusted to securely canonicalize the name of the host being connected to. If -.Dq no, the hostname entered on the +.Dq no , +the hostname entered on the command line will be passed untouched to the GSSAPI library. The default is .Dq yes . -This option only applies to protocol version 2 connections using GSSAPI -key exchange. +This option only applies to protocol version 2 connections using GSSAPI. .It Cm HashKnownHosts Indicates that -.Nm ssh +.Xr ssh 1 should hash host names and addresses when they are added to .Pa ~/.ssh/known_hosts . These hashed names may be used normally by -.Nm ssh +.Xr ssh 1 and -.Nm sshd , +.Xr sshd 8 , but they do not reveal identifying information should the file's contents be disclosed. The default is .Dq no . -Note that hashing of names and addresses will not be retrospectively applied -to existing known hosts files, but these may be manually hashed using +Note that existing names and addresses in known hosts files +will not be converted automatically, +but may be manually hashed using .Xr ssh-keygen 1 . .It Cm HostbasedAuthentication Specifies whether to try rhosts based authentication with public key @@ -530,30 +545,29 @@ The default for this option is: Specifies an alias that should be used instead of the real host name when looking up or saving the host key in the host key database files. -This option is useful for tunneling ssh connections +This option is useful for tunneling SSH connections or for multiple servers running on a single host. .It Cm HostName Specifies the real host name to log into. This can be used to specify nicknames or abbreviations for hosts. -Default is the name given on the command line. +The default is the name given on the command line. Numeric IP addresses are also permitted (both on the command line and in .Cm HostName specifications). .It Cm IdentitiesOnly Specifies that -.Nm ssh +.Xr ssh 1 should only use the authentication identity files configured in the .Nm files, -even if the -.Nm ssh-agent +even if +.Xr ssh-agent 1 offers more identities. The argument to this keyword must be .Dq yes or .Dq no . -This option is intended for situations where -.Nm ssh-agent +This option is intended for situations where ssh-agent offers many different identities. The default is .Dq no . @@ -569,8 +583,21 @@ and for protocol version 2. Additionally, any identities represented by the authentication agent will be used for authentication. +.Pp The file name may use the tilde -syntax to refer to a user's home directory. +syntax to refer to a user's home directory or one of the following +escape characters: +.Ql %d +(local user's home directory), +.Ql %u +(local user name), +.Ql %l +(local host name), +.Ql %h +(remote host name) or +.Ql %r +(remote user name). +.Pp It is possible to have multiple identity files specified in configuration files; all these identities will be tried in sequence. @@ -578,6 +605,13 @@ identities will be tried in sequence. Specifies the list of methods to use in keyboard-interactive authentication. Multiple method names must be comma-separated. The default is to use the server specified list. +The methods available vary depending on what the server supports. +For an OpenSSH server, +it may be zero or more of: +.Dq bsdauth , +.Dq pam , +and +.Dq skey . .It Cm LocalCommand Specifies a command to execute on the local machine after successfully connecting to the server. @@ -619,9 +653,9 @@ empty address or indicates that the port should be available from all interfaces. .It Cm LogLevel Gives the verbosity level that is used when logging messages from -.Nm ssh . +.Xr ssh 1 . The possible values are: -QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2 and DEBUG3. +QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of verbose output. @@ -631,7 +665,7 @@ in order of preference. The MAC algorithm is used in protocol version 2 for data integrity protection. Multiple algorithms must be comma-separated. -The default is +The default is: .Dq hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 . .It Cm NoHostAuthenticationForLocalhost This option can be used if the home directory is shared across machines. @@ -646,7 +680,7 @@ The default is to check the host key for localhost. .It Cm NumberOfPasswordPrompts Specifies the number of password prompts before giving up. The argument to this keyword must be an integer. -Default is 3. +The default is 3. .It Cm PasswordAuthentication Specifies whether to use password authentication. The argument to this keyword must be @@ -670,7 +704,7 @@ The default is .Dq no . .It Cm Port Specifies the port number to connect on the remote host. -Default is 22. +The default is 22. .It Cm PreferredAuthentications Specifies the order in which the client should try protocol 2 authentication methods. @@ -679,20 +713,26 @@ This allows a client to prefer one method (e.g.\& over another method (e.g.\& .Cm password ) The default for this option is: -.Dq publickey,gssapi-keyex,external-keyx,gssapi-with-mic,gssapi,password,keyboard-interactive . +.Do gssapi-keyex , +external-keyx, +gssapi-with-mic, +hostbased, +publickey, +keyboard-interactive, +password +.Dc . .It Cm Protocol Specifies the protocol versions -.Nm ssh +.Xr ssh 1 should support in order of preference. The possible values are -.Dq 1 +.Sq 1 and -.Dq 2 . +.Sq 2 . Multiple versions must be comma-separated. The default is .Dq 2,1 . -This means that -.Nm ssh +This means that ssh tries version 2 and falls back to version 1 if version 2 is not available. .It Cm ProxyCommand @@ -750,9 +790,9 @@ or .Sq G to indicate Kilobytes, Megabytes, or Gigabytes, respectively. The default is between -.Dq 1G +.Sq 1G and -.Dq 4G , +.Sq 4G , depending on the cipher. This option applies to protocol version 2 only. .It Cm RemoteForward @@ -798,7 +838,7 @@ or The default is .Dq no . This option applies to protocol version 1 only and requires -.Nm ssh +.Xr ssh 1 to be setuid root. .It Cm RSAAuthentication Specifies whether to try RSA authentication. @@ -816,31 +856,31 @@ Note that this option applies to protocol version 1 only. Specifies what variables from the local .Xr environ 7 should be sent to the server. -Note that environment passing is only supported for protocol 2, the -server must also support it, and the server must be configured to +Note that environment passing is only supported for protocol 2. +The server must also support it, and the server must be configured to accept these environment variables. Refer to .Cm AcceptEnv in .Xr sshd_config 5 for how to configure the server. -Variables are specified by name, which may contain the wildcard characters -.Ql \&* -and -.Ql \&? . +Variables are specified by name, which may contain wildcard characters. Multiple environment variables may be separated by whitespace or spread across multiple .Cm SendEnv directives. The default is not to send any environment variables. +.Pp +See +.Sx PATTERNS +for more information on patterns. .It Cm ServerAliveCountMax Sets the number of server alive messages (see below) which may be sent without -.Nm ssh +.Xr ssh 1 receiving any messages back from the server. If this threshold is reached while server alive messages are being sent, -.Nm ssh -will disconnect from the server, terminating the session. +ssh will disconnect from the server, terminating the session. It is important to note that the use of server alive messages is very different from .Cm TCPKeepAlive @@ -856,14 +896,15 @@ server depend on knowing when a connection has become inactive. The default value is 3. If, for example, .Cm ServerAliveInterval -(see below) is set to 15, and +(see below) is set to 15 and .Cm ServerAliveCountMax -is left at the default, if the server becomes unresponsive ssh -will disconnect after approximately 45 seconds. +is left at the default, if the server becomes unresponsive, +ssh will disconnect after approximately 45 seconds. +This option applies to protocol version 2 only. .It Cm ServerAliveInterval Sets a timeout interval in seconds after which if no data has been received from the server, -.Nm ssh +.Xr ssh 1 will send a message through the encrypted channel to request a response from the server. The default @@ -872,41 +913,39 @@ This option applies to protocol version 2 only. .It Cm SmartcardDevice Specifies which smartcard device to use. The argument to this keyword is the device -.Nm ssh +.Xr ssh 1 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. .It Cm StrictHostKeyChecking If this flag is set to .Dq yes , -.Nm ssh +.Xr ssh 1 will never automatically add host keys to the .Pa ~/.ssh/known_hosts file, and refuses to connect to hosts whose host key has changed. This provides maximum protection against trojan horse attacks, -however, can be annoying when the +though it can be annoying when the .Pa /etc/ssh/ssh_known_hosts -file is poorly maintained, or connections to new hosts are +file is poorly maintained or when connections to new hosts are frequently made. This option forces the user to manually add all new hosts. If this flag is set to .Dq no , -.Nm ssh -will automatically add new host keys to the +ssh will automatically add new host keys to the user known hosts files. If this flag is set to .Dq ask , new host keys will be added to the user known host files only after the user has confirmed that is what they really want to do, and -.Nm ssh -will refuse to connect to hosts whose host key has changed. +ssh will refuse to connect to hosts whose host key has changed. The host keys of known hosts will be verified automatically in all cases. The argument must be .Dq yes , -.Dq no +.Dq no , or .Dq ask . The default is @@ -929,24 +968,44 @@ This is important in scripts, and many users want it too. To disable TCP keepalive messages, the value should be set to .Dq no . .It Cm Tunnel -Request starting +Request .Xr tun 4 device forwarding between the client and the server. -This option also allows requesting layer 2 (ethernet) -instead of layer 3 (point-to-point) tunneling from the server. The argument must be .Dq yes , -.Dq point-to-point , +.Dq point-to-point +(layer 3), .Dq ethernet +(layer 2), or .Dq no . +Specifying +.Dq yes +requests the default tunnel mode, which is +.Dq point-to-point . The default is .Dq no . .It Cm TunnelDevice -Force a specified +Specifies the .Xr tun 4 -device on the client. -Without this option, the next available device will be used. +devices to open on the client +.Pq Ar local_tun +and the server +.Pq Ar remote_tun . +.Pp +The argument must be +.Sm off +.Ar local_tun Op : Ar remote_tun . +.Sm on +The devices may be specified by numerical ID or the keyword +.Dq any , +which uses the next available tunnel device. +If +.Ar remote_tun +is not specified, it defaults to +.Dq any . +The default is +.Dq any:any . .It Cm UsePrivilegedPort Specifies whether to use a privileged port for outgoing connections. The argument must be @@ -956,8 +1015,8 @@ or The default is .Dq no . If set to -.Dq yes -.Nm ssh +.Dq yes , +.Xr ssh 1 must be setuid root. Note that this option must be set to .Dq yes @@ -990,12 +1049,17 @@ need to confirm new host keys according to the option. The argument must be .Dq yes , -.Dq no +.Dq no , or .Dq ask . The default is .Dq no . Note that this option applies to protocol version 2 only. +.Pp +See also +.Sx VERIFYING HOST KEYS +in +.Xr ssh 1 . .It Cm XAuthLocation Specifies the full pathname of the .Xr xauth 1 @@ -1003,14 +1067,47 @@ program. The default is .Pa /usr/X11R6/bin/xauth . .El +.Sh PATTERNS +A +.Em pattern +consists of zero or more non-whitespace characters, +.Sq * +(a wildcard that matches zero or more characters), +or +.Sq ?\& +(a wildcard that matches exactly one character). +For example, to specify a set of declarations for any host in the +.Dq .co.uk +set of domains, +the following pattern could be used: +.Pp +.Dl Host *.co.uk +.Pp +The following pattern +would match any host in the 192.168.0.[0-9] network range: +.Pp +.Dl Host 192.168.0.? +.Pp +A +.Em pattern-list +is a comma-separated list of patterns. +Patterns within pattern-lists may be negated +by preceding them with an exclamation mark +.Pq Sq !\& . +For example, +to allow a key to be used from anywhere within an organisation +except from the +.Dq dialup +pool, +the following entry (in authorized_keys) could be used: +.Pp +.Dl from=\&"!*.dialup.example.com,*.example.com\&" .Sh FILES .Bl -tag -width Ds .It Pa ~/.ssh/config This is the per-user configuration file. The format of this file is described above. -This file is used by the -.Nm ssh -client. +This file is used by the SSH client. Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not accessible by others. .It Pa /etc/ssh/ssh_config diff --git a/openssh/sshconnect.c b/openssh/sshconnect.c index 975674c..e016e19 100644 --- a/openssh/sshconnect.c +++ b/openssh/sshconnect.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshconnect.c,v 1.200 2006/10/10 10:12:45 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -13,12 +14,35 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect.c,v 1.171 2005/12/06 22:38:27 reyk Exp $"); -#include +#include +#include +#include +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include + +#include +#include +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include -#include "ssh.h" #include "xmalloc.h" +#include "key.h" +#include "hostfile.h" +#include "ssh.h" #include "rsa.h" #include "buffer.h" #include "packet.h" @@ -32,6 +56,7 @@ RCSID("$OpenBSD: sshconnect.c,v 1.171 2005/12/06 22:38:27 reyk Exp $"); #include "atomicio.h" #include "misc.h" #include "dns.h" +#include "version.h" char *client_version_string = NULL; char *server_version_string = NULL; @@ -62,7 +87,6 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) int pin[2], pout[2]; pid_t pid; char strport[NI_MAXSERV]; - size_t len; /* Convert the port number into a string. */ snprintf(strport, sizeof strport, "%hu", port); @@ -74,10 +98,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) * Use "exec" to avoid "sh -c" processes on some platforms * (e.g. Solaris) */ - len = strlen(proxy_command) + 6; - tmp = xmalloc(len); - strlcpy(tmp, "exec ", len); - strlcat(tmp, proxy_command, len); + xasprintf(&tmp, "exec %s", proxy_command); command_string = percent_expand(tmp, "h", host, "p", strport, (char *)NULL); xfree(tmp); @@ -94,8 +115,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) char *argv[10]; /* Child. Permanently give up superuser privileges. */ - seteuid(original_real_uid); - setuid(original_real_uid); + permanently_drop_suid(original_real_uid); /* Redirect stdin and stdout. */ close(pin[1]); @@ -236,7 +256,7 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr, fd_set *fdset; struct timeval tv; socklen_t optlen; - int fdsetsz, optval, rc, result = -1; + int optval, rc, result = -1; if (timeout <= 0) return (connect(sockfd, serv_addr, addrlen)); @@ -250,10 +270,8 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr, if (errno != EINPROGRESS) return (-1); - fdsetsz = howmany(sockfd + 1, NFDBITS) * sizeof(fd_mask); - fdset = (fd_set *)xmalloc(fdsetsz); - - memset(fdset, 0, fdsetsz); + fdset = (fd_set *)xcalloc(howmany(sockfd + 1, NFDBITS), + sizeof(fd_mask)); FD_SET(sockfd, fdset); tv.tv_sec = timeout; tv.tv_usec = 0; @@ -336,17 +354,16 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, fatal("%s: %.100s: %s", __progname, host, gai_strerror(gaierr)); - /* - * Try to connect several times. On some machines, the first time - * will sometimes fail. In general socket code appears to behave - * quite magically on many machines. - */ - for (attempt = 0; ;) { - if (attempt > 0) + for (attempt = 0; attempt < connection_attempts; attempt++) { + if (attempt > 0) { + /* Sleep a moment before retrying. */ + sleep(1); debug("Trying again..."); - - /* Loop through addresses for this host, and try each one in - sequence until the connection succeeds. */ + } + /* + * Loop through addresses for this host, and try each one in + * sequence until the connection succeeds. + */ for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) continue; @@ -373,29 +390,18 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, } else { debug("connect to address %s port %s: %s", ntop, strport, strerror(errno)); - /* - * Close the failed socket; there appear to - * be some problems when reusing a socket for - * which connect() has already returned an - * error. - */ close(sock); + sock = -1; } } - if (ai) + if (sock != -1) break; /* Successful connection. */ - - attempt++; - if (attempt >= connection_attempts) - break; - /* Sleep a moment before retrying. */ - sleep(1); } freeaddrinfo(aitop); /* Return failure if we didn't get a successful connection. */ - if (attempt >= connection_attempts) { + if (sock == -1) { error("ssh: connect to host %s port %s: %s", host, strport, strerror(errno)); return (-1); @@ -427,10 +433,10 @@ ssh_exchange_identification(void) int connection_in = packet_get_connection_in(); int connection_out = packet_get_connection_out(); int minor1 = PROTOCOL_MINOR_1; - u_int i; + u_int i, n; /* Read other side's version identification. */ - for (;;) { + for (n = 0;;) { for (i = 0; i < sizeof(buf) - 1; i++) { size_t len = atomicio(read, connection_in, &buf[i], 1); @@ -447,6 +453,8 @@ ssh_exchange_identification(void) buf[i + 1] = 0; break; } + if (++n > 65536) + fatal("ssh_exchange_identification: No banner received"); } buf[sizeof(buf) - 1] = 0; if (strncmp(buf, "SSH-", 4) == 0) @@ -548,13 +556,17 @@ confirm(const char *prompt) * check whether the supplied host key is valid, return -1 if the key * is not valid. the user_hostfile will not be updated if 'readonly' is true. */ +#define RDRW 0 +#define RDONLY 1 +#define ROQUIET 2 static int -check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, - int readonly, const char *user_hostfile, const char *system_hostfile) +check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port, + Key *host_key, int readonly, const char *user_hostfile, + const char *system_hostfile) { Key *file_key; const char *type = key_type(host_key); - char *ip = NULL; + char *ip = NULL, *host = NULL; char hostline[1000], *hostp, *fp; HostStatus host_status; HostStatus ip_status; @@ -605,7 +617,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, if (getnameinfo(hostaddr, salen, ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST) != 0) fatal("check_host_key: getnameinfo failed"); - ip = xstrdup(ntop); + ip = put_host_port(ntop, port); } else { ip = xstrdup(""); } @@ -613,18 +625,21 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, * Turn off check_host_ip if the connection is to localhost, via proxy * command or if we don't have a hostname to compare with */ - if (options.check_host_ip && - (local || strcmp(host, ip) == 0 || options.proxy_command != NULL)) + if (options.check_host_ip && (local || + strcmp(hostname, ip) == 0 || options.proxy_command != NULL)) options.check_host_ip = 0; /* - * Allow the user to record the key under a different name. This is - * useful for ssh tunneling over forwarded connections or if you run - * multiple sshd's on different ports on the same machine. + * Allow the user to record the key under a different name or + * differentiate a non-standard port. This is useful for ssh + * tunneling over forwarded connections or if you run multiple + * sshd's on different ports on the same machine. */ if (options.host_key_alias != NULL) { - host = options.host_key_alias; + host = xstrdup(options.host_key_alias); debug("using hostkeyalias: %s", host); + } else { + host = put_host_port(hostname, port); } /* @@ -693,6 +708,15 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, } break; case HOST_NEW: + if (options.host_key_alias == NULL && port != 0 && + port != SSH_DEFAULT_PORT) { + debug("checking without port identifier"); + if (check_host_key(hostname, hostaddr, 0, host_key, 2, + user_hostfile, system_hostfile) == 0) { + debug("found matching key w/out port"); + break; + } + } if (readonly) goto fail; /* The host is new. */ @@ -772,6 +796,8 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, "list of known hosts.", hostp, type); break; case HOST_CHANGED: + if (readonly == ROQUIET) + goto fail; if (options.check_host_ip && host_ip_differ) { char *key_msg; if (ip_status == HOST_NEW) @@ -810,7 +836,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 - * agent forwarding. + * forwarding. */ if (options.password_authentication) { error("Password authentication is disabled to avoid " @@ -845,6 +871,11 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, options.num_local_forwards = options.num_remote_forwards = 0; } + if (options.tun_open != SSH_TUNMODE_NO) { + error("Tunnel forwarding is disabled to avoid " + "man-in-the-middle attacks."); + options.tun_open = SSH_TUNMODE_NO; + } /* * XXX Should permit the user to change to use the new id. * This could be done by converting the host key to an @@ -886,10 +917,12 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, } xfree(ip); + xfree(host); return 0; fail: xfree(ip); + xfree(host); return -1; } @@ -923,12 +956,13 @@ verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key) /* 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) { - if (check_host_key(host, hostaddr, host_key, /*readonly*/ 1, - options.user_hostfile2, options.system_hostfile2) == 0) + if (check_host_key(host, hostaddr, options.port, host_key, + RDONLY, options.user_hostfile2, + options.system_hostfile2) == 0) return 0; } - return check_host_key(host, hostaddr, host_key, /*readonly*/ 0, - options.user_hostfile, options.system_hostfile); + return check_host_key(host, hostaddr, options.port, host_key, + RDRW, options.user_hostfile, options.system_hostfile); } /* @@ -952,7 +986,7 @@ ssh_login(Sensitive *sensitive, const char *orighost, host = xstrdup(orighost); for (cp = host; *cp; cp++) if (isupper(*cp)) - *cp = tolower(*cp); + *cp = (char)tolower(*cp); /* Exchange protocol version identification strings with the server. */ ssh_exchange_identification(); @@ -969,6 +1003,7 @@ ssh_login(Sensitive *sensitive, const char *orighost, ssh_kex(host, hostaddr); ssh_userauth1(local_user, server_user, host, sensitive); } + xfree(local_user); } void @@ -982,8 +1017,7 @@ ssh_put_password(char *password) return; } size = roundup(strlen(password) + 1, 32); - padded = xmalloc(size); - memset(padded, 0, size); + padded = xcalloc(1, size); strlcpy(padded, password, size); packet_put_string(padded, size); memset(padded, 0, size); diff --git a/openssh/sshconnect.h b/openssh/sshconnect.h index e7c7a2b..4e66bbf 100644 --- a/openssh/sshconnect.h +++ b/openssh/sshconnect.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect.h,v 1.18 2005/12/06 22:38:28 reyk Exp $ */ +/* $OpenBSD: sshconnect.h,v 1.23 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -23,8 +23,6 @@ * (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 SSHCONNECT_H -#define SSHCONNECT_H typedef struct Sensitive Sensitive; struct Sensitive { @@ -54,16 +52,18 @@ int ssh_local_cmd(const char *); /* * Macros to raise/lower permissions. */ -#define PRIV_START do { \ - int save_errno = errno; \ - (void)seteuid(original_effective_uid); \ - errno = save_errno; \ +#define PRIV_START do { \ + int save_errno = errno; \ + if (seteuid(original_effective_uid) != 0) \ + fatal("PRIV_START: seteuid: %s", \ + strerror(errno)); \ + errno = save_errno; \ } while (0) -#define PRIV_END do { \ - int save_errno = errno; \ - (void)seteuid(original_real_uid); \ - errno = save_errno; \ +#define PRIV_END do { \ + int save_errno = errno; \ + if (seteuid(original_real_uid) != 0) \ + fatal("PRIV_END: seteuid: %s", \ + strerror(errno)); \ + errno = save_errno; \ } while (0) - -#endif diff --git a/openssh/sshconnect1.c b/openssh/sshconnect1.c index 440d7c5..fd07bbf 100644 --- a/openssh/sshconnect1.c +++ b/openssh/sshconnect1.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshconnect1.c,v 1.70 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -13,28 +14,38 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect1.c,v 1.62 2005/10/30 08:52:18 djm Exp $"); + +#include +#include #include #include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" -#include "xmalloc.h" #include "rsa.h" #include "buffer.h" #include "packet.h" +#include "key.h" +#include "cipher.h" #include "kex.h" #include "uidswap.h" #include "log.h" #include "readconf.h" -#include "key.h" #include "authfd.h" #include "sshconnect.h" #include "authfile.h" #include "misc.h" -#include "cipher.h" #include "canohost.h" +#include "hostfile.h" #include "auth.h" /* Session id for the current session. */ @@ -197,7 +208,7 @@ try_rsa_authentication(int idx) BIGNUM *challenge; Key *public, *private; char buf[300], *passphrase, *comment, *authfile; - int i, type, quit; + int i, perm_ok = 1, type, quit; public = options.identity_keys[idx]; authfile = options.identity_files[idx]; @@ -243,15 +254,16 @@ try_rsa_authentication(int idx) if (public->flags & KEY_FLAG_EXT) private = public; else - private = key_load_private_type(KEY_RSA1, authfile, "", NULL); - if (private == NULL && !options.batch_mode) { + private = key_load_private_type(KEY_RSA1, authfile, "", NULL, + &perm_ok); + if (private == NULL && !options.batch_mode && perm_ok) { snprintf(buf, sizeof(buf), "Enter passphrase for RSA key '%.100s': ", comment); for (i = 0; i < options.number_of_password_prompts; i++) { passphrase = read_passphrase(buf, 0); if (strcmp(passphrase, "") != 0) { private = key_load_private_type(KEY_RSA1, - authfile, passphrase, NULL); + authfile, passphrase, NULL, NULL); quit = 0; } else { debug2("no passphrase given, try next key"); @@ -268,7 +280,7 @@ try_rsa_authentication(int idx) xfree(comment); if (private == NULL) { - if (!options.batch_mode) + if (!options.batch_mode && perm_ok) error("Bad passphrase."); /* Send a dummy response packet to avoid protocol error. */ @@ -551,14 +563,20 @@ ssh_kex(char *host, struct sockaddr *hostaddr) * the first 16 bytes of the session id. */ if ((key = BN_new()) == NULL) - fatal("respond_to_rsa_challenge: BN_new failed"); - BN_set_word(key, 0); + fatal("ssh_kex: BN_new failed"); + if (BN_set_word(key, 0) == 0) + fatal("ssh_kex: BN_set_word failed"); for (i = 0; i < SSH_SESSION_KEY_LENGTH; i++) { - BN_lshift(key, key, 8); - if (i < 16) - BN_add_word(key, session_key[i] ^ session_id[i]); - else - BN_add_word(key, session_key[i]); + if (BN_lshift(key, key, 8) == 0) + fatal("ssh_kex: BN_lshift failed"); + if (i < 16) { + if (BN_add_word(key, session_key[i] ^ session_id[i]) + == 0) + fatal("ssh_kex: BN_add_word failed"); + } else { + if (BN_add_word(key, session_key[i]) == 0) + fatal("ssh_kex: BN_add_word failed"); + } } /* diff --git a/openssh/sshconnect2.c b/openssh/sshconnect2.c index c35587f..4a18b05 100644 --- a/openssh/sshconnect2.c +++ b/openssh/sshconnect2.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshconnect2.c,v 1.162 2006/08/30 00:06:51 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,18 +24,30 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect2.c,v 1.143 2005/10/14 02:17:59 stevesk Exp $"); + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #include "openbsd-compat/sys-queue.h" +#include "xmalloc.h" #include "ssh.h" #include "ssh2.h" -#include "xmalloc.h" #include "buffer.h" #include "packet.h" #include "compat.h" -#include "bufaux.h" #include "cipher.h" +#include "key.h" #include "kex.h" #include "myproposal.h" #include "sshconnect.h" @@ -49,6 +62,7 @@ RCSID("$OpenBSD: sshconnect2.c,v 1.143 2005/10/14 02:17:59 stevesk Exp $"); #include "canohost.h" #include "msg.h" #include "pathnames.h" +#include "uidswap.h" #ifdef GSSAPI #include "ssh-gss.h" @@ -92,8 +106,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) #ifdef GSSAPI char *orig = NULL, *gss = NULL; - int len; - char *gss_host = NULL; + char *gss_host = NULL; #endif xxx_host = host; @@ -101,22 +114,21 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) #ifdef GSSAPI if (options.gss_keyex) { - /* Add the GSSAPI mechanisms currently supported on this client to - * the key exchange algorithm proposal */ - orig = myproposal[PROPOSAL_KEX_ALGS]; - if (options.gss_trust_dns) - gss_host = (char *)get_canonical_hostname(1); - else - gss_host = host; - - gss = ssh_gssapi_client_mechanisms(gss_host); - if (gss) { - debug("Offering GSSAPI proposal: %s", gss); - len = strlen(orig) + strlen(gss) + 2; - myproposal[PROPOSAL_KEX_ALGS] = xmalloc(len); - snprintf(myproposal[PROPOSAL_KEX_ALGS], len, "%s,%s", gss, - orig); - } + /* Add the GSSAPI mechanisms currently supported on this + * client to the key exchange algorithm proposal */ + orig = myproposal[PROPOSAL_KEX_ALGS]; + + if (options.gss_trust_dns) + gss_host = (char *)get_canonical_hostname(1); + else + gss_host = host; + + gss = ssh_gssapi_client_mechanisms(gss_host); + if (gss) { + debug("Offering GSSAPI proposal: %s", gss); + xasprintf(&myproposal[PROPOSAL_KEX_ALGS], + "%s,%s", gss, orig); + } } #endif @@ -153,9 +165,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) * 'null' hostkey, as a last resort */ if (options.gss_keyex && gss) { orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]; - len = strlen(orig) + sizeof(",null"); - myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = xmalloc(len); - snprintf(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], len, + xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], "%s,null", orig); } #endif @@ -168,8 +178,10 @@ ssh_kex2(char *host, struct sockaddr *hostaddr) kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; + kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; #ifdef GSSAPI kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client; + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client; kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client; #endif kex->client_version_string=client_version_string; @@ -381,14 +393,28 @@ ssh_userauth2(const char *local_user, const char *server_user, char *host, pubkey_cleanup(&authctxt); dispatch_range(SSH2_MSG_USERAUTH_MIN, SSH2_MSG_USERAUTH_MAX, NULL); - if ((options.none_switch == 1) && (options.none_enabled == 1) && !tty_flag) /* no null on tty sessions */ + + /* if the user wants to use the none cipher do it */ + /* post authentication and only if the right conditions are met */ + /* both of the NONE commands must be true and there must be no */ + /* tty allocated */ + if ((options.none_switch == 1) && (options.none_enabled == 1)) { - debug("Requesting none rekeying..."); - myproposal[PROPOSAL_ENC_ALGS_STOC] = "none"; - myproposal[PROPOSAL_ENC_ALGS_CTOS] = "none"; - kex_prop2buf(&xxx_kex->my,myproposal); - packet_request_rekeying(); - fprintf(stderr, "WARNING: ENABLED NULL CIPHER\n"); + if (!tty_flag) /* no null on tty sessions */ + { + debug("Requesting none rekeying..."); + myproposal[PROPOSAL_ENC_ALGS_STOC] = "none"; + myproposal[PROPOSAL_ENC_ALGS_CTOS] = "none"; + kex_prop2buf(&xxx_kex->my,myproposal); + packet_request_rekeying(); + fprintf(stderr, "WARNING: ENABLED NONE CIPHER\n"); + } + else + { + /* requested NONE cipher when in a tty */ + debug("Cannot switch to NONE cipher with tty allocated"); + fprintf(stderr, "NONE cipher switch disabled when a TTY is allocated\n"); + } } debug("Authentication succeeded (%s).", authctxt.method->name); } @@ -443,7 +469,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); - if (options.log_level > SYSLOG_LEVEL_QUIET) + if (options.log_level >= SYSLOG_LEVEL_INFO) fprintf(stderr, "%s", msg); xfree(msg); xfree(lang); @@ -585,17 +611,10 @@ userauth_gssapi(Authctxt *authctxt) /* Check to see if the mechanism is usable before we offer it */ while (mech < gss_supported->count && !ok) { - if (gssctxt) - ssh_gssapi_delete_ctx(&gssctxt); - ssh_gssapi_build_ctx(&gssctxt); - ssh_gssapi_set_oid(gssctxt, &gss_supported->elements[mech]); - /* My DER encoding requires length<128 */ if (gss_supported->elements[mech].length < 128 && - ssh_gssapi_check_mechanism(&gss_supported->elements[mech], - gss_host) && - !GSS_ERROR(ssh_gssapi_import_name(gssctxt, - gss_host))) { + ssh_gssapi_check_mechanism(&gssctxt, + &gss_supported->elements[mech], gss_host)) { ok = 1; /* Mechanism works */ } else { mech++; @@ -692,8 +711,8 @@ input_gssapi_response(int type, u_int32_t plen, void *ctxt) { Authctxt *authctxt = ctxt; Gssctxt *gssctxt; - unsigned int oidlen; - unsigned char *oidv; + u_int oidlen; + u_char *oidv; if (authctxt == NULL) fatal("input_gssapi_response: no authentication context"); @@ -1157,14 +1176,16 @@ load_identity_file(char *filename) { Key *private; char prompt[300], *passphrase; - int quit, i; + int perm_ok, quit, i; struct stat st; if (stat(filename, &st) < 0) { debug3("no such identity: %s", filename); return NULL; } - private = key_load_private_type(KEY_UNSPEC, filename, "", NULL); + private = key_load_private_type(KEY_UNSPEC, filename, "", NULL, &perm_ok); + if (!perm_ok) + return NULL; if (private == NULL) { if (options.batch_mode) return NULL; @@ -1173,8 +1194,8 @@ load_identity_file(char *filename) for (i = 0; i < options.number_of_password_prompts; i++) { passphrase = read_passphrase(prompt, 0); if (strcmp(passphrase, "") != 0) { - private = key_load_private_type(KEY_UNSPEC, filename, - passphrase, NULL); + private = key_load_private_type(KEY_UNSPEC, + filename, passphrase, NULL, NULL); quit = 0; } else { debug2("no passphrase given, try next key"); @@ -1217,8 +1238,7 @@ pubkey_prepare(Authctxt *authctxt) if (key && key->type == KEY_RSA1) continue; options.identity_keys[i] = NULL; - id = xmalloc(sizeof(*id)); - memset(id, 0, sizeof(*id)); + id = xcalloc(1, sizeof(*id)); id->key = key; id->filename = xstrdup(options.identity_files[i]); TAILQ_INSERT_TAIL(&files, id, next); @@ -1242,8 +1262,7 @@ pubkey_prepare(Authctxt *authctxt) } } if (!found && !options.identities_only) { - id = xmalloc(sizeof(*id)); - memset(id, 0, sizeof(*id)); + id = xcalloc(1, sizeof(*id)); id->key = key; id->filename = comment; id->ac = ac; @@ -1439,8 +1458,7 @@ ssh_keysign(Key *key, u_char **sigp, u_int *lenp, return -1; } if (pid == 0) { - seteuid(getuid()); - setuid(getuid()); + permanently_drop_suid(getuid()); close(from[0]); if (dup2(from[1], STDOUT_FILENO) < 0) fatal("ssh_keysign: dup2: %s", strerror(errno)); @@ -1520,12 +1538,11 @@ userauth_hostbased(Authctxt *authctxt) if (p == NULL) { error("userauth_hostbased: cannot get local ipaddr/name"); key_free(private); + xfree(blob); return 0; } len = strlen(p) + 2; - chost = xmalloc(len); - strlcpy(chost, p, len); - strlcat(chost, ".", len); + xasprintf(&chost, "%s.", p); debug2("userauth_hostbased: chost %s", chost); xfree(p); @@ -1558,6 +1575,7 @@ userauth_hostbased(Authctxt *authctxt) error("key_sign failed"); xfree(chost); xfree(pkalg); + xfree(blob); return 0; } packet_start(SSH2_MSG_USERAUTH_REQUEST); @@ -1573,6 +1591,7 @@ userauth_hostbased(Authctxt *authctxt) xfree(signature); xfree(chost); xfree(pkalg); + xfree(blob); packet_send(); return 1; diff --git a/openssh/sshd.8 b/openssh/sshd.8 index 51d339b..522279e 100644 --- a/openssh/sshd.8 +++ b/openssh/sshd.8 @@ -34,7 +34,7 @@ .\" (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.215 2006/02/01 09:11:41 jmc Exp $ +.\" $OpenBSD: sshd.8,v 1.234 2006/08/21 08:15:57 dtucker Exp $ .Dd September 25, 1999 .Dt SSHD 8 .Os @@ -81,7 +81,7 @@ configuration file. .Nm rereads its configuration file when it receives a hangup signal, .Dv SIGHUP , -by executing itself with the name and options it was started with, e.g., +by executing itself with the name and options it was started with, e.g.\& .Pa /usr/sbin/sshd . .Pp The options are as follows: @@ -154,7 +154,7 @@ is normally not run from inetd because it needs to generate the server key before it can respond to the client, and this may take tens of seconds. Clients would have to wait too long if the key was regenerated every time. -However, with small key sizes (e.g., 512) using +However, with small key sizes (e.g. 512) using .Nm from inetd may be feasible. @@ -308,17 +308,6 @@ or .Ql \&*NP\&* ). .Pp -System security is not improved unless -.Nm rshd , -.Nm rlogind , -and -.Nm rexecd -are disabled (thus completely disabling -.Xr rlogin -and -.Xr rsh -into the machine). -.Sh COMMAND EXECUTION AND DATA FORWARDING If the client successfully authenticates itself, a dialog for preparing the session is entered. At this time the client may request @@ -326,7 +315,7 @@ things like allocating a pseudo-tty, forwarding X11 connections, forwarding TCP connections, or forwarding the authentication agent connection over the secure channel. .Pp -Finally, the client either requests a shell or execution of a command. +After this, the client either requests a shell or execution of a command. The sides then enter session mode. In this mode, either side may send data at any time, and such data is forwarded to/from the shell or @@ -381,31 +370,73 @@ The .Dq rc files are given the X11 authentication protocol and cookie in standard input. +See +.Sx SSHRC , +below. .It Runs user's shell or command. .El +.Sh SSHRC +If the file +.Pa ~/.ssh/rc +exists, +.Xr sh 1 +runs it after reading the +environment files but before starting the user's shell or command. +It must not produce any output on stdout; stderr must be used +instead. +If X11 forwarding is in use, it will receive the "proto cookie" pair in +its standard input (and +.Ev DISPLAY +in its environment). +The script must call +.Xr xauth 1 +because +.Nm +will not run xauth automatically to add X11 cookies. +.Pp +The primary purpose of this file is to run any initialization routines +which may be needed before the user's home directory becomes +accessible; AFS is a particular example of such an environment. +.Pp +This file will probably contain some initialization code followed by +something similar to: +.Bd -literal -offset 3n +if read proto cookie && [ -n "$DISPLAY" ]; then + if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then + # X11UseLocalhost=yes + echo add unix:`echo $DISPLAY | + cut -c11-` $proto $cookie + else + # X11UseLocalhost=no + echo add $DISPLAY $proto $cookie + fi | xauth -q - +fi +.Ed +.Pp +If this file does not exist, +.Pa /etc/ssh/sshrc +is run, and if that +does not exist either, xauth is used to add the cookie. .Sh AUTHORIZED_KEYS FILE FORMAT -.Pa ~/.ssh/authorized_keys -is the default file that lists the public keys that are -permitted for RSA authentication in protocol version 1 -and for public key authentication (PubkeyAuthentication) -in protocol version 2. .Cm AuthorizedKeysFile -may be used to specify an alternative file. -.Pp +specifies the file containing public keys for +public key authentication; +if none is specified, the default is +.Pa ~/.ssh/authorized_keys . Each line of the file contains one key (empty lines and lines starting with a .Ql # are ignored as comments). -Each RSA public key consists of the following fields, separated by -spaces: options, bits, exponent, modulus, comment. -Each protocol version 2 public key consists of: -options, keytype, base64 encoded key, comment. -The options field -is optional; its presence is determined by whether the line starts +Protocol 1 public keys consist of the following space-separated fields: +options, bits, exponent, modulus, comment. +Protocol 2 public key consist of: +options, keytype, base64-encoded key, comment. +The options field is optional; +its presence is determined by whether the line starts with a number or not (the options field never starts with a number). -The bits, exponent, modulus and comment fields give the RSA key for +The bits, exponent, modulus, and comment fields give the RSA key for protocol version 1; the comment field is not used for anything (but may be convenient for the user to identify the key). @@ -420,7 +451,7 @@ Note that lines in this file are usually several hundred bytes long keys up to 16 kilobits. You don't want to type them in; instead, copy the .Pa identity.pub , -.Pa id_dsa.pub +.Pa id_dsa.pub , or the .Pa id_rsa.pub file and edit it. @@ -435,26 +466,6 @@ No spaces are permitted, except within double quotes. The following option specifications are supported (note that option keywords are case-insensitive): .Bl -tag -width Ds -.It Cm from="pattern-list" -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 \&* -and -.Ql \&? -serve as wildcards). -The list may also contain -patterns negated by prefixing them with -.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 -by itself does not trust the network or name servers or anything (but -the key); however, if somebody somehow steals the key, the key -permits an intruder to log in from anywhere in the world. -This additional option makes using a stolen key more difficult (name -servers and/or routers would have to be compromised in addition to -just the key). .It Cm command="command" Specifies that the command is executed whenever this key is used for authentication. @@ -470,6 +481,9 @@ to restrict certain public keys to perform just a specific operation. An example might be a key that permits remote backups but nothing else. Note that the client may specify TCP and/or X11 forwarding unless they are explicitly prohibited. +The command originally supplied by the client is available in the +.Ev SSH_ORIGINAL_COMMAND +environment variable. Note that this option applies to shell, command or subsystem execution. .It Cm environment="NAME=value" Specifies that the string is to be added to the environment when @@ -484,20 +498,38 @@ option. This option is automatically disabled if .Cm UseLogin is enabled. +.It Cm from="pattern-list" +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. +The purpose +of this option is to optionally increase security: public key authentication +by itself does not trust the network or name servers or anything (but +the key); however, if somebody somehow steals the key, the key +permits an intruder to log in from anywhere in the world. +This additional option makes using a stolen key more difficult (name +servers and/or routers would have to be compromised in addition to +just the key). +.Pp +See +.Sx PATTERNS +in +.Xr ssh_config 5 +for more information on patterns. +.It Cm no-agent-forwarding +Forbids authentication agent forwarding when this key is used for +authentication. .It Cm no-port-forwarding Forbids TCP forwarding when this key is used for authentication. Any port forward requests by the client will return an error. -This might be used, e.g., in connection with the +This might be used, e.g. in connection with the .Cm command option. +.It Cm no-pty +Prevents tty allocation (a request to allocate a pty will fail). .It Cm no-X11-forwarding Forbids X11 forwarding when this key is used for authentication. Any X11 forward requests by the client will return an error. -.It Cm no-agent-forwarding -Forbids authentication agent forwarding when this key is used for -authentication. -.It Cm no-pty -Prevents tty allocation (a request to allocate a pty will fail). .It Cm permitopen="host:port" Limit local .Li ``ssh -L'' @@ -517,16 +549,20 @@ device on the server. Without this option, the next available device will be used if the client requests a tunnel. .El -.Ss Examples -1024 33 12121...312314325 ylo@foo.bar .Pp -from="*.niksula.hut.fi,!pc.niksula.hut.fi" 1024 35 23...2334 ylo@niksula -.Pp -command="dump /home",no-pty,no-port-forwarding 1024 33 23...2323 backup.hut.fi -.Pp -permitopen="10.2.1.55:80",permitopen="10.2.1.56:25" 1024 33 23...2323 -.Pp -tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== reyk@openbsd.org +An example authorized_keys file: +.Bd -literal -offset 3n +# Comments allowed at start of line +ssh-rsa AAAAB3Nza...LiPk== user@example.net +from="*.sales.example.net,!pc.sales.example.net" ssh-rsa +AAAAB2...19Q== john@example.net +command="dump /home",no-pty,no-port-forwarding ssh-dss +AAAAC3...51R== example.net +permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss +AAAAB5...21S== +tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== +jane@example.net +.Ed .Sh SSH_KNOWN_HOSTS FILE FORMAT The .Pa /etc/ssh/ssh_known_hosts @@ -535,7 +571,7 @@ and files contain host public keys for all known hosts. The global file should be prepared by the administrator (optional), and the per-user file is -maintained automatically: whenever the user connects from an unknown host +maintained automatically: whenever the user connects from an unknown host, its key is added to the per-user file. .Pp Each line in these files contains the following fields: hostnames, @@ -543,7 +579,7 @@ bits, exponent, modulus, comment. The fields are separated by spaces. .Pp Hostnames is a comma-separated list of patterns -.Pf ( Ql \&* +.Pf ( Ql * and .Ql \&? act as @@ -555,6 +591,13 @@ A pattern may also be preceded by 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. +A hostname or address may optionally be enclosed within +.Ql \&[ +and +.Ql \&] +brackets then followed by +.Ql \&: +and a non-standard port number. .Pp Alternately, hostnames may be stored in a hashed form which hides host names and addresses should the file's contents be disclosed. @@ -565,7 +608,7 @@ Only one hashed hostname may appear on a single line and none of the above negation or wildcard operators may be applied. .Pp Bits, exponent, and modulus are taken directly from the RSA host key; they -can be obtained, e.g., from +can be obtained, for example, from .Pa /etc/ssh/ssh_host_key.pub . The optional comment field continues to the end of the line, and is not used. .Pp @@ -590,88 +633,19 @@ Rather, generate them by a script or by taking .Pa /etc/ssh/ssh_host_key.pub and adding the host names at the front. -.Ss Examples -.Bd -literal -closenet,...,130.233.208.41 1024 37 159...93 closenet.hut.fi -cvs.openbsd.org,199.185.137.3 ssh-rsa AAAA1234.....= -.Ed -.Bd -literal +.Pp +An example ssh_known_hosts file: +.Bd -literal -offset 3n +# Comments allowed at start of line +closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net +cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= # A hashed hostname |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa AAAA1234.....= .Ed .Sh FILES -.Bl -tag -width Ds -.It Pa /etc/ssh/sshd_config -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. -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. -These files should be world-readable but writable only by -root. -Their contents should match the respective private parts. -These files are not -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 -Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". -The file format is described in -.Xr moduli 5 . -.It Pa /var/empty -.Xr chroot 2 -directory used by -.Nm -during privilege separation in the pre-authentication phase. -The directory should not contain any files and must be owned by root -and not group or world-writable. -.It Pa /var/run/sshd.pid -Contains the process ID of the -.Nm -listening for connections (if there are several daemons running -concurrently for different ports, this contains the process ID of the one -started last). -The content of this file is not sensitive; it can be world-readable. -.It Pa ~/.ssh/authorized_keys -Lists the public keys (RSA or DSA) that can be used to log into the user's account. -This file must be readable by root (which may on some machines imply -it being world-readable if the user's home directory resides on an NFS -volume). -It is recommended that it not be accessible by others. -The format of this file is described above. -Users will place the contents of their -.Pa identity.pub , -.Pa id_dsa.pub -and/or -.Pa id_rsa.pub -files into this file, as described in -.Xr ssh-keygen 1 . -.It Pa "/etc/ssh/ssh_known_hosts", "~/.ssh/known_hosts" -These files are consulted when using rhosts with RSA host -authentication or protocol version 2 hostbased authentication -to check the public key of the host. -The key must be listed in one of these files to be accepted. -The client uses the same files -to verify that it is connecting to the correct remote host. -These files should be writable only by root/the owner. -.Pa /etc/ssh/ssh_known_hosts -should be world-readable, and -.Pa ~/.ssh/known_hosts -can, but need not be, world-readable. -.It Pa /etc/motd -See -.Xr motd 5 . -.It Pa ~/.hushlogin +.Bl -tag -width Ds -compact +.It ~/.hushlogin This file is used to suppress printing the last login time and .Pa /etc/motd , if @@ -682,86 +656,49 @@ respectively, are enabled. It does not suppress printing of the banner specified by .Cm Banner . -.It Pa /etc/nologin -If this file exists, +.Pp +.It ~/.rhosts +This file is used for host-based authentication (see +.Xr ssh 1 +for more information). +On some machines this file may need to be +world-readable if the user's home directory is on an NFS partition, +because .Nm -refuses to let anyone except root log in. -The contents of the file -are displayed to anyone trying to log in, and non-root connections are -refused. -The file should be world-readable. -.It Pa /etc/hosts.allow, /etc/hosts.deny -Access controls that should be enforced by tcp-wrappers are defined here. -Further details are described in -.Xr hosts_access 5 . -.It Pa ~/.rhosts -This file is used during -.Cm RhostsRSAAuthentication -and -.Cm HostbasedAuthentication -and contains host-username pairs, separated by a space, one per -line. -The given user on the corresponding host is permitted to log in -without a password. -The same file is used by rlogind and rshd. -The file must -be writable only by the user; it is recommended that it not be +reads it as root. +Additionally, this file must be owned by the user, +and must not have write permissions for anyone else. +The recommended +permission for most machines is read/write for the user, and not accessible by others. .Pp -It is also possible to use netgroups in the file. -Either host or user -name may be of the form +@groupname to specify all hosts or all users -in the group. -.It Pa ~/.shosts -For ssh, -this file is exactly the same as for -.Pa .rhosts . -However, this file is -not used by rlogin and rshd, so using this permits access using SSH only. -.It Pa /etc/hosts.equiv -This file is used during -.Cm RhostsRSAAuthentication -and -.Cm HostbasedAuthentication -authentication. -In the simplest form, this file contains host names, one per line. -Users on -those hosts are permitted to log in without a password, provided they -have the same user name on both machines. -The host name may also be -followed by a user name; such users are permitted to log in as -.Em any -user on this machine (except root). -Additionally, the syntax -.Dq +@group -can be used to specify netgroups. -Negated entries start with -.Ql \&- . -.Pp -If the client host/user is successfully matched in this file, login is -automatically permitted provided the client and server user names are the -same. -Additionally, successful client host key authentication is required. -This file must be writable only by root; it is recommended -that it be world-readable. -.Pp -.Sy "Warning: It is almost never a good idea to use user names in" -.Pa hosts.equiv . -Beware that it really means that the named user(s) can log in as -.Em anybody , -which includes bin, daemon, adm, and other accounts that own critical -binaries and directories. -Using a user name practically grants the user root access. -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 -This is processed exactly as -.Pa /etc/hosts.equiv . -However, this file may be useful in environments that want to run both -rsh/rlogin and ssh. -.It Pa ~/.ssh/environment +.It ~/.shosts +This file is used in exactly the same way as +.Pa .rhosts , +but allows host-based authentication without permitting login with +rlogin/rsh. +.Pp +.It ~/.ssh/authorized_keys +Lists the public keys (RSA/DSA) that can be used for logging in as this user. +The format of this file is described above. +The content of the file is not highly sensitive, but the recommended +permissions are read/write for the user, and not accessible by others. +.Pp +If this file, the +.Pa ~/.ssh +directory, or the user's home directory are writable +by other users, then the file could be modified or replaced by unauthorized +users. +In this case, +.Nm +will not allow it to be used unless the +.Cm StrictModes +option has been set to +.Dq no . +The recommended permissions can be set by executing +.Dq chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys . +.Pp +.It ~/.ssh/environment This file is read into the environment at login (if it exists). It can only contain empty lines, comment lines (that start with .Ql # ) , @@ -772,55 +709,115 @@ Environment processing is disabled by default and is controlled via the .Cm PermitUserEnvironment option. -.It Pa ~/.ssh/rc -If this file exists, it is run with -.Pa /bin/sh -after reading the -environment files but before starting the user's shell or command. -It must not produce any output on stdout; stderr must be used -instead. -If X11 forwarding is in use, it will receive the "proto cookie" pair in -its standard input (and -.Ev DISPLAY -in its environment). -The script must call -.Xr xauth 1 -because +.Pp +.It ~/.ssh/known_hosts +Contains a list of host keys for all hosts the user has logged into +that are not already in the systemwide list of known host keys. +The format of this file is described above. +This file should be writable only by root/the owner and +can, but need not be, world-readable. +.Pp +.It ~/.ssh/rc +Contains initialization routines to be run before +the user's home directory becomes accessible. +This file should be writable only by the user, and need not be +readable by anyone else. +.Pp +.It /etc/hosts.allow +.It /etc/hosts.deny +Access controls that should be enforced by tcp-wrappers are defined here. +Further details are described in +.Xr hosts_access 5 . +.Pp +.It /etc/hosts.equiv +This file is for host-based authentication (see +.Xr ssh 1 ) . +It should only be writable by root. +.Pp +.It /etc/moduli +Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". +The file format is described in +.Xr moduli 5 . +.Pp +.It /etc/motd +See +.Xr motd 5 . +.Pp +.It /etc/nologin +If this file exists, .Nm -will not run xauth automatically to add X11 cookies. +refuses to let anyone except root log in. +The contents of the file +are displayed to anyone trying to log in, and non-root connections are +refused. +The file should be world-readable. .Pp -The primary purpose of this file is to run any initialization routines -which may be needed before the user's home directory becomes -accessible; AFS is a particular example of such an environment. +.It /etc/shosts.equiv +This file is used in exactly the same way as +.Pa hosts.equiv , +but allows host-based authentication without permitting login with +rlogin/rsh. +.Pp +.It /etc/ssh/ssh_known_hosts +Systemwide list of known host keys. +This file should be prepared by the +system administrator to contain the public host keys of all machines in the +organization. +The format of this file is described above. +This file should be writable only by root/the owner and +should be world-readable. .Pp -This file will probably contain some initialization code followed by -something similar to: -.Bd -literal -if read proto cookie && [ -n "$DISPLAY" ]; then - if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then - # X11UseLocalhost=yes - echo add unix:`echo $DISPLAY | - cut -c11-` $proto $cookie - else - # X11UseLocalhost=no - echo add $DISPLAY $proto $cookie - fi | xauth -q - -fi -.Ed +.It /etc/ssh/ssh_host_key +.It /etc/ssh/ssh_host_dsa_key +.It /etc/ssh/ssh_host_rsa_key +These three 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 these files are group/world-accessible. .Pp -If this file does not exist, -.Pa /etc/ssh/sshrc -is run, and if that -does not exist either, xauth is used to add the cookie. +.It /etc/ssh/ssh_host_key.pub +.It /etc/ssh/ssh_host_dsa_key.pub +.It /etc/ssh/ssh_host_rsa_key.pub +These three 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. +These files are not +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 . .Pp -This file should be writable only by the user, and need not be -readable by anyone else. -.It Pa /etc/ssh/sshrc -Like -.Pa ~/.ssh/rc . -This can be used to specify +.It /etc/ssh/sshd_config +Contains configuration data for +.Nm sshd . +The file format and configuration options are described in +.Xr sshd_config 5 . +.Pp +.It /etc/ssh/sshrc +Similar to +.Pa ~/.ssh/rc , +it can be used to specify machine-specific login-time initializations globally. This file should be writable only by root, and should be world-readable. +.Pp +.It /var/empty +.Xr chroot 2 +directory used by +.Nm +during privilege separation in the pre-authentication phase. +The directory should not contain any files and must be owned by root +and not group or world-writable. +.Pp +.It /var/run/sshd.pid +Contains the process ID of the +.Nm +listening for connections (if there are several daemons running +concurrently for different ports, this contains the process ID of the one +started last). +The content of this file is not sensitive; it can be world-readable. .El .Sh SEE ALSO .Xr scp 1 , @@ -836,26 +833,6 @@ This file should be writable only by root, and should be world-readable. .Xr sshd_config 5 , .Xr inetd 8 , .Xr sftp-server 8 -.Rs -.%A T. Ylonen -.%A T. Kivinen -.%A M. Saarinen -.%A T. Rinne -.%A S. Lehtinen -.%T "SSH Protocol Architecture" -.%N draft-ietf-secsh-architecture-12.txt -.%D January 2002 -.%O work in progress material -.Re -.Rs -.%A M. Friedl -.%A N. Provos -.%A W. A. Simpson -.%T "Diffie-Hellman Group Exchange for the SSH Transport Layer Protocol" -.%N draft-ietf-secsh-dh-group-exchange-02.txt -.%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. @@ -867,3 +844,14 @@ 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 CAVEATS +System security is not improved unless +.Nm rshd , +.Nm rlogind , +and +.Nm rexecd +are disabled (thus completely disabling +.Xr rlogin +and +.Xr rsh +into the machine). diff --git a/openssh/sshd.c b/openssh/sshd.c index 5305b00..33f5f7b 100644 --- a/openssh/sshd.c +++ b/openssh/sshd.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshd.c,v 1.348 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -42,7 +43,33 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshd.c,v 1.318 2005/12/24 02:27:41 djm Exp $"); + +#include +#include +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include "openbsd-compat/sys-tree.h" +#include + +#include +#include +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -53,28 +80,28 @@ RCSID("$OpenBSD: sshd.c,v 1.318 2005/12/24 02:27:41 djm Exp $"); #include #endif +#include "xmalloc.h" #include "ssh.h" #include "ssh1.h" #include "ssh2.h" -#include "xmalloc.h" #include "rsa.h" #include "sshpty.h" #include "packet.h" #include "log.h" +#include "buffer.h" #include "servconf.h" #include "uidswap.h" #include "compat.h" -#include "buffer.h" -#include "bufaux.h" #include "cipher.h" -#include "kex.h" #include "key.h" +#include "kex.h" #include "dh.h" #include "myproposal.h" #include "authfile.h" #include "pathnames.h" #include "atomicio.h" #include "canohost.h" +#include "hostfile.h" #include "auth.h" #include "misc.h" #include "msg.h" @@ -83,8 +110,12 @@ RCSID("$OpenBSD: sshd.c,v 1.318 2005/12/24 02:27:41 djm Exp $"); #include "session.h" #include "monitor_mm.h" #include "monitor.h" +#ifdef GSSAPI +#include "ssh-gss.h" +#endif #include "monitor_wrap.h" #include "monitor_fdpass.h" +#include "version.h" #ifdef USE_SECURITY_SESSION_API #include @@ -205,15 +236,21 @@ int *startup_pipes = NULL; int startup_pipe; /* in child */ /* variables used for privilege separation */ -int use_privsep; +int use_privsep = -1; struct monitor *pmonitor = NULL; /* global authentication context */ Authctxt *the_authctxt = NULL; +/* sshd_config buffer */ +Buffer cfg; + /* message to be displayed after login */ Buffer loginmsg; +/* Unprivileged user */ +struct passwd *privsep_pw = NULL; + /* Prototypes for various functions defined later in this file. */ void destroy_sensitive_data(void); void demote_sensitive_data(void); @@ -250,6 +287,8 @@ close_startup_pipes(void) * the effect is to reread the configuration file (and to regenerate * the server key). */ + +/*ARGSUSED*/ static void sighup_handler(int sig) { @@ -279,6 +318,7 @@ sighup_restart(void) /* * Generic signal handler for terminating signals in the master daemon. */ +/*ARGSUSED*/ static void sigterm_handler(int sig) { @@ -289,6 +329,7 @@ sigterm_handler(int sig) * SIGCHLD handler. This is called whenever a child dies. This will then * reap any zombies left by exited children. */ +/*ARGSUSED*/ static void main_sigchld_handler(int sig) { @@ -307,16 +348,15 @@ main_sigchld_handler(int sig) /* * Signal handler for the alarm after the login grace period has expired. */ +/*ARGSUSED*/ static void grace_alarm_handler(int sig) { - /* XXX no idea how fix this signal handler */ - if (use_privsep && pmonitor != NULL && pmonitor->m_pid > 0) kill(pmonitor->m_pid, SIGALRM); /* Log error and exit. */ - fatal("Timeout before authentication for %s", get_remote_ipaddr()); + sigdie("Timeout before authentication for %s", get_remote_ipaddr()); } /* @@ -349,6 +389,7 @@ generate_ephemeral_server_key(void) arc4random_stir(); } +/*ARGSUSED*/ static void key_regeneration_alarm(int sig) { @@ -545,7 +586,6 @@ privsep_preauth_child(void) { u_int32_t rnd[256]; gid_t gidset[1]; - struct passwd *pw; int i; /* Enable challenge-response authentication for privilege separation */ @@ -558,12 +598,6 @@ privsep_preauth_child(void) /* Demote the private keys to public keys. */ demote_sensitive_data(); - if ((pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) - fatal("Privilege separation user %s does not exist", - SSH_PRIVSEP_USER); - memset(pw->pw_passwd, 0, strlen(pw->pw_passwd)); - endpwent(); - /* Change our root directory */ if (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1) fatal("chroot(\"%s\"): %s", _PATH_PRIVSEP_CHROOT_DIR, @@ -572,16 +606,16 @@ privsep_preauth_child(void) fatal("chdir(\"/\"): %s", strerror(errno)); /* Drop our privileges */ - debug3("privsep user:group %u:%u", (u_int)pw->pw_uid, - (u_int)pw->pw_gid); + debug3("privsep user:group %u:%u", (u_int)privsep_pw->pw_uid, + (u_int)privsep_pw->pw_gid); #if 0 /* XXX not ready, too heavy after chroot */ - do_setusercontext(pw); + do_setusercontext(privsep_pw); #else - gidset[0] = pw->pw_gid; + gidset[0] = privsep_pw->pw_gid; if (setgroups(1, gidset) < 0) fatal("setgroups: %.100s", strerror(errno)); - permanently_set_uid(pw); + permanently_set_uid(privsep_pw); #endif } @@ -870,6 +904,332 @@ recv_rexec_state(int fd, Buffer *conf) debug3("%s: done", __func__); } +/* Accept a connection from inetd */ +static void +server_accept_inetd(int *sock_in, int *sock_out) +{ + int fd; + + startup_pipe = -1; + if (rexeced_flag) { + close(REEXEC_CONFIG_PASS_FD); + *sock_in = *sock_out = dup(STDIN_FILENO); + if (!debug_flag) { + startup_pipe = dup(REEXEC_STARTUP_PIPE_FD); + close(REEXEC_STARTUP_PIPE_FD); + } + } else { + *sock_in = dup(STDIN_FILENO); + *sock_out = dup(STDOUT_FILENO); + } + /* + * We intentionally do not close the descriptors 0, 1, and 2 + * as our code for setting the descriptors won't work if + * ttyfd happens to be one of those. + */ + if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + if (fd > STDOUT_FILENO) + close(fd); + } + debug("inetd sockets after dupping: %d, %d", *sock_in, *sock_out); +} + +/* + * Listen for TCP connections + */ +static void +server_listen(void) +{ + int ret, listen_sock, on = 1; + struct addrinfo *ai; + char ntop[NI_MAXHOST], strport[NI_MAXSERV]; + int socksize; + int socksizelen = sizeof(int); + + for (ai = options.listen_addrs; ai; ai = ai->ai_next) { + if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) + continue; + if (num_listen_socks >= MAX_LISTEN_SOCKS) + fatal("Too many listen sockets. " + "Enlarge MAX_LISTEN_SOCKS"); + if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, + ntop, sizeof(ntop), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { + error("getnameinfo failed: %.100s", + (ret != EAI_SYSTEM) ? gai_strerror(ret) : + strerror(errno)); + continue; + } + /* Create socket for listening. */ + listen_sock = socket(ai->ai_family, ai->ai_socktype, + ai->ai_protocol); + if (listen_sock < 0) { + /* kernel may not support ipv6 */ + verbose("socket: %.100s", strerror(errno)); + continue; + } + if (set_nonblock(listen_sock) == -1) { + close(listen_sock); + continue; + } + /* + * Set socket options. + * Allow local port reuse in TIME_WAIT. + */ + if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, + &on, sizeof(on)) == -1) + error("setsockopt SO_REUSEADDR: %s", strerror(errno)); + + debug("Bind to port %s on %s.", strport, ntop); + + getsockopt(listen_sock, SOL_SOCKET, SO_RCVBUF, + &socksize, &socksizelen); + debug("Server TCP RWIN socket size: %d", socksize); + debug("HPN Buffer Size: %d", options.hpn_buffer_size); + + /* Bind the socket to the desired port. */ + if (bind(listen_sock, ai->ai_addr, ai->ai_addrlen) < 0) { + error("Bind to port %s on %s failed: %.200s.", + strport, ntop, strerror(errno)); + close(listen_sock); + continue; + } + listen_socks[num_listen_socks] = listen_sock; + num_listen_socks++; + + /* Start listening on the port. */ + if (listen(listen_sock, SSH_LISTEN_BACKLOG) < 0) + fatal("listen on [%s]:%s: %.100s", + ntop, strport, strerror(errno)); + logit("Server listening on %s port %s.", ntop, strport); + } + freeaddrinfo(options.listen_addrs); + + if (!num_listen_socks) + fatal("Cannot bind any address."); +} + +/* + * The main TCP accept loop. Note that, for the non-debug case, returns + * from this function are in a forked subprocess. + */ +static void +server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s) +{ + fd_set *fdset; + int i, j, ret, maxfd; + int key_used = 0, startups = 0; + int startup_p[2] = { -1 , -1 }; + struct sockaddr_storage from; + socklen_t fromlen; + pid_t pid; + + /* setup fd set for accept */ + fdset = NULL; + maxfd = 0; + for (i = 0; i < num_listen_socks; i++) + if (listen_socks[i] > maxfd) + maxfd = listen_socks[i]; + /* pipes connected to unauthenticated childs */ + startup_pipes = xcalloc(options.max_startups, sizeof(int)); + for (i = 0; i < options.max_startups; i++) + startup_pipes[i] = -1; + + /* + * Stay listening for connections until the system crashes or + * the daemon is killed with a signal. + */ + for (;;) { + if (received_sighup) + sighup_restart(); + if (fdset != NULL) + xfree(fdset); + fdset = (fd_set *)xcalloc(howmany(maxfd + 1, NFDBITS), + sizeof(fd_mask)); + + for (i = 0; i < num_listen_socks; i++) + FD_SET(listen_socks[i], fdset); + for (i = 0; i < options.max_startups; i++) + if (startup_pipes[i] != -1) + FD_SET(startup_pipes[i], fdset); + + /* Wait in select until there is a connection. */ + ret = select(maxfd+1, fdset, NULL, NULL, NULL); + if (ret < 0 && errno != EINTR) + error("select: %.100s", strerror(errno)); + if (received_sigterm) { + logit("Received signal %d; terminating.", + (int) received_sigterm); + close_listen_socks(); + unlink(options.pid_file); + exit(255); + } + if (key_used && key_do_regen) { + generate_ephemeral_server_key(); + key_used = 0; + key_do_regen = 0; + } + if (ret < 0) + continue; + + for (i = 0; i < options.max_startups; i++) + if (startup_pipes[i] != -1 && + FD_ISSET(startup_pipes[i], fdset)) { + /* + * the read end of the pipe is ready + * if the child has closed the pipe + * after successful authentication + * or if the child has died + */ + close(startup_pipes[i]); + startup_pipes[i] = -1; + startups--; + } + for (i = 0; i < num_listen_socks; i++) { + if (!FD_ISSET(listen_socks[i], fdset)) + continue; + fromlen = sizeof(from); + *newsock = accept(listen_socks[i], + (struct sockaddr *)&from, &fromlen); + if (*newsock < 0) { + if (errno != EINTR && errno != EWOULDBLOCK) + error("accept: %.100s", strerror(errno)); + continue; + } + if (unset_nonblock(*newsock) == -1) { + close(*newsock); + continue; + } + if (drop_connection(startups) == 1) { + debug("drop connection #%d", startups); + close(*newsock); + continue; + } + if (pipe(startup_p) == -1) { + close(*newsock); + continue; + } + + if (rexec_flag && socketpair(AF_UNIX, + SOCK_STREAM, 0, config_s) == -1) { + error("reexec socketpair: %s", + strerror(errno)); + close(*newsock); + close(startup_p[0]); + close(startup_p[1]); + continue; + } + + for (j = 0; j < options.max_startups; j++) + if (startup_pipes[j] == -1) { + startup_pipes[j] = startup_p[0]; + if (maxfd < startup_p[0]) + maxfd = startup_p[0]; + startups++; + break; + } + + /* + * Got connection. Fork a child to handle it, unless + * we are in debugging mode. + */ + if (debug_flag) { + /* + * In debugging mode. Close the listening + * socket, and start processing the + * connection without forking. + */ + debug("Server will not fork when running in debugging mode."); + close_listen_socks(); + *sock_in = *newsock; + *sock_out = *newsock; + close(startup_p[0]); + close(startup_p[1]); + startup_pipe = -1; + pid = getpid(); + if (rexec_flag) { + send_rexec_state(config_s[0], + &cfg); + close(config_s[0]); + } + break; + } + + /* + * Normal production daemon. Fork, and have + * the child process the connection. The + * parent continues listening. + */ + platform_pre_fork(); + if ((pid = fork()) == 0) { + /* + * Child. Close the listening and + * max_startup sockets. Start using + * the accepted socket. Reinitialize + * logging (since our pid has changed). + * We break out of the loop to handle + * the connection. + */ + platform_post_fork_child(); + startup_pipe = startup_p[1]; + close_startup_pipes(); + close_listen_socks(); + *sock_in = *newsock; + *sock_out = *newsock; + log_init(__progname, + options.log_level, + options.log_facility, + log_stderr); + if (rexec_flag) + close(config_s[0]); + break; + } + + /* Parent. Stay in the loop. */ + platform_post_fork_parent(pid); + if (pid < 0) + error("fork: %.100s", strerror(errno)); + else + debug("Forked child %ld.", (long)pid); + + close(startup_p[1]); + + if (rexec_flag) { + send_rexec_state(config_s[0], &cfg); + close(config_s[0]); + close(config_s[1]); + } + + /* + * Mark that the key has been used (it + * was "given" to the child). + */ + if ((options.protocol & SSH_PROTO_1) && + key_used == 0) { + /* Schedule server key regeneration alarm. */ + signal(SIGALRM, key_regeneration_alarm); + alarm(options.key_regeneration_time); + key_used = 1; + } + + close(*newsock); + + /* + * Ensure that our random state differs + * from that of the child + */ + arc4random_stir(); + } + + /* child process check (or debug mode) */ + if (num_listen_socks < 0) + break; + } +} + + /* * Main program for the daemon. */ @@ -878,25 +1238,14 @@ main(int ac, char **av) { extern char *optarg; extern int optind; - int opt, j, i, fdsetsz, on = 1; + int opt, i, on = 1; int sock_in = -1, sock_out = -1, newsock = -1; - pid_t pid; - socklen_t fromlen; - fd_set *fdset; - struct sockaddr_storage from; const char *remote_ip; int remote_port; - FILE *f; - struct addrinfo *ai; - char ntop[NI_MAXHOST], strport[NI_MAXSERV]; char *line; - int listen_sock, maxfd; - int startup_p[2] = { -1 , -1 }, config_s[2] = { -1 , -1 }; - int startups = 0; + int config_s[2] = { -1 , -1 }; Key *key; Authctxt *authctxt; - int ret, key_used = 0; - Buffer cfg; #ifdef HAVE_SECUREWARE (void)set_auth_parameters(ac, av); @@ -909,7 +1258,7 @@ main(int ac, char **av) /* Save argv. Duplicate so setproctitle emulation doesn't clobber it */ saved_argc = ac; rexec_argc = ac; - saved_argv = xmalloc(sizeof(*saved_argv) * (ac + 1)); + saved_argv = xcalloc(ac + 1, sizeof(*saved_argv)); for (i = 0; i < ac; i++) saved_argv[i] = xstrdup(av[i]); saved_argv[i] = NULL; @@ -971,7 +1320,8 @@ main(int ac, char **av) options.log_level = SYSLOG_LEVEL_QUIET; break; case 'b': - options.server_key_bits = atoi(optarg); + options.server_key_bits = (int)strtonum(optarg, 256, + 32768, NULL); break; case 'p': options.ports_from_cmdline = 1; @@ -1008,7 +1358,7 @@ main(int ac, char **av) test_flag = 1; break; case 'u': - utmp_len = atoi(optarg); + utmp_len = (u_int)strtonum(optarg, 0, MAXHOSTNAMELEN+1, NULL); if (utmp_len > MAXHOSTNAMELEN) { fprintf(stderr, "Invalid utmp length.\n"); exit(1); @@ -1017,7 +1367,7 @@ main(int ac, char **av) case 'o': line = xstrdup(optarg); if (process_server_config_line(&options, line, - "command-line", 0) != 0) + "command-line", 0, NULL, NULL, NULL, NULL) != 0) exit(1); xfree(line); break; @@ -1075,11 +1425,8 @@ main(int ac, char **av) else load_server_config(config_file_name, &cfg); - parse_server_config(&options, - rexeced_flag ? "rexec" : config_file_name, &cfg); - - if (!rexec_flag) - buffer_free(&cfg); + parse_server_config(&options, rexeced_flag ? "rexec" : config_file_name, + &cfg, NULL, NULL, NULL); seed_rng(); @@ -1097,8 +1444,21 @@ main(int ac, char **av) debug("sshd version %.100s", SSH_RELEASE); + /* Store privilege separation user for later use if required. */ + if ((privsep_pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) { + if (use_privsep || options.kerberos_authentication) + fatal("Privilege separation user %s does not exist", + SSH_PRIVSEP_USER); + } else { + memset(privsep_pw->pw_passwd, 0, strlen(privsep_pw->pw_passwd)); + privsep_pw = pwcopy(privsep_pw); + xfree(privsep_pw->pw_passwd); + privsep_pw->pw_passwd = xstrdup("*"); + } + endpwent(); + /* load private host keys */ - sensitive_data.host_keys = xmalloc(options.num_host_key_files * + sensitive_data.host_keys = xcalloc(options.num_host_key_files, sizeof(Key *)); for (i = 0; i < options.num_host_key_files; i++) sensitive_data.host_keys[i] = NULL; @@ -1167,12 +1527,8 @@ main(int ac, char **av) } if (use_privsep) { - struct passwd *pw; struct stat st; - if ((pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) - fatal("Privilege separation user %s does not exist", - SSH_PRIVSEP_USER); if ((stat(_PATH_PRIVSEP_CHROOT_DIR, &st) == -1) || (S_ISDIR(st.st_mode) == 0)) fatal("Missing privilege separation directory: %s", @@ -1204,7 +1560,7 @@ main(int ac, char **av) debug("setgroups() failed: %.200s", strerror(errno)); if (rexec_flag) { - rexec_argv = xmalloc(sizeof(char *) * (rexec_argc + 2)); + rexec_argv = xcalloc(rexec_argc + 2, sizeof(char *)); for (i = 0; i < rexec_argc; i++) { debug("rexec_argv[%d]='%s'", i, saved_argv[i]); rexec_argv[i] = saved_argv[i]; @@ -1252,121 +1608,31 @@ main(int ac, char **av) /* ignore SIGPIPE */ signal(SIGPIPE, SIG_IGN); - /* Start listening for a socket, unless started from inetd. */ + /* Get a connection, either from inetd or a listening TCP socket */ if (inetd_flag) { - int fd; + server_accept_inetd(&sock_in, &sock_out); - startup_pipe = -1; - if (rexeced_flag) { - close(REEXEC_CONFIG_PASS_FD); - sock_in = sock_out = dup(STDIN_FILENO); - if (!debug_flag) { - startup_pipe = dup(REEXEC_STARTUP_PIPE_FD); - close(REEXEC_STARTUP_PIPE_FD); - } - } else { - sock_in = dup(STDIN_FILENO); - sock_out = dup(STDOUT_FILENO); - } - /* - * We intentionally do not close the descriptors 0, 1, and 2 - * as our code for setting the descriptors won't work if - * ttyfd happens to be one of those. - */ - if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - if (fd > STDOUT_FILENO) - close(fd); - } - debug("inetd sockets after dupping: %d, %d", sock_in, sock_out); if ((options.protocol & SSH_PROTO_1) && sensitive_data.server_key == NULL) generate_ephemeral_server_key(); } else { - for (ai = options.listen_addrs; ai; ai = ai->ai_next) { - if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) - continue; - if (num_listen_socks >= MAX_LISTEN_SOCKS) - fatal("Too many listen sockets. " - "Enlarge MAX_LISTEN_SOCKS"); - if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, - ntop, sizeof(ntop), strport, sizeof(strport), - NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { - error("getnameinfo failed: %.100s", - (ret != EAI_SYSTEM) ? gai_strerror(ret) : - strerror(errno)); - continue; - } - /* Create socket for listening. */ - listen_sock = socket(ai->ai_family, ai->ai_socktype, - ai->ai_protocol); - if (listen_sock < 0) { - /* kernel may not support ipv6 */ - verbose("socket: %.100s", strerror(errno)); - continue; - } - if (set_nonblock(listen_sock) == -1) { - close(listen_sock); - continue; - } - /* - * Set socket options. - * Allow local port reuse in TIME_WAIT. - */ - if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, - &on, sizeof(on)) == -1) - error("setsockopt SO_REUSEADDR: %s", strerror(errno)); - - debug("Bind to port %s on %s.", strport, ntop); - - /* Bind the socket to the desired port. */ - if (bind(listen_sock, ai->ai_addr, ai->ai_addrlen) < 0) { - if (!ai->ai_next) - error("Bind to port %s on %s failed: %.200s.", - strport, ntop, strerror(errno)); - close(listen_sock); - continue; - } - listen_socks[num_listen_socks] = listen_sock; - num_listen_socks++; - - /* Start listening on the port. */ - logit("Server listening on %s port %s.", ntop, strport); - if (listen(listen_sock, SSH_LISTEN_BACKLOG) < 0) - fatal("listen: %.100s", strerror(errno)); - - } - freeaddrinfo(options.listen_addrs); - - if (!num_listen_socks) - fatal("Cannot bind any address."); + server_listen(); if (options.protocol & SSH_PROTO_1) generate_ephemeral_server_key(); - /* - * Arrange to restart on SIGHUP. The handler needs - * listen_sock. - */ signal(SIGHUP, sighup_handler); - + signal(SIGCHLD, main_sigchld_handler); signal(SIGTERM, sigterm_handler); signal(SIGQUIT, sigterm_handler); - /* Arrange SIGCHLD to be caught. */ - signal(SIGCHLD, main_sigchld_handler); - - /* Write out the pid file after the sigterm handler is setup */ + /* + * Write out the pid file after the sigterm handler + * is setup and the listen sockets are bound + */ if (!debug_flag) { - /* - * Record our pid in /var/run/sshd.pid to make it - * easier to kill the correct sshd. We don't want to - * do this before the bind above because the bind will - * fail if there already is a daemon, and this will - * overwrite any old pid in the file. - */ - f = fopen(options.pid_file, "wb"); + FILE *f = fopen(options.pid_file, "w"); + if (f == NULL) { error("Couldn't create pid file \"%s\": %s", options.pid_file, strerror(errno)); @@ -1376,194 +1642,9 @@ main(int ac, char **av) } } - /* setup fd set for listen */ - fdset = NULL; - maxfd = 0; - for (i = 0; i < num_listen_socks; i++) - if (listen_socks[i] > maxfd) - maxfd = listen_socks[i]; - /* pipes connected to unauthenticated childs */ - startup_pipes = xmalloc(options.max_startups * sizeof(int)); - for (i = 0; i < options.max_startups; i++) - startup_pipes[i] = -1; - - /* - * Stay listening for connections until the system crashes or - * the daemon is killed with a signal. - */ - for (;;) { - if (received_sighup) - sighup_restart(); - if (fdset != NULL) - xfree(fdset); - fdsetsz = howmany(maxfd+1, NFDBITS) * sizeof(fd_mask); - fdset = (fd_set *)xmalloc(fdsetsz); - memset(fdset, 0, fdsetsz); - - for (i = 0; i < num_listen_socks; i++) - FD_SET(listen_socks[i], fdset); - for (i = 0; i < options.max_startups; i++) - if (startup_pipes[i] != -1) - FD_SET(startup_pipes[i], fdset); - - /* Wait in select until there is a connection. */ - ret = select(maxfd+1, fdset, NULL, NULL, NULL); - if (ret < 0 && errno != EINTR) - error("select: %.100s", strerror(errno)); - if (received_sigterm) { - logit("Received signal %d; terminating.", - (int) received_sigterm); - close_listen_socks(); - unlink(options.pid_file); - exit(255); - } - if (key_used && key_do_regen) { - generate_ephemeral_server_key(); - key_used = 0; - key_do_regen = 0; - } - if (ret < 0) - continue; - - for (i = 0; i < options.max_startups; i++) - if (startup_pipes[i] != -1 && - FD_ISSET(startup_pipes[i], fdset)) { - /* - * the read end of the pipe is ready - * if the child has closed the pipe - * after successful authentication - * or if the child has died - */ - close(startup_pipes[i]); - startup_pipes[i] = -1; - startups--; - } - for (i = 0; i < num_listen_socks; i++) { - if (!FD_ISSET(listen_socks[i], fdset)) - continue; - fromlen = sizeof(from); - newsock = accept(listen_socks[i], (struct sockaddr *)&from, - &fromlen); - if (newsock < 0) { - if (errno != EINTR && errno != EWOULDBLOCK) - error("accept: %.100s", strerror(errno)); - continue; - } - if (unset_nonblock(newsock) == -1) { - close(newsock); - continue; - } - if (drop_connection(startups) == 1) { - debug("drop connection #%d", startups); - close(newsock); - continue; - } - if (pipe(startup_p) == -1) { - close(newsock); - continue; - } - - if (rexec_flag && socketpair(AF_UNIX, - SOCK_STREAM, 0, config_s) == -1) { - error("reexec socketpair: %s", - strerror(errno)); - close(newsock); - close(startup_p[0]); - close(startup_p[1]); - continue; - } - - for (j = 0; j < options.max_startups; j++) - if (startup_pipes[j] == -1) { - startup_pipes[j] = startup_p[0]; - if (maxfd < startup_p[0]) - maxfd = startup_p[0]; - startups++; - break; - } - - /* - * Got connection. Fork a child to handle it, unless - * we are in debugging mode. - */ - if (debug_flag) { - /* - * In debugging mode. Close the listening - * socket, and start processing the - * connection without forking. - */ - debug("Server will not fork when running in debugging mode."); - close_listen_socks(); - sock_in = newsock; - sock_out = newsock; - close(startup_p[0]); - close(startup_p[1]); - startup_pipe = -1; - pid = getpid(); - if (rexec_flag) { - send_rexec_state(config_s[0], - &cfg); - close(config_s[0]); - } - break; - } else { - /* - * Normal production daemon. Fork, and have - * the child process the connection. The - * parent continues listening. - */ - if ((pid = fork()) == 0) { - /* - * Child. Close the listening and max_startup - * sockets. Start using the accepted socket. - * Reinitialize logging (since our pid has - * changed). We break out of the loop to handle - * the connection. - */ - startup_pipe = startup_p[1]; - close_startup_pipes(); - close_listen_socks(); - sock_in = newsock; - sock_out = newsock; - log_init(__progname, options.log_level, options.log_facility, log_stderr); - if (rexec_flag) - close(config_s[0]); - break; - } - } - - /* Parent. Stay in the loop. */ - if (pid < 0) - error("fork: %.100s", strerror(errno)); - else - debug("Forked child %ld.", (long)pid); - - close(startup_p[1]); - - if (rexec_flag) { - send_rexec_state(config_s[0], &cfg); - close(config_s[0]); - close(config_s[1]); - } - - /* Mark that the key has been used (it was "given" to the child). */ - if ((options.protocol & SSH_PROTO_1) && - key_used == 0) { - /* Schedule server key regeneration alarm. */ - signal(SIGALRM, key_regeneration_alarm); - alarm(options.key_regeneration_time); - key_used = 1; - } - - arc4random_stir(); - - /* Close the new socket (the child is now taking care of it). */ - close(newsock); - } - /* child process check (or debug mode) */ - if (num_listen_socks < 0) - break; - } + /* Accept a connection and return in a forked child */ + server_accept_loop(&sock_in, &sock_out, + &newsock, config_s); } /* This is the child processing a new connection. */ @@ -1658,7 +1739,13 @@ main(int ac, char **av) * We use get_canonical_hostname with usedns = 0 instead of * get_remote_ipaddr here so IP options will be checked. */ - remote_ip = get_canonical_hostname(0); + (void) get_canonical_hostname(0); + /* + * The rest of the code depends on the fact that + * get_remote_ipaddr() caches the remote ip, even if + * the socket goes away. + */ + remote_ip = get_remote_ipaddr(); #ifdef SSH_AUDIT_EVENTS audit_connection_from(remote_ip, remote_port); @@ -1761,8 +1848,7 @@ main(int ac, char **av) packet_set_nonblocking(); /* allocate authentication context */ - authctxt = xmalloc(sizeof(*authctxt)); - memset(authctxt, 0, sizeof(*authctxt)); + authctxt = xcalloc(1, sizeof(*authctxt)); authctxt->loginmsg = &loginmsg; @@ -1801,6 +1887,7 @@ main(int ac, char **av) */ alarm(0); signal(SIGALRM, SIG_DFL); + authctxt->authenticated = 1; if (startup_pipe != -1) { close(startup_pipe); startup_pipe = -1; @@ -1853,11 +1940,14 @@ ssh1_session_key(BIGNUM *session_key_int) { int rsafail = 0; - if (BN_cmp(sensitive_data.server_key->rsa->n, sensitive_data.ssh1_host_key->rsa->n) > 0) { + if (BN_cmp(sensitive_data.server_key->rsa->n, + sensitive_data.ssh1_host_key->rsa->n) > 0) { /* Server key has bigger modulus. */ if (BN_num_bits(sensitive_data.server_key->rsa->n) < - BN_num_bits(sensitive_data.ssh1_host_key->rsa->n) + SSH_KEY_BITS_RESERVED) { - fatal("do_connection: %s: server_key %d < host_key %d + SSH_KEY_BITS_RESERVED %d", + BN_num_bits(sensitive_data.ssh1_host_key->rsa->n) + + SSH_KEY_BITS_RESERVED) { + fatal("do_connection: %s: " + "server_key %d < host_key %d + SSH_KEY_BITS_RESERVED %d", get_remote_ipaddr(), BN_num_bits(sensitive_data.server_key->rsa->n), BN_num_bits(sensitive_data.ssh1_host_key->rsa->n), @@ -1872,8 +1962,10 @@ ssh1_session_key(BIGNUM *session_key_int) } else { /* Host key has bigger modulus (or they are equal). */ if (BN_num_bits(sensitive_data.ssh1_host_key->rsa->n) < - BN_num_bits(sensitive_data.server_key->rsa->n) + SSH_KEY_BITS_RESERVED) { - fatal("do_connection: %s: host_key %d < server_key %d + SSH_KEY_BITS_RESERVED %d", + BN_num_bits(sensitive_data.server_key->rsa->n) + + SSH_KEY_BITS_RESERVED) { + fatal("do_connection: %s: " + "host_key %d < server_key %d + SSH_KEY_BITS_RESERVED %d", get_remote_ipaddr(), BN_num_bits(sensitive_data.ssh1_host_key->rsa->n), BN_num_bits(sensitive_data.server_key->rsa->n), @@ -1998,10 +2090,10 @@ do_ssh1_kex(void) * key is in the highest bits. */ if (!rsafail) { - BN_mask_bits(session_key_int, sizeof(session_key) * 8); + (void) BN_mask_bits(session_key_int, sizeof(session_key) * 8); len = BN_num_bytes(session_key_int); if (len < 0 || (u_int)len > sizeof(session_key)) { - error("do_connection: bad session key len from %s: " + error("do_ssh1_kex: bad session key len from %s: " "session_key_int %d > sizeof(session_key) %lu", get_remote_ipaddr(), len, (u_long)sizeof(session_key)); rsafail++; @@ -2098,11 +2190,9 @@ do_ssh2_kex(void) myproposal[PROPOSAL_COMP_ALGS_CTOS] = myproposal[PROPOSAL_COMP_ALGS_STOC] = "none,zlib@openssh.com"; } - + myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); - /* start key exchange */ - #ifdef GSSAPI { char *orig; @@ -2111,8 +2201,8 @@ do_ssh2_kex(void) orig = myproposal[PROPOSAL_KEX_ALGS]; /* - * If we don't have a host key, then there's no point advertising - * the other key exchange algorithms + * If we don't have a host key, then there's no point advertising + * the other key exchange algorithms */ if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0) @@ -2123,15 +2213,13 @@ do_ssh2_kex(void) else gss = NULL; - if (gss && orig) { - int len = strlen(orig) + strlen(gss) + 2; - newstr = xmalloc(len); - snprintf(newstr, len, "%s,%s", gss, orig); - } else if (gss) { + if (gss && orig) + xasprintf(&newstr, "%s,%s", gss, orig); + else if (gss) newstr = gss; - } else if (orig) { + else if (orig) newstr = orig; - } + /* * If we've got GSSAPI mechanisms, then we've got the 'null' host * key alg, but we can't tell people about it unless its the only @@ -2147,18 +2235,21 @@ do_ssh2_kex(void) } #endif - /* start key exchange */ - kex = kex_setup(myproposal); - kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; + /* start key exchange */ + /* start key exchange */ + kex = kex_setup(myproposal); + kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; + kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; #ifdef GSSAPI kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; #endif - kex->server = 1; - kex->client_version_string=client_version_string; - kex->server_version_string=server_version_string; + kex->server = 1; + kex->client_version_string=client_version_string; + kex->server_version_string=server_version_string; kex->load_host_key=&get_hostkey_by_type; kex->host_key_index=&get_hostkey_index; diff --git a/openssh/sshd_config b/openssh/sshd_config index 833cbbc..6bc88ae 100644 --- a/openssh/sshd_config +++ b/openssh/sshd_config @@ -1,4 +1,4 @@ -# $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $ +# $OpenBSD: sshd_config,v 1.74 2006/07/19 13:07:10 dtucker Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. @@ -73,16 +73,19 @@ Protocol 2 # GSSAPI options #GSSAPIAuthentication yes #GSSAPICleanupCredentials yes +#GSSAPIStrictAcceptorCheck yes +#GSSAPIKeyExchange yes # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication mechanism. -# Depending on your PAM configuration, this may bypass the setting of -# PasswordAuthentication, PermitEmptyPasswords, and -# "PermitRootLogin without-password". If you just want the PAM account and -# session checks to run without PAM authentication, then enable this but set -# ChallengeResponseAuthentication=no -UsePAM yes +# be allowed through the ChallengeResponseAuthentication and +# PasswordAuthentication. Depending on your PAM configuration, +# PAM authentication via ChallengeResponseAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# PAM authentication, then enable this but set PasswordAuthentication +# and ChallengeResponseAuthentication to 'no'. +#UsePAM yes #AllowTcpForwarding yes #GatewayPorts no @@ -103,16 +106,16 @@ X11Forwarding yes #MaxStartups 10 #PermitTunnel no -# override default of no subsystems -Subsystem sftp /usr/libexec/sftp-server - # no default banner path #Banner /some/path +# override default of no subsystems +Subsystem sftp /usr/libexec/sftp-server + # the following are HPN related configuration options # tcp receive buffer polling. enable in autotuning kernels #TcpRcvBufPoll no - + # allow the use of the none cipher #NoneEnabled no @@ -122,3 +125,9 @@ Subsystem sftp /usr/libexec/sftp-server # buffer size for hpn to non-hn connections #HPNBufferSize 2048 + +# Example of overriding settings on a per-user basis +#Match User anoncvs +# X11Forwarding no +# AllowTcpForwarding no +# ForceCommand cvs server diff --git a/openssh/sshd_config.5 b/openssh/sshd_config.5 index 31e112f..c90bac7 100644 --- a/openssh/sshd_config.5 +++ b/openssh/sshd_config.5 @@ -34,7 +34,7 @@ .\" (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.48 2006/01/02 17:09:49 jmc Exp $ +.\" $OpenBSD: sshd_config.5,v 1.70 2006/08/21 08:14:01 dtucker Exp $ .Dd September 25, 1999 .Dt SSHD_CONFIG 5 .Os @@ -46,7 +46,7 @@ .It Pa /etc/ssh/sshd_config .El .Sh DESCRIPTION -.Nm sshd +.Xr sshd 8 reads configuration data from .Pa /etc/ssh/sshd_config (or the file specified with @@ -56,6 +56,9 @@ The file contains keyword-argument pairs, one per line. Lines starting with .Ql # and empty lines are interpreted as comments. +Arguments may optionally be enclosed in double quotes +.Pq \&" +in order to represent arguments containing spaces. .Pp The possible keywords and their meanings are as follows (note that @@ -72,7 +75,7 @@ in for how to configure the client. Note that environment passing is only supported for protocol 2. Variables are specified by name, which may contain the wildcard characters -.Ql \&* +.Ql * and .Ql \&? . Multiple environment variables may be separated by whitespace or spread @@ -85,11 +88,11 @@ For this reason, care should be taken in the use of this directive. The default is not to accept any environment variables. .It Cm AddressFamily Specifies which address family should be used by -.Nm sshd . +.Xr sshd 8 . Valid arguments are .Dq any , .Dq inet -(use IPv4 only) or +(use IPv4 only), or .Dq inet6 (use IPv6 only). The default is @@ -99,13 +102,20 @@ This keyword can be followed by a list of group name patterns, separated by spaces. If specified, login is allowed only for users whose primary group or supplementary group list matches one of the patterns. -.Ql \&* -and -.Ql \&? -can be used as -wildcards in the patterns. Only group names are valid; a numerical group ID is not recognized. By default, login is allowed for all groups. +The allow/deny directives are processed in the following order: +.Cm DenyUsers , +.Cm AllowUsers , +.Cm DenyGroups , +and finally +.Cm AllowGroups . +.Pp +See +.Sx PATTERNS +in +.Xr ssh_config 5 +for more information on patterns. .It Cm AllowTcpForwarding Specifies whether TCP forwarding is permitted. The default is @@ -118,24 +128,31 @@ This keyword can be followed by a list of user name patterns, separated by spaces. If specified, login is allowed only for user names that match one of the patterns. -.Ql \&* -and -.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. If the pattern takes the form USER@HOST then USER and HOST are separately checked, restricting logins to particular users from particular hosts. +The allow/deny directives are processed in the following order: +.Cm DenyUsers , +.Cm AllowUsers , +.Cm DenyGroups , +and finally +.Cm AllowGroups . +.Pp +See +.Sx PATTERNS +in +.Xr ssh_config 5 +for more information on patterns. .It Cm AuthorizedKeysFile 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. +setup. The following tokens are defined: %% is replaced by a literal '%', -%h is replaced by the home directory of the user being authenticated and +%h is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user. After expansion, .Cm AuthorizedKeysFile @@ -151,7 +168,7 @@ authentication is allowed. This option is only available for protocol version 2. By default, no banner is displayed. .It Cm ChallengeResponseAuthentication -Specifies whether challenge response authentication is allowed. +Specifies whether challenge-response authentication is allowed. All authentication styles from .Xr login.conf 5 are supported. @@ -174,20 +191,19 @@ The supported ciphers are .Dq blowfish-cbc , and .Dq cast128-cbc . -The default is -.Bd -literal - ``aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128, - arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr, - aes192-ctr,aes256-ctr'' +The default is: +.Bd -literal -offset 3n +aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128, +arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr, +aes192-ctr,aes256-ctr .Ed .It Cm ClientAliveCountMax Sets the number of client alive messages (see below) which may be sent without -.Nm sshd +.Xr sshd 8 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. +sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from .Cm TCPKeepAlive @@ -205,12 +221,13 @@ If .Cm ClientAliveInterval (see below) is set to 15, and .Cm ClientAliveCountMax -is left at the default, unresponsive ssh clients +is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. +This option applies to protocol version 2 only. .It Cm ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, -.Nm sshd +.Xr sshd 8 will send a message through the encrypted channel to request a response from the client. The default @@ -231,36 +248,62 @@ This keyword can be followed by a list of group name patterns, separated by spaces. Login is disallowed for users whose primary group or supplementary group list matches one of the patterns. -.Ql \&* -and -.Ql \&? -can be used as -wildcards in the patterns. Only group names are valid; a numerical group ID is not recognized. By default, login is allowed for all groups. +The allow/deny directives are processed in the following order: +.Cm DenyUsers , +.Cm AllowUsers , +.Cm DenyGroups , +and finally +.Cm AllowGroups . +.Pp +See +.Sx PATTERNS +in +.Xr ssh_config 5 +for more information on patterns. .It Cm DenyUsers This keyword can be followed by a list of user name patterns, separated by spaces. Login is disallowed for user names that match one of the patterns. -.Ql \&* -and -.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. If the pattern takes the form USER@HOST then USER and HOST are separately checked, restricting logins to particular users from particular hosts. +The allow/deny directives are processed in the following order: +.Cm DenyUsers , +.Cm AllowUsers , +.Cm DenyGroups , +and finally +.Cm AllowGroups . +.Pp +See +.Sx PATTERNS +in +.Xr ssh_config 5 +for more information on patterns. +.It Cm ForceCommand +Forces the execution of the command specified by +.Cm ForceCommand , +ignoring any command supplied by the client. +The command is invoked by using the user's login shell with the -c option. +This applies to shell, command, or subsystem execution. +It is most useful inside a +.Cm Match +block. +The command originally supplied by the client is available in the +.Ev SSH_ORIGINAL_COMMAND +environment variable. .It Cm GatewayPorts Specifies whether remote hosts are allowed to connect to ports forwarded for the client. By default, -.Nm sshd +.Xr sshd 8 binds remote port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. .Cm GatewayPorts -can be used to specify that -.Nm sshd +can be used to specify that sshd should allow remote port forwardings to bind to non-loopback addresses, thus allowing other hosts to connect. The argument may be @@ -289,6 +332,34 @@ on logout. The default is .Dq yes . Note that this option applies to protocol version 2 only. +.It Cm GSSAPIStrictAcceptorCheck +Determines whether to be strict about the identity of the GSSAPI acceptor +a client authenticates against. If +.Dq yes +then the client must authenticate against the +.Pa host +service on the current hostname. If +.Dq no +then the client may authenticate against any service key stored in the +machine's default store. This facility is provided to assist with operation +on multi homed machines. +The default is +.Dq yes . +Note that this option applies only to protocol version 2 GSSAPI connections, +and setting it to +.Dq no +may only work with recent Kerberos GSSAPI libraries. +.It Cm GSSAPICredentialsPath +If specified, the delegated GSSAPI credential is stored in the +given path, overwriting any existing credentials. +Paths can be specified with syntax similar to the AuthorizedKeysFile +option (i.e., accepting %h and %u tokens). +When using this option, +setting 'GssapiCleanupCredentials no' is recommended, +so logging out of one session +doesn't remove the credentials in use by another session of +the same user. +Currently only implemented for the GSI mechanism. .It Cm GSIAllowLimitedProxy Specifies whether to accept limited proxy credentials for authentication. @@ -297,12 +368,29 @@ The default is .It Cm HostbasedAuthentication Specifies whether rhosts or /etc/hosts.equiv authentication together with successful public key client host authentication is allowed -(hostbased authentication). +(host-based authentication). This option is similar to .Cm RhostsRSAAuthentication and applies to protocol version 2 only. The default is .Dq no . +.It Cm HostbasedUsesNameFromPacketOnly +Specifies whether or not the server will attempt to perform a reverse +name lookup when matching the name in the +.Pa ~/.shosts , +.Pa ~/.rhosts , +and +.Pa /etc/hosts.equiv +files during +.Cm HostbasedAuthentication . +A setting of +.Dq yes +means that +.Xr sshd 8 +uses the name supplied by the client rather than +attempting to resolve the name from the TCP connection itself. +The default is +.Dq no . .It Cm HostKey Specifies a file containing a private host key used by SSH. @@ -314,7 +402,7 @@ and .Pa /etc/ssh/ssh_host_dsa_key for protocol version 2. Note that -.Nm sshd +.Xr sshd 8 will refuse to use a file if it is group/world-accessible. It is possible to have multiple host key files. .Dq rsa1 @@ -341,7 +429,7 @@ The default is .Dq yes . .It Cm IgnoreUserKnownHosts Specifies whether -.Nm sshd +.Xr sshd 8 should ignore the user's .Pa ~/.ssh/known_hosts during @@ -356,24 +444,24 @@ Specifies whether the password provided by the user for 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 +The default is .Dq no . .It Cm KerberosGetAFSToken If AFS is active and the user has a Kerberos 5 TGT, attempt to acquire an AFS token before accessing the user's home directory. -Default is +The default is .Dq no . .It Cm KerberosOrLocalPasswd -If set then if password authentication through Kerberos fails then +If password authentication through Kerberos fails then the password will be validated via any additional local mechanism such as .Pa /etc/passwd . -Default is +The default is .Dq yes . .It Cm KerberosTicketCleanup Specifies whether to automatically destroy the user's ticket cache file on logout. -Default is +The default is .Dq yes . .It Cm KeyRegenerationInterval In protocol version 1, the ephemeral server key is automatically regenerated @@ -386,7 +474,7 @@ If the value is 0, the key is never regenerated. The default is 3600 (seconds). .It Cm ListenAddress Specifies the local addresses -.Nm sshd +.Xr sshd 8 should listen on. The following forms may be used: .Pp @@ -412,8 +500,7 @@ The following forms may be used: If .Ar port is not specified, -.Nm sshd -will listen on the address and all prior +sshd will listen on the address and all prior .Cm Port options specified. The default is to listen on all local addresses. @@ -422,7 +509,7 @@ Multiple options are permitted. Additionally, any .Cm Port -options must precede this option for non port qualified addresses. +options must precede this option for non-port qualified addresses. .It Cm LoginGraceTime The server disconnects after this time if the user has not successfully logged in. @@ -430,9 +517,9 @@ If the value is 0, there is no time limit. The default is 120 seconds. .It Cm LogLevel Gives the verbosity level that is used when logging messages from -.Nm sshd . +.Xr sshd 8 . The possible values are: -QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2 and DEBUG3. +QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of debugging output. @@ -442,8 +529,37 @@ Specifies the available MAC (message authentication code) algorithms. The MAC algorithm is used in protocol version 2 for data integrity protection. Multiple algorithms must be comma-separated. -The default is +The default is: .Dq hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 . +.It Cm Match +Introduces a conditional block. +If all of the criteria on the +.Cm Match +line are satisfied, the keywords on the following lines override those +set in the global section of the config file, until either another +.Cm Match +line or the end of the file. +The arguments to +.Cm Match +are one or more criteria-pattern pairs. +The available criteria are +.Cm User , +.Cm Group , +.Cm Host , +and +.Cm Address . +Only a subset of keywords may be used on the lines following a +.Cm Match +keyword. +Available keywords are +.Cm AllowTcpForwarding , +.Cm ForceCommand , +.Cm GatewayPorts , +.Cm PermitOpen , +.Cm X11DisplayOffset , +.Cm X11Forwarding , +and +.Cm X11UseLocalHost . .It Cm MaxAuthTries Specifies the maximum number of authentication attempts permitted per connection. @@ -452,8 +568,7 @@ additional failures are logged. The default is 6. .It Cm MaxStartups Specifies the maximum number of concurrent unauthenticated connections to the -.Nm sshd -daemon. +SSH daemon. Additional connections will be dropped until authentication succeeds or the .Cm LoginGraceTime expires for a connection. @@ -462,8 +577,8 @@ The default is 10. Alternatively, random early drop can be enabled by specifying the three colon separated values .Dq start:rate:full -(e.g., "10:30:60"). -.Nm sshd +(e.g. "10:30:60"). +.Xr sshd 8 will refuse connection attempts with a probability of .Dq rate/100 (30%) @@ -484,24 +599,51 @@ When password authentication is allowed, it specifies whether the server allows login to accounts with empty password strings. The default is .Dq no . +.It Cm PermitOpen +Specifies the destinations to which TCP port forwarding is permitted. +The forwarding specification must be one of the following forms: +.Pp +.Bl -item -offset indent -compact +.It +.Cm PermitOpen +.Sm off +.Ar host : port +.Sm on +.It +.Cm PermitOpen +.Sm off +.Ar IPv4_addr : port +.Sm on +.It +.Cm PermitOpen +.Sm off +.Ar \&[ IPv6_addr \&] : port +.Sm on +.El +.Pp +Multiple forwards may be specified by separating them with whitespace. +An argument of +.Dq any +can be used to remove all restrictions and permit any forwarding requests. +By default all port forwarding requests are permitted. .It Cm PermitRootLogin Specifies whether root can log in using .Xr ssh 1 . The argument must be .Dq yes , .Dq without-password , -.Dq forced-commands-only +.Dq forced-commands-only , or .Dq no . The default is .Dq yes . .Pp If this option is set to -.Dq without-password +.Dq without-password , password authentication is disabled for root. .Pp If this option is set to -.Dq forced-commands-only +.Dq forced-commands-only , root login with public key authentication will be allowed, but only if the .Ar command @@ -511,7 +653,7 @@ normally not allowed). All other authentication methods are disabled for root. .Pp If this option is set to -.Dq no +.Dq no , root is not allowed to log in. .It Cm PermitTunnel Specifies whether @@ -519,10 +661,17 @@ Specifies whether device forwarding is allowed. The argument must be .Dq yes , -.Dq point-to-point , +.Dq point-to-point +(layer 3), .Dq ethernet -or +(layer 2), or .Dq no . +Specifying +.Dq yes +permits both +.Dq point-to-point +and +.Dq ethernet . The default is .Dq no . .It Cm PermitUserEnvironment @@ -533,7 +682,7 @@ and options in .Pa ~/.ssh/authorized_keys are processed by -.Nm sshd . +.Xr sshd 8 . The default is .Dq no . Enabling environment processing may enable users to bypass access @@ -541,13 +690,12 @@ restrictions in some configurations using mechanisms such as .Ev LD_PRELOAD . .It Cm PidFile Specifies the file that contains the process ID of the -.Nm sshd -daemon. +SSH daemon. The default is .Pa /var/run/sshd.pid . .It Cm Port Specifies the port number that -.Nm sshd +.Xr sshd 8 listens on. The default is 22. Multiple options of this type are permitted. @@ -555,14 +703,14 @@ See also .Cm ListenAddress . .It Cm PrintLastLog Specifies whether -.Nm sshd +.Xr sshd 8 should print the date and time of the last user login when a user logs in interactively. The default is .Dq yes . .It Cm PrintMotd Specifies whether -.Nm sshd +.Xr sshd 8 should print .Pa /etc/motd when a user logs in interactively. @@ -573,12 +721,12 @@ The default is .Dq yes . .It Cm Protocol Specifies the protocol versions -.Nm sshd +.Xr sshd 8 supports. The possible values are -.Dq 1 +.Sq 1 and -.Dq 2 . +.Sq 2 . Multiple versions must be comma-separated. The default is .Dq 2,1 . @@ -610,7 +758,7 @@ Defines the number of bits in the ephemeral protocol version 1 server key. The minimum value is 512, and the default is 768. .It Cm StrictModes Specifies whether -.Nm sshd +.Xr sshd 8 should check file modes and ownership of the user's files and home directory before accepting login. This is normally desirable because novices sometimes accidentally leave their @@ -618,9 +766,9 @@ directory or files world-writable. The default is .Dq yes . .It Cm Subsystem -Configures an external subsystem (e.g., file transfer daemon). -Arguments should be a subsystem name and a command to execute upon subsystem -request. +Configures an external subsystem (e.g. file transfer daemon). +Arguments should be a subsystem name and a command (with optional arguments) +to execute upon subsystem request. The command .Xr sftp-server 8 implements the @@ -630,7 +778,7 @@ By default no subsystems are defined. Note that this option applies to protocol version 2 only. .It Cm SyslogFacility Gives the facility code that is used when logging messages from -.Nm sshd . +.Xr sshd 8 . The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is AUTH. @@ -657,7 +805,7 @@ To disable TCP keepalive messages, the value should be set to .Dq no . .It Cm UseDNS Specifies whether -.Nm sshd +.Xr sshd 8 should look up the remote host name and check that the resolved host name for the remote IP address maps back to the very same IP address. @@ -688,7 +836,10 @@ If set to .Dq yes this will enable PAM authentication using .Cm ChallengeResponseAuthentication -and PAM account and session module processing for all authentication types. +and +.Cm PasswordAuthentication +in addition to PAM account and session module processing for all +authentication types. .Pp Because PAM challenge-response authentication usually serves an equivalent role to password authentication, you should disable either @@ -705,7 +856,7 @@ The default is .Dq no . .It Cm UsePrivilegeSeparation Specifies whether -.Nm sshd +.Xr sshd 8 separates privileges by creating an unprivileged child process to deal with incoming network traffic. After successful authentication, another process will be created that has @@ -716,11 +867,9 @@ The default is .Dq yes . .It Cm X11DisplayOffset Specifies the first display number available for -.Nm sshd Ns 's +.Xr sshd 8 Ns 's X11 forwarding. -This prevents -.Nm sshd -from interfering with real X11 servers. +This prevents sshd from interfering with real X11 servers. The default is 10. .It Cm X11Forwarding Specifies whether X11 forwarding is permitted. @@ -733,14 +882,14 @@ The default is .Pp When X11 forwarding is enabled, there may be additional exposure to the server and to client displays if the -.Nm sshd +.Xr sshd 8 proxy display is configured to listen on the wildcard address (see .Cm X11UseLocalhost -below), however this is not the default. +below), though this is not the default. Additionally, the authentication spoofing and authentication data verification and substitution occur on the client side. The security risk of using X11 forwarding is that the client's X11 -display server may be exposed to attack when the ssh client requests +display server may be exposed to attack when the SSH client requests forwarding (see the warnings for .Cm ForwardX11 in @@ -758,12 +907,11 @@ X11 forwarding is automatically disabled if is enabled. .It Cm X11UseLocalhost Specifies whether -.Nm sshd +.Xr sshd 8 should bind the X11 forwarding server to the loopback address or to the wildcard address. By default, -.Nm sshd -binds the forwarding server to the loopback address and sets the +sshd binds the forwarding server to the loopback address and sets the hostname part of the .Ev DISPLAY environment variable to @@ -789,8 +937,8 @@ program. The default is .Pa /usr/X11R6/bin/xauth . .El -.Ss Time Formats -.Nm sshd +.Sh TIME FORMATS +.Xr sshd 8 command-line arguments and configuration file options that specify time may be expressed using a sequence of the form: .Sm off @@ -803,7 +951,7 @@ is a positive integer value and is one of the following: .Pp .Bl -tag -width Ds -compact -offset indent -.It Cm +.It Aq Cm none seconds .It Cm s | Cm S seconds @@ -834,7 +982,7 @@ Time format examples: .Bl -tag -width Ds .It Pa /etc/ssh/sshd_config Contains configuration data for -.Nm sshd . +.Xr sshd 8 . This file should be writable by root only, but it is recommended (though not necessary) that it be world-readable. .El diff --git a/openssh/sshlogin.c b/openssh/sshlogin.c index 15eb916..0059ff8 100644 --- a/openssh/sshlogin.c +++ b/openssh/sshlogin.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshlogin.c,v 1.25 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -39,7 +40,20 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshlogin.c,v 1.13 2004/08/12 09:18:24 djm Exp $"); + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include #include "loginrec.h" #include "log.h" @@ -54,15 +68,15 @@ extern ServerOptions options; * information is not available. This must be called before record_login. * The host the user logged in from will be returned in buf. */ -u_long +time_t get_last_login_time(uid_t uid, const char *logname, - char *buf, u_int bufsize) + char *buf, size_t bufsize) { struct logininfo li; login_get_lastlog(&li, uid); strlcpy(buf, li.hostname, bufsize); - return li.tv_sec; + return (time_t)li.tv_sec; } /* @@ -103,7 +117,7 @@ store_lastlog_message(const char *user, uid_t uid) */ void record_login(pid_t pid, const char *tty, const char *user, uid_t uid, - const char *host, struct sockaddr * addr, socklen_t addrlen) + const char *host, struct sockaddr *addr, socklen_t addrlen) { struct logininfo *li; @@ -119,7 +133,7 @@ record_login(pid_t pid, const char *tty, const char *user, uid_t uid, #ifdef LOGIN_NEEDS_UTMPX void record_utmp_only(pid_t pid, const char *ttyname, const char *user, - const char *host, struct sockaddr * addr, socklen_t addrlen) + const char *host, struct sockaddr *addr, socklen_t addrlen) { struct logininfo *li; diff --git a/openssh/sshlogin.h b/openssh/sshlogin.h index 1c8bfad..500d3fe 100644 --- a/openssh/sshlogin.h +++ b/openssh/sshlogin.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sshlogin.h,v 1.4 2002/08/29 15:57:25 stevesk Exp $ */ +/* $OpenBSD: sshlogin.h,v 1.8 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -11,18 +11,13 @@ * incompatible with the protocol description in the RFC file, it must be * called by a name other than "ssh" or "Secure Shell". */ -#ifndef SSHLOGIN_H -#define SSHLOGIN_H -void -record_login(pid_t, const char *, const char *, uid_t, +void record_login(pid_t, const char *, const char *, uid_t, const char *, struct sockaddr *, socklen_t); void record_logout(pid_t, const char *, const char *); -u_long get_last_login_time(uid_t, const char *, char *, u_int); +time_t get_last_login_time(uid_t, const char *, char *, u_int); #ifdef LOGIN_NEEDS_UTMPX void record_utmp_only(pid_t, const char *, const char *, const char *, struct sockaddr *, socklen_t); #endif - -#endif diff --git a/openssh/sshpty.c b/openssh/sshpty.c index 36788c4..79c62ee 100644 --- a/openssh/sshpty.c +++ b/openssh/sshpty.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshpty.c,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,11 +13,26 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshpty.c,v 1.12 2004/06/21 17:36:31 avsm Exp $"); +#include +#include +#include +#include + +#include +#include +#include +#ifdef HAVE_PATHS_H +# include +#endif +#include +#include +#include +#include #ifdef HAVE_UTIL_H # include -#endif /* HAVE_UTIL_H */ +#endif +#include #include "sshpty.h" #include "log.h" @@ -38,7 +54,7 @@ RCSID("$OpenBSD: sshpty.c,v 1.12 2004/06/21 17:36:31 avsm Exp $"); */ int -pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) +pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen) { /* openpty(3) exists in OSF/1 and some other os'es */ char *name; @@ -161,11 +177,12 @@ pty_make_controlling_tty(int *ttyfd, const char *tty) /* Changes the window size associated with the pty. */ void -pty_change_window_size(int ptyfd, int row, int col, - int xpixel, int ypixel) +pty_change_window_size(int ptyfd, u_int row, u_int col, + u_int xpixel, u_int ypixel) { struct winsize w; + /* may truncate u_int -> u_short */ w.ws_row = row; w.ws_col = col; w.ws_xpixel = xpixel; @@ -200,6 +217,10 @@ pty_setowner(struct passwd *pw, const char *tty) fatal("stat(%.100s) failed: %.100s", tty, strerror(errno)); +#ifdef WITH_SELINUX + ssh_selinux_setup_pty(pw->pw_name, tty); +#endif + if (st.st_uid != pw->pw_uid || st.st_gid != gid) { if (chown(tty, pw->pw_uid, gid) < 0) { if (errno == EROFS && diff --git a/openssh/sshpty.h b/openssh/sshpty.h index c0678de..7fac622 100644 --- a/openssh/sshpty.h +++ b/openssh/sshpty.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sshpty.h,v 1.5 2004/05/08 00:01:37 deraadt Exp $ */ +/* $OpenBSD: sshpty.h,v 1.10 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -14,17 +14,14 @@ * called by a name other than "ssh" or "Secure Shell". */ -#ifndef SSHPTY_H -#define SSHPTY_H +#include struct termios get_saved_tio(void); void leave_raw_mode(void); void enter_raw_mode(void); -int pty_allocate(int *, int *, char *, int); +int pty_allocate(int *, int *, char *, size_t); void pty_release(const char *); void pty_make_controlling_tty(int *, const char *); -void pty_change_window_size(int, int, int, int, int); +void pty_change_window_size(int, u_int, u_int, u_int, u_int); void pty_setowner(struct passwd *, const char *); - -#endif /* SSHPTY_H */ diff --git a/openssh/sshtty.c b/openssh/sshtty.c index 0b17c3e..0456766 100644 --- a/openssh/sshtty.c +++ b/openssh/sshtty.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sshtty.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,10 +36,13 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshtty.c,v 1.6 2004/05/08 00:01:37 deraadt Exp $"); + +#include +#include +#include +#include #include "sshpty.h" -#include "log.h" static struct termios _saved_tio; static int _in_raw_mode = 0; diff --git a/openssh/ttymodes.c b/openssh/ttymodes.c index cf4c7d5..d8e2c55 100644 --- a/openssh/ttymodes.c +++ b/openssh/ttymodes.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ttymodes.c,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -43,14 +44,19 @@ */ #include "includes.h" -RCSID("$OpenBSD: ttymodes.c,v 1.19 2003/04/08 20:21:29 itojun Exp $"); + +#include + +#include +#include +#include +#include #include "packet.h" #include "log.h" #include "ssh1.h" #include "compat.h" #include "buffer.h" -#include "bufaux.h" #define TTY_OP_END 0 /* @@ -384,7 +390,8 @@ tty_parse_modes(int fd, int *n_bytes_ptr) n_bytes += 4; baud = packet_get_int(); debug3("tty_parse_modes: ispeed %d", baud); - if (failure != -1 && cfsetispeed(&tio, baud_to_speed(baud)) == -1) + if (failure != -1 && + cfsetispeed(&tio, baud_to_speed(baud)) == -1) error("cfsetispeed failed for %d", baud); break; @@ -394,7 +401,8 @@ tty_parse_modes(int fd, int *n_bytes_ptr) n_bytes += 4; baud = packet_get_int(); debug3("tty_parse_modes: ospeed %d", baud); - if (failure != -1 && cfsetospeed(&tio, baud_to_speed(baud)) == -1) + if (failure != -1 && + cfsetospeed(&tio, baud_to_speed(baud)) == -1) error("cfsetospeed failed for %d", baud); break; @@ -442,11 +450,12 @@ tty_parse_modes(int fd, int *n_bytes_ptr) /* * It is a truly undefined opcode (160 to 255). * We have no idea about its arguments. So we - * must stop parsing. Note that some data may be - * left in the packet; hopefully there is nothing - * more coming after the mode data. + * must stop parsing. Note that some data + * may be left in the packet; hopefully there + * is nothing more coming after the mode data. */ - logit("parse_tty_modes: unknown opcode %d", opcode); + logit("parse_tty_modes: unknown opcode %d", + opcode); goto set; } } else { @@ -462,7 +471,8 @@ tty_parse_modes(int fd, int *n_bytes_ptr) (void) packet_get_int(); break; } else { - logit("parse_tty_modes: unknown opcode %d", opcode); + logit("parse_tty_modes: unknown opcode %d", + opcode); goto set; } } diff --git a/openssh/ttymodes.h b/openssh/ttymodes.h index 481282c..4d848fe 100644 --- a/openssh/ttymodes.h +++ b/openssh/ttymodes.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ttymodes.h,v 1.13 2004/07/11 17:48:47 deraadt Exp $ */ +/* $OpenBSD: ttymodes.h,v 1.14 2006/03/25 22:22:43 djm Exp $ */ /* * Author: Tatu Ylonen diff --git a/openssh/uidswap.c b/openssh/uidswap.c index aab7064..91d878c 100644 --- a/openssh/uidswap.c +++ b/openssh/uidswap.c @@ -1,3 +1,4 @@ +/* $OpenBSD: uidswap.c,v 1.35 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,7 +13,15 @@ */ #include "includes.h" -RCSID("$OpenBSD: uidswap.c,v 1.24 2003/05/29 16:58:45 deraadt Exp $"); + +#include +#include +#include +#include +#include +#include + +#include #include "log.h" #include "uidswap.h" @@ -77,7 +86,7 @@ temporarily_use_uid(struct passwd *pw) fatal("getgroups: %.100s", strerror(errno)); if (saved_egroupslen > 0) { saved_egroups = xrealloc(saved_egroups, - saved_egroupslen * sizeof(gid_t)); + saved_egroupslen, sizeof(gid_t)); if (getgroups(saved_egroupslen, saved_egroups) < 0) fatal("getgroups: %.100s", strerror(errno)); } else { /* saved_egroupslen == 0 */ @@ -96,7 +105,7 @@ temporarily_use_uid(struct passwd *pw) fatal("getgroups: %.100s", strerror(errno)); if (user_groupslen > 0) { user_groups = xrealloc(user_groups, - user_groupslen * sizeof(gid_t)); + user_groupslen, sizeof(gid_t)); if (getgroups(user_groupslen, user_groups) < 0) fatal("getgroups: %.100s", strerror(errno)); } else { /* user_groupslen == 0 */ @@ -123,6 +132,41 @@ temporarily_use_uid(struct passwd *pw) strerror(errno)); } +void +permanently_drop_suid(uid_t uid) +{ + uid_t old_uid = getuid(); + + debug("permanently_drop_suid: %u", (u_int)uid); +#if defined(HAVE_SETRESUID) && !defined(BROKEN_SETRESUID) + if (setresuid(uid, uid, uid) < 0) + fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno)); +#elif defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID) + if (setreuid(uid, uid) < 0) + fatal("setreuid %u: %.100s", (u_int)uid, strerror(errno)); +#else +# ifndef SETEUID_BREAKS_SETUID + if (seteuid(uid) < 0) + fatal("seteuid %u: %.100s", (u_int)uid, strerror(errno)); +# endif + if (setuid(uid) < 0) + fatal("setuid %u: %.100s", (u_int)uid, strerror(errno)); +#endif + +#ifndef HAVE_CYGWIN + /* Try restoration of UID if changed (test clearing of saved uid) */ + if (old_uid != uid && + (setuid(old_uid) != -1 || seteuid(old_uid) != -1)) + fatal("%s: was able to restore old [e]uid", __func__); +#endif + + /* Verify UID drop was successful */ + if (getuid() != uid || geteuid() != uid) { + fatal("%s: euid incorrect uid:%u euid:%u (should be %u)", + __func__, (u_int)getuid(), (u_int)geteuid(), (u_int)uid); + } +} + /* * Restores to the original (privileged) uid. */ @@ -169,6 +213,8 @@ permanently_set_uid(struct passwd *pw) uid_t old_uid = getuid(); gid_t old_gid = getgid(); + if (pw == NULL) + fatal("permanently_set_uid: no user given"); if (temporarily_use_uid_effective) fatal("permanently_set_uid: temporarily_use_uid effective"); debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid, diff --git a/openssh/uidswap.h b/openssh/uidswap.h index 0726980..1c1163d 100644 --- a/openssh/uidswap.h +++ b/openssh/uidswap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uidswap.h,v 1.9 2001/06/26 17:27:25 markus Exp $ */ +/* $OpenBSD: uidswap.h,v 1.13 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -12,11 +12,7 @@ * called by a name other than "ssh" or "Secure Shell". */ -#ifndef UIDSWAP_H -#define UIDSWAP_H - void temporarily_use_uid(struct passwd *); void restore_uid(void); void permanently_set_uid(struct passwd *); - -#endif /* UIDSWAP_H */ +void permanently_drop_suid(uid_t); diff --git a/openssh/uuencode.c b/openssh/uuencode.c index 0a7c8d1..a139495 100644 --- a/openssh/uuencode.c +++ b/openssh/uuencode.c @@ -1,3 +1,4 @@ +/* $OpenBSD: uuencode.c,v 1.24 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -23,7 +24,11 @@ */ #include "includes.h" -RCSID("$OpenBSD: uuencode.c,v 1.17 2003/11/10 16:23:41 jakob Exp $"); + +#include +#include +#include +#include #include "xmalloc.h" #include "uuencode.h" @@ -58,9 +63,14 @@ uudecode(const char *src, u_char *target, size_t targsize) void dump_base64(FILE *fp, u_char *data, u_int len) { - char *buf = xmalloc(2*len); + char *buf; int i, n; + if (len > 65536) { + fprintf(fp, "dump_base64: len > 65536\n"); + return; + } + buf = xmalloc(2*len); n = uuencode(data, len, buf, 2*len); for (i = 0; i < n; i++) { fprintf(fp, "%c", buf[i]); diff --git a/openssh/uuencode.h b/openssh/uuencode.h index 08e87c4..fec55b4 100644 --- a/openssh/uuencode.h +++ b/openssh/uuencode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uuencode.h,v 1.10 2003/11/10 16:23:41 jakob Exp $ */ +/* $OpenBSD: uuencode.h,v 1.13 2006/08/03 03:34:42 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -24,9 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef UUENCODE_H -#define UUENCODE_H int uuencode(const u_char *, u_int, char *, size_t); int uudecode(const char *, u_char *, size_t); void dump_base64(FILE *, u_char *, u_int); -#endif diff --git a/openssh/version.h b/openssh/version.h index d84d3e4..45db4a6 100644 --- a/openssh/version.h +++ b/openssh/version.h @@ -1,4 +1,4 @@ -/* $OpenBSD: version.h,v 1.46 2006/02/01 11:27:22 markus Exp $ */ +/* $OpenBSD: version.h,v 1.48 2006/11/07 10:31:31 markus Exp $ */ #ifdef GSI #define GSI_VERSION " GSI" @@ -18,10 +18,11 @@ #define MGLUE_VERSION "" #endif -#define SSH_VERSION "OpenSSH_4.3" +#define NCSA_VERSION " NCSA_GSSAPI_GPT_3.8" -#define SSH_PORTABLE "p2" -#define SSH_HPN "-hpn12" +#define SSH_VERSION "OpenSSH_4.5" + +#define SSH_PORTABLE "p1" +#define SSH_HPN "-hpn12v14" #define SSH_RELEASE SSH_VERSION SSH_PORTABLE SSH_HPN \ - " NCSA_GSSAPI_GPT_3.8" \ - GSI_VERSION KRB5_VERSION MGLUE_VERSION + NCSA_VERSION GSI_VERSION KRB5_VERSION MGLUE_VERSION diff --git a/openssh/xmalloc.c b/openssh/xmalloc.c index 99c6ac3..9985b4c 100644 --- a/openssh/xmalloc.c +++ b/openssh/xmalloc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: xmalloc.c,v 1.27 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -13,7 +14,12 @@ */ #include "includes.h" -RCSID("$OpenBSD: xmalloc.c,v 1.16 2001/07/23 18:21:46 stevesk Exp $"); + +#include +#include +#include +#include +#include #include "xmalloc.h" #include "log.h" @@ -32,18 +38,38 @@ xmalloc(size_t size) } void * -xrealloc(void *ptr, size_t new_size) +xcalloc(size_t nmemb, size_t size) +{ + void *ptr; + + if (size == 0 || nmemb == 0) + fatal("xcalloc: zero size"); + if (SIZE_T_MAX / nmemb < size) + fatal("xcalloc: nmemb * size > SIZE_T_MAX"); + ptr = calloc(nmemb, size); + if (ptr == NULL) + fatal("xcalloc: out of memory (allocating %lu bytes)", + (u_long)(size * nmemb)); + return ptr; +} + +void * +xrealloc(void *ptr, size_t nmemb, size_t size) { void *new_ptr; + size_t new_size = nmemb * size; if (new_size == 0) fatal("xrealloc: zero size"); + if (SIZE_T_MAX / nmemb < size) + fatal("xrealloc: nmemb * size > SIZE_T_MAX"); if (ptr == NULL) new_ptr = malloc(new_size); else new_ptr = realloc(ptr, new_size); if (new_ptr == NULL) - fatal("xrealloc: out of memory (new_size %lu bytes)", (u_long) new_size); + fatal("xrealloc: out of memory (new_size %lu bytes)", + (u_long) new_size); return new_ptr; } @@ -66,3 +92,19 @@ xstrdup(const char *str) strlcpy(cp, str, len); return cp; } + +int +xasprintf(char **ret, const char *fmt, ...) +{ + va_list ap; + int i; + + va_start(ap, fmt); + i = vasprintf(ret, fmt, ap); + va_end(ap); + + if (i < 0 || *ret == NULL) + fatal("xasprintf: could not allocate memory"); + + return (i); +} diff --git a/openssh/xmalloc.h b/openssh/xmalloc.h index 7ac4b13..fb217a4 100644 --- a/openssh/xmalloc.h +++ b/openssh/xmalloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.h,v 1.9 2002/06/19 00:27:55 deraadt Exp $ */ +/* $OpenBSD: xmalloc.h,v 1.13 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -16,12 +16,11 @@ * called by a name other than "ssh" or "Secure Shell". */ -#ifndef XMALLOC_H -#define XMALLOC_H - void *xmalloc(size_t); -void *xrealloc(void *, size_t); +void *xcalloc(size_t, size_t); +void *xrealloc(void *, size_t, size_t); void xfree(void *); char *xstrdup(const char *); - -#endif /* XMALLOC_H */ +int xasprintf(char **, const char *, ...) + __attribute__((__format__ (printf, 2, 3))) + __attribute__((__nonnull__ (2))); -- 2.45.2