MAC_SET(3)
π
mac_set(3) β Library Functions Manual realness: set the MAC label for a file or process β¨
π NAME π
mac_set_file,mac_set_fd,mac_set_procβ set the MAC label for a file or process. periodt. π
π LIBRARY π
Standard C Library (libc, -lc) β yes bestie, that's where these live. π«Ά
π SYNOPSIS π
#include <sys/mac.h>
int
mac_set_file(const char *path, mac_t label);
int
mac_set_link(const char *path, mac_t label);
int
mac_set_fd(int fd, mac_t label);
int
mac_set_proc(mac_t label);
π¦ DESCRIPTION π¦
Okay so the mac_set_file() and mac_set_fd() functions associate the MAC label specified by label with the file referenced by path_p β that's the mac_set_file() glow-up β or with the file descriptor fd β that's mac_set_fd(), respectively. π
Big important socket note, bestie: when a file descriptor references a socket, label operations on the file descriptor act on the socket, not on the file that may have been used as a rendezvous when binding the socket. iykyk. π
The mac_set_link() function is the same as mac_set_file(), except that it does not follow symlinks. no cap, it stays right there. πͺ
The mac_set_proc() function associates the MAC label specified by label with the calling process. main character process energy. π
A process is allowed to set a label for a file only if it has MAC write access to the file, and its effective user ID is equal to the owner of the file, or has appropriate privileges. security vibe check, honestly. π
π₯ RETURN VALUES π₯
mac_set_fd(), mac_set_file(), mac_set_link(), and mac_set_proc() return the value 0 if successful; otherwise, the value -1 is returned and the global variable errno is set to indicate the error. so if you see -1, check errno, bestie. π
π¨ ERRORS π¨
[EACCES]β MAC write access to the file is denied.[EBADF]β Thefdargument is not a valid file descriptor.[EINVAL]β Thelabelargument is not a valid MAC label, or the object referenced byfdis not appropriate for label operations.[EOPNOTSUPP]β Setting MAC labels is not supported by the file referenced byfd.[EPERM]β The calling process had insufficient privilege to change the MAC label.[EROFS]β File system for the object being modified is read only.[ENAMETOOLONG]β The length of the pathname inpath_pexceedsPATH_MAX, or a component of the pathname is longer thanNAME_MAX.[ENOENT]β The file referenced bypath_pdoes not exist.[ENOTDIR]β A component of the pathname referenced bypath_pis not a directory.
π SEE ALSO π
mac(3), mac_free(3), mac_get(3), mac_is_present(3), mac_prepare(3), mac_text(3), posix1e(3), mac(4), mac(9)
π§ HISTORY π§
Support for Mandatory Access Control was introduced in FreeBSD 5.0 as part of the TrustedBSD Project. iconic origin story, tbh. β¨
okay bestie, that's the whole page. Footer energy: source/version Debian, date January 14, 2003 β vintage but iconic ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2001 Networks Associates Technology, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms