NTFS Reparse Points

I have an AppleScript script that runs a stress test. Part of the test is to open, save, and close certain files. Somehow, the files have picked up some «extended attributes» that prohibit the file…

11.1 About Extended User Attributes Services

Information about what is a WebCenter Content service and how services can be used is provided in Section 2, «Using Services.» Information about basic services structure, attributes, actions, and a service example is provided in Section 3, «Customizing Services.» You should be familiar with this information before customizing current services or creating new services

The locations for specific Extended User Attributes services are listed within each individual service.

The most commonly used services have more extensive descriptions.

Man Pages

MAN PAGE for OSX xattr

MAN PAGE for Python xattr VERSION 0.6.4

NOTE: I could not find the python help page for current VERSION 0.9.6

Thanks for Reading!

Полезные ссылки

Если вы хотите разобраться в теме самостоятельно, почитайте эти источники. Теоретическая часть, которую вы увидите далее — это короткий пересказ материалов из этого списка.

  • Официальная документация с MSDN: docs.microsoft.com/en-us/windows/win32/fileio/reparse-points
  • М. Руссинович, Д. Соломон, А. Ионеску, Внутреннее устройство Microsoft Windows. 6-е изд. Основные подсистемы ОС. Стр 535.
  • Короткий и удобный гайд: hex.pp.ua/reparse-point-custom.php
  • Очень классный проект использующий RP: github.com/aleksk/LazyCopy
  • Решение задачи которую мы разберем ниже: github.com/Dabudabot/injection-monitor

NAME

extattr_get_fd extattr_set_fd extattr_delete_fd extattr_list_fd extattr_get_file extattr_set_file extattr_delete_file extattr_list_file extattr_get_link extattr_set_link extattr_delete_link extattr_list_link — system calls to manipulate VFS extended attributes 

Requirements

  • Swift 4.0 or higher
  • macOS, iOS, tvOS or Linux
  • XCode 9.0

SYNOPSIS

   #include <sys/types.h>
   #include <sys/extattr.h>
ssize_textattr_get_fd (int fd int attrnamespace const char *attrname void *data size_t nbytes);
intextattr_set_fd (int fd int attrnamespace const char *attrname const void *data size_t nbytes);
intextattr_delete_fd (int fd int attrnamespace const char *attrname);
ssize_textattr_list_fd (int fd int attrnamespace void *data size_t nbytes);
ssize_textattr_get_file (const char *path int attrnamespace const char *attrname void *data size_t nbytes);
intextattr_set_file (const char *path int attrnamespace const char *attrname const void *data size_t nbytes);
intextattr_delete_file (const char *path int attrnamespace const char *attrname);
ssize_textattr_list_file (const char *path int attrnamespace void *data size_t nbytes);
ssize_textattr_get_link (const char *path int attrnamespace const char *attrname void *data size_t nbytes);
intextattr_set_link (const char *path int attrnamespace const char *attrname const void *data size_t nbytes);
intextattr_delete_link (const char *path int attrnamespace const char *attrname);
ssize_textattr_list_link (const char *path int attrnamespace void *data size_t nbytes);
 

11.2 Extended User Attributes Services

The following Extended User Attributes component services are installed when the Content Server instance is installed:

The following services are extended to provide support for the Extended User Attributes component:

11.2.1 ADD_EXTENDED_USER_ATTRIBUTES

Service that adds extended attributes to a user. The user does not have to exist before using the service. If this service is asked to add extended attributes which already exist for the user, the service modifies the previous entries.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dName: The user name.

ExtUserAttribInfo Resultset: A result set containing extended user attribution information.

Optional Service Parameters

CheckUserMustExist: If set to true, a limited check is performed to verify that the user exists before extended attributes are added. This check only works for local users; it is not recommended to set this value for typical service calls.

The following example from add_user_attr.txt illustrates the use of this service:

11.2.2 EDIT_EXTENDED_USER_ATTRIBUTES

