]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_config.erl: Normalize hostnames in config file. If mixed case is used...
authorMickaël Rémond <mickael.remond@process-one.net>
Fri, 29 Jun 2007 17:27:42 +0000 (17:27 +0000)
committerMickaël Rémond <mickael.remond@process-one.net>
Fri, 29 Jun 2007 17:27:42 +0000 (17:27 +0000)
* src/stringprep/stringprep_sup.erl: Likewise
* src/stringprep/Makefile.in: Likewise
* src/stringprep/Makefile.win32: Likewise
* src/ejabberd_app.erl: Likewise

SVN Revision: 806

ChangeLog
src/ejabberd_app.erl
src/ejabberd_config.erl
src/ejabberd_service.erl
src/ejabberd_sup.erl
src/stringprep/Makefile.in
src/stringprep/Makefile.win32

index ab9ff684aae89e797e2f388fdbb14c68acd05949..af4b63f471fff8322ea247de091f732e0657c67b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-29  Mickael Remond  <mickael.remond@process-one.net>
+
+       * src/ejabberd_config.erl: Normalize hostnames in config file. If mixed
+       case is used, the hostname will be now useable (EJAB-277).
+       * src/stringprep/stringprep_sup.erl: Likewise
+       * src/stringprep/Makefile.in: Likewise
+       * src/stringprep/Makefile.win32: Likewise
+       * src/ejabberd_app.erl: Likewise
+
 2007-06-28  Mickael Remond  <mickael.remond@process-one.net>
 
        * src/ejabberd_auth_anonymous.erl: Do not purge non anonymous accounts
index dc1f4f58c203978068f0f18022a51bd5ce9dddda..8a08c0ce376fd7eeaf4a3a2ad5fc3caf0a5c1696 100644 (file)
@@ -23,6 +23,7 @@ start(normal, _Args) ->
     db_init(),
     sha:start(),
     catch ssl:start(),
+    stringprep_sup:start_link(),
     translate:start(),
     acl:start(),
     ejabberd_ctl:init(),
index 28c070af5fb4df6314302c850002bceb35068617..a44c9378f347968777de554e6d9f64b6f72dcb1d 100644 (file)
@@ -63,7 +63,7 @@ search_hosts(Term, State) ->
        {host, Host} ->
            if
                State#state.hosts == [] ->
-                   add_option(hosts, [Host], State#state{hosts = [Host]});
+                   add_hosts_to_option([Host], State);
                true ->
                    ?ERROR_MSG("Can't load config file: "
                               "too many hosts definitions", []),
@@ -72,7 +72,7 @@ search_hosts(Term, State) ->
        {hosts, Hosts} ->
            if
                State#state.hosts == [] ->
-                   add_option(hosts, Hosts, State#state{hosts = Hosts});
+                   add_hosts_to_option(Hosts, State);
                true ->
                    ?ERROR_MSG("Can't load config file: "
                               "too many hosts definitions", []),
@@ -82,6 +82,24 @@ search_hosts(Term, State) ->
            State
     end.
 
+add_hosts_to_option(Hosts, State) ->
+    PrepHosts = normalize_hosts(Hosts),
+    add_option(hosts, PrepHosts, State#state{hosts = PrepHosts}).
+
+normalize_hosts(Hosts) ->
+    normalize_hosts(Hosts,[]).
+normalize_hosts([], PrepHosts) ->
+    lists:reverse(PrepHosts);
+normalize_hosts([Host|Hosts], PrepHosts) ->
+    case jlib:nodeprep(Host) of
+       error ->
+           ?ERROR_MSG("Can't load config file: "
+                      "invalid host name [~p]", [Host]),
+           exit("invalid hostname");
+       PrepHost ->
+           normalize_hosts(Hosts, [PrepHost|PrepHosts])
+    end.
+
 process_term(Term, State) ->
     case Term of
        override_global ->
index 7d866f6f10c421c69f85f7e5e5f4dd265c2994cf..06bd50b4b992512dc90e93cf2f3c902e8e063151 100644 (file)
@@ -37,7 +37,7 @@
                hosts, password, access,
                check_from}).
 
-%-Define(DBGFSM, true).
+%-define(DBGFSM, true).
 
 -ifdef(DBGFSM).
 -define(FSMOPTS, [{debug, [trace]}]).
index af2c16f8f6e288739e7c0ce838bb2fe7c4f096ce..074b12eeddd0b50e61a6710569aa694541a30427 100644 (file)
@@ -17,7 +17,6 @@
 start_link() ->
     supervisor:start_link({local, ?MODULE}, ?MODULE, []).
 
-
 init([]) ->
     Hooks =
        {ejabberd_hooks,
@@ -26,13 +25,6 @@ init([]) ->
         brutal_kill,
         worker,
         [ejabberd_hooks]},
-    StringPrep =
-       {stringprep,
-        {stringprep, start_link, []},
-        permanent,
-        brutal_kill,
-        worker,
-        [stringprep]},
     NodeGroups =
        {ejabberd_node_groups,
         {ejabberd_node_groups, start_link, []},
@@ -155,7 +147,6 @@ init([]) ->
         [ejabberd_tmp_sup]},
     {ok, {{one_for_one, 10, 1},
          [Hooks,
-          StringPrep,
           NodeGroups,
           SystemMonitor,
           Router,
index e44f8c96a0713b1b29abedada0bae1ae7ce1774c..5de176bd7847b9dfadd1b4b6708dcafb81125f6f 100644 (file)
@@ -25,7 +25,8 @@ ifdef debug
 endif
 
 OBJS   = \
-       $(OUTDIR)/stringprep.beam
+       $(OUTDIR)/stringprep.beam \
+       $(OUTDIR)/stringprep_sup.beam
 
 all:    $(OBJS) $(ERLSHLIBS)
 
index 37e806a1abcaa8faf8e4b26806abb65df19868ed..03d7a3dd50a73aaffc3d4425fc9eeb1b9d9f5d97 100644 (file)
@@ -9,7 +9,8 @@ AUXIL  = uni_data.c uni_norm.c
 OBJECT = stringprep_drv.o
 DLL    = $(OUTDIR)\stringprep_drv.dll
 
-ALL : $(DLL) $(OUTDIR)\stringprep.beam
+ALL : $(DLL) $(OUTDIR)\stringprep.beam \
+       $(OUTDIR)\stringprep_sup.beam
 
 CLEAN :
        -@erase $(DLL)
@@ -17,10 +18,14 @@ CLEAN :
        -@erase $(OUTDIR)\stringprep_drv.lib
        -@erase $(OBJECT)
        -@erase $(OUTDIR)\stringprep.beam
+       -@erase $(OUTDIR)\stringprep_sup.beam
 
 $(OUTDIR)\stringprep.beam : stringprep.erl
        erlc -W $(EFLAGS) -o $(OUTDIR) stringprep.erl
 
+$(OUTDIR)\stringprep_sup.beam : stringprep_sup.erl
+       erlc -W $(EFLAGS) -o $(OUTDIR) stringprep_sup.erl
+
 CC=cl.exe
 CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include"