C question

John Vetterli jvetterli-zC6tqtfhjqE at public.gmane.org
Thu Jul 20 18:49:26 UTC 2006


I think what you want is something like:

#include <unistd.h>

#define REAL_PATH "/home/jvetterli/tmp/runme.pl"

int
main (int argc, char *argv[])
{
   setuid (geteuid ());
   setgid (getegid ());
   argv[0] = REAL_PATH;
   execv (REAL_PATH, argv);
   return 1;
}

Of course, if you were really after pointers for string manipulation in C, 
this is no help at all :)

JV


On Thu, 20 Jul 2006, Madison Kelly wrote:

> Hi all,
>
>  As something of a follow-up to my last question, I need some C help (a 
> language I am quite 'n00by' in :p ).
>
>  What I want to do is, I think, simple. Take a set of command line options 
> and use them when calling a perl script. From the ANSI C book I have gotten 
> to the point where I can print the commands to STDOUT but I can't figure out 
> how to put them into a variable. I know 'char' is for one byte, but don't 
> know what type to use for a full string or how to concatenate the switches 
> into the string.
>
>  Here's what I've got so far (probably broken from playing with it):
>
> #include <stdio.h>
>
> #define REAL_PATH 
> "/home/digimer/projects/mizu-bu/releases/mizu-bu/cgi-bin/exec-priv.pl"
> main(int argc, char *argv[])
> {
>        setuid(geteuid());
>        setgid(getegid());
> 	var say;
> 	say="Hello";
>
> 	int i;
> 	for (i=1; i<argc; i++ )
> 	{
> 		printf("%s%s", argv[i], (i < argc-1) ? " " : "");
> 	}
> 	printf("\n");
> 	printf("%s", say);
> /*        execv(REAL_PATH, av);*/
> }
>
>  Thanks for any help!!
>
> Madison
> --
> The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
>
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list