Remove hardcoded path to resolvconf
PATCH 1/1 Remove hardcoded path to resolvconf
--- contrib/pull-resolv-conf/client.down | 5 +++-- contrib/pull-resolv-conf/client.up | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
contrib/pull-resolv-conf/client.down +3 -2
@@ -34,9 +34,10 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin -if [ -x /sbin/resolvconf ] ; then - /sbin/resolvconf -d "${1}" +if type resolvconf >/dev/null 2>&1; then + resolvconf -d "${1}" -f elif [ -e /etc/resolv.conf.ovpnsave ] ; then # cp + rm rather than mv in case it's a symlink cp /etc/resolv.conf.ovpnsave /etc/resolv.conf
contrib/pull-resolv-conf/client.up +3 -2
@@ -33,6 +33,7 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin # init variables
@@ -86,8 +87,8 @@ fi out="# resolv.conf autogenerated by ${0} (${1})${nl}${dns}${nl}${ds}${domains}" # use resolvconf if it's available -if [ -x /sbin/resolvconf ] ; then - printf "%s\n" "${out}" | /sbin/resolvconf -a "${1}" +if type resolvconf >/dev/null 2>&1; then + printf "%s\n" "${out}" | resolvconf -p -a "${1}" else # Preserve the existing resolv.conf if [ -e /etc/resolv.conf ] ; then
Signature · 1 line
1.7.3.2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 11 lines · Jesse Young
Signed-off-by Jesse Young <[email protected]...>--- contrib/pull-resolv-conf/client.down | 5 +++-- contrib/pull-resolv-conf/client.up | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)contrib/pull-resolv-conf/client.down +0
-0
contrib/pull-resolv-conf/client.down line 39
Quoted 8 lines
contrib/pull-resolv-conf/client.down +2
-2@@ -34,9 +34,10 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin -if [ -x /sbin/resolvconf ] ; then - /sbin/resolvconf -d "${1}" +if type resolvconf >/dev/null 2>&1; then
Hi and thank you for your patch!
Even though I do see that this approach is much cleaner. Hardcoded paths is not ideal. But I am not sure I like this way of test. It works probably fine on up-to-date systems, but will it run on all most bash versions? We must consider that there are some old systems with older bash installations which we might break.
I'd rather see a similar patch which checks the exit code instead of something more undefined like this approach. Also for clarity in the code of what we expect or not.
kind regards,
David Sommerseth
Quoted 17 lines
contrib/pull-resolv-conf/client.down +1
-0+ resolvconf -d "${1}" -f elif [ -e /etc/resolv.conf.ovpnsave ] ; then # cp + rm rather than mv in case it's a symlink cp /etc/resolv.conf.ovpnsave /etc/resolv.confcontrib/pull-resolv-conf/client.up +1
-0@@ -33,6 +33,7 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin # init variables
contrib/pull-resolv-conf/client.up fi · line 94
Quoted 10 lines
contrib/pull-resolv-conf/client.up +2
-2@@ -86,8 +87,8 @@ fi out="# resolv.conf autogenerated by ${0} (${1})${nl}${dns}${nl}${ds}${domains}" # use resolvconf if it's available -if [ -x /sbin/resolvconf ] ; then - printf "%s\n" "${out}" | /sbin/resolvconf -a "${1}" +if type resolvconf >/dev/null 2>&1; then + printf "%s\n" "${out}" | resolvconf -p -a "${1}" else # Preserve the existing resolv.conf if [ -e /etc/resolv.conf ] ; then
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkzbKc8ACgkQDC186MBRfroIxgCdG+GexMR06qTHB4HvDsNtK1eK 10cAnikZC4ppKb62udCCR3Lx/5VeEzVi
=6aYB
-----END PGP SIGNATURE-----
Quoted 20 lines · David Sommerseth
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 16 lines · Jesse Young
Signed-off-by Jesse Young <[email protected]...>--- contrib/pull-resolv-conf/client.down | 5 +++-- contrib/pull-resolv-conf/client.up | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)contrib/pull-resolv-conf/client.down +1
-0@@ -34,9 +34,10 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
Quoted 5 lines
contrib/pull-resolv-conf/client.down line 39
Quoted 3 lines
contrib/pull-resolv-conf/client.down +1
-2-if [ -x /sbin/resolvconf ] ; then - /sbin/resolvconf -d "${1}" +if type resolvconf >/dev/null 2>&1; thenHi and thank you for your patch!
Hi David, Thanks for your comments. Hopefully, I will address them to your satisfaction.
Quoted 9 lines
Even though I do see that this approach is much cleaner. Hardcoded paths is not ideal. But I am not sure I like this way of test. It works probably fine on up-to-date systems, but will it run on all most bash versions? We must consider that there are some old systems with older bash installations which we might break.
I'd rather see a similar patch which checks the exit code instead of something more undefined like this approach. Also for clarity in the code of what we expect or not.
I quickly ran this if statement in dash, bash --posix, and busybox's implementation of sh, and all three worked as expected. In fact, this is POSIX behavior.
See:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
Quoted 2 lines
The if command shall execute a compound-list and use its exit status to determine whether to execute another compound-list.
Furthermore, I've explicitly changed the shell to /bin/dash and verified that it works. Also, this is the way dhcpcd determines if resolvconf exists, from where I borrowed this code.
As for code clairity, I beleive this is a common sh idiom to branch on the exit status of a command wile directing output to /dev/null. I have personally seen it in many sh code.
Thanks,
Jesse
Quoted 41 lines
kind regards,
David Sommerseth
Quoted 17 lines
contrib/pull-resolv-conf/client.down +1
-0+ resolvconf -d "${1}" -f elif [ -e /etc/resolv.conf.ovpnsave ] ; then # cp + rm rather than mv in case it's a symlink cp /etc/resolv.conf.ovpnsave /etc/resolv.confcontrib/pull-resolv-conf/client.up +1
-0@@ -33,6 +33,7 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin # init variablescontrib/pull-resolv-conf/client.up fi · line 94
Quoted 10 lines
contrib/pull-resolv-conf/client.up +2
-2@@ -86,8 +87,8 @@ fi out="# resolv.conf autogenerated by ${0} (${1})${nl}${dns}${nl}${ds}${domains}" # use resolvconf if it's available -if [ -x /sbin/resolvconf ] ; then - printf "%s\n" "${out}" | /sbin/resolvconf -a "${1}" +if type resolvconf >/dev/null 2>&1; then + printf "%s\n" "${out}" | resolvconf -p -a "${1}" else # Preserve the existing resolv.conf if [ -e /etc/resolv.conf ] ; then-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkzbKc8ACgkQDC186MBRfroIxgCdG+GexMR06qTHB4HvDsNtK1eK 10cAnikZC4ppKb62udCCR3Lx/5VeEzVi
=6aYB
-----END PGP SIGNATURE-----
David Sommerseth
Applied-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 33 lines · Jesse Young
On Thu, Nov 11, 2010 at 00:25:03 +0100, David Sommerseth wrote:
Quoted 16 lines · Jesse Young
Quoted 16 lines
Quoted 16 lines
Signed-off-by Jesse Young <[email protected]...>--- contrib/pull-resolv-conf/client.down | 5 +++-- contrib/pull-resolv-conf/client.up | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)contrib/pull-resolv-conf/client.down +1
-0@@ -34,9 +34,10 @@ # A horrid work around, from a security perspective, # is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have # been WARNED. +PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbinQuoted 3 lines
Quoted 3 lines
contrib/pull-resolv-conf/client.down line 39
Quoted 3 lines
contrib/pull-resolv-conf/client.down +1
-2-if [ -x /sbin/resolvconf ] ; then - /sbin/resolvconf -d "${1}" +if type resolvconf >/dev/null 2>&1; thenHi and thank you for your patch!
Quoted 2 lines
Hi David, Thanks for your comments. Hopefully, I will address them to your satisfaction.
Even though I do see that this approach is much cleaner. Hardcoded paths is not ideal. But I am not sure I like this way of test. It works probably fine on up-to-date systems, but will it run on all most bash versions? We must consider that there are some old systems with older bash installations which we might break.
Quoted 7 lines
I'd rather see a similar patch which checks the exit code instead of something more undefined like this approach. Also for clarity in the code of what we expect or not.
Quoted 3 lines
I quickly ran this if statement in dash, bash --posix, and busybox's implementation of sh, and all three worked as expected. In fact, this is POSIX behavior.
Perfect! When it's a defined standard, I'll accept it more easily :)
Applied to bugfix2.1, to be merged into allmerged and beta2.2.
commit 3adf2f558e157ef5087ca44f13e097a394ef7c78
Author: Jesse Young <[email protected]...> Date: Mon Nov 1 11:33:26 2010 -0500
Remove hardcoded path to resolvconf
Signed-off-by: Jesse Young <[email protected]...>
Acked-by: David Sommerseth <[email protected]...>
Signed-off-by: David Sommerseth <[email protected]...>kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkzgXdUACgkQDC186MBRfrosWgCdEqCt+ik6013KlDRN5e67WnQ+ MOsAnRvzVAlOEi7KVZbiITonVyLWGZ82
=LI99
-----END PGP SIGNATURE-----