00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "includes.h"
00016 RCSID("$OpenBSD: auth-rh-rsa.c,v 1.38 2005/07/17 07:17:54 djm Exp $");
00017
00018 #include "packet.h"
00019 #include "uidswap.h"
00020 #include "log.h"
00021 #include "servconf.h"
00022 #include "key.h"
00023 #include "hostfile.h"
00024 #include "pathnames.h"
00025 #include "auth.h"
00026 #include "canohost.h"
00027
00028 #include "monitor_wrap.h"
00029
00030
00031 extern ServerOptions options;
00032
00033 int
00034 auth_rhosts_rsa_key_allowed(struct passwd *pw, char *cuser, char *chost,
00035 Key *client_host_key)
00036 {
00037 HostStatus host_status;
00038
00039
00040 if (!auth_rhosts(pw, cuser))
00041 return 0;
00042
00043 host_status = check_key_in_hostfiles(pw, client_host_key,
00044 chost, _PATH_SSH_SYSTEM_HOSTFILE,
00045 options.ignore_user_known_hosts ? NULL : _PATH_SSH_USER_HOSTFILE);
00046
00047 return (host_status == HOST_OK);
00048 }
00049
00050
00051
00052
00053
00054 int
00055 auth_rhosts_rsa(Authctxt *authctxt, char *cuser, Key *client_host_key)
00056 {
00057 char *chost;
00058 struct passwd *pw = authctxt->pw;
00059
00060 debug("Trying rhosts with RSA host authentication for client user %.100s",
00061 cuser);
00062
00063 if (!authctxt->valid || client_host_key == NULL ||
00064 client_host_key->rsa == NULL)
00065 return 0;
00066
00067 chost = (char *)get_canonical_hostname(options.use_dns);
00068 debug("Rhosts RSA authentication: canonical host %.900s", chost);
00069
00070 if (!PRIVSEP(auth_rhosts_rsa_key_allowed(pw, cuser, chost, client_host_key))) {
00071 debug("Rhosts with RSA host authentication denied: unknown or invalid host key");
00072 packet_send_debug("Your host key cannot be verified: unknown or invalid host key.");
00073 return 0;
00074 }
00075
00076
00077
00078 if (!auth_rsa_challenge_dialog(client_host_key)) {
00079 logit("Client on %.800s failed to respond correctly to host authentication.",
00080 chost);
00081 return 0;
00082 }
00083
00084
00085
00086
00087
00088 verbose("Rhosts with RSA host authentication accepted for %.100s, %.100s on %.700s.",
00089 pw->pw_name, cuser, chost);
00090 packet_send_debug("Rhosts with RSA host authentication accepted.");
00091 return 1;
00092 }