Commit Graph

6156 Commits (38320fce56a8d83b79d6c970c491a454ba9de213)

Author SHA1 Message Date
Beniamino Galvani 38320fce56 fix(network-manager): write DHCP filename option to dhcpopts file
Anaconda parses the 'filename' variable [1] set in /tmp/net.$netif.dhcpopts to
determine the name of the kickstart file to use.

[1] https://github.com/rhinstaller/anaconda/blob/anaconda-35.21-1/dracut/fetch-kickstart-net.sh#L31-L34
2021-08-10 15:16:48 +00:00
Shreenidhi Shedi 55468a2d40 fix(install): use size_t to avoid -Wsign-compare warning
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-09 17:11:22 +00:00
Shreenidhi Shedi ef0f848a67 fix(install): improve gettid definition
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-09 17:11:22 +00:00
Shreenidhi Shedi 19537f8943 fix(install): validate return values log.c
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-09 17:11:22 +00:00
Shreenidhi Shedi b5cf7ec784 fix(install): rectify unused function args in log.c
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-09 17:11:22 +00:00
Shreenidhi Shedi e2a61595d2 fix(install): use wrapper for asprintf
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-09 17:11:22 +00:00
Kairui Song 5ab18dee99 fix(squash): apply FIPS and libpthread workaround
There are some workarounds in dracut.sh for FIPS/libpthread covering
some hidden lib dependency issues. These workarounds didn't take effect
for the squash loader since the squash loader is installed
independently. So apply these workarounds again.

Also skip the lib detection code, since these extra installed libs
are small, and squash loader contents are dropped after switch root,
won't be an issue to be always installed. And this makes the code
cleaner.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-08-09 17:08:52 +00:00
Beniamino Galvani 07977ee5c5 fix(cms): reload NetworkManager connections
When NetworkManager is running as systemd service, it's not enough to write
connection files; the module should also tell NetworkManager to reload the
connections from disk so that any new connection can be auto-activated.

