SAFE_OPEN_REGIST...WARNING_CALLBACK(3)
π safe_open_register_path_warning_callback
okay so this is the SAFE_OPEN_REGIST...WARNING_CALLBACK(3) page from the safe_open manual, and itβs literally about registering a warning callback for path-manipulation shenanigans. bestie, pay attention π
πΈ NAME
safe_open_register_path_warning_callback β register a callback to warn the application when a path is being manipulated in the safe open and fopen replacement functions
β¨ SYNOPSIS
#include "safe_open.h"
typedef int (*safe_open_pw_callback)(const char *fn);
safe_open_pw_callback
safe_open_register_path_warning_callback(safe_open_pw_callback func);
π DESCRIPTION
safe_open_register_path_warning_callback is used to register a function that is called when one of the safe open or fopen replacement functions (see the SEE ALSO section for the complete list) detects that the file name is being manipulated during operation.
This provides the application with a warning mechanism that an attack on the file name may be occurring. An application may expect to see an occasional false positive depending upon its design, but repeated warnings almost certainly indicates an active attack or a misconfigured or designed application.
π Callback function description
The registered callback function is called with the file name that caused the path manipulation to be detected in fn.
The expected use of this function is to log the file name that caused the path manipulation to be detected to allow an active attack to be detected.
Other potential uses would be to immediately cause the program to exit, or returning a non-zero value and having the function return an error immediately (-1 for the open(2) replacements and NULL for the fopen (3) replacements).
π§ Callback function return value
If 0 is returned from the callback, the function that detected the manipulation will retry the operation as if no callback were registered. If a non-zero value is returned the function that detected the manipulation will immediately return an error to its caller.
π RETURN VALUE
The previous callback function is returned.
π ERRORS
None.
π AUTHOR
James A. Kupsch
π SEE ALSO
safe_open_wrapper(3)safe_open_wrapper_follow(3)safe_open_no_create(3)safe_open_no_create_follow(3)safe_create_fail_if_exists(3)safe_create_keep_if_exists(3)safe_create_keep_if_exists_follow(3)safe_create_replace_if_exists(3)safe_fopen_wrapper(3)safe_fopen_wrapper_follow(3)safe_fopen_no_create(3)safe_fopen_no_create_follow(3)safe_fcreate_fail_if_exists(3)safe_fcreate_keep_if_exists(3)safe_fcreate_keep_if_exists_follow(3)safe_fcreate_replace_if_exists(3)
Catch u later, bestie π«Άπ β this safe_open page (SAFE_OPEN_REGIST...WARNING_CALLBACK(3)) signs off with footer date/version energy of 2011-0 (the rest got chopped mid-slay, iconic π).
π¦ where this page comes from
- nixos 26.05: safefile 1.0.5
- nixpkgs unstable: safefile 1.0.5
- Copyright 2007-2008, 2011 James A. Kupsch
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms