Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
shell exec cmd prob [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
nordic bro
Guru
Guru


Joined: 25 Oct 2003
Posts: 561

PostPosted: Tue Aug 20, 2013 5:35 pm    Post subject: shell exec cmd prob [solved] Reply with quote

this is run from a script that's started by a desktop file to pop up a terminal to temporarily interact with. I need to:

1. prevent terminal from closing immediately after input since I may have entered it wrong and need to re-enter;

2. use the open terminal to temporarily block subsequent things in the script from running until I'm ready to have them run.

/usr/bin/xterm -e sh -c "echo -n pw | sudo openconnect .... --background ...; sh"

I'm using 2-factor auth so openconnect will display a "Response:" prompt - if I mistype the code openconnect will ask for pw again then "Response:" once more so added "; sh" to keep terminal open temporarily.

then once I'm on the vpn I have to do a second administrator-like login on the vpn via my web browser which I don't think the script can be used to monitor so instead I use the fact the open terminal will temporarily block the rest of the script until this second login is complete. I then close the terminal with the intention of allowing the script to continue its other tasks.

part 1 works fine, the problem is part 2 in that when I close the terminal it kills the vpn session. is what I'm using now too convoluted and/or will never work? or maybe there's a fix for #2? I've tried "&" here and there to background openconnect (although it has its own "--background" so wouldn't think that's needed) such that it doesn't get killed but so far anywhere I put it doesn't have the desired effect - maybe some embedded shell subtlety I'm not appreciating?

thanks.


Last edited by nordic bro on Tue Aug 27, 2013 12:23 am; edited 1 time in total
Back to top
View user's profile Send private message
tomk
Administrator
Administrator


Joined: 23 Sep 2003
Posts: 7219
Location: Sat in front of my computer

PostPosted: Wed Aug 21, 2013 7:41 pm    Post subject: Reply with quote

Moved from Portage & Programming to Desktop Environments at nordic bro's request.
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
nordic bro
Guru
Guru


Joined: 25 Oct 2003
Posts: 561

PostPosted: Tue Aug 27, 2013 12:22 am    Post subject: Reply with quote

turns out an openconnect option was causing the problem ("--setuid" which is to drop to user privs after vpn is up). I tried many experiments including nohup/disown, other terminals/shells, etc., but not until I removed that option did the session stay up after terminal was closed. I can use that option if I copy/paste the cmd into an existing xterm then close after, must be a combo thing of how I'm having the script pop up an xterm that leads to the trouble.
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 3803

PostPosted: Wed Aug 28, 2013 10:05 pm    Post subject: Reply with quote

If a program opens a file (here probably a tty) then it still can access the file even after privileges are dropped. However, once it closes the file and reopens, it needs the appropriate privileges. This is the same problem why "screen" is in certain situations unable to attach to the active terminal.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum