aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssh/auth-rhosts.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2008-08-01 02:48:36 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2008-08-01 02:48:36 +0000
commitd4af9e693f15f5155095f38c7650b24fe74ae351 (patch)
treeed813bdf7d8dbee35f19092d185e1a2793885204 /crypto/openssh/auth-rhosts.c
parentb0f9661dfbf75198259c7128685d06cd91a18d61 (diff)
parentbf2dc2ac25811c5fe81e4fd0837ef3c92a0c9c00 (diff)
downloadsrc-d4af9e693f15f5155095f38c7650b24fe74ae351.tar.gz
src-d4af9e693f15f5155095f38c7650b24fe74ae351.zip
Upgrade to OpenSSH 5.1p1.
I have worked hard to reduce diffs against the vendor branch. One notable change in that respect is that we no longer prefer DSA over RSA - the reasons for doing so went away years ago. This may cause some surprises, as ssh will warn about unknown host keys even for hosts whose keys haven't changed. MFC after: 6 weeks
Notes
Notes: svn path=/head/; revision=181111
Diffstat (limited to 'crypto/openssh/auth-rhosts.c')
-rw-r--r--crypto/openssh/auth-rhosts.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/crypto/openssh/auth-rhosts.c b/crypto/openssh/auth-rhosts.c
index cd0a7967a244..5c12967016b4 100644
--- a/crypto/openssh/auth-rhosts.c
+++ b/crypto/openssh/auth-rhosts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth-rhosts.c,v 1.41 2006/08/03 03:34:41 deraadt Exp $ */
+/* $OpenBSD: auth-rhosts.c,v 1.43 2008/06/13 14:18:51 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -26,6 +26,8 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "packet.h"
#include "buffer.h"
@@ -37,6 +39,7 @@
#include "key.h"
#include "hostfile.h"
#include "auth.h"
+#include "misc.h"
/* import */
extern ServerOptions options;
@@ -55,12 +58,27 @@ check_rhosts_file(const char *filename, const char *hostname,
{
FILE *f;
char buf[1024]; /* Must not be larger than host, user, dummy below. */
+ int fd;
+ struct stat st;
/* Open the .rhosts file, deny if unreadable */
- f = fopen(filename, "r");
- if (!f)
+ if ((fd = open(filename, O_RDONLY|O_NONBLOCK)) == -1)
return 0;
-
+ if (fstat(fd, &st) == -1) {
+ close(fd);
+ return 0;
+ }
+ if (!S_ISREG(st.st_mode)) {
+ logit("User %s hosts file %s is not a regular file",
+ server_user, filename);
+ close(fd);
+ return 0;
+ }
+ unset_nonblock(fd);
+ if ((f = fdopen(fd, "r")) == NULL) {
+ close(fd);
+ return 0;
+ }
while (fgets(buf, sizeof(buf), f)) {
/* All three must be at least as big as buf to avoid overflows. */
char hostbuf[1024], userbuf[1024], dummy[1024], *host, *user, *cp;