如何确定是否启用了CONFIG_FANOTIFY_ACCESS_PERMISSIONS? [英] How to find out whether CONFIG_FANOTIFY_ACCESS_PERMISSIONS is enabled?
问题描述
我想使用 fanotify(7)
,我遇到的问题是,尽管配置了 CONFIG_FANOTIFY
,但在某些内核上, CONFIG_FANOTIFY_ACCESS_PERMISSIONS
无法正常工作.
至少我想报告这种情况.
现在在Debian和Ubuntu上,我可以使用等效于 grep CONFIG_FANOTIFY_ACCESS_PERMISSIONS/boot/config-$(uname -r)
的功能来验证该功能是否可用.在其他一些系统上,我可以使用等效于 zgrep CONFIG_FANOTIFY_ACCESS_PERMISSIONS/proc/config.gz
的系统,但是这两个方法可能没有涵盖其他系统.
是否有一种方法可以在任何 fanotify(7)
函数中弄清楚当前运行的内核上是否可以使用fanotify权限处理?
当未实现 fanotify_mark()
时,我在想一种类似于返回的 ENOSYS
的方法(解决方案
当通过 FAN_ALL_PERM_EVENTS
时,似乎 fanotify_mark()
返回 EINVAL
但是 CONFIG_FANOTIFY_ACCESS_PERMISSIONS
已禁用.
请参见 fs/notify/fanotify/fanotify_user.c
在内核源代码中:
SYSCALL_DEFINE5(fanotify_mark,int,fanotify_fd,unsigned int,标志,__u64,mask,int,dfd,const char __user *,路径名){...#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS如果(遮罩&〜(FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD))#别的如果(遮罩&〜(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD))#万一返回-EINVAL;
I want to make use of fanotify(7)
and the problem I run into is that on some kernels CONFIG_FANOTIFY_ACCESS_PERMISSIONS
does not work, although CONFIG_FANOTIFY
is configured.
At the very least I'd like to report this condition.
Now on Debian and Ubuntu I could use the equivalent of grep CONFIG_FANOTIFY_ACCESS_PERMISSIONS /boot/config-$(uname -r)
to verify that the feature is available. On some other systems I could use the equivalent of zgrep CONFIG_FANOTIFY_ACCESS_PERMISSIONS /proc/config.gz
, but there are probably some more systems that are not covered by these two methods.
Is there a way to figure out in any of the fanotify(7)
functions whether or not fanotify permission handling is available on the kernel currently running?
I was thinking of a method similar to the returned ENOSYS
when fanotify_mark()
is not implemented (fanotify_mark(2)
), but could not find anything like that in the documentation.
It seems that fanotify_mark()
returns EINVAL
when FAN_ALL_PERM_EVENTS
is passed but CONFIG_FANOTIFY_ACCESS_PERMISSIONS
is disabled.
See fs/notify/fanotify/fanotify_user.c
in kernel sources:
SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
__u64, mask, int, dfd,
const char __user *, pathname)
{
...
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
if (mask & ~(FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD))
#else
if (mask & ~(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD))
#endif
return -EINVAL;
这篇关于如何确定是否启用了CONFIG_FANOTIFY_ACCESS_PERMISSIONS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!