=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/authfile.c,v retrieving revision 1.61 retrieving revision 1.61.2.1 diff -u -r1.61 -r1.61.2.1 --- src/usr.bin/ssh/authfile.c 2005/06/17 02:44:32 1.61 +++ src/usr.bin/ssh/authfile.c 2006/10/06 03:19:32 1.61.2.1 @@ -1,3 +1,4 @@ +/* $OpenBSD: authfile.c,v 1.61.2.1 2006/10/06 03:19:32 brad Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,17 +36,26 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#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 "xmalloc.h" +#include "cipher.h" #include "buffer.h" -#include "bufaux.h" #include "key.h" #include "ssh.h" #include "log.h" @@ -184,7 +194,7 @@ 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 +221,10 @@ 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 +515,7 @@ return prv; } -static int +int key_perm_ok(int fd, const char *filename) { struct stat st; @@ -534,7 +542,7 @@ Key * key_load_private_type(int type, const char *filename, const char *passphrase, - char **commentp) + char **commentp, int *perm_ok) { int fd; @@ -542,22 +550,24 @@ 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;