snd_user_file: avoid use wordexp

As suggested in POSIX[1], wordexp might execute the shell. If the libc
implementation does so, it will break the firefox sandbox which does
not allow exec. This happened on Alpine Linux with musl libc[2].

Since we cannot guarantee that the system wordexp implementation does
not execute shell, we cannot really use it, and need to implement the
~/ expansion ourselves.

We provide a configure option --with-wordexp for users that still may
need it, but we leave this off by default because wordexp is a large
attack vector and it is better to avoid it.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/wordexp.html#tag_16_684_08
[2]: http://bugs.alpinelinux.org/issues/7454#note-2

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Natanael Copa 2017-07-14 18:47:05 +02:00 committed by Takashi Iwai
parent adab355f35
commit cb34cee0d8
2 changed files with 75 additions and 9 deletions

View file

@ -303,8 +303,25 @@ fi
AC_SUBST(ALSA_DEPLIBS)
dnl Check for use of wordexp...
AC_MSG_CHECKING(for use of wordexp)
AC_ARG_WITH(wordexp,
AS_HELP_STRING([--with-wordexp],
[Use wordexp when expanding configs (default = no)]),
[case "$withval" in
y|yes) wordexp=yes ;;
*) wordexp=no ;;
esac],)
if test "$wordexp" = "yes" ; then
AC_DEFINE(HAVE_WORDEXP, "1", [Enable use of wordexp])
AC_MSG_RESULT(yes)
AC_CHECK_HEADER([wordexp.h],[], [AC_MSG_ERROR([Couldn't find wordexp.h])])
else
AC_MSG_RESULT(no)
fi
dnl Check for headers
AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h sys/shm.h])
AC_CHECK_HEADERS([endian.h sys/endian.h sys/shm.h])
dnl Check for resmgr support...
AC_MSG_CHECKING(for resmgr support)