diff --git a/net-im/calculate-ejabberd/Manifest b/net-im/calculate-ejabberd/Manifest new file mode 100644 index 000000000..38838f6a7 --- /dev/null +++ b/net-im/calculate-ejabberd/Manifest @@ -0,0 +1,13 @@ +AUX 2.0.0-missing-declaration.patch 411 RMD160 f314900dd00fd23c9043cb5a60982448c39d2fa9 SHA1 687066247c9ad74c4e9ec869a9f4f0d9e80bae6d SHA256 1c32a57f4f187d55b28b240820875fcd3e731f6d91cd9429d14c318222f07e7b +AUX ejabberd 355 RMD160 bf400cf3a84169a79797db9228ad102d93c9147b SHA1 83bae90f0e211f6e59c96dd6ce419a4c0bcdd3d9 SHA256 1f2254ce2835a986eb75adaf5602d1cb74ced989c2360331822a2c5e11c9837b +AUX ejabberd-2.0.2.confd 840 RMD160 5227a3fbb0d0c8bffd8a5537003f965f1fb73582 SHA1 d3a51fa0923a571d30f3f0840834c651726ad206 SHA256 d6b0c44a450c4191e450b8e3ab281dc2e3bc668a97ddd1652d2e6c555675a2c6 +AUX ejabberd-2.0.2.initd 1134 RMD160 b5d3a5a50069be713511ebd37f9eab07dab33371 SHA1 0cd2c3bd44c1923014c1cdd84edfb56ddb11bdc2 SHA256 8b2c50bc80b5b0700195c79a4eaa6f68549fd63310b584c2e86d951c116e14de +AUX ejabberd-wrapper-2.0.2.template 1273 RMD160 7ec1a86be5df671cb2ce54705de482ca1a172974 SHA1 ec412773c7913d8cfa59e6dcd330242268e60959 SHA256 96dcdca694fbe26b1098007d9e33361812a0ed532894e417155c0ac973bcdf6f +AUX ejabberdctl 199 RMD160 1f4be5dcd018f0936baaeb41e2fd1c4a6a59bc62 SHA1 347200e8dd5790282cedb6a70c71fd4a6db9a0f5 SHA256 b88de8e8e5e8730ac7fe04b49ae3cf131c49a4e1ba451b35f1305d1c24a2dda0 +AUX inetrc 36 RMD160 4b79020864689ede547969610fde18fe490f5810 SHA1 1e0bae0f7251e2ae3b62ba9d3e5cc86bb5dd271e SHA256 0f383befc4c46134d88ce14d3bd06c404ef6575391f4ac0b5e8c28ba383b28fc +AUX mod_shared_roster_ldap.patch 15881 RMD160 cafc8975c30e0893bd16336a86e29b3eaffcb07a SHA1 b50d5123653994ec6174ada696be4cb3cdbb82b1 SHA256 83b36953ed9bee717c95c1edacc22231dfa607dbb9bee995ea90ed242a3add8e +AUX self-cert-v2.sh 1017 RMD160 3beb0f05e8cc3041abd2f689d31d410bc7d5088d SHA1 1f07299b2e49541dcbf5c2b81b26280bbf0b6aeb SHA256 34b2c9cb36c424ffd1117bd20b67d0f4a05168b0bc6237e287c2dcabd0e27972 +AUX self-cert.sh 491 RMD160 89bb577975eef172fa3c6e07b08d323162d1278b SHA1 61a4c8b79141ec1bc846e8ede6fa19a07210c619 SHA256 6a0c53a8573411c18ed6f5dd79ce4807b72fb10bc5eb3a3a7f4641c57e4ddceb +AUX ssl.cnf 1042 RMD160 47d2542942fb21f4be1e827d47eb4e0468e73910 SHA1 7347bae5a195ad158881fe5313f55ee41e85cb81 SHA256 ed066f7720fd9f4c2d57ffb2ebcbc4b2810d2b7ca22b67ec8c1dc1227baaa635 +DIST ejabberd-2.0.2.tar.gz 1040817 RMD160 b24c1c2d6ce8c56fd26f28a98b89d99890dbad72 SHA1 7c82082b941277fe18aac25ca9b2016f25dc8472 SHA256 23136f2d215e82836d84322011914e1c9a846ab056b80cd26ff3e70b300b345a +EBUILD calculate-ejabberd-2.0.2.ebuild 4955 RMD160 392007636ef070def316e5d62c5d02c05ef21b51 SHA1 6382ac2f5b11cf10ac1e5a18928726ca140aa2c8 SHA256 6f6e10f69f66bf2859fc54f794f015809af35079245bbde1000b944ccd369e2c diff --git a/net-im/calculate-ejabberd/calculate-ejabberd-2.0.2.ebuild b/net-im/calculate-ejabberd/calculate-ejabberd-2.0.2.ebuild new file mode 100644 index 000000000..5795bde03 --- /dev/null +++ b/net-im/calculate-ejabberd/calculate-ejabberd-2.0.2.ebuild @@ -0,0 +1,160 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/ejabberd-2.0.2.ebuild,v 1.2 2008/09/10 14:05:35 mr_bones_ Exp $ + +inherit eutils multilib + +JABBER_ETC="/etc/jabber" +JABBER_RUN="/var/run/jabber" +JABBER_SPOOL="/var/spool/jabber" +JABBER_LOG="/var/log/jabber" + +JABBER_NAME="ejabberd" +MY_PV=${PV} +MY_P=${JABBER_NAME}-${MY_PV} + +DESCRIPTION="The Erlang Jabber Daemon" +HOMEPAGE="http://www.ejabberd.im/" +SRC_URI="http://www.process-one.net/downloads/ejabberd/${PV}/${MY_P}.tar.gz" +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~x86" +IUSE="debug mod_irc mod_muc mod_pubsub ldap odbc pam ssl web zlib" + +DEPEND=">=net-im/jabber-base-0.01 + >=dev-libs/expat-1.95 + >=dev-lang/erlang-11.2.5 + odbc? ( dev-db/unixODBC ) + ldap? ( =net-nds/openldap-2* ) + ssl? ( >=dev-libs/openssl-0.9.8e ) + zlib? ( sys-libs/zlib )" + +PROVIDE="virtual/jabber-server" + +S=${WORKDIR}/${MY_P}/src + +src_unpack() { + unpack ${A} + cd "${S}" + + # Bug #171427 + epatch "${FILESDIR}/2.0.0-missing-declaration.patch" + # mod_shared_roster_ldap.patch + epatch "${FILESDIR}/mod_shared_roster_ldap.patch" + + # get rid of the prefix + sed -i -e "s/\\@prefix\\@//" "${S}/Makefile.in" \ + || die "cannot sed Makefile.in" + # we want ejabberdctl in /usr/sbin not /sbin !!! + sed -i -e "s/\\/sbin/\\/usr\\/sbin/" "${S}/Makefile.in" \ + || die "cannot sed Makefile.in" +} + +src_compile() { + econf --prefix=/ \ + $(use_enable mod_irc) \ + $(use_enable ldap eldap) \ + $(use_enable mod_muc) \ + $(use_enable mod_pubsub) \ + $(use_enable ssl tls) \ + $(use_enable web) \ + $(use_enable odbc) \ + $(use_enable zlib ejabberd_zlib) \ + $(use_enable pam) \ + || die "econf failed" + + if useq debug; then + emake ejabberd_debug=true || die "compiling ejabberd core failed" + else + emake || die "compiling ejabberd core failed" + fi +} + +src_install() { + make \ + DESTDIR="${D}" \ + EJABBERDDIR="${D}/usr/$(get_libdir)/erlang/lib/${P}" \ + ETCDIR="${D}${JABBER_ETC}" \ + LOGDIR="${D}${JABBER_LOG}" \ + install || die "install failed" + + # remove the default ejabberdctl as we use our own + rm "${D}/sbin/ejabberdctl" + + insinto ${JABBER_ETC} + + chown -R jabber:jabber "${D}${JABBER_ETC}" + chown -R jabber:jabber "${D}${JABBER_LOG}" + chown -R jabber:jabber "${D}/usr/$(get_libdir)/erlang/lib/${P}" + + if useq ssl ; then + doins "${FILESDIR}/ssl.cnf" + newins "${FILESDIR}/self-cert-v2.sh" self-cert.sh + fi + + # Pam helper module permissions + # http://www.process-one.net/docs/ejabberd/guide_en.html + if useq pam; then + chown root:jabber "${D}"/usr/lib/erlang/lib/${P}/priv/bin/epam + chmod 4750 "${D}"/usr/lib/erlang/lib/${P}/priv/bin/epam + fi + + cd "${WORKDIR}/${MY_P}-beta1/doc" + dodoc "release_notes_${MY_PV}.txt" + dohtml *.{html,png} + + # set up /usr/sbin/ejabberd wrapper + cat "${FILESDIR}/ejabberd-wrapper-${MY_PV}.template" \ + | sed -e "s/\@libdir\@/$(get_libdir)/g" -e "s/\@version\@/${PV}/g" \ + > "${T}/ejabberd" + exeinto /usr/sbin + doexe "${T}/ejabberd" + + # set up /usr/sbin/ejabberdctl wrapper + cat "${FILESDIR}/ejabberdctl-wrapper-${MY_PV}.template" \ + | sed -e "s/\@libdir\@/$(get_libdir)/g" -e "s/\@version\@/${PV}/g" \ + > "${T}/ejabberdctl" + doexe "${T}/ejabberdctl" + + dodir /var/lib/ejabberd + newinitd "${FILESDIR}/${MY_P}.initd" ${JABBER_NAME} + newconfd "${FILESDIR}/${MY_P}.confd" ${JABBER_NAME} + + # fix up the ssl cert paths in /etc/jabber/ejabberd.cfg to use the cert + # that would be generated by /etc/jabber/self-cert.sh + sed -i -e "s/\/path\/to\/ssl.pem/\/etc\/jabber\/ssl.pem/g" \ + "${D}${JABBER_ETC}/ejabberd.cfg" || die "Cannot sed ejabberd.cfg" + + # if mod_irc is not enabled, comment out the mod_irc in the default + # ejabberd.cfg + if ! use mod_irc; then + sed -i -e "s/{mod_irc,/%{mod_irc,/" \ + "${D}${JABBER_ETC}/ejabberd.cfg" || die "Cannot sed ejabberd.cfg" + fi +} + +pkg_postinst() { + elog "For configuration instructions, please see" + elog "/usr/share/doc/${PF}/html/guide.html, or the online version at" + elog "http://www.process-one.net/en/projects/ejabberd/docs/guide_en.html" + if useq ssl ; then + if [ ! -e /etc/jabber/ssl.pem ]; then + elog "Please edit ${JABBER_ETC}/ssl.cnf and run ${JABBER_ETC}/self-cert.sh" + elog "Ejabberd may refuse to start without an SSL certificate" + fi + fi + if ! useq web ; then + elog "The web USE flag is off, this has disabled the web admin interface." + fi + elog "====================================================================" + elog 'Quick Start Guide:' + elog '1) Add output of `hostname -s` to /etc/jabber/ejabberd.cfg line 89' + elog ' {hosts, ["localhost", "thehost"]}.' + elog '2) Add an admin user to /etc/jabber/ejabberd.cfg line 324' + elog ' {acl, admin, {user, "theadmin", "thehost"}}.' + elog '3) Start the server' + elog ' # /etc/init.d/ejabberd start' + elog '4) Register the admin user' + elog ' # /usr/sbin/ejabberdctl register theadmin thehost thepassword' + elog '5) Log in with your favourite jabber client or using the web admin' +} diff --git a/net-im/calculate-ejabberd/files/2.0.0-missing-declaration.patch b/net-im/calculate-ejabberd/files/2.0.0-missing-declaration.patch new file mode 100644 index 000000000..72c56cbce --- /dev/null +++ b/net-im/calculate-ejabberd/files/2.0.0-missing-declaration.patch @@ -0,0 +1,12 @@ +diff -uNr ejabberd-1.1.4.ORIG/src/expat_erl.c ejabberd-1.1.4/src/expat_erl.c +--- ejabberd-1.1.4.ORIG/src/expat_erl.c 2007-09-14 12:07:56.000000000 +0100 ++++ ejabberd-1.1.4/src/expat_erl.c 2007-09-14 12:08:56.000000000 +0100 +@@ -14,6 +14,8 @@ + * Workaround for EI encode_string bug + */ + ++int x_fix_buff(ei_x_buff* x, int szneeded); ++ + #define put8(s,n) do { \ + (s)[0] = (char)((n) & 0xff); \ + (s) += 1; \ diff --git a/net-im/calculate-ejabberd/files/ejabberd b/net-im/calculate-ejabberd/files/ejabberd new file mode 100644 index 000000000..d7506959f --- /dev/null +++ b/net-im/calculate-ejabberd/files/ejabberd @@ -0,0 +1,11 @@ +#!/bin/bash + +erl -pa /var/lib/ejabberd/ebin \ + -sname ejabberd \ + -s ejabberd \ + -ejabberd config \"/etc/ejabberd/ejabberd.cfg\" \ + log_path \"/var/log/ejabberd/ejabberd.log\" \ + -kernel inetrc \"/etc/ejabberd/inetrc\" \ + -sasl sasl_error_logger \{file,\"/var/log/ejabberd/sasl.log\"\} \ + -mnesia dir \"/var/spool/ejabberd\" \ + $@ diff --git a/net-im/calculate-ejabberd/files/ejabberd-2.0.2.confd b/net-im/calculate-ejabberd/files/ejabberd-2.0.2.confd new file mode 100644 index 000000000..ce9211bee --- /dev/null +++ b/net-im/calculate-ejabberd/files/ejabberd-2.0.2.confd @@ -0,0 +1,23 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/files/ejabberd-2.0.2.confd,v 1.1 2008/08/03 16:19:05 caleb Exp $ + +# Name of your ejabberd node. Used by ejabberdctl to determine which +# node to communicate with. +EJABBERD_NODE="ejabberd@`hostname -s`" + +# Max number of open network connections. Default is 1024. Increasing +# this will slightly increase memory usage. +#ERL_MAX_PORTS=1024 + +# Return memory to the system after using it, instead of keeping it +# allocated for future use. Decreases the memory required by ejabberd, +# but makes it run slower. Default is unset, set to any value to +# activate. +#ERL_FULLSWEEP_AFTER=0 + +# set to 1, "true" or "yes" if you have a symmetric-multi-processor +# default is non smp +#HAVE_SMP=0 + + diff --git a/net-im/calculate-ejabberd/files/ejabberd-2.0.2.initd b/net-im/calculate-ejabberd/files/ejabberd-2.0.2.initd new file mode 100644 index 000000000..329001a95 --- /dev/null +++ b/net-im/calculate-ejabberd/files/ejabberd-2.0.2.initd @@ -0,0 +1,54 @@ +#!/sbin/runscript +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/files/ejabberd-2.0.2.initd,v 1.1 2008/08/03 16:19:05 caleb Exp $ + +opts="${opts} reload" + +depend() { + use dns + need net + provide jabber-server +} + +checkconfig() { + if [ ! -e /etc/jabber/ejabberd.cfg ] ; then + eerror "You need a /etc/jabber/ejabberd.cfg file to run ejabberd" + return 1 + fi +} + +start() { + checkconfig || return 1 + ebegin "Starting ejabberd" + # the process name of beam is different depending whether smp is used. + # set it explicitly so start-stop-daemon works + case "$HAVE_SMP" in + "1"|"true"|"yes") + BEAMNAME="beam.smp" + SMPOPT="enable" + ;; + *) + BEAMNAME="beam" + SMPOPT="disable" + ;; + esac + cd /var/lib/ejabberd + start-stop-daemon --start --quiet --chuid jabber:jabber \ + --name $BEAMNAME \ + --exec /usr/sbin/ejabberd -- -detached -noinput -smp $SMPOPT + eend $? +} + +stop() { + ebegin "Stopping ejabberd" + /usr/sbin/ejabberdctl stop + eend $? +} + +reload() { + ebegin "Reloading ejabberd" + /usr/sbin/ejabberdctl reopen-log + eend $? +} + diff --git a/net-im/calculate-ejabberd/files/ejabberd-wrapper-2.0.2.template b/net-im/calculate-ejabberd/files/ejabberd-wrapper-2.0.2.template new file mode 100644 index 000000000..e9baa13e7 --- /dev/null +++ b/net-im/calculate-ejabberd/files/ejabberd-wrapper-2.0.2.template @@ -0,0 +1,49 @@ +#!/bin/sh + +[ -f /etc/conf.d/ejabberd ] && . /etc/conf.d/ejabberd + +# provide some default configuration +ERL=/usr/bin/erl +CONFIG=/etc/jabber/ejabberd.cfg +INETRC=/etc/jabber/inetrc +LOG_PATH=/var/log/jabber/ejabberd.log +SASL_LOG=/var/log/jabber/sasl.log +SPOOL=/var/spool/jabber + +ARGS= +while [ $# -ne 0 ] ; do + PARAM=$1 + shift + case $PARAM in + --) break ;; + --node) EJABBERD_NODE=$1; shift ;; + --config) CONFIG=$1 ; shift ;; + --log) LOG_PATH=$1 ; shift ;; + --sasl-log) SASL_LOG=$1 ; shift ;; + --spool) SPOOL=$1 ; shift ;; + *) ARGS="$ARGS $PARAM" ;; + esac +done + +if [ "$EJABBERD_NODE" = "${EJABBERD_NODE%.*}" ] ; then + SNAME=-sname +else + SNAME=-name +fi + +# export ejabberd configuration environment variables +export HOME=/var/run/jabber +export EJABBERD_EBIN=/usr/@libdir@/erlang/lib/calculate-ejabberd-@version@/ebin +export EJABBERD_MSGS_PATH=/usr/@libdir@/erlang/lib/calculate-ejabberd-@version@/priv/msgs +export EJABBERD_SO_PATH=/usr/@libdir@/erlang/lib/calculate-ejabberd-@version@/priv/lib +export EJABBERD_LOG_PATH=$LOG_PATH +export EJABBERD_CONFIG_PATH=$CONFIG + +exec $ERL $SNAME $EJABBERD_NODE \ + -s ejabberd \ + -kernel inetrc \"$INETRC\" \ + -sasl sasl_error_logger \{file,\"$SASL_LOG\"\} \ + -mnesia dir \"$SPOOL\" \ + $ERL_OPTIONS $ARGS "$@" + + diff --git a/net-im/calculate-ejabberd/files/ejabberdctl b/net-im/calculate-ejabberd/files/ejabberdctl new file mode 100644 index 000000000..a3a18245e --- /dev/null +++ b/net-im/calculate-ejabberd/files/ejabberdctl @@ -0,0 +1,8 @@ +#!/bin/sh + +exec env HOME=/var/run/ejabberd \ + erl -pa /var/lib/ejabberd/ebin \ + -noinput \ + -sname ejabberdctl \ + -s ejabberd_ctl \ + -extra $@ diff --git a/net-im/calculate-ejabberd/files/inetrc b/net-im/calculate-ejabberd/files/inetrc new file mode 100644 index 000000000..2d2f63575 --- /dev/null +++ b/net-im/calculate-ejabberd/files/inetrc @@ -0,0 +1 @@ +{file, resolv, "/etc/resolv.conf"}. diff --git a/net-im/calculate-ejabberd/files/mod_shared_roster_ldap.patch b/net-im/calculate-ejabberd/files/mod_shared_roster_ldap.patch new file mode 100644 index 000000000..e88dbf0bc --- /dev/null +++ b/net-im/calculate-ejabberd/files/mod_shared_roster_ldap.patch @@ -0,0 +1,557 @@ +diff -uNr ejabberd-2.0.2-beta1.ORIG/src/mod_shared_roster_ldap.erl ejabberd-2.0.2-beta1/src/mod_shared_roster_ldap.erl +--- mod_shared_roster_ldap.erl ++++ mod_shared_roster_ldap.erl +@@ -0,0 +1,553 @@ ++%%%---------------------------------------------------------------------- ++%%% File : mod_shared_roster_ldap.erl ++%%% Author : Alexey Shchepin ++%%% Purpose : LDAP shared roster management ++%%% Created : 5 Mar 2005 by Alexey Shchepin ++%%% Id : $Id: mod_shared_roster.erl 24 2005-04-14 01:15:31Z alexey $ ++%%%---------------------------------------------------------------------- ++ ++%%%---------------------------------------------------------------------- ++%%% Some changes to make it AD friendly and more usable :-) ++%%% realloc@realloc.spb.ru ++%%%---------------------------------------------------------------------- ++ ++ ++-module(mod_shared_roster_ldap). ++-author('alexey@sevcom.net'). ++ ++-behaviour(gen_server). ++-behaviour(gen_mod). ++ ++%% gen_server callbacks ++-export([ ++ init/1, ++ handle_info/2, ++ handle_call/3, ++ handle_cast/2, ++ terminate/2, ++ code_change/3 ++]). ++ ++-export([ ++ start/2, ++ start_link/2, ++ stop/1, ++ get_user_roster/2, ++ get_subscription_lists/3, ++ get_jid_info/4, ++ process_item/2, ++ in_subscription/6, ++ out_subscription/4 ++]). ++ ++-include("ejabberd.hrl"). ++-include("eldap/eldap.hrl"). ++-include("jlib.hrl"). ++-include("mod_roster.hrl"). ++ ++-record(state, { ++ host, ++ eldap_id, ++ servers, ++ port, ++ dn, ++ base, ++ password, ++ uid, ++ group_attr, ++ group_desc, ++ user_desc, ++ uid_format, ++ filter, ++ ufilter, ++ rfilter, ++ gfilter ++}). ++ ++-define(LDAP_REQUEST_TIMEOUT, 10000). ++ ++%% Unused callbacks. ++handle_cast(_Request, State) -> ++ {noreply, State}. ++code_change(_OldVsn, State, _Extra) -> ++ {ok, State}. ++handle_info(_Info, State) -> ++ {noreply, State}. ++%% ----- ++ ++start(Host, Opts) -> ++ Proc = gen_mod:get_module_proc(Host, ?MODULE), ++ ChildSpec = { ++ Proc, {?MODULE, start_link, [Host, Opts]}, ++ permanent, 1000, worker, [?MODULE] ++ }, ++ supervisor:start_child(ejabberd_sup, ChildSpec). ++ ++stop(Host) -> ++ Proc = gen_mod:get_module_proc(Host, ?MODULE), ++ gen_server:call(Proc, stop), ++ supervisor:terminate_child(ejabberd_sup, Proc), ++ supervisor:delete_child(ejabberd_sup, Proc). ++ ++start_link(Host, Opts) -> ++ Proc = gen_mod:get_module_proc(Host, ?MODULE), ++ gen_server:start_link({local, Proc}, ?MODULE, [Host, Opts], []). ++ ++terminate(_Reason, State) -> ++ Host = State#state.host, ++ ejabberd_hooks:delete(roster_get, Host, ++ ?MODULE, get_user_roster, 70), ++ ejabberd_hooks:delete(roster_in_subscription, Host, ++ ?MODULE, in_subscription, 30), ++ ejabberd_hooks:delete(roster_out_subscription, Host, ++ ?MODULE, out_subscription, 30), ++ ejabberd_hooks:delete(roster_get_subscription_lists, Host, ++ ?MODULE, get_subscription_lists, 70), ++ ejabberd_hooks:delete(roster_get_jid_info, Host, ++ ?MODULE, get_jid_info, 70), ++ ejabberd_hooks:delete(roster_process_item, Host, ++ ?MODULE, process_item, 50). ++ ++init([Host, Opts]) -> ++ State = parse_options(Host, Opts), ++ ejabberd_hooks:add(roster_get, Host, ++ ?MODULE, get_user_roster, 70), ++ ejabberd_hooks:add(roster_in_subscription, Host, ++ ?MODULE, in_subscription, 30), ++ ejabberd_hooks:add(roster_out_subscription, Host, ++ ?MODULE, out_subscription, 30), ++ ejabberd_hooks:add(roster_get_subscription_lists, Host, ++ ?MODULE, get_subscription_lists, 70), ++ ejabberd_hooks:add(roster_get_jid_info, Host, ++ ?MODULE, get_jid_info, 70), ++ ejabberd_hooks:add(roster_process_item, Host, ++ ?MODULE, process_item, 50), ++ eldap:start_link(State#state.eldap_id, ++ State#state.servers, ++ State#state.port, ++ State#state.dn, ++ State#state.password), ++ {ok, State}. ++ ++get_user_roster(Items, US) -> ++ {U, S} = US, ++ DisplayedGroups = get_user_displayed_groups(US), ++ %% Get shared roster users in all groups and remove self: ++ SRUsers = ++ lists:foldl( ++ fun(Group, Acc1) -> ++ lists:foldl( ++ fun(User, Acc2) -> ++ if User == US -> Acc2; ++ true -> dict:append(User, ++ get_group_name(S, Group), ++ Acc2) ++ end ++ end, Acc1, get_group_users(S, Group)) ++ end, dict:new(), DisplayedGroups), ++ ++ %% If partially subscribed users are also in shared roster, show them as ++ %% totally subscribed: ++ {NewItems1, SRUsersRest} = ++ lists:mapfoldl( ++ fun(Item, SRUsers1) -> ++ {_, _, {U1, S1, _}} = Item#roster.usj, ++ US1 = {U1, S1}, ++ case dict:find(US1, SRUsers1) of ++ {ok, _GroupNames} -> ++ {Item#roster{subscription = both, ask = none}, ++ dict:erase(US1, SRUsers1)}; ++ error -> ++ {Item, SRUsers1} ++ end ++ end, SRUsers, Items), ++ ++ %% Export items in roster format: ++ SRItems = [#roster{usj = {U, S, {U1, S1, ""}}, ++ us = US, ++ jid = {U1, S1, ""}, ++ name = get_user_name(U1,S1), ++ subscription = both, ++ ask = none, ++ groups = GroupNames} || ++ {{U1, S1}, GroupNames} <- dict:to_list(SRUsersRest)], ++ SRItems ++ NewItems1. ++ ++%% This function in use to rewrite the roster entries when moving or renaming ++%% them in the user contact list. ++process_item(RosterItem, Host) -> ++ USFrom = RosterItem#roster.us, ++ {User,Server,_Resource} = RosterItem#roster.jid, ++ USTo = {User,Server}, ++ DisplayedGroups = get_user_displayed_groups(USFrom), ++ CommonGroups = lists:filter(fun(Group) -> ++ is_user_in_group(USTo, Group, Server) ++ end, DisplayedGroups), ++ case CommonGroups of ++ [] -> RosterItem; ++ %% Roster item cannot be removed: We simply reset the original groups: ++ _ when RosterItem#roster.subscription == remove -> ++ GroupNames = lists:map(fun(Group) -> ++ get_group_name(Host, Group) ++ end, CommonGroups), ++ RosterItem#roster{subscription = both, ask = none, ++ groups=[GroupNames]}; ++ _ -> RosterItem#roster{subscription = both, ask = none} ++ end. ++ ++get_subscription_lists({F, T}, User, Server) -> ++ LUser = jlib:nodeprep(User), ++ LServer = jlib:nameprep(Server), ++ US = {LUser, LServer}, ++ DisplayedGroups = get_user_displayed_groups(US), ++ SRUsers = ++ lists:usort( ++ lists:flatmap( ++ fun(Group) -> ++ get_group_users(LServer, Group) ++ end, DisplayedGroups)), ++ SRJIDs = [{U1, S1, ""} || {U1, S1} <- SRUsers], ++ {lists:usort(SRJIDs ++ F), lists:usort(SRJIDs ++ T)}. ++ ++get_jid_info({Subscription, Groups}, User, Server, JID) -> ++ LUser = jlib:nodeprep(User), ++ LServer = jlib:nameprep(Server), ++ US = {LUser, LServer}, ++ {U1, S1, _} = jlib:jid_tolower(JID), ++ US1 = {U1, S1}, ++ DisplayedGroups = get_user_displayed_groups(US), ++ SRUsers = ++ lists:foldl( ++ fun(Group, Acc1) -> ++ lists:foldl( ++ fun(User1, Acc2) -> ++ dict:append( ++ User1, get_group_name(LServer, Group), Acc2) ++ end, Acc1, get_group_users(LServer, Group)) ++ end, dict:new(), DisplayedGroups), ++ case dict:find(US1, SRUsers) of ++ {ok, GroupNames} -> ++ NewGroups = if ++ Groups == [] -> GroupNames; ++ true -> Groups ++ end, ++ {both, NewGroups}; ++ error -> ++ {Subscription, Groups} ++ end. ++ ++in_subscription(Acc, User, Server, JID, Type, _Reason) -> ++ process_subscription(in, User, Server, JID, Type, Acc). ++ ++out_subscription(User, Server, JID, Type) -> ++ process_subscription(out, User, Server, JID, Type, false). ++ ++process_subscription(Direction, User, Server, JID, _Type, Acc) -> ++ LUser = jlib:nodeprep(User), ++ LServer = jlib:nameprep(Server), ++ US = {LUser, LServer}, ++ {U1, S1, _} = jlib:jid_tolower(jlib:jid_remove_resource(JID)), ++ US1 = {U1, S1}, ++ DisplayedGroups = get_user_displayed_groups(US), ++ SRUsers = ++ lists:usort( ++ lists:flatmap( ++ fun(Group) -> ++ get_group_users(LServer, Group) ++ end, DisplayedGroups)), ++ case lists:member(US1, SRUsers) of ++ true -> ++ case Direction of ++ in -> ++ {stop, false}; ++ out -> ++ stop ++ end; ++ false -> ++ Acc ++ end. ++ ++get_group_users(Host, Group) -> ++ make_request(Host, {get_group_users, Group}, []). ++ ++get_group_name(Host, Group) -> ++ make_request(Host, {get_group_name, Group}, Group). ++ ++get_user_displayed_groups({User, Host}) -> ++ make_request(Host, {get_user_displayed_groups, User}, []). ++ ++is_user_in_group({User, _Server}, Group, Host) -> ++ make_request(Host, {is_user_in_group, User, Group}, false). ++ ++get_user_name(User, Host) -> ++ make_request(Host, {get_user_name, User},[]). ++ ++ ++%%%----------------------- ++%%% Internal functions. ++%%%----------------------- ++handle_call({get_user_displayed_groups, User}, _From, State) -> ++ GroupAttr = State#state.group_attr, ++ Reply = case eldap_filter:parse(State#state.rfilter) of ++ {ok, EldapFilter} -> ++ case eldap:search(State#state.eldap_id, [ ++ {base, State#state.base}, ++ {filter, EldapFilter}, ++ {attributes, [GroupAttr]}]) of ++ #eldap_search_result{entries = Es} -> ++ lists:usort(lists:flatmap( ++ fun(#eldap_entry{attributes = Attrs}) -> ++ case Attrs of ++ [{GroupAttr, ValuesList}] -> ++ ValuesList; ++ _ -> ++ [] ++ end ++ end, Es)); ++ _ -> ++ [] ++ end; ++ _ -> ++ [] ++ end, ++ {reply, Reply, State}; ++ ++handle_call({get_group_name, Group}, _From, State) -> ++ GroupDescAttr = State#state.group_desc, ++ Reply = case eldap_filter:parse(State#state.gfilter, [{"%g", Group}]) of ++ {ok, EldapFilter} -> ++ case eldap:search(State#state.eldap_id, [ ++ {base, State#state.base}, ++ {filter, EldapFilter}, ++ {attributes, [GroupDescAttr]}]) of ++ #eldap_search_result{entries = [ ++ #eldap_entry{attributes = ++ [{GroupDescAttr, GroupName} | _]} ++ ]} -> ++ GroupName; ++ _ -> ++ Group ++ end; ++ _ -> ++ Group ++ end, ++ {reply, Reply, State}; ++ ++handle_call({get_user_name, User}, _From, State) -> ++UserDescAttr = State#state.user_desc, ++Reply = case eldap_filter:parse(State#state.ufilter, [{"%u", User}]) of ++ {ok, EldapFilter} -> ++ case eldap:search(State#state.eldap_id, [ ++ {base, State#state.base}, ++ {filter, EldapFilter}, ++ {attributes, [UserDescAttr]}]) of ++ #eldap_search_result{entries = [ ++ #eldap_entry{attributes = ++ [{UserDescAttr, UserName} | _]} ++ ]} -> ++ UserName; ++ _ -> ++ User ++ end; ++ _ -> ++ User ++ end, ++ {reply, Reply, State}; ++ ++ ++handle_call({get_group_users, Group}, _From, State) -> ++ UIDAttr = State#state.uid, ++ UAF = State#state.uid_format, ++ Host = State#state.host, ++ Reply = case eldap_filter:parse(State#state.gfilter, [{"%g", Group}]) of ++ {ok, EldapFilter} -> ++ case eldap:search(State#state.eldap_id, [ ++ {base, State#state.base}, ++ {filter, EldapFilter}, ++ {attributes, [UIDAttr]}]) of ++ #eldap_search_result{entries = Es} -> ++ lists:usort(lists:flatmap( ++ fun(#eldap_entry{attributes = Attrs}) -> ++ case Attrs of ++ [{UIDAttr, UsersList}] -> ++ lists:foldl(fun(User, Acc) -> ++ case catch get_user_part(User, UAF) of ++ {ok, U} -> ++ case ejabberd_auth:is_user_exists(U, Host) of ++ true -> [{U, Host} | Acc]; ++ _ -> Acc ++ end; ++ _ -> Acc ++ end ++ end, [], UsersList); ++ _ -> ++ [] ++ end ++ end, Es)); ++ _ -> ++ [] ++ end; ++ _ -> ++ [] ++ end, ++ {reply, Reply, State}; ++ ++handle_call({is_user_in_group, User, Group}, _From, State) -> ++ Reply = case eldap_filter:parse(State#state.filter, ++ [{"%u", User}, {"%g", Group}]) of ++ {ok, EldapFilter} -> ++ case eldap:search(State#state.eldap_id, [ ++ {base, State#state.base}, ++ {filter, EldapFilter}, ++ {attributes, ["dn"]}]) of ++ #eldap_search_result{entries = [_|_]} -> ++ true; ++ _ -> ++ false ++ end; ++ _ -> ++ false ++ end, ++ {reply, Reply, State}; ++ ++handle_call(stop, _From, State) -> ++ {stop, normal, ok, State}; ++ ++handle_call(_Request, _From, State) -> ++ {reply, bad_request, State}. ++ ++%%%----------------------- ++%%% Auxiliary functions. ++%%%----------------------- ++parse_options(Host, Opts) -> ++ Eldap_ID = atom_to_list(gen_mod:get_module_proc(Host, ?MODULE)), ++ LDAPServers = case gen_mod:get_opt(ldap_servers, Opts, undefined) of ++ undefined -> ++ ejabberd_config:get_local_option({ldap_servers, Host}); ++ S -> S ++ end, ++ LDAPPort = case gen_mod:get_opt(ldap_port, Opts, undefined) of ++ undefined -> ++ case ejabberd_config:get_local_option({ldap_port, Host}) of ++ undefined -> 389; ++ P -> P ++ end; ++ P -> P ++ end, ++ LDAPBase = case gen_mod:get_opt(ldap_base, Opts, undefined) of ++ undefined -> ++ ejabberd_config:get_local_option({ldap_base, Host}); ++ B -> B ++ end, ++ GroupAttr = case gen_mod:get_opt(ldap_groupattr, Opts, undefined) of ++ undefined -> "cn"; ++ GA -> GA ++ end, ++ GroupDesc = case gen_mod:get_opt(ldap_groupdesc, Opts, undefined) of ++ undefined -> "cn"; ++ GD -> GD ++ end, ++ UserDesc = case gen_mod:get_opt(ldap_userdesc, Opts, undefined) of ++ undefined -> "cn"; ++ UD -> UD ++ end, ++ UIDAttr = case gen_mod:get_opt(ldap_memberattr, Opts, undefined) of ++ undefined -> "memberUid"; ++ UA -> UA ++ end, ++ UIDAttrFormat = case gen_mod:get_opt(ldap_memberattr_format, Opts, undefined) of ++ undefined -> "%u"; ++ UAF -> UAF ++ end, ++ RootDN = case gen_mod:get_opt(ldap_rootdn, Opts, undefined) of ++ undefined -> ++ case ejabberd_config:get_local_option({ldap_rootdn, Host}) of ++ undefined -> ""; ++ RDN -> RDN ++ end; ++ RDN -> RDN ++ end, ++ Password = case gen_mod:get_opt(ldap_password, Opts, undefined) of ++ undefined -> ++ case ejabberd_config:get_local_option({ldap_password, Host}) of ++ undefined -> ""; ++ Pass -> Pass ++ end; ++ Pass -> Pass ++ end, ++ ConfigFilter = case gen_mod:get_opt(ldap_filter, Opts, undefined) of ++ undefined -> ++ ejabberd_config:get_local_option({ldap_filter, Host}); ++ F -> ++ F ++ end, ++ ++ RosterFilter = case gen_mod:get_opt(ldap_rfilter, Opts, undefined) of ++ undefined -> ++ ejabberd_config:get_local_option({ldap_rfilter, Host}); ++ RF -> ++ RF ++ end, ++ ++ SubFilter = "(&("++UIDAttr++"="++UIDAttrFormat++")("++GroupAttr++"=%g))", ++ UserSubFilter = eldap_filter:do_sub(SubFilter, [{"%g", "*"}]), ++ GroupSubFilter = eldap_filter:do_sub(SubFilter, [{"%u", "*"}]), ++ Filter = case ConfigFilter of ++ undefined -> SubFilter; ++ "" -> SubFilter; ++ _ -> "(&" ++ SubFilter ++ ConfigFilter ++ ")" ++ end, ++ UserFilter = case ConfigFilter of ++ undefined -> UserSubFilter; ++ "" -> UserSubFilter; ++ _ -> "(&" ++ UserSubFilter ++ ConfigFilter ++ ")" ++ end, ++ GroupFilter = case ConfigFilter of ++ undefined -> GroupSubFilter; ++ "" -> GroupSubFilter; ++ _ -> "(&" ++ GroupSubFilter ++ ConfigFilter ++ ")" ++ end, ++ #state{ ++ host = Host, ++ eldap_id = Eldap_ID, ++ servers = LDAPServers, ++ port = LDAPPort, ++ dn = RootDN, ++ base = LDAPBase, ++ password = Password, ++ uid = UIDAttr, ++ group_attr = GroupAttr, ++ group_desc = GroupDesc, ++ user_desc = UserDesc, ++ uid_format = UIDAttrFormat, ++ filter = Filter, ++ ufilter = UserFilter, ++ rfilter = RosterFilter, ++ gfilter = GroupFilter ++ }. ++ ++get_user_part(String, Pattern) -> ++ F = fun(S, P) -> ++ First = string:str(P, "%u"), ++ TailLength = length(P) - (First+1), ++ string:sub_string(S, First, length(S) - TailLength) ++ end, ++ case catch F(String, Pattern) of ++ {'EXIT', _} -> ++ {error, badmatch}; ++ Result -> ++ case regexp:sub(Pattern, "%u", Result) of ++ {ok, String, _} -> {ok, Result}; ++ _ -> {error, badmatch} ++ end ++ end. ++ ++make_request(Host, Request, Fallback) -> ++ Proc = gen_mod:get_module_proc(Host, ?MODULE), ++ case catch gen_server:call(Proc, Request, ?LDAP_REQUEST_TIMEOUT) of ++ {'EXIT', _} -> ++ Fallback; ++ Result -> ++ Result ++ end. ++ diff --git a/net-im/calculate-ejabberd/files/self-cert-v2.sh b/net-im/calculate-ejabberd/files/self-cert-v2.sh new file mode 100755 index 000000000..b2f3b7dad --- /dev/null +++ b/net-im/calculate-ejabberd/files/self-cert-v2.sh @@ -0,0 +1,41 @@ +#! /bin/sh +# +# self-cert.sh for ejabberd, stolen from: +# mkimapdcert,v 1.1 2001/01/02 03:54:25 drobbins Exp +# +# Copyright 2000 Double Precision, Inc. See COPYING for +# distribution information. +# +# This is a short script to quickly generate a self-signed X.509 key for +# eJabberd. Normally this script would get called by an automatic +# package installation routine. + +test -x /usr/bin/openssl || exit 0 + +prefix="/usr" +pemfile="/etc/jabber/ssl.pem" +randfile="/etc/jabber/ssl.rand" + +if test -f $pemfile +then + echo "$pemfile already exists." + exit 1 +fi + +cp /dev/null $pemfile +chmod 640 $pemfile +chown root:jabber $pemfile + +cleanup() { + rm -f $pemfile + rm -f $randfile + exit 1 +} + +dd if=/dev/urandom of=$randfile count=1 2>/dev/null +/usr/bin/openssl req -new -x509 -days 365 -nodes \ + -config /etc/jabber/ssl.cnf -out $pemfile -keyout $pemfile || cleanup +/usr/bin/openssl gendh -rand $randfile 512 >> $pemfile || cleanup +/usr/bin/openssl x509 -subject -dates -fingerprint -noout -in $pemfile || cleanup +rm -f $randfile + diff --git a/net-im/calculate-ejabberd/files/self-cert.sh b/net-im/calculate-ejabberd/files/self-cert.sh new file mode 100755 index 000000000..2c984fd9d --- /dev/null +++ b/net-im/calculate-ejabberd/files/self-cert.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +###### +# +# Generate a certificate and key with no passphrase. +# +###### + +OPENSSL=/usr/bin/openssl + +## This generates the cert and key +$OPENSSL req -new -x509 -newkey rsa:1024 -keyout /tmp/privkey.pem -out /etc/ejabberd/ssl.pem +## This will remove the passphrase +$OPENSSL rsa -in /tmp/privkey.pem -out /tmp/privkey.pem +## Put it all together +cat /tmp/privkey.pem >> /etc/ejabberd/ssl.pem +## Cleanup +rm /tmp/privkey.pem +echo "" +echo "Your new key is /etc/ejabberd/ssl.pem" +echo "" diff --git a/net-im/calculate-ejabberd/files/ssl.cnf b/net-im/calculate-ejabberd/files/ssl.cnf new file mode 100644 index 000000000..7a51d913b --- /dev/null +++ b/net-im/calculate-ejabberd/files/ssl.cnf @@ -0,0 +1,36 @@ +# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/files/ssl.cnf,v 1.1 2006/10/12 16:26:07 chainsaw Exp $ +# This is the openssl config file to generate keys for ejabberd +# It is read by self-cert.sh + +[ req ] +# you can increase this value, but be aware that it will make things much slower +# this should be a power of 2! +default_bits = 1024 +# leave the rest of these alone! +encrypt_key = yes +distinguished_name = req_dn +x509_extensions = cert_type +prompt = no + +[ req_dn ] +# 2-Letter ISO country code +C=UK +# FULL name of state/province/district +# NO abbreviations! +ST=Cambridgeshire +# FULL name of city +# NO abbreviations! +L=Peterborough +# Full Name of your organization +# NO abbreviations! +O=Bits and Bobs Ltd. +# Leave this alone unless specifically need to change it! +OU=Automatically-generated ejabberd SSL key +# This should be a FQDN that resolves to the IP of your server +CN=localhost +# This should be the email address for the administrator of the server +emailAddress=root@localhost + +# Leave this alone! +[ cert_type ] +nsCertType = server