Re: Kernal Extension
Re: Kernal Extension
- Subject: Re: Kernal Extension
- From: Quinn <email@hidden>
- Date: Wed, 24 Nov 2004 16:45:03 +0000
At 13:47 -0600 18/11/04, Setaro, James wrote:
To: "'email@hidden '" <email@hidden>
Cc:
First up, please don't cross post between lists. It makes life
painful if folks who respond aren't on both lists.
I am writing a kernal extension for 10.1.5.
I am trying to call kmodstat from inside the of the MoreAuthSample(setuid(0)
for admin) tool using pipes(to check the output) and execlp to make sure
that my extension is loaded at run-time.
I have tried everything I can think of but it won't execute. I think that I
am not setting
up the enviroment correctly and exec can't find the the kmodstat command,
but I don't know where to look for answers on setting this a exec enviroment
or if it is even possible to execute kmodstat from execl.
Right now I am trying to excute this:
execlp( "/usr/sbin/kmodstat", "/usr/sbin/kmodstat", NULL );
but it seems to just break my pipe. Signal status: 10
kextload and kextunload seem to work fine. Any ideas?
Second, don't use execlp from secure code because it depends on the
environment (specifically the PATH environment variable). execl is a
much better choice. execve is even better because it forces you to
explicitly control everything.
However, I don't think that this is the root cause of your problem.
I don't really know what might be causing it, but I have a good idea
of how to start debugging it. It's likely that kmodstat is dependent
on some environmental factors that aren't obvious. As MoreSecurity
nukes the /entire/ environment, whatever kmodstat is dependent on is
having problems.
The best way to figure out the environmental dependencies is to write
a tiny program that selectively nukes the environment and then exec's
kmodstat. Something like:
int main(...)
{
OSStatus junk;
junk =
MoreSecDestroyInheritedEnvironment(kMoreSecKeepEverythingMask, argv);
assert(junk == noErr);
execve("kmodstat", ...)
}
Run this program using "sudo" and see if it works. If so, then
selectively remove entries from the kMoreSecKeepEverythingMask until
it stops working, or until you've removed everything except
kMoreSecKeepStandardFilesMask. This will yield one of two results.
o If kmodstat fails, you know that the last environment factor was
the one it's dependent on. We can then hunt for an explanation of
what it is.
o If kmodstat works with a nuked environment, something else is
causing the problem.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden