summaryrefslogtreecommitdiff
path: root/authfile.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-03-04 21:53:35 +1100
committerDamien Miller <djm@mindrot.org>2010-03-04 21:53:35 +1100
commit1aed65eb27feec505997c98621bdf158f9ab8b99 (patch)
tree81c2d0b9aff3c2211388ba00cde544e0618750d2 /authfile.c
parent2befbad9b3c8fc6e4e564c062870229bc722734c (diff)
- djm@cvs.openbsd.org 2010/03/04 10:36:03
[auth-rh-rsa.c auth-rsa.c auth.c auth.h auth2-hostbased.c auth2-pubkey.c] [authfile.c authfile.h hostfile.c hostfile.h servconf.c servconf.h] [ssh-keygen.c ssh.1 sshconnect.c sshd_config.5] Add a TrustedUserCAKeys option to sshd_config to specify CA keys that are trusted to authenticate users (in addition than doing it per-user in authorized_keys). Add a RevokedKeys option to sshd_config and a @revoked marker to known_hosts to allow keys to me revoked and banned for user or host authentication. feedback and ok markus@
Diffstat (limited to 'authfile.c')
-rw-r--r--authfile.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/authfile.c b/authfile.c
index 2c615709d..224c6aa80 100644
--- a/authfile.c
+++ b/authfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfile.c,v 1.79 2010/01/12 00:16:47 dtucker Exp $ */ 1/* $OpenBSD: authfile.c,v 1.80 2010/03/04 10:36:03 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -692,3 +692,65 @@ key_load_public(const char *filename, char **commentp)
692 key_free(pub); 692 key_free(pub);
693 return NULL; 693 return NULL;
694} 694}
695
696/*
697 * Returns 1 if the specified "key" is listed in the file "filename",
698 * 0 if the key is not listed or -1 on error.
699 * If strict_type is set then the key type must match exactly,
700 * otherwise a comparison that ignores certficiate data is performed.
701 */
702int
703key_in_file(Key *key, const char *filename, int strict_type)
704{
705 FILE *f;
706 char line[SSH_MAX_PUBKEY_BYTES];
707 char *cp;
708 u_long linenum = 0;
709 int ret = 0;
710 Key *pub;
711 int (*key_compare)(const Key *, const Key *) = strict_type ?
712 key_equal : key_equal_public;
713
714 if ((f = fopen(filename, "r")) == NULL) {
715 if (errno == ENOENT) {
716 debug("%s: keyfile \"%s\" missing", __func__, filename);
717 return 0;
718 } else {
719 error("%s: could not open keyfile \"%s\": %s", __func__,
720 filename, strerror(errno));
721 return -1;
722 }
723 }
724
725 while (read_keyfile_line(f, filename, line, sizeof(line),
726 &linenum) != -1) {
727 cp = line;
728
729 /* Skip leading whitespace. */
730 for (; *cp && (*cp == ' ' || *cp == '\t'); cp++)
731 ;
732
733 /* Skip comments and empty lines */
734 switch (*cp) {
735 case '#':
736 case '\n':
737 case '\0':
738 continue;
739 }
740
741 pub = key_new(KEY_UNSPEC);
742 if (key_read(pub, &cp) != 1) {
743 key_free(pub);
744 continue;
745 }
746 if (key_compare(key, pub)) {
747 ret = 1;
748 key_free(pub);
749 break;
750 }
751 key_free(pub);
752 }
753 fclose(f);
754 return ret;
755}
756