xattr_get
PHP function
Edit on GitHub ✎
(PECL xattr >= 0.9.0)
Get an extended attribute
Description
xattr_get(string $filename, string $name, int $flags = 0): string|false
This function gets the value of an extended attribute of a file.
Namespace
Parameters
filenameThe file from which we get the attribute.
nameThe name of the attribute.
flagsXATTR_DONTFOLLOWDo not follow the symbolic link but operate on symbolic link itself. XATTR_ROOTSet attribute in root (trusted) namespace. Requires root privileges.
Return Values
Returns a string containing the value or false if the attribute doesn't exist.
Examples
Checks if system administrator has signed the file
php
<?php
$file = '/usr/local/sbin/some_binary';
$signature = xattr_get($file, 'Root signature', XATTR_ROOT);
/* ... check if $signature is valid ... */
?>