diff --git a/ChangeLog b/ChangeLog
index cd04540e4..72fe05cb9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-07-11 Jean-Sébastien Pédron ejabberd is a free and open source instant messaging server written in Erlang. ejabberd is cross-platform, distributed, fault-tolerant, and based on open standards to achieve real-time communication. ejabberd is designed to be a rock-solid and feature rich XMPP server. ejabberd is suitable for small deployments, whether they need to be scalable or not, as well as extremely big deployments.
-
-Chapter 1 Introduction
The command to compile ejabberd in BSD systems is:
gmake ++
You need to have GNU install, +but it isn’t included in Solaris. +It can be easily installed if your Solaris system +is set up for blastwave.org +package repository. +Make sure /opt/csw/bin is in your PATH and run: +
pkg-get -i fileutils +
If that program is called ginstall, +modify the ejabberd Makefile script to suit your system, +for example: +
cat Makefile | sed s/install/ginstall/ > Makefile.gi +
And finally install ejabberd with: +
gmake -f Makefile.gi ginstall-
To compile ejabberd on a Microsoft Windows system, you need:
ejabberd\src\ejabberd.cfg
and run
werl -s ejabberd -name ejabberd
You need a Jabber account and grant him administrative privileges +
You need a Jabber account and grant him administrative privileges to enter the ejabberd Web Admin:
To upgrade an ejabberd installation to a new version, +
To upgrade an ejabberd installation to a new version, simply uninstall the old version, and then install the new one. Of course, it is important that the configuration file and Mnesia database spool directory are not removed.
ejabberd automatically updates the Mnesia table definitions at startup when needed. If you also use an external database for storage of some modules, check if the release notes of the new ejabberd version indicates you need to also update those tables.
-The configuration file will be loaded the first time you start ejabberd. The +
The configuration file will be loaded the first time you start ejabberd. The content from this file will be parsed and stored in the internal ejabberd database. Subsequently the configuration will be loaded from the database and any commands in the configuration file are appended to the entries in the database.
Note that ejabberd never edits the configuration file. @@ -477,7 +494,7 @@ override_acls.
With these lines the old global options (shared between all ejabberd nodes in a cluster), local options (which are specific for this particular ejabberd node) and ACLs will be removed before new ones are added.
-The option hosts defines a list containing one or more domains that ejabberd will serve.
Examples:
{hosts, ["example.net", "example.com"]}.
Options can be defined separately for every virtual host using the host_config option. It has the following syntax: @@ -561,7 +578,7 @@ other different modules for some specific virtual hosts: } ]}.
-The option listen defines for which addresses and ports ejabberd will listen and what services will be run on them. Each element of the list is a tuple with the following elements: @@ -623,7 +640,10 @@ do not allow outgoing sockets on port 5222.
If HTTP Polling is enabled, it wil is also needed in the Jabber client. Remark also that HTTP Polling can be interesting to host a web-based Jabber client such as JWChat. -
{ip, {192, 168, 1, 1}}
.
The option auth_method defines the authentication method that is used for user authentication:
{auth_method, [<method>]}. @@ -941,7 +961,7 @@ attacks.
Access control in ejabberd is performed via Access Control Lists (ACLs). The @@ -1048,7 +1068,7 @@ There’s also available the access max_s2s_connections_per_node.< Allow up to 3 connections with each remote server:
{access, max_s2s_connections, [{3, all}]}.-
Shapers enable you to limit connection traffic. The syntax of shapers is like this:
{shaper, <shapername>, <kind>}. @@ -1067,7 +1087,7 @@ To define a shaper named ‘normal’ with traffic speed limi 50,000 bytes/second:{shaper, fast, {maxrate, 50000}}.-3.1.7 Default Language
3.1.7 Default Language
The option language defines the default language of server strings that can be seen by Jabber clients. If a Jabber client do not support xml:lang, the specified language is used. The default value is @@ -1079,7 +1099,7 @@ To set Russian as default language:
{language, "es"}.
The option include_config_file in a configuration file instructs ejabberd to include other configuration files immediately.
The basic usage is:
{include_config_file, <filename>}.
It is also possible to specify suboptions: @@ -1110,7 +1130,7 @@ and later includes another file with additional rules:
{acl, admin, {user, "bob", "localhost"}}. {acl, admin, {user, "jan", "localhost"}}.-
In the ejabberd configuration file, it is possible to define a macro for a value and later use this macro when defining an option.
A macro is defined with this syntax: @@ -1159,7 +1179,7 @@ This usage behaves as if it were defined and used this way: ] }.
-ejabberd uses its internal Mnesia database by default. However, it is possible to use a relational database or an LDAP server to store persistent, @@ -1181,7 +1201,7 @@ different storage systems for modules, and so forth.
The following databas
Although this section will describe ejabberd’s configuration when you want to use the native MySQL driver, it does not describe MySQL’s installation and database creation. Check the MySQL documentation and the tutorial Using ejabberd with MySQL native driver for information regarding these topics. @@ -1237,7 +1257,7 @@ relational databases like MySQL. To enable storage to your database, just make sure that your database is running well (see previous sections), and replace the suffix-less or ldap module variant with the odbc module variant. Keep in mind that you cannot have several variants of the same module loaded!
-Although this section will describe ejabberd’s configuration when you want to use Microsoft SQL Server, it does not describe Microsoft SQL Server’s installation and database creation. Check the MySQL documentation and the @@ -1273,7 +1293,7 @@ database, just make sure that your database is running well (see previous sections), and replace the suffix-less or ldap module variant with the odbc module variant. Keep in mind that you cannot have several variants of the same module loaded!
-Although this section will describe ejabberd’s configuration when you want to use the native PostgreSQL driver, it does not describe PostgreSQL’s installation and database creation. Check the PostgreSQL documentation and the tutorial Using ejabberd with MySQL native driver for information regarding these topics. @@ -1332,7 +1352,7 @@ relational databases like PostgreSQL. To enable storage to your database, just make sure that your database is running well (see previous sections), and replace the suffix-less or ldap module variant with the odbc module variant. Keep in mind that you cannot have several variants of the same module loaded!
-Although this section will describe ejabberd’s configuration when you want to use the ODBC driver, it does not describe the installation and database creation of your database. Check the documentation of your database. The tutorial Using ejabberd with MySQL native driver also can help you. Note that the tutorial @@ -1375,7 +1395,7 @@ database, just make sure that your database is running well (see previous sections), and replace the suffix-less or ldap module variant with the odbc module variant. Keep in mind that you cannot have several variants of the same module loaded!
-ejabberd has built-in LDAP support. You can authenticate users against LDAP server and use LDAP directory as vCard storage. Shared rosters are not supported yet.
@@ -1552,7 +1572,7 @@ configuration is shown below:{auth_method, ldap}. ... ]}.-
The option modules defines the list of modules that will be loaded after ejabberd’s startup. Each entry in the list is a tuple in which the first element is the name of a module and the second is a list of options for that @@ -1574,7 +1594,7 @@ all entries end with a comma: {mod_version, []} ]}.
-The following table lists all modules included in ejabberd.
-
Module Feature Dependencies @@ -1636,7 +1656,7 @@ Last connection date and time: Use mod_last_odbc instead of ejabberd website. Please remember that these contributions might not work or that they can contain severe bugs and security leaks. Therefore, use them at your own risk! - mod_adhoc Ad-Hoc Commands (XEP-0050) 3.3.2 Common Options
The following options are used by many modules. Therefore, they are described in +
3.3.2 Common Options
The following options are used by many modules. Therefore, they are described in this separate section.
iqdisc
Many modules define handlers for processing IQ queries of different namespaces @@ -1688,7 +1708,7 @@ the "@HOST@" keyword must be used: ... ]}.
-3.3.3 mod_announce
3.3.3 mod_announce
This module enables configured users to broadcast announcements and to set the message of the day (MOTD). Configured users can perform these actions with a @@ -1752,7 +1772,7 @@ Only administrators can send announcements:
Note that mod_announce can be resource intensive on large deployments as it can broadcast lot of messages. This module should be disabled for instances of ejabberd with hundreds of thousands users.
-3.3.4 mod_disco
3.3.4 mod_disco
@@ -1795,7 +1815,7 @@ To serve a link to the Jabber User Directory on jabber.org: ... ]}.
-3.3.5 mod_echo
3.3.5 mod_echo
This module simply echoes any Jabber packet back to the sender. This mirror can be of interest for ejabberd and Jabber client debugging.
Options: @@ -1815,7 +1835,7 @@ of them all? ... ]}.
-3.3.6 mod_irc
3.3.6 mod_irc
This module is an IRC transport that can be used to join channels on IRC servers.
End user information: @@ -1874,7 +1894,7 @@ our domains and on other servers. ... ]}.
-3.3.7 mod_last
3.3.7 mod_last
This module adds support for Last Activity (XEP-0012). It can be used to discover when a disconnected user last accessed the server, to know when a connected user was last active on the server, or to query the uptime of the @@ -1883,7 +1903,7 @@ connected user was last active on the server, or to query the uptime of the iqdisc
This specifies the processing discipline for Last activity (jabber:iq:last) IQ queries (see section 3.3.2). -3.3.8 mod_muc
3.3.8 mod_muc
With this module enabled, your server will support Multi-User Chat (XEP-0045). End users will be able to join text conferences.
Some of the features of Multi-User Chat:
-
- @@ -2083,7 +2103,7 @@ newly created chatrooms have by default those options. ... ]}.
3.3.9 mod_muc_log
3.3.9 mod_muc_log
This module enables optional logging of Multi-User Chat (MUC) conversations to HTML. Once you enable this module, users can join a chatroom using a MUC capable Jabber client, and if they have enough privileges, they can request the @@ -2092,8 +2112,8 @@ configuration form in which they can set the option to enable chatroom logging.< Chatroom details are added on top of each page: room title, JID, author, subject and configuration.
-Room title and JID are links to join the chatroom (using -XMPP URIs). +The room JID in the generated HTML is a link to join the chatroom (using +XMPP URI). Subject and chatroom configuration changes are tracked and displayed. Joins, leaves, nick changes, kicks, bans and ‘/me’ are tracked and displayed, including the reason if available. @@ -2190,7 +2210,7 @@ top link will be the default -<a href="/">Home</a>
. ... ]}.3.3.10 mod_offline
3.3.10 mod_offline
This module implements offline message storage. This means that all messages sent to an offline user will be stored on the server until that user comes online again. Thus it is very similar to how email works. Note that @@ -2201,7 +2221,7 @@ is use to set a max number of offline messages per user (quota). Its value can be either infinity or a strictly positive integer. The default value is infinity.
-3.3.11 mod_privacy
3.3.11 mod_privacy
This module implements Blocking Communication (also known as Privacy Rules) as defined in section 10 from XMPP IM. If end users have support for it in their Jabber client, they will be able to: @@ -2229,7 +2249,7 @@ subscription type (or globally). iqdisc
This specifies the processing discipline for Blocking Communication (jabber:iq:privacy) IQ queries (see section 3.3.2). -3.3.12 mod_private
3.3.12 mod_private
This module adds support for Private XML Storage (XEP-0049):
Using this method, Jabber entities can store private data on the server and @@ -2241,7 +2261,7 @@ of client-specific preferences; another is Bookmark Storage ( This specifies the processing discipline for Private XML Storage (jabber:iq:private) IQ queries (see section 3.3.2). -3.3.13 mod_proxy65
3.3.13 mod_proxy65
This module implements SOCKS5 Bytestreams (XEP-0065). It allows ejabberd to act as a file transfer proxy between two XMPP clients.
Options: @@ -2296,7 +2316,7 @@ The simpliest configuration of the module: ... ]}.
-3.3.14 mod_pubsub
3.3.14 mod_pubsub
This module offers a Publish-Subscribe Service (XEP-0060). The functionality in mod_pubsub can be extended using plugins. The plugin that implements PEP (Personal Eventing via Pubsub) (XEP-0163) @@ -2327,7 +2347,7 @@ and is shared by all node plugins. ... ]}.
-3.3.15 mod_register
3.3.15 mod_register
This module adds support for In-Band Registration (XEP-0077). This protocol enables end users to use a Jabber client to:
-
- @@ -2343,6 +2363,7 @@ restrictions by default).
- welcome_message
- Set a welcome message that is sent to each newly registered account. The first string is the subject, and the second string is the message body. +In the body you can set a newline with the characters: ~n.
- registration_watchers
- This option defines a list of JIDs which will be notified each time a new account is registered.
- iqdisc
- This specifies @@ -2393,19 +2414,19 @@ Also define a registration timeout of one hour: ... {mod_register, [ - {welcome_message, {"Welcome!", "Welcome to this Jabber server. Check http://www.jabber.org"}}, + {welcome_message, {"Welcome!", "Hi.~nWelcome to this Jabber server.~n Check http://www.jabber.org~n~nBye"}}, {registration_watchers, ["admin1@example.org", "boss@example.net"]} ]}, ... ]}.
3.3.16 mod_roster
3.3.16 mod_roster
This module implements roster management as defined in RFC 3921: XMPP IM.
Options:
-
- iqdisc
- This specifies the processing discipline for Roster Management (jabber:iq:roster) IQ queries (see section 3.3.2).
3.3.17 mod_service_log
3.3.17 mod_service_log
This module adds support for logging end user packets via a Jabber message auditing service such as Bandersnatch. All user @@ -2435,7 +2456,7 @@ To log all end user packets to the Bandersnatch service running on ... ]}.
-3.3.18 mod_shared_roster
3.3.18 mod_shared_roster
This module enables you to create shared roster groups. This means that you can create groups of people that can see members from (other) groups in their rosters. The big advantages of this feature are that end users do not need to @@ -2510,7 +2531,7 @@ roster groups as shown in the following table:
This module adds support for Statistics Gathering (XEP-0039). This protocol allows you to retrieve next statistics from your ejabberd deployment:
This module features support for Entity Time (XEP-0090). By using this XEP, you are able to discover the time at another entity’s location.
Options:
This module allows end users to store and retrieve their vCard, and to retrieve other users vCards, as defined in vcard-temp (XEP-0054). The module also implements an uncomplicated Jabber User Directory based on the vCards of @@ -2604,7 +2625,7 @@ and that all virtual hosts will be searched instead of only the current one: ... ]}.
-ejabberd can map LDAP attributes to vCard fields. This behaviour is implemented in the mod_vcard_ldap module. This module does not depend on the authentication method (see 3.2.5).
The mod_vcard_ldap module has @@ -2778,7 +2799,7 @@ searching his info in LDAP.
This module implements Software Version (XEP-0092). Consequently, it answers ejabberd’s version when queried.
Options:
The ejabberdctl command line administration script allows to start, stop and perform +
The ejabberdctl command line administration script allows to start, stop and perform many other administrative tasks in a local or remote ejabberd server.
When ejabberdctl is executed without any parameter, it displays the available options. If there isn’t an ejabberd server running, the available parameters are: @@ -2822,7 +2843,7 @@ and other codes may be used for specifical results. This can be used by other scripts to determine automatically if a command succedded or failed, for example using: echo $?
-ejabberd is an Erlang/OTP application that runs inside an Erlang runtime system. +
ejabberd is an Erlang/OTP application that runs inside an Erlang runtime system. This system is configured using environment variables and command line parameters. The ejabberdctl administration script uses many of those possibilities. You can configure some of them with the file ejabberdctl.cfg, @@ -2889,7 +2910,7 @@ Starts the Erlang system detached from the system console.
Note that some characters need to be escaped when used in shell scripts, for instance "
and {}
.
You can find other options in the Erlang manual page (erl -man erl).
The ejabberd Web Admin allows to administer most of ejabberd using a web browser.
This feature is enabled by default:
a ejabberd_http listener with the option web_admin (see
section 3.1.3) is included in the listening ports. Then you can open
@@ -2949,15 +2970,15 @@ web browser to https://192.168.1.1:5280/admin/
:
...
]}.
If you enable mod_configure and mod_adhoc, +
If you enable mod_configure and mod_adhoc, you can perform several administrative tasks in ejabberd with a Jabber client. The client must support Ad-Hoc Commands (XEP-0050), and you must login in the Jabber server with an account with proper privileges.
-ejabberd uses the distributed Mnesia database. +
ejabberd uses the distributed Mnesia database. Being distributed, Mnesia enforces consistency of its file, -so it stores the name of the Erlang node in it. +so it stores the name of the Erlang node in it (see section 5.4). The name of an Erlang node includes the hostname of the computer. So, the name of the Erlang node changes if you change the name of the machine in which ejabberd runs, @@ -2971,8 +2992,8 @@ you must follow these instructions: For example:
ejabberdctl restore /tmp/ejabberd-oldhost.backup-
You need to take the following TCP ports in mind when configuring your firewall:
-
@@ -2983,7 +3004,7 @@ you must follow these instructions: Port Description port range Used for connections between Erlang nodes. This range is configurable (see section 5.2).
epmd (Erlang Port Mapper Daemon) +
epmd (Erlang Port Mapper Daemon) is a small name server included in Erlang/OTP and used by Erlang programs when establishing distributed Erlang communications. ejabberd needs epmd to use ejabberdctl and also when clustering ejabberd nodes. @@ -3008,9 +3029,10 @@ but can be configured in the file ejabberdctl.cfg. The Erlang command-line parameter used internally is, for example:
erl ... -kernel inet_dist_listen_min 4370 inet_dist_listen_max 4375-
The Erlang cookie is a string with numbers and letters. -An Erlang node reads the cookie at startup from the command-line parameter -setcookie -or from a cookie file. +
The Erlang cookie is a string with numbers and letters. +An Erlang node reads the cookie at startup from the command-line parameter -setcookie. +If not indicated, the cookie is read from the cookie file $HOME/.erlang.cookie. +If this file does not exist, it is created immediately with a random cookie. Two Erlang nodes communicate only if they have the same cookie. Setting a cookie on the Erlang node allows you to structure your Erlang network and define which nodes are allowed to connect to which.
Thanks to Erlang cookies, you can prevent access to the Erlang node by mistake, @@ -3021,7 +3043,7 @@ to prevent unauthorized access or intrusion to an Erlang node. The communication between Erlang nodes are not encrypted, so the cookie could be read sniffing the traffic on the network. The recommended way to secure the Erlang node is to block the port 4369.
-An Erlang node may have a node name. +
An Erlang node may have a node name. The name can be short (if indicated with the command-line parameter -sname) or long (if indicated with the parameter -name). Starting an Erlang node with -sname limits the communication between Erlang nodes to the LAN.
Using the option -sname instead of -name is a simple method @@ -3029,10 +3051,30 @@ to difficult unauthorized access to your Erlang node. However, it is not ultimately effective to prevent access to the Erlang node, because it may be possible to fake the fact that you are on another network using a modified version of Erlang epmd. -The recommended way to secure the Erlang node is to block the port 4369.
-+The recommended way to secure the Erlang node is to block the port 4369.
+ejabberd stores sensible data in the file system either in plain text or binary files. +The file system permissions should be set to only allow the proper user to read, +write and execute those files and directories.
A Jabber domain is served by one or more ejabberd nodes. These nodes can be run on different machines that are connected via a network. They all must have the ability to connect to port 4369 of all another nodes, and must @@ -3046,29 +3088,29 @@ router,
This module is the main router of Jabber packets on each node. It routes them based on their destination’s domains. It uses a global routing table. The domain of the packet’s destination is searched in the routing table, and if it is found, the packet is routed to the appropriate process. If not, it is sent to the s2s manager.
-This module routes packets which have a destination domain equal to one of this server’s host names. If the destination JID has a non-empty user part, it is routed to the session manager, otherwise it is processed depending on its content.
-This module routes packets to local users. It looks up to which user resource a packet must be sent via a presence table. Then the packet is either routed to the appropriate c2s process, or stored in offline storage, or bounced back.
-This module routes packets to other Jabber servers. First, it checks if an opened s2s connection from the domain of the packet’s source to the domain of the packet’s destination exists. If that is the case, the s2s manager routes the packet to the process serving this connection, otherwise a new connection is opened.
-Suppose you already configured ejabberd on one machine named (first), and you need to setup another one to make an ejabberd cluster. Then do following steps:
access
’ options — they will be taken from
enabled only on one machine in the cluster).
You can repeat these steps for other machines supposed to serve this domain.
-ejabberd includes an algorithm to load balance the components that are plugged on an ejabberd cluster. It means that you can plug one or several instances of the same component on each ejabberd cluster and that the traffic will be automatically distributed.
The default distribution algorithm try to deliver to a local instance of a component. If several local instances are available, one instance is chosen randomly. If no instance is available locally, one instance is chosen randomly among the remote component instances.
If you need a different behaviour, you can change the load balancing behaviour with the option domain_balancing. The syntax of the option is the following:
{domain_balancing, "component.example.com", <balancing_criterium>}.
Several balancing criteria are available:
When there is a risk of failure for a given component, domain balancing can cause service trouble. If one component is failing the service will not work correctly unless the sessions are rebalanced.
In this case, it is best to limit the problem to the sessions handled by the failing component. This is what the domain_balancing_component_number option does, making the load balancing algorithm not dynamic, but sticky on a fix number of component instances.
The syntax is the following:
{domain_balancing_component_number, "component.example.com", N}-
ejabberd includes a watchdog mechanism. If a process in the ejabberd server consumes too much memory, a message is sent to the Jabber accounts defined with the option @@ -3132,7 +3174,7 @@ Example configuration: To remove all watchdog admins, set the option with an empty list:
{watchdog_admins, []}.-
An ejabberd node writes two log files: +
An ejabberd node writes two log files:
{loglevel, 4}.-
The Debug Console is an Erlang shell attached to an already running ejabberd server. +
The Debug Console is an Erlang shell attached to an already running ejabberd server. With this Erlang shell, an experienced administrator can perform complex tasks.
This shell gives complete control over the ejabberd server, so it is important to use it with extremely care. There are some simple and safe examples in the article Interconnecting Erlang Nodes
To exit the shell, close the window or press the keys: control+c control+c.
-All built-in modules support the xml:lang attribute inside IQ queries. Figure A.1, for example, shows the reply to the following query:
<iq id='5' @@ -3181,9 +3223,9 @@ HTTP header ‘Accept-Language: ru’-Appendix B Release Notes
Appendix B Release Notes
Release notes are available from ejabberd Home Page
-Appendix C Acknowledgements
Thanks to all people who contributed to this guide: +
Appendix C Acknowledgements
Thanks to all people who contributed to this guide:
Ejabberd Installation and Operation Guide.
+
Ejabberd Installation and Operation Guide.
Copyright © 2003 — 2008 Process-one
This document is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
diff --git a/doc/guide.tex b/doc/guide.tex
index 73d889fc5..5a23a359a 100644
--- a/doc/guide.tex
+++ b/doc/guide.tex
@@ -361,7 +361,7 @@ The files and directories created are, by default:
\titem{/sbin/ejabberdctl} Administration script
\titem{/var/lib/ejabberd/}
\begin{description}
- \titem{.erlang.cookie} Erlang cookie file
+ \titem{.erlang.cookie} Erlang cookie file (see section \ref{cookie})
\titem{db} Mnesia database spool files
\titem{ebin} Binary Erlang files (*.beam)
\titem{priv}
@@ -405,6 +405,31 @@ gmake
\end{verbatim}
+\makesubsection{solaris}{Specific Notes for Sun Solaris}
+\ind{install!solaris}
+
+You need to have \term{GNU install},
+but it isn't included in Solaris.
+It can be easily installed if your Solaris system
+is set up for \footahref{http://www.blastwave.org/}{blastwave.org}
+package repository.
+Make sure \term{/opt/csw/bin} is in your \term{PATH} and run:
+\begin{verbatim}
+pkg-get -i fileutils
+\end{verbatim}
+
+If that program is called \term{ginstall},
+modify the \ejabberd{} \term{Makefile} script to suit your system,
+for example:
+\begin{verbatim}
+cat Makefile | sed s/install/ginstall/ > Makefile.gi
+\end{verbatim}
+And finally install \ejabberd{} with:
+\begin{verbatim}
+gmake -f Makefile.gi ginstall
+\end{verbatim}
+
+
\makesubsection{windows}{Specific Notes for Microsoft Windows}
\ind{install!windows}
@@ -729,7 +754,10 @@ This is a detailed description of each option allowed by the listening modules:
is also needed in the \Jabber{} client. Remark also that HTTP Polling can be
interesting to host a web-based \Jabber{} client such as
\footahref{http://jwchat.sourceforge.net/}{JWChat}.
- \titem{inet6} \ind{options!inet6}\ind{IPv6}Set up the socket for IPv6.
+ \titem{inet6} \ind{options!inet6}\ind{IPv6}Set up the socket for IPv6 instead of IPv4.
+ Note: this option is not required for S2S outgoing connections,
+ because when ejabberd attempts to establish a S2S outgoing connection
+ it first tries IPv4, and if that fails it attempts with IPv6.
\titem{\{ip, IPAddress\}} \ind{options!ip}This option specifies which network
interface to listen for. For example \verb|{ip, {192, 168, 1, 1}}|.
\titem{\{max\_stanza\_size, Size\}}
@@ -2710,9 +2738,9 @@ Features:
\begin{itemize}
\item Chatroom details are added on top of each page: room title, JID,
author, subject and configuration.
-\item \ind{protocols!RFC 4622: Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP)}
- Room title and JID are links to join the chatroom (using
- \footahref{http://www.ietf.org/rfc/rfc4622.txt}{XMPP URIs}).
+\item \ind{protocols!RFC 5122: Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP)}
+ The room JID in the generated HTML is a link to join the chatroom (using
+ \footahref{http://www.xmpp.org/rfcs/rfc5122.html}{XMPP URI}).
\item Subject and chatroom configuration changes are tracked and displayed.
\item Joins, leaves, nick changes, kicks, bans and `/me' are tracked and
displayed, including the reason if available.
@@ -3008,6 +3036,7 @@ Options:
\titem{welcome\_message} \ind{options!welcomem}Set a welcome message that
is sent to each newly registered account. The first string is the subject, and
the second string is the message body.
+ In the body you can set a newline with the characters: \term{\~\ n}.
\titem{registration\_watchers} \ind{options!rwatchers}This option defines a
list of JIDs which will be notified each time a new account is registered.
\iqdiscitem{In-Band Registration (\ns{jabber:iq:register})}
@@ -3066,7 +3095,7 @@ Also define a registration timeout of one hour:
...
{mod_register,
[
- {welcome_message, {"Welcome!", "Welcome to this Jabber server. Check http://www.jabber.org"}},
+ {welcome_message, {"Welcome!", "Hi.~nWelcome to this Jabber server.~n Check http://www.jabber.org~n~nBye"}},
{registration_watchers, ["admin1@example.org", "boss@example.net"]}
]},
...
@@ -3781,7 +3810,7 @@ an account with proper privileges.
\ejabberd{} uses the distributed Mnesia database.
Being distributed, Mnesia enforces consistency of its file,
-so it stores the name of the Erlang node in it.
+so it stores the name of the Erlang node in it (see section \ref{nodename}).
The name of an Erlang node includes the hostname of the computer.
So, the name of the Erlang node changes
if you change the name of the machine in which \ejabberd{} runs,
@@ -3861,8 +3890,9 @@ erl ... -kernel inet_dist_listen_min 4370 inet_dist_listen_max 4375
\makesection{cookie}{Erlang Cookie}
The Erlang cookie is a string with numbers and letters.
-An Erlang node reads the cookie at startup from the command-line parameter \term{-setcookie}
-or from a cookie file.
+An Erlang node reads the cookie at startup from the command-line parameter \term{-setcookie}.
+If not indicated, the cookie is read from the cookie file \term{\$HOME/.erlang.cookie}.
+If this file does not exist, it is created immediately with a random cookie.
Two Erlang nodes communicate only if they have the same cookie.
Setting a cookie on the Erlang node allows you to structure your Erlang network
and define which nodes are allowed to connect to which.
@@ -3894,6 +3924,32 @@ using a modified version of Erlang \term{epmd}.
The recommended way to secure the Erlang node is to block the port 4369.
+\makesection{secure-files}{Securing sensible files}
+
+\ejabberd{} stores sensible data in the file system either in plain text or binary files.
+The file system permissions should be set to only allow the proper user to read,
+write and execute those files and directories.
+
+\begin{description}
+ \titem{ejabberd configuration file: /etc/ejabberd/ejabberd.cfg}
+ Contains the JID of administrators
+ and passwords of external components.
+ The backup files probably contain also this information,
+ so it is preferable to secure the whole \term{/etc/ejabberd/} directory.
+ \titem{ejabberd service log: /var/log/ejabberd/ejabberd.log}
+ Contains IP addresses of clients.
+ If the loglevel is set to 5, it contains whole conversations and passwords.
+ If a logrotate system is used, there may be several log files with similar information,
+ so it is preferable to secure the whole \term{/var/log/ejabberd/} directory.
+ \titem{Mnesia database spool files: /var/lib/ejabberd/db/*}
+ The files store binary data, but some parts are still readable.
+ The files are generated by Mnesia and their permissions cannot be set directly,
+ so it is preferable to secure the whole \term{/var/lib/ejabberd/db/} directory.
+ \titem{Erlang cookie file: /var/lib/ejabberd/.erlang.cookie}
+ See section \ref{cookie}.
+\end{description}
+
+
\makechapter{clustering}{Clustering}
\ind{clustering}
diff --git a/src/Makefile.in b/src/Makefile.in
index 57bb56333..607af353e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -60,6 +60,7 @@ DESTDIR =
EJABBERDDIR = $(DESTDIR)@localstatedir@/lib/ejabberd
BEAMDIR = $(EJABBERDDIR)/ebin
+SPOOLDIR = $(EJABBERDDIR)/db
PRIVDIR = $(EJABBERDDIR)/priv
SODIR = $(PRIVDIR)/lib
PBINDIR = $(PRIVDIR)/bin
@@ -116,20 +117,21 @@ install: all
install -m 644 *.beam $(BEAMDIR)
rm -f $(BEAMDIR)/configure.beam
install -m 644 *.app $(BEAMDIR)
+ install -d -m 750 $(SPOOLDIR)
install -d $(SODIR)
install -d $(PBINDIR)
install -m 644 *.so $(SODIR)
$(INSTALL_EPAM)
install -d $(MSGSDIR)
install -m 644 msgs/*.msg $(MSGSDIR)
- install -d $(ETCDIR)
+ install -d -m 750 $(ETCDIR)
[ -f $(ETCDIR)/ejabberd.cfg ] && install -b -m 644 ejabberd.cfg.example $(ETCDIR)/ejabberd.cfg-new || install -b -m 644 ejabberd.cfg.example $(ETCDIR)/ejabberd.cfg
sed -e "s*@rootdir@*@prefix@*" ejabberdctl.template > ejabberdctl.example
[ -f $(ETCDIR)/ejabberdctl.cfg ] && install -b -m 644 ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new || install -b -m 644 ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg
install -b -m 644 inetrc $(ETCDIR)/inetrc
install -d $(SBINDIR)
install -m 755 ejabberdctl.example $(SBINDIR)/ejabberdctl
- install -d $(LOGDIR)
+ install -d -m 750 $(LOGDIR)
uninstall: uninstall-binary
diff --git a/src/configure b/src/configure
index 573a17ee7..034868416 100755
--- a/src/configure
+++ b/src/configure
@@ -4765,6 +4765,9 @@ _ACEOF
fi
+# Check Erlang headers are installed
+#AC_CHECK_HEADER(erl_driver.h,,[AC_MSG_ERROR([cannot find Erlang header files])])
+
# Change default prefix
diff --git a/src/configure.ac b/src/configure.ac
index a3e8894e9..254b16b06 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -26,6 +26,9 @@ AM_WITH_PAM
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
+# Check Erlang headers are installed
+#AC_CHECK_HEADER(erl_driver.h,,[AC_MSG_ERROR([cannot find Erlang header files])])
+
# Change default prefix
AC_PREFIX_DEFAULT(/)
diff --git a/src/ejabberd.cfg.example b/src/ejabberd.cfg.example
index e1d63ed9e..eb43bb3ca 100644
--- a/src/ejabberd.cfg.example
+++ b/src/ejabberd.cfg.example
@@ -459,7 +459,7 @@
%% a message with this subject and body.
%%
{welcome_message, {"Welcome!",
- "Welcome to this Jabber server."}},
+ "Hi.~nWelcome to this Jabber server."}},
%%
%% When a user registers, send a notification to
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl
index dae88f07a..82fd029ce 100644
--- a/src/ejabberd_c2s.erl
+++ b/src/ejabberd_c2s.erl
@@ -1223,6 +1223,9 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData)
when Monitor == StateData#state.socket_monitor ->
{stop, normal, StateData};
+handle_info({peername, IP}, StateName, StateData) ->
+ ejabberd_sm:set_session_ip(StateData#state.sid, IP),
+ fsm_next_state(StateName, StateData#state{ip = IP});
handle_info(Info, StateName, StateData) ->
?ERROR_MSG("Unexpected info: ~p", [Info]),
fsm_next_state(StateName, StateData).
diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl
index 7a9cade1f..c18cfe6de 100644
--- a/src/ejabberd_config.erl
+++ b/src/ejabberd_config.erl
@@ -96,8 +96,10 @@ get_plain_terms_file(File1) ->
{ok, Terms} ->
include_config_files(Terms);
{error, Reason} ->
- ?ERROR_MSG("Can't load config file ~p: ~p", [File, Reason]),
- exit(File ++ ": " ++ file:format_error(Reason))
+ ExitText = lists:flatten(File ++ ": around line "
+ ++ file:format_error(Reason)),
+ ?ERROR_MSG("Problem loading ejabberd config file:~n~s", [ExitText]),
+ exit(ExitText)
end.
%% @doc Convert configuration filename to absolute path.
diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl
index 7cb36141d..9a84b592e 100644
--- a/src/ejabberd_ctl.erl
+++ b/src/ejabberd_ctl.erl
@@ -30,6 +30,7 @@
-export([start/0,
init/0,
process/1,
+ dump_to_textfile/1,
register_commands/3,
register_commands/4,
unregister_commands/3,
diff --git a/src/ejabberd_local.erl b/src/ejabberd_local.erl
index 76719bbb8..c3786ca53 100644
--- a/src/ejabberd_local.erl
+++ b/src/ejabberd_local.erl
@@ -37,6 +37,7 @@
register_iq_handler/5,
register_iq_response_handler/4,
unregister_iq_handler/2,
+ unregister_iq_response_handler/2,
refresh_iq_handlers/0,
bounce_resource_packet/3
]).
@@ -168,6 +169,9 @@ register_iq_handler(Host, XMLNS, Module, Fun) ->
register_iq_handler(Host, XMLNS, Module, Fun, Opts) ->
ejabberd_local ! {register_iq_handler, Host, XMLNS, Module, Fun, Opts}.
+unregister_iq_response_handler(Host, ID) ->
+ ejabberd_local ! {unregister_iq_response_handler, Host, ID}.
+
unregister_iq_handler(Host, XMLNS) ->
ejabberd_local ! {unregister_iq_handler, Host, XMLNS}.
@@ -254,6 +258,9 @@ handle_info({route, From, To, Packet}, State) ->
handle_info({register_iq_response_handler, _Host, ID, Module, Function}, State) ->
mnesia:dirty_write(#iq_response{id = ID, module = Module, function = Function}),
{noreply, State};
+handle_info({unregister_iq_response_handler, _Host, ID}, State) ->
+ mnesia:dirty_delete({iq_response, ID}),
+ {noreply, State};
handle_info({register_iq_handler, Host, XMLNS, Module, Function}, State) ->
ets:insert(?IQTABLE, {{XMLNS, Host}, Module, Function}),
catch mod_disco:register_feature(Host, XMLNS),
diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl
index 5fdad76af..3b6c80439 100644
--- a/src/ejabberd_receiver.erl
+++ b/src/ejabberd_receiver.erl
@@ -268,7 +268,8 @@ code_change(_OldVsn, State, _Extra) ->
%%--------------------------------------------------------------------
activate_socket(#state{socket = Socket,
- sock_mod = SockMod}) ->
+ sock_mod = SockMod,
+ c2s_pid = C2SPid}) ->
PeerName =
case SockMod of
gen_tcp ->
@@ -281,7 +282,8 @@ activate_socket(#state{socket = Socket,
case PeerName of
{error, _Reason} ->
self() ! {tcp_closed, Socket};
- {ok, _} ->
+ {ok, IP} ->
+ C2SPid ! {peername, IP},
ok
end.
diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl
index 9300958d5..ccf679386 100644
--- a/src/ejabberd_sm.erl
+++ b/src/ejabberd_sm.erl
@@ -49,7 +49,8 @@
ctl_process/2,
get_session_pid/3,
get_user_info/3,
- get_user_ip/3
+ get_user_ip/3,
+ set_session_ip/2
]).
%% gen_server callbacks
@@ -186,6 +187,18 @@ get_user_info(User, Server, Resource) ->
[{node, Node}, {conn, Conn}, {ip, IP}]
end.
+set_session_ip(SID, IP) ->
+ case mnesia:dirty_read(session, SID) of
+ [#session{info = Info} = Session] ->
+ NewInfo = case lists:keymember(ip, 1, Info) of
+ true -> lists:keyreplace(ip, 1, Info, {ip, IP});
+ false -> [{ip, IP}|Info]
+ end,
+ mnesia:dirty_write(Session#session{info = NewInfo});
+ _ ->
+ ok
+ end.
+
set_presence(SID, User, Server, Resource, Priority, Presence, Info) ->
set_session(SID, User, Server, Resource, Priority, Info),
% XXX OLD FORMAT: Presence.
diff --git a/src/mod_caps.erl b/src/mod_caps.erl
index 2be0fac66..3240aa6e2 100644
--- a/src/mod_caps.erl
+++ b/src/mod_caps.erl
@@ -53,6 +53,7 @@
-define(PROCNAME, ejabberd_mod_caps).
-define(DICT, dict).
+-define(CAPS_QUERY_TIMEOUT, 60000). % 1mn without answer, consider client never answer
-record(caps, {node, version, exts}).
-record(caps_features, {node_pair, features}).
@@ -220,6 +221,7 @@ handle_cast({note_caps, From,
ejabberd_local:register_iq_response_handler
(Host, ID, ?MODULE, handle_disco_response),
ejabberd_router:route(jlib:make_jid("", Host, ""), From, Stanza),
+ timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}),
?DICT:store(ID, {Node, SubNode}, Dict)
end, Requests, Missing),
{noreply, State#state{disco_requests = NewRequests}};
@@ -274,6 +276,16 @@ handle_cast({disco_response, From, _To,
end,
NewRequests = ?DICT:erase(ID, Requests),
{noreply, State#state{disco_requests = NewRequests}};
+handle_cast({disco_timeout, ID}, #state{host = Host, disco_requests = Requests} = State) ->
+ %% do not wait a response anymore for this IQ, client certainly will never answer
+ NewRequests = case ?DICT:is_key(ID, Requests) of
+ true ->
+ ejabberd_local:unregister_iq_response_handler(Host, ID),
+ ?DICT:erase(ID, Requests);
+ false ->
+ Requests
+ end,
+ {noreply, State#state{disco_requests = NewRequests}};
handle_cast(visit_feature_queries, #state{feature_queries = FeatureQueries} = State) ->
Timestamp = timestamp(),
NewFeatureQueries =
diff --git a/src/mod_configure.erl b/src/mod_configure.erl
index 625e380cd..e012794dd 100644
--- a/src/mod_configure.erl
+++ b/src/mod_configure.erl
@@ -1416,7 +1416,7 @@ set_form(_From, _Host, ["running nodes", ENode, "backup", "textfile"], _Lang, XD
false ->
{error, ?ERR_BAD_REQUEST};
{value, {_, [String]}} ->
- case rpc:call(Node, mnesia, dump_to_textfile, [String]) of
+ case rpc:call(Node, ejabberd_ctl, dump_to_textfile, [String]) of
{badrpc, _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
{error, _Reason} ->
diff --git a/src/mod_muc/mod_muc_log.erl b/src/mod_muc/mod_muc_log.erl
index fce9c15b2..9ab8d4ce2 100644
--- a/src/mod_muc/mod_muc_log.erl
+++ b/src/mod_muc/mod_muc_log.erl
@@ -120,9 +120,11 @@ init([Host, Opts]) ->
NoFollow = gen_mod:get_opt(spam_prevention, Opts, true),
Lang = case ejabberd_config:get_local_option({language, Host}) of
undefined ->
- "";
- L ->
- L
+ case ejabberd_config:get_global_option(language) of
+ undefined -> "en";
+ L -> L
+ end;
+ L -> L
end,
{ok, #state{host = Host,
out_dir = OutDir,
@@ -286,9 +288,10 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
top_link = TopLink} = State,
Room = get_room_info(RoomJID, Opts),
+ Now = now(),
TimeStamp = case Timezone of
- local -> calendar:now_to_local_time(now());
- universal -> calendar:now_to_universal_time(now())
+ local -> calendar:now_to_local_time(Now);
+ universal -> calendar:now_to_universal_time(Now)
end,
{Fd, Fn, _Dir} = build_filename_string(TimeStamp, OutDir, Room#room.jid, DirType),
{Date, Time} = TimeStamp,
@@ -382,10 +385,12 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
{Hour, Minute, Second} = Time,
STime = lists:flatten(
io_lib:format("~2..0w:~2..0w:~2..0w", [Hour, Minute, Second])),
+ {_, _, Microsecs} = Now,
+ STimeUnique = io_lib:format("~s.~w", [STime, Microsecs]),
% Write message
- file:write(F, io_lib:format("[~s] ~s~n",
- [STime, STime, STime, Text])),
+ file:write(F, io_lib:format("[~s] ~s~n",
+ [STimeUnique, STimeUnique, STimeUnique, STime, Text])),
% Close file
file:close(F),
diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl
index e858d680f..64957a70a 100644
--- a/src/mod_muc/mod_muc_room.erl
+++ b/src/mod_muc/mod_muc_room.erl
@@ -59,6 +59,7 @@
-record(lqueue, {queue, len, max}).
-record(config, {title = "",
+ description = "",
allow_change_subj = true,
allow_query_users = true,
allow_private_messages = true,
@@ -2614,7 +2615,10 @@ get_config(Lang, StateData, From) ->
[{xmlcdata, "http://jabber.org/protocol/muc#roomconfig"}]}]},
?STRINGXFIELD("Room title",
"muc#roomconfig_roomname",
- Config#config.title)
+ Config#config.title),
+ ?STRINGXFIELD("Room description",
+ "muc#roomconfig_roomdesc",
+ Config#config.description)
] ++
case acl:match_rule(StateData#state.server_host, AccessPersistent, From) of
allow ->
@@ -2761,6 +2765,8 @@ set_xoption([], Config) ->
Config;
set_xoption([{"muc#roomconfig_roomname", [Val]} | Opts], Config) ->
?SET_STRING_XOPT(title, Val);
+set_xoption([{"muc#roomconfig_roomdesc", [Val]} | Opts], Config) ->
+ ?SET_STRING_XOPT(description, Val);
set_xoption([{"muc#roomconfig_changesubject", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(allow_change_subj, Val);
set_xoption([{"allow_query_users", [Val]} | Opts], Config) ->
@@ -2856,6 +2862,7 @@ set_opts([], StateData) ->
set_opts([{Opt, Val} | Opts], StateData) ->
NSD = case Opt of
title -> StateData#state{config = (StateData#state.config)#config{title = Val}};
+ description -> StateData#state{config = (StateData#state.config)#config{description = Val}};
allow_change_subj -> StateData#state{config = (StateData#state.config)#config{allow_change_subj = Val}};
allow_query_users -> StateData#state{config = (StateData#state.config)#config{allow_query_users = Val}};
allow_private_messages -> StateData#state{config = (StateData#state.config)#config{allow_private_messages = Val}};
@@ -2895,6 +2902,7 @@ make_opts(StateData) ->
Config = StateData#state.config,
[
?MAKE_CONFIG_OPT(title),
+ ?MAKE_CONFIG_OPT(description),
?MAKE_CONFIG_OPT(allow_change_subj),
?MAKE_CONFIG_OPT(allow_query_users),
?MAKE_CONFIG_OPT(allow_private_messages),
@@ -2991,9 +2999,12 @@ process_iq_disco_info(_From, get, Lang, StateData) ->
iq_disco_info_extras(Lang, StateData) ->
Len = length(?DICT:to_list(StateData#state.users)),
+ RoomDescription = (StateData#state.config)#config.description,
[{xmlelement, "x", [{"xmlns", ?NS_XDATA}, {"type", "result"}],
[?RFIELDT("hidden", "FORM_TYPE",
"http://jabber.org/protocol/muc#roominfo"),
+ ?RFIELD("Room description", "muc#roominfo_description",
+ RoomDescription),
?RFIELD("Number of occupants", "muc#roominfo_occupants",
integer_to_list(Len))
]}].
diff --git a/src/mod_privacy_odbc.erl b/src/mod_privacy_odbc.erl
index 8db812d0b..b4e267d28 100644
--- a/src/mod_privacy_odbc.erl
+++ b/src/mod_privacy_odbc.erl
@@ -16,7 +16,7 @@
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
-%%%
+%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
@@ -698,11 +698,11 @@ raw_to_item({SType, SValue, SAction, SOrder, SMatchAll, SMatchIQ,
"d" -> deny
end,
Order = list_to_integer(SOrder),
- MatchAll = SMatchAll == "t",
- MatchIQ = SMatchIQ == "t",
- MatchMessage = SMatchMessage == "t",
- MatchPresenceIn = SMatchPresenceIn == "t",
- MatchPresenceOut = SMatchPresenceOut == "t",
+ MatchAll = SMatchAll == "1" orelse SMatchAll == "t",
+ MatchIQ = SMatchIQ == "1" orelse SMatchIQ == "t" ,
+ MatchMessage = SMatchMessage == "1" orelse SMatchMessage == "t",
+ MatchPresenceIn = SMatchPresenceIn == "1" orelse SMatchPresenceIn == "t",
+ MatchPresenceOut = SMatchPresenceOut == "1" orelse SMatchPresenceOut == "t",
#listitem{type = Type,
value = Value,
action = Action,
@@ -750,11 +750,11 @@ item_to_raw(#listitem{type = Type,
deny -> "d"
end,
SOrder = integer_to_list(Order),
- SMatchAll = if MatchAll -> "t"; true -> "f" end,
- SMatchIQ = if MatchIQ -> "t"; true -> "f" end,
- SMatchMessage = if MatchMessage -> "t"; true -> "f" end,
- SMatchPresenceIn = if MatchPresenceIn -> "t"; true -> "f" end,
- SMatchPresenceOut = if MatchPresenceOut -> "t"; true -> "f" end,
+ SMatchAll = if MatchAll -> "1"; true -> "0" end,
+ SMatchIQ = if MatchIQ -> "1"; true -> "0" end,
+ SMatchMessage = if MatchMessage -> "1"; true -> "0" end,
+ SMatchPresenceIn = if MatchPresenceIn -> "1"; true -> "0" end,
+ SMatchPresenceOut = if MatchPresenceOut -> "1"; true -> "0" end,
["'", SType, "', "
"'", SValue, "', "
"'", SAction, "', "
@@ -871,6 +871,3 @@ sql_set_privacy_list(ID, RItems) ->
") "
"values ('", ID, "', ", Items, ");"])
end, RItems).
-
-
-
diff --git a/src/mod_pubsub/gen_pubsub_node.erl b/src/mod_pubsub/gen_pubsub_node.erl
index 195ed3934..bbbb5c409 100644
--- a/src/mod_pubsub/gen_pubsub_node.erl
+++ b/src/mod_pubsub/gen_pubsub_node.erl
@@ -62,7 +62,9 @@ behaviour_info(callbacks) ->
{get_states, 2},
{get_state, 3},
{set_state, 1},
+ {get_items, 7},
{get_items, 2},
+ {get_item, 8},
{get_item, 3},
{set_item, 1},
{get_item_name, 3}
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl
index cb8ce997d..e83e0170f 100644
--- a/src/mod_pubsub/mod_pubsub.erl
+++ b/src/mod_pubsub/mod_pubsub.erl
@@ -30,16 +30,17 @@
%%%
%%% @reference See XEP-0060: Pubsub for
%%% the latest version of the PubSub specification.
-%%% This module uses version 1.10 of the specification as a base.
+%%% This module uses version 1.11 of the specification as a base.
%%% Most of the specification is implemented.
-%%% Code is derivated from the original pubsub v1.7, functions concerning config may be rewritten.
-%%% Code also inspired from the original PEP patch by Magnus Henoch (mangeATfreemail.hu)
+%%% Functions concerning configuration should be rewritten.
+%%% Code is derivated from the original pubsub v1.7, by Alexey Shchepin The permission are not checked in this function.
Triggers item deletion.
%%Default plugin: The user performing the deletion must be the node owner -%% or a node publisher e item publisher.
+%% or a publisher. delete_item(Host, Node, Publisher, ItemId) -> PublisherKey = jlib:jid_tolower(jlib:jid_remove_resource(Publisher)), State = case get_state(Host, Node, PublisherKey) of @@ -542,17 +539,16 @@ delete_item(Host, Node, Publisher, ItemId) -> purge_node(Host, Node, Owner) -> OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), case get_state(Host, Node, OwnerKey) of - {error, ?ERR_ITEM_NOT_FOUND} -> - %% This should not append (case node does not exists) - {error, ?ERR_ITEM_NOT_FOUND}; {result, #pubsub_state{items = Items, affiliation = owner}} -> lists:foreach(fun(ItemId) -> mnesia:delete({pubsub_item, {ItemId, {Host, Node}}}) end, Items), {result, {default, broadcast}}; + {result, _} -> + %% Entity is not owner + {error, ?ERR_FORBIDDEN}; _ -> - %% Entity is not an owner - {error, ?ERR_FORBIDDEN} + {error, ?ERR_ITEM_NOT_FOUND} end. %% @spec (Host, JID) -> [{Node,Affiliation}] @@ -588,7 +584,7 @@ get_affiliation(Host, Node, Owner) -> OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), Affiliation = case get_state(Host, Node, OwnerKey) of {result, #pubsub_state{affiliation = A}} -> A; - _ -> unknown + _ -> none end, {result, Affiliation}. @@ -638,7 +634,7 @@ get_subscription(Host, Node, Owner) -> OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), Subscription = case get_state(Host, Node, OwnerKey) of {result, #pubsub_state{subscription = S}} -> S; - _ -> unknown + _ -> none end, {result, Subscription}. @@ -713,6 +709,44 @@ get_items(Host, Node) -> Items = mnesia:match_object( #pubsub_item{itemid = {'_', {Host, Node}}, _ = '_'}), {result, Items}. +get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) -> + {Affiliation, Subscription} = + case get_state(Host, Node, jlib:jid_tolower(jlib:jid_remove_resource(JID))) of + {result, #pubsub_state{affiliation = A, subscription = S}} -> {A, S}; + _ -> {none, none} + end, + Subscribed = not ((Subscription == none) or (Subscription == pending)), + if + %%SubID == "", ?? -> + %% Entity has multiple subscriptions to the node but does not specify a subscription ID + %{error, ?ERR_EXTENDED(?ERR_BAD_REQUEST, "subid-required")}; + %%InvalidSubID -> + %% Entity is subscribed but specifies an invalid subscription ID + %{error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; + Affiliation == outcast -> + %% Requesting entity is blocked + {error, ?ERR_FORBIDDEN}; + (AccessModel == open) and (not Subscribed) -> + %% Entity is not subscribed + {error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "not-subscribed")}; + (AccessModel == presence) and (not PresenceSubscription) -> + %% Entity is not authorized to create a subscription (presence subscription required) + {error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "presence-subscription-required")}; + (AccessModel == roster) and (not RosterGroup) -> + %% Entity is not authorized to create a subscription (not in roster group) + {error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "not-in-roster-group")}; + (AccessModel == whitelist) -> % TODO: to be done + %% Node has whitelist access model + {error, ?ERR_EXTENDED(?ERR_NOT_ALLOWED, "closed-node")}; + (AccessModel == authorize) -> % TODO: to be done + %% Node has authorize access model + {error, ?ERR_FORBIDDEN}; + %%MustPay -> + %% % Payment is required for a subscription + %% {error, ?ERR_PAYMENT_REQUIRED}; + true -> + get_items(Host, Node) + end. %% @spec (Host, Node, ItemId) -> [Item] | [] %% Host = mod_pubsub:host() @@ -727,6 +761,44 @@ get_item(Host, Node, ItemId) -> _ -> {error, ?ERR_ITEM_NOT_FOUND} end. +get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) -> + {Affiliation, Subscription} = + case get_state(Host, Node, jlib:jid_tolower(jlib:jid_remove_resource(JID))) of + {result, #pubsub_state{affiliation = A, subscription = S}} -> {A, S}; + _ -> {none, none} + end, + Subscribed = not ((Subscription == none) or (Subscription == pending)), + if + %%SubID == "", ?? -> + %% Entity has multiple subscriptions to the node but does not specify a subscription ID + %{error, ?ERR_EXTENDED(?ERR_BAD_REQUEST, "subid-required")}; + %%InvalidSubID -> + %% Entity is subscribed but specifies an invalid subscription ID + %{error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; + Affiliation == outcast -> + %% Requesting entity is blocked + {error, ?ERR_FORBIDDEN}; + (AccessModel == open) and (not Subscribed) -> + %% Entity is not subscribed + {error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "not-subscribed")}; + (AccessModel == presence) and (not PresenceSubscription) -> + %% Entity is not authorized to create a subscription (presence subscription required) + {error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "presence-subscription-required")}; + (AccessModel == roster) and (not RosterGroup) -> + %% Entity is not authorized to create a subscription (not in roster group) + {error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "not-in-roster-group")}; + (AccessModel == whitelist) -> % TODO: to be done + %% Node has whitelist access model + {error, ?ERR_EXTENDED(?ERR_NOT_ALLOWED, "closed-node")}; + (AccessModel == authorize) -> % TODO: to be done + %% Node has authorize access model + {error, ?ERR_FORBIDDEN}; + %%MustPay -> + %% % Payment is required for a subscription + %% {error, ?ERR_PAYMENT_REQUIRED}; + true -> + get_item(Host, Node, ItemId) + end. %% @spec (Item) -> ok | {error, Reason::stanzaError()} %% Item = mod_pubsub:pubsubItems() diff --git a/src/mod_pubsub/node_dispatch.erl b/src/mod_pubsub/node_dispatch.erl index 3b4418c3e..0532826d2 100644 --- a/src/mod_pubsub/node_dispatch.erl +++ b/src/mod_pubsub/node_dispatch.erl @@ -60,7 +60,9 @@ get_states/2, get_state/3, set_state/1, + get_items/7, get_items/2, + get_item/8, get_item/3, set_item/1, get_item_name/3 @@ -94,7 +96,6 @@ features() -> ["create-nodes", "delete-nodes", "instant-nodes", - "item-ids", "outcast-affiliation", "persistent-items", "publish", @@ -175,9 +176,15 @@ set_state(State) -> get_items(Host, Node) -> node_default:get_items(Host, Node). +get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + get_item(Host, Node, ItemId) -> node_default:get_item(Host, Node, ItemId). +get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + set_item(Item) -> node_default:set_item(Item). diff --git a/src/mod_pubsub/node_pep.erl b/src/mod_pubsub/node_pep.erl index 97bf1b2fa..2c648148d 100644 --- a/src/mod_pubsub/node_pep.erl +++ b/src/mod_pubsub/node_pep.erl @@ -29,6 +29,7 @@ -module(node_pep). -author('christophe.romain@process-one.net'). +-include("ejabberd.hrl"). -include("pubsub.hrl"). -include("jlib.hrl"). @@ -57,7 +58,9 @@ get_states/2, get_state/3, set_state/1, + get_items/7, get_items/2, + get_item/8, get_item/3, set_item/1, get_item_name/3 @@ -65,6 +68,7 @@ init(Host, ServerHost, Opts) -> node_default:init(Host, ServerHost, Opts), + complain_if_modcaps_disabled(ServerHost), ok. terminate(Host, ServerHost) -> @@ -94,7 +98,6 @@ features() -> "auto-subscribe", %* "delete-nodes", %* "filtered-notifications", %* - "item-ids", "modify-affiliations", "outcast-affiliation", "persistent-items", @@ -183,7 +186,7 @@ get_node_subscriptions(_Host, _Node) -> {result, []}. get_subscription(_Host, _Node, _Owner) -> - {result, unknown}. + {result, none}. set_subscription(_Host, _Node, _Owner, _Subscription) -> ok. @@ -200,11 +203,39 @@ set_state(State) -> get_items(Host, Node) -> node_default:get_items(Host, Node). +get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + get_item(Host, Node, ItemId) -> node_default:get_item(Host, Node, ItemId). +get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + set_item(Item) -> node_default:set_item(Item). get_item_name(Host, Node, Id) -> node_default:get_item_name(Host, Node, Id). + + +%%% +%%% Internal +%%% + +%% @doc Check mod_caps is enabled, otherwise show warning. +%% The PEP plugin for mod_pubsub requires mod_caps to be enabled in the host. +%% Check that the mod_caps module is enabled in that Jabber Host +%% If not, show a warning message in the ejabberd log file. +complain_if_modcaps_disabled(ServerHost) -> + Modules = ejabberd_config:get_local_option({modules, ServerHost}), + ModCaps = [mod_caps_enabled || {mod_caps, _Opts} <- Modules], + case ModCaps of + [] -> + ?WARNING_MSG("The PEP plugin is enabled in mod_pubsub of host ~p. " + "This plugin requires mod_caps to be enabled, " + "but it isn't.", [ServerHost]); + _ -> + ok + end. + diff --git a/src/mod_pubsub/node_private.erl b/src/mod_pubsub/node_private.erl index 35f63c925..00e952392 100644 --- a/src/mod_pubsub/node_private.erl +++ b/src/mod_pubsub/node_private.erl @@ -62,7 +62,9 @@ get_states/2, get_state/3, set_state/1, + get_items/7, get_items/2, + get_item/8, get_item/3, set_item/1, get_item_name/3 @@ -96,7 +98,6 @@ features() -> ["create-nodes", "delete-nodes", "instant-nodes", - "item-ids", "outcast-affiliation", "persistent-items", "publish", @@ -175,9 +176,15 @@ set_state(State) -> get_items(Host, Node) -> node_default:get_items(Host, Node). +get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + get_item(Host, Node, ItemId) -> node_default:get_item(Host, Node, ItemId). +get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + set_item(Item) -> node_default:set_item(Item). diff --git a/src/mod_pubsub/node_public.erl b/src/mod_pubsub/node_public.erl index 1586abe86..ab4107a76 100644 --- a/src/mod_pubsub/node_public.erl +++ b/src/mod_pubsub/node_public.erl @@ -62,7 +62,9 @@ get_states/2, get_state/3, set_state/1, + get_items/7, get_items/2, + get_item/8, get_item/3, set_item/1, get_item_name/3 @@ -96,7 +98,6 @@ features() -> ["create-nodes", "delete-nodes", "instant-nodes", - "item-ids", "outcast-affiliation", "persistent-items", "publish", @@ -172,9 +173,15 @@ set_state(State) -> get_items(Host, Node) -> node_default:get_items(Host, Node). +get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + get_item(Host, Node, ItemId) -> node_default:get_item(Host, Node, ItemId). +get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> + node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId). + set_item(Item) -> node_default:set_item(Item). diff --git a/src/mod_pubsub/node_zoo.erl b/src/mod_pubsub/node_zoo.erl new file mode 100644 index 000000000..45e601ed7 --- /dev/null +++ b/src/mod_pubsub/node_zoo.erl @@ -0,0 +1,181 @@ +%%% ==================================================================== +%%% ``The contents of this file are subject to the Erlang Public License, +%%% Version 1.1, (the "License"); you may not use this file except in +%%% compliance with the License. You should have received a copy of the +%%% Erlang Public License along with this software. If not, it can be +%%% retrieved via the world wide web at http://www.erlang.org/. +%%% +%%% Software distributed under the License is distributed on an "AS IS" +%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%%% the License for the specific language governing rights and limitations +%%% under the License. +%%% +%%% The Initial Developer of the Original Code is Process-one. +%%% Portions created by Process-one are Copyright 2006-2008, Process-one +%%% All Rights Reserved.'' +%%% This software is copyright 2006-2008, Process-one. +%%% +%%% @copyright 2006-2008 Process-one +%%% @author Christophe romain