https://bugzilla.redhat.com/show_bug.cgi?id=1975929
2021-08-09 17:07:50 +00:00
Beniamino Galvani 5ee7e249b8 fix(network-manager): check for nm-initrd-generator in both /usr/{libexec,lib}
Sice commit 22d6863ef1 ("fix(network-manager): cope with distributions not
using `libexec`") nm-initrd-generator can be installed in either /usr/libexec
or /usr/lib. Change other modules to check for the binary in both locations.
2021-08-09 17:07:50 +00:00
Shreenidhi Shedi 74a4179948 fix(install): use unsigned int instead of unsigned
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-07 20:14:03 +00:00
Shreenidhi Shedi b0bf8187d5 fix(install): reduce cppcheck warnings
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-08-07 20:14:03 +00:00
Thomas Haller e509c638e6 fix(network-manager): ensure safe content of /tmp/dhclient."$ifname".dhcpopts
NetworkManager leaves state files behind in "/run/NetworkManager/devices".
These files are in keyfile format (glib's GKeyFile API [1]).

From the statefile, the dracut module writes a .dhcpopts file. And other users
want to parse that file, for example anaconda ([2]). To be fair,
anaconda seems to parse a different file, so I am a bit confused who
uses this file how. In any case, it seems somebody might be tempted to
execute this as a script.

We need to write the .dhcpopts file in a format that is defined and easy
to handle from a shell script. As already previously, this format is
a bash script that sets certain variables. That means, to load the file,
the user could execute it as bash script. But this is dangerous, as the
file contains potentially untrusted data from the network.
Optimally, users still don't trust the .dhcpopts file to be safe for
executing! It would be better if users too try to parse the file
instead of executing it. That is not trivial however because in face
of special characters, as we use bash's `printf '%q'` to escape the values
and parsing bash escaping is not trivial.

Anyway, make sure we properly quote and handle the content so that also
executing is safe. In the best case, there are no special characters
that require escaping, and naive parsing can be done with `sed`.
Otherwise, executing is now also supposed to be safe.

In this case we parse DHCP options from the state file. They are themselves
backslash escaped UTF-8 strings (C escape sequences), which then are stored
via keyfile API. The properly parse them, we would first need to load the file
with GKeyFile (which undoes one level of backslash escaping) and then
use g_str_compress() (to undo the second level). We mimic that with
shell.

[1] b3411d6780/dracut/fetch-kickstart-net.sh (L30)
[2] https://developer.gnome.org/glib/stable/glib-Key-value-file-parser.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-07 19:56:07 +00:00
Beniamino Galvani c868feb1b1 docs: add a note about other network modules in 'man dracut.cmdline' 2021-08-06 15:59:29 +02:00
Stefan Berger 9da76af8e7 fix(integrity): add support for loading multiple EVM x509 certs
Add support for loading EVM x509 certs from a directory that the user can
specify with the EVMKEYSDIR variable in the evm config file. By default
the additional certs are loaded from /etc/keys/evm.

Support for multiple EVM keys allows the usage in a system of files with
signed metadata from multiple parties.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
2021-08-06 13:58:01 +00:00
Mike Gilbert f649cd10b2 fix(base): do not quote $initargs for switch_root
We want word splitting to occur so that the arguments are passed
separately, and we don't end up passing an empty string if no arguments
are specified.

Bug: https://bugs.gentoo.org/803548
Fixes: 2fabaaa62d
2021-08-06 13:52:19 +00:00
Kairui Song cbd85597e3 fix(squash): remove tailing '/' when installing ld.so.conf.d
This tailing '/' will result in following error:

dracut-install: ERROR: installing '/etc/ld.so.conf.d/'
dracut: FAILED: /usr/lib/dracut/dracut-install -D /var/tmp/dracut.kEFQLs/initramfs -d /etc/ld.so.conf.d/

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-08-06 13:41:23 +00:00
Beniamino Galvani 0e5905315e fix(network-manager): include nm-daemon-helper binary
Since version 1.32, NetworkManager launches a tiny external helper to determine
the hostname via reverse DNS resolution through glibc's nss-dns. Include the
binary.
2021-08-06 13:40:56 +00:00
Zoltán Böszörményi d7acf107f2 fix(base): repair installing dracut-util
inst_binary uses ${dracutsysrootdir} internally to find the source
file.

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
2021-07-23 13:11:17 +00:00
Andreas Schwab 3cc9f1c10c fix(kernel-modules): add more modules on RISC-V
Include the same extra modules for ARM also on RISC-V and add drivers/mmc/host
and drivers/spi to the list.
2021-07-21 15:10:00 +00:00
Zbigniew Jędrzejewski-Szmek a7f5429cb8 fix(dracut-systemd): do not use Requires for vconsole-setup.service
systemd-vconsole-setup.service may fail if the user specifies a missing keymap,
see [1,2,3], or font. This is unfortunate, but the system should not refuse
boot. It is better to continue, possible without the desired font or keymap.
All other systemd services that depend on systemd-vconsole-setup.service do so
without a hard Requires=.

(In particular, systemd-vconsole-setup internally will try to do as much setup
as possible, and will load the font even if it cannot load the keymap and vice
versa.)

[1] https://fedoraproject.org/wiki/Common_F34_bugs#kbd-legacy-media
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1955162
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1955793
2021-07-20 20:53:19 +02:00
Pingfan Liu dc21638c3f fix(squash): keep ld cache under initdir
When running kdump on PowerPC, the following bug is hit:
[    0.391629] Freeing unused kernel memory: 5568K
[    0.391634] This architecture does not have kernel memory protection.
/bin/sh: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[    0.392214] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    0.392214]
[    0.392223] CPU: 6 PID: 1 Comm: init Not tainted 4.18.0-319.el8.ppc64le #1
[    0.392228] Call Trace:
[    0.392234] [c00000000c703c10] [c000000008ecb94c] dump_stack+0xb0/0xf4 (unreliable)
[    0.392243] [c00000000c703c50] [c000000008167324] panic+0x148/0x3c4
[    0.392249] [c00000000c703cf0] [c000000008170474] do_exit+0xcd4/0xd40
[    0.392255] [c00000000c703dc0] [c0000000081705b0] do_group_exit+0x60/0x110
[    0.392261] [c00000000c703e00] [c000000008170684] sys_exit_group+0x24/0x30
[    0.392268] [c00000000c703e20] [c00000000800b408] system_call+0x5c/0x70

This is due to the non-conventional library path:
ldd /bin/bash
        linux-vdso64.so.1 (0x00007fffbdc90000)
        libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007fffbda80000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fffbda50000)
        libc.so.6 => /lib64/glibc-hwcaps/power9/libc-2.28.so (0x00007fffbd830000)
                            ^^^
        /lib64/ld64.so.2 (0x00007fffbdcb0000)

ldd finds the path by libc.so.6 -> /usr/lib64/libc.so.6 ->
/usr/lib64/glibc-hwcaps/power9/libc-2.28.so and cache the result. So
when dracut_install, it only saw
'/usr/lib64/glibc-hwcaps/power9/libc-2.28.so' and blind to
'/usr/lib64/libc.so.6'

