summaryrefslogtreecommitdiff
path: root/auth.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-05-10 11:58:03 +1000
committerDamien Miller <djm@mindrot.org>2010-05-10 11:58:03 +1000
commit30da3447d2ef3329cb0eb083cdddf84532659454 (patch)
tree02537d2355d77cc15d1bf9d266d474e660848012 /auth.c
parent099fc1634e1cc0f96b77a811e554bf9d796def8f (diff)
- djm@cvs.openbsd.org 2010/05/07 11:30:30
[auth-options.c auth-options.h auth.c auth.h auth2-pubkey.c] [key.c servconf.c servconf.h sshd.8 sshd_config.5] add some optional indirection to matching of principal names listed in certificates. Currently, a certificate must include the a user's name to be accepted for authentication. This change adds the ability to specify a list of certificate principal names that are acceptable. When authenticating using a CA trusted through ~/.ssh/authorized_keys, this adds a new principals="name1[,name2,...]" key option. For CAs listed through sshd_config's TrustedCAKeys option, a new config option "AuthorizedPrincipalsFile" specifies a per-user file containing the list of acceptable names. If either option is absent, the current behaviour of requiring the username to appear in principals continues to apply. These options are useful for role accounts, disjoint account namespaces and "user@realm"-style naming policies in certificates. feedback and ok markus@
Diffstat (limited to 'auth.c')
-rw-r--r--auth.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/auth.c b/auth.c
index 89a936068..bec191a59 100644
--- a/auth.c
+++ b/auth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth.c,v 1.86 2010/03/05 02:58:11 djm Exp $ */ 1/* $OpenBSD: auth.c,v 1.87 2010/05/07 11:30:29 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -366,6 +366,14 @@ authorized_keys_file2(struct passwd *pw)
366 return expand_authorized_keys(options.authorized_keys_file2, pw); 366 return expand_authorized_keys(options.authorized_keys_file2, pw);
367} 367}
368 368
369char *
370authorized_principals_file(struct passwd *pw)
371{
372 if (options.authorized_principals_file == NULL)
373 return NULL;
374 return expand_authorized_keys(options.authorized_principals_file, pw);
375}
376
369/* return ok if key exists in sysfile or userfile */ 377/* return ok if key exists in sysfile or userfile */
370HostStatus 378HostStatus
371check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host, 379check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
@@ -477,21 +485,18 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
477 return 0; 485 return 0;
478} 486}
479 487
480FILE * 488static FILE *
481auth_openkeyfile(const char *file, struct passwd *pw, int strict_modes) 489auth_openfile(const char *file, struct passwd *pw, int strict_modes,
490 int log_missing, char *file_type)
482{ 491{
483 char line[1024]; 492 char line[1024];
484 struct stat st; 493 struct stat st;
485 int fd; 494 int fd;
486 FILE *f; 495 FILE *f;
487 496
488 /*
489 * Open the file containing the authorized keys
490 * Fail quietly if file does not exist
491 */
492 if ((fd = open(file, O_RDONLY|O_NONBLOCK)) == -1) { 497 if ((fd = open(file, O_RDONLY|O_NONBLOCK)) == -1) {
493 if (errno != ENOENT) 498 if (log_missing || errno != ENOENT)
494 debug("Could not open keyfile '%s': %s", file, 499 debug("Could not open %s '%s': %s", file_type, file,
495 strerror(errno)); 500 strerror(errno));
496 return NULL; 501 return NULL;
497 } 502 }
@@ -501,8 +506,8 @@ auth_openkeyfile(const char *file, struct passwd *pw, int strict_modes)
501 return NULL; 506 return NULL;
502 } 507 }
503 if (!S_ISREG(st.st_mode)) { 508 if (!S_ISREG(st.st_mode)) {
504 logit("User %s authorized keys %s is not a regular file", 509 logit("User %s %s %s is not a regular file",
505 pw->pw_name, file); 510 pw->pw_name, file_type, file);
506 close(fd); 511 close(fd);
507 return NULL; 512 return NULL;
508 } 513 }
@@ -521,6 +526,20 @@ auth_openkeyfile(const char *file, struct passwd *pw, int strict_modes)
521 return f; 526 return f;
522} 527}
523 528
529
530FILE *
531auth_openkeyfile(const char *file, struct passwd *pw, int strict_modes)
532{
533 return auth_openfile(file, pw, strict_modes, 1, "authorized keys");
534}
535
536FILE *
537auth_openprincipals(const char *file, struct passwd *pw, int strict_modes)
538{
539 return auth_openfile(file, pw, strict_modes, 0,
540 "authorized principals");
541}
542
524struct passwd * 543struct passwd *
525getpwnamallow(const char *user) 544getpwnamallow(const char *user)
526{ 545{