FreeRADIUS InkBridge

File Handling Functions

The file handling functions perform operations on files.

The filenames can be taken from untrusted sources, in which cases special characters such as ‘/’ and ‘$’ are escaped. Any special character is replaced with an underscore, followed by the hex value of the character. Valid UTF-8 characters are allowed.

For example, the "unsafe" string user@freeradius.org/.. will turn into the filename user@freeradius.org_2f... This operation renders the filename "safe" for operations on the local file system. It is not possible for unsafe data to create unexpected files, or to perform directory traversal attacks.

Table 1. File Handling Functions

Function

Description

file.cat

Returns the contents of a file.

file.escape

Returns an escaped or safe version of the input string.

file.exists

Checks to see if a file exists on the filesystem.

file.head

Returns the first line of the file.

file.mkdir

Create a directory on the filesystem.

file.rm

Removes a file from the filesystem.

file.rmdir

Removes a directory from the filesystem.

file.size

Returns the size of a file.

file.tail

Return the last line of a file or the last number(n) of lines of a file.

file.touch

Create a file if it does not already exist.