_SECURE_PATH(3)
π NAME π
_secure_path β determine if a file appears to be secure
okay bestie, this is the _SECURE_PATH(3) page from the Library Functions Manual β¨ itβs giving βshould I trust this file or nah?β energy, and honestly that is such a mood.
π LIBRARY π
System Utilities Library (libutil, -lutil) π«Ά
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <libutil.h>
int
_secure_path(const char *path, uid_t uid, gid_t gid);
π DESCRIPTION π
so _secure_path() does some basic security checking on a path. Itβs meant for processes running with root privileges so they can decide whether or not to trust the contents of a given file. It uses a method often used to detect system compromise π
A file is considered βsecureβ if it meets these conditions:
- The file exists, and is a regular file (not a symlink, device special or named pipe, etc.) π«π
- It is not world writable. πβ
- It is owned by the given
uidoruid 0, ifuidis not-1π - It is not group writable or it has group ownership by the given
gid, ifgidis not-1π―
π RETURN VALUES π
- zero if the file exists and may be considered secure β
-2if the file does not exist π-1otherwise to indicate a security failure π
The syslog(3) function is used to log any failure of this function, including the reason, at LOG_ERR priority π
π SEE ALSO π
π¦ HISTORY π¦
Code from which this function was derived was contributed to the FreeBSD project by Berkeley Software Design, Inc. The function _secure_path() first appeared in FreeBSD 2.2.5 π
π BUGS π
β οΈ bestie, the checks carried out are rudimentary and no attempt is made to eliminate race conditions between use of this function and access to the file referenced. so likeβ¦ itβs not a full-body security scan, okay? π
xoxo, this page is brought to you by Debian, dated May 10, 2020 π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1997 David Nugent <davidn@blaze.net.au>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms