Bug 452326 - ejabberdctl runs as wrong user, wrong hostname
Summary: ejabberdctl runs as wrong user, wrong hostname
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: ejabberd
Version: 8
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Peter Lemenkov
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-06-20 23:24 UTC by Bill McGonigle
Modified: 2008-09-25 00:12 UTC (History)
2 users (show)

Fixed In Version: 2.0.1-4.fc8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-09-25 00:09:17 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch that changes hostname and adds runuser (691 bytes, patch)
2008-06-20 23:24 UTC, Bill McGonigle
no flags Details | Diff
Patch to use `hostname -s` instead of hardcoding localhost or using cut (1.02 KB, patch)
2008-06-22 18:10 UTC, Adam Goode
no flags Details | Diff
patch to fix quoting issue for register (644 bytes, patch)
2008-06-25 04:01 UTC, Bill McGonigle
no flags Details | Diff

Description Bill McGonigle 2008-06-20 23:24:30 UTC
/etc/init.d/ejabberd is using a node name of ejabberd@`hostname|cut -d. -f1` but
ejabbertctl uses ejabberd@localhost.  This causes errors such as:

%ejabberd status
RPC failed on the node ejabberd@localhost: nodedown

It also appears that ejabberctl needs to run as the ejabberd user.  I'm quite
sure why this is, but I can get status and register with it like that, but not
otherwise.

Attaching a patch that seems to fix the status and register cases I needed.  I
suspect it might need to be expanded for some of the other cases but I haven't
tested, no am I sure why you'd e.g. start/stop in ejabberdctl when there's an
init script to do it.

Running:
  ejabberd-2.0.1-2.fc8
  ejabberd-doc-2.0.1-2.fc8

from testing.

Comment 1 Bill McGonigle 2008-06-20 23:24:30 UTC
Created attachment 309954 [details]
Patch that changes hostname and adds runuser

Comment 2 Fedora Update System 2008-06-22 16:58:00 UTC
ejabberd-2.0.1-3.fc8 has been submitted as an update for Fedora 8

Comment 3 Fedora Update System 2008-06-22 17:02:37 UTC
ejabberd-2.0.1-3.fc9 has been submitted as an update for Fedora 9

Comment 4 Adam Goode 2008-06-22 18:08:08 UTC
I have tried ejabberd-2.0.1-3.fc9, and it is still not working for me. I still
have to change HOST=localhost in ejabberdctl, and node=localhost in
/etc/init.d/ejabberd.

There must be some configurations where localhost is appropriate, and others
where `hostname | cut ...` is.

There is perhaps some insight here, especially the -name and -sname options?
http://www.erlang.org/doc/man/erl.html

Aha, I think I've got it:
`hostname -s`

It's because we're using -sname, and because of this:
[root@lincoln4 ~]# hostname -s
localhost
[root@lincoln4 ~]# hostname -f
localhost.localdomain
[root@lincoln4 ~]# hostname 
lincoln4

When I change ejabberdctl and the init file to this, it works. Interestingly,
ejabberd.logrotate was already using `hostname -s`.

Comment 5 Adam Goode 2008-06-22 18:10:05 UTC
Created attachment 310000 [details]
Patch to use `hostname -s` instead of hardcoding localhost or using cut

Comment 6 Peter Lemenkov 2008-06-22 18:30:10 UTC
Dammit!  They're the same on my machine:

[petro@Sulaco ~]$ hostname | cut -d. -f1
Sulaco
[petro@Sulaco ~]$ hostname -s
Sulaco
[petro@Sulaco ~]$ hostname -f
Sulaco
[petro@Sulaco ~]$ 

Thanks for catching this.

Comment 7 Fedora Update System 2008-06-22 19:41:15 UTC
ejabberd-2.0.1-4.fc8 has been submitted as an update for Fedora 8

Comment 8 Fedora Update System 2008-06-22 20:04:07 UTC
ejabberd-2.0.1-4.fc9 has been submitted as an update for Fedora 9

Comment 9 Adam Goode 2008-06-22 20:41:12 UTC
Working well now, thanks!

