Commit Graph

11 Commits

Author SHA1 Message Date
Bruno Meneguele
35ea7eb3a7
ima-setup: expand copy metadata perservation
Instead of a raw copy of extended attributes, it would be intestering to
keep all the SELinux labels using the official supported method and also the
file timestamp to differentiate between a policy update (preserving the
policy timestamp) and a raw change in the file.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
2026-07-06 09:04:04 -03:00
Bruno Meneguele
5ff49ee731
ima-setup: check for required argument
The IMA policy file is required for the setup but it was not being checked
if the user passed it before checking if the policy file existed, thus an
empty argument would fail with a weird "  doesn't exist" message.

This commit adds the check for the argument presence at the beginning of the
script, guaranteeing it cannot be empty, and remove the policy file
existence from the middle of runtime, leaving the check already in place at
the argument parsing logic.

At the same time, reword parts of the usage message to make things clearer.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
2026-07-06 08:35:48 -03:00
Coiby Xu
6d6ac4e2d0 ima-setup: skip installing rpm-plugin-ima if it has been installed
Resolves: https://issues.redhat.com/browse/RHEL-99358
Upstream Status: RHEL-only

Suggested-by: Marko Myllynen <myllynen@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
2025-10-30 08:48:14 +08:00
Coiby Xu
5a27b43c2f ima-setup: rebuild all initramfs images to include the integrity dracut module
Resolves: https://issues.redhat.com/browse/RHEL-92638
Conflict: Caused by a typo that exists in upstream

commit ac36e54bee77c82bd7f48a507d014a1ec0055645
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Jul 10 16:53:18 2025 +0800

    ima-setup: rebuild all initramfs images to include the integrity dracut module

    Resolves: https://issues.redhat.com/browse/RHEL-92638

    Quoting Raju,
      ima-setup currently only rebuild the initramfs of running kernel, so
      the older kernel's(n-1 or n-2) initramfs does contain an outdated
      information or it does not contain ima module, as a result the system
      fails to boot with older kernel.

      It is always recommended to have at least 2 older kernel's kept
      installed on the system as a fallback option in case if the latest
      kernel fails to boot due to some unforeseen issue. So that we can boot
      the system with older kernel to troubleshoot the can't boot issue with
      older kernel.

    Suggested-by: Raju Cheerla <rcheerla@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2025-10-30 08:42:31 +08:00
Coiby Xu
d6d9da7af7 ima-setup: fix two shellcheck warnings
Relates: https://issues.redhat.com/browse/RHEL-82392
Conflict: None

Upstream Status: https://src.fedoraproject.org/rpms/ima-evm-utils.git

commit 7b800d82d0947fd0e75e92997a3aec7af079c1cc
Author: Coiby Xu <coxu@redhat.com>
Date:   Tue Feb 25 13:24:33 2025 +0800

    ima-setup: fix two shellcheck warnings

    Fix the following two shellcheck warnings,

        In ima-setup.sh line 36:
                                echo "$policy_file doesn't exist"
                                      ^----------^ SC2154 (warning): policy_file is referenced but not assigned.

        In ima-setup.sh line 41:
                        reinstall_threshold=${_opt#*=}
                        ^-----------------^ SC2034 (warning): reinstall_threshold appears unused. Verify use (or export if used externally).

    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2025-03-06 16:59:13 +08:00
Coiby Xu
3f5494f50f ima-setup: run zipl after building initramfs for s390x
Resolves: https://issues.redhat.com/browse/RHEL-82392
Conflict: None

Upstream Status: https://src.fedoraproject.org/rpms/ima-evm-utils.git

commit 2f1870b21accb4393a420cf55cba774dfd2d78ae
Author: Coiby Xu <coxu@redhat.com>
Date:   Tue Feb 25 13:17:28 2025 +0800

    ima-setup: run zipl after building initramfs for s390x

    Resovles: https://issues.redhat.com/browse/RHEL-74293

    Without running zipl, the old initramfs will be booted.

    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2025-03-06 16:58:48 +08:00
Coiby Xu
9325189a33 add usage for ima-add-sigs
Related: https://issues.redhat.com/browse/RHEL-34778
Conflict: None

Upstream Status: https://src.fedoraproject.org/rpms/ima-evm-utils.git

commit 0e28d7448d1ac2608241949a25d6cb245b04874d
Author: Coiby Xu <coxu@redhat.com>
Date:   Wed Oct 16 14:10:05 2024 +0800

    add usage for ima-add-sigs

    Also format the usage info ima-setup.

    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2024-11-08 10:58:05 +08:00
Coiby Xu
6e0f7dff8d ima-setup: include the integrity module for the default kernel
Resolves: https://issues.redhat.com/browse/RHEL-34778
Conflict: fix a typo

Upstream Status: https://src.fedoraproject.org/rpms/ima-evm-utils.git

commit 62f613cbb7e1753b2e8fa0ce547c02be24842b22
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Jun 3 14:39:06 2024 +0800

    ima-setup: include the integrity module for the default kernel

    ima-setup may run after a new kernel is installed. Detect this case by
    checking if the default kernel is the running kernel.

    Suggested-by: Marko Myllynen <myllynen@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2024-11-08 10:58:05 +08:00
Coiby Xu
15abff6d5f ima-setup: Allow users to specify custom reinstall_threshold
Resolves: https://issues.redhat.com/browse/RHEL-34778
Conflict: None

Upstream Status: https://src.fedoraproject.org/rpms/ima-evm-utils.git

commit 141a74d96ab3cdee1b0d2cf6a0cba19337920e02
Author: Coiby Xu <coxu@redhat.com>
Date:   Tue May 28 09:54:19 2024 +0800

    ima-setup: Allow users to specify custom reinstall_threshold

    Some users may use custom built packages and we are not sure about the
    number of this type of packages. So make reinstall_threshold
    configurable.

    Suggested-by: Marko Myllynen <myllynen@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2024-11-08 10:58:05 +08:00
Coiby Xu
87e9121bc9 ima-setup: Install prerequisite package rpm-plugin-ima
Upstream Status: RHEL-only

Since rpm-plugin-ima is not a BaseOS package, install it in ima-setup.

Signed-off-by: Coiby Xu <coxu@redhat.com>
2024-11-08 10:58:05 +08:00
Coiby Xu
478b5e4548 Add some IMA setup tools
Resolves: https://issues.redhat.com/browse/RHEL-34778
Conflict: Upstream has -libs subpackage

Upstream Status: https://src.fedoraproject.org/rpms/ima-evm-utils.git

commit 8980421a049c776e2b77e534793aafb925b3ad48
Author: Coiby Xu <coiby.xu@gmail.com>
Date:   Mon May 6 17:48:52 2024 +0800

    Add some IMA setup tools

    Some IMA setup tools are added to ease IMA setup which will do
    the following tasks,
       - add IMA signatures to installed packages files
       - load IMA keys and policy
       - enable the dracut integrity module to load IMA keys and policy
         automatically

    Two IMA polices as suggested by Stefan Berger are also provided which
    will be signed automatically with other package files.

    Thanks to Marko Myllynen for coming up with the idea to have a tool
    similar to fips-mode-setup. And thanks to Mimi Zohar and Stefan Berger
    for providing the feedback!

    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2024-11-08 10:58:05 +08:00