Opened 8 years ago

Last modified 8 years ago

#501 new Feature Wish

environment variables don't pass to windows up script

Reported by: jktseug Owned by:
Priority: major Milestone:
Component: Generic / unclassified Version: OpenVPN git master branch (Community Ed)
Severity: Not set (select this one, unless your'e a OpenVPN developer) Keywords:


in windows up script none of the environment variables that were set by the command that calls openvpn are set. It would be nice to keep or copy all the variables over to the script so that they can be used, or define a way to get these variables.

Change History (5)

comment:1 Changed 8 years ago by Gert Döring

It should work by calling OpenVPN's --setenv command ("--setenv MYENV foo").

comment:2 Changed 8 years ago by Gert Döring

Type: Bug / DefectFeature Wish
Version: 2.2.2git master branch

comment:3 Changed 8 years ago by jktseug

If you have a complex need I could see that as being very complex to manage
--setenv value1 %value1% --setenv value2 %value2%

a quick fix to get around this
in a command script that calls openvpn.exe
set> variables.cmd

in the up/down script
call variables.cmd

comment:4 Changed 8 years ago by Samuli Seppänen

I'm inclined to just closing this unless the change to OpenVPN code would be trivial. Thoughts from the developers?

comment:5 Changed 8 years ago by jktseug

I think it should be trivial to call
GetEnvironmentStrings?(); and copy the whole block of memory to the new memory location.

You could even make this an extra option. The option would likely be harder but I doubt it would be that difficult.
I don't know if there is a security reason for removing the variables or if it is an unintended consequence of the way CreateProcessW works in windows.

I also haven't looked into this for linux.
If you are looking for a universal way, i believe you can add a third option to main for getting the entire environment variable block.

Note: See TracTickets for help on using tickets.