Service that edits extended user attributes for a user. The user does not have to exist before using the service. All previously extended attributes are replaced by the new extended attributes provided.

Additional Required Service Parameters

dName: The user name.

ExtUserAttribInfo ResultSet: A result set containing extended user attribution information.

Optional Service Parameters

CheckUserMustExist: If set to true , a limited check is performed to verify that the user exists before extended attributes are added. This check only works for local users; it is not recommended to set this value for typical service calls.

The following example from edit_user_attr.txt illustrates the use of this service:

11.2.3 DELETE_EXTENDED_USER_ATTRIBUTES

Service that deletes specific extended user attributes for a user.

Additional Required Service Parameters

dName: The user name.

ExtUserAttribInfo ResultSet: A result set containing extended user attribution information.

allowMissingAttributes: If set to true , the service suppresses errors when trying to delete attributes that do not exist (the default is false ).

Optional Service Parameters

CheckUserMustExist: If set to true , a limited check is performed to verify that the user exists before extended attributes are added. This check only works for local users; it is not recommended to set this value for typical service calls.

11.2.4 DELETE_EXTENDED_ATTRIBUTES_BY_APPLICATION

Service that deletes all extended attributes for a particular role/account for a specified application.

Additional Required Service Parameters

dAttributeType: The type of attribute to delete.

dAttributeName: The name of the attribute to delete.

dApplication: The application from which to delete the attribute.

The following example from delete_attr_by_app.txt illustrates the use of this service:

11.2.5 DELETE_ALL_EXTENDED_ATTRIBUTES_FOR_USER

Service that deletes all extended attributes for a user.

Additional Required Service Parameters

dName: The user name.

Optional Service Parameters

CheckUserMustExist: If set to true , a limited check is performed to verify that the user exists before extended attributes are added. This check only works for local users; it is not recommended to set this value for typical service calls.

The following example from delete_user_attr_all.txt illustrates the use of this service:

11.2.6 DELETE_ALL_EXTENDED_ATTRIBUTES_FOR_APPLICATION

Service that deletes all extended users attributes for an application.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dApplication: The application.

The following example from del_all_attr_app.txt illustrates the use of this service:

11.2.7 QUERY_EXTENDED_USER_ATTRIBUTES

Service that places all of a user’s extended attributes into a result set in the binder. All of the data is put into the ExtUserAttribInfo ResultSet.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dName: The user name.

Optional Service Parameters

dApplication: The application name for the attribute.

dAttributeType: The type of attribute.

dAttributeName: The name of the attribute.

Adding one or more of the optional parameters enables greater flexibility in narrowing the query. The following example from query_user_attr_ext.txt illustrates the use of this service:

11.2.8 QUERY_EXTENDED_ATTRIBUTE_MAPPINGS

Service that places all mapped extended attributes from a particular attribute into a result set in the binder. All of the data is put into the ExtUserAttribInfo ResultSet.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dMappedAttributeName: The name of the attribute to be mapped.

Optional Service Parameters

dApplication: The application name for the attribute.

dAttributeType: The type of attribute.

dAttributeName: The name of the attribute.

Adding one or more of the optional parameters enables greater flexibility in narrowing the query. The following example from query_attr_map_ext.txt illustrates the use of this service:

11.2.9 EC_SET_PROPERTY

Service that sets an extended configuration property. It can be used to either add a new property or modify an existing property.

Location: IdcHomeDir / components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dECPropType: The type of property.

dECPropKey: A key (generally relating to dECPropType).

dECPropValue: The property value.

Optional Service Parameters

dECPropSubKey: (Recommended) A second key; for example, the key can be a feature of what is defined by dECPropType and dEDPropKey.

The following example from set_property.txt illustrates the use of this service:

11.2.10 EC_DELETE_PROPERTY

Service that deletes an extended configuration property. It is important that the exact key be specified for deletion. This service does not automatically delete all subkeys under a key.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dECPropType: The type of property.

