Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove support of wildcards for R15B03 and previous

A bug in filelib:wildcard/1,2 was fixed in R16B:
  erlang/otp@70b5e24

So, wildcard strings in the configuration file are now forbidden for older
releases.
  • Loading branch information...
commit a64236b0be6d0c76f7bff7796f12b164d8dbb8d3 1 parent e2a40fa
Christopher Faulet authored
View
15 configure.ac
@@ -211,6 +211,20 @@ fi
AM_CONDITIONAL(HAVE_BAD_UNICODE, [test "x$HAVE_BAD_UNICODE" = "xtrue"])
AC_SUBST(HAVE_BAD_UNICODE)
+dnl filelib:wildcard/2 was buggy for R15B03 and previous (ERTS <= 5.9.3)
+AC_MSG_CHECKING([for buggy filelib:wildcard/2 function])
+AX_COMPARE_VERSION([${ERLANG_ERTS_VER}], [le], [5.9.3],
+ [bad_wildcard="yes"],
+ [bad_wildcard="no"])
+AC_MSG_RESULT([${bad_wildcard}])
+
+HAVE_BAD_WILDCARD=false
+if test "x${bad_wildcard}" = "xyes"; then
+ HAVE_BAD_WILDCARD=true
+fi
+AM_CONDITIONAL(HAVE_BAD_WILDCARD, [test "x$HAVE_BAD_WILDCARD" = "xtrue"])
+AC_SUBST(HAVE_BAD_WILDCARD)
+
dnl Determine directories for installation.
if test "x${prefix}" != "xNONE" -a "x${ERLANG_INSTALL_LIB_DIR}" = "x"; then
dnl Under $prefix
@@ -511,6 +525,7 @@ AC_CONFIG_FILES([
src/yaws_appdeps.hrl
test/eunit//subconfig_DATA/yaws_absolute.conf
+ test/eunit//subconfig_DATA/yaws_absolute_no_wildcard.conf
test/support/yaws.conf
test/t1/yaws.conf
test/t2/yaws.conf
View
3  doc/yaws.tex
@@ -2437,6 +2437,9 @@ \section{Global Part}
subconfig = vhosts/*.conf
\end{verbatim}
+ \textbf{WARNING: because of a bug in filelib:wildcard/2, wildcard
+ strings are forbidden for R15B03 and previous.}
+
\item \verb+subconfigdir = Directory+ ---
Load all config files found in the specified directory. The given
Directory can be an absolute path or relative to the configuration
View
4 include.mk
@@ -28,6 +28,10 @@ ifeq ($(HAVE_BAD_UNICODE),true)
ERLC_GENERIC_FLAGS += -DHAVE_BAD_UNICODE
endif
+ifeq ($(HAVE_BAD_WILDCARD),true)
+ ERLC_GENERIC_FLAGS += -DHAVE_BAD_WILDCARD
+endif
+
# Local Variables:
# tab-width: 8
# End:
View
3  man/yaws.conf.5
@@ -280,6 +280,9 @@ Or, relatively to the configuration localtion:
subconfig = vhosts/*.conf
.fi
+\fBWARNING: because of a bug in filelib:wildcard/2, wildcard strings are
+forbidden for R15B03 and previous.\fR
+
.TP
\fBsubconfigdir = Directory\fR
View
31 src/yaws_config.erl
@@ -15,6 +15,12 @@
-include_lib("kernel/include/file.hrl").
+-ifndef(HAVE_BAD_WILDCARD).
+-define(WILDCARD_SUPPORTED, true).
+-else.
+-define(WILDCARD_SUPPORTED, false).
+-endif.
+
-export([load/1,
make_default_gconf/2, make_default_sconf/0, make_default_sconf/2,
add_sconf/1,
@@ -707,15 +713,22 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) ->
Err
end;
{false,true} ->
- Names = filelib:wildcard(Name, ConfPath),
- Files = [filename:absname(N, ConfPath)
- || N <- lists:sort(Names)],
- case subconfigfiles(Files, GC, Cs) of
- {ok, GC1, Cs1} ->
- fload(FD, globals, GC1, C, Cs1,
- Lno+1, Next);
- Err ->
- Err
+ %% below, ignore dialyzer warning:
+ case ?WILDCARD_SUPPORTED of
+ true ->
+ Names = filelib:wildcard(Name, ConfPath),
+ Files = [filename:absname(N, ConfPath)
+ || N <- lists:sort(Names)],
+ case subconfigfiles(Files, GC, Cs) of
+ {ok, GC1, Cs1} ->
+ fload(FD, globals, GC1, C, Cs1,
+ Lno+1, Next);
+ Err ->
+ Err
+ end;
+ false ->
+ {error, ?F("Unsupport wildcard at line ~w"
+ " [support by releases >= R16A ]",[Lno])}
end;
{false,false} ->
{error, ?F("Expect filename or wildcard at line ~w"
View
38 test/eunit/subconfig.erl
@@ -5,17 +5,18 @@
-include("yaws.hrl").
-include("tftest.hrl").
+
+-ifndef(HAVE_BAD_WILDCARD).
+
absolute_subconfig_test() ->
Env = #env{debug = false,
conf = {file, ?builddir++"/subconfig_DATA/yaws_absolute.conf"}},
-
{ok, _GC, SCs} = yaws_config:load(Env),
check_sconfs(lists:flatten(SCs)).
relative_subconfig_test() ->
Env = #env{debug = false,
conf = {file, ?srcdir++"/subconfig_DATA/yaws_relative.conf"}},
-
{ok, _GC, SCs} = yaws_config:load(Env),
check_sconfs(lists:flatten(SCs)).
@@ -28,3 +29,36 @@ check_sconfs(SCs) ->
?assert(lists:keymember(8004, #sconf.port, SCs)),
ok.
+-else.
+
+absolute_subconfig_test() ->
+ Env = #env{debug = false,
+ conf = {file, ?builddir++"/subconfig_DATA/yaws_absolute_no_wildcard.conf"}},
+ {ok, _GC, SCs} = yaws_config:load(Env),
+ check_sconfs(lists:flatten(SCs)).
+
+relative_subconfig_test() ->
+ Env = #env{debug = false,
+ conf = {file, ?srcdir++"/subconfig_DATA/yaws_relative_no_wildcard.conf"}},
+ {ok, _GC, SCs} = yaws_config:load(Env),
+ check_sconfs(lists:flatten(SCs)).
+
+unsupported_wildcard_test() ->
+ Env1 = #env{debug = false,
+ conf = {file, ?builddir++"/subconfig_DATA/yaws_absolute.conf"}},
+ {error, _} = yaws_config:load(Env1),
+
+ Env2 = #env{debug = false,
+ conf = {file, ?srcdir++"/subconfig_DATA/yaws_relative.conf"}},
+ {error, _} = yaws_config:load(Env2),
+ ok.
+
+
+check_sconfs(SCs) ->
+ ?assertEqual(3, length(SCs)),
+ ?assert(lists:keymember(80, #sconf.port, SCs)),
+ ?assert(lists:keymember(8003, #sconf.port, SCs)),
+ ?assert(lists:keymember(8004, #sconf.port, SCs)),
+ ok.
+
+-endif.
View
2  test/eunit/subconfig_DATA/yaws_absolute_no_wildcard.conf.in
@@ -0,0 +1,2 @@
+subconfigdir = @abs_srcdir@/subconfigdir.d
+subconfig = @abs_srcdir@/subconfig.conf
View
2  test/eunit/subconfig_DATA/yaws_relative_no_wildcard.conf
@@ -0,0 +1,2 @@
+subconfigdir = subconfigdir.d
+subconfig = subconfig.conf
Please sign in to comment.
Something went wrong with that request. Please try again.