linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* New project
@ 2002-07-26 11:41 xlp
  2002-07-26 14:14 ` Bruno. N. F. Pacheco
  0 siblings, 1 reply; 2+ messages in thread
From: xlp @ 2002-07-26 11:41 UTC (permalink / raw)
  To: linux-c-programming

Hi, I am coding a new project that demands me advanced C programming, I am bored
of "Learn how to program in C" and those basic C tasks.
I decided to make my own projects, understand manual pages style, learn how
to make sucessfull web search, use irc channel and so on...
I am coding a project, that It's a like a telnetd with login features, it
becomes a daemon, listens on certain port, accepts connection, autenticate, and
execute a shell.
The problem is when authentication is successful, It execve() a /bin/sh
however, I want to define certain variable such as PATH, TERM, etc.
I want that when a client 'logs in', my daemon set certain variables (ej.
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin) and then
executes the shell, so the client has a presetted variables on his session.
You may think, Why dont you read his .cshrc ?, I dont want to read any file
on the system , I just want my daemon set everything and then executes the 
shell.
smthg like:
char *PATH="/bin:/sbin:/usr/bin:/usr/sbin";
char *TERM="vt100";
char *FOO="bar";

I read putenv() man, Does it have any relation?, I dont know who to put it
to work...

Thank you for any advice/help

bye.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: New project
  2002-07-26 11:41 New project xlp
@ 2002-07-26 14:14 ` Bruno. N. F. Pacheco
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno. N. F. Pacheco @ 2002-07-26 14:14 UTC (permalink / raw)
  To: linux-c-programming

Are you sure you read execve(2) man page? You just have to pass your env
variables in the last arguments, something like:

char *argz[] = {
    "/bin/sh",
    NULL
};

char *envz[] = {
    "PATH=/bin:/sbin:/usr/bin:/usr/sbin",
    "TERM=v100",
    "FOO=bar",
    NULL
};

execve(argz[0], argz, envz);

	-- Bruno N. F. Pacheco

On Fri, 26 Jul 2002, xlp wrote:

> Hi, I am coding a new project that demands me advanced C programming, I am bored
> of "Learn how to program in C" and those basic C tasks.
> I decided to make my own projects, understand manual pages style, learn how
> to make sucessfull web search, use irc channel and so on...
> I am coding a project, that It's a like a telnetd with login features, it
> becomes a daemon, listens on certain port, accepts connection, autenticate, and
> execute a shell.
> The problem is when authentication is successful, It execve() a /bin/sh
> however, I want to define certain variable such as PATH, TERM, etc.
> I want that when a client 'logs in', my daemon set certain variables (ej.
> PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin) and then
> executes the shell, so the client has a presetted variables on his session.
> You may think, Why dont you read his .cshrc ?, I dont want to read any file
> on the system , I just want my daemon set everything and then executes the 
> shell.
> smthg like:
> char *PATH="/bin:/sbin:/usr/bin:/usr/sbin";
> char *TERM="vt100";
> char *FOO="bar";
> 
> I read putenv() man, Does it have any relation?, I dont know who to put it
> to work...
> 
> Thank you for any advice/help
> 
> bye.
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-26 14:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-26 11:41 New project xlp
2002-07-26 14:14 ` Bruno. N. F. Pacheco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).