xref: /freebsd/crypto/heimdal/lib/kafs/kafs.3 (revision 6a068746777241722b2b32c5d0bc443a2a64d80b)
1*ae771770SStanislav Sedov.\" Copyright (c) 1998 - 2006 Kungliga Tekniska Högskolan
2bbd80c28SJacques Vidrine.\" (Royal Institute of Technology, Stockholm, Sweden).
3bbd80c28SJacques Vidrine.\" All rights reserved.
4b528cefcSMark Murray.\"
5bbd80c28SJacques Vidrine.\" Redistribution and use in source and binary forms, with or without
6bbd80c28SJacques Vidrine.\" modification, are permitted provided that the following conditions
7bbd80c28SJacques Vidrine.\" are met:
8bbd80c28SJacques Vidrine.\"
9bbd80c28SJacques Vidrine.\" 1. Redistributions of source code must retain the above copyright
10bbd80c28SJacques Vidrine.\"    notice, this list of conditions and the following disclaimer.
11bbd80c28SJacques Vidrine.\"
12bbd80c28SJacques Vidrine.\" 2. Redistributions in binary form must reproduce the above copyright
13bbd80c28SJacques Vidrine.\"    notice, this list of conditions and the following disclaimer in the
14bbd80c28SJacques Vidrine.\"    documentation and/or other materials provided with the distribution.
15bbd80c28SJacques Vidrine.\"
16bbd80c28SJacques Vidrine.\" 3. Neither the name of the Institute nor the names of its contributors
17bbd80c28SJacques Vidrine.\"    may be used to endorse or promote products derived from this software
18bbd80c28SJacques Vidrine.\"    without specific prior written permission.
19bbd80c28SJacques Vidrine.\"
20bbd80c28SJacques Vidrine.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
21bbd80c28SJacques Vidrine.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22bbd80c28SJacques Vidrine.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23bbd80c28SJacques Vidrine.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
24bbd80c28SJacques Vidrine.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25bbd80c28SJacques Vidrine.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26bbd80c28SJacques Vidrine.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27bbd80c28SJacques Vidrine.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28bbd80c28SJacques Vidrine.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29bbd80c28SJacques Vidrine.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30bbd80c28SJacques Vidrine.\" SUCH DAMAGE.
31bbd80c28SJacques Vidrine.\"
32*ae771770SStanislav Sedov.\"	$Id$
33bbd80c28SJacques Vidrine.\"
34c19800e8SDoug Rabson.Dd May  1, 2006
35bbd80c28SJacques Vidrine.Os HEIMDAL
36b528cefcSMark Murray.Dt KAFS 3
37b528cefcSMark Murray.Sh NAME
38b528cefcSMark Murray.Nm k_hasafs ,
39c19800e8SDoug Rabson.Nm k_hasafs_recheck ,
40b528cefcSMark Murray.Nm k_pioctl ,
41b528cefcSMark Murray.Nm k_unlog ,
42b528cefcSMark Murray.Nm k_setpag ,
43b528cefcSMark Murray.Nm k_afs_cell_of_file ,
44bbd80c28SJacques Vidrine.Nm kafs_set_verbose ,
45bbd80c28SJacques Vidrine.Nm kafs_settoken_rxkad ,
46bbd80c28SJacques Vidrine.Nm kafs_settoken ,
47b528cefcSMark Murray.Nm krb_afslog ,
48c19800e8SDoug Rabson.Nm krb_afslog_uid ,
49bbd80c28SJacques Vidrine.Nm kafs_settoken5 ,
50bbd80c28SJacques Vidrine.Nm krb5_afslog ,
51bbd80c28SJacques Vidrine.Nm krb5_afslog_uid
52b528cefcSMark Murray.Nd AFS library
538373020dSJacques Vidrine.Sh LIBRARY
548373020dSJacques VidrineAFS cache manager access library (libkafs, -lkafs)
55b528cefcSMark Murray.Sh SYNOPSIS
56bbd80c28SJacques Vidrine.In kafs.h
57b528cefcSMark Murray.Ft int
58b528cefcSMark Murray.Fn k_afs_cell_of_file "const char *path" "char *cell" "int len"
59b528cefcSMark Murray.Ft int
60bbd80c28SJacques Vidrine.Fn k_hasafs "void"
61b528cefcSMark Murray.Ft int
62c19800e8SDoug Rabson.Fn k_hasafs_recheck "void"
63c19800e8SDoug Rabson.Ft int
64b528cefcSMark Murray.Fn k_pioctl "char *a_path" "int o_opcode" "struct ViceIoctl *a_paramsP" "int a_followSymlinks"
65b528cefcSMark Murray.Ft int
66bbd80c28SJacques Vidrine.Fn k_setpag "void"
67b528cefcSMark Murray.Ft int
68bbd80c28SJacques Vidrine.Fn k_unlog "void"
69bbd80c28SJacques Vidrine.Ft void
70bbd80c28SJacques Vidrine.Fn kafs_set_verbose "void (*func)(void *, const char *, int)" "void *"
71b528cefcSMark Murray.Ft int
72bbd80c28SJacques Vidrine.Fn kafs_settoken_rxkad "const char *cell" "struct ClearToken *token" "void *ticket" "size_t ticket_len"
73bbd80c28SJacques Vidrine.Ft int
74bbd80c28SJacques Vidrine.Fn kafs_settoken "const char *cell" "uid_t uid" "CREDENTIALS *c"
75b528cefcSMark Murray.Fn krb_afslog "char *cell" "char *realm"
76b528cefcSMark Murray.Ft int
77b528cefcSMark Murray.Fn krb_afslog_uid "char *cell" "char *realm" "uid_t uid"
78bbd80c28SJacques Vidrine.Ft krb5_error_code
79bbd80c28SJacques Vidrine.Fn krb5_afslog_uid "krb5_context context" "krb5_ccache id" "const char *cell" "krb5_const_realm realm" "uid_t uid"
80bbd80c28SJacques Vidrine.Ft int
81bbd80c28SJacques Vidrine.Fn kafs_settoken5 "const char *cell" "uid_t uid" "krb5_creds *c"
82bbd80c28SJacques Vidrine.Ft krb5_error_code
83bbd80c28SJacques Vidrine.Fn krb5_afslog "krb5_context context" "krb5_ccache id" "const char *cell" "krb5_const_realm realm"
84b528cefcSMark Murray.Sh DESCRIPTION
85b528cefcSMark Murray.Fn k_hasafs
86b528cefcSMark Murrayinitializes some library internal structures, and tests for the
874137ff4cSJacques Vidrinepresence of AFS in the kernel, none of the other functions should be
88b528cefcSMark Murraycalled before
89b528cefcSMark Murray.Fn k_hasafs
90b528cefcSMark Murrayis called, or if it fails.
915e9cd1aeSAssar Westerlund.Pp
92c19800e8SDoug Rabson.Fn k_hasafs_recheck
93c19800e8SDoug Rabsonforces a recheck if a AFS client has started since last time
94c19800e8SDoug Rabson.Fn k_hasafs
95c19800e8SDoug Rabsonor
96c19800e8SDoug Rabson.Fn k_hasafs_recheck
97c19800e8SDoug Rabsonwas called.
98c19800e8SDoug Rabson.Pp
99bbd80c28SJacques Vidrine.Fn kafs_set_verbose
100bbd80c28SJacques Vidrineset a log function that will be called each time the kafs library does
101bbd80c28SJacques Vidrinesomething important so that the application using libkafs can output
102bbd80c28SJacques Vidrineverbose logging.
103bbd80c28SJacques VidrineCalling the function
104bbd80c28SJacques Vidrine.Fa kafs_set_verbose
105bbd80c28SJacques Vidrinewith the function argument set to
106bbd80c28SJacques Vidrine.Dv NULL
107bbd80c28SJacques Vidrinewill stop libkafs from calling the logging function (if set).
108bbd80c28SJacques Vidrine.Pp
109bbd80c28SJacques Vidrine.Fn kafs_settoken_rxkad
110bbd80c28SJacques Vidrineset
111bbd80c28SJacques Vidrine.Li rxkad
112bbd80c28SJacques Vidrinewith the
113bbd80c28SJacques Vidrine.Fa token
114bbd80c28SJacques Vidrineand
115bbd80c28SJacques Vidrine.Fa ticket
116bbd80c28SJacques Vidrine(that have the length
117bbd80c28SJacques Vidrine.Fa ticket_len )
118bbd80c28SJacques Vidrinefor a given
119bbd80c28SJacques Vidrine.Fa cell .
120bbd80c28SJacques Vidrine.Pp
121bbd80c28SJacques Vidrine.Fn kafs_settoken
122bbd80c28SJacques Vidrineand
123bbd80c28SJacques Vidrine.Fn kafs_settoken5
124bbd80c28SJacques Vidrinework the same way as
125bbd80c28SJacques Vidrine.Fn kafs_settoken_rxkad
126bbd80c28SJacques Vidrinebut internally converts the Kerberos 4 or 5 credential to a afs
127bbd80c28SJacques Vidrinecleartoken and ticket.
128bbd80c28SJacques Vidrine.Pp
129b528cefcSMark Murray.Fn krb_afslog ,
130b528cefcSMark Murrayand
131b528cefcSMark Murray.Fn krb_afslog_uid
132b528cefcSMark Murrayobtains new tokens (and possibly tickets) for the specified
133b528cefcSMark Murray.Fa cell
134b528cefcSMark Murrayand
135b528cefcSMark Murray.Fa realm .
136b528cefcSMark MurrayIf
137b528cefcSMark Murray.Fa cell
138b528cefcSMark Murrayis
139b528cefcSMark Murray.Dv NULL ,
140b528cefcSMark Murraythe local cell is used. If
141b528cefcSMark Murray.Fa realm
142b528cefcSMark Murrayis
143b528cefcSMark Murray.Dv NULL ,
144b528cefcSMark Murraythe function tries to guess what realm to use. Unless you  have some good knowledge of what cell or realm to use, you should pass
145b528cefcSMark Murray.Dv NULL .
146b528cefcSMark Murray.Fn krb_afslog
147b528cefcSMark Murraywill use the real user-id for the
148b528cefcSMark Murray.Dv ViceId
149b528cefcSMark Murrayfield in the token,
150b528cefcSMark Murray.Fn krb_afslog_uid
151b528cefcSMark Murraywill use
152b528cefcSMark Murray.Fa uid .
1535e9cd1aeSAssar Westerlund.Pp
154bbd80c28SJacques Vidrine.Fn krb5_afslog ,
155bbd80c28SJacques Vidrineand
156bbd80c28SJacques Vidrine.Fn krb5_afslog_uid
157bbd80c28SJacques Vidrineare the Kerberos 5 equivalents of
158bbd80c28SJacques Vidrine.Fn krb_afslog ,
159bbd80c28SJacques Vidrineand
160bbd80c28SJacques Vidrine.Fn krb_afslog_uid .
161bbd80c28SJacques Vidrine.Pp
162bbd80c28SJacques Vidrine.Fn krb5_afslog ,
163bbd80c28SJacques Vidrine.Fn kafs_settoken5
164c19800e8SDoug Rabsoncan be configured to behave differently via a
165bbd80c28SJacques Vidrine.Nm krb5_appdefault
166bbd80c28SJacques Vidrineoption
167bbd80c28SJacques Vidrine.Li afs-use-524
168bbd80c28SJacques Vidrinein
169bbd80c28SJacques Vidrine.Pa krb5.conf .
170bbd80c28SJacques VidrinePossible values for
171bbd80c28SJacques Vidrine.Li afs-use-524
172bbd80c28SJacques Vidrineare:
173bbd80c28SJacques Vidrine.Bl -tag -width local
174bbd80c28SJacques Vidrine.It yes
175bbd80c28SJacques Vidrineuse the 524 server in the realm to convert the ticket
176bbd80c28SJacques Vidrine.It no
177bbd80c28SJacques Vidrineuse the Kerberos 5 ticket directly, can be used with if the afs cell
178bbd80c28SJacques Vidrinesupport 2b token.
179bbd80c28SJacques Vidrine.It local, 2b
180bbd80c28SJacques Vidrineconvert the Kerberos 5 credential to a 2b token locally (the same work
181bbd80c28SJacques Vidrineas a 2b 524 server should have done).
182bbd80c28SJacques Vidrine.El
183bbd80c28SJacques Vidrine.Pp
184bbd80c28SJacques VidrineExample:
185bbd80c28SJacques Vidrine.Pp
186bbd80c28SJacques Vidrine.Bd -literal
187bbd80c28SJacques Vidrine[appdefaults]
188bbd80c28SJacques Vidrine	SU.SE = { afs-use-524 = local }
189bbd80c28SJacques Vidrine	PDC.KTH.SE = { afs-use-524 = yes }
190bbd80c28SJacques Vidrine	afs-use-524 = yes
191bbd80c28SJacques Vidrine.Ed
192bbd80c28SJacques Vidrine.Pp
193bbd80c28SJacques Vidrinelibkafs will use the
194bbd80c28SJacques Vidrine.Li libkafs
195bbd80c28SJacques Vidrineas application name when running the
196bbd80c28SJacques Vidrine.Nm krb5_appdefault
197bbd80c28SJacques Vidrinefunction call.
198bbd80c28SJacques Vidrine.Pp
199bbd80c28SJacques VidrineThe (uppercased) cell name is used as the realm to the
200bbd80c28SJacques Vidrine.Nm krb5_appdefault function.
201bbd80c28SJacques Vidrine.Pp
2025e9cd1aeSAssar Westerlund.\" The extra arguments are the ubiquitous context, and the cache id where
2035e9cd1aeSAssar Westerlund.\" to store any obtained tickets. Since AFS servers normally can't handle
2045e9cd1aeSAssar Westerlund.\" Kerberos 5 tickets directly, these functions will first obtain version
2055e9cd1aeSAssar Westerlund.\" 5 tickets for the requested cells, and then convert them to version 4
2065e9cd1aeSAssar Westerlund.\" tickets, that can be stashed in the kernel. To convert tickets the
2075e9cd1aeSAssar Westerlund.\" .Fn krb524_convert_creds_kdc
2085e9cd1aeSAssar Westerlund.\" function will be used.
2095e9cd1aeSAssar Westerlund.\" .Pp
210b528cefcSMark Murray.Fn k_afs_cell_of_file
211b528cefcSMark Murraywill in
212b528cefcSMark Murray.Fa cell
213b528cefcSMark Murrayreturn the cell of a specified file, no more than
214b528cefcSMark Murray.Fa len
215b528cefcSMark Murraycharacters is put in
216b528cefcSMark Murray.Fa cell .
2175e9cd1aeSAssar Westerlund.Pp
218b528cefcSMark Murray.Fn k_pioctl
219b528cefcSMark Murraydoes a
220b528cefcSMark Murray.Fn pioctl
221c19800e8SDoug Rabsonsystem call with the specified arguments. This function is equivalent to
222b528cefcSMark Murray.Fn lpioctl .
2235e9cd1aeSAssar Westerlund.Pp
224b528cefcSMark Murray.Fn k_setpag
225b528cefcSMark Murrayinitializes a new PAG.
2265e9cd1aeSAssar Westerlund.Pp
227b528cefcSMark Murray.Fn k_unlog
228b528cefcSMark Murrayremoves destroys all tokens in the current PAG.
229b528cefcSMark Murray.Sh RETURN VALUES
230b528cefcSMark Murray.Fn k_hasafs
231b528cefcSMark Murrayreturns 1 if AFS is present in the kernel, 0 otherwise.
232b528cefcSMark Murray.Fn krb_afslog
233b528cefcSMark Murrayand
234b528cefcSMark Murray.Fn krb_afslog_uid
235bbd80c28SJacques Vidrinereturns 0 on success, or a Kerberos error number on failure.
236b528cefcSMark Murray.Fn k_afs_cell_of_file ,
237b528cefcSMark Murray.Fn k_pioctl ,
238b528cefcSMark Murray.Fn k_setpag ,
239b528cefcSMark Murrayand
240b528cefcSMark Murray.Fn k_unlog
241b528cefcSMark Murrayall return the value of the underlaying system call, 0 on success.
2428373020dSJacques Vidrine.Sh ENVIRONMENT
2438373020dSJacques VidrineThe following environment variable affect the mode of operation of
2448373020dSJacques Vidrine.Nm kafs :
2458373020dSJacques Vidrine.Bl -tag -width AFS_SYSCALL
2468373020dSJacques Vidrine.It Ev AFS_SYSCALL
2478373020dSJacques VidrineNormally,
2488373020dSJacques Vidrine.Nm kafs
2498373020dSJacques Vidrinewill try to figure out the correct system call(s) that are used by AFS
2508373020dSJacques Vidrineby itself.  If it does not manage to do that, or does it incorrectly,
2518373020dSJacques Vidrineyou can set this variable to the system call number or list of system
2528373020dSJacques Vidrinecall numbers that should be used.
2538373020dSJacques Vidrine.El
254b528cefcSMark Murray.Sh EXAMPLES
255b528cefcSMark MurrayThe following code from
256b528cefcSMark Murray.Nm login
257b528cefcSMark Murraywill obtain a new PAG and tokens for the local cell and the cell of
258b528cefcSMark Murraythe users home directory.
259b528cefcSMark Murray.Bd -literal
260b528cefcSMark Murrayif (k_hasafs()) {
261b528cefcSMark Murray	char cell[64];
262b528cefcSMark Murray	k_setpag();
263b528cefcSMark Murray	if(k_afs_cell_of_file(pwd->pw_dir, cell, sizeof(cell)) == 0)
264b528cefcSMark Murray		krb_afslog(cell, NULL);
265b528cefcSMark Murray	krb_afslog(NULL, NULL);
266b528cefcSMark Murray}
267b528cefcSMark Murray.Ed
268b528cefcSMark Murray.Sh ERRORS
2694137ff4cSJacques VidrineIf any of these functions (apart from
270b528cefcSMark Murray.Fn k_hasafs )
271bbd80c28SJacques Vidrineis called without AFS being present in the kernel, the process will
272b528cefcSMark Murrayusually (depending on the operating system) receive a SIGSYS signal.
273b528cefcSMark Murray.Sh SEE ALSO
274c19800e8SDoug Rabson.Xr krb5_appdefault 3 ,
275c19800e8SDoug Rabson.Xr krb5.conf 5
276b528cefcSMark Murray.Rs
277b528cefcSMark Murray.%A Transarc Corporation
278b528cefcSMark Murray.%J AFS-3 Programmer's Reference
279b528cefcSMark Murray.%T File Server/Cache Manager Interface
280b528cefcSMark Murray.%D 1991
281b528cefcSMark Murray.Re
282*ae771770SStanislav Sedov.Sh FILES
283*ae771770SStanislav Sedovlibkafs will search for
284*ae771770SStanislav Sedov.Pa ThisCell and
285*ae771770SStanislav Sedov.Pa TheseCells
286*ae771770SStanislav Sedovin the following locations:
287*ae771770SStanislav Sedov.Pa /usr/vice/etc ,
288*ae771770SStanislav Sedov.Pa /etc/openafs ,
289*ae771770SStanislav Sedov.Pa /var/db/openafs/etc ,
290*ae771770SStanislav Sedov.Pa /usr/arla/etc ,
291*ae771770SStanislav Sedov.Pa /etc/arla ,
292*ae771770SStanislav Sedovand
293*ae771770SStanislav Sedov.Pa /etc/afs
294b528cefcSMark Murray.Sh BUGS
295b528cefcSMark Murray.Ev AFS_SYSCALL
296b528cefcSMark Murrayhas no effect under AIX.
297