2 * gcc -D _GNU_SOURCE -shared -fPIC -o nofail_setfacl.so nofail_setfacl.c
15 #define XATTRNAME "system.posix_acl_access"
16 #define NOTICEMSG "%s: Could not set acl"
17 #define NOTICEMSGFD (NOTICEMSG + 4)
19 #define MIN(a,b) (((a)<(b))?(a):(b))
21 int setxattr (const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
23 int (*orig_setxattr
)(const char*, const char*, const void*, size_t, int) = dlsym(RTLD_NEXT
, __func__
);
24 int result
= orig_setxattr(path
, name
, value
, size
, flags
);
26 if(result
< 0 && errno
== EOPNOTSUPP
)
28 if(strcmp(name
, XATTRNAME
)==0)
30 warnx(NOTICEMSG
, path
);
37 int lsetxattr (const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
39 int (*orig_lsetxattr
)(const char*, const char*, const void*, size_t, int) = dlsym(RTLD_NEXT
, __func__
);
40 int result
= orig_lsetxattr(path
, name
, value
, size
, flags
);
42 if(result
< 0 && errno
== EOPNOTSUPP
)
44 if(strcmp(name
, XATTRNAME
)==0)
46 warnx(NOTICEMSG
, path
);
53 int fsetxattr (int fd
, const char *name
, const void *value
, size_t size
, int flags
)
55 int (*orig_fsetxattr
)(int, const char*, const void*, size_t, int) = dlsym(RTLD_NEXT
, __func__
);
56 int result
= orig_fsetxattr(fd
, name
, value
, size
, flags
);
58 if(result
< 0 && errno
== EOPNOTSUPP
)
60 if(strcmp(name
, XATTRNAME
)==0)
62 char linkpath
[PATH_MAX
];
64 sprintf(linkpath
, "/proc/self/fd/%d", fd
);
65 ssize_t sz
= readlink(linkpath
, path
, PATH_MAX
);
66 path
[MIN(sz
, PATH_MAX
-1)] = '\0';
67 warnx(NOTICEMSG
, path
);