1*0a6a1f1dSLionel Sambuc.\" $NetBSD: kafs.3,v 1.1.1.3 2014/04/24 12:45:49 pettai Exp $ 2ebfedea0SLionel Sambuc.\" 3ebfedea0SLionel Sambuc.\" Copyright (c) 1998 - 2006 Kungliga Tekniska Högskolan 4ebfedea0SLionel Sambuc.\" (Royal Institute of Technology, Stockholm, Sweden). 5ebfedea0SLionel Sambuc.\" All rights reserved. 6ebfedea0SLionel Sambuc.\" 7ebfedea0SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 8ebfedea0SLionel Sambuc.\" modification, are permitted provided that the following conditions 9ebfedea0SLionel Sambuc.\" are met: 10ebfedea0SLionel Sambuc.\" 11ebfedea0SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 12ebfedea0SLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 13ebfedea0SLionel Sambuc.\" 14ebfedea0SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 15ebfedea0SLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 16ebfedea0SLionel Sambuc.\" documentation and/or other materials provided with the distribution. 17ebfedea0SLionel Sambuc.\" 18ebfedea0SLionel Sambuc.\" 3. Neither the name of the Institute nor the names of its contributors 19ebfedea0SLionel Sambuc.\" may be used to endorse or promote products derived from this software 20ebfedea0SLionel Sambuc.\" without specific prior written permission. 21ebfedea0SLionel Sambuc.\" 22ebfedea0SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23ebfedea0SLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24ebfedea0SLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25ebfedea0SLionel Sambuc.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26ebfedea0SLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27ebfedea0SLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28ebfedea0SLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29ebfedea0SLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30ebfedea0SLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31ebfedea0SLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32ebfedea0SLionel Sambuc.\" SUCH DAMAGE. 33ebfedea0SLionel Sambuc.\" 34ebfedea0SLionel Sambuc.\" Id 35ebfedea0SLionel Sambuc.\" 36ebfedea0SLionel Sambuc.Dd May 1, 2006 37ebfedea0SLionel Sambuc.Os 38ebfedea0SLionel Sambuc.Dt KAFS 3 39ebfedea0SLionel Sambuc.Sh NAME 40ebfedea0SLionel Sambuc.Nm k_hasafs , 41ebfedea0SLionel Sambuc.Nm k_hasafs_recheck , 42ebfedea0SLionel Sambuc.Nm k_pioctl , 43ebfedea0SLionel Sambuc.Nm k_unlog , 44ebfedea0SLionel Sambuc.Nm k_setpag , 45ebfedea0SLionel Sambuc.Nm k_afs_cell_of_file , 46ebfedea0SLionel Sambuc.Nm kafs_set_verbose , 47ebfedea0SLionel Sambuc.Nm kafs_settoken_rxkad , 48ebfedea0SLionel Sambuc.Nm kafs_settoken , 49ebfedea0SLionel Sambuc.Nm krb_afslog , 50ebfedea0SLionel Sambuc.Nm krb_afslog_uid , 51ebfedea0SLionel Sambuc.Nm kafs_settoken5 , 52ebfedea0SLionel Sambuc.Nm krb5_afslog , 53ebfedea0SLionel Sambuc.Nm krb5_afslog_uid 54ebfedea0SLionel Sambuc.Nd AFS library 55ebfedea0SLionel Sambuc.Sh LIBRARY 56ebfedea0SLionel SambucAFS cache manager access library (libkafs, -lkafs) 57ebfedea0SLionel Sambuc.Sh SYNOPSIS 58ebfedea0SLionel Sambuc.In kafs.h 59ebfedea0SLionel Sambuc.Ft int 60ebfedea0SLionel Sambuc.Fn k_afs_cell_of_file "const char *path" "char *cell" "int len" 61ebfedea0SLionel Sambuc.Ft int 62ebfedea0SLionel Sambuc.Fn k_hasafs "void" 63ebfedea0SLionel Sambuc.Ft int 64ebfedea0SLionel Sambuc.Fn k_hasafs_recheck "void" 65ebfedea0SLionel Sambuc.Ft int 66ebfedea0SLionel Sambuc.Fn k_pioctl "char *a_path" "int o_opcode" "struct ViceIoctl *a_paramsP" "int a_followSymlinks" 67ebfedea0SLionel Sambuc.Ft int 68ebfedea0SLionel Sambuc.Fn k_setpag "void" 69ebfedea0SLionel Sambuc.Ft int 70ebfedea0SLionel Sambuc.Fn k_unlog "void" 71ebfedea0SLionel Sambuc.Ft void 72ebfedea0SLionel Sambuc.Fn kafs_set_verbose "void (*func)(void *, const char *, int)" "void *" 73ebfedea0SLionel Sambuc.Ft int 74ebfedea0SLionel Sambuc.Fn kafs_settoken_rxkad "const char *cell" "struct ClearToken *token" "void *ticket" "size_t ticket_len" 75ebfedea0SLionel Sambuc.Ft int 76ebfedea0SLionel Sambuc.Fn kafs_settoken "const char *cell" "uid_t uid" "CREDENTIALS *c" 77ebfedea0SLionel Sambuc.Fn krb_afslog "char *cell" "char *realm" 78ebfedea0SLionel Sambuc.Ft int 79ebfedea0SLionel Sambuc.Fn krb_afslog_uid "char *cell" "char *realm" "uid_t uid" 80ebfedea0SLionel Sambuc.Ft krb5_error_code 81ebfedea0SLionel Sambuc.Fn krb5_afslog_uid "krb5_context context" "krb5_ccache id" "const char *cell" "krb5_const_realm realm" "uid_t uid" 82ebfedea0SLionel Sambuc.Ft int 83ebfedea0SLionel Sambuc.Fn kafs_settoken5 "const char *cell" "uid_t uid" "krb5_creds *c" 84ebfedea0SLionel Sambuc.Ft krb5_error_code 85ebfedea0SLionel Sambuc.Fn krb5_afslog "krb5_context context" "krb5_ccache id" "const char *cell" "krb5_const_realm realm" 86ebfedea0SLionel Sambuc.Sh DESCRIPTION 87ebfedea0SLionel Sambuc.Fn k_hasafs 88ebfedea0SLionel Sambucinitializes some library internal structures, and tests for the 89ebfedea0SLionel Sambucpresence of AFS in the kernel, none of the other functions should be 90ebfedea0SLionel Sambuccalled before 91ebfedea0SLionel Sambuc.Fn k_hasafs 92ebfedea0SLionel Sambucis called, or if it fails. 93ebfedea0SLionel Sambuc.Pp 94ebfedea0SLionel Sambuc.Fn k_hasafs_recheck 95ebfedea0SLionel Sambucforces a recheck if a AFS client has started since last time 96ebfedea0SLionel Sambuc.Fn k_hasafs 97ebfedea0SLionel Sambucor 98ebfedea0SLionel Sambuc.Fn k_hasafs_recheck 99ebfedea0SLionel Sambucwas called. 100ebfedea0SLionel Sambuc.Pp 101ebfedea0SLionel Sambuc.Fn kafs_set_verbose 102ebfedea0SLionel Sambucset a log function that will be called each time the kafs library does 103ebfedea0SLionel Sambucsomething important so that the application using libkafs can output 104ebfedea0SLionel Sambucverbose logging. 105ebfedea0SLionel SambucCalling the function 106ebfedea0SLionel Sambuc.Fa kafs_set_verbose 107ebfedea0SLionel Sambucwith the function argument set to 108ebfedea0SLionel Sambuc.Dv NULL 109ebfedea0SLionel Sambucwill stop libkafs from calling the logging function (if set). 110ebfedea0SLionel Sambuc.Pp 111ebfedea0SLionel Sambuc.Fn kafs_settoken_rxkad 112ebfedea0SLionel Sambucset 113ebfedea0SLionel Sambuc.Li rxkad 114ebfedea0SLionel Sambucwith the 115ebfedea0SLionel Sambuc.Fa token 116ebfedea0SLionel Sambucand 117ebfedea0SLionel Sambuc.Fa ticket 118ebfedea0SLionel Sambuc(that have the length 119ebfedea0SLionel Sambuc.Fa ticket_len ) 120ebfedea0SLionel Sambucfor a given 121ebfedea0SLionel Sambuc.Fa cell . 122ebfedea0SLionel Sambuc.Pp 123ebfedea0SLionel Sambuc.Fn kafs_settoken 124ebfedea0SLionel Sambucand 125ebfedea0SLionel Sambuc.Fn kafs_settoken5 126ebfedea0SLionel Sambucwork the same way as 127ebfedea0SLionel Sambuc.Fn kafs_settoken_rxkad 128ebfedea0SLionel Sambucbut internally converts the Kerberos 4 or 5 credential to a afs 129ebfedea0SLionel Sambuccleartoken and ticket. 130ebfedea0SLionel Sambuc.Pp 131ebfedea0SLionel Sambuc.Fn krb_afslog , 132ebfedea0SLionel Sambucand 133ebfedea0SLionel Sambuc.Fn krb_afslog_uid 134ebfedea0SLionel Sambucobtains new tokens (and possibly tickets) for the specified 135ebfedea0SLionel Sambuc.Fa cell 136ebfedea0SLionel Sambucand 137ebfedea0SLionel Sambuc.Fa realm . 138ebfedea0SLionel SambucIf 139ebfedea0SLionel Sambuc.Fa cell 140ebfedea0SLionel Sambucis 141ebfedea0SLionel Sambuc.Dv NULL , 142ebfedea0SLionel Sambucthe local cell is used. If 143ebfedea0SLionel Sambuc.Fa realm 144ebfedea0SLionel Sambucis 145ebfedea0SLionel Sambuc.Dv NULL , 146ebfedea0SLionel Sambucthe function tries to guess what realm to use. Unless you have some good knowledge of what cell or realm to use, you should pass 147ebfedea0SLionel Sambuc.Dv NULL . 148ebfedea0SLionel Sambuc.Fn krb_afslog 149ebfedea0SLionel Sambucwill use the real user-id for the 150ebfedea0SLionel Sambuc.Dv ViceId 151ebfedea0SLionel Sambucfield in the token, 152ebfedea0SLionel Sambuc.Fn krb_afslog_uid 153ebfedea0SLionel Sambucwill use 154ebfedea0SLionel Sambuc.Fa uid . 155ebfedea0SLionel Sambuc.Pp 156ebfedea0SLionel Sambuc.Fn krb5_afslog , 157ebfedea0SLionel Sambucand 158ebfedea0SLionel Sambuc.Fn krb5_afslog_uid 159ebfedea0SLionel Sambucare the Kerberos 5 equivalents of 160ebfedea0SLionel Sambuc.Fn krb_afslog , 161ebfedea0SLionel Sambucand 162ebfedea0SLionel Sambuc.Fn krb_afslog_uid . 163ebfedea0SLionel Sambuc.Pp 164ebfedea0SLionel Sambuc.Fn krb5_afslog , 165ebfedea0SLionel Sambuc.Fn kafs_settoken5 166ebfedea0SLionel Sambuccan be configured to behave differently via a 167ebfedea0SLionel Sambuc.Nm krb5_appdefault 168ebfedea0SLionel Sambucoption 169ebfedea0SLionel Sambuc.Li afs-use-524 170ebfedea0SLionel Sambucin 171ebfedea0SLionel Sambuc.Pa krb5.conf . 172ebfedea0SLionel SambucPossible values for 173ebfedea0SLionel Sambuc.Li afs-use-524 174ebfedea0SLionel Sambucare: 175ebfedea0SLionel Sambuc.Bl -tag -width local 176ebfedea0SLionel Sambuc.It yes 177ebfedea0SLionel Sambucuse the 524 server in the realm to convert the ticket 178ebfedea0SLionel Sambuc.It no 179ebfedea0SLionel Sambucuse the Kerberos 5 ticket directly, can be used with if the afs cell 180ebfedea0SLionel Sambucsupport 2b token. 181ebfedea0SLionel Sambuc.It local, 2b 182ebfedea0SLionel Sambucconvert the Kerberos 5 credential to a 2b token locally (the same work 183ebfedea0SLionel Sambucas a 2b 524 server should have done). 184ebfedea0SLionel Sambuc.El 185ebfedea0SLionel Sambuc.Pp 186ebfedea0SLionel SambucExample: 187ebfedea0SLionel Sambuc.Pp 188ebfedea0SLionel Sambuc.Bd -literal 189ebfedea0SLionel Sambuc[appdefaults] 190ebfedea0SLionel Sambuc SU.SE = { afs-use-524 = local } 191ebfedea0SLionel Sambuc PDC.KTH.SE = { afs-use-524 = yes } 192ebfedea0SLionel Sambuc afs-use-524 = yes 193ebfedea0SLionel Sambuc.Ed 194ebfedea0SLionel Sambuc.Pp 195ebfedea0SLionel Sambuclibkafs will use the 196ebfedea0SLionel Sambuc.Li libkafs 197ebfedea0SLionel Sambucas application name when running the 198ebfedea0SLionel Sambuc.Nm krb5_appdefault 199ebfedea0SLionel Sambucfunction call. 200ebfedea0SLionel Sambuc.Pp 201ebfedea0SLionel SambucThe (uppercased) cell name is used as the realm to the 202ebfedea0SLionel Sambuc.Nm krb5_appdefault function. 203ebfedea0SLionel Sambuc.Pp 204ebfedea0SLionel Sambuc.\" The extra arguments are the ubiquitous context, and the cache id where 205ebfedea0SLionel Sambuc.\" to store any obtained tickets. Since AFS servers normally can't handle 206ebfedea0SLionel Sambuc.\" Kerberos 5 tickets directly, these functions will first obtain version 207ebfedea0SLionel Sambuc.\" 5 tickets for the requested cells, and then convert them to version 4 208ebfedea0SLionel Sambuc.\" tickets, that can be stashed in the kernel. To convert tickets the 209ebfedea0SLionel Sambuc.\" .Fn krb524_convert_creds_kdc 210ebfedea0SLionel Sambuc.\" function will be used. 211ebfedea0SLionel Sambuc.\" .Pp 212ebfedea0SLionel Sambuc.Fn k_afs_cell_of_file 213ebfedea0SLionel Sambucwill in 214ebfedea0SLionel Sambuc.Fa cell 215ebfedea0SLionel Sambucreturn the cell of a specified file, no more than 216ebfedea0SLionel Sambuc.Fa len 217ebfedea0SLionel Sambuccharacters is put in 218ebfedea0SLionel Sambuc.Fa cell . 219ebfedea0SLionel Sambuc.Pp 220ebfedea0SLionel Sambuc.Fn k_pioctl 221ebfedea0SLionel Sambucdoes a 222ebfedea0SLionel Sambuc.Fn pioctl 223ebfedea0SLionel Sambucsystem call with the specified arguments. This function is equivalent to 224ebfedea0SLionel Sambuc.Fn lpioctl . 225ebfedea0SLionel Sambuc.Pp 226ebfedea0SLionel Sambuc.Fn k_setpag 227ebfedea0SLionel Sambucinitializes a new PAG. 228ebfedea0SLionel Sambuc.Pp 229ebfedea0SLionel Sambuc.Fn k_unlog 230ebfedea0SLionel Sambucremoves destroys all tokens in the current PAG. 231ebfedea0SLionel Sambuc.Sh RETURN VALUES 232ebfedea0SLionel Sambuc.Fn k_hasafs 233ebfedea0SLionel Sambucreturns 1 if AFS is present in the kernel, 0 otherwise. 234ebfedea0SLionel Sambuc.Fn krb_afslog 235ebfedea0SLionel Sambucand 236ebfedea0SLionel Sambuc.Fn krb_afslog_uid 237ebfedea0SLionel Sambucreturns 0 on success, or a Kerberos error number on failure. 238ebfedea0SLionel Sambuc.Fn k_afs_cell_of_file , 239ebfedea0SLionel Sambuc.Fn k_pioctl , 240ebfedea0SLionel Sambuc.Fn k_setpag , 241ebfedea0SLionel Sambucand 242ebfedea0SLionel Sambuc.Fn k_unlog 243ebfedea0SLionel Sambucall return the value of the underlaying system call, 0 on success. 244ebfedea0SLionel Sambuc.Sh ENVIRONMENT 245ebfedea0SLionel SambucThe following environment variable affect the mode of operation of 246ebfedea0SLionel Sambuc.Nm kafs : 247ebfedea0SLionel Sambuc.Bl -tag -width AFS_SYSCALL 248ebfedea0SLionel Sambuc.It Ev AFS_SYSCALL 249ebfedea0SLionel SambucNormally, 250ebfedea0SLionel Sambuc.Nm kafs 251ebfedea0SLionel Sambucwill try to figure out the correct system call(s) that are used by AFS 252ebfedea0SLionel Sambucby itself. If it does not manage to do that, or does it incorrectly, 253ebfedea0SLionel Sambucyou can set this variable to the system call number or list of system 254ebfedea0SLionel Sambuccall numbers that should be used. 255ebfedea0SLionel Sambuc.El 256ebfedea0SLionel Sambuc.Sh EXAMPLES 257ebfedea0SLionel SambucThe following code from 258ebfedea0SLionel Sambuc.Nm login 259ebfedea0SLionel Sambucwill obtain a new PAG and tokens for the local cell and the cell of 260ebfedea0SLionel Sambucthe users home directory. 261ebfedea0SLionel Sambuc.Bd -literal 262ebfedea0SLionel Sambucif (k_hasafs()) { 263ebfedea0SLionel Sambuc char cell[64]; 264ebfedea0SLionel Sambuc k_setpag(); 265ebfedea0SLionel Sambuc if(k_afs_cell_of_file(pwd->pw_dir, cell, sizeof(cell)) == 0) 266ebfedea0SLionel Sambuc krb_afslog(cell, NULL); 267ebfedea0SLionel Sambuc krb_afslog(NULL, NULL); 268ebfedea0SLionel Sambuc} 269ebfedea0SLionel Sambuc.Ed 270ebfedea0SLionel Sambuc.Sh ERRORS 271ebfedea0SLionel SambucIf any of these functions (apart from 272ebfedea0SLionel Sambuc.Fn k_hasafs ) 273ebfedea0SLionel Sambucis called without AFS being present in the kernel, the process will 274ebfedea0SLionel Sambucusually (depending on the operating system) receive a SIGSYS signal. 275ebfedea0SLionel Sambuc.Sh SEE ALSO 276ebfedea0SLionel Sambuc.Xr krb5_appdefault 3 , 277ebfedea0SLionel Sambuc.Xr krb5.conf 5 278ebfedea0SLionel Sambuc.Rs 279ebfedea0SLionel Sambuc.%A Transarc Corporation 280ebfedea0SLionel Sambuc.%J AFS-3 Programmer's Reference 281ebfedea0SLionel Sambuc.%T File Server/Cache Manager Interface 282ebfedea0SLionel Sambuc.%D 1991 283ebfedea0SLionel Sambuc.Re 284ebfedea0SLionel Sambuc.Sh FILES 285ebfedea0SLionel Sambuclibkafs will search for 286ebfedea0SLionel Sambuc.Pa ThisCell and 287ebfedea0SLionel Sambuc.Pa TheseCells 288ebfedea0SLionel Sambucin the following locations: 289ebfedea0SLionel Sambuc.Pa /usr/vice/etc , 290ebfedea0SLionel Sambuc.Pa /etc/openafs , 291ebfedea0SLionel Sambuc.Pa /var/db/openafs/etc , 292ebfedea0SLionel Sambuc.Pa /usr/arla/etc , 293ebfedea0SLionel Sambuc.Pa /etc/arla , 294ebfedea0SLionel Sambucand 295ebfedea0SLionel Sambuc.Pa /etc/afs 296ebfedea0SLionel Sambuc.Sh BUGS 297ebfedea0SLionel Sambuc.Ev AFS_SYSCALL 298ebfedea0SLionel Sambuchas no effect under AIX. 299