Bug 18642 - tmpfilesdir variable empty because of incorrect test
Summary: tmpfilesdir variable empty because of incorrect test
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL: https://bugzilla.redhat.com/show_bug....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-06 21:53 CEST by Raphael Gertz
Modified: 2016-06-07 11:48 CEST (History)
1 user (show)

See Also:
Source RPM: dracut-044-3.mga6.src.rpm
CVE:
Status comment:


Attachments

Description Raphael Gertz 2016-06-06 21:53:58 CEST
Description of problem:
$tmpfilesdir variable is empty in dracut script if systemd-devel package is not installed because of 2 incorrect tests in /usr/bin/dracut +1282 and +1283

It should be a [[ -d "/path" ]] and not [[ -f "/path" ]] which fail for obvious reasons.

Result is dracut-tmpfiles.conf is incorrectly place in / of the initramfs instead of wanted :
/lib/tmpfiles.d
/usr/lib/tmpfiles.d
(and likely /etc/tmpfiles.d if systemd-devel is installed)

Code of the install procedure is placed at last line in /usr/lib/dracut/modules.d/98dracut-systemd/module-setup.sh

I am in the case where I need to add some content in this configuration file which shoudn't be placed there.

Version-Release number of selected component (if applicable):
dracut-044-3.mga6

How reproducible:
Alway

Steps to Reproduce:
1. KVER=`ls -d /lib/modules/4.* | sort | tail -n 1 | perl -pne 's%^/lib/modules/%%;s%/$%%'`
2. mkinitrd -v -f /boot/initrd-$KVER.img $KVER
3. Ctrl+z before it finish and look in /var/tmp/dracut.XXXXXX/initramfs/ dir
(or place a debug read in /usr/bin/dracut or extract archive)
Raphael Gertz 2016-06-06 22:58:14 CEST

URL: (none) => https://bugzilla.redhat.com/show_bug.cgi?id=1343230

Comment 1 Raphael Gertz 2016-06-06 22:58:33 CEST
Posted upstream ?
https://bugzilla.redhat.com/show_bug.cgi?id=1343230
Comment 2 Raphael Gertz 2016-06-07 00:27:13 CEST
Same problem with $tmpfilesdir/systemd.conf in /usr/lib/dracut/modules.d/00systemd/module-setup.sh whitch will never be installed.

It's assumed in this case that tmpfilesdir should be set to /usr/lib/tmpfiles.d by default.
Comment 3 Colin Guthrie 2016-06-07 10:19:13 CEST
This seems to be a bug in the fallback code in 3a04bddeed15c810865aa49a2575bf13e651272d which sets the defaults.

Fixed in svn/cauldron and patch sent upstream.

Status: NEW => RESOLVED
CC: (none) => mageia
Resolution: (none) => FIXED

Comment 4 Raphael Gertz 2016-06-07 11:03:53 CEST
There is a trailing bug in this module too : /usr/lib/dracut/modules.d/00systemd/module-setup.sh

It miss a directive :
egrep '^utmp:' /etc/group >> "$initdir/etc/group"

After line 186 for /usr/lib/tmpfiles.d/systemd.conf line 11 witch fail here for me.

Can u plz add it too ?

Status: RESOLVED => REOPENED
Resolution: FIXED => (none)

Comment 5 Colin Guthrie 2016-06-07 11:07:50 CEST
(In reply to Raphael Gertz from comment #4)
> Can u plz add it too ?

Sure, but can you say what the utmp group is needed for so I can write a commit message properly?
Comment 6 Raphael Gertz 2016-06-07 11:13:11 CEST
As well as the root group :
egrep '^root:' /etc/group >> "$initdir/etc/group"
Comment 7 Colin Guthrie 2016-06-07 11:16:11 CEST
(In reply to Raphael Gertz from comment #6)
> As well as the root group :
> egrep '^root:' /etc/group >> "$initdir/etc/group"

Sure, but again, can you say what those groups are needed for, i.e. what component they log errors for etc. Just so I can put it in the commit message and it'll be allowed in (I know I'll be asked this question!).
Comment 8 Raphael Gertz 2016-06-07 11:29:11 CEST
To summary if possible add :
egrep '^utmp:' /etc/group >> "$initdir/etc/group"
egrep '^root:' /etc/group >> "$initdir/etc/group"

In /usr/lib/dracut/modules.d/00systemd/module-setup.sh +186


Those two groups are present in /usr/lib/tmpfiles.d/systemd.conf.

The root group is also required by /usr/lib/tmpfiles.d/dracut-tmpfiles.conf for debug log in case of failed dracut boot.


In my case I have some service early service depending on systemd-tmpfiles-setup.service whose are failing with this error :
systemd-tmpfiles[594]: [/usr/lib/tmpfiles.d/systemd.conf:11] Unknown group 'utmp'.

Not sure if it's a bug related to mageia specific configuration of /usr/lib/tmpfiles.d/systemd.conf which was silently failing or my configuration which depend on this service early.

This service can only started through deps so it's really anoying to understand why it is failing for 2 missing groups.

A better fix would be to parse all the group and user of $tmpfilesdir files and add them in passwd and group, but I have no idea how to simply write that yet.

Is that enough explanation ? I have no idea how to explain better...
Comment 9 Raphael Gertz 2016-06-07 11:31:02 CEST
The command generating the error is :
/usr/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev
Comment 10 Colin Guthrie 2016-06-07 11:31:49 CEST
(In reply to Raphael Gertz from comment #8)
> A better fix would be to parse all the group and user of $tmpfilesdir files
> and add them in passwd and group, but I have no idea how to simply write
> that yet.

Cool, this should be possible. There is code in dracut-init.sh to parse users/groups from udev rules, so it should be easy enough to extend to also parse tmpfiles snippets.

I'll see if I can squeeze that in today, but otherwise I'll just put those two groups in directly.

 
> Is that enough explanation ? I have no idea how to explain better...

Yes, perfect, thank you :)
Comment 11 Raphael Gertz 2016-06-07 11:36:06 CEST
With in journal -ab (just in case) :
systemd[1]: systemd-tmpfiles-setup.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: Failed to start Create Volatile File and Directories.
systemd[1]: systemd-tmpfiles-setup.service: Unit entered failed state.
systemd[1]: systemd-tmpfiles-setup.service: Failed with result 'exit-code'.
Comment 12 Raphael Gertz 2016-06-07 11:39:24 CEST
If you want to use that code it's likely you will need to extract the user+group in two modules.

For /usr/lib/tmpfiles.d/systemd.conf in /usr/lib/dracut/modules.d/00systemd/module-setup.sh+186
For /usr/lib/tmpfiles.d/dracut-tmpfiles.conf in /usr/lib/dracut/modules.d/98dracut-systemd/module-setup.sh+61
Comment 13 Colin Guthrie 2016-06-07 11:48:02 CEST
OK, I've added the patch now (just the simple one and will leave it up to upstream to do a better, more generic one should they see fit).

There is a discussion just now about whether or not to drop a require from dracut so I won't bother pushing to cauldron for now as I suspect tmb may do so in due course.

Fixing for now but if it doesn't appear or you notice more users/groups missing just reopen.

Status: REOPENED => RESOLVED
Resolution: (none) => FIXED


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