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

« back to all changes in this revision

Viewing changes to auth2-pubkey.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: auth2-pubkey.c,v 1.15 2006/08/03 03:34:41 deraadt Exp $ */
 
1
/* $OpenBSD: auth2-pubkey.c,v 1.19 2008/07/03 21:46:58 otto Exp $ */
2
2
/*
3
3
 * Copyright (c) 2000 Markus Friedl.  All rights reserved.
4
4
 *
28
28
#include <sys/types.h>
29
29
#include <sys/stat.h>
30
30
 
 
31
#include <fcntl.h>
31
32
#include <pwd.h>
32
33
#include <stdio.h>
33
34
#include <stdarg.h>
 
35
#include <unistd.h>
34
36
 
35
37
#include "xmalloc.h"
36
38
#include "ssh.h"
183
185
        int found_key = 0;
184
186
        FILE *f;
185
187
        u_long linenum = 0;
186
 
        struct stat st;
187
188
        Key *found;
188
189
        char *fp;
189
190
 
191
192
        temporarily_use_uid(pw);
192
193
 
193
194
        debug("trying public key file %s", file);
 
195
        f = auth_openkeyfile(file, pw, options.strict_modes);
194
196
 
195
 
        /* Fail quietly if file does not exist */
196
 
        if (stat(file, &st) < 0) {
197
 
                /* Restore the privileged uid. */
198
 
                restore_uid();
199
 
                return 0;
200
 
        }
201
 
        /* Open the file containing the authorized keys. */
202
 
        f = fopen(file, "r");
203
197
        if (!f) {
204
 
                /* Restore the privileged uid. */
205
 
                restore_uid();
206
 
                return 0;
207
 
        }
208
 
        if (options.strict_modes &&
209
 
            secure_filename(f, file, pw, line, sizeof(line)) != 0) {
210
 
                fclose(f);
211
 
                logit("Authentication refused: %s", line);
212
198
                restore_uid();
213
199
                return 0;
214
200
        }
272
258
        int success;
273
259
        char *file;
274
260
 
 
261
        if (reject_blacklisted_key(key, 0) == 1)
 
262
                return 0;
 
263
 
275
264
        file = authorized_keys_file(pw);
276
265
        success = user_key_allowed2(pw, key, file);
277
266
        xfree(file);