0

I'm writing network configuring system for embedded device, which uses ioctl calls. On starting system I need to check rights to future calls. Is possible to check enough or have not enough privileges to ioctl(ID) call without calling that ioctl?

Dcow
  • 1,413
  • 1
  • 19
  • 42

2 Answers2

0

That really sounds like bad design, you can't check "right to future calls", since something might change. After all, it's the future, so it's really hard to predict, and many technical solutions are better off by not even trying.

If you do the call thinking it "should" succeed, and it fails any way, you still need to handle it. So you might as well handle the permissions-failure too, and not bother trying to check it in advance.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • of course I should checks result of ioctls, but on start I want do self diagnostics – Dcow Jul 03 '14 at 13:25
0

I don't know if this answer to your ask but did you look about capabilities ?

if (!CAP_IS_SUPPORTED(CAP_NET_ADMIN)){ 
     EXIT_FAIL("Capability CAP_NET_ADMIN is not supported\n");
}

Extracted from 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;
...

Hop this help

rom1nux
  • 110
  • 1
  • 11