mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-09-17 15:53:46 -04:00
set_file_attrs() holds an O_RDONLY|O_NOFOLLOW fd (held_fd) for the entry's regular-file/dir/FIFO inode so metadata is applied to the pinned inode rather than by re-resolving the path, which a parent-symlink race could redirect. - xattrs: the set/remove/list of -X xattrs use the f-variant calls on held_fd (lib/sysxattrs gains the wrappers); a raced FIFO can't block the open (O_NONBLOCK). - ACLs (real root): get_acl_fdat()/set_acl_fdat() apply the ACL via lib/acl.c's fd path (xacl_*_fd), or setxattrat(AT_SYMLINK_NOFOLLOW) on the dirfd+leaf for a socket/device, covering both the access and default ACL. pack_smb_acl()+ change_sacl_perms() still build the entries, so the bytes written match acl_set_file() exactly. With no safe primitive we skip rather than re-resolve the path. The legacy path-based libacl calls remain only for the cross-tree (no held dirfd) and non-Linux cases. - --fake-super ACL-as-xattr writes/deletes also go through held_fd, closing the last path-based metadata write under fake-super.
30 lines
925 B
C
30 lines
925 B
C
#ifdef SUPPORT_XATTRS
|
|
|
|
#if defined HAVE_SYS_XATTR_H
|
|
#include <sys/xattr.h>
|
|
#elif defined HAVE_ATTR_XATTR_H
|
|
#include <attr/xattr.h>
|
|
#elif defined HAVE_SYS_EXTATTR_H
|
|
#include <sys/extattr.h>
|
|
#endif
|
|
|
|
/* Linux 2.4 does not define this as a distinct errno value: */
|
|
#ifndef ENOATTR
|
|
#define ENOATTR ENODATA
|
|
#endif
|
|
|
|
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size);
|
|
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size);
|
|
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size);
|
|
int sys_fsetxattr(int filedes, const char *name, const void *value, size_t size);
|
|
int sys_lremovexattr(const char *path, const char *name);
|
|
int sys_fremovexattr(int filedes, const char *name);
|
|
ssize_t sys_llistxattr(const char *path, char *list, size_t size);
|
|
ssize_t sys_flistxattr(int filedes, char *list, size_t size);
|
|
|
|
#else
|
|
|
|
/* No xattrs available */
|
|
|
|
#endif
|