00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "includes.h"
00025 RCSID("$OpenBSD: auth-skey.c,v 1.20 2002/06/30 21:59:45 deraadt Exp $");
00026
00027 #ifdef SKEY
00028
00029 #include <skey.h>
00030
00031 #include "xmalloc.h"
00032 #include "auth.h"
00033 #include "monitor_wrap.h"
00034
00035 static void *
00036 skey_init_ctx(Authctxt *authctxt)
00037 {
00038 return authctxt;
00039 }
00040
00041 int
00042 skey_query(void *ctx, char **name, char **infotxt,
00043 u_int* numprompts, char ***prompts, u_int **echo_on)
00044 {
00045 Authctxt *authctxt = ctx;
00046 char challenge[1024], *p;
00047 int len;
00048 struct skey skey;
00049
00050 if (_compat_skeychallenge(&skey, authctxt->user, challenge,
00051 sizeof(challenge)) == -1)
00052 return -1;
00053
00054 *name = xstrdup("");
00055 *infotxt = xstrdup("");
00056 *numprompts = 1;
00057 *prompts = xmalloc(*numprompts * sizeof(char *));
00058 *echo_on = xmalloc(*numprompts * sizeof(u_int));
00059 (*echo_on)[0] = 0;
00060
00061 len = strlen(challenge) + strlen(SKEY_PROMPT) + 1;
00062 p = xmalloc(len);
00063 strlcpy(p, challenge, len);
00064 strlcat(p, SKEY_PROMPT, len);
00065 (*prompts)[0] = p;
00066
00067 return 0;
00068 }
00069
00070 int
00071 skey_respond(void *ctx, u_int numresponses, char **responses)
00072 {
00073 Authctxt *authctxt = ctx;
00074
00075 if (authctxt->valid &&
00076 numresponses == 1 &&
00077 skey_haskey(authctxt->pw->pw_name) == 0 &&
00078 skey_passcheck(authctxt->pw->pw_name, responses[0]) != -1)
00079 return 0;
00080 return -1;
00081 }
00082
00083 static void
00084 skey_free_ctx(void *ctx)
00085 {
00086
00087 }
00088
00089 KbdintDevice skey_device = {
00090 "skey",
00091 skey_init_ctx,
00092 skey_query,
00093 skey_respond,
00094 skey_free_ctx
00095 };
00096
00097 KbdintDevice mm_skey_device = {
00098 "skey",
00099 skey_init_ctx,
00100 mm_skey_query,
00101 mm_skey_respond,
00102 skey_free_ctx
00103 };
00104 #endif