[Toybox] Issue with TOYFLAG_STAYROOT

Ashwini Sharma ak.ashwini at gmail.com
Mon Jun 11 06:53:02 PDT 2012


Hi Rob,

  I developed a feature which needs SETUID capabilty. I installed
toybox as root.

When I invoke my feature as another user with "./toybox <cmd_name>" it
fails, whereas when I make a link to toybox and execute "<cmd_name>"
it works fine.

In my <cmd_main> i have done xsetuid(geteuid());

I think it may be a condition check miss in main.c

if (!(which->flags & TOYFLAG_STAYROOT)) {
            if (uid != euid) xsetuid(euid=uid);
}

Incase of invocation like ./toybox <cmd_name>, toy_init is called for
toybox, this doesn't have TOYFLAG_STAYROOT set and hence previliges
are dropped. But the next time when toy_init is called for command,
the uid and euid are same becos of the previous toy_init call.

I think we can avoid dropping previliges if toy_init is invoked for
toybox, this will fix the issue.

Please point me in the right direction.

regards,
Ashwini

 1339422782.0


More information about the Toybox mailing list