]> git.lizzy.rs Git - plan9front.git/blob - sys/include/auth.h
upas/fs plumb modify messages for self-changed flags
[plan9front.git] / sys / include / auth.h
1 #pragma src     "/sys/src/libauth"
2 #pragma lib     "libauth.a"
3
4 /*
5  * Interface for typical callers.
6  */
7
8 typedef struct  AuthInfo        AuthInfo;
9 typedef struct  Chalstate       Chalstate;
10 typedef struct  Chapreply       Chapreply;
11 typedef struct  MSchapreply     MSchapreply;
12 typedef struct  UserPasswd      UserPasswd;
13 typedef struct  AuthRpc         AuthRpc;
14
15 enum
16 {
17         MAXCHLEN=       256,            /* max challenge length */
18         MAXNAMELEN=     256,            /* maximum name length */
19         MD5LEN=         16,
20
21         ARok = 0,                       /* rpc return values */
22         ARdone,
23         ARerror,
24         ARneedkey,
25         ARbadkey,
26         ARwritenext,
27         ARtoosmall,
28         ARtoobig,
29         ARrpcfailure,
30         ARphase,
31
32         AuthRpcMax = 4096,
33 };
34
35 struct AuthRpc
36 {
37         int afd;
38         char ibuf[AuthRpcMax+1];        /* +1 for NUL in auth_rpc.c */
39         char obuf[AuthRpcMax];
40         char *arg;
41         uint narg;
42 };
43
44 struct AuthInfo
45 {
46         char    *cuid;          /* caller id */
47         char    *suid;          /* server id */
48         char    *cap;           /* capability (only valid on server side) */
49         int     nsecret;        /* length of secret */
50         uchar   *secret;        /* secret */
51 };
52
53 struct Chalstate
54 {
55         char    *user;
56         char    *dom;
57         char    chal[MAXCHLEN];
58         int     nchal;
59         void    *resp;
60         int     nresp;
61
62 /* for implementation only */
63         int     afd;                    /* to factotum */
64         AuthRpc *rpc;                   /* to factotum */
65         char    userbuf[MAXNAMELEN];    /* temp space if needed */
66         int     userinchal;             /* user was sent to obtain challenge */
67 };
68
69 struct  Chapreply               /* for protocol "chap" */
70 {
71         uchar   id;
72         char    resp[MD5LEN];
73 };
74
75 struct  MSchapreply             /* for protocol "mschap" and "ntlm" */
76 {
77         char    LMresp[24];             /* Lan Manager response */
78         char    NTresp[24];             /* NT response */
79 };
80
81 struct  UserPasswd
82 {
83         char    *user;
84         char    *passwd;
85 };
86
87 extern  int     newns(char*, char*);
88 extern  int     addns(char*, char*);
89
90 extern  int     noworld(char*);
91 extern  int     amount(int, char*, int, char*);
92
93 extern  int     login(char*, char*, char*);
94
95 typedef struct Attr Attr;
96 enum {
97         AttrNameval,            /* name=val -- when matching, must have name=val */
98         AttrQuery,              /* name? -- when matching, must be present */
99         AttrDefault,            /* name=val -- when matching, if present must match INTERNAL */
100 };
101 struct Attr
102 {
103         int type;
104         Attr *next;
105         char *name;
106         char *val;
107 };
108
109 typedef int AuthGetkey(char*);
110
111 int     _attrfmt(Fmt*);
112 Attr    *_copyattr(Attr*);
113 Attr    *_delattr(Attr*, char*);
114 Attr    *_findattr(Attr*, char*);
115 void    _freeattr(Attr*);
116 Attr    *_mkattr(int, char*, char*, Attr*);
117 Attr    *_parseattr(char*);
118 char    *_strfindattr(Attr*, char*);
119 #pragma varargck type "A" Attr*
120
121 extern AuthInfo*        fauth_proxy(int, AuthRpc *rpc, AuthGetkey *getkey, char *params);
122 extern AuthInfo*        auth_proxy(int fd, AuthGetkey *getkey, char *fmt, ...);
123 extern int              auth_getkey(char*);
124 extern int              (*amount_getkey)(char*);
125 extern void             auth_freeAI(AuthInfo *ai);
126 extern int              auth_chuid(AuthInfo *ai, char *ns);
127 extern Chalstate        *auth_challenge(char*, ...);
128 extern AuthInfo*        auth_response(Chalstate*);
129 extern int              auth_respond(void*, uint, char*, uint, void*, uint, AuthGetkey*, char*, ...);
130 extern int              auth_respondAI(void *, uint, char*, uint, void*, uint, AuthInfo**, AuthGetkey*, char*, ...);
131 extern void             auth_freechal(Chalstate*);
132 extern AuthInfo*        auth_userpasswd(char *user, char *passwd);
133 extern UserPasswd*      auth_getuserpasswd(AuthGetkey *getkey, char*, ...);
134 extern AuthInfo*        auth_getinfo(AuthRpc *rpc);
135 extern AuthRpc*         auth_allocrpc(int afd);
136 extern Attr*            auth_attr(AuthRpc *rpc);
137 extern void             auth_freerpc(AuthRpc *rpc);
138 extern uint             auth_rpc(AuthRpc *rpc, char *verb, void *a, int n);
139 #pragma varargck argpos auth_proxy 3
140 #pragma varargck argpos auth_challenge 1
141 #pragma varargck argpos auth_respond 8
142 #pragma varargck argpos auth_respondAI 9
143 #pragma varargck argpos auth_getuserpasswd 2