FS#54077 - package prosody not working due to bad install folder permission.

Attached to Project: Community Packages
Opened by social loser (socialloser1) - Tuesday, 16 May 2017, 08:01 GMT
Last edited by Sergej Pupykin (sergej) - Monday, 02 October 2017, 17:01 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:
package prosody not working due to bad permission of installing folder.
prosody installation contains a folder '/var/lib/prosody' with permission 750.
the command to add user "prosodyctl adduser" won't work with this setting, even running this command as root. it seems this command utilize another process to do this, which is not running as root. (just my guess, prosody is written with lua, which I can not read )


Steps to reproduce:
1, install prosody package
2, run command 'prosodyctl adduser test@localhost'
This task depends upon

Closed by  Sergej Pupykin (sergej)
Monday, 02 October 2017, 17:01 GMT
Reason for closing:  Fixed
Comment by social loser (socialloser1) - Tuesday, 16 May 2017, 09:15 GMT
with some further experiment , I add more info here , to make things more clear.

say, my current login user is 'tom',

there are several problems, all with the permission of '/var/lib/prosody/' folder:

1, a clear installation will create this folder with ownership of root, and permission 750
at this time , running 'prosodyctl adduser' will fail. the reason cause this is this command is running as user 'tom', it tries to create file owned by 'tom' and it fails.

if you run 'prosodyctl adduser' with root, the created file is not readable by the server process.

2, if change permission to 777, then user can be added , but the user file created is not readable by the server daemon, so even you add the user successfully , you still can't log in.

3, you have to manually change the permission of user data files created by 'prosodyctl adduser' command to be readable by others. at this time, it works. but further 'adduser' command still create wrong permission(or ownership).


Comment by Maxime Buquet (ppjet6) - Tuesday, 16 May 2017, 09:45 GMT
It seems to be written in the post_install, "you need to 'chown prosody:jabber /var/lib/prosody'". Why not have post_install do it directly?
Comment by loqs (loqs) - Tuesday, 16 May 2017, 20:11 GMT
The user and groups are defined in https://git.archlinux.org/svntogit/community.git/tree/trunk/sysuser.conf?h=packages/prosody&id=c291b6e58bc08b3e512f1ba8f7fde35839a65b4a
However they are only created by systemd-sysusers.hook which runs at the end of the transaction after the install script and the prosody user has no defined uid so can not be referenced by uid.
Comment by social loser (socialloser1) - Wednesday, 17 May 2017, 02:37 GMT
according to this post : https://bbs.archlinux.org/viewtopic.php?id=224873
you can see that system users is created once the conf file is installed to sysusers.d folder. so when post_install is running , the user has already been created. chown will work.
Comment by loqs (loqs) - Wednesday, 17 May 2017, 11:38 GMT
Please specify which post in that thread you are referring to. How did you personally verify the assertion?
$ getent passwd prosody
$ getent group jabber
$ cat prosody.install
post_install() {
chown prosody:jabber /var/lib/prosody
echo ">> Documentation: http://wiki.archlinux.org/index.php/Prosody"
echo ">> Probably you need to do 'chown prosody:jabber /var/lib/prosody'"
}

post_upgrade() {
post_install $1
}

post_remove() {
paths=(/etc/prosody /var/lib/prosody /var/log/prosody
/var/log/old/prosody)
first=true
for path in ${paths[@]}; do
if [ -d $path ]; then
if $first; then
first=false
echo "==> Leftover Paths:"
fi
echo "==> $path"
fi
done
}
$ sudo pacman -U prosody-1\:0.10.r7198+.2fd20f372cb1+-2-x86_64.pkg.tar.xz
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (5) lua51-5.1.5-6 lua51-expat-1.3.0-3 lua51-filesystem-1.6.3-3
lua51-socket-20160311-1 prosody-1:0.10.r7198+.2fd20f372cb1+-2

Total Installed Size: 2.42 MiB

:: Proceed with installation? [Y/n] y
(5/5) checking keys in keyring [######################] 100%
(4/5) checking package integrity [######################] 100%
(4/5) loading package files [######################] 100%
(5/5) checking for file conflicts [######################] 100%
(5/5) checking available disk space [######################] 100%
:: Processing package changes...
(1/5) installing lua51 [######################] 100%
(2/5) installing lua51-socket [######################] 100%
(3/5) installing lua51-expat [######################] 100%
(4/5) installing lua51-filesystem [######################] 100%
(5/5) installing prosody [######################] 100%
chown: invalid user: ‘prosody:jabber’
>> Documentation: http://wiki.archlinux.org/index.php/Prosody
>> Probably you need to do 'chown prosody:jabber /var/lib/prosody'
Optional dependencies for prosody
lua51-sec: TLS encryption support
lua51-bitop: websocket support
lua51-event: libevent support
lua51-dbi: SQL storage support
:: Running post-transaction hooks...
(1/3) Updating system user accounts...
(2/3) Creating temporary files...
(3/3) Arming ConditionNeedsUpdate...
Note the chown failure. A tmpfiles.d entry might work but you are required to read pacman's output which instructs you to manually perform the action anyway which you appear to have ignored.
Comment by Maxime Buquet (ppjet6) - Wednesday, 17 May 2017, 12:17 GMT
Is there any drawbacks to calling systemd-sysusers in the .install?
See how aur/prosody-hg does it.
Comment by loqs (loqs) - Wednesday, 17 May 2017, 16:52 GMT
Adding the following to prosody.tmpfile.d
d /var/lib/prosody 0750 prosody jabber -
Also appears to work and avoids running systemd-sysusers on a per package basis.
Does that change work for you on a clean install / clean-chroot?
Edit: Change permissions from 0755 to 0750 to match existing permissions only changing the ownership
Comment by social loser (socialloser1) - Sunday, 21 May 2017, 01:16 GMT
yes, you're right, I tested copy files to sysuser.d, the user is not created until manually run systemd-sysusers command. I don't know why `privoxy` package can do that.

aren't directories created by 'tmpfiles.d' file will be deleted with reboot? prosody use '/var/lib/prosody' to storage pesistent informations, user account, password, etc.

even this directory is persistent, it is called "tmp", but while calling the configure script, it is called "datadir" ("--datadir=/var/lib/prosody"). I always feel such kind of workaround a little frustrating.

Comment by Sergej Pupykin (sergej) - Monday, 02 October 2017, 17:00 GMT
I added

d /var/lib/prosody 0750 prosody jabber -

to tmpfile. It creates /var/lib/prosody with rwxr-x--- and prosody:jabber

Loading...