]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libauth/auth_userpasswd.c
audiohda: fix syntax error
[plan9front.git] / sys / src / libauth / auth_userpasswd.c
1 #include <u.h>
2 #include <libc.h>
3 #include <auth.h>
4 #include "authlocal.h"
5
6 AuthInfo*
7 auth_userpasswd(char *user, char *passwd)
8 {
9         AuthRpc *rpc;
10         AuthInfo *ai;
11         char *s;
12         int afd;
13
14         afd = open("/mnt/factotum/rpc", ORDWR|OCEXEC);
15         if(afd < 0)
16                 return nil;
17         ai = nil;
18         rpc = auth_allocrpc(afd);
19         if(rpc == nil)
20                 goto Out;
21         s = "proto=dp9ik role=login";
22         if(auth_rpc(rpc, "start", s, strlen(s)) != ARok){
23                 s = "proto=p9sk1 role=login";
24                 if(auth_rpc(rpc, "start", s, strlen(s)) != ARok)
25                         goto Out;
26         }
27         if(auth_rpc(rpc, "write", user, strlen(user)) != ARok
28         || auth_rpc(rpc, "write", passwd, strlen(passwd)) != ARok)
29                 goto Out;
30         ai = auth_getinfo(rpc);
31 Out:
32         if(rpc != nil)
33                 auth_freerpc(rpc);
34         close(afd);
35         return ai;
36 }