Skip to content

Commit 110d693

Browse files
committed
macOS: Use setxattr with XATTR_NOFOLLOW instead of lsetxattr
setxattr will search by default yes, but you can disable that with XATTR_NOFOLLOW
1 parent 726e8e8 commit 110d693

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Modules/posixmodule.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15485,12 +15485,21 @@ os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute,
1548515485
if (path->fd > -1)
1548615486
result = fsetxattr(path->fd, attribute->narrow,
1548715487
value->buf, value->len, flags);
15488+
#ifdef __APPLE__
15489+
else
15490+
result = setxattr(path->narrow,
15491+
attribute->narrow,
15492+
value->buf,
15493+
value->len,
15494+
followSymLinks ? flags : flags | XATTR_NOFOLLOW);
15495+
#else
1548815496
else if (follow_symlinks)
1548915497
result = setxattr(path->narrow, attribute->narrow,
1549015498
value->buf, value->len, flags);
1549115499
else
1549215500
result = lsetxattr(path->narrow, attribute->narrow,
1549315501
value->buf, value->len, flags);
15502+
#endif
1549415503
Py_END_ALLOW_THREADS;
1549515504

1549615505
if (result) {

0 commit comments

Comments
 (0)