diff --git a/doc/dev.html b/doc/dev.html index 1cac5b212..b7fea526a 100644 --- a/doc/dev.html +++ b/doc/dev.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/REC-html40/loose.dtd"> -Ejabberd 2.1.5 Developers Guide +<TITLE>Ejabberd 2.1.x Developers Guide @@ -49,7 +49,7 @@ TD P{margin:0px;}

-

Ejabberd 2.1.5 Developers Guide

Alexey Shchepin
+

Ejabberd 2.1.x Developers Guide

Alexey Shchepin
mailto:alexey@sevcom.net
xmpp:aleksey@jabber.ru

diff --git a/doc/features.html b/doc/features.html index 83d55d922..503ac0d3f 100644 --- a/doc/features.html +++ b/doc/features.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/REC-html40/loose.dtd"> -Ejabberd 2.1.5 Feature Sheet +<TITLE>Ejabberd 2.1.x Feature Sheet @@ -50,7 +50,7 @@ SPAN{width:20%; float:right; text-align:left; margin-left:auto;}

-

Ejabberd 2.1.5 Feature Sheet

Sander Devrieze
+

Ejabberd 2.1.x Feature Sheet

Sander Devrieze
mailto:s.devrieze@pandora.be
xmpp:sander@devrieze.dyndns.org

diff --git a/doc/guide.html b/doc/guide.html index 77fefc5d8..57873a873 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -6,7 +6,7 @@ - ejabberd 2.1.5 + ejabberd 2.1.x Installation and Operation Guide @@ -76,7 +76,7 @@ BLOCKQUOTE.figure DIV.center DIV.center HR{display:none;}


- +
ejabberd 2.1.5
ejabberd 2.1.x
 
Installation and Operation Guide

diff --git a/doc/version.tex b/doc/version.tex index 6c3a1154a..905ac86f2 100644 --- a/doc/version.tex +++ b/doc/version.tex @@ -1,2 +1,2 @@ % ejabberd version (automatically generated). -\newcommand{\version}{2.1.5} +\newcommand{\version}{2.1.x} diff --git a/src/Makefile.in b/src/Makefile.in index cf600c324..4e561813d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -31,6 +31,7 @@ else endif EFLAGS += @ERLANG_SSLVER@ -pa . +ERLANG_CFLAGS += @ERLANG_SSLVER@ # make debug=true to compile Erlang module with debug informations. ifdef debug @@ -63,6 +64,11 @@ ifeq (@transient_supervisors@, false) EFLAGS+=-DNO_TRANSIENT_SUPERVISORS endif +ifeq (@md2@, true) + EFLAGS+=-DHAVE_MD2 + ERLANG_CFLAGS += -DHAVE_MD2 +endif + INSTALL_EPAM= ifeq (@pam@, pam) INSTALL_EPAM=install -m 750 $(O_USER) epam $(PBINDIR) diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 09b166b99..5d9dbca60 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -134,7 +134,7 @@ ssldef() -> if OTP >= "R14" -> "-DSSL40\n"; OTP >= "R12" -> "-DSSL39\n"; - true -> "" + true -> "\n" end. %% return physical architecture based on OS/Processor diff --git a/src/configure b/src/configure index f8fd718a2..d515abc22 100755 --- a/src/configure +++ b/src/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for ejabberd 2.1.5. +# Generated by GNU Autoconf 2.65 for ejabberd 2.1.x. # # Report bugs to . # @@ -552,8 +552,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ejabberd' PACKAGE_TARNAME='ejabberd' -PACKAGE_VERSION='2.1.5' -PACKAGE_STRING='ejabberd 2.1.5' +PACKAGE_VERSION='2.1.x' +PACKAGE_STRING='ejabberd 2.1.x' PACKAGE_BUGREPORT='ejabberd@process-one.net' PACKAGE_URL='' @@ -608,6 +608,7 @@ build_os build_vendor build_cpu build +md2 INSTALLUSER SSL_CFLAGS SSL_LIBS @@ -1278,7 +1279,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ejabberd 2.1.5 to adapt to many kinds of systems. +\`configure' configures ejabberd 2.1.x to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1344,7 +1345,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ejabberd 2.1.5:";; + short | recursive ) echo "Configuration of ejabberd 2.1.x:";; esac cat <<\_ACEOF @@ -1469,7 +1470,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ejabberd configure 2.1.5 +ejabberd configure 2.1.x generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -1815,7 +1816,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ejabberd $as_me 2.1.5, which was +It was created by ejabberd $as_me 2.1.x, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -3224,7 +3225,7 @@ ssldef() -> if OTP >= "R14" -> "-DSSL40\n"; OTP >= "R12" -> "-DSSL39\n"; - true -> "" + true -> "\n" end. %% return physical architecture based on OS/Processor @@ -4822,6 +4823,16 @@ if test "$ENABLEUSER" != ""; then fi +ac_fn_c_check_header_mongrel "$LINENO" "openssl/md2.h" "ac_cv_header_openssl_md2_h" "$ac_includes_default" +if test "x$ac_cv_header_openssl_md2_h" = x""yes; then : + md2=true +else + md2=false +fi + + + + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do for ac_t in install-sh install.sh shtool; do @@ -5654,7 +5665,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ejabberd $as_me 2.1.5, which was +This file was extended by ejabberd $as_me 2.1.x, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5707,7 +5718,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ejabberd config.status 2.1.5 +ejabberd config.status 2.1.x configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff --git a/src/configure.ac b/src/configure.ac index 1497643d3..1d25dd871 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -148,6 +148,9 @@ if test "$ENABLEUSER" != ""; then AC_SUBST([INSTALLUSER], [$ENABLEUSER]) fi +AC_CHECK_HEADER(openssl/md2.h, md2=true, md2=false) +AC_SUBST(md2) + AC_CANONICAL_SYSTEM #AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$target") #AC_SUBST(target_os) diff --git a/src/ejabberd.app b/src/ejabberd.app index 0ebb1aaf4..67653d241 100644 --- a/src/ejabberd.app +++ b/src/ejabberd.app @@ -2,7 +2,7 @@ {application, ejabberd, [{description, "ejabberd"}, - {vsn, "2.1.5"}, + {vsn, "2.1.x"}, {modules, [acl, adhoc, configure, diff --git a/src/mod_caps.erl b/src/mod_caps.erl index dcd4145fe..126d4243e 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -277,25 +277,8 @@ feature_response(#iq{type = result, sub_el = [{xmlelement, _, _, Els}]}, Host, From, Caps, [SubNode | SubNodes]) -> BinaryNode = node_to_binary(Caps#caps.node, SubNode), - IsValid = case Caps#caps.hash of - "md2" -> - Caps#caps.version == make_disco_hash(Els, md2); - "md5" -> - Caps#caps.version == make_disco_hash(Els, md5); - "sha-1" -> - Caps#caps.version == make_disco_hash(Els, sha1); - "sha-224" -> - Caps#caps.version == make_disco_hash(Els, sha224); - "sha-256" -> - Caps#caps.version == make_disco_hash(Els, sha256); - "sha-384" -> - Caps#caps.version == make_disco_hash(Els, sha384); - "sha-512" -> - Caps#caps.version == make_disco_hash(Els, sha512); - _ -> - true - end, - if IsValid -> + case check_hash(Caps, Els) of + true -> Features = lists:flatmap( fun({xmlelement, "feature", FAttrs, _}) -> [xml:get_attr_s("var", FAttrs)]; @@ -305,7 +288,7 @@ feature_response(#iq{type = result, mnesia:dirty_write( #caps_features{node_pair = BinaryNode, features = features_to_binary(Features)}); - true -> + false -> mnesia:dirty_write(#caps_features{node_pair = BinaryNode}) end, feature_request(Host, From, Caps, SubNodes); @@ -350,6 +333,7 @@ make_my_disco_hash(Host) -> "" end. +-ifdef(HAVE_MD2). make_disco_hash(DiscoEls, Algo) -> Concat = [concat_identities(DiscoEls), concat_features(DiscoEls), @@ -371,6 +355,64 @@ make_disco_hash(DiscoEls, Algo) -> sha:sha512(Concat) end). +check_hash(Caps, Els) -> + case Caps#caps.hash of + "md2" -> + Caps#caps.version == make_disco_hash(Els, md2); + "md5" -> + Caps#caps.version == make_disco_hash(Els, md5); + "sha-1" -> + Caps#caps.version == make_disco_hash(Els, sha1); + "sha-224" -> + Caps#caps.version == make_disco_hash(Els, sha224); + "sha-256" -> + Caps#caps.version == make_disco_hash(Els, sha256); + "sha-384" -> + Caps#caps.version == make_disco_hash(Els, sha384); + "sha-512" -> + Caps#caps.version == make_disco_hash(Els, sha512); + _ -> + true + end. +-else. +make_disco_hash(DiscoEls, Algo) -> + Concat = [concat_identities(DiscoEls), + concat_features(DiscoEls), + concat_info(DiscoEls)], + base64:encode_to_string( + if Algo == md5 -> + crypto:md5(Concat); + Algo == sha1 -> + crypto:sha(Concat); + Algo == sha224 -> + sha:sha224(Concat); + Algo == sha256 -> + sha:sha256(Concat); + Algo == sha384 -> + sha:sha384(Concat); + Algo == sha512 -> + sha:sha512(Concat) + end). + +check_hash(Caps, Els) -> + case Caps#caps.hash of + "md5" -> + Caps#caps.version == make_disco_hash(Els, md5); + "sha-1" -> + Caps#caps.version == make_disco_hash(Els, sha1); + "sha-224" -> + Caps#caps.version == make_disco_hash(Els, sha224); + "sha-256" -> + Caps#caps.version == make_disco_hash(Els, sha256); + "sha-384" -> + Caps#caps.version == make_disco_hash(Els, sha384); + "sha-512" -> + Caps#caps.version == make_disco_hash(Els, sha512); + _ -> + true + end. +-endif. + concat_features(Els) -> lists:usort( lists:flatmap( diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index cd358fcdf..e5b528a04 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -1916,10 +1916,18 @@ send_new_presence(NJID, Reason, StateData) -> false -> [] end, + Status2 = case ((StateData#state.config)#config.anonymous==false) + andalso (NJID == Info#user.jid) of + true -> + [{xmlelement, "status", [{"code", "100"}], []} + | Status]; + false -> + Status + end, Packet = xml:append_subtags( Presence, [{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}], - [{xmlelement, "item", ItemAttrs, ItemEls} | Status]}]), + [{xmlelement, "item", ItemAttrs, ItemEls} | Status2]}]), ejabberd_router:route( jlib:jid_replace_resource(StateData#state.jid, Nick), Info#user.jid, diff --git a/src/sha.erl b/src/sha.erl index 64c15c166..06dd3c2d1 100644 --- a/src/sha.erl +++ b/src/sha.erl @@ -28,7 +28,11 @@ -author('alexey@process-one.net'). -export([start/0, sha/1, sha1/1, sha224/1, sha256/1, sha384/1, - sha512/1, md2/1]). + sha512/1]). + +-ifdef(HAVE_MD2). +-export([md2/1]). +-endif. -include("ejabberd.hrl"). @@ -80,8 +84,10 @@ sha384(Text) -> sha512(Text) -> erlang:port_control(?DRIVER, 512, Text). +-ifdef(HAVE_MD2). md2(Text) -> erlang:port_control(?DRIVER, 2, Text). +-endif. driver_path() -> Suffix = case os:type() of diff --git a/src/tls/Makefile.in b/src/tls/Makefile.in index 445879657..ee40f93ec 100644 --- a/src/tls/Makefile.in +++ b/src/tls/Makefile.in @@ -30,6 +30,11 @@ ifdef debug EFLAGS+=+debug_info +export_all endif +ifeq (@md2@, true) + EFLAGS+=-DHAVE_MD2 + ERLANG_CFLAGS += -DHAVE_MD2 +endif + ERLSHLIBS = ../tls_drv.so ../sha_drv.so OUTDIR = .. SOURCES = $(wildcard *.erl) diff --git a/src/tls/sha_drv.c b/src/tls/sha_drv.c index 13d65803a..8e6de3203 100644 --- a/src/tls/sha_drv.c +++ b/src/tls/sha_drv.c @@ -20,7 +20,9 @@ #include #include +#ifdef HAVE_MD2 #include +#endif static ErlDrvData sha_drv_start(ErlDrvPort port, char *buf) { @@ -36,11 +38,13 @@ static int sha_drv_control(ErlDrvData handle, ErlDrvBinary *b = NULL; switch (command) { +#ifdef HAVE_MD2 case 2: rlen = MD2_DIGEST_LENGTH; b = driver_alloc_binary(rlen); if (b) MD2((unsigned char*)buf, len, (unsigned char*)b->orig_bytes); break; +#endif case 224: rlen = SHA224_DIGEST_LENGTH; b = driver_alloc_binary(rlen); diff --git a/src/xml.c b/src/xml.c index d1b2b7f44..e363fed74 100644 --- a/src/xml.c +++ b/src/xml.c @@ -2,6 +2,23 @@ #include #include +#ifdef SSL40 +#define ENIF_ALLOC(SIZE) enif_alloc(SIZE) +#define ENIF_FREE(PTR) enif_free(PTR) +#define ENIF_REALLOC(PTR, SIZE) enif_realloc(PTR, SIZE) +#define ENIF_ALLOC_BINARY(SIZE, BIN) enif_alloc_binary(SIZE, BIN) +#define ENIF_COMPARE(TERM1, TERM2) enif_compare(TERM1, TERM2) +#else +#define ENIF_ALLOC(SIZE) enif_alloc(env, SIZE) +#define ENIF_FREE(PTR) enif_free(env, PTR) +#define ENIF_REALLOC(PTR, SIZE) enif_realloc(env, PTR, SIZE) +#define ENIF_ALLOC_BINARY(SIZE, BIN) enif_alloc_binary(env, SIZE, BIN) +#define ENIF_COMPARE(TERM1, TERM2) enif_compare(env, TERM1, TERM2) +#endif + +static ERL_NIF_TERM atom_xmlelement; +static ERL_NIF_TERM atom_xmlcdata; + struct buf { int limit; int len; @@ -10,12 +27,19 @@ struct buf { static int make_element(ErlNifEnv* env, struct buf *rbuf, ERL_NIF_TERM el); +static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) +{ + atom_xmlelement = enif_make_atom(env, "xmlelement"); + atom_xmlcdata = enif_make_atom(env, "xmlcdata"); + return 0; +} + static struct buf *init_buf(ErlNifEnv* env) { - struct buf *rbuf = enif_alloc(env, sizeof(struct buf)); + struct buf *rbuf = ENIF_ALLOC(sizeof(struct buf)); rbuf->limit = 1024; rbuf->len = 0; - rbuf->b = enif_alloc(env, rbuf->limit); + rbuf->b = ENIF_ALLOC(rbuf->limit); return rbuf; } @@ -23,9 +47,9 @@ static void destroy_buf(ErlNifEnv* env, struct buf *rbuf) { if (rbuf) { if (rbuf->b) { - enif_free(env, rbuf->b); + ENIF_FREE(rbuf->b); }; - enif_free(env, rbuf); + ENIF_FREE(rbuf); }; } @@ -35,7 +59,7 @@ inline void resize_buf(ErlNifEnv* env, struct buf *rbuf, int len_to_add) if (new_len >= rbuf->limit) { rbuf->limit = ((new_len / 1024) + 1) * 1024; - rbuf->b = enif_realloc(env, rbuf->b, rbuf->limit); + rbuf->b = ENIF_REALLOC(rbuf->b, rbuf->limit); }; } @@ -141,7 +165,7 @@ static int make_element(ErlNifEnv* env, struct buf *rbuf, ERL_NIF_TERM el) if (enif_get_tuple(env, el, &arity, &tuple)) { if (arity == 2) { - if (!enif_compare(env, tuple[0], enif_make_atom(env, "xmlcdata"))) { + if (!ENIF_COMPARE(tuple[0], atom_xmlcdata)) { if (enif_inspect_iolist_as_binary(env, tuple[1], &cdata)) { crypt(env, rbuf, cdata.data, cdata.size); ret = 1; @@ -149,7 +173,7 @@ static int make_element(ErlNifEnv* env, struct buf *rbuf, ERL_NIF_TERM el) }; }; if (arity == 4) { - if (!enif_compare(env, tuple[0], enif_make_atom(env, "xmlelement"))) { + if (!ENIF_COMPARE(tuple[0], atom_xmlelement)) { if (enif_inspect_iolist_as_binary(env, tuple[1], &name)) { buf_add_char(env, rbuf, '<'); buf_add_str(env, rbuf, (char *)name.data, name.size); @@ -192,7 +216,7 @@ static ERL_NIF_TERM element_to(ErlNifEnv* env, int argc, destroy_buf(env, rbuf); return result; } else { - if (enif_alloc_binary(env, rbuf->len, &output)) { + if (ENIF_ALLOC_BINARY(rbuf->len, &output)) { memcpy(output.data, rbuf->b, rbuf->len); result = enif_make_binary(env, &output); destroy_buf(env, rbuf); @@ -206,11 +230,13 @@ static ERL_NIF_TERM element_to(ErlNifEnv* env, int argc, return enif_make_badarg(env); } -/* static ERL_NIF_TERM element_to_string(ErlNifEnv* env, int argc, */ -/* const ERL_NIF_TERM argv[]) */ -/* { */ -/* return element_to(env, argc, argv, 1); */ -/* } */ +#ifdef SSL40 +static ERL_NIF_TERM element_to_string(ErlNifEnv* env, int argc, + const ERL_NIF_TERM argv[]) +{ + return element_to(env, argc, argv, 1); +} +#endif static ERL_NIF_TERM element_to_binary(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) @@ -222,9 +248,11 @@ static ErlNifFunc nif_funcs[] = { /* Stupid Erlang bug with enif_make_string() is fixed in R14A only (OTP-8685), so we can't use - element_to_string yet.*/ - /* {"element_to_string", 1, element_to_string}, */ + element_to_string in Erlang < R14A.*/ +#ifdef SSL40 + {"element_to_string", 1, element_to_string}, +#endif {"element_to_binary", 1, element_to_binary} }; -ERL_NIF_INIT(xml, nif_funcs, NULL, NULL, NULL, NULL) +ERL_NIF_INIT(xml, nif_funcs, load, NULL, NULL, NULL)