a401 environment variables to init - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > Userland Programming & Scripting

Userland Programming & Scripting C, Shell, Perl, Sed & Awk

Reply
 
Thread Tools Display Modes
  #1  
Old July 9th, 2010, 10:10
izotov izotov is offline
Member
 
Join Date: Feb 2010
Location: Budapest, Hungary
Posts: 117
Thanks: 7
Thanked 6 Times in 6 Posts
Default environment variables to init

Hi,
I have configured init to keep alive ssh tunnels specifying some ssh commands in /etc/ttys. (For details see init(8).) 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 /etc/profile and /etc/csh.login 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:
sh -c 'SSH_AUTH_SOCK=/tmp/ssh-init/agent ssh user@host'
instead of only
Code:
ssh user@host
in /etc/ttys.
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!
Reply With Quote
  #2  
Old July 9th, 2010, 11:57
Alt's Avatar
Alt Alt is offline
Member
 
Join Date: Nov 2008
Location: Mother Russia
Posts: 726
Thanks: 32
Thanked 77 Times in 71 Posts
Default

You can make an sh script that sets env variable and then exec(1) your ssh
Or may write
Code:
sh -c 'SSH_AUTH_SOCK=/tmp/ssh-init/agent exec ssh user@host'
I think it should work

Last edited by Alt; July 9th, 2010 at 12:04.
Reply With Quote
  #3  
Old July 9th, 2010, 12:19
izotov izotov is offline
Member
 
Join Date: Feb 2010
Location: Budapest, Hungary
Posts: 117
Thanks: 7
Thanked 6 Times in 6 Posts
Default

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

But the question is still alive: can I set environment variables for init (or in more general for processes already running)?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Perl module variables Alt Userland Programming & Scripting 4 June 26th, 2010 09:52
Environment of daemon when starting with sudo ractive Porting New Software 3 January 27th, 2010 14:54
Programming environment in FreeBSD probe Userland Programming & Scripting 14 September 23rd, 2009 12:59
init scripte with nfs genius0815 Userland Programming & Scripting 2 July 27th, 2009 12:44
HOWTO: install Visual Understanding Environment (VUE) rocky Howtos & FAQs (Moderated) 0 April 3rd, 2009 04:23


All times are GMT +1. The time now is 06:17.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0