Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#33249 - [ejabberd] Error on the ExecStart line

Attached to Project: Community Packages
Opened by Chris luna (chris_l) - Sunday, 30 December 2012, 20:51 GMT
Last edited by Sergej Pupykin (sergej) - Thursday, 10 January 2013, 09:30 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sergej Pupykin (sergej)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Is not possible to use the ejabberd server using the provided systemd unit. systemctl status ejabberd says its working ok, however is not possible to actually connect to the server.

However,
starting it manually, it works. To start it manually, copy the command from ExecStart from the unit file, and paste it on a terminal.
Starting it that way it works perfectly.

I have fix it by changing the ExecStart line of the ejabberd.service, and now it works.
The resulting line is this:

ExecStart=/usr/bin/erl -pa /usr/lib/ejabberd/ebin -sname ejabberd -s ejabberd -ejabberd config '"/etc/ejabberd/ejabberd.cfg"' log_path '"/var/log/ejabberd/ejabberd.log"' -sasl sasl_error_logger '{file,"/var/log/ejabberd/sasl.log"}' -mnesia dir '"/var/lib/ejabberd"' -detached -kernel inetrc '"/etc/ejabberd/inetrc"'

The difference is the way the quotes are passed. (I'm using simple quotes to enclose the double quotes. On the original unit file, is using backslashes to pass them)

Additional info:
* package version(s)
2.1.11-7

Steps to reproduce:
systemctl start ejabberd.service # does not work
to fix:
cp /usr/lib/systemd/system/ejabberd.service /etc/systemd/system/ejabberd.service
edit /etc/systemd/system/ejabberd.service to change the ExecStart line to the line I included above
This task depends upon

Closed by  Sergej Pupykin (sergej)
Thursday, 10 January 2013, 09:30 GMT
Reason for closing:  Fixed
Comment by Chris luna (chris_l) - Sunday, 30 December 2012, 20:57 GMT
Nope, I spoke too soon. My ExecStart line works for a few seconds and then dies. (noticed that by doing ps ax|grep erl)

But Im sure manually starting works (I been using it this way somedays now)
Comment by Dave Reisner (falconindy) - Sunday, 30 December 2012, 21:12 GMT
FYI backslash escapes should work just fine according to the code.

The unit is setup to be Type=forking -- does the service actually fork? I assume this is what the "-detached" flag does. Have you tried removing this flag and starting as Type=simple?

You can get logging from journalctl by looking at the failing PID. That is, grab the PID from systemctl status ejabberd and run 'journalctl -b _PID=<pid>'
Comment by Chris luna (chris_l) - Monday, 31 December 2012, 04:00 GMT
No, removing the -detached flag and setting it to simple still does not work.

Here is the output of journalctl:
dic 30 21:52:46 server erl[7199]: {error_logger,{{2012,12,30},{21,52,46}},std_error,"File operation error: eacces. Target: /etc/ejabberd/inetrc. Function: get_file. Process: kernel_sup."}
dic 30 21:52:46 server erl[7199]: {error_logger,{{2012,12,30},{21,52,46}},"inet_config: file ~s not found~n",["/etc/ejabberd/inetrc"]}
dic 30 21:52:46 server erl[7199]: =ERROR REPORT==== 30-Dec-2012::15:52:46 ===
dic 30 21:52:46 server erl[7199]: File operation error: eacces. Target: /etc/ejabberd/inetrc. Function: get_file. Process: kernel_sup.
dic 30 21:52:46 server erl[7199]: =ERROR REPORT==== 30-Dec-2012::15:52:46 ===
dic 30 21:52:46 server erl[7199]: inet_config: file /etc/ejabberd/inetrc not found
dic 30 21:52:46 server erl[7199]: Eshell V5.9.3.1 (abort with ^G)
dic 30 21:52:46 server erl[7199]: (ejabberd@localhost)1> *** Terminating erlang (ejabberd@localhost)

I must add the file /etc/ejabberd/inetrc does exist and has 644 permisions (also tried setting it to 666, but that does not help)

EDIT: Setting the user as root does fix it. Probably there is a permissions problem? I'll continue to do tests. I'll post again as soon as I get any more progress.

EDIT2: Ok, using ejabberd user now. I removed the line for the group on the unit file (the "Group=jabber" part) and then changed the group ownership of the files in the ejabberd home with # chown ejabberd.ejabberd /var/lib/ejabberd/*. It works correctly with this change.
Btw, I tried to conserve the jabber group part and do # chown ejabberd.jabber /var/lib/ejabberd/* but that does not work.
Comment by Chris luna (chris_l) - Tuesday, 01 January 2013, 18:40 GMT
Ok, I think I know what is the problem.
When ejabberd is started by initscripts, the rc file start it by doing:

su ejabberd -s /bin/bash - -c 'erl -pa /usr/lib/ejabberd/ebin -sname ejabberd -s ejabberd -ejabberd config \"/etc/ejabberd/ejabberd.cfg\" log_path \"/var/log/ejabberd/ejabberd.log\" -sasl sasl_error_logger \{file,\"/var/log/ejabberd/sasl.log\"\} -mnesia dir \"/var/lib/ejabberd\" -detached -kernel inetrc \"/etc/ejabberd/inetrc\"'

That starts the service using the ejabberd user, but also, using ejabberd group. (I checked using ps -ae -O fgroup,fuser ). The jabber group is an additional group, is not the main one, and it start the service using the main group of ejabberd user.
I used to use ejabberd on initscripts and worked correctly like that several months.

When the service is started by systemd, is started by using the ejabberd user, BUT using the jabber group this time instead. And it have problems because, at least on my system, /etc/ejabberd has 750 permissions and the ownership is root:ejabberd.

I see two ways to fix it.
The first one is by not using the jabber group at all.
The second one is setting the jabber group as the default group of ejabberd user and then changing the /etc/ejabberd and its files to root:jabber

I did the second one, and is working correctly for me now.
Comment by Dave Reisner (falconindy) - Tuesday, 01 January 2013, 18:48 GMT
Or simply change the owner of /etc/ejabberd to ejabberd instead of root.
Comment by Chris luna (chris_l) - Tuesday, 01 January 2013, 19:00 GMT
Heh, yeah that works. But, since the maintainer has on the ejabberd.install this line:

chown root:ejabberd /etc/ejabberd/ejabberd.cfg /etc/ejabberd/ejabberdctl.cfg /etc/ejabberd

I guess there is a reason for that... dunno XD

But yeah, changing that to root:jabber or ejabberd.jabber or ejabberd.ejabberd works.
Comment by Sergej Pupykin (sergej) - Thursday, 10 January 2013, 09:30 GMT
I removed Group= from .service, so systemd should start ejabberd in the same way as initscripts.

Loading...