[Techtalk] wrapping unix commands

Elwing elwing at elwing.org
Fri Apr 8 06:02:06 EST 2005

check out the man page for execve and friends

it makes a system call - which means the C program would have to be run
as root (or suid root).

the basic usage is: (without allocating memory which you'll have to do!)
char * args[2];
args[0] = "argument 1";
args[1] = NULL;

execve("pciconf", args, NULL);

(that NULL in execve means that I'm not setting any environment
variables. - you set up a separate array with environment varables in it)

WARNING!  you can open up security holes by doing this - so be careful!!

More info and examples in the man page


overhaul wrote:
> Hello!
> I'm in a bit of a pinch.   I have limited C knowledge but have been told
> it's quite simple to write a C wrapper around unix commands.   I have a
> need now to create a few wrappers for commands that kernel will not
> allow any non-root user to run ... such as pciconf.
> I have scoured the net but either the info doesn't exist (doubtful) or
> I'm not looking in the right places.
> Does anybody have a clue how to write a C wrapper?
> thanks!!
> -T
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://linuxchix.org/cgi-bin/mailman/listinfo/techtalk

More information about the Techtalk mailing list