~ubuntu-branches/ubuntu/lucid/openssh/lucid

« back to all changes in this revision

Viewing changes to auth-rhosts.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-09-30 23:09:58 UTC
  • mfrom: (1.13.3 upstream) (29 hardy)
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: james.westby@ubuntu.com-20080930230958-o6vsgn8c4mm959s0
Tags: 1:5.1p1-3
* Remove unnecessary ssh-vulnkey output in non-verbose mode when no
  compromised or unknown keys were found (closes: #496495).
* Configure with --disable-strip; dh_strip will deal with stripping
  binaries and will honour DEB_BUILD_OPTIONS (thanks, Bernhard R. Link;
  closes: #498681).
* Fix handling of zero-length server banners (thanks, Tomas Mraz; closes:
  #497026).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $OpenBSD: auth-rhosts.c,v 1.41 2006/08/03 03:34:41 deraadt Exp $ */
 
1
/* $OpenBSD: auth-rhosts.c,v 1.43 2008/06/13 14:18:51 dtucker Exp $ */
2
2
/*
3
3
 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4
4
 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
26
26
#include <stdio.h>
27
27
#include <string.h>
28
28
#include <stdarg.h>
 
29
#include <fcntl.h>
 
30
#include <unistd.h>
29
31
 
30
32
#include "packet.h"
31
33
#include "buffer.h"
37
39
#include "key.h"
38
40
#include "hostfile.h"
39
41
#include "auth.h"
 
42
#include "misc.h"
40
43
 
41
44
/* import */
42
45
extern ServerOptions options;
55
58
{
56
59
        FILE *f;
57
60
        char buf[1024]; /* Must not be larger than host, user, dummy below. */
 
61
        int fd;
 
62
        struct stat st;
58
63
 
59
64
        /* Open the .rhosts file, deny if unreadable */
60
 
        f = fopen(filename, "r");
61
 
        if (!f)
62
 
                return 0;
63
 
 
 
65
        if ((fd = open(filename, O_RDONLY|O_NONBLOCK)) == -1)
 
66
                return 0;
 
67
        if (fstat(fd, &st) == -1) {
 
68
                close(fd);
 
69
                return 0;
 
70
        }
 
71
        if (!S_ISREG(st.st_mode)) {
 
72
                logit("User %s hosts file %s is not a regular file",
 
73
                    server_user, filename);
 
74
                close(fd);
 
75
                return 0;
 
76
        }
 
77
        unset_nonblock(fd);
 
78
        if ((f = fdopen(fd, "r")) == NULL) {
 
79
                close(fd);
 
80
                return 0;
 
81
        }
64
82
        while (fgets(buf, sizeof(buf), f)) {
65
83
                /* All three must be at least as big as buf to avoid overflows. */
66
84
                char hostbuf[1024], userbuf[1024], dummy[1024], *host, *user, *cp;