summaryrefslogtreecommitdiff
path: root/sys/src/libauth
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-01-21 22:37:45 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-01-21 22:37:45 +0100
commit3004f058f69a16f09c07c58d0e60a1732190f0d3 (patch)
tree183e78edf574b5cfed682e03adbcd8c787644c0f /sys/src/libauth
parenta7974d96b7e510cba9ae4ef87fed8b0ded109f98 (diff)
libauth: add auth_respondAI() function to get AuthInfo for mschap/mschapv2
Diffstat (limited to 'sys/src/libauth')
-rw-r--r--sys/src/libauth/auth_respond.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/sys/src/libauth/auth_respond.c b/sys/src/libauth/auth_respond.c
index bc9fd2034..cab4446e0 100644
--- a/sys/src/libauth/auth_respond.c
+++ b/sys/src/libauth/auth_respond.c
@@ -22,11 +22,11 @@ dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
}
}
-int
-auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp, AuthGetkey *getkey, char *fmt, ...)
+static int
+dorespond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp,
+ AuthInfo **ai, AuthGetkey *getkey, char *fmt, va_list arg)
{
char *p, *s;
- va_list arg;
int afd;
AuthRpc *rpc;
Attr *a;
@@ -40,11 +40,8 @@ auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nr
}
quotefmtinstall(); /* just in case */
- va_start(arg, fmt);
- p = vsmprint(fmt, arg);
- va_end(arg);
-
- if(p==nil
+
+ if((p = vsmprint(fmt, arg))==nil
|| dorpc(rpc, "start", p, strlen(p), getkey) != ARok
|| dorpc(rpc, "write", chal, nchal, getkey) != ARok
|| dorpc(rpc, "read", nil, 0, getkey) != ARok){
@@ -59,6 +56,9 @@ auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nr
nresp = rpc->narg;
memmove(resp, rpc->arg, nresp);
+ if(ai != nil)
+ *ai = auth_getinfo(rpc);
+
if((a = auth_attr(rpc)) != nil
&& (s = _strfindattr(a, "user")) != nil && strlen(s) < nuser)
strcpy(user, s);
@@ -70,3 +70,29 @@ auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nr
auth_freerpc(rpc);
return nresp;
}
+
+int
+auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp,
+ AuthGetkey *getkey, char *fmt, ...)
+{
+ va_list arg;
+ int ret;
+
+ va_start(arg, fmt);
+ ret = dorespond(chal, nchal, user, nuser, resp, nresp, nil, getkey, fmt, arg);
+ va_end(arg);
+ return ret;
+}
+
+int
+auth_respondAI(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp,
+ AuthInfo **ai, AuthGetkey *getkey, char *fmt, ...)
+{
+ va_list arg;
+ int ret;
+
+ va_start(arg, fmt);
+ ret = dorespond(chal, nchal, user, nuser, resp, nresp, ai, getkey, fmt, arg);
+ va_end(arg);
+ return ret;
+}