KAFS5(3)
π¦ K_AFS_CELL_OF_FILE(3) β LOCAL manual vibes, AFS library edition π¦
Okay bestie, welcome to the K_AFS_CELL_OF_FILE(3) page β it's a LOCAL manual and it's all about the AFS library. This is a lot of functions, but we're gonna get through it together, no cap π.
β¨ NAME β¨
k_hasafs, k_hasafs_recheck, k_pioctl, k_unlog, k_setpag, k_afs_cell_of_file, kafs_set_verbose, kafs_settoken_rxkad, kafs_settoken, krb_afslog, krb_afslog_uid, kafs_settoken5, krb5_afslog, krb5_afslog_uid β the whole AFS library crew π
.
π LIBRARY π
It's the AFS cache manager access library β libkafs5, link it with -lkafs5. Slay.
π«Ά SYNOPSIS π«Ά
Copy these signatures exactly, bestie β this is not a vibe-only situation π:
#include <kafs.h>
int
k_afs_cell_of_file(const char *path, char *cell, int len);
int
k_hasafs(void);
int
k_hasafs_recheck(void);
int
k_pioctl(char *a_path, int o_opcode, struct ViceIoctl *a_paramsP,
int a_followSymlinks);
int
k_setpag(void);
int
k_unlog(void);
void
kafs_set_verbose(void (*func)(void *, const char *, int), void *);
int
kafs_settoken_rxkad(const char *cell, struct ClearToken *token,
void *ticket, size_t ticket_len);
int
kafs_settoken(const char *cell, uid_t uid, CREDENTIALS *c);
krb_afslog(char *cell, char *realm);
int
krb_afslog_uid(char *cell, char *realm, uid_t uid);
krb5_error_code
krb5_afslog_uid(krb5_context context, krb5_ccache id, const char *cell,
krb5_const_realm realm, uid_t uid);
int
kafs_settoken5(const char *cell, uid_t uid, krb5_creds *c);
krb5_error_code
krb5_afslog(krb5_context context, krb5_ccache id, const char *cell,
krb5_const_realm realm);
π DESCRIPTION π
k_hasafs() is the main character you gotta call first: it initializes some library internal structures and tests for the presence of AFS in the kernel. None of the other functions should be called before k_hasafs() is called, or if it fails. Periodt.
k_hasafs_recheck() forces a recheck if an AFS client has started since the last time k_hasafs() or k_hasafs_recheck() was called. It's giving "wait, are they here now?" energy π.
kafs_set_verbose() sets a log function that gets called each time the kafs library does something important, so the application using libkafs can output verbose logging. Calling kafs_set_verbose with the function argument set to NULL stops libkafs from calling the logging function (if set). No spam, no problem π«Ά.
kafs_settoken_rxkad() sets rxkad with the token and ticket (that have the length ticket_len) for a given cell.
kafs_settoken() and kafs_settoken5() work the same way as kafs_settoken_rxkad() but internally convert the Kerberos 4 or 5 credential to an afs cleartoken and ticket.
krb_afslog() and krb_afslog_uid() obtain new tokens (and possibly tickets) for the specified cell and realm. If cell is NULL, the local cell is used. If realm is NULL, the function tries to guess what realm to use. Unless you have some good knowledge of what cell or realm to use, you should pass NULL. krb_afslog() will use the real user-id for the ViceId field in the token, and krb_afslog_uid() will use uid. iykyk π
.
krb5_afslog() and krb5_afslog_uid() are the Kerberos 5 equivalents of krb_afslog() and krb_afslog_uid().
krb5_afslog() and kafs_settoken5() can be configured to behave differently via a krb5_appdefault option afs-use-524 in krb5.conf. Possible values for afs-use-524 are:
yesβ use the 524 server in the realm to convert the ticket.noβ use the Kerberos 5 ticket directly; can be used with if the afs cell support 2b token.local,2bβ convert the Kerberos 5 credential to a 2b token locally (the same work as a 2b 524 server should have done).
Example:
[appdefaults]
SU.SE = { afs-use-524 = local }
PDC.KTH.SE = { afs-use-524 = yes }
afs-use-524 = yes
libkafs will use libkafs as the application name when running the krb5_appdefault function call.
The (uppercased) cell name is used as the realm to the krb5_appdefault function.
k_afs_cell_of_file() will in cell return the cell of a specified file; no more than len characters is put in cell.
k_pioctl() does a pioctl() system call with the specified arguments. This function is equivalent to lpioctl().
k_setpag() initializes a new PAG.
k_unlog() removes/destroys all tokens in the current PAG.
π RETURN VALUES π
k_hasafs()returns1if AFS is present in the kernel,0otherwise.krb_afslog()andkrb_afslog_uid()return0on success, or a Kerberos error number on failure.k_afs_cell_of_file(),k_pioctl(),k_setpag(), andk_unlog()all return the value of the underlying system call,0on success.
πΈ ENVIRONMENT πΈ
The following environment variable affects how kafs operates:
AFS_SYSCALLβ Normally, kafs will try to figure out the correct system call(s) that are used by AFS by itself. If it does not manage to do that, or does it incorrectly, you can set this variable to the system call number or list of system call numbers that should be used. Emergency override realness π«‘.
π EXAMPLES π
The following code from login will obtain a new PAG and tokens for the local cell and the cell of the user's home directory. Iconic.
if (k_hasafs()) {
char cell[64];
k_setpag();
if(k_afs_cell_of_file(pwd->pw_dir, cell, sizeof(cell)) == 0)
krb_afslog(cell, NULL);
krb_afslog(NULL, NULL);
}
π ERRORS π
If any of these functions (apart fromk_hasafs()) is called without AFS being present in the kernel, the process will usually (depending on the operating system) receive aSIGSYSsignal. Not cute. π
π₯ SEE ALSO π₯
krb5_appdefault(3)krb5.conf(5)- Transarc Corporation, βFile Server/Cache Manager Interfaceβ, AFS-3 Programmer's Reference, 1991.
π FILES π
libkafs will search for ThisCell and TheseCells in the following locations:
/usr/vice/etc/etc/openafs/var/db/openafs/etc/usr/arla/etc/etc/arla/etc/afs
π§ BUGS π§
AFS_SYSCALL has no effect under AIX. Sorry AIX bestie ππ.
Signed, sealed, and absolutely slaying: HEIMDAL Β· May 1, 2006 Β· filed under KAFS(3) π β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- Copyright (c) 1998 - 2006 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms