Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 234667 - net-misc/openvpn-2.1_rc9 doesn't seem to honour PEER_DNS setting
Summary: net-misc/openvpn-2.1_rc9 doesn't seem to honour PEER_DNS setting
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Cédric Krier
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-13 19:01 UTC by Jon Gerdes
Modified: 2008-11-01 15:50 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix openvpn init script for setenv (openvpn-2.1.init.diff,663 bytes, patch)
2008-09-22 13:19 UTC, Roy Marples
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Gerdes 2008-08-13 19:01:49 UTC
I have two systems using OpenVPN and recently upgraded to 2.1_rc9 on ~x86.  Suddenly I found that PEER_DNS was no longer honoured (set in /etc/conf.d/openvpn).

I use a /etc/init.d/openvpn.<myvpn> style configuration.

Reproducible: Always

Steps to Reproduce:
1. Upgrade to latest OVPN with PEER_DNS="no" set
2. DNS settings in resolv.conf overwritten
3. /etc/resolv.conf gets changed

Actual Results:  
resolv.conf changed

Expected Results:  
resolv.conf not to change

I can see where the init script has this:
# Ensure that our scripts get the PEER_DNS variable
        export PEER_DNS

I set an ewarn in the script and saw the setting at that point OK.

I changed up.sh and down.sh by adding SET_PEER="no" manually and that "fixed it".

I am using OpenRC but don't think that is the fault because I'm fairly sure that the previous OVPN I ran didn't suffer from this.
Comment 1 Thomas Beinicke 2008-09-11 12:27:11 UTC
I am having the same problem.
Using OpenRC with /etc/conf.d/openvpn -> PEER_DNS="no"
but it does get changed.

A fix for that would be highly appreciated.
Comment 2 meme 2008-09-19 23:07:03 UTC
(In reply to comment #0)
> I have two systems using OpenVPN and recently upgraded to 2.1_rc9 on ~x86. 
> Suddenly I found that PEER_DNS was no longer honoured (set in
> /etc/conf.d/openvpn).
> 
> I use a /etc/init.d/openvpn.<myvpn> style configuration.
> 
> Reproducible: Always
> 
> Steps to Reproduce:
> 1. Upgrade to latest OVPN with PEER_DNS="no" set
> 2. DNS settings in resolv.conf overwritten
> 3. /etc/resolv.conf gets changed
> 
> Actual Results:  
> resolv.conf changed
> 
> Expected Results:  
> resolv.conf not to change
> 
> I can see where the init script has this:
> # Ensure that our scripts get the PEER_DNS variable
>         export PEER_DNS
> 
> I set an ewarn in the script and saw the setting at that point OK.
> 
> I changed up.sh and down.sh by adding SET_PEER="no" manually and that "fixed
> it".

Did you verify that PEER_DNS was empty in this script?

> I am using OpenRC but don't think that is the fault because I'm fairly sure
> that the previous OVPN I ran didn't suffer from this.

This looks like the same bug I'm seeing with SVCNAME. 

I've checked, as you did, and I see it's defined correctly in the init script, but is empty when the up.sh script is run. As a result, my service-specific ${SVCNAME}-up.sh script doesn't get run.
As in your case, I can 'fix' it by redefining SVCNAME in up.sh.

Comment 3 meme 2008-09-20 09:22:45 UTC
Here's a fix for both of our problems that, at least, doesn't break when a different vpn service is started:
Modify /etc/init.d/openvpn as follows:
<               -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon ${args}
---
>               -- --config "${VPNCONF}" --writepid "${VPNPID}" --setenv SVCNAME "${SVCNAME}" \
>               --setenv PEER_DNS "${PEER_DNS}" --daemon ${args}
Comment 4 meme 2008-09-20 09:35:42 UTC
oops...that also needs to be done for shutdown; add
-- --setenv SVCNAME "${SVCNAME}" --setenv PEER_DNS "${PEER_DNS}"
to the end of the start-stop-daemon call
Comment 5 Thomas Beinicke 2008-09-20 22:20:45 UTC
Thanks meme, it works really well.

I tested it with settings peerdns to yes and no and the config works fine again.
I am using openrc as well so I don't know if it still works with the old system.

If no one objects this should enter the tree.
Comment 6 meme 2008-09-22 12:34:09 UTC
Maybe there's a better way to get the environment across to openvpn, or maybe there are more variables needed...
Noone else seems to be reading this bug, so CC:roy@marples.name
Comment 7 Roy Marples 2008-09-22 13:19:48 UTC
Created attachment 166092 [details, diff]
Fix openvpn init script for setenv

OpenRC is not to blame here - newer versions of OpenVPN dictate the whole env to the scripts, so exporting variables is now useless. This patch to the script fixes that.
Comment 8 meme 2008-09-22 20:09:22 UTC
Thanks Roy.
Something is needed for the shutdown side too though. I did this:
        ebegin "Stopping ${SVCNAME}"
        start-stop-daemon --stop --quiet \
-               --exec /usr/sbin/openvpn --pidfile "${VPNPID}"
+               --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \
+               -- --setenv SVCNAME "${SVCNAME}" --setenv PEER_DNS "${SVCNAME}"
        eend $?
 }
Comment 9 meme 2008-09-22 20:14:40 UTC
(In reply to comment #8)
Oops...worked for me, but the last line, of course, should be 
> +               -- --setenv SVCNAME "${SVCNAME}" --setenv PEER_DNS "${PEER_DNS}"

Comment 10 Roy Marples 2008-09-22 20:23:03 UTC
Your patch does nothing, as stopping OpenVPN does not affect the environment the current OpenVPN process sends to scripts.

What issues did you see shutting OpenVPN down?
Comment 11 meme 2008-09-22 21:17:49 UTC
(In reply to comment #10)
> Your patch does nothing, as stopping OpenVPN does not affect the environment
> the current OpenVPN process sends to scripts.
> 
> What issues did you see shutting OpenVPN down?

My shutdown script didn't run...I thought.
I've checked again with only the startup part of the patch, and it works fine.
Sorry about that.




Comment 12 Cédric Krier gentoo-dev 2008-11-01 15:50:17 UTC
Fix in cvs