In the final kdumpimg, the symlink /usr/lib64/libc.so.6 is not created,
hence ld.so can not find the /usr/lib64/glibc-hwcaps/power9/libc-2.28.so

On the other hand, during the process of building kdumpimg, all of dynamic library info
have been cached in ld.so.cache. Hence this bug can be simplely resolved
by keeping ld cache under $initdir/etc.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
v3 -> v4:
  use inst() instead of copy
v2 -> v3:
  fix format by shfmt -s -w modules.d/99squash/module-setup.sh
v1 -> v2:
  cp -r /etc/ld.so* instead of move, since after switch-root, initdir
can not be seen any longer
2021-07-20 12:41:58 +00:00
Zoltán Böszörményi 1beeaf3b71 fix(dracut-install): tweaks to get_real_file()
Fix potential memory leaks in two locations and use
_exit(EXIT_FAILURE) if asprintf(&abspath, ...) fails.

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
2021-07-19 19:39:57 +00:00
Coiby Xu 6c71ba4121 fix(qeth_rules): check the existence of /sys/devices/qeth/*/online beforehand
On s390x KVM machines, the follow errors occurred,
    $ kdumpctl rebuild
    kdump: Rebuilding /boot/initramfs-4.18.0-321.el8.s390xkdump.img
    /usr/lib/dracut/modules.d/95qeth_rules/module-setup.sh: line 13: /sys/devices/qeth/*/online: No such file or directory
    /usr/lib/dracut/modules.d/95qeth_rules/module-setup.sh: line 13: /sys/devices/qeth/*/online: No such file or directory

because s390x KVM uses virtual devices and /sys/devices/qeth/*/online
doesn't exist. Eliminate this error by checking the existence
beforehand.
2021-07-14 12:46:23 +00:00
Dusty Mabe a0f12fb6a0 fix(network-manager): don't pull in systemd-udev-settle
We get a nice warning about it being deprecated:

```
systemd-udev-settle.service is deprecated. Please fix nm-initrd.service not to pull it in.
```

The service is deprecated because its purpose was to wait for the
discovery of all hardware, but it didn't guarantee that (see the
systemd-udev-settle man page).

NM now runs as an independent service and can deal with devices showing
up at any point, but it does need udev to be started. For now just
Want/After systemd-udev-trigger.
2021-07-01 10:34:37 +02:00
Masahiro Matsuya ec50cec3bd fix: SC2046: Quote this to prevent word splitting 2021-06-29 22:03:38 +00:00
Masahiro Matsuya acb18869e9 fix: SC2086: Double quote to prevent globbing and word splitting 2021-06-29 22:03:38 +00:00
Masahiro Matsuya 2f091b1707 fix(url-lib): make pre-pivot hook separetely per nfs mount 2021-06-29 22:03:38 +00:00
Tomasz Paweł Gajc f806a628aa fix(mksh): requires printf 2021-06-30 00:01:41 +02:00
LinkTed 6610093698 fix(crypt-gpg): execute --card-status on each try
If the gpg card is not inserted before the --card-status command is
executed then the public key is not linked with the card. Therefore,
the LUKS partition cannot be decrypted. To solve this, the
--card--status command is executed on each try.
2021-06-29 22:00:03 +00:00
Kairui Song c7fbc0c890 fix(dracut.sh): handle symlinks appropriately while using '-i' option
[[ -d $symlink ]] will return true if the symlink points to a directory.
So the symlink will not be copied, instead a directory is created with
the symlink name and the content is copied.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-06-29 09:53:19 +02:00
Hari Bathini f1138012c9 fix(dracut.sh): handle '-i' option to include files beginning with '.'
While including a directory using '--include' option, the file and
subdirectory names that begin with '.' are not included. Also, dracut
throws a warning message when a subdirectory is empty or only has
files or subdirectories that begin with '.'.

For example, while trying to include /tmpdata directory with the
below tree:

  # tree -a /tmpdata
  /tmpdata
  ├── .anothertestdir
  ├── testdir
  │   └── .testsubdir
  └── .testfile

dracut throws the below warning message:

  # dracut --include /tmpdata /root
  cp: cannot stat '/tmpdata/testdir/*': No such file or directory
  #

and this is how the included /tmpdata directory tree looks:

  # tree -a root
  root
  └── testdir

