Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-120362 / Ensure that commonly requested xattrs are in SA #243

Open
wants to merge 1 commit into
base: stable/angelfish
Choose a base branch
from

Conversation

anodos325
Copy link
Collaborator

Now that we have SA-based xattrs on FreeBSD we should ensure that certain important samba-related xattrs are written to this area rather than in the xattr dir. This avoids having to perform more expensive permissions check, lookup, and read.

Since we can't always know what the contents of these xattrs will be beforehand, store empty xattrs and have Samba internally assign special meaning to the ones with no value (e.g. fail read with ENOATTR). This is sufficient to mask the attributes from SMB clients since vfs_streams_xattr will attempt to FGETXATTR prior to appending the xattr to STREAM_INFO response.

Three attributes to be stored in this way are:

  • user.DOSATTRIB (always requested for files)
  • stream (AFP_AfpInfo) which is used by VFS fruit to generate response to SMB2 FIND_INFO requests when AAPL context negotiated.
  • stream (AFP_Resource) which is requested by Finder to check for metadata related to icons or other usage of resource forks.

Now that we have SA-based xattrs on FreeBSD we should
ensure that certain important samba-related xattrs are
written to this area rather than in the xattr dir. This
avoids having to perform more expensive permissions check,
lookup, and read.

Since we can't always know what the contents of these xattrs
will be beforehand, store empty xattrs and have Samba internally
assign special meaning to the ones with no value (e.g. fail
read with ENOATTR). This is sufficient to mask the attributes
from SMB clients since vfs_streams_xattr will attempt to
FGETXATTR prior to appending the xattr to STREAM_INFO response.

Three attributes to be stored in this way are:
- user.DOSATTRIB (always requested for files)
- stream (AFP_AfpInfo) which is used by VFS fruit to generate
  response to SMB2 FIND_INFO requests when AAPL context negotiated.
- stream (AFP_Resource) which is requested by Finder to check for
  metadata related to icons or other usage of resource forks.
struct streams_xattr_config *config)
{
if ((strcmp(name, SAMBA_XATTR_DOS_ATTRIB) == 0) ||
(strcmp(name, config->afpinfo_name) == 0) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these elements in the struct get checked for NULL before it reaches this function? I presume they do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gets checked in streams_xattr_connect()

	if (config->afpresource_name == NULL) {
		DBG_ERR("talloc_asprintf() failed\n");
		return -1;
	}

If tree connect fails, then session won't get this far.

Copy link

@yocalebo yocalebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@anodos325 anodos325 changed the title Ensure that commonly requested xattrs are in SA NAS-120362 / Ensure that commonly requested xattrs are in SA Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants