salt.modules.mac_xattr

This module allows you to manage extended attributes on files or directories

salt '*' xattr.list /path/to/file

salt.modules.mac_xattr.clear(path)

Causes the all attributes on the file/directory to be removed

Parameters

path (str) -- The file(s) to get attributes from

Returns

True if successful, otherwise False

Raises

CommandExecutionError on file not found or any other unknown error

CLI Example:

salt '*' xattr.delete /path/to/file "com.test.attr"

salt.modules.mac_xattr.delete(path, attribute)

Removes the given attribute from the file

Parameters
  • path (str) -- The file(s) to get attributes from

  • attribute (str) -- The attribute name to be deleted from the file/directory

Returns

True if successful, otherwise False

Return type

bool

Raises

CommandExecutionError on file not found, attribute not found, and any other unknown error

CLI Example:

salt '*' xattr.delete /path/to/file "com.test.attr"

salt.modules.mac_xattr.list_(path, **kwargs)

List all of the extended attributes on the given file/directory

Parameters
  • path (str) -- The file(s) to get attributes from

  • hex (bool) -- Return the values with forced hexadecimal values

Returns

A dictionary containing extended attributes and values for the given file

Return type

dict

Raises

CommandExecutionError on file not found or any other unknown error

CLI Example:

salt '*' xattr.list /path/to/file
salt '*' xattr.list /path/to/file hex=True

salt.modules.mac_xattr.read(path, attribute, **kwargs)

Read the given attributes on the given file/directory

Parameters
  • path (str) -- The file to get attributes from

  • attribute (str) -- The attribute to read

  • hex (bool) -- Return the values with forced hexadecimal values

Returns

A string containing the value of the named attribute

Return type

str

Raises

CommandExecutionError on file not found, attribute not found, and any other unknown error

CLI Example:

salt '*' xattr.read /path/to/file com.test.attr
salt '*' xattr.read /path/to/file com.test.attr hex=True

salt.modules.mac_xattr.write(path, attribute, value, **kwargs)

Causes the given attribute name to be assigned the given value

Parameters
  • path (str) -- The file(s) to get attributes from

  • attribute (str) -- The attribute name to be written to the file/directory

  • value (str) -- The value to assign to the given attribute

  • hex (bool) -- Set the values with forced hexadecimal values

Returns

True if successful, otherwise False

Return type

bool

Raises

CommandExecutionError on file not found or any other unknown error

CLI Example:

salt '*' xattr.write /path/to/file "com.test.attr" "value"

© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.mac_xattr.html