dECPropKey: A key (generally relating to dECPropType).

Optional Service Parameters

dECPropSubKey: (Recommended) A second key; for example, the key can be a feature of what is defined by dECPropType and dEDPropKey.

The following example from del_property.txt illustrates the use of this service:

11.2.11 EC_GET_PROPERTY

Service that returns a specified extended configuration property in the ResultSet PROPERTY_LIST. It is important that the exact key be specified; if you want to search based on just the key (not subkey) use EC_GET_PROPERTY_BY_KEY.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dECPropType: The type of property.

dECPropKey: A key (generally relating to dECPropType).

Optional Service Parameters

dECPropSubKey: (Recommended) A second key; for example, the key can be a feature of what is defined by dECPropType and dEDPropKey.

The following example from get_property.txt illustrates the use of this service:

11.2.12 EC_GET_PROPERTY_BY_KEY

Service that returns a specified extended configuration property in the ResultSet PROPERTY_LIST.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dECPropType: The type of property.

dECPropKey: A key (generally relating to dECPropType).

The following example from get_property_by_key.txt illustrates the use of this service:

11.2.13 SET_DEFAULT_ATTRIBUTES

Service that sets some default attributes that will always be applied to a user. The type is defaults and the key is userattributes , so these do not need to be provided.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

dDefAttribs: The default attributes in the form of a comma-separated entry consisting of three items.

Optional Service Parameters

dECPropSubKey: A second key; the default attributes will load for all users whether or not this key is specified.

IsSecureDefaultAttribute: When set to 1 and used with the databinder when using the default web services ( ) then it registers defaults that only apply to logged in users. (By default, default attributes apply to all users, including anonymous .)

The following example from set_defs.txt illustrates the use of this service:

11.2.14 DELETE_DEFAULT_ATTRIBUTES

Service that deletes some default attributes that will always be applied to a user.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Optional Service Parameters

dECPropSubKey: A second key. If this parameter is not specified, the service will only remove the default attributes specified without a subkey; it will not remove other attributes.

IsSecureDefaultAttribute: If set to 1 and used with the databinder when using the default web services ( ) then it deletes defaults that only apply to logged in users. (By default, default attributes apply to all users, including anonymous .)

The following example from del_defs.txt illustrates the use of this service:

11.2.15 GET_DEFAULT_ATTRIBUTES

This service returns the default attributes that are applied to all users in the ResultSet DEFAULT_ATTRIBUTES.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Optional Service Parameters

dECPropSubKey: If specified, it narrows the search for the default attributes to only the one matching that subkey.

IsSecureDefaultAttribute: If set to 1 and used with the databinder when using the default web services ( ) then it retrieves defaults that only apply to logged in users. (By default, default attributes apply to all users, including anonymous .)

The following example from get_defs.txt illustrates the use of this service:

11.2.16 SET_EXTENDED_ATTRIBUTE_MAPPINGS

Service that sets mappings from one user attribute to another user attribute. Only mappings from roles to other attributes is supported (mapping does not work when the source is an account).

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

ExtUserAttribInfo: A result set containing extended user attribute information.

The following example from set_attr_mapping.txt illustrates the use of this service:

11.2.17 DELETED_EXTENDED_ATTRIBUTE_MAPPINGS

Service that deletes mappings from one user attribute to another user attribute.

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Additional Required Service Parameters

ExtUserAttribInfo: A result set containing extended user attribute information.

Optional Service Parameters

allowMissingAttributes: If set to true , the service suppresses errors when trying to delete attributes that do not exist. The default is false .

The following example from del_attr_mapping.txt illustrates the use of this service:

11.2.18 ADD_USER

The service has been altered to add extended user attributes at the same time the user is added. For additional information see Section 4.14.4, «ADD_USER.»

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Optional Service Parameter

ExtUserAttribInfo ResultSet: A result set containing extended user attribution information. If it is not included, no extended attributes are added.

