-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
618 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
# *systemd* socket configuration support | ||
# *systemd* integration | ||
|
||
For some environments, it might be advantageous to use *xcauth* over a network socket. Here is a pair of sample *systemd* configuration files, accepting network connection to `localhost:23664`. | ||
`xcauth` can also be started from *systemd*. Three modes are supported: | ||
|
||
## Installation (as root) | ||
1. Starting in *inetd* compatibility mode: For each connection to that socket, a new `xcauth` process is started. `xcauth` reads from stdin/stdout (DEPRECATED). | ||
1. Using *systemd* [socket activation](http://0pointer.net/blog/projects/socket-activation.html), single protocol per configuration file: On the first connection, the single `xcauth` process is started for this protocol/port. For each incoming connection, only a thread is spawned. This is more efficient if a new connection is opened for every request (common for *saslauthd* and *postfix* modes, but depends on the requesting application). | ||
1. Using *systemd* socket activation, multiple protocols per configuration file: Similar to the one above, but only a single `xcauth` process is ever started. All protocols are determined by information passed by *systemd* on process start (RECOMMENDED). | ||
|
||
The following ports are used by default: | ||
- TCP port 23662: *ejabberd* protocol support | ||
- TCP port 23663: *prosody* protocol support | ||
- TCP port 23664: *prosody* or *ejabberd* protocol support, depending on configuration in `/etc/xcauth.conf` (DEPRECATED) | ||
- TCP port 23665: *postfix* protocol support | ||
- `/var/run/saslauthd/mux` (stream-based Unix domain socket): *saslauthd* protocol support | ||
|
||
## XMPP authentication over *systemd* socket | ||
|
||
For some environments, it might be advantageous to use *xcauth* over a network socket. Here is a set of sample *systemd* configuration files, accepting the network connections described above. | ||
|
||
### Installation (as root) | ||
|
||
1. Perform the *xcauth* installation as explained in the [parent README](../README.md) or the [installation wiki](https://github.com/jsxc/xcauth/wiki). Especially install source into `/opt/xcauth` and put the configuration in `/etc/xcauth.conf`. | ||
1. Copy `[email protected]` and `xcauth.socket` to `/etc/systemd/system` (if no modifications to these files are needed, you may also symlink them manually or using `systemctl link`; beware that some versions of *systemd* have problems with symlinks ([systemd#3010](https://github.com/systemd/systemd/issues/3010)) | ||
1. Create the user `xcauth` and the directories: `sudo ../install.sh` | ||
1. Activate the service: `systemctl enable xcauth.socket` and `systemctl start xcauth.socket` | ||
1. Copy `xc*` to `/etc/systemd/system` (if no modifications to these files are needed, you may also symlink them manually or using `systemctl link`; beware that some versions of *systemd* have problems with symlinks ([systemd#3010](https://github.com/systemd/systemd/issues/3010)) | ||
1. Activate the service: | ||
```sh | ||
systemctl enable xcauth.service | ||
for i in xc*.socket; do | ||
systemctl start $i | ||
done | ||
systemctl start xcauth.service | ||
``` | ||
|
||
:warning: If you do not want to replace an existing *saslauthd* on your system, do not copy or start `xcsaslauth.socket`. | ||
|
||
## Testing | ||
### Testing | ||
|
||
If you have set `type=generic` (equivalent to `type=prosody`) in `/etc/xcauth.conf`, then the following should work (`$` indicates the command line prompt, `<` is data received and `>` data sent): | ||
Trye the following (`$` indicates the command line prompt, `<` is data received and `>` data sent): | ||
|
||
``` | ||
$ telnet localhost 23664 | ||
$ telnet localhost 23663 | ||
< Trying ::1... | ||
< Connected to localhost. | ||
< Escape character is '^]'. | ||
|
@@ -38,7 +62,7 @@ respective documentation for how to do this). Then, run the following | |
commands to have *xcauth.py* pose as *saslauthd*: | ||
|
||
1. Install *xcauth* as described above. | ||
1. Copy `xcsaslauth@.service` and `xcsaslauth.socket` to `/etc/systemd/system` (see above for symlink issues) | ||
1. Copy `xcsaslauth.service` and `xcsaslauth.socket` to `/etc/systemd/system` (see above for symlink issues) | ||
1. Disable "normal" *saslauthd*: `systemctl disable saslauthd` | ||
1. Enable *xcauth.py* in *saslauthd* mode: `systemctl enable xcsaslauth.socket` and `systemctl start xcsaslauth.socket` | ||
|
||
|
@@ -47,7 +71,7 @@ Note that the *xcsaslauth* service listens on the Unix domain socket | |
the software configuration files might only mention `/var/run/saslauthd`, | ||
the `/mux` suffix is added internally by the *SASL* library. | ||
|
||
## `postfix` mode (existance check) | ||
## `postfix` mode (existence check) | ||
|
||
When a *Postfix* mail server serves multiple realms (=domains), it | ||
needs some way to know whether a | ||
|
@@ -80,7 +104,7 @@ user's mailbox. | |
to `/etc/postfix/main.cf`. Integrate any existing assignment to | ||
`virtual_mailbox_maps`. | ||
1. Install *xcauth* as described above. | ||
1. Copy `xcpostfix@.service` and `xcpostfix.socket` to `/etc/systemd/system` (see above for symlink issues) | ||
1. Copy `xcpostfix.service` and `xcpostfix.socket` to `/etc/systemd/system` (see above for symlink issues) | ||
1. Enable *xcauth.py* in *postfix* mode: `systemctl enable xcpostfix.socket` and `systemctl start xcpostfix.socket` | ||
|
||
## Security considerations | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=XMPP to Nextcloud+JSXC authentication bridge | ||
|
||
[Service] | ||
ExecStart=/opt/xmpp-cloud-auth/xcauth.py | ||
User=xcauth | ||
Sockets=xcauth.socket xcejabberd.socket xcpostfix.socket xcprosody.socket xcsaslauth.socket | ||
# Should be doable in `xcsaslauth.socket` according to | ||
# https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ExecStartPre= | ||
# but doesn't for me in Ubuntu 18.04. So I moved it here. | ||
# | ||
# The downside of this setup: salsauth connection may not occur before | ||
# manual `systemctl start xcauth.service` or connection to one of the | ||
# other sockets. | ||
ExecStartPre=+/bin/chgrp sasl /var/run/saslauthd/ | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
[Unit] | ||
Description=XMPP to Nextcloud+JSXC authentication bridge | ||
PartOf=xcauth.service | ||
|
||
[Socket] | ||
ListenStream=[::1]:23664 | ||
ListenStream=127.0.0.1:23664 | ||
Accept=yes | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
Accept=false | ||
# Is not one of the recognized protocols, so this name will be ignored | ||
# (i.e., the protocol defaults to what is passed by "-t") | ||
FileDescriptorName=deprecated |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=XMPP to Nextcloud+JSXC authentication bridge for ejabberd | ||
|
||
[Socket] | ||
ListenStream=[::1]:23662 | ||
ListenStream=127.0.0.1:23662 | ||
Accept=false | ||
FileDescriptorName=ejabberd | ||
Service=xcauth.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
[Unit] | ||
Description=Postfix virtual mailbox to Nextcloud+JSXC bridge | ||
PartOf=xcpostfix.service | ||
|
||
[Socket] | ||
ListenStream=[::1]:23665 | ||
ListenStream=127.0.0.1:23665 | ||
Accept=yes | ||
Accept=yes | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
Accept=false | ||
FileDescriptorName=postfix | ||
Service=xcauth.service |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=XMPP to Nextcloud+JSXC authentication bridge for Prosody | ||
|
||
[Socket] | ||
ListenStream=[::1]:23663 | ||
ListenStream=127.0.0.1:23663 | ||
Accept=false | ||
FileDescriptorName=prosody | ||
Service=xcauth.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
[Unit] | ||
Description=SASL to Nextcloud+JSXC authentication bridge | ||
PartOf=xcsaslauth.service | ||
|
||
[Socket] | ||
ListenStream=/var/run/saslauthd/mux | ||
SocketUser=root | ||
SocketGroup=sasl | ||
SocketMode=660 | ||
DirectoryMode=710 | ||
Accept=yes | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
# Does not work for me yet, despite the documentation in | ||
# https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ExecStartPre= | ||
#ExecStartPost=/bin/chgrp sasl /var/run/saslauthd/ | ||
Accept=false | ||
FileDescriptorName=saslauthd | ||
Service=xcauth.service |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
all: nosetests perltests | ||
more: really-all | ||
really-all: nosetests perltests-all | ||
|
||
nosetests: | ||
(cd .. && nosetests3) | ||
|
||
perltests: | ||
for i in run-online*.pl; do (cd .. && tests/$$i) || exit 1; done | ||
perltests: perltests-direct perltests-subprocess perltests-socket1366x | ||
perltests-all: perltests perltests-socket2366x | ||
|
||
perltests-direct: | ||
cd .. && tests/run-online.pl | ||
perltests-subprocess: | ||
for i in run-online-*.pl; do echo == $$i; (cd .. && tests/$$i subprocess) || exit 1; done | ||
perltests-socket1366x: | ||
for i in run-online-*.pl; do echo == $$i; (cd .. && tests/$$i socket1366x) || exit 1; sleep 1; done | ||
perltests-socket2366x: | ||
for i in run-online-*.pl; do echo == $$i; (cd .. && tests/$$i socket2366x) || exit 1; done |
Oops, something went wrong.