environment variables to init

C, C++, Python, Perl, Shell, etc.

environment variables to init

Postby izotov » 09 Jul 2010, 09:10

Hi,
I have configured init to keep alive ssh tunnels specifying some ssh commands in [FILE]/etc/ttys[/FILE]. (For details see [man=8]init[/man].) It worked perfectly.

Now I must use passphrase protected private keys for ssh. To be able to use the key without typing in the passphrase all the time (which is impossible for an automated ssh tunnel) I use the ssh-agent.

Now my problem is that ssh communicates with ssh-agent through a socket stored in the SSH_AUTH_SOCK environment variable that is totally unknown by the init. How could I pass this variable to init?

Specifying it in [FILE]/etc/profile[/FILE] and [FILE]/etc/csh.login[/FILE] does not work.
Tried to create a script setting and exporting the variable and make init to run it with init_script loader variable does not work.

The only way I could make it work was to specify something similar to
Code: Select all
sh -c 'SSH_AUTH_SOCK=/tmp/ssh-init/agent ssh user@host'

instead of only
Code: Select all
ssh user@host
in [FILE]/etc/ttys[/FILE].
This is problematic as it starts two processes instead of only one and init monitors the sh process instead of the ssh and can produce misleading error messages. Not the best...

So the question is again: how could I pass some environment variables to init?

Thanks!
izotov
Member
 
Posts: 118
Joined: 02 Feb 2010, 07:35
Location: Budapest, Hungary

Postby Alt » 09 Jul 2010, 10:57

You can make an sh script that sets env variable and then exec(1) your ssh
Or may write
Code: Select all
sh -c 'SSH_AUTH_SOCK=/tmp/ssh-init/agent exec ssh user@host'
I think it should work
User avatar
Alt
Member
 
Posts: 726
Joined: 18 Nov 2008, 12:22
Location: Mother Russia

Postby izotov » 09 Jul 2010, 11:19

Yes, thanks for this tip. This solves my problem with the processes.

But the question is still alive: can I set environment variables for [font="Courier New"]init[/font] (or in more general for processes already running)?
izotov
Member
 
Posts: 118
Joined: 02 Feb 2010, 07:35
Location: Budapest, Hungary


Return to Userland Programming & Scripting

Who is online

Users browsing this forum: No registered users and 0 guests