rpms/ejabberd/F-8 ejabberd-ejabberd_cfg_pam_name.diff, NONE, 1.1 ejabberd.pam, NONE, 1.1 .cvsignore, 1.8, 1.9 ejabberd-build.patch, 1.2, 1.3 ejabberd-ejabberdctl_fix.diff, 1.2, 1.3 ejabberd.spec, 1.20, 1.21 import.log, 1.2, 1.3 mod_ctlextra.erl, 1.3, 1.4 sources, 1.8, 1.9
Peter Lemenkov
peter at fedoraproject.org
Fri Aug 29 20:20:02 UTC 2008
- Previous message (by thread): rpms/ejabberd/F-9 ejabberd-ejabberd_cfg_pam_name.diff, NONE, 1.1 ejabberd.pam, NONE, 1.1 .cvsignore, 1.9, 1.10 ejabberd-build.patch, 1.2, 1.3 ejabberd-ejabberdctl_fix.diff, 1.2, 1.3 ejabberd.spec, 1.25, 1.26 import.log, 1.2, 1.3 mod_ctlextra.erl, 1.3, 1.4 sources, 1.11, 1.12
- Next message (by thread): rpms/psmisc/devel psmisc.spec,1.50,1.51
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: peter
Update of /cvs/extras/rpms/ejabberd/F-8
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv11225/F-8
Modified Files:
.cvsignore ejabberd-build.patch ejabberd-ejabberdctl_fix.diff
ejabberd.spec import.log mod_ctlextra.erl sources
Added Files:
ejabberd-ejabberd_cfg_pam_name.diff ejabberd.pam
Log Message:
Ver. 2.0.2
ejabberd-ejabberd_cfg_pam_name.diff:
--- NEW FILE ejabberd-ejabberd_cfg_pam_name.diff ---
--- src/ejabberd.cfg.example~ 2008-08-01 16:34:28.000000000 +0400
+++ src/ejabberd.cfg.example 2008-08-09 21:09:07.000000000 +0400
@@ -214,7 +214,7 @@
%% Authentication using PAM
%%
%%{auth_method, pam}.
-%%{pam_service, "pamservicename"}.
+%%{pam_service, "ejabberd"}.
%%
%% Authentication using LDAP
--- NEW FILE ejabberd.pam ---
#%PAM-1.0
auth include system-auth
account include system-auth
Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/.cvsignore,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- .cvsignore 24 May 2008 18:12:50 -0000 1.8
+++ .cvsignore 29 Aug 2008 20:19:31 -0000 1.9
@@ -1 +1 @@
-ejabberd-2.0.1_2.tar.gz
+ejabberd-2.0.2.tar.gz
ejabberd-build.patch:
Index: ejabberd-build.patch
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/ejabberd-build.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ejabberd-build.patch 24 May 2008 18:12:50 -0000 1.2
+++ ejabberd-build.patch 29 Aug 2008 20:19:31 -0000 1.3
@@ -1,11 +1,11 @@
---- src/Makefile.in~ 2008-05-23 14:59:01.000000000 +0400
-+++ src/Makefile.in 2008-05-23 16:27:42.000000000 +0400
-@@ -56,7 +56,7 @@
+--- src/Makefile.in.fix_paths 2008-08-01 16:34:28.000000000 +0400
++++ src/Makefile.in 2008-08-09 19:54:03.000000000 +0400
+@@ -58,7 +58,7 @@
DESTDIR =
-EJABBERDDIR = $(DESTDIR)@localstatedir@/lib/ejabberd
+EJABBERDDIR = $(DESTDIR)@libdir@/ejabberd
BEAMDIR = $(EJABBERDDIR)/ebin
+ SPOOLDIR = $(EJABBERDDIR)/db
PRIVDIR = $(EJABBERDDIR)/priv
- SODIR = $(PRIVDIR)/lib
ejabberd-ejabberdctl_fix.diff:
Index: ejabberd-ejabberdctl_fix.diff
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/ejabberd-ejabberdctl_fix.diff,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ejabberd-ejabberdctl_fix.diff 22 Jun 2008 19:02:18 -0000 1.2
+++ ejabberd-ejabberdctl_fix.diff 29 Aug 2008 20:19:31 -0000 1.3
@@ -1,12 +1,13 @@
---- src/ejabberdctl.template 2008-05-20 14:22:03.000000000 +0400
-+++ src/ejabberdctl.template 2008-06-22 19:41:03.000000000 +0400
-@@ -9,12 +9,13 @@
+--- src/ejabberdctl.template.fix_user 2008-08-01 16:34:28.000000000 +0400
++++ src/ejabberdctl.template 2008-08-09 16:04:56.000000000 +0400
+@@ -9,13 +9,14 @@
# define default environment variables
NODE=ejabberd
-HOST=localhost
+HOST=`hostname -s`
ERLANG_NODE=$NODE@$HOST
+ ERL=@erl@
-ROOTDIR=@rootdir@
+ROOTDIR=
+MAINDIR=
@@ -17,7 +18,7 @@
# read custom configuration
CONFIG=$ROOTDIR/etc/ejabberd/ejabberdctl.cfg
-@@ -42,10 +43,10 @@
+@@ -43,10 +44,10 @@
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES"
# define additional environment variables
@@ -32,18 +33,19 @@
EJABBERD_LOG_PATH=$LOGS_DIR/ejabberd.log
SASL_LOG_PATH=$LOGS_DIR/sasl.log
DATETIME=`date "+%Y%m%d-%H%M%S"`
-@@ -139,11 +140,13 @@
+@@ -139,11 +140,14 @@
# common control function
ctl ()
{
-+ /sbin/runuser -s /bin/bash - ejabberd -c " \
- erl \
++ $ERL_COMMAND=" \
+ $ERL \
$NAME ejabberdctl \
-noinput \
-pa $EJABBERD_EBIN \
- -s ejabberd_ctl -extra $ERLANG_NODE $@
+ -s ejabberd_ctl -extra $ERLANG_NODE $@ \
+ "
++ /sbin/runuser -s /bin/bash - ejabberd -c "$ERL_COMMAND"
result=$?
case $result in
0) :;;
Index: ejabberd.spec
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/ejabberd.spec,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ejabberd.spec 22 Jun 2008 19:02:18 -0000 1.20
+++ ejabberd.spec 29 Aug 2008 20:19:31 -0000 1.21
@@ -1,31 +1,33 @@
Name: ejabberd
-Version: 2.0.1
-Release: 4%{?dist}
+Version: 2.0.2
+Release: 1%{?dist}
Summary: A distributed, fault-tolerant Jabber/XMPP server
Group: Applications/Internet
License: GPLv2+
URL: http://www.ejabberd.im/
-Source0: http://www.process-one.net/downloads/%{name}/%{version}/%{name}-%{version}_2.tar.gz
+Source0: http://www.process-one.net/downloads/%{name}/%{version}/%{name}-%{version}.tar.gz
Source1: ejabberd.init
Source2: ejabberd.logrotate
-# http://ejabberd.jabber.ru/ejabberdctl-extra
-Source4: https://svn.process-one.net/ejabberd-modules/mod_ctlextra/trunk/src/mod_ctlextra.erl
+# http://www.ejabberd.im/mod_ctlextra
+# svn export -r 557 https://svn.process-one.net/ejabberd-modules/mod_ctlextra/trunk/src/mod_ctlextra.erl
+Source4: mod_ctlextra.erl
# The following were extracted from a patch found on http://realloc.spb.ru/share/ejabberdad.html
Source5: ejabberd_auth_ad.erl
Source6: mod_shared_roster_ad.erl
Source7: mod_vcard_ad.erl
-#
-#Source8: ejabberdctl
Source9: ejabberdctl.pam
Source10: ejabberdctl.apps
+Source11: ejabberd.pam
# Fedora-specific stuff - fixing paths
Patch1: ejabberd-build.patch
# BZ# 439583, 452326, 451554
Patch2: ejabberd-ejabberdctl_fix.diff
+# Use ejabberd as an example for PAM service name
+Patch3: ejabberd-ejabberd_cfg_pam_name.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -71,6 +73,26 @@
%post
/sbin/chkconfig --add ejabberd
+(cd /etc/ejabberd
+if [ ! -f ejabberd.pem ]
+then
+ echo "Generating SSL certificate /etc/ejabberd/ejabberd.pem..."
+ HOSTNAME=$(hostname -s)
+ DOMAINNAME=$(hostname -d)
+ openssl req -new -x509 -days 365 -nodes -out ejabberd.pem \
+ -keyout ejabberd.pem > /dev/null 2>&1 <<+++
+.
+.
+.
+$DOMAINNAME
+$HOSTNAME
+ejabberd
+root@$HOSTNAME.$DOMAINNAME
++++
+chown ejabberd:ejabberd ejabberd.pem
+chmod 600 ejabberd.pem
+fi)
+
%preun
if [ $1 = 0 ]; then
/sbin/service ejabberd stop >/dev/null 2>&1
@@ -83,9 +105,10 @@
fi
%prep
-%setup -q -n %{name}-%{version}
+%setup -q
%patch1 -p0 -b .fix_paths
%patch2 -p0 -b .fix_user
+%patch3 -p0 -b .pam_name
dos2unix src/odbc/mssql.sql
cp %{S:4} src
@@ -95,7 +118,7 @@
%build
pushd src
-%configure --enable-odbc --enable-debug
+%configure --enable-odbc --enable-debug --enable-pam
# doesn't builds on SMP currently
make
popd
@@ -121,9 +144,9 @@
mkdir -p %{buildroot}%{_bindir}
ln -s consolehelper %{buildroot}%{_bindir}/ejabberdctl
-#install -D -p -m 0755 %{S:8} %{buildroot}%{_sbindir}/ejabberdctl
install -D -p -m 0644 %{S:9} %{buildroot}%{_sysconfdir}/pam.d/ejabberdctl
install -D -p -m 0644 %{S:10} %{buildroot}%{_sysconfdir}/security/console.apps/ejabberdctl
+install -D -p -m 0644 %{S:11} %{buildroot}%{_sysconfdir}/pam.d/ejabberd
mkdir -p %{buildroot}%{_initrddir}
install -p -m 0755 %{S:1} %{buildroot}%{_initrddir}/ejabberd
@@ -153,6 +176,7 @@
%{_initrddir}/ejabberd
%config(noreplace) %{_sysconfdir}/logrotate.d/ejabberd
+%config(noreplace) %{_sysconfdir}/pam.d/ejabberd
%config(noreplace) %{_sysconfdir}/pam.d/ejabberdctl
%config(noreplace) %{_sysconfdir}/security/console.apps/ejabberdctl
%{_bindir}/ejabberdctl
@@ -162,6 +186,7 @@
%dir %{_libdir}/%{name}/ebin
%dir %{_libdir}/%{name}/priv
%dir %{_libdir}/%{name}/priv/bin
+%attr(4750,root,ejabberd) %{_libdir}/%{name}/priv/bin/epam
%dir %{_libdir}/%{name}/priv/lib
%dir %{_libdir}/%{name}/priv/msgs
@@ -183,6 +208,20 @@
%endif
%changelog
+* Fri Aug 29 2008 Peter Lemenkov <lemenkov at gmail.com> 2.0.2-1
+- Ver. 2.0.2
+
+* Sat Aug 9 2008 Peter Lemenkov <lemenkov at gmail.com> 2.0.2-0.3.beta1
+- PAM support (BZ# 452803)
+
+* Sat Aug 9 2008 Peter Lemenkov <lemenkov at gmail.com> 2.0.2-0.2.beta1
+- Fix build with --fuzz=0
+
+* Sat Aug 9 2008 Peter Lemenkov <lemenkov at gmail.com> 2.0.2-0.1.beta1
+- Version 2.0.2-beta1
+- Fixed BZ# 452326
+- Fixed BZ# 227270
+
* Sun Jun 22 2008 Peter Lemenkov <lemenkov at gmail.com> 2.0.1-4
- Last minute fix (issue with shortnames/fqdn)
Index: import.log
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/import.log,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- import.log 22 Jun 2008 19:02:18 -0000 1.2
+++ import.log 29 Aug 2008 20:19:31 -0000 1.3
@@ -1,2 +1,3 @@
ejabberd-2_0_1-3_fc9:F-8:ejabberd-2.0.1-3.fc9.src.rpm:1214151206
ejabberd-2_0_1-4_fc9:F-8:ejabberd-2.0.1-4.fc9.src.rpm:1214161287
+ejabberd-2_0_2-1_fc9:F-8:ejabberd-2.0.2-1.fc9.src.rpm:1220041151
Index: mod_ctlextra.erl
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/mod_ctlextra.erl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mod_ctlextra.erl 5 Sep 2007 13:04:12 -0000 1.3
+++ mod_ctlextra.erl 29 Aug 2008 20:19:31 -0000 1.4
@@ -8,7 +8,6 @@
-module(mod_ctlextra).
-author('badlop at ono.com').
--vsn('$Revision$ ').
-behaviour(gen_mod).
@@ -23,87 +22,96 @@
-include("jlib.hrl").
-include("mod_roster.hrl").
--record(session, {sid, usr, us, priority}). % copied from ejabberd_sm.erl
+%% Copied from ejabberd_sm.erl
+-record(session, {sid, usr, us, priority, info}).
+
+-compile(export_all).
+
+%%-------------
+%% gen_mod
+%%-------------
start(Host, _Opts) ->
- ejabberd_ctl:register_commands([
- {"compile file", "recompile and reload file"},
- {"load-config file", "load config from file"},
- {"remove-node nodename", "remove an ejabberd node from the database"},
-
- %% ejabberd_auth
- {"delete-older-users days", "delete users that have not logged in the last 'days'"},
- {"set-password user server password", "set password to user at server"},
-
- %% ejd2odbc
- {"export2odbc server output", "export Mnesia tables on server to files on output directory"},
-
- %% mod_offline
- {"delete-older-messages days", "delete offline messages older than 'days'"},
-
- %% mod_shared_roster
- {"srg-create group host name description display", "create the group with options"},
- {"srg-delete group host", "delete the group"},
- {"srg-user-add user server group host", "add user at server to group on host"},
- {"srg-user-del user server group host", "delete user at server from group on host"},
-
- %% mod_vcard
- {"vcard-get user host data [data2]", "get data from the vCard of the user"},
- {"vcard-set user host data [data2] content", "set data to content on the vCard"},
-
- %% mod_announce
- %% announce_send_online host message
- %% announce_send_all host, message
-
- %% mod_muc
- %% muc-add room opts
- %% muc-del room
- {"muc-purge days", "destroy rooms with not activity on the last 'days'"},
- {"muc-online-rooms", "list existing rooms"},
-
- %% mod_roster
- {"add-rosteritem user1 server1 user2 server2 nick group subs", "Add user2 at server2 to user1 at server1's roster"},
- %%{"", "subs= none, from, to or both"},
- %%{"", "example: add-roster peter localhost mike server.com MiKe Employees both"},
- %%{"", "will add mike at server.com to peter at localhost roster"},
- {"rem-rosteritem user1 server1 user2 server2", "Remove user2 at server2 from user1 at server1's roster"},
- {"pushroster file user server", "push template roster in file to user at server"},
- {"pushroster-all file", "push template roster in file to all those users"},
- {"push-alltoall server group", "adds all the users to all the users in Group"},
-
- {"status-list status", "list the logged users with status"},
- {"status-num status", "number of logged users with status"},
-
- {"stats registeredusers", "number of registered users"},
- {"stats onlineusers", "number of logged users"},
- {"stats uptime-seconds", "uptime of ejabberd node in seconds"},
-
- %% misc
- {"get-cookie", "get the Erlang cookie of this node"},
- {"killsession user server resource", "kill a user session"}
- ], ?MODULE, ctl_process),
- ejabberd_ctl:register_commands(Host, [
- %% mod_muc
- {"muc-purge days", "destroy rooms with not activity on the last 'days'"},
- {"muc-online-rooms", "list existing rooms"},
-
- %% mod_last
- {"num-active-users days", "number of users active in the last 'days'"},
- {"status-list status", "list the logged users with status"},
- {"status-num status", "number of logged users with status"},
- {"stats registeredusers", "number of registered users"},
- {"stats onlineusers", "number of logged users"}
- ], ?MODULE, ctl_process),
- ok.
-
-stop(_Host) ->
- ok.
-
-
-ctl_process(_Val, ["blo"]) ->
- FResources = "eeeaaa aaa",
- io:format("~s", [FResources]),
- ?STATUS_SUCCESS;
+ ejabberd_ctl:register_commands(commands_global(), ?MODULE, ctl_process),
+ ejabberd_ctl:register_commands(Host, commands_host(), ?MODULE, ctl_process).
+
+stop(Host) ->
+ ejabberd_ctl:unregister_commands(commands_global(), ?MODULE, ctl_process),
+ ejabberd_ctl:unregister_commands(Host, commands_host(), ?MODULE, ctl_process).
+
+commands_global() ->
+ [
+ {"compile file", "recompile and reload file"},
+ {"load-config file", "load config from file"},
+ {"remove-node nodename", "remove an ejabberd node from the database"},
+
+ %% ejabberd_auth
+ {"delete-older-users days", "delete users that have not logged in the last 'days'"},
+ {"set-password user server password", "set password to user at server"},
+
+ %% ejd2odbc
+ {"export2odbc server output", "export Mnesia tables on server to files on output directory"},
+
+ %% mod_offline
+ {"delete-older-messages days", "delete offline messages older than 'days'"},
+
+ %% mod_shared_roster
+ {"srg-create group host name description display", "create the group with options"},
+ {"srg-delete group host", "delete the group"},
+ {"srg-user-add user server group host", "add user at server to group on host"},
+ {"srg-user-del user server group host", "delete user at server from group on host"},
+ {"srg-list-groups host", "list the shared roster groups from host"},
+ {"srg-get-info group host", "get info of a specific group on host"},
+
+ %% mod_vcard
+ {"vcard-get user host data [data2]", "get data from the vCard of the user"},
+ {"vcard-set user host data [data2] content", "set data to content on the vCard"},
+
+ %% mod_announce
+ %% announce_send_online host message
+ %% announce_send_all host, message
+
+ %% mod_roster
+ {"add-rosteritem user1 server1 user2 server2 nick group subs", "Add user2 at server2 to user1 at server1's roster"},
+ %%{"", "subs= none, from, to or both"},
+ %%{"", "example: add-roster peter localhost mike server.com MiKe Employees both"},
+ %%{"", "will add mike at server.com to peter at localhost roster"},
+ {"rem-rosteritem user1 server1 user2 server2", "Remove user2 at server2 from user1 at server1's roster"},
+ {"rosteritem-purge [options]", "Purge all rosteritems that match filtering options"},
+ {"pushroster file user server", "push template roster in file to user at server"},
+ {"pushroster-all file", "push template roster in file to all those users"},
+ {"push-alltoall server group", "adds all the users to all the users in Group"},
+
+ {"status-list status", "list the logged users with status"},
+ {"status-num status", "number of logged users with status"},
+
+ {"stats registeredusers", "number of registered users"},
+ {"stats onlineusers", "number of logged users"},
+ {"stats onlineusersnode", "number of logged users in the ejabberd node"},
+ {"stats uptime-seconds", "uptime of ejabberd node in seconds"},
+
+ %% misc
+ {"get-cookie", "get the Erlang cookie of this node"},
+ {"killsession user server resource", "kill a user session"}
+ ].
+
+commands_host() ->
+ [
+ %% mod_last
+ {"num-active-users days", "number of users active in the last 'days'"},
+ {"status-list status", "list the logged users with status"},
+ {"status-num status", "number of logged users with status"},
+ {"stats registeredusers", "number of registered users"},
+ {"stats onlineusers", "number of logged users"},
+
+ %% misc
+ {"ban-account username [reason]", "ban account: kick sessions and change password"}
+ ].
+
+
+%%-------------
+%% Commands global
+%%-------------
ctl_process(_Val, ["delete-older-messages", Days]) ->
mod_offline:remove_old_messages(list_to_integer(Days)),
@@ -126,7 +134,8 @@
Export = fun({TableFun, Table}) ->
Filename = filename:join([Output, atom_to_list(Table)++".txt"]),
io:format("Trying to export Mnesia table '~p' on server '~s' to file '~s'~n", [Table, Server, Filename]),
- catch ejd2odbc:TableFun(Server, Filename)
+ Res = (catch ejd2odbc:TableFun(Server, Filename)),
+ io:format(" Result: ~p~n", [Res])
end,
lists:foreach(Export, Tables),
?STATUS_SUCCESS;
@@ -163,7 +172,8 @@
mnesia:del_table_copy(schema, list_to_atom(Node)),
?STATUS_SUCCESS;
-ctl_process(_Val, ["srg-create", Group, Host, Name, Description, Display]) ->
+ctl_process(_Val, ["srg-create" | Parameters]) ->
+ [Group, Host, Name, Description, Display] = group_parameters(Parameters, "'"),
Opts = [{name, Name}, {displayed_groups, [Display]}, {description, Description}],
{atomic, ok} = mod_shared_roster:create_group(Host, Group, Opts),
?STATUS_SUCCESS;
@@ -180,13 +190,23 @@
{atomic, ok} = mod_shared_roster:remove_user_from_group(Host, {User, Server}, Group),
?STATUS_SUCCESS;
-ctl_process(_Val, ["muc-purge", Days]) ->
- {purged, Num_total, Num_purged, Names_purged} = muc_purge(list_to_integer(Days)),
- io:format("Purged ~p chatrooms from a total of ~p on the server:~n~p~n", [Num_purged, Num_total, Names_purged]),
+ctl_process(_Val, ["srg-list-groups", Host]) ->
+ lists:foreach(
+ fun(SrgGroup) ->
+ io:format("~s~n",[SrgGroup])
+ end,
+ lists:sort(mod_shared_roster:list_groups(Host))),
?STATUS_SUCCESS;
-ctl_process(_Val, ["muc-online-rooms"]) ->
- format_print_room(all, ets:tab2list(muc_online_room)),
+ctl_process(_Val, ["srg-get-info", Group, Host]) ->
+ Opts = mod_shared_roster:get_group_opts(Host,Group),
+ [io:format("~s: ~p~n", [Title, Value]) || {Title , Value} <- Opts],
+
+ Members = mod_shared_roster:get_group_explicit_users(Host,Group),
+ Members_string = [ " " ++ jlib:jid_to_string(jlib:make_jid(MUser, MServer, ""))
+ || {MUser, MServer} <- Members],
+ io:format("members:~s~n", [Members_string]),
+
?STATUS_SUCCESS;
ctl_process(_Val, ["add-rosteritem", LocalUser, LocalServer, RemoteUser, RemoteServer, Nick, Group, Subs]) ->
@@ -217,6 +237,67 @@
?STATUS_BADRPC
end;
+ctl_process(_Val, ["rosteritem-purge"]) ->
+ io:format("Rosteritems that match all the filtering will be removed.~n"),
+ io:format("Options for filtering:~n"),
+ io:format("~n"),
+ io:format(" -subs none|from|to|both~n"),
+ io:format(" Subscription type. By default all values~n"),
+ io:format("~n"),
+ io:format(" -ask none|out|in~n"),
+ io:format(" Pending subscription. By default all values~n"),
+ io:format("~n"),
+ io:format(" -user JID~n"),
+ io:format(" The JID of the local user.~n"),
+ io:format(" Can use these globs: *, ? and [...].~n"),
+ io:format(" By default it is: * *@*~n"),
+ io:format("~n"),
+ io:format(" -contact JID~n"),
+ io:format(" Similar to 'user', but for the contact JID.~n"),
+ io:format("~n"),
+ io:format("Example:~n"),
+ io:format(" ejabberdctl rosteritem-purge -subs none from to -ask out in -contact *@*icq*~n"),
+ io:format("~n"),
+ ?STATUS_SUCCESS;
+ctl_process(_Val, ["rosteritem-purge" | Options_list]) ->
+ Options_prop_list = lists:foldl(
+ fun(O, R) ->
+ case O of
+ [$- | K] ->
+ [{K, []} | R];
+ V ->
+ [{K, Vs} | RT] = R,
+ [{K, [V|Vs]} | RT]
+ end
+ end,
+ [],
+ Options_list),
+
+ Subs = [list_to_atom(S)
+ || S <- proplists:get_value("subs",
+ Options_prop_list,
+ ["none", "from", "to", "both"])],
+ Asks = [list_to_atom(S)
+ || S <-
+ proplists:get_value("ask",
+ Options_prop_list,
+ ["none", "out", "in"])],
+ User = proplists:get_value("user", Options_prop_list, ["*", "*@*"]),
+ Contact = proplists:get_value("contact", Options_prop_list, ["*", "*@*"]),
+
+ case rosteritem_purge({Subs, Asks, User, Contact}) of
+ {atomic, ok} ->
+ ?STATUS_SUCCESS;
+ {error, Reason} ->
+ io:format("Error purging rosteritems: ~p~n",
+ [Reason]),
+ ?STATUS_ERROR;
+ {badrpc, Reason} ->
+ io:format("BadRPC purging rosteritems: ~p~n",
+ [Reason]),
+ ?STATUS_BADRPC
+ end;
+
ctl_process(_Val, ["pushroster", File, User, Server]) ->
case pushroster(File, User, Server) of
ok ->
@@ -277,7 +358,8 @@
Res = case Stat of
"uptime-seconds" -> uptime_seconds();
"registeredusers" -> mnesia:table_info(passwd, size);
- "onlineusers" -> mnesia:table_info(session, size)
+ "onlineusersnode" -> length(ejabberd_sm:dirty_get_my_sessions_list());
+ "onlineusers" -> length(ejabberd_sm:dirty_get_sessions_list())
end,
io:format("~p~n", [Res]),
?STATUS_SUCCESS;
@@ -292,26 +374,17 @@
io:format("~s~n", [atom_to_list(erlang:get_cookie())]),
?STATUS_SUCCESS;
-ctl_process(_Val, ["killsession", User, Server, Resource]) ->
- ejabberd_router:route(
- jlib:make_jid("", "", ""),
- jlib:make_jid(User, Server, Resource),
- {xmlelement, "broadcast", [], [{exit, "killed"}]}),
+ctl_process(_Val, ["killsession", User, Server, Resource | Tail]) ->
+ kick_session(User, Server, Resource, prepare_reason(Tail)),
?STATUS_SUCCESS;
ctl_process(Val, _Args) ->
Val.
-ctl_process(_Val, Host, ["muc-purge", Days]) ->
- {purged, Num_total, Num_purged, Names_purged} = muc_purge(Host, list_to_integer(Days)),
- io:format("Purged ~p chatrooms from a total of ~p on the host ~p:~n~p~n", [Num_purged, Num_total, Host, Names_purged]),
- ?STATUS_SUCCESS;
-
-ctl_process(_Val, ServerHost, ["muc-online-rooms"]) ->
- MUCHost = find_host(ServerHost),
- format_print_room(MUCHost, ets:tab2list(muc_online_room)),
- ?STATUS_SUCCESS;
+%%-------------
+%% Commands vhost
+%%-------------
ctl_process(_Val, Host, ["num-active-users", Days]) ->
Number = num_active_users(Host, list_to_integer(Days)),
@@ -336,14 +409,21 @@
[ io:format("~s@~s ~s ~p \"~s\"~n", [U, S, R, P, St]) || {U, S, R, P, St} <- Res],
?STATUS_SUCCESS;
+ctl_process(_Val, Host, ["ban-account", User | Tail]) ->
+ ban_account(User, Host, prepare_reason(Tail)),
+ ?STATUS_SUCCESS;
+
ctl_process(Val, _Host, _Args) ->
Val.
%%-------------
-%% UTILS
+%% Utils
%%-------------
+uptime_seconds() ->
+ trunc(element(1, erlang:statistics(wall_clock))/1000).
+
get_status_list(Host, Status_required) ->
%% Get list of all logged users
Sessions = ejabberd_sm:dirty_get_my_sessions_list(),
@@ -418,6 +498,153 @@
Packet = {xmlelement, "iq", [{"type", "set"}, {"to", ToS}], [Query]},
ejabberd_router:route(LJID, LJID, Packet).
+
+%%-----------------------------
+%% Ban user
+%%-----------------------------
+
+ban_account(User, Server, Reason) ->
+ kick_sessions(User, Server, Reason),
+ set_random_password(User, Server, Reason).
+
+kick_sessions(User, Server, Reason) ->
+ lists:map(
+ fun(Resource) ->
+ kick_session(User, Server, Resource, Reason)
+ end,
+ get_resources(User, Server)).
+
+kick_session(User, Server, Resource, Reason) ->
+ ejabberd_router:route(
+ jlib:make_jid("", "", ""),
+ jlib:make_jid(User, Server, Resource),
+ {xmlelement, "broadcast", [], [{exit, Reason}]}).
+
+get_resources(User, Server) ->
+ lists:map(
+ fun(Session) ->
+ element(3, Session#session.usr)
+ end,
+ get_sessions(User, Server)).
+
+get_sessions(User, Server) ->
+ LUser = jlib:nodeprep(User),
+ LServer = jlib:nameprep(Server),
+ Sessions = mnesia:dirty_index_read(session, {LUser, LServer}, #session.us),
+ true = is_list(Sessions),
+ Sessions.
+
+set_random_password(User, Server, Reason) ->
+ NewPass = build_random_password(Reason),
+ set_password(User, Server, NewPass).
+
+build_random_password(Reason) ->
+ Date = jlib:timestamp_to_iso(calendar:universal_time()),
+ RandomString = randoms:get_string(),
+ "BANNED_ACCOUNT--" ++ Date ++ "--" ++ RandomString ++ "--" ++ Reason.
+
+set_password(User, Server, Password) ->
+ {atomic, ok} = ejabberd_auth:set_password(User, Server, Password).
+
+prepare_reason([]) ->
+ "Kicked by administrator";
+prepare_reason([Reason]) ->
+ Reason;
+prepare_reason(StringList) ->
+ string:join(StringList, "_").
+
+
+%%-----------------------------
+%% Purge roster items
+%%-----------------------------
+
+rosteritem_purge(Options) ->
+ Num_rosteritems = mnesia:table_info(roster, size),
+ io:format("There are ~p roster items in total.~n", [Num_rosteritems]),
+ Key = mnesia:dirty_first(roster),
+ ok = rip(Key, Options, {0, Num_rosteritems, 0, 0}),
+ {atomic, ok}.
+
+rip('$end_of_table', _Options, Counters) ->
+ print_progress_line(Counters),
+ ok;
+rip(Key, Options, {Pr, NT, NV, ND}) ->
+ Key_next = mnesia:dirty_next(roster, Key),
+ ND2 = case decide_rip(Key, Options) of
+ true ->
+ mnesia:dirty_delete(roster, Key),
+ ND+1;
+ false ->
+ ND
+ end,
+ NV2 = NV+1,
+ Pr2 = print_progress_line({Pr, NT, NV2, ND2}),
+ rip(Key_next, Options, {Pr2, NT, NV2, ND2}).
+
+print_progress_line({Pr, NT, NV, ND}) ->
+ Pr2 = trunc((NV/NT)*100),
+ case Pr == Pr2 of
+ true ->
+ ok;
+ false ->
+ io:format("Progress ~p% - visited ~p - deleted ~p~n", [Pr2, NV, ND])
+ end,
+ Pr2.
+
+decide_rip(Key, {Subs, Asks, User, Contact}) ->
+ case catch mnesia:dirty_read(roster, Key) of
+ [RI] ->
+ lists:member(RI#roster.subscription, Subs)
+ andalso lists:member(RI#roster.ask, Asks)
+ andalso decide_rip_jid(RI#roster.us, User)
+ andalso decide_rip_jid(RI#roster.jid, Contact);
+ _ ->
+ false
+ end.
+
+%% Returns true if the server of the JID is included in the servers
+decide_rip_jid({UName, UServer, _UResource}, Match_list) ->
+ decide_rip_jid({UName, UServer}, Match_list);
+decide_rip_jid({UName, UServer}, Match_list) ->
+ lists:any(
+ fun(Match_string) ->
+ MJID = jlib:string_to_jid(Match_string),
+ MName = MJID#jid.luser,
+ MServer = MJID#jid.lserver,
+ Is_server = is_glob_match(UServer, MServer),
+ case MName of
+ [] when UName == [] ->
+ Is_server;
+ [] ->
+ false;
+ _ ->
+ Is_server
+ andalso is_glob_match(UName, MName)
+ end
+ end,
+ Match_list).
+
+%% Copied from ejabberd-2.0.0/src/acl.erl
+is_regexp_match(String, RegExp) ->
+ case regexp:first_match(String, RegExp) of
+ nomatch ->
+ false;
+ {match, _, _} ->
+ true;
+ {error, ErrDesc} ->
+ io:format(
+ "Wrong regexp ~p in ACL: ~p",
+ [RegExp, lists:flatten(regexp:format_error(ErrDesc))]),
+ false
+ end.
+is_glob_match(String, Glob) ->
+ is_regexp_match(String, regexp:sh_to_awk(Glob)).
+
+
+%%-----------------------------
+%% Push Roster from file
+%%-----------------------------
+
pushroster(File, User, Server) ->
{ok, [Roster]} = file:consult(File),
subscribe_roster({User, Server, "", User}, Roster).
@@ -632,161 +859,28 @@
lists:reverse(Hist)
end.
-
-format_print_room(Host1, Rooms)->
- lists:foreach(
- fun({_, {Roomname, Host},_}) ->
- case Host1 of
- all ->
- io:format("~s ~s ~n", [Roomname, Host]);
- Host ->
- io:format("~s ~s ~n", [Roomname, Host]);
- _ ->
- ok
- end
- end,
- Rooms).
-
-
-%%----------------------------
-%% Purge MUC
-%%----------------------------
-
-%% Required for muc_purge
-%% Copied from mod_muc/mod_muc_room.erl
--define(DICT, dict).
--record(muc_online_room, {name_host, pid}).
--record(lqueue, {queue, len, max}).
--record(config, {title = "",
- allow_change_subj = true,
- allow_query_users = true,
- allow_private_messages = true,
- public = true,
- public_list = true,
- persistent = false,
- moderated = false, % TODO
- members_by_default = true,
- members_only = false,
- allow_user_invites = false,
- password_protected = false,
- password = "",
- anonymous = true,
- logging = false
- }).
--record(state, {room,
- host,
- server_host,
- access,
- jid,
- config = #config{},
- users,
- affiliations,
- history,
- subject = "",
- subject_author = "",
- just_created = false}).
-
-muc_purge(Days) ->
- ServerHost = global,
- Host = global,
- muc_purge2(ServerHost, Host, Days).
-
-muc_purge(ServerHost, Days) ->
- Host = find_host(ServerHost),
- muc_purge2(ServerHost, Host, Days).
-
-muc_purge2(ServerHost, Host, Last_allowed) ->
- Room_names = get_room_names(Host),
-
- Decide = fun(N) -> decide(N, Last_allowed) end,
- Rooms_to_delete = lists:filter(Decide, Room_names),
-
- Num_rooms = length(Room_names),
- Num_rooms_to_delete = length(Rooms_to_delete),
-
- Rooms_to_delete_full = fill_serverhost(Rooms_to_delete, ServerHost),
-
- Delete = fun({N, H, SH}) ->
- mod_muc:room_destroyed(H, N, SH),
- mod_muc:forget_room(H, N)
- end,
- lists:foreach(Delete, Rooms_to_delete_full),
- {purged, Num_rooms, Num_rooms_to_delete, Rooms_to_delete}.
-
-fill_serverhost(Rooms_to_delete, global) ->
- ServerHosts1 = ?MYHOSTS,
- ServerHosts2 = [ {ServerHost, find_host(ServerHost)} || ServerHost <- ServerHosts1],
- [ {Name, Host, find_serverhost(Host, ServerHosts2)} || {Name, Host} <- Rooms_to_delete];
-fill_serverhost(Rooms_to_delete, ServerHost) ->
- [ {Name, Host, ServerHost}|| {Name, Host} <- Rooms_to_delete].
-
-find_serverhost(Host, ServerHosts) ->
- {value, {ServerHost, Host}} = lists:keysearch(Host, 2, ServerHosts),
- ServerHost.
-
-find_host(ServerHost) ->
- gen_mod:get_module_opt(ServerHost, mod_muc, host, "conference." ++ ServerHost).
-
-decide({Room_name, Host}, Last_allowed) ->
- Room_pid = get_room_pid(Room_name, Host),
-
- C = get_room_config(Room_pid),
- Persistent = C#config.persistent,
-
- S = get_room_state(Room_pid),
- Just_created = S#state.just_created,
-
- Room_users = S#state.users,
- Num_users = length(?DICT:to_list(Room_users)),
-
- History = (S#state.history)#lqueue.queue,
- Ts_now = calendar:now_to_universal_time(now()),
- Ts_uptime = element(1, erlang:statistics(wall_clock))/1000,
- {Have_history, Last} = case queue:is_empty(History) of
- true ->
- {false, Ts_uptime};
- false ->
- Last_message = queue:last(History),
- {_, _, _, Ts_last, _} = Last_message,
- Ts_diff =
- calendar:datetime_to_gregorian_seconds(Ts_now)
- - calendar:datetime_to_gregorian_seconds(Ts_last),
- {true, Ts_diff}
- end,
-
- case {Persistent, Just_created, Num_users, Have_history, seconds_to_days(Last)} of
- {true, false, 0, _, Last_days}
- when Last_days > Last_allowed ->
- true;
- _ ->
- false
- end.
-
-seconds_to_days(S) ->
- round(S) div 60*60*24.
-
-uptime_seconds() ->
- trunc(element(1, erlang:statistics(wall_clock))/1000).
-
-get_room_names(Host) ->
- Get_room_names = fun(Room_reg, Names) ->
- case {Host, Room_reg#muc_online_room.name_host} of
- {Host, {Name1, Host}} ->
- [{Name1, Host} | Names];
- {global, {Name1, Host1}} ->
- [{Name1, Host1} | Names];
- _ ->
- Names
- end
- end,
- ets:foldr(Get_room_names, [], muc_online_room).
-
-get_room_pid(Name, Host) ->
- [Room_ets] = ets:lookup(muc_online_room, {Name, Host}),
- Room_ets#muc_online_room.pid.
-
-get_room_config(Room_pid) ->
- gen_fsm:sync_send_all_state_event(Room_pid, get_config).
-
-get_room_state(Room_pid) ->
- gen_fsm:sync_send_all_state_event(Room_pid, get_state).
+group_parameters(Ps, [Char]) ->
+ {none, Grouped_Ps} = lists:foldl(
+ fun(P, {State, Res}) ->
+ case State of
+ none ->
+ case P of
+ [Char | PTail]->
+ {building, [PTail | Res]};
+ _ ->
+ {none, [P | Res]}
+ end;
+ building ->
+ [ResHead | ResTail] = Res,
+ case lists:last(P) of
+ Char ->
+ P2 = lists:sublist(P, length(P)-1),
+ {none, [ResHead ++ " " ++ P2 | ResTail]};
+ _ ->
+ {building, [ResHead ++ " " ++ P | ResTail]}
+ end
+ end
+ end,
+ {none, []},
+ Ps),
+ lists:reverse(Grouped_Ps).
Index: sources
===================================================================
RCS file: /cvs/extras/rpms/ejabberd/F-8/sources,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- sources 24 May 2008 18:12:50 -0000 1.8
+++ sources 29 Aug 2008 20:19:31 -0000 1.9
@@ -1 +1 @@
-9c9417ab8dc334094ec7a611016c726e ejabberd-2.0.1_2.tar.gz
+eef7ab12fc1e3ed34669bb2d5e1d0448 ejabberd-2.0.2.tar.gz
- Previous message (by thread): rpms/ejabberd/F-9 ejabberd-ejabberd_cfg_pam_name.diff, NONE, 1.1 ejabberd.pam, NONE, 1.1 .cvsignore, 1.9, 1.10 ejabberd-build.patch, 1.2, 1.3 ejabberd-ejabberdctl_fix.diff, 1.2, 1.3 ejabberd.spec, 1.25, 1.26 import.log, 1.2, 1.3 mod_ctlextra.erl, 1.3, 1.4 sources, 1.11, 1.12
- Next message (by thread): rpms/psmisc/devel psmisc.spec,1.50,1.51
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list