3

I am attempting to write a python script for linux to start openvpn and have been running into a problem getting openvpn to start using subprocess.

I am using the following to start openvpn:

openvpn_cmd = ['sudo', 'openvpn', '--config', 'client.cfg', '--auth-user-pass', 'hmaauth.conf']
prog = subprocess.Popen(openvpn_cmd)

But I get the following error back from OpenVPN:

Options error: --nobind doesn't make sense unless used with --remote

The config file is downloaded directly from the VPN service website prior to running the subprocess command, so I can't (and shouldn't have to) change anything in the configuration.

I've heard this can happen if you don't run with root privileges, but I'm already doing that...

Does anyone have any suggestions as to why I am getting this error?

I have a working shell script that starts openvpn using the following:

sudo openvpn --config client.cfg --auth-user-pass hmaauth.conf

Which should be exactly what I have in my python script.

Thanks in advance for your advice.

Gfei
  • 73
  • 1
  • 7
  • maybe try with full paths for openvpn and the configuration files? – Uku Loskit Jan 10 '12 at 00:53
  • Does the `openvpn` command work from command line? I can't see any python issue here, except that maybe you forgot to change to the right directory. – Has QUIT--Anony-Mousse Jan 10 '12 at 07:36
  • The python script sits in the same directory as the configuration files, so that shouldn't be an issue. I'm scratching my head too, I can't see any issues with the python code. The same command works fine from a shell script... – Gfei Jan 10 '12 at 13:07
  • Gfei, when you run something as sudo, the environment variables are different. – Uku Loskit Jan 10 '12 at 13:08
  • Hmm, well I guess I'll try adding full paths when I get a chance later. I've never run in to that issue before. – Gfei Jan 10 '12 at 13:10

1 Answers1

3

Ok, the problem here is that I'm dumb. I was downloading a config file that didn't have the remote server for the VPN specified, now I understand the 'no remote' error.

Now that I have that cleared up we're good to go.

Gfei
  • 73
  • 1
  • 7