summaryrefslogtreecommitdiff
path: root/man/2/factotum
blob: b13062aafd1bf6bee2133c0ed1eee0176557df2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.TH FACTOTUM 2
.SH NAME
Factotum: mount, proxy, rpc \- client interface to factotum
.SH SYNOPSIS
.EX
include "factotum.m";
auth := load Factotum Factotum->PATH;

Authinfo: adt{
    cuid: string;    # ID on caller
    suid: string;    # ID on server
    cap:  string;    # capability (only valid on server side)
    secret: array of byte;   # key for encryption
};

AuthRpcMax: con \fR...\fP;

init:          fn();
mount:  fn(fd: ref Sys->FD, mnt: string, flags: int, aname: string):
            (int, ref Authinfo);
getuserpasswd:	fn(keyspec: string): (string, string);
rpc:    fn(facfd: ref Sys->FD, verb: string, a: array of byte):
            (string, array of byte);
proxy:  fn(afd: ref Sys->FD, facfd: ref Sys->FD, arg: string):
            ref Authinfo;
.EE
.SH DESCRIPTION
.B Factotum
interacts with an instance of the authentication agent
.IR factotum (4)
to authenticate a client to a server.
It can also interact with Plan 9's
.I factotum
if that is in the name space (as well as or instead of
.IR factotum (4)).
.PP
.B Init
must be called before any other function.
.PP
.B Mount
is similar to
.B Sys->mount
(see
.IR sys-bind (1)),
but uses
.I factotum
to authenticate,
if the server requires it.
.B Factotum->mount
should be used instead of
.B Sys->mount
when mounting file servers that use
.IR auth (5)
to authenticate.
(If the server on
.I fd
does not require authentication,
.B Factotum->mount
simply calls
.BR Sys->mount .)
.B Mount
returns
.RI ( v , ai ).
If the integer
.I v
is non-negative, the mount succeeded;
on error,
.I v
is negative, either the authentication or the mount failed,
.I ai
is nil, and the system error string contains a diagnostic.
If the server required authentication and that was successful,
.I ai
is a non-nil reference to an
.B Authinfo
value containing the agreed user IDs, a capability for
.IR cap (3)
that is valid only on the server, and an array of bytes
containing a shared secret that can be used by client
and server to create encryption and hashing keys for the conversation.
.PP
.B Getuserpasswd
returns a tuple
.RI ( user , password )
containing the values for the
.B user
and
.B !password
attributes of a factotum entry that has
.B proto=pass
and matches the given
.IR keyspec .
The tuple values are nil if no entry matches or the caller lacks permission to see them.
.PP
.B Proxy
links an authenticating server on
.I afd
with the
.I factotum
agent on
.IR facfd .
Typically
.I facfd
is the result of
.IP
.EX
sys->open("/mnt/factotum/rpc", Sys->ORDWR)
.EE
.PP
.I Afd
is typically the result of
.IR sys-open (2),
.IR sys-dial (2),
or
.IR sys-fauth (2).
.I Params
gives any parameters for
.IR factotum ,
as a string containing space-separated
.IB attr = value
pairs.
.B Proxy
ferries messages between the server and
.I factotum
until the end of the selected authentication protocol.
If authentication failed,
.B proxy
returns nil; otherwise on success it always returns a non-nil reference to an
.B Authinfo
value with contents as above, but if the protocol does not
supply that authentication data, all the values are nil.
.PP
.B Rpc
does one message exchange with the
.I factotum
on
.IR facfd .
It writes a message containing the given
.I verb
and optional binary parameter
.IR a ,
and returns
.RI ( v , a )
where
.I v
is the response string from
.I factotum
and
.I a
is an optional binary parameter for that response.
Exceptionally,
.I v
is the string
\f5"rpc failure"\fP
if communication fails or a message is garbled, or
\f5"no key"\fP
if
.B rpc
cannot find a suitable key.
See
.IR factotum (4)
for details of the protocol.
.PP
.B AuthRpcMax
is an integer constant giving the maximum size of a message in an
.B rpc
exchange.
.SH SOURCE
.B /appl/lib/factotum.b
.SH SEE ALSO
.IR sys-bind (2),
.IR sys-fauth (2),
.IR factotum (4),
.IR auth (5)