The following example from add_user.txt illustrates the use of this service:

11.2.19 EDIT_USER

This service has been altered to allow editing of extended user attributes at the same time. The old values are completely replaced by the new ones. For additional information, see Section 4.14.4, «ADD_USER.»

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

Optional Service Parameters

ExtUserAttribInfo ResultSet: A result set containing extended user attribution information. If it is not included, the extended attributes are not replaced.

The following example from edit_user.txt illustrates the use of this service:

11.2.20 DELETE_USER

This service has been altered to delete a user’s extended attributes if they exist. For additional information, see Section 4.14.10, «DELETE_USER.»

Location: IdcHomeDir /components/ExtendedUserAttributes/resources/extendeduserattributes_services.htm

The following example from delete_user.txt illustrates the use of this service:

11.2.21 QUERY_USER_ATTRIBUTES

This service acts as usual however the attributes it returns are contingent on the value of the getAllAttributes parameter. If the parameter is passed as true , this service returns a merger of both regular and extended user attributes. For additional information, see Section 4.14.24, «QUERY_USER_ATTRIBUTES.»

CAVEAT

This interface is under active development, and as such is subject tochange as applications are adapted to use it.Developers are discouraged from relying on its stability. 

Usage

Extended attributes only work with urls that begins with file:///.

Listing

To get which extended attributes are set for file:

do { print(try url.listExtendedAttributes())} catch { print(error.localizedDescription)}

Retrieving

To check either a specific extended attribute exists or not:

if url.hasExtendedAttribute(forName: «eaName«) { // Do something}

To retrieve raw data for an extended attribute, simply use this code as template, Please note if extended attribute doesn’t exist, it will throw an error.

do { let data = try url.extendedAttribute(forName: «eaName«) print(data as NSData)} catch { print(error.localizedDescription)}

You can retrieve values of extended attributes if they are set with standard plist binary format. This can be String, Int/NSNumber, Double, Bool, URL, Date, Array or Dictionary. Arrays should not contain nil value.

To retrieve raw data for an extended attribute, simply use this code as template:

do { let notes: String = try url.extendedAttributeValue(forName: «notes«) print(«Notes:«, notes) let isDownloeded: Bool = try url.extendedAttributeValue(forName: «isdownloaded«) print(«isDownloaded:«, isDownloeded) let originURL: URL = try url.extendedAttributeValue(forName: «originurl«) print(«Original url:«, originurl)} catch { print(error.localizedDescription)}

or to list all values of a file:

do { for name in try url.listExtendedAttributes() { let value = try url.extendedAttributeValue(forName: name) print(name, «:« , value) }} catch { print(error.localizedDescription)}

Setting attributes

To set raw data for an extended attribute:

do { try url.setExtendedAttribute(data: Data(bytes: [0xFF, 0x20]), forName: «data«)} catch { print(error.localizedDescription)}

To set a value for an extended attribute:

do { let dictionary: [String: Any] = [«name«: «Amir«, «age«: 30] try url.setExtendedAttribute(value: dictionary, forName: «identity«)} catch { print(error.localizedDescription)}

Removing

To remove an extended attribute:

do { try url.removeExtendedAttribute(forName: «identity«)} catch { print(error.localizedDescription)}

SEE ALSO

extattr(3),getextattr(8),setextattr(8),extattr(9),VOP_GETEXTATTR9,VOP_SETEXTATTR9 

HISTORY

Extended attribute support was developed as part of theTrustedBSDProject, and introduced inFx 5.0 .It was developed to support security extensions requiring additional labelsto be associated with each file or directory. 

Index

NAMELIBRARYSYNOPSISDESCRIPTIONCAVEATRETURN VALUESERRORSSEE ALSOHISTORYBUGS

:

Inferno Solutions
Hosting by Hoster.ru

:

Понравилась статья? Поделиться с друзьями:
Добавить комментарий

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: