可以检查ioctl的权限

Is possible to check rights to ioctl

本文关键字:权限 ioctl 检查      更新时间:2023-10-16

我正在为嵌入式设备编写网络配置系统,它使用ioctl调用。在启动系统时,我需要检查将来调用的权利。是否有可能检查足够或没有足够的特权ioctl(ID)调用而不调用ioctl?

我不知道这是否回答了你的问题,但是你看了能力吗?

if (!CAP_IS_SUPPORTED(CAP_NET_ADMIN)){ 
     EXIT_FAIL("Capability CAP_NET_ADMIN is not supportedn");
}

摘自man:

... 
CAP_NET_ADMIN
 Perform various network-related operations:     
   * interface configuration;
   * administration of IP firewall, masquerading, and accounting
   * modify routing tables;
   * bind to any address for transparent proxying;
   * set type-of-service (TOS)
   * clear driver statistics;
   * set promiscuous mode;
   * enabling multicasting;
...

这听起来真是糟糕的设计,你不能检查"right to future calls",因为有些东西可能会改变。毕竟,这是未来,所以很难预测,许多技术解决方案最好不要尝试。

如果您认为调用"应该"成功,但无论如何都失败了,您仍然需要处理它。因此,您也可以处理权限失败,而不必费心尝试提前检查它。