Active Topics

 


Reply
Thread Tools
barry99705's Avatar
Posts: 641 | Thanked: 27 times | Joined on Apr 2007
#11
Code:
#!/bin/sh
sudo gainroot
cd /usr/sbin/
openvpn --config /etc/openvpn/openvpn.conf
Here's what I have, maybe I'm missing something.

It does work if I run it manually.

Here's what it does.

Code:
~ $ ./vpn
Root shell enabled


BusyBox v1.4.1 (2007-03-12 19:00:25 EET) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

/home/user # exit
./vpn: ./vpn: 4: openvpn: not found
~ $
__________________
Just because you are online, doesn't mean you don't have to form a full sentence.


SEARCH! It's probably already been answered.

Last edited by barry99705; 2007-07-19 at 16:30.
 
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#12
If openvpn is in /usr/sbin then it sounds to me like /usr/sbin is not in $PATH after the sudo gainroot. If so, change that line
openvpn --config /etc/openvpn/openvpn.conf
to
./openvpn --config /etc/openvpn/openvpn.conf

(well, that's one way -- another is to fix the PATH. but the above should work everywhere.)
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.
 
barry99705's Avatar
Posts: 641 | Thanked: 27 times | Joined on Apr 2007
#13
Originally Posted by TA-t3 View Post
If openvpn is in /usr/sbin then it sounds to me like /usr/sbin is not in $PATH after the sudo gainroot. If so, change that line
openvpn --config /etc/openvpn/openvpn.conf
to
./openvpn --config /etc/openvpn/openvpn.conf

(well, that's one way -- another is to fix the PATH. but the above should work everywhere.)
Nope, /usr/sbin is in path. Now I get
Code:
./vpn: ./vpn: 4: ./openvpn: not found
You guys have tested this right? Because if it's doing what I think it's doing, once you gainroot, it's basically a new shell. Which causes the script to stop running.
__________________
Just because you are online, doesn't mean you don't have to form a full sentence.


SEARCH! It's probably already been answered.

Last edited by barry99705; 2007-07-20 at 16:08.
 
Posts: 17 | Thanked: 1 time | Joined on Jul 2007
#14
The script should work, but I don't know why you guys are using relative paths and changing directories in your shell scripts. Do it the clean way: use absolute paths. that would save a lot of posting. If it helps, here's my version of a shell script that works just great. And remember, a shell script just executes commands for you, so if you can execute the commands in a shell by hand, then you can do it in a script. Just don't get mixed up with relative paths:

VPN Script:
#!/bin/sh
/usr/bin/op
openvpn --config /etc/openvpn/config.conf &

Notice the "&" to background the process. And you're probably asking what "/usr/bin/op" is. It's just another shell script:
#!/bin/sh
sudo gainroot

The only reason it is another shell script is because sometimes I want to become root and don't want to type more than two characters--especially when i have to use that blasted on screen stylus keyboard with my thumbs. "op" is easy to type and it's near the enter key..
 
barry99705's Avatar
Posts: 641 | Thanked: 27 times | Joined on Apr 2007
#15
Originally Posted by rrwright View Post
The script should work, but I don't know why you guys are using relative paths and changing directories in your shell scripts. Do it the clean way: use absolute paths. that would save a lot of posting. If it helps, here's my version of a shell script that works just great. And remember, a shell script just executes commands for you, so if you can execute the commands in a shell by hand, then you can do it in a script. Just don't get mixed up with relative paths:

VPN Script:
#!/bin/sh
/usr/bin/op
openvpn --config /etc/openvpn/config.conf &

Notice the "&" to background the process. And you're probably asking what "/usr/bin/op" is. It's just another shell script:
#!/bin/sh
sudo gainroot

The only reason it is another shell script is because sometimes I want to become root and don't want to type more than two characters--especially when i have to use that blasted on screen stylus keyboard with my thumbs. "op" is easy to type and it's near the enter key..
Nope, still doesn't work.
Code:
~ $ ./vpn Root shell enabled   BusyBox v1.4.1 (2007-03-12 19:00:25 EET) Built-in shell (ash) 
Enter 'help' for a list of built-in commands.  
/home/user # 
/home/user # exit 
Fri Jul 20 13:19:22 2007 OpenVPN 2.0.7 arm-unknown-linux [SSL] [LZO] [EPOLL]
 built on Jul 17 2006 Fri Jul 20 13:19:22 2007 
IMPORTANT: OpenVPN's default port number is now 1194,
 based on an official port number assignment by IANA.
  OpenVPN 2.0-beta16 and earlier used 5000 as the default port. 
Enter Private Key Password: 
Fri Jul 20 13:19:27 2007 Error parsing PKCS#12 file Nokia.p12:

 error:23076071:lib(35):func(118):reason(113): error:23076071:lib(35):func(118):reason(113)
 Fri Jul 20 13:19:27 2007 
Error: private key password verification failed Fri Jul 20 13:19:27 2007 Exiting
 ~ $
It's runnung in the background now...
__________________
Just because you are online, doesn't mean you don't have to form a full sentence.


SEARCH! It's probably already been answered.

Last edited by barry99705; 2007-07-20 at 21:32. Reason: Gotta stop pasting from the 800
 
Posts: 13 | Thanked: 7 times | Joined on Jul 2007 @ Wuppertal, Germany
#16
sudo gainroot starts another shell process rather than raising
the privileges of the existing one.

A quick solution would be to make openvpn suid root as in
chmod 4755 /usr/sbin/openvpn
 
barry99705's Avatar
Posts: 641 | Thanked: 27 times | Joined on Apr 2007
#17
Originally Posted by mikemx View Post
sudo gainroot starts another shell process rather than raising
the privileges of the existing one.

A quick solution would be to make openvpn suid root as in
chmod 4755 /usr/sbin/openvpn

Nope.


I think I'll just stick to doing it manually. I know that works.

Crap! I knew I shouldn't have read that thread on how dangerous root was. Looks like in all my chown-ing and chmod-ing something got screwed up. I rebooted and get stuck at the Nokia screen....
__________________
Just because you are online, doesn't mean you don't have to form a full sentence.


SEARCH! It's probably already been answered.

Last edited by barry99705; 2007-07-20 at 23:53.
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:36.