No file or directory beginning with '.' is included & also, copying
/tmpdata/testdir reported "No such file or directory" warning. Using
'.' instead of '*' in the below command will fix the warning whether
the directory being copied is empty or only has files or directories
that begin with dot:

  $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/*

Also, enable 'dotglob' temporarily to include files and directories
beginning with a `.' in the results of pathname expansion of source
directory being included.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
2021-06-29 09:53:19 +02:00
Dusty Mabe a97d2cedcf fix(network-manager): support teaming under NM+systemd
Previously when NM was run without dbus then teaming would come
up appropriately [1], but now that dbus exists we also need to
include some supporting infrastructure to allow for it to work
again.

[1] d689380cfc
2021-06-28 11:30:34 +00:00
Kairui Song a2b6be4479 fix(squash): create relative symlinks
Don't use absolute path, or it may resolve to wrong files after unpack
the initramfs to a sub path on a running system.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-06-28 11:25:58 +00:00
Jonathan Lebon 78557f05a6 fix(fips): handle s390x OSTree systems
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
https://github.com/openshift/os/pull/546
https://github.com/ibm-s390-linux/s390-tools/issues/78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>
2021-06-28 11:25:20 +00:00
David Tardon 2e3c5444d2 fix(multipath): get config. dir from configuration 2021-06-28 13:21:33 +02:00
Frantisek Sumsal 6a44426162 fix(install): add a missing ret value assignment
Spotted when reconfiguring LGTM for RHEL 9 dracut repo.
2021-06-28 11:20:21 +00:00
Dusty Mabe a97d6e2b13 fix(network-manager): pull in network.target in nm-initrd.service
Otherwise units with `After=network.target` won't have any effect.
2021-06-28 10:58:10 +00:00
Kairui Song 563f543424 feat(squash): install umount util
Also install umount binary, make it possible to cleanup squash overlay
mounts. This is useful for other tools reusing the dracut initramfs built
with squash module enabled.

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-06-25 21:11:58 +02:00
Matthias Berndt 8b17105bed fix(tpm2-tss): typo in depends()
There is no systemd-udev module, only systemd-udevd
2021-06-22 15:32:28 +02:00
lapseofreason e0abf88a15 fix(crypt): remove quotes from cryptsetupopts
Fixes #1528.
2021-06-08 19:28:45 +00:00
Harald Hoyer 86bf2533d7 docs: update NEWS.md and AUTHORS 2021-05-27 14:34:19 +02:00
Tomasz Paweł Gajc 12beeac741 fix(fs-lib): install fsck utilities 2021-05-27 09:13:04 +02:00
Stefan Berger b12d91c431 fix(integrity): require ALLOW_METADATA_WRITES to come from EVM config file
Upcoming versions of EVM will not require the ALLOW_METADATA_WRITES anymore,
therefore we remove it from the script and require it to be set in the EVM
config file variable EVM_ACTIVATION_BITS for those versions that need it.

Patch 9 in this patch set deprecates the EVM_ALLOW_METADATA_WRITES flag:
https://lore.kernel.org/linux-integrity/20210514152753.982958-1-roberto.sassu@huawei.com/

Suggested-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-26 17:11:07 +02:00
Marcos Mello 5eb24aa21d fix(install): configure logging earlier
There are log_error() and log_debug() calls in parse_argv().
2021-05-26 09:22:09 +02:00
Jóhann B. Guðmundsson 7d205598c6 fix(warpclock): minor cleanups
- Removing shell mode lines
- Remove uncessary file requirements
- Remove hard coded path to binary
- Add missing license header
- Document sections
- refactor install section
2021-05-25 14:00:52 +02:00
Jóhann B. Guðmundsson f4ea5f8734 fix(dash): minor cleanups
- Remove hard coded path to binary
- Add missing license header
- Document sections
- refactor install section
2021-05-25 11:59:08 +00:00
Jóhann B. Guðmundsson 6c673298f3 fix(mksh): minor cleanups
- Remove hard coded path to binary
- Add missing license header
- Document sections
- refactor install section
2021-05-25 11:58:43 +00:00
Marcos Mello 4cb086fa29 feat(install): add default value for --firmwaredirs
If not specified, use /lib/firmware.
2021-05-25 11:48:59 +02:00
Harald Hoyer a277a5fc7a fix(dracut-functions): get_maj_min without get_maj_min_cache_file set
If `get_maj_min_cache_file` is unset `get_maj_min()` would error out.

Fix it to work without a cache file set.
2021-05-21 14:17:07 +02:00
Harald Hoyer 0a6007bf4f fix(dracut): pipe hardlink output to `dinfo`
Otherwise the output is cluttered with:
```
Mode:           real
Files:          1364
Linked:         5 files
Compared:       0 xattrs
Compared:       384 files
Saved:          12.84 KiB
Duration:       0.052674 seconds
```
2021-05-21 14:16:43 +02:00