libauth: add auth_respondAI() function to get AuthInfo for mschap/mschapv2
This commit is contained in:
parent
a7974d96b7
commit
3004f058f6
4 changed files with 58 additions and 11 deletions
|
@ -135,7 +135,8 @@ extern void auth_freeAI(AuthInfo *ai);
|
||||||
extern int auth_chuid(AuthInfo *ai, char *ns);
|
extern int auth_chuid(AuthInfo *ai, char *ns);
|
||||||
extern Chalstate *auth_challenge(char*, ...);
|
extern Chalstate *auth_challenge(char*, ...);
|
||||||
extern AuthInfo* auth_response(Chalstate*);
|
extern AuthInfo* auth_response(Chalstate*);
|
||||||
extern int auth_respond(void*, uint, char*, uint, void*, uint, AuthGetkey *getkey, char*, ...);
|
extern int auth_respond(void*, uint, char*, uint, void*, uint, AuthGetkey*, char*, ...);
|
||||||
|
extern int auth_respondAI(void *, uint, char*, uint, void*, uint, AuthInfo**, AuthGetkey*, char*, ...);
|
||||||
extern void auth_freechal(Chalstate*);
|
extern void auth_freechal(Chalstate*);
|
||||||
extern AuthInfo* auth_userpasswd(char *user, char *passwd);
|
extern AuthInfo* auth_userpasswd(char *user, char *passwd);
|
||||||
extern UserPasswd* auth_getuserpasswd(AuthGetkey *getkey, char*, ...);
|
extern UserPasswd* auth_getuserpasswd(AuthGetkey *getkey, char*, ...);
|
||||||
|
@ -147,6 +148,7 @@ extern uint auth_rpc(AuthRpc *rpc, char *verb, void *a, int n);
|
||||||
#pragma varargck argpos auth_proxy 3
|
#pragma varargck argpos auth_proxy 3
|
||||||
#pragma varargck argpos auth_challenge 1
|
#pragma varargck argpos auth_challenge 1
|
||||||
#pragma varargck argpos auth_respond 8
|
#pragma varargck argpos auth_respond 8
|
||||||
|
#pragma varargck argpos auth_respondAI 9
|
||||||
#pragma varargck argpos auth_getuserpasswd 2
|
#pragma varargck argpos auth_getuserpasswd 2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -125,7 +125,8 @@ extern void auth_freeAI(AuthInfo *ai);
|
||||||
extern int auth_chuid(AuthInfo *ai, char *ns);
|
extern int auth_chuid(AuthInfo *ai, char *ns);
|
||||||
extern Chalstate *auth_challenge(char*, ...);
|
extern Chalstate *auth_challenge(char*, ...);
|
||||||
extern AuthInfo* auth_response(Chalstate*);
|
extern AuthInfo* auth_response(Chalstate*);
|
||||||
extern int auth_respond(void*, uint, char*, uint, void*, uint, AuthGetkey *getkey, char*, ...);
|
extern int auth_respond(void*, uint, char*, uint, void*, uint, AuthGetkey*, char*, ...);
|
||||||
|
extern int auth_respondAI(void *, uint, char*, uint, void*, uint, AuthInfo**, AuthGetkey*, char*, ...);
|
||||||
extern void auth_freechal(Chalstate*);
|
extern void auth_freechal(Chalstate*);
|
||||||
extern AuthInfo* auth_userpasswd(char *user, char *passwd);
|
extern AuthInfo* auth_userpasswd(char *user, char *passwd);
|
||||||
extern UserPasswd* auth_getuserpasswd(AuthGetkey *getkey, char*, ...);
|
extern UserPasswd* auth_getuserpasswd(AuthGetkey *getkey, char*, ...);
|
||||||
|
@ -137,4 +138,5 @@ extern uint auth_rpc(AuthRpc *rpc, char *verb, void *a, int n);
|
||||||
#pragma varargck argpos auth_proxy 3
|
#pragma varargck argpos auth_proxy 3
|
||||||
#pragma varargck argpos auth_challenge 1
|
#pragma varargck argpos auth_challenge 1
|
||||||
#pragma varargck argpos auth_respond 8
|
#pragma varargck argpos auth_respond 8
|
||||||
|
#pragma varargck argpos auth_respondAI 9
|
||||||
#pragma varargck argpos auth_getuserpasswd 2
|
#pragma varargck argpos auth_getuserpasswd 2
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.TH AUTH 2
|
.TH AUTH 2
|
||||||
.SH NAME
|
.SH NAME
|
||||||
amount, newns, addns, login, noworld, auth_proxy, fauth_proxy, auth_allocrpc, auth_freerpc, auth_rpc, auth_getkey, amount_getkey, auth_freeAI, auth_chuid, auth_challenge, auth_response, auth_freechal, auth_respond, auth_userpasswd, auth_getuserpasswd, auth_getinfo \- routines for authenticating users
|
amount, newns, addns, login, noworld, auth_proxy, fauth_proxy, auth_allocrpc, auth_freerpc, auth_rpc, auth_getkey, amount_getkey, auth_freeAI, auth_chuid, auth_challenge, auth_response, auth_freechal, auth_respond, auth_respondAI, auth_userpasswd, auth_getuserpasswd, auth_getinfo \- routines for authenticating users
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.nf
|
.nf
|
||||||
.PP
|
.PP
|
||||||
|
@ -68,6 +68,9 @@ void auth_freechal(Chalstate*);
|
||||||
int auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp, AuthGetkey *getkey, char *fmt, ...);
|
int auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp, AuthGetkey *getkey, char *fmt, ...);
|
||||||
.PP
|
.PP
|
||||||
.B
|
.B
|
||||||
|
int auth_respondAI(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp, AuthInfo **ai, AuthGetkey *getkey, char *fmt, ...);
|
||||||
|
.PP
|
||||||
|
.B
|
||||||
AuthInfo* auth_userpasswd(char*user, char*password);
|
AuthInfo* auth_userpasswd(char*user, char*password);
|
||||||
.PP
|
.PP
|
||||||
.B
|
.B
|
||||||
|
@ -350,6 +353,20 @@ and it will use
|
||||||
.I factotum
|
.I factotum
|
||||||
to return the proper user and response.
|
to return the proper user and response.
|
||||||
.PP
|
.PP
|
||||||
|
.I Auth_respondAI
|
||||||
|
is like
|
||||||
|
.I auth_respond
|
||||||
|
but has an additional
|
||||||
|
.I ai
|
||||||
|
output parameter to return an
|
||||||
|
.I AuthInfo
|
||||||
|
structure on success that holds protocol specific secret keys
|
||||||
|
derived from the exchange. The returned
|
||||||
|
.I AuthInfo
|
||||||
|
structure should be freed with
|
||||||
|
.I auth_freeAI
|
||||||
|
by the caller.
|
||||||
|
.PP
|
||||||
.I Auth_userpasswd
|
.I Auth_userpasswd
|
||||||
verifies a simple user/password pair.
|
verifies a simple user/password pair.
|
||||||
.I Auth_getuserpasswd
|
.I Auth_getuserpasswd
|
||||||
|
|
|
@ -22,11 +22,11 @@ dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp, AuthGetkey *getkey, char *fmt, ...)
|
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;
|
char *p, *s;
|
||||||
va_list arg;
|
|
||||||
int afd;
|
int afd;
|
||||||
AuthRpc *rpc;
|
AuthRpc *rpc;
|
||||||
Attr *a;
|
Attr *a;
|
||||||
|
@ -40,11 +40,8 @@ auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nr
|
||||||
}
|
}
|
||||||
|
|
||||||
quotefmtinstall(); /* just in case */
|
quotefmtinstall(); /* just in case */
|
||||||
va_start(arg, fmt);
|
|
||||||
p = vsmprint(fmt, arg);
|
if((p = vsmprint(fmt, arg))==nil
|
||||||
va_end(arg);
|
|
||||||
|
|
||||||
if(p==nil
|
|
||||||
|| dorpc(rpc, "start", p, strlen(p), getkey) != ARok
|
|| dorpc(rpc, "start", p, strlen(p), getkey) != ARok
|
||||||
|| dorpc(rpc, "write", chal, nchal, getkey) != ARok
|
|| dorpc(rpc, "write", chal, nchal, getkey) != ARok
|
||||||
|| dorpc(rpc, "read", nil, 0, 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;
|
nresp = rpc->narg;
|
||||||
memmove(resp, rpc->arg, nresp);
|
memmove(resp, rpc->arg, nresp);
|
||||||
|
|
||||||
|
if(ai != nil)
|
||||||
|
*ai = auth_getinfo(rpc);
|
||||||
|
|
||||||
if((a = auth_attr(rpc)) != nil
|
if((a = auth_attr(rpc)) != nil
|
||||||
&& (s = _strfindattr(a, "user")) != nil && strlen(s) < nuser)
|
&& (s = _strfindattr(a, "user")) != nil && strlen(s) < nuser)
|
||||||
strcpy(user, s);
|
strcpy(user, s);
|
||||||
|
@ -70,3 +70,29 @@ auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nr
|
||||||
auth_freerpc(rpc);
|
auth_freerpc(rpc);
|
||||||
return nresp;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue