Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ">>" with no command in configure can be ambigious for some ancient /bin/sh. #7876

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

mpsuzuki
Copy link
Contributor

Current configure script uses ambiguous syntax. Bash executes it correctly, but ancient Bourne shell may be confused. For example, an execution on FreeBSD 9.2 (2013) aborts like:

creating wolfssl-config - generic 5.7.2 for -lwolfssl -lpthread
checking the number of available CPUs... 2
configure: adding automake macro support
configure: creating aminclude.am
configure: added jobserver support to make for 3 jobs
checking that generated files are newer than configure... done
configure: creating ./config.status
./config.status: 2414: Syntax error: ";;" unexpected

The claimed part in config.status is a redirection ">>" with no command, like,

    "wolfssl/wolfcrypt/async.h":C) test ! -f $srcdir/wolfssl/wolfcrypt/async.h && >> $srcdir/wolfssl/wolfcrypt/async.h ;;
    "wolfssl/wolfcrypt/fips.h":C) test ! -f $srcdir/wolfssl/wolfcrypt/fips.h && >> $srcdir/wolfssl/wolfcrypt/fips.h ;;
    "wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h":C) test ! -f $srcdir/wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h && >> $srcdir/wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h ;;
    "wolfssl/wolfcrypt/port/intel/quickassist.h":C) test ! -f $srcdir/wolfssl/wolfcrypt/port/intel/quickassist.h && >> $srcdir/wolfssl/wolfcrypt/port/intel/quickassist.h ;;
    "wolfssl/wolfcrypt/port/intel/quickassist_mem.h":C) test ! -f $srcdir/wolfssl/wolfcrypt/port/intel/quickassist_mem.h && >> $srcdir/wolfssl/wolfcrypt/port/intel/quickassist_mem.h ;;

This part is expanded from AX_OUT_OF_TREE_FILE in configure.ac:

# See Automake 9.4.1 Built Sources Example
AC_DEFUN([AX_OUT_OF_TREE_FILE],[
  AC_CONFIG_COMMANDS([$1], [test ! -f $srcdir/$1 && >> $srcdir/$1])
])

A redirection ">>" with no leading command would be acceptable (I confirmed "> test.txt" causes no error on FreeBSD 9.2 /bin/sh), but using it in a case-esac statement can confuse the parser in some ancient /bin/sh. Maybe some /bin/sh try to capture the command after "&&", and misunderstand ";;" as the command to be executed (and failed).

Rewriting AC_CONFIG_COMMANDS to "test ! -f $srcdir/$1 && echo -n >> $srcdir/$1" would work for same result.

@wolfSSL-Bot
Copy link

Can one of the admins verify this patch?

@dgarske
Copy link
Contributor

dgarske commented Aug 15, 2024

Okay to test. Approved contributor agreement is on file.

@dgarske dgarske requested a review from douzzer August 15, 2024 14:43
@douzzer douzzer merged commit 9a693f5 into wolfSSL:master Aug 16, 2024
123 of 125 checks passed
@mpsuzuki
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants