25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

Merge remote branch 'mainline/2.1.x' into 2.2.x

This commit is contained in:
Christophe Romain 2010-08-09 10:04:11 +02:00
commit 23b28ec60f
15 changed files with 170 additions and 57 deletions

View File

@ -2,7 +2,7 @@
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>Ejabberd 2.1.5 Developers Guide
<TITLE>Ejabberd 2.1.x Developers Guide
</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
@ -49,7 +49,7 @@ TD P{margin:0px;}
<!--HEVEA command line is: /usr/bin/hevea -fix -pedantic dev.tex -->
<!--CUT DEF section 1 --><P><A NAME="titlepage"></A>
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.5 Developers Guide</H1><H3 CLASS="titlerest">Alexey Shchepin<BR>
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.x Developers Guide</H1><H3 CLASS="titlerest">Alexey Shchepin<BR>
<A HREF="mailto:alexey@sevcom.net"><TT>mailto:alexey@sevcom.net</TT></A><BR>
<A HREF="xmpp:aleksey@jabber.ru"><TT>xmpp:aleksey@jabber.ru</TT></A></H3></TD></TR>
</TABLE><DIV CLASS="center">

View File

@ -2,7 +2,7 @@
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>Ejabberd 2.1.5 Feature Sheet
<TITLE>Ejabberd 2.1.x Feature Sheet
</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
@ -50,7 +50,7 @@ SPAN{width:20%; float:right; text-align:left; margin-left:auto;}
<!--HEVEA command line is: /usr/bin/hevea -fix -pedantic features.tex -->
<!--CUT DEF section 1 --><P><A NAME="titlepage"></A>
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.5 Feature Sheet</H1><H3 CLASS="titlerest">Sander Devrieze<BR>
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.x Feature Sheet</H1><H3 CLASS="titlerest">Sander Devrieze<BR>
<A HREF="mailto:s.devrieze@pandora.be"><TT>mailto:s.devrieze@pandora.be</TT></A><BR>
<A HREF="xmpp:sander@devrieze.dyndns.org"><TT>xmpp:sander@devrieze.dyndns.org</TT></A></H3></TD></TR>
</TABLE><DIV CLASS="center">

View File

@ -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;}
<HR SIZE=2><BR>
<BR>
<TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP> <FONT SIZE=6><B>ejabberd 2.1.5 </B></FONT></TD></TR>
<TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP> <FONT SIZE=6><B>ejabberd 2.1.x </B></FONT></TD></TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
<TR><TD ALIGN=right NOWRAP> <FONT SIZE=6>Installation and Operation Guide</FONT></TD></TR>
</TABLE><BR>

View File

@ -1,2 +1,2 @@
% ejabberd version (automatically generated).
\newcommand{\version}{2.1.5}
\newcommand{\version}{2.1.x}

View File

@ -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)

2
src/aclocal.m4 vendored
View File

@ -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

31
src/configure vendored
View File

@ -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 <ejabberd@process-one.net>.
#
@ -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\\"

View File

@ -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)

View File

@ -2,7 +2,7 @@
{application, ejabberd,
[{description, "ejabberd"},
{vsn, "2.1.5"},
{vsn, "2.1.x"},
{modules, [acl,
adhoc,
configure,

View File

@ -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(

View File

@ -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,

View File

@ -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

View File

@ -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)

View File

@ -20,7 +20,9 @@
#include <erl_driver.h>
#include <openssl/sha.h>
#ifdef HAVE_MD2
#include <openssl/md2.h>
#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);

View File

@ -2,6 +2,23 @@
#include <string.h>
#include <stdio.h>
#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)