Bug 200871 - net-im/ejabberd: dirs under /var being created with inappropriate ownership
Summary: net-im/ejabberd: dirs under /var being created with inappropriate ownership
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Ashish SHUKLA
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-15 12:37 UTC by Marko Cupać
Modified: 2015-06-22 15:56 UTC (History)
0 users

See Also:
ashish: maintainer-feedback-


Attachments
diff to fix the problem (1.03 KB, patch)
2015-06-20 03:34 UTC, Ashish SHUKLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marko Cupać 2015-06-15 12:37:44 UTC
Every time after installing and/or updating ejabberd, directories /var/run/ejabberdctl, /var/log/ejabberd and /var/spool/ejabberd are (re)created with root:wheel ownership. In order for ejabberd to run, they need to be owned by ejabberd:ejabberd.

I don't know a thing about porting, but reading a few paragraphs of porter's handbook, I guess it could be solved by changing a few lines in pkg-plist.

Here's diff:
--- pkg-plist.orig      2015-06-15 14:19:43.000000000 +0200
+++ pkg-plist   2015-06-15 14:22:36.000000000 +0200
@@ -408,6 +408,6 @@
 %%PORTDOCS%%%%DOCSDIR%%/webadmmain.png
 %%PORTDOCS%%%%DOCSDIR%%/webadmmainru.png
 %%PORTDOCS%%%%DOCSDIR%%/yozhikheader.png
-@dir /var/spool/ejabberd
-@dir /var/run/ejabberdctl
-@dir /var/log/ejabberd
+@dir(ejabberd,ejabberd,750) /var/spool/ejabberd
+@dir(ejabberd,ejabberd,750) /var/run/ejabberdctl
+@dir(ejabberd,ejabberd,750) /var/log/ejabberd
Comment 1 Ashish SHUKLA freebsd_committer 2015-06-18 15:39:40 UTC
(In reply to Marko Cupać from comment #0)

Hi Marko,

I've fixed a similar issue sometime ago in r381868[1]. The permissions are being set in pkg-install script of the port.

To figure out your issue, I'll need following information from your side:

 1. Output of:

    make -C /usr/ports/net-im/ejabberd -V PKGNAME

 2. Output of:

    uname -a

 3. Command-line steps on how to reproduce the issue.

References:
[1] https://svnweb.freebsd.org/ports?view=revision&revision=381868

Thanks,
Ashish
Comment 2 Marko Cupać 2015-06-19 20:35:00 UTC
(In reply to Ashish SHUKLA from comment #1)

I am building in poudriere, so /usr/ports is actually a symlink:
/usr/ports -> /usr/local/poudriere/ports/default

Here are answers to your questions:

pacija@pkg:~ % make -C /usr/ports/net-im/ejabberd -V PKGNAME
ejabberd-15.04

pacija@pkg:~ % uname -a
FreeBSD pkg.mimar.rs 10.1-RELEASE-p10 FreeBSD 10.1-RELEASE-p10 #0: Wed May 13 06:54:13 UTC 2015     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

As I build with poudriere, I guess you need information about jail which builds ejabberd:

pacija@pkg:~ % sudo poudriere jail -j 101amd64 -i
Jail name:         101amd64
Jail version:      10.1-RELEASE-p10
Jail arch:         amd64
Jail method:       ftp
Jail mount:        /usr/local/poudriere/jails/101amd64
Jail fs:           pkg/poudriere/jails/101amd64
Jail updated:      2015-05-14 09:40:42
Tree name:         default
Tree method:       portsnap

My ownerships are set as follows:

pacija@xmpp:/var/run % ls -lh | grep ejab
drwxr-x---  2 ejabberd  ejabberd   512B Jun 20 00:01 ejabberdctl

pacija@xmpp:/var/spool % ls -lh | grep ejab
drwxr-x---  2 ejabberd  ejabberd   512B Jun 19 18:39 ejabberd

pacija@xmpp:/var/log % ls -lh | grep ejab
drwxr-x---  2 ejabberd  ejabberd   512B Jun 19 00:45 ejabberd

After reinstalling with 'pkg install -f net-im/ejabberd' ownership is reset on /var/run/ejabberdctl:

pacija@xmpp:/var/run % ls -lh | grep ejab
drwxr-x---  2 root  wheel     512B Jun 10 09:30 ejabberdctl

/var/spool/ejabberd and /var/log/ejabberd preserve their ownership (contrary to what I originally said):

pacija@xmpp:/var/spool % ls -lh | grep ejab
drwxr-x---  2 ejabberd  ejabberd   512B Jun 10 09:30 ejabberd

pacija@xmpp:/var/log % ls -lh | grep ejab
drwxr-x---  2 ejabberd  ejabberd   512B Jun 10 09:30 ejabberd

Because of /var/run/ejabberdctl's ownership being reset to root:wheel, ejabberd won't start, and it throws the following message in ejabberd.log:

2015-06-19 22:24:04.146 [info] <0.7.0> Application lager started on node 'ejabberd@xmpp.mimar.rs'
2015-06-19 22:24:04.146 [error] <0.37.0>@ejabberd_app:write_pid_file:222 Cannot write PID file /var/run/ejabberdctl/ejabberd.pid
Reason: eacces
2015-06-19 22:24:04.147 [error] <0.36.0> CRASH REPORT Process <0.36.0> with 0 neighbours exited with reason: bad return value {cannot_write_pid_file,"/var/run/ejabberdctl/ejabberd.pid",eacces} from ejabberd_app:start(normal, []) in application_master:init/4 line 133
2015-06-19 22:24:04.148 [info] <0.7.0> Application ejabberd exited with reason: bad return value {cannot_write_pid_file,"/var/run/ejabberdctl/ejabberd.pid",eacces} from ejabberd_app:start(normal, [])


After giving ownership of /var/run/ejabberdctl to ejabberd:ejabberd, killing epmd process and restarting ejabberd with 'service ejabberd start', ejabberd starts and works fine.

I apologize for giving incorrect information originally. It appears that only /var/run/ejabberdctl's ownership is being reset. However, this alone results in need for manual chown after every install/upgrade.

Thank you for looking into it, I'd be glad to do some more tests if needed.
Comment 3 Ashish SHUKLA freebsd_committer 2015-06-20 03:34:52 UTC
Created attachment 157892 [details]
diff to fix the problem

(In reply to Marko Cupać from comment #2)

> After giving ownership of /var/run/ejabberdctl to ejabberd:ejabberd, killing epmd process and restarting ejabberd with 'service ejabberd start', ejabberd starts and works fine.

> I apologize for giving incorrect information originally. It appears that only /var/run/ejabberdctl's ownership is being reset. However, this alone results in need for manual chown after every install/upgrade.

No worries.

> Thank you for looking into it, I'd be glad to do some more tests if needed.

Thanks for reporting the issue. Could you please try the attached diff, and see if it fixes the issue for you ?

Sorry for the inconvenience.

Thanks!
Comment 4 Marko Cupać 2015-06-20 08:41:31 UTC
(In reply to Ashish SHUKLA from comment #3)

That fixed it. Thanx!
Comment 5 commit-hook freebsd_committer 2015-06-22 15:54:36 UTC
A commit references this bug:

Author: ashish
Date: Mon Jun 22 15:53:49 UTC 2015
New revision: 390299
URL: https://svnweb.freebsd.org/changeset/ports/390299

Log:
  - Fix permissions on /var/run/ejabberdctl, missed from r381868

  PR:		200871

Changes:
  head/net-im/ejabberd/Makefile
  head/net-im/ejabberd/files/pkg-install.in
Comment 6 Ashish SHUKLA freebsd_committer 2015-06-22 15:56:02 UTC
This should be fixed now.

Thanks for the report.