PATCH: remove bashisms from easy-rsa
Hi,
based on a FreeBSD problem report, I am attaching a patch against the 2.1 branch to remove a bashism (source FILE needs to become . FILE) and switch the shebang lines to /bin/sh.
Note that some parts of the scripts may be Solaris /bin/sh unfriendly, for instance, Solaris's sh doesn't support test -e or [ -e. My patch does not address this.
Please apply.
Best regards
Matthias Andree
build-ca +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Build a root certificate
inherit-inter +2 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Build a new PKI which is rooted on an intermediate certificate generated # by ./build-inter or ./pkitool --inter from a parent PKI. The new PKI should
@@ -34,6 +34,6 @@ cp "$PARENT_CA" "$KEY_DIR/$EXPORT_CA" cat "$KEY_DIR/ca.crt" >> "$KEY_DIR/$EXPORT_CA" else - echo 'Please source the vars script first (i.e. "source ./vars")' + echo 'Please source the vars script first (i.e. ". ./vars")' echo 'Make sure you have edited it to reflect your configuration.' fi
pkitool +3 -3
@@ -45,7 +45,7 @@ need_vars() { echo ' Please edit the vars script to reflect your configuration,' - echo ' then source it with "source ./vars".' + echo ' then source it with ". ./vars".' echo ' Next, to start with a fresh PKI configuration and to delete any' echo ' previous certificates and keys, run "./clean-all".' echo " Finally, you can run this tool ($PROGNAME) to build certificates/keys."
@@ -109,7 +109,7 @@ echo "Typical usage for initial PKI setup. Build myserver, client1, and client2 cert/keys." echo "Protect client2 key with a password. Build DH parms. Generated files in ./keys :" echo " [edit vars with your site-specific info]" - echo " source ./vars" + echo " . ./vars" echo " ./clean-all" echo " ./build-dh -> takes a long time, consider backgrounding" echo " ./$PROGNAME --initca"
@@ -117,7 +117,7 @@ echo " ./$PROGNAME client1" echo " ./$PROGNAME --pass client2" echo "Typical usage for adding client cert to existing PKI:" - echo " source ./vars" + echo " . ./vars" echo " ./$PROGNAME client-new" }
build-req +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Build a certificate signing request and private key. Use this # when your root certificate and key is not available locally.
build-key +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Make a certificate/private key pair using a locally generated # root certificate.
sign-req +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Sign a certificate signing request (a .csr file) # with a local root certificate and key.
build-key-pkcs12 +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Make a certificate/private key pair using a locally generated # root certificate and convert it to a PKCS #12 file including the
clean-all +2 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Initialize the $KEY_DIR directory. # Note that this script does a
@@ -11,6 +11,6 @@ touch "$KEY_DIR/index.txt" && \ echo 01 >"$KEY_DIR/serial" else - echo 'Please source the vars script first (i.e. "source ./vars")' + echo 'Please source the vars script first (i.e. ". ./vars")' echo 'Make sure you have edited it to reflect your configuration.' fi
build-req-pass +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Like build-req, but protect your private key # with a password.
build-dh +2 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Build Diffie-Hellman parameters for the server side # of an SSL/TLS connection.
@@ -6,6 +6,6 @@ if [ -d $KEY_DIR ] && [ $KEY_SIZE ]; then $OPENSSL dhparam -out ${KEY_DIR}/dh${KEY_SIZE}.pem ${KEY_SIZE} else - echo 'Please source the vars script first (i.e. "source ./vars")' + echo 'Please source the vars script first (i.e. ". ./vars")' echo 'Make sure you have edited it to reflect your configuration.' fi
list-crl +2 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # list revoked certificates
@@ -8,6 +8,6 @@ cd "$KEY_DIR" && \ $OPENSSL crl -text -noout -in "$CRL" else - echo 'Please source the vars script first (i.e. "source ./vars")' + echo 'Please source the vars script first (i.e. ". ./vars")' echo 'Make sure you have edited it to reflect your configuration.' fi
build-key-server +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Make a certificate/private key pair using a locally generated # root certificate.
build-key-pass +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Similar to build-key, but protect the private key # with a password.
revoke-full +2 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # revoke a certificate, regenerate CRL, # and verify revocation
@@ -35,6 +35,6 @@ # verify the revocation $OPENSSL verify -CAfile "$RT" -crl_check "$1.crt" else - echo 'Please source the vars script first (i.e. "source ./vars")' + echo 'Please source the vars script first (i.e. ". ./vars")' echo 'Make sure you have edited it to reflect your configuration.' fi
README +3 -3
@@ -188,7 +188,7 @@ label : PKCS#11 token label Notes: Please edit the vars script to reflect your configuration, - then source it with "source ./vars". + then source it with ". ./vars". Next, to start with a fresh PKI configuration and to delete any previous certificates and keys, run "./clean-all". Finally, you can run this tool (pkitool) to build certificates/keys.
@@ -217,7 +217,7 @@ Typical usage for initial PKI setup. Build myserver, client1, and client2 cert/keys. Protect client2 key with a password. Build DH parms. Generated files in ./keys : [edit vars with your site-specific info] - source ./vars + . ./vars ./clean-all ./build-dh -> takes a long time, consider backgrounding ./pkitool --initca
@@ -225,5 +225,5 @@ ./pkitool client1 ./pkitool --pass client2 Typical usage for adding client cert to existing PKI: - source ./vars + . ./vars ./pkitool client-new
build-inter +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Make an intermediate CA certificate/private key pair using a locally generated # root certificate.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 5 lines · Matthias Andree
Hi,
based on a FreeBSD problem report, I am attaching a patch against the 2.1 branch to remove a bashism (source FILE needs to become . FILE) and switch the shebang lines to
/bin/sh.
Thank you very much for your patch!
Quoted 3 lines
Note that some parts of the scripts may be Solaris
/bin/shunfriendly, for instance, Solaris's sh doesn't support test -e or [ -e. My patch does not address this.
This makes me very reluctant from accepting the patch, to be very honest. I'd rather keep the current bashism which works on all platforms where bash is available than to apply a patch which will break the script from working on one of the supported platforms.
I would rather like to see a patch which works safely on all platforms.
If 'test -e' or '[ -e' does not work in /bin/sh on some platforms, that
do indeed speak for keeping the bash support - unless there are other ways how to solve this issue.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkwKsikACgkQDC186MBRfrqlGwCffs/zQP5ZKmYD7mMlT9rse4TB ml4AoIxTVVpKHnOJgMNDKPFaCSHdGb6D
=ACWx
-----END PGP SIGNATURE-----
Quoted 11 lines · David Sommerseth
Quoted 3 lines · Matthias Andree
Note that some parts of the scripts may be Solaris
/bin/shunfriendly, for instance, Solaris's sh doesn't support test -e or [ -e. My patch does not address this.This makes me very reluctant from accepting the patch, to be very honest. I'd rather keep the current bashism which works on all platforms where bash is available than to apply a patch which will break the script from working on one of the supported platforms.
Quoted 4 lines
I would rather like to see a patch which works safely on all platforms.
If 'test -e' or '[ -e' does not work in/bin/shon some platforms, that
do indeed speak for keeping the bash support - unless there are other ways how to solve this issue.
I think Solaris should have a POSIX-compatible shell (korn shell, hence supporting test -e) under /usr/xpg4/bin/sh, although for some reason the default /bin/sh is an old bourne shell. People could link /bin/sh to the POSIX shell, and then the scripts should work fine.
However, I think it would be sensible, before merging, to actually do that and test the scripts on a real Solaris system to check that they work as expected (unfortunately I don't have access to a Solaris system, otherwise I would do that myself).
Signature · 1 line
D.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 17 lines · Davide Brini
Quoted 11 lines · David Sommerseth
Quoted 3 lines · Matthias Andree
Note that some parts of the scripts may be Solaris
/bin/shunfriendly, for instance, Solaris's sh doesn't support test -e or [ -e. My patch does not address this.This makes me very reluctant from accepting the patch, to be very honest. I'd rather keep the current bashism which works on all platforms where bash is available than to apply a patch which will break the script from working on one of the supported platforms.
Quoted 4 lines
I would rather like to see a patch which works safely on all platforms.
If 'test -e' or '[ -e' does not work in/bin/shon some platforms, that
do indeed speak for keeping the bash support - unless there are other ways how to solve this issue.
Quoted 4 lines
I think Solaris should have a POSIX-compatible shell (korn shell, hence supporting test -e) under
/usr/xpg4/bin/sh, although for some reason the default/bin/shis an old bourne shell. People could link/bin/shto the POSIX shell, and then the scripts should work fine.
Yes, that can be seen as a solution for some people. But then it would be better for us to explicitly require the needed shell rather to tell them to (w)hack their system "because easy-rsa don't support old Solaris /bin/sh".
We should *never ever* recommend people to modify their OS base installation at any point to make OpenVPN and/or its utilities to work.
In fact, it's probably more likely that they would go in and modify the
shell script themselves to use the proper shell instead of re-link /bin/sh - at least I hope the sys-admin would be that clever.
Anyhow, easy-rsa might not be the most critical tool, but accepting this patch will cause a regression in the Solaris users point of view. I'm not willing to accept breaking features which we do know work in the current release.
Quoted 4 lines
However, I think it would be sensible, before merging, to actually do that and test the scripts on a real Solaris system to check that they work as expected (unfortunately I don't have access to a Solaris system, otherwise I would do that myself).
The Solaris 10 docs states it pretty clear:
-e file
True if file exists. (Not available in sh.)
This limitation is also for -a, -G, -o, -O, -S, -nt, -ot and -ef.
source: <http://docs.sun.com/app/docs/doc/816-5165/test-1?l=en&a=view>
And there are 3 places where we do use 'test -e' in easy-rsa-2.0:
nherit-inter:29: if [ -e "$1/$EXPORT_CA" ]; then
pkitool:371: [ -e "$FN.crt.der" ]; rm "$FN.crt.der"
revoke-full:29: if [ -e export-ca.crt ]; then
We simply need to solve these issues to avoid bashism.
Davide: I know you have done some bashishm cleanup already on some other scripts. Can you double check that those scripts do not break, based on this Solaris information? I was not aware of this limitation in Solaris, so I did not check for such things during the review. But those patches needs to be double checked now.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkwKv/8ACgkQDC186MBRfrpIRgCgrq2qORzynmagW8sozDNYQL3g IHEAoJxf80eFjh9ugdzkm6Z4tMGR53ef
=/k22
-----END PGP SIGNATURE-----
Quoted 10 lines · David Sommerseth
Yes, that can be seen as a solution for some people. But then it would be better for us to explicitly require the needed shell rather to tell them to (w)hack their system "because easy-rsa don't support old Solaris
/bin/sh".We should *never ever* recommend people to modify their OS base installation at any point to make OpenVPN and/or its utilities to work.
In fact, it's probably more likely that they would go in and modify the
shell script themselves to use the proper shell instead of re-link/bin/sh- at least I hope the sys-admin would be that clever.
Ok, I wasn't aware of this policy. I thought that it could just be stated that the scripts need a POSIX shell (just as it's *already* de-facto stated that they require bash, which is not installed on all systems).
But ok, I'm not arguing on this; as you said, interested people will probably be able to adjust them to their needs anyway.
Quoted 15 lines
[snip]
Quoted 4 lines
However, I think it would be sensible, before merging, to actually do that and test the scripts on a real Solaris system to check that they work as expected (unfortunately I don't have access to a Solaris system, otherwise I would do that myself).
The Solaris 10 docs states it pretty clear:
-e file
True if file exists. (Not available in sh.)This limitation is also for -a, -G, -o, -O, -S, -nt, -ot and -ef.
source: <http://docs.sun.com/app/docs/doc/816-5165/test-1?l=en&a=view>
Quoted 7 lines
And there are 3 places where we do use 'test -e' in easy-rsa-2.0:
nherit-inter:29: if [ -e "$1/$EXPORT_CA" ]; then
pkitool:371: [ -e "$FN.crt.der" ]; rm "$FN.crt.der"
revoke-full:29: if [ -e export-ca.crt ]; thenWe simply need to solve these issues to avoid bashism.
Even after doing that, we're still NOT guaranteed that the scripts will work with Solaris' default /bin/sh. There may still be other constructs not supported by Solaris' default /bin/sh.
Solaris' default /bin/sh is NOT a POSIX shell; it's an old Bourne shell, which I'm not familiar with except for knowing that many things I and most people are used to are not supported (I don't know exactly what these missing features are, although it should definitely be possible to find out).
For the case at hand, I'd say it could be enough to replace "test -e" with "test -f", since we're testing for files anyway:
-e pathname
True if pathname resolves to an existing directory entry. False if pathname cannot be resolved.
-f pathname
True if pathname resolves to an existing directory entry for a regular file. False if pathname cannot be resolved, or if pathname resolves to an existing directory entry for a file that is not a regular file.
This description is for a POSIX shell; -f should be supported by the Bourne shell, as it's not in the list you quoted above. However, I don't know it the Bourne shell's semantic for -f is the same as POSIX's. I think it should be similar or equal.
<rant>
I'm not sure why Solaris has been insisting for ages now in shipping default tools that are either old, with less features or downright broken. It's not just about sh; other popular tools like awk are also pretty much unusable by default under Solaris; one needs to use the POSIX-compliant versions that are under /usr/xpg4/bin/.
</rant>
Quoted 5 lines
Davide: I know you have done some bashishm cleanup already on some other scripts. Can you double check that those scripts do not break, based on this Solaris information? I was not aware of this limitation in Solaris, so I did not check for such things during the review. But those patches needs to be double checked now.
As I said, I don't have access to a Solaris box, and I'm not familiar with the old Bourne shell.
However, I can certainly check for POSIX compliance, which should be the lowest common compatibility level scripts should aim for IMHO.
Signature · 1 line
D.
Quoted 70 lines · Davide Brini
Quoted 10 lines · David Sommerseth
Yes, that can be seen as a solution for some people. But then it would be better for us to explicitly require the needed shell rather to tell them to (w)hack their system "because easy-rsa don't support old Solaris
/bin/sh".We should *never ever* recommend people to modify their OS base installation at any point to make OpenVPN and/or its utilities to work. In fact, it's probably more likely that they would go in and modify the shell script themselves to use the proper shell instead of re-link
/bin/sh- at least I hope the sys-admin would be that clever.Ok, I wasn't aware of this policy. I thought that it could just be stated that the scripts need a POSIX shell (just as it's *already* de-facto stated that they require bash, which is not installed on all systems).
But ok, I'm not arguing on this; as you said, interested people will probably be able to adjust them to their needs anyway.Quoted 15 lines
[snip]
Quoted 4 lines
However, I think it would be sensible, before merging, to actually do that and test the scripts on a real Solaris system to check that they work as expected (unfortunately I don't have access to a Solaris system, otherwise I would do that myself).
The Solaris 10 docs states it pretty clear:
-e file
True if file exists. (Not available in sh.)This limitation is also for -a, -G, -o, -O, -S, -nt, -ot and -ef.
source: <http://docs.sun.com/app/docs/doc/816-5165/test-1?l=en&a=view>Quoted 7 lines
And there are 3 places where we do use 'test -e' in easy-rsa-2.0:
nherit-inter:29: if [ -e "$1/$EXPORT_CA" ]; then
pkitool:371: [ -e "$FN.crt.der" ]; rm "$FN.crt.der"
revoke-full:29: if [ -e export-ca.crt ]; thenWe simply need to solve these issues to avoid bashism.
Even after doing that, we're still NOT guaranteed that the scripts will work with Solaris' default
/bin/sh. There may still be other constructs not supported by Solaris' default/bin/sh.Solaris' default
/bin/shis NOT a POSIX shell; it's an old Bourne shell, which I'm not familiar with except for knowing that many things I and most people are used to are not supported (I don't know exactly what these missing features are, although it should definitely be possible to find out).For the case at hand, I'd say it could be enough to replace "test -e" with "test -f", since we're testing for files anyway:
(quoted diff) +0
-2-e pathname True if pathname resolves to an existing directory entry. False if pathname cannot be resolved. -f pathname True if pathname resolves to an existing directory entry for aregular
file. False if pathname cannot be resolved, or if pathname
resolves to an
existing directory entry for a file that is not a regular file.This description is for a POSIX shell; -f should be supported by the Bourne shell, as it's not in the list you quoted above. However, I don't know it the Bourne shell's semantic for -f is the same as POSIX's. I think it should be similar or equal.
Quoted 7 lines
<rant>
I'm not sure why Solaris has been insisting for ages now in shipping default tools that are either old, with less features or downright broken. It's not just about sh; other popular tools like awk are also pretty much unusable by default under Solaris; one needs to use the POSIX-compliant versions that are under/usr/xpg4/bin/.
</rant>
Most of the common GNU utilities (including gcc) are in the standard Solaris install, either via /usr/sfw/ or by using g prefix (e.g. gawk, gmake).
--Toby
Quoted 25 lines
Quoted 6 lines
Davide: I know you have done some bashishm cleanup already on some other scripts. Can you double check that those scripts do not break, based on this Solaris information? I was not aware of this limitation in Solaris, so I did not check for such things during the review. But those patches needs to be double checked now.
As I said, I don't have access to a Solaris box, and I'm not familiar with the old Bourne shell.
However, I can certainly check for POSIX compliance, which should be the lowest common compatibility level scripts should aim for IMHO.
Signature · 11 lines
D. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 11 lines · Toby Thain
Quoted 7 lines
<rant>
I'm not sure why Solaris has been insisting for ages now in shipping default tools that are either old, with less features or downright broken. It's not just about sh; other popular tools like awk are also pretty much unusable by default under Solaris; one needs to use the POSIX-compliant versions that are under/usr/xpg4/bin/.
</rant>Most of the common GNU utilities (including gcc) are in the standard Solaris install, either via
/usr/sfw/or by using g prefix (e.g. gawk, gmake).
Possibly, but it still means that either scripts using standard names and expecting standard functionality have to be changed, or the system has to be changed to have the standard-named utilites point to the GNU versions.
Signature · 1 line
D.
Quoted 10 lines · Davide Brini
Quoted 8 lines · Toby Thain
Quoted 7 lines
<rant>
I'm not sure why Solaris has been insisting for ages now in shipping default tools that are either old, with less features or downright broken. It's not just about sh; other popular tools like awk are also pretty much unusable by default under Solaris; one needs to use the POSIX-compliant versions that are under/usr/xpg4/bin/.
</rant>
Quoted 7 lines
Quoted 3 lines
Most of the common GNU utilities (including gcc) are in the standard Solaris install, either via
/usr/sfw/or by using g prefix (e.g. gawk, gmake).Possibly, but it still means that either scripts using standard names and expecting standard functionality have to be changed, or the system has to be changed to have the standard-named utilites point to the GNU versions.
Yes and no... Autotools will generally find the g-binaries (obviously autotools has long supported Solaris). OpenSolaris does, I believe, bring more GNU to standard userland (but this is not uncontroversial).
It is a bit tricky deriving a portable bang-path in your case. But innovations like dash on Debian also serve to prove that 'all the world's not a GNU/Linux'.
--Toby
Quoted 13 lines
Signature · 12 lines
-- D. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 5 lines · Toby Thain
Quoted 5 lines
Quoted 4 lines
Most of the common GNU utilities (including gcc) are in the standard Solaris install, either via
/usr/sfw/or by using g prefix (e.g. gawk,
gmake).
Quoted 8 lines
Quoted 4 lines
Possibly, but it still means that either scripts using standard names and expecting standard functionality have to be changed, or the system has to be changed to have the standard-named utilites point to the GNU versions.
Yes and no... Autotools will generally find the g-binaries (obviously autotools has long supported Solaris). OpenSolaris does, I believe, bring more GNU to standard userland (but this is not uncontroversial).
Well yes, but to paraphrase what you say later, "all the world's not GNU", so probably not everyone uses autotools :-)
In my (admittedly limited) experience, solaris has always shipped non-standard or inferior default tools, even long before GNU came about.
Quoted 3 lines
It is a bit tricky deriving a portable bang-path in your case. But innovations like dash on Debian also serve to prove that 'all the world's not a GNU/Linux'.
Agreed! (although dash isn't perfect yet, but nevermind). That's why I think #!/bin/sh should be used.
WARNING: Long and boring stuff follows; for the short version, skip to the last paragraph.
Actually, to be really pedantic, the shabang is NOT truly standard. It's just historical practice, whose existence the standard acknowledges and tolerates. Here's what the standard says:
"If the first line of a file of shell commands starts with the characters "#!", the results are unspecified."
(See http://www.in-ulm.de/~mascheck/various/shebang/ for more details on the shabang than you'd ever want to know.)
However as I said, historical practice is recognized, so it's considered in the relevant sections:
--------------
"Applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by "getconf PATH", ensuring that the returned pathname is an absolute pathname and not a shell built-in.
...
Furthermore, on systems that support executable scripts (the "#!" construct), it is recommended that applications using executable scripts install them using "getconf PATH" to determine the shell pathname and update the "#!" script appropriately as it is being installed (for example, with sed)."
--------------
Yes, it's weird. But it does mean that users of shabang-based scripts are (theoretically) already expected to change the shabang path if needed. The standard goes on with some sample installation code which basically assumes that scripts should come in files named "script.source", and contain a magic word INSTALLSHELLPATH that would be replaced, at installation time, with the actual location of the POSIX-conformant "sh" on the system:
...
# Each script should begin:
#
# #!INSTALLSHELLPATH
#
scripts="a b c"
#
# Transform each script
#
for i in ${scripts}
do
sed -e "s|INSTALLSHELLPATH|${Pshell}|" < ${i}.source > ${i}done
where ${Pshell} is the location of "sh" determined from the output of "getconf PATH".
Alternatively, one would be supposed to do
PATH=$(getconf PATH)
to get a list of locations, on the system, where compliant tools are installed (under Solaris, that includes /usr/xpg4/bin). Then, run the scripts by doing
sh script
which, given the previously set $PATH, will find the POSIX "sh" on the system.
Obviously, certainly nobody adopts the suggested method, very few people use the alternative method, and virtually everybody relies on the shabang instead.
So, given that everyone uses the shabang, and that #!/bin/sh seems to have become a more-or-less de facto path (at least in many people's expectations), my opinion is that OpenVPN scripts should either use #!/bin/sh and specify that a POSIX shell is expected, or (less preferred) use #!/bin/bash and specify that (obviously) bash is expected. Requiring bash is less preferred because that would force its installation on systems that don't have it, but after all it certainly wouldn't be the first piece of software in history coming with prerequisites or dependencies.
Some systems don't install bash or a POSIX sh in /bin, so it may also be necessary to create symlinks on those systems. I think it's the easiest tradeoff, and should be done anyway, because on such systems many other #!/bin/sh or #!/bin/bash scripts are likely to break anyway.
Signature · 1 line
D.
Quoted 16 lines · Davide Brini
Quoted 5 lines · Toby Thain
Quoted 5 lines
Quoted 4 lines
Most of the common GNU utilities (including gcc) are in the standard Solaris install, either via
/usr/sfw/or by using g prefix (e.g. gawk,
gmake).Quoted 8 lines
Quoted 4 lines
Possibly, but it still means that either scripts using standard names and expecting standard functionality have to be changed, or the system has to be changed to have the standard-named utilites point to the GNU versions.
Yes and no... Autotools will generally find the g-binaries (obviously autotools has long supported Solaris). OpenSolaris does, I believe, bring more GNU to standard userland (but this is not uncontroversial).
Quoted 5 lines
Well yes, but to paraphrase what you say later, "all the world's not GNU", so probably not everyone uses autotools :-)
In my (admittedly limited) experience, solaris has always shipped non-standard or inferior default tools, even long before GNU came about.
Yes - Buggy/poorly supported vendor tools (Sun was certainly not the only or worst offender) was a major issue GNU was meant to fix. (In the particular case of SunOS, missing vendor compiler.)
Quoted 8 lines
Quoted 4 lines
It is a bit tricky deriving a portable bang-path in your case. But innovations like dash on Debian also serve to prove that 'all the world's not a GNU/Linux'.
Agreed! (although dash isn't perfect yet, but nevermind). That's why I think #!/bin/sh should be used.
--Toby
Quoted 3 lines
Signature · 2 lines
-- D.
Quoted 4 lines · Davide Brini
Some systems don't install bash or a POSIX sh in /bin, so it may also be necessary to create symlinks on those systems. I think it's the easiest tradeoff, and should be done anyway, because on such systems many other #!/bin/sh or #!/bin/bash scripts are likely to break anyway.
While the assertion that you're starting from is true (installation locations of sh), OpenVPN shouldn't be a tool that requires administrators to pollute their installations with symlinks.
I've posted a patch that forgoes the getconf part (I'm not sure currently if Solaris /bin/sh likes $(...) notation or insists on ...), and just does a blunt check for /usr/xpg4/bin/sh.
It's also a blunt hit in another place, it tries export FOO=bar in a subshell, which fails on Solaris 10's /bin/sh - and for instance pkitool relies on that syntax later when assigning OPENSSL. However I have no other offenders to test than Solaris 10.
As a side note, not sure if it was mentioned already, I've only superficially glanced at the whole long thread, Ubuntu uses dash (Debian Almqvist shell) for /bin/sh for efficiency reasons.
Finally, it appears that zsh can also emulates certain other shells, I'd recently received a FreeBSD bug report against some other (non-openvpn) software where someone was using zsh as bash replacement (for scripts that are documented to use bash and aren't easily fixed).
The fun never ends ;-)
Quoted 2 lines · Matthias Andree
I'm not sure currently if Solaris
/bin/shlikes $(...) notation or insists on...
`` is the only portable way.
//Peter
Quoted 17 lines · Davide Brini
Quoted 11 lines · David Sommerseth
Quoted 3 lines · Matthias Andree
Note that some parts of the scripts may be Solaris
/bin/shunfriendly, for instance, Solaris's sh doesn't support test -e or [ -e. My patch does not address this.This makes me very reluctant from accepting the patch, to be very honest. I'd rather keep the current bashism which works on all platforms where bash is available than to apply a patch which will break the script from working on one of the supported platforms.
Quoted 4 lines
I would rather like to see a patch which works safely on all platforms. If 'test -e' or '[ -e' does not work in
/bin/shon some platforms, that do indeed speak for keeping the bash support - unless there are other ways how to solve this issue.
Quoted 4 lines
I think Solaris should have a POSIX-compatible shell (korn shell, hence supporting test -e) under
/usr/xpg4/bin/sh, although for some reason the default/bin/shis an old bourne shell. People could link/bin/shto the POSIX shell, and then the scripts should work fine.
Solaris has shipped with bash for many years (/usr/bin/bash).
--Toby
Quoted 17 lines
However, I think it would be sensible, before merging, to actually do that and test the scripts on a real Solaris system to check that they work as expected (unfortunately I don't have access to a Solaris system, otherwise I would do that myself).
Signature · 11 lines
D. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 3 lines · David Sommerseth
I'd rather keep the current bashism which works on all platforms where bash is available than to apply a patch which will break the script from working on one of the supported platforms.
Agree.
//Peter