Comment 10 Bill McGonigle 2008-06-24 17:53:09 UTC
Eh - dumb question - where can I grab this?  I figured updates-testing but it
doesn't seem to be there or in development:

Installing:
 ejabberd                i386       2.0.1-2.fc8      updates-testing   710 k
 ejabberd-doc            i386       2.0.1-2.fc8      updates-testing   1.0 M



Comment 11 Peter Lemenkov 2008-06-24 18:52:03 UTC
It has been moved to updates-testing few hours ago. Let's wait until it will be
spreaded across mirrors.

Comment 12 Fedora Update System 2008-06-25 02:53:11 UTC
ejabberd-2.0.1-4.fc8 has been pushed to the Fedora 8 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update ejabberd'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F8/FEDORA-2008-5671

Comment 13 Bill McGonigle 2008-06-25 04:01:38 UTC
Created attachment 310205 [details]
patch to fix quoting issue for register

I don't even believe myself at this point, but when I submitted the original
patch I was able to do a register command and it succeeded.  But now using both
that same patch and the current update version, I get bash quoting problems. 
I'm not an expert bash hacker, so I may have boned something.  Here's what I'm
seeing with -x:

+ ctl register bill bfccomputing.com 1234abcd
+ /sbin/runuser -s /bin/bash - ejabberd -c '	 erl	   -sname ejabberdctl  
    -noinput	   -pa /usr/lib/ejabberd/ebin	    -s ejabberd_ctl -extra
ejabberd@borlaug register' bill bfccomputing.com '1234abcd     '

I can't figure out where those extra quotes are coming from, but it causes the
erlang call to fail (no kidding, right?)

To work around this, I made the change reflected in this patch which just
stuffs the command into a variable and then calls out with that.  That seems to
get the quoting right:

[root@borlaug sbin]# ejabberdctl register bill bfccomputing.com 1234abcd
User "bill" already registered at node ejabberd@borlaug

(see, proof I'm not imagining it this time...)

Other than that, ejabberd-2.0.1-4.fc8 appears to work out of the box.  Thanks!

Comment 14 Fedora Update System 2008-07-09 02:45:50 UTC
ejabberd-2.0.1-4.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2008-07-09 02:54:32 UTC
ejabberd-2.0.1-4.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Bill McGonigle 2008-07-09 17:40:19 UTC
Since the version # didn't increase, I'll assume it's the same code, and such
the problem in comment 13 wasn't addressed, so this will still be broken, and
this bug should be reopened.


Comment 17 Peter Lemenkov 2008-07-09 17:49:10 UTC
You're right.
Reopeninn this ticket...

Comment 18 Guillaume Desmottes 2008-08-21 14:19:42 UTC
(In reply to comment #13)
> Created an attachment (id=310205) [details]
> patch to fix quoting issue for register


Could you push this patch to the F-9 package please? I rebased the OLPC XS ejabberd package on the F-9 one and spend hours trying to understand why ejabberdctl didn't work as expected. I finally found and applied this patch which solved the problem.

Comment 20 Fedora Update System 2008-08-29 20:40:38 UTC
ejabberd-2.0.2-1.fc8 has been submitted as an update for Fedora 8.
http://admin.fedoraproject.org/updates/ejabberd-2.0.2-1.fc8

Comment 21 Fedora Update System 2008-08-29 20:40:47 UTC
ejabberd-2.0.2-1.fc9 has been submitted as an update for Fedora 9.
http://admin.fedoraproject.org/updates/ejabberd-2.0.2-1.fc9

Comment 22 Fedora Update System 2008-09-10 07:13:53 UTC
ejabberd-2.0.2-1.fc8 has been pushed to the Fedora 8 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update ejabberd'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F8/FEDORA-2008-7657

Comment 23 Fedora Update System 2008-09-10 07:15:19 UTC
ejabberd-2.0.2-1.fc9 has been pushed to the Fedora 9 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update ejabberd'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F9/FEDORA-2008-7637

Comment 24 Fedora Update System 2008-09-25 00:09:03 UTC
ejabberd-2.0.2-1.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 25 Fedora Update System 2008-09-25 00:12:49 UTC
ejabberd-2.0.2-1.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.