summaryrefslogtreecommitdiff
path: root/auth-bsdauth.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-12-21 14:45:46 +1100
committerDamien Miller <djm@mindrot.org>2001-12-21 14:45:46 +1100
commit9f0f5c64bc4b6144e3fed6a7f538f7c21819a492 (patch)
treef79317ab211f59181a61b526f566e9c8cfe70c73 /auth-bsdauth.c
parent89681214ca2f50a1b1ed6164c3afe1ce14995ffc (diff)
- deraadt@cvs.openbsd.org 2001/12/19 07:18:56
[auth1.c auth2.c auth2-chall.c auth-bsdauth.c auth.c authfile.c auth.h] [auth-krb4.c auth-rhosts.c auth-skey.c bufaux.c canohost.c channels.c] [cipher.c clientloop.c compat.c compress.c deattack.c key.c log.c mac.c] [match.c misc.c nchan.c packet.c readconf.c rijndael.c rijndael.h scard.c] [servconf.c servconf.h serverloop.c session.c sftp.c sftp-client.c] [sftp-glob.c sftp-int.c sftp-server.c ssh-add.c ssh-agent.c ssh.c] [sshconnect1.c sshconnect2.c sshconnect.c sshd.8 sshd.c sshd_config] [ssh-keygen.c sshlogin.c sshpty.c sshtty.c ttymodes.c uidswap.c] basic KNF done while i was looking for something else
Diffstat (limited to 'auth-bsdauth.c')
-rw-r--r--auth-bsdauth.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/auth-bsdauth.c b/auth-bsdauth.c
index 3732477de..b70d48f20 100644
--- a/auth-bsdauth.c
+++ b/auth-bsdauth.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: auth-bsdauth.c,v 1.1 2001/05/18 14:13:28 markus Exp $"); 25RCSID("$OpenBSD: auth-bsdauth.c,v 1.2 2001/12/19 07:18:56 deraadt Exp $");
26 26
27#ifdef BSD_AUTH 27#ifdef BSD_AUTH
28#include "xmalloc.h" 28#include "xmalloc.h"
@@ -36,74 +36,74 @@ bsdauth_init_ctx(Authctxt *authctxt)
36} 36}
37 37
38static int 38static int
39bsdauth_query(void *ctx, char **name, char **infotxt, 39bsdauth_query(void *ctx, char **name, char **infotxt,
40 u_int *numprompts, char ***prompts, u_int **echo_on) 40 u_int *numprompts, char ***prompts, u_int **echo_on)
41{ 41{
42 Authctxt *authctxt = ctx; 42 Authctxt *authctxt = ctx;
43 char *challenge = NULL; 43 char *challenge = NULL;
44 44
45 if (authctxt->as != NULL) { 45 if (authctxt->as != NULL) {
46 debug2("bsdauth_query: try reuse session"); 46 debug2("bsdauth_query: try reuse session");
47 challenge = auth_getitem(authctxt->as, AUTHV_CHALLENGE); 47 challenge = auth_getitem(authctxt->as, AUTHV_CHALLENGE);
48 if (challenge == NULL) { 48 if (challenge == NULL) {
49 auth_close(authctxt->as); 49 auth_close(authctxt->as);
50 authctxt->as = NULL; 50 authctxt->as = NULL;
51 } 51 }
52 } 52 }
53 53
54 if (challenge == NULL) { 54 if (challenge == NULL) {
55 debug2("bsdauth_query: new bsd auth session"); 55 debug2("bsdauth_query: new bsd auth session");
56 debug3("bsdauth_query: style %s", 56 debug3("bsdauth_query: style %s",
57 authctxt->style ? authctxt->style : "<default>"); 57 authctxt->style ? authctxt->style : "<default>");
58 authctxt->as = auth_userchallenge(authctxt->user, 58 authctxt->as = auth_userchallenge(authctxt->user,
59 authctxt->style, "auth-ssh", &challenge); 59 authctxt->style, "auth-ssh", &challenge);
60 if (authctxt->as == NULL) 60 if (authctxt->as == NULL)
61 challenge = NULL; 61 challenge = NULL;
62 debug2("bsdauth_query: <%s>", challenge ? challenge : "empty"); 62 debug2("bsdauth_query: <%s>", challenge ? challenge : "empty");
63 } 63 }
64 64
65 if (challenge == NULL) 65 if (challenge == NULL)
66 return -1; 66 return -1;
67 67
68 *name = xstrdup(""); 68 *name = xstrdup("");
69 *infotxt = xstrdup(""); 69 *infotxt = xstrdup("");
70 *numprompts = 1; 70 *numprompts = 1;
71 *prompts = xmalloc(*numprompts * sizeof(char*)); 71 *prompts = xmalloc(*numprompts * sizeof(char*));
72 *echo_on = xmalloc(*numprompts * sizeof(u_int)); 72 *echo_on = xmalloc(*numprompts * sizeof(u_int));
73 (*echo_on)[0] = 0; 73 (*echo_on)[0] = 0;
74 (*prompts)[0] = xstrdup(challenge); 74 (*prompts)[0] = xstrdup(challenge);
75 75
76 return 0; 76 return 0;
77} 77}
78 78
79static int 79static int
80bsdauth_respond(void *ctx, u_int numresponses, char **responses) 80bsdauth_respond(void *ctx, u_int numresponses, char **responses)
81{ 81{
82 Authctxt *authctxt = ctx; 82 Authctxt *authctxt = ctx;
83 int authok; 83 int authok;
84 84
85 if (authctxt->as == 0) 85 if (authctxt->as == 0)
86 error("bsdauth_respond: no bsd auth session"); 86 error("bsdauth_respond: no bsd auth session");
87 87
88 if (numresponses != 1) 88 if (numresponses != 1)
89 return -1; 89 return -1;
90 90
91 authok = auth_userresponse(authctxt->as, responses[0], 0); 91 authok = auth_userresponse(authctxt->as, responses[0], 0);
92 authctxt->as = NULL; 92 authctxt->as = NULL;
93 debug3("bsdauth_respond: <%s> = <%d>", responses[0], authok); 93 debug3("bsdauth_respond: <%s> = <%d>", responses[0], authok);
94 94
95 return (authok == 0) ? -1 : 0; 95 return (authok == 0) ? -1 : 0;
96} 96}
97 97
98static void 98static void
99bsdauth_free_ctx(void *ctx) 99bsdauth_free_ctx(void *ctx)
100{ 100{
101 Authctxt *authctxt = ctx; 101 Authctxt *authctxt = ctx;
102 102
103 if (authctxt && authctxt->as) { 103 if (authctxt && authctxt->as) {
104 auth_close(authctxt->as); 104 auth_close(authctxt->as);
105 authctxt->as = NULL; 105 authctxt->as = NULL;
106 } 106 }
107} 107}
108 108
109KbdintDevice bsdauth_device = { 109KbdintDevice bsdauth_device = {