Skip to content

Commit 71ff225

Browse files
committed
acls: handle EOPNOTSUPP for default ACLs
1 parent 00e068b commit 71ff225

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎acls.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,9 @@ int default_perms_for_dir(const char *dir)
14701470
break;
14711471
#ifdef ENOTSUP
14721472
case ENOTSUP:
1473+
#endif
1474+
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || EOPNOTSUPP != ENOTSUP)
1475+
case EOPNOTSUPP:
14731476
#endif
14741477
case ENOSYS:
14751478
/* No ACLs are available. */
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
import subprocess
4+
5+
from harness.environment import SCRATCHDIR
6+
from harness.filesystem import rmtree
7+
from harness.mutation import build_patched_rsync
8+
from harness.results import test_fail
9+
from harness.rsync import rsync_argv_for
10+
from harness import metadata
11+
12+
metadata(features={'acl', 'native_build'}, transports={'pipe'},
13+
mutates={'filesystem', 'process'}, tags={'metadata', 'regression'})
14+
15+
PATCH_FUNCTION = 'int default_perms_for_dir(const char *dir)'
16+
PATCH_FUNCTION_NEW = '''#undef ENOTSUP
17+
#define ENOTSUP 12346
18+
#undef EOPNOTSUPP
19+
#define EOPNOTSUPP 12345
20+
21+
int default_perms_for_dir(const char *dir)'''
22+
PATCH_CALL = '\tsacl = sys_acl_get_file(dir, SMB_ACL_TYPE_DEFAULT);'
23+
PATCH_CALL_NEW = '\terrno = EOPNOTSUPP;\n\tsacl = NULL;'
24+
25+
probe_rsync = build_patched_rsync('default-acl-eopnotsupp-rsync', [
26+
('acls.c', PATCH_FUNCTION, PATCH_FUNCTION_NEW),
27+
('acls.c', PATCH_CALL, PATCH_CALL_NEW),
28+
])
29+
30+
base = SCRATCHDIR / 'default-acl-eopnotsupp'
31+
src = base / 'src'
32+
dest = base / 'dest'
33+
rmtree(base)
34+
(src / 'dir').mkdir(parents=True)
35+
(src / 'dir' / 'file').write_text('content\n')
36+
37+
result = subprocess.run(
38+
rsync_argv_for(probe_rsync, '-r', str(src) + '/', str(dest) + '/'),
39+
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
40+
)
41+
copied = dest / 'dir' / 'file'
42+
if result.returncode != 0 or not copied.is_file() or copied.read_text() != 'content\n':
43+
test_fail(f'transfer failed after unsupported default ACL: {result.stderr!r}')
44+
if b'default_perms_for_dir' in result.stderr:
45+
test_fail(f'EOPNOTSUPP was reported as an ACL failure: {result.stderr!r}')
46+
47+
print('default-acl-eopnotsupp: unsupported default ACL falls back to the umask')

0 commit comments

Comments
 (0)