K_SETPAG(3)
π K_AFS_CELL_OF_FILE(3) β AFS library, but make it make sense β¨
okay so bestie, welcome to the AFS library page from the KAFS(3) manual, local vibes only. This is the whole squad of functions, no cap. Let's get into it.
πΈ NAME πΈ
Meet the AFS library besties: 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 β it's the AFS library, periodt. π
π LIBRARY π
AFS cache manager access library (libkafs, -lkafs). Slay. β¨
πͺ SYNOPSIS πͺ
#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 β¨
Okay so here's the tea. βοΈ
k_hasafs() does the main character move: it initializes some library internal structures and tests whether AFS is present in the kernel. Do not call any of the other functions before k_hasafs() is called, or if it fails. That's the rule, bestie.
k_hasafs_recheck() forces a recheck if an AFS client has started since the last time k_hasafs() or k_hasafs_recheck() was called. Recheck queen. π
kafs_set_verbose() sets a log function that will be called each time the kafs library does something important, so the application using libkafs can output verbose logging. If you call kafs_set_verbose with the function argument set to NULL, libkafs stops calling the logging function (if one was set). Mute button activated. π
kafs_settoken_rxkad() sets rxkad with the token and ticket (that have the length ticket_len) for a given cell. Very specific, very iconic. π
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. Glow-up, but for credentials. β¨
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; krb_afslog_uid() will use uid. Choose your fighter. π₯
krb5_afslog() and krb5_afslog_uid() are the Kerberos 5 equivalents of krb_afslog() and krb_afslog_uid(). Kerberos 5 said "anything you can do I can do better." π
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 the libkafs as application name when running the krb5_appdefault function call. The (uppercased) cell name is used as the realm to the krb5_appdefault function. Cute and consistent. π
k_afs_cell_of_file() will in cell return the cell of a specified file; no more than len characters is put in cell. Short and sweet, just like a good text. π¬
k_pioctl() does a pioctl() system call with the specified arguments. This function is equivalent to lpioctl(). Twinsies. π―
k_setpag() initializes a new PAG. Fresh start energy. π±
k_unlog() removes destroys all tokens in the current PAG. (Yes, "removes destroys" β we're keeping the original phrasing, it's part of the lore.) Bye tokens. π
π«Ά RETURN VALUES π«Ά
k_hasafs() returns 1 if AFS is present in the kernel, 0 otherwise.
krb_afslog() and krb_afslog_uid() return 0 on success, or a Kerberos error number on failure.
k_afs_cell_of_file(), k_pioctl(), k_setpag(), and k_unlog() all return the value of the underlaying system call, 0 on success. No notes. β¨
π ENVIRONMENT π
The following environment variable affect the mode of operation of kafs:
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.
Environment variable said "I got this." πͺ
π EXAMPLES π
The following code from login will obtain a new PAG and tokens for the local cell and the cell of the users home directory.
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);
}
Look at that main character code. It ate. π₯
π¨ ERRORS π¨
If any of these functions (apart from k_hasafs()) is called without AFS being present in the kernel, the process will usually (depending on the operating system) receive a SIGSYS signal. So like, don't do that unless you want drama. π
π 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
It's giving "where is the cell file, bestie?" π΅οΈββοΈ
π BUGS π
AFS_SYSCALL has no effect under AIX. Noted, no cap. π
This iconic page was brought to you by HEIMDAL, dated May 1, 2006, and it lives in the KAFS(3) manual. Stay slay, bestie. π«Άβ¨
π¦ where this page comes from
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- debian bookworm: heimdal-dev 7.8.git20221117.28daf24+dfsg-2 Β· BSD-3-Clause
- debian trixie: heimdal-dev 7.8.git20221117.28daf24+dfsg-9+deb13u1 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: heimdal 7.8.0-unstable-2024-09-10
- ubuntu jammy: heimdal-dev 7.7.0+dfsg-3ubuntu1 Β· BSD-3-Clause
- ubuntu noble: heimdal-dev 7.8.git20221117.28daf24+dfsg-5ubuntu3 Β· BSD-3-Clause
- ubuntu questing: heimdal-dev 7.8.git20221117.28daf24+dfsg-9ubuntu1
- ubuntu resolute: heimdal-dev 7.8.git20221117.28daf24+dfsg-11ubuntu1 Β· BSD-3-Clause
- ubuntu stonking: heimdal-dev 7.8.git20240113.1b4565a+dfsg-2ubuntu1 Β· BSD-3-Clause
- Copyright (c) 1998 - 2006 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms