From 285d399006d4ec9a28aedd846ee6c91cb140ee10 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Tue, 7 Nov 2023 11:29:40 +0000 Subject: [PATCH] import UBI systemd-252-18.el9 --- ...md-Support-OOMPolicy-in-scope-units.patch} | 4 +- ...o-OOMPolicy-continue-for-login-sess.patch} | 4 +- ...work-description-of-OOMPolicy-a-bit.patch} | 4 +- ...ing-integration-of-OOMPolicy-in-sco.patch} | 4 +- ...-Store-fuzz-tests-in-structured-way.patch} | 4 +- ...erate-fuzzer-inputs-with-directives.patch} | 4 +- ...generated-corpora-in-the-final-zip-.patch} | 4 +- ...gracefully-terminate-delegated-scop.patch} | 4 +- ...erential-shellcheck-workflow-on-push.patch | 47 + ...athering-metadata-for-source-git-au.patch} | 4 +- ...the-source-git-automation-commit-li.patch} | 4 +- ...-CodeQL-and-build-workflows-based-on.patch | 107 ++ ...-also-update-regexp-in-.mergify.yml-.patch | 38 + ...etc-system-update-for-OSTree-systems.patch | 205 ++++ ...ype-of-signature-to-match-the-actua.patch} | 4 +- ...und-initialization-for-journal-file.patch} | 4 +- ...ch => 0243-journald-fix-log-message.patch} | 4 +- ...results-of-parsing-environment-vari.patch} | 4 +- ...e-compression_supported-helper-func.patch} | 4 +- ...-use-the-compression-algorithm-spec.patch} | 4 +- ...to-specify-compression-algorithm-th.patch} | 4 +- ...e-that-journal-file-is-created-with.patch} | 4 +- ...ine-CPU-automatically-on-IBM-platfor.patch | 31 + ...sions-for-source-git-automation-work.patch | 30 + ...e-fixes-for-dmesg.txt-reconstruction.patch | 492 ++++++++ ...y-set-the-base-when-converting-recor.patch | 37 + ...ning-the-dmesg.txt-file-if-not-reque.patch | 68 ++ ...a-couple-of-tests-for-systemd-pstore.patch | 240 ++++ ...tch-all-messages-with-the-FILE-field.patch | 57 + ...-the-SELinux-test-module-on-the-host.patch | 116 ++ ...ress-test-slightly-less-stressful-on.patch | 32 + ...naligned_read_ne-32-64-to-parse-auxv.patch | 202 ++++ ...-make-merge_unit_ids-always-return-N.patch | 57 + ...-make-merge_unit_ids-return-non-NULL.patch | 27 + ...261-core-transaction-do-not-log-null.patch | 45 + ...ly-labels-to-mark-downstream-only-co.patch | 24 + ...PT_LOAD-segment-early-based-on-the-.patch} | 4 +- ...r-overflow-when-computing-end-of-co.patch} | 4 +- ...265-sulogin-use-DEFINE_MAIN_FUNCTION.patch | 46 + ...rol-lost-of-the-current-terminal-whe.patch | 131 +++ ...cuum-count-size-of-all-journal-files.patch | 90 ++ ...a-concept-for-gcc-cleanup-attribute-.patch | 133 +++ ...-macro-introduce-FOREACH_ARRAY-macro.patch | 94 ++ ...rename-function-to-match-struct-name.patch | 64 ++ ...271-journal-vacuum-use-CLEANUP_ARRAY.patch | 107 ++ SOURCES/0272-pam-add-call-to-pam_umask.patch | 28 + ..._id-align-VF-representor-names-with-.patch | 196 ++++ ...0274-pam-add-a-call-to-pam_namespace.patch | 42 + ...-automatically-on-IBM-s390x-platform.patch | 39 + ...cape-invalid-UTF8-char-in-dbus-reply.patch | 106 ++ ...ate-cpu-controller-assign-weights-t.patch} | 4 +- ...vme-symlink-creation-on-namespace-ch.patch | 61 + ...pace-after-comma-before-the-line-con.patch | 35 + ...tore-compat-symlink-for-nvme-devices.patch | 61 + SOURCES/0281-rules-drop-doubled-space.patch | 25 + ...aint-the-host-if-cgroups-v1-is-used.patch} | 4 +- ...n-resetting-PID-also-reset-known-fla.patch | 43 + ...stable-from-advanced-commit-linter-c.patch | 28 + ...ice-when-resetting-PID-also-reset-kn.patch | 43 + ...nstall-python3-lldb-COMPILER_VERSION.patch | 42 + ...add-downstream-CONTRIBUTING-document.patch | 83 ++ ...88-doc-improve-CONTRIBUTING-document.patch | 57 + ...c-use-link-with-prefilled-Jira-issue.patch | 25 + ...nk-downstream-CONTRIBUTING-in-README.patch | 52 + .../0291-bpf-fix-restrict_fs-on-s390x.patch | 51 + ...et_id-use-naming-scheme-for-RHEL-9.3.patch | 24 + ...s-use-inactive_exit_timestamp-if-it-.patch | 46 + ...l_timestamp_is_set-in-one-more-place.patch | 25 + ...-loginctl-list-users-also-show-state.patch | 77 ++ ...tl-list-sessions-minor-modernization.patch | 67 ++ ...ginctl-list-sessions-also-show-state.patch | 65 ++ ...r-state-in-loginctl-list-users-sessi.patch | 59 + ...est-add-a-missing-session-activation.patch | 45 + ...0-test-extend-test-for-loginctl-list.patch | 57 + .../0301-loginctl-shorten-variable-name.patch | 66 ++ ...-loginctl-use-bus_map_all_properties.patch | 150 +++ ...session-idle-status-in-list-sessions.patch | 96 ++ .../0304-loginctl-some-modernizations.patch | 184 +++ ...sessions-fix-timestamp-for-idle-hint.patch | 55 + ...ist-users-use-bus_map_all_properties.patch | 103 ++ ...lso-show-idle-hint-in-session-status.patch | 78 ++ ...-ArrayCleanup-passed-to-array_cleanu.patch | 45 + ...309-static-destruct-several-cleanups.patch | 87 ++ ...introduce-STATIC_ARRAY_DESTRUCTOR_RE.patch | 172 +++ ...e-case-that-the-number-of-elements-h.patch | 40 + ...-apply-similar-config-reordering-of-.patch | 74 ++ ...-ret_size-in-strv_make_nulstr-option.patch | 34 + ...generator_add_symlink-to-instantiate.patch | 105 ++ ...wfs-units-to-be-just-a-regular-unit-.patch | 270 +++++ ...use-correct-targets-when-sysroot-is-.patch | 159 +++ ...ator-add-SYSTEMD_SYSFS_CHECK-env-var.patch | 70 ++ ...ile-support-for-fstab-generator-test.patch | 155 +++ ...b-generator-also-check-file-contents.patch | 345 ++++++ ...enerator-add-tests-for-mount-options.patch | 667 +++++++++++ ...split-out-several-functions-from-par.patch | 408 +++++++ ...stab-generator-call-add_swap-earlier.patch | 81 ++ ...refuse-to-add-swap-earlier-if-disabl.patch | 41 + ...refuse-invalid-mount-point-path-in-f.patch | 119 ++ ...fix-error-code-propagation-in-run_ge.patch | 75 ++ ...support-defining-mount-units-through.patch | 307 +++++ ...ses-for-defining-mount-and-swap-unit.patch | 412 +++++++ ...e-TimeoutSec-0-to-TimeoutSec-infinit.patch | 221 ++++ ...-TimeoutSec-0-to-TimeoutSec-infinity.patch | 98 ++ ...-generator-use-correct-swap-name-var.patch | 27 + ...tor-add-more-parameter-name-comments.patch | 41 + ...unify-initrd-root-device.target-depe.patch | 59 + .../0333-fstab-util-add-fstab_is_bind.patch | 72 ++ ...resolve-bind-mount-source-when-in-in.patch | 150 +++ ...rename-initrd-flag-to-prefix_sysroot.patch | 147 +++ ...-generator-fix-target-of-sysroot-usr.patch | 31 + ...add-rd.systemd.mount-extra-and-frien.patch | 201 ++++ ...add-a-flag-to-accept-entry-for-in-in.patch | 79 ++ ...ator-extract-core-part-as-a-function.patch | 223 ++++ ...ator-also-test-with-SYSTEMD_IN_INITR.patch | 738 ++++++++++++ ...ator-add-more-tests-for-systemd.moun.patch | 295 +++++ ...enable-fsck-for-block-device-mounts-.patch | 206 ++++ ...se-correct-scope-of-looking-up-units.patch | 48 + ...file-related-tests-into-TEST-23-UNIT.patch | 1009 +++++++++++++++++ ...e-TEST-07-ISSUE-1981-to-TEST-07-PID1.patch | 140 +++ ...TEST-08-ISSUE-2730-into-TEST-07-PID1.patch | 188 +++ ...TEST-09-ISSUE-2691-into-TEST-07-PID1.patch | 76 ++ ...TEST-10-ISSUE-2467-with-TEST-07-PID1.patch | 158 +++ ...TEST-11-ISSUE-3166-into-TEST-07-PID1.patch | 108 ++ ...TEST-12-ISSUE-3171-into-TEST-07-PID1.patch | 172 +++ ...3-s-units-into-a-dedicated-subfolder.patch | 76 ++ ...EST-47-ISSUE-14566-into-TEST-07-PID1.patch | 150 +++ ...EST-51-ISSUE-16115-into-TEST-07-PID1.patch | 120 ++ ...ST-20-MAINPIDGAMES-into-TEST-07-PID1.patch | 273 +++++ ...e-common-test-parts-into-a-utility-s.patch | 312 +++++ ...-test-add-tests-for-JoinsNamespaceOf.patch | 208 ++++ ...57-core-unit-drop-doubled-empty-line.patch | 24 + ...oinsNamespaceOf-implies-the-inverse-.patch | 113 ++ ...-shared-namespace-in-transitive-rela.patch | 140 +++ ...-bidirectional-dependency-simultaneo.patch | 236 ++++ ...ype-of-ifindex-D-Bus-field-and-make-.patch | 29 + ...solved-add-some-line-breaks-comments.patch | 100 ++ ...-filter-loopback-DNS-server-from-glo.patch | 122 ++ ...-add-simple-wrapper-around-BLKSSZGET.patch | 75 ++ ...-on-setting-the-sector-size-correctl.patch | 62 + ...d-probe_sector_size-helper-for-detec.patch | 134 +++ ...-tell-kernel-explicitly-about-loopba.patch | 370 ++++++ ...ert-Treat-EPERM-as-not-available-too.patch | 25 + ...pt-EPERM-for-unavailable-idmapped-mo.patch | 26 + SOURCES/systemd-user | 3 + SOURCES/sysusers.generate-pre.sh | 135 ++- SPECS/systemd.spec | 369 ++++-- 146 files changed, 15905 insertions(+), 172 deletions(-) rename SOURCES/{0228-systemd-Support-OOMPolicy-in-scope-units.patch => 0227-systemd-Support-OOMPolicy-in-scope-units.patch} (98%) rename SOURCES/{0229-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch => 0228-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch} (93%) rename SOURCES/{0230-man-rework-description-of-OOMPolicy-a-bit.patch => 0229-man-rework-description-of-OOMPolicy-a-bit.patch} (97%) rename SOURCES/{0231-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch => 0230-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch} (98%) rename SOURCES/{0232-meson-Store-fuzz-tests-in-structured-way.patch => 0231-meson-Store-fuzz-tests-in-structured-way.patch} (98%) rename SOURCES/{0233-meson-Generate-fuzzer-inputs-with-directives.patch => 0232-meson-Generate-fuzzer-inputs-with-directives.patch} (99%) rename SOURCES/{0234-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch => 0233-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch} (93%) rename SOURCES/{0235-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch => 0234-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch} (94%) create mode 100644 SOURCES/0235-ci-trigger-differential-shellcheck-workflow-on-push.patch rename SOURCES/{0244-ci-workflow-for-gathering-metadata-for-source-git-au.patch => 0236-ci-workflow-for-gathering-metadata-for-source-git-au.patch} (94%) rename SOURCES/{0245-ci-first-part-of-the-source-git-automation-commit-li.patch => 0237-ci-first-part-of-the-source-git-automation-commit-li.patch} (97%) create mode 100644 SOURCES/0238-ci-Mergify-check-CodeQL-and-build-workflows-based-on.patch create mode 100644 SOURCES/0239-ci-add-NOTICE-to-also-update-regexp-in-.mergify.yml-.patch create mode 100644 SOURCES/0240-Support-etc-system-update-for-OSTree-systems.patch rename SOURCES/{0236-journal-def-fix-type-of-signature-to-match-the-actua.patch => 0241-journal-def-fix-type-of-signature-to-match-the-actua.patch} (92%) rename SOURCES/{0237-journal-use-compound-initialization-for-journal-file.patch => 0242-journal-use-compound-initialization-for-journal-file.patch} (97%) rename SOURCES/{0238-journald-fix-log-message.patch => 0243-journald-fix-log-message.patch} (92%) rename SOURCES/{0239-sd-journal-cache-results-of-parsing-environment-vari.patch => 0244-sd-journal-cache-results-of-parsing-environment-vari.patch} (96%) rename SOURCES/{0240-compress-introduce-compression_supported-helper-func.patch => 0245-compress-introduce-compression_supported-helper-func.patch} (95%) rename SOURCES/{0241-sd-journal-always-use-the-compression-algorithm-spec.patch => 0246-sd-journal-always-use-the-compression-algorithm-spec.patch} (98%) rename SOURCES/{0242-sd-journal-allow-to-specify-compression-algorithm-th.patch => 0247-sd-journal-allow-to-specify-compression-algorithm-th.patch} (97%) rename SOURCES/{0243-test-add-test-case-that-journal-file-is-created-with.patch => 0248-test-add-test-case-that-journal-file-is-created-with.patch} (96%) create mode 100644 SOURCES/0249-rules-do-not-online-CPU-automatically-on-IBM-platfor.patch create mode 100644 SOURCES/0250-ci-update-permissions-for-source-git-automation-work.patch create mode 100644 SOURCES/0251-pstore-fixes-for-dmesg.txt-reconstruction.patch create mode 100644 SOURCES/0252-pstore-explicitly-set-the-base-when-converting-recor.patch create mode 100644 SOURCES/0253-pstore-avoid-opening-the-dmesg.txt-file-if-not-reque.patch create mode 100644 SOURCES/0254-test-add-a-couple-of-tests-for-systemd-pstore.patch create mode 100644 SOURCES/0255-test-match-all-messages-with-the-FILE-field.patch create mode 100644 SOURCES/0256-test-build-the-SELinux-test-module-on-the-host.patch create mode 100644 SOURCES/0257-test-make-the-stress-test-slightly-less-stressful-on.patch create mode 100644 SOURCES/0258-coredump-use-unaligned_read_ne-32-64-to-parse-auxv.patch create mode 100644 SOURCES/0259-core-transaction-make-merge_unit_ids-always-return-N.patch create mode 100644 SOURCES/0260-core-transaction-make-merge_unit_ids-return-non-NULL.patch create mode 100644 SOURCES/0261-core-transaction-do-not-log-null.patch create mode 100644 SOURCES/0262-ci-allow-RHEL-only-labels-to-mark-downstream-only-co.patch rename SOURCES/{0246-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch => 0263-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch} (97%) rename SOURCES/{0247-elf-util-check-for-overflow-when-computing-end-of-co.patch => 0264-elf-util-check-for-overflow-when-computing-end-of-co.patch} (95%) create mode 100644 SOURCES/0265-sulogin-use-DEFINE_MAIN_FUNCTION.patch create mode 100644 SOURCES/0266-sulogin-fix-control-lost-of-the-current-terminal-whe.patch create mode 100644 SOURCES/0267-journal-vacuum-count-size-of-all-journal-files.patch create mode 100644 SOURCES/0268-memory-util-add-a-concept-for-gcc-cleanup-attribute-.patch create mode 100644 SOURCES/0269-macro-introduce-FOREACH_ARRAY-macro.patch create mode 100644 SOURCES/0270-journal-vacuum-rename-function-to-match-struct-name.patch create mode 100644 SOURCES/0271-journal-vacuum-use-CLEANUP_ARRAY.patch create mode 100644 SOURCES/0272-pam-add-call-to-pam_umask.patch create mode 100644 SOURCES/0273-udev-builtin-net_id-align-VF-representor-names-with-.patch create mode 100644 SOURCES/0274-pam-add-a-call-to-pam_namespace.patch create mode 100644 SOURCES/0275-rules-online-CPU-automatically-on-IBM-s390x-platform.patch create mode 100644 SOURCES/0276-core-mount-escape-invalid-UTF8-char-in-dbus-reply.patch rename SOURCES/{0227-Revert-user-delegate-cpu-controller-assign-weights-t.patch => 0277-Revert-user-delegate-cpu-controller-assign-weights-t.patch} (96%) create mode 100644 SOURCES/0278-udev-rules-fix-nvme-symlink-creation-on-namespace-ch.patch create mode 100644 SOURCES/0279-rules-add-whitespace-after-comma-before-the-line-con.patch create mode 100644 SOURCES/0280-udev-restore-compat-symlink-for-nvme-devices.patch create mode 100644 SOURCES/0281-rules-drop-doubled-space.patch rename SOURCES/{0248-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch => 0282-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch} (96%) create mode 100644 SOURCES/0283-core-service-when-resetting-PID-also-reset-known-fla.patch create mode 100644 SOURCES/0284-ci-drop-systemd-stable-from-advanced-commit-linter-c.patch create mode 100644 SOURCES/0285-Revert-core-service-when-resetting-PID-also-reset-kn.patch create mode 100644 SOURCES/0286-ci-explicitly-install-python3-lldb-COMPILER_VERSION.patch create mode 100644 SOURCES/0287-doc-add-downstream-CONTRIBUTING-document.patch create mode 100644 SOURCES/0288-doc-improve-CONTRIBUTING-document.patch create mode 100644 SOURCES/0289-doc-use-link-with-prefilled-Jira-issue.patch create mode 100644 SOURCES/0290-docs-link-downstream-CONTRIBUTING-in-README.patch create mode 100644 SOURCES/0291-bpf-fix-restrict_fs-on-s390x.patch create mode 100644 SOURCES/0292-udev-net_id-use-naming-scheme-for-RHEL-9.3.patch create mode 100644 SOURCES/0293-core-timer-Always-use-inactive_exit_timestamp-if-it-.patch create mode 100644 SOURCES/0294-timer-Use-dual_timestamp_is_set-in-one-more-place.patch create mode 100644 SOURCES/0295-loginctl-list-users-also-show-state.patch create mode 100644 SOURCES/0296-loginctl-list-sessions-minor-modernization.patch create mode 100644 SOURCES/0297-loginctl-list-sessions-also-show-state.patch create mode 100644 SOURCES/0298-test-add-test-for-state-in-loginctl-list-users-sessi.patch create mode 100644 SOURCES/0299-test-add-a-missing-session-activation.patch create mode 100644 SOURCES/0300-test-extend-test-for-loginctl-list.patch create mode 100644 SOURCES/0301-loginctl-shorten-variable-name.patch create mode 100644 SOURCES/0302-loginctl-use-bus_map_all_properties.patch create mode 100644 SOURCES/0303-loginctl-show-session-idle-status-in-list-sessions.patch create mode 100644 SOURCES/0304-loginctl-some-modernizations.patch create mode 100644 SOURCES/0305-loginctl-list-sessions-fix-timestamp-for-idle-hint.patch create mode 100644 SOURCES/0306-loginctl-list-users-use-bus_map_all_properties.patch create mode 100644 SOURCES/0307-loginctl-also-show-idle-hint-in-session-status.patch create mode 100644 SOURCES/0308-memory-util-make-ArrayCleanup-passed-to-array_cleanu.patch create mode 100644 SOURCES/0309-static-destruct-several-cleanups.patch create mode 100644 SOURCES/0310-static-destruct-introduce-STATIC_ARRAY_DESTRUCTOR_RE.patch create mode 100644 SOURCES/0311-macro-support-the-case-that-the-number-of-elements-h.patch create mode 100644 SOURCES/0312-shared-generator-apply-similar-config-reordering-of-.patch create mode 100644 SOURCES/0313-nulstr-util-make-ret_size-in-strv_make_nulstr-option.patch create mode 100644 SOURCES/0314-generator-teach-generator_add_symlink-to-instantiate.patch create mode 100644 SOURCES/0315-units-rework-growfs-units-to-be-just-a-regular-unit-.patch create mode 100644 SOURCES/0316-fstab-generator-use-correct-targets-when-sysroot-is-.patch create mode 100644 SOURCES/0317-fstab-generator-add-SYSTEMD_SYSFS_CHECK-env-var.patch create mode 100644 SOURCES/0318-test-add-fstab-file-support-for-fstab-generator-test.patch create mode 100644 SOURCES/0319-test-fstab-generator-also-check-file-contents.patch create mode 100644 SOURCES/0320-test-fstab-generator-add-tests-for-mount-options.patch create mode 100644 SOURCES/0321-fstab-generator-split-out-several-functions-from-par.patch create mode 100644 SOURCES/0322-fstab-generator-call-add_swap-earlier.patch create mode 100644 SOURCES/0323-fstab-generator-refuse-to-add-swap-earlier-if-disabl.patch create mode 100644 SOURCES/0324-fstab-generator-refuse-invalid-mount-point-path-in-f.patch create mode 100644 SOURCES/0325-fstab-generator-fix-error-code-propagation-in-run_ge.patch create mode 100644 SOURCES/0326-fstab-generator-support-defining-mount-units-through.patch create mode 100644 SOURCES/0327-test-add-test-cases-for-defining-mount-and-swap-unit.patch create mode 100644 SOURCES/0328-generators-change-TimeoutSec-0-to-TimeoutSec-infinit.patch create mode 100644 SOURCES/0329-units-change-TimeoutSec-0-to-TimeoutSec-infinity.patch create mode 100644 SOURCES/0330-fstab-generator-use-correct-swap-name-var.patch create mode 100644 SOURCES/0331-fstab-generator-add-more-parameter-name-comments.patch create mode 100644 SOURCES/0332-fstab-generator-unify-initrd-root-device.target-depe.patch create mode 100644 SOURCES/0333-fstab-util-add-fstab_is_bind.patch create mode 100644 SOURCES/0334-fstab-generator-resolve-bind-mount-source-when-in-in.patch create mode 100644 SOURCES/0335-fstab-generator-rename-initrd-flag-to-prefix_sysroot.patch create mode 100644 SOURCES/0336-fstab-generator-fix-target-of-sysroot-usr.patch create mode 100644 SOURCES/0337-fstab-generator-add-rd.systemd.mount-extra-and-frien.patch create mode 100644 SOURCES/0338-fstab-generator-add-a-flag-to-accept-entry-for-in-in.patch create mode 100644 SOURCES/0339-test-fstab-generator-extract-core-part-as-a-function.patch create mode 100644 SOURCES/0340-test-fstab-generator-also-test-with-SYSTEMD_IN_INITR.patch create mode 100644 SOURCES/0341-test-fstab-generator-add-more-tests-for-systemd.moun.patch create mode 100644 SOURCES/0342-fstab-generator-enable-fsck-for-block-device-mounts-.patch create mode 100644 SOURCES/0343-core-use-correct-scope-of-looking-up-units.patch create mode 100644 SOURCES/0344-test-merge-unit-file-related-tests-into-TEST-23-UNIT.patch create mode 100644 SOURCES/0345-test-rename-TEST-07-ISSUE-1981-to-TEST-07-PID1.patch create mode 100644 SOURCES/0346-test-merge-TEST-08-ISSUE-2730-into-TEST-07-PID1.patch create mode 100644 SOURCES/0347-test-merge-TEST-09-ISSUE-2691-into-TEST-07-PID1.patch create mode 100644 SOURCES/0348-test-merge-TEST-10-ISSUE-2467-with-TEST-07-PID1.patch create mode 100644 SOURCES/0349-test-merge-TEST-11-ISSUE-3166-into-TEST-07-PID1.patch create mode 100644 SOURCES/0350-test-merge-TEST-12-ISSUE-3171-into-TEST-07-PID1.patch create mode 100644 SOURCES/0351-test-move-TEST-23-s-units-into-a-dedicated-subfolder.patch create mode 100644 SOURCES/0352-test-merge-TEST-47-ISSUE-14566-into-TEST-07-PID1.patch create mode 100644 SOURCES/0353-test-merge-TEST-51-ISSUE-16115-into-TEST-07-PID1.patch create mode 100644 SOURCES/0354-test-merge-TEST-20-MAINPIDGAMES-into-TEST-07-PID1.patch create mode 100644 SOURCES/0355-test-abstract-the-common-test-parts-into-a-utility-s.patch create mode 100644 SOURCES/0356-test-add-tests-for-JoinsNamespaceOf.patch create mode 100644 SOURCES/0357-core-unit-drop-doubled-empty-line.patch create mode 100644 SOURCES/0358-core-unit-make-JoinsNamespaceOf-implies-the-inverse-.patch create mode 100644 SOURCES/0359-core-unit-search-shared-namespace-in-transitive-rela.patch create mode 100644 SOURCES/0360-core-unit-update-bidirectional-dependency-simultaneo.patch create mode 100644 SOURCES/0361-resolvectl-fix-type-of-ifindex-D-Bus-field-and-make-.patch create mode 100644 SOURCES/0362-resolved-add-some-line-breaks-comments.patch create mode 100644 SOURCES/0363-resolvectl-don-t-filter-loopback-DNS-server-from-glo.patch create mode 100644 SOURCES/0364-blockdev-util-add-simple-wrapper-around-BLKSSZGET.patch create mode 100644 SOURCES/0365-loop-util-insist-on-setting-the-sector-size-correctl.patch create mode 100644 SOURCES/0366-dissect-image-add-probe_sector_size-helper-for-detec.patch create mode 100644 SOURCES/0367-loop-util-always-tell-kernel-explicitly-about-loopba.patch create mode 100644 SOURCES/0368-Revert-Treat-EPERM-as-not-available-too.patch create mode 100644 SOURCES/0369-Revert-test-accept-EPERM-for-unavailable-idmapped-mo.patch diff --git a/SOURCES/0228-systemd-Support-OOMPolicy-in-scope-units.patch b/SOURCES/0227-systemd-Support-OOMPolicy-in-scope-units.patch similarity index 98% rename from SOURCES/0228-systemd-Support-OOMPolicy-in-scope-units.patch rename to SOURCES/0227-systemd-Support-OOMPolicy-in-scope-units.patch index 3eb8eb0..49e94dd 100644 --- a/SOURCES/0228-systemd-Support-OOMPolicy-in-scope-units.patch +++ b/SOURCES/0227-systemd-Support-OOMPolicy-in-scope-units.patch @@ -1,4 +1,4 @@ -From 9603354ef8d1e0456718703920e41e6fadad95a8 Mon Sep 17 00:00:00 2001 +From 97e7419df4912abc62ca379afbb6721b008fbf87 Mon Sep 17 00:00:00 2001 From: Mark Laws Date: Mon, 14 Nov 2022 21:48:09 +0900 Subject: [PATCH] systemd: Support OOMPolicy in scope units @@ -7,7 +7,7 @@ Closes #25376. (cherry picked from commit 5fa098357e0ea9f05b00ed5b04a36ef9f64037db) -Resolves: #2175619 +Resolves: #2176918 --- man/org.freedesktop.systemd1.xml | 6 ++++++ src/core/dbus-scope.c | 6 ++++++ diff --git a/SOURCES/0229-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch b/SOURCES/0228-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch similarity index 93% rename from SOURCES/0229-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch rename to SOURCES/0228-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch index 7353229..5050745 100644 --- a/SOURCES/0229-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch +++ b/SOURCES/0228-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch @@ -1,4 +1,4 @@ -From df85e937594d551c91a1efd5ba73d56399304f19 Mon Sep 17 00:00:00 2001 +From 60f4b73b48b7e9d3f734ecdf63fa5ba9ab3c2338 Mon Sep 17 00:00:00 2001 From: Mark Laws Date: Thu, 24 Nov 2022 14:56:29 +0900 Subject: [PATCH] systemd: Default to OOMPolicy=continue for login session @@ -9,7 +9,7 @@ kill the user's other processes for no good reason. (cherry picked from commit 98b6c94b577205d31b019286c2a84cc9af244ea0) -Resolves: #2175619 +Resolves: #2176918 --- src/login/logind-dbus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SOURCES/0230-man-rework-description-of-OOMPolicy-a-bit.patch b/SOURCES/0229-man-rework-description-of-OOMPolicy-a-bit.patch similarity index 97% rename from SOURCES/0230-man-rework-description-of-OOMPolicy-a-bit.patch rename to SOURCES/0229-man-rework-description-of-OOMPolicy-a-bit.patch index 14690c4..b830a07 100644 --- a/SOURCES/0230-man-rework-description-of-OOMPolicy-a-bit.patch +++ b/SOURCES/0229-man-rework-description-of-OOMPolicy-a-bit.patch @@ -1,4 +1,4 @@ -From b2d0c171a9ef84fb8ab8d8a428a8f51db37f58ea Mon Sep 17 00:00:00 2001 +From 1e066581a0bdfe5848dfc701e84e5d7d431699f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 13 Dec 2022 15:25:55 +0100 Subject: [PATCH] man: rework description of OOMPolicy= a bit @@ -9,7 +9,7 @@ right at the beginning. (cherry picked from commit 100d37d4f3111a97f51e37b51eea9243cb037b61) -Resolves: #2175619 +Resolves: #2176918 --- man/systemd.service.xml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/SOURCES/0231-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch b/SOURCES/0230-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch similarity index 98% rename from SOURCES/0231-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch rename to SOURCES/0230-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch index 1ea0d0b..2dceff9 100644 --- a/SOURCES/0231-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch +++ b/SOURCES/0230-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch @@ -1,4 +1,4 @@ -From 6013f45b86f39a502d9e92b96adee402a32de062 Mon Sep 17 00:00:00 2001 +From 53464ce69ec5202b9abfb35ddbd58c61e2e0ba18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 13 Dec 2022 15:26:58 +0100 Subject: [PATCH] core,man: add missing integration of OOMPolicy= in scopes @@ -7,7 +7,7 @@ Fixup for 5fa098357e0ea9f05b00ed5b04a36ef9f64037db. (cherry picked from commit d5a1657d5a78e9a101fa91e60921bed54ec162b8) -Resolves: #2175619 +Resolves: #2176918 --- man/systemd.scope.xml | 2 ++ man/systemd.service.xml | 22 ++++++++++------------ diff --git a/SOURCES/0232-meson-Store-fuzz-tests-in-structured-way.patch b/SOURCES/0231-meson-Store-fuzz-tests-in-structured-way.patch similarity index 98% rename from SOURCES/0232-meson-Store-fuzz-tests-in-structured-way.patch rename to SOURCES/0231-meson-Store-fuzz-tests-in-structured-way.patch index f82313c..1b50089 100644 --- a/SOURCES/0232-meson-Store-fuzz-tests-in-structured-way.patch +++ b/SOURCES/0231-meson-Store-fuzz-tests-in-structured-way.patch @@ -1,4 +1,4 @@ -From c37de74b2eeefcbcd3f6d7f218e33cda3c3b5397 Mon Sep 17 00:00:00 2001 +From d2bab1cb6c0d7242dbaca55d507f886f7ec0fa6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= Date: Thu, 6 Oct 2022 19:06:08 +0200 Subject: [PATCH] meson: Store fuzz tests in structured way @@ -9,7 +9,7 @@ This is just refactoring with no intentional . (cherry picked from commit 7db5761ddaa53eba197b5abc485e3290f47c661f) -Related: #2175619 +Related: #2176918 --- meson.build | 69 ++++++++++++++++++------------------------- test/fuzz/meson.build | 22 ++++++++++---- diff --git a/SOURCES/0233-meson-Generate-fuzzer-inputs-with-directives.patch b/SOURCES/0232-meson-Generate-fuzzer-inputs-with-directives.patch similarity index 99% rename from SOURCES/0233-meson-Generate-fuzzer-inputs-with-directives.patch rename to SOURCES/0232-meson-Generate-fuzzer-inputs-with-directives.patch index b0915b5..1d5d2bb 100644 --- a/SOURCES/0233-meson-Generate-fuzzer-inputs-with-directives.patch +++ b/SOURCES/0232-meson-Generate-fuzzer-inputs-with-directives.patch @@ -1,4 +1,4 @@ -From d8468261b4f42c4252db283a9fcb2aef5abc39fd Mon Sep 17 00:00:00 2001 +From fd7d93a34d8ef8a194544dba9763e8d58a805641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= Date: Thu, 6 Oct 2022 16:48:01 +0200 Subject: [PATCH] meson: Generate fuzzer inputs with directives @@ -19,7 +19,7 @@ script neither). (cherry picked from commit 7e343b530e68c55f868a4a8261824ca543319a52) -Related: #2175619 +Related: #2176918 --- meson.build | 31 +- test/fuzz/fuzz-link-parser/directives.link | 97 --- diff --git a/SOURCES/0234-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch b/SOURCES/0233-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch similarity index 93% rename from SOURCES/0234-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch rename to SOURCES/0233-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch index 3feb115..c6d6c56 100644 --- a/SOURCES/0234-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch +++ b/SOURCES/0233-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch @@ -1,4 +1,4 @@ -From 3892f0c14a5cb99399d54d9b6fde9c0a09fd1b89 Mon Sep 17 00:00:00 2001 +From a810aef1f95727ec3e044441bf02e0261b2e09ec Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 7 Jan 2023 10:27:05 +0100 Subject: [PATCH] oss-fuzz: include generated corpora in the final zip file @@ -12,7 +12,7 @@ Fixes: #25859 (cherry picked from commit bef8d18b3f9776fdb28fc9a4820f9ce9418422f9) -Related: #2175619 +Related: #2176918 --- tools/oss-fuzz.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SOURCES/0235-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch b/SOURCES/0234-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch similarity index 94% rename from SOURCES/0235-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch rename to SOURCES/0234-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch index 1a2f0f8..635b0a3 100644 --- a/SOURCES/0235-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch +++ b/SOURCES/0234-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch @@ -1,4 +1,4 @@ -From 6b22e9c84c00989ea58b1d9df75f2c20eaa2c274 Mon Sep 17 00:00:00 2001 +From 25223b64f043d9b78d1f70ee7e4a2a3b7a579a84 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Fri, 17 Mar 2023 14:00:15 +0100 Subject: [PATCH] unit: In cgroupv1, gracefully terminate delegated scopes @@ -12,7 +12,7 @@ Co-authored-by: Colin Walters rhel-only -Resolves: #2179165 +Resolves: #2180120 --- src/core/unit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SOURCES/0235-ci-trigger-differential-shellcheck-workflow-on-push.patch b/SOURCES/0235-ci-trigger-differential-shellcheck-workflow-on-push.patch new file mode 100644 index 0000000..3889959 --- /dev/null +++ b/SOURCES/0235-ci-trigger-differential-shellcheck-workflow-on-push.patch @@ -0,0 +1,47 @@ +From e92d004898cb36db27a2ceba6647793ff9617561 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Thu, 30 Mar 2023 17:07:51 +0200 +Subject: [PATCH] ci: trigger `differential-shellcheck` workflow on push + +Fixes: redhat-plumbers-in-action/differential-shellcheck#215 + +rhel-only + +Related: #2100440 +--- + .github/workflows/differential-shellcheck.yml | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/.github/workflows/differential-shellcheck.yml b/.github/workflows/differential-shellcheck.yml +index 105f92d1c9..3662126304 100644 +--- a/.github/workflows/differential-shellcheck.yml ++++ b/.github/workflows/differential-shellcheck.yml +@@ -3,6 +3,10 @@ + + name: Differential ShellCheck + on: ++ push: ++ branches: ++ - main ++ - rhel-9.*.0 + pull_request: + branches: + - main +@@ -18,15 +22,14 @@ jobs: + + permissions: + security-events: write +- pull-requests: write + + steps: + - name: Repository checkout +- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b ++ uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Differential ShellCheck +- uses: redhat-plumbers-in-action/differential-shellcheck@1b1b75e42f0694c1012228513b21617a748c866e ++ uses: redhat-plumbers-in-action/differential-shellcheck@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/SOURCES/0244-ci-workflow-for-gathering-metadata-for-source-git-au.patch b/SOURCES/0236-ci-workflow-for-gathering-metadata-for-source-git-au.patch similarity index 94% rename from SOURCES/0244-ci-workflow-for-gathering-metadata-for-source-git-au.patch rename to SOURCES/0236-ci-workflow-for-gathering-metadata-for-source-git-au.patch index 3a9d249..8e5ff36 100644 --- a/SOURCES/0244-ci-workflow-for-gathering-metadata-for-source-git-au.patch +++ b/SOURCES/0236-ci-workflow-for-gathering-metadata-for-source-git-au.patch @@ -1,4 +1,4 @@ -From 15d494b7ee019ab3e3a2a8e61c73ea8693ddb8ba Mon Sep 17 00:00:00 2001 +From 44f29dde7b88fbaed0972b155a6c7c4751f74839 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Mon, 17 Apr 2023 14:51:19 +0200 Subject: [PATCH] ci: workflow for gathering metadata for source-git automation @@ -9,7 +9,7 @@ This workflow also triggers for rest of the source-git automation workflows. rhel-only -Related: #2184929 +Related: #2100440 --- .github/workflows/gather-metadata.yml | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/SOURCES/0245-ci-first-part-of-the-source-git-automation-commit-li.patch b/SOURCES/0237-ci-first-part-of-the-source-git-automation-commit-li.patch similarity index 97% rename from SOURCES/0245-ci-first-part-of-the-source-git-automation-commit-li.patch rename to SOURCES/0237-ci-first-part-of-the-source-git-automation-commit-li.patch index b90b6c3..4c32125 100644 --- a/SOURCES/0245-ci-first-part-of-the-source-git-automation-commit-li.patch +++ b/SOURCES/0237-ci-first-part-of-the-source-git-automation-commit-li.patch @@ -1,4 +1,4 @@ -From 47c1a02ba0e669484e93dd78dd475592ecaa4cbd Mon Sep 17 00:00:00 2001 +From 6a84f210a9a4dd4fde22ea5d60dff46cad36597f Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Mon, 17 Apr 2023 14:59:55 +0200 Subject: [PATCH] ci: first part of the source-git automation - commit linter @@ -13,7 +13,7 @@ is configured via the `advanced-commit-linter.yml` file. rhel-only -Related: #2184929 +Related: #2100440 --- .github/advanced-commit-linter.yml | 23 +++++++++++ .github/workflows/source-git-automation.yml | 45 +++++++++++++++++++++ diff --git a/SOURCES/0238-ci-Mergify-check-CodeQL-and-build-workflows-based-on.patch b/SOURCES/0238-ci-Mergify-check-CodeQL-and-build-workflows-based-on.patch new file mode 100644 index 0000000..5cefade --- /dev/null +++ b/SOURCES/0238-ci-Mergify-check-CodeQL-and-build-workflows-based-on.patch @@ -0,0 +1,107 @@ +From 049f899364c844326d00ee81b0a4f022315a8206 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 25 Apr 2023 15:18:39 +0200 +Subject: [PATCH] ci(Mergify): check CodeQL and build workflows based on + changed files + +CodeQL and build workflow aren't run for all PRs. They are only run when specific files are changed. + +from the CodeQL workflow: + +```yml +paths: + - '**/meson.build' + - '.github/**/codeql*' + - 'src/**' + - 'test/**' + - 'tools/**' +``` + +This results in Mergify incorrectly labeling PRs with `needs-ci` label. +Let's update the Mergify config to check for the changed files as well. + +rhel-only + +Related: #2100440 +--- + .mergify.yml | 40 +++++++++++++++++++++++++++------------- + 1 file changed, 27 insertions(+), 13 deletions(-) + +diff --git a/.mergify.yml b/.mergify.yml +index bc1743e8ea..e862808ca7 100644 +--- a/.mergify.yml ++++ b/.mergify.yml +@@ -9,11 +9,15 @@ pull_request_rules: + - label!=ci-waived + - or: + # Build test +- - -check-success=build (gcc, 11, bfd, gcrypt) +- - -check-success=build (gcc, 12, gold, openssl) +- - -check-success=build (clang, 13, mold, gcrypt) +- - -check-success=build (clang, 14, lld, openssl) +- - -check-success=build (clang, 15, bfd, auto) ++ # test build check only when the tests have been run ... ++ - and: ++ - files~=^(\S+\/meson\.build|\.github\/workflows\/\S+|meson_options\.txt|src\/\S+|test\/fuzz\/\S+) ++ - or: ++ - -check-success=build (gcc, 11, bfd, gcrypt) ++ - -check-success=build (gcc, 12, gold, openssl) ++ - -check-success=build (clang, 13, mold, gcrypt) ++ - -check-success=build (clang, 14, lld, openssl) ++ - -check-success=build (clang, 15, bfd, auto) + # Unit tests + - -check-success=build (GCC, auto) + - -check-success=build (GCC_ASAN_UBSAN, auto) +@@ -30,14 +34,17 @@ pull_request_rules: + # CentOS CI + - -check-success=CentOS CI (CentOS Stream 9) + - -check-success=CentOS CI (CentOS Stream 9 + sanitizers) +- # CodeQL +- - -check-success=CodeQL + # Packit + - -check-success=rpm-build:centos-stream-9-aarch64 + - -check-success=rpm-build:centos-stream-9-x86_64 + # Other + - -check-success=Lint Code Base + - -check-success=Differential ShellCheck ++ # CodeQL ++ # test CodeQL check only when the CodeQL have been run ... ++ - and: ++ - files~=^(\S+\/meson\.build|\.github\/\S+\/codeql|src\/\S+|test\/\S+|tools\/\S+) ++ - -check-success=CodeQL + actions: + label: + add: +@@ -81,11 +88,15 @@ pull_request_rules: + - label=ci-waived + - and: + # Build test +- - check-success=build (gcc, 11, bfd, gcrypt) +- - check-success=build (gcc, 12, gold, openssl) +- - check-success=build (clang, 13, mold, gcrypt) +- - check-success=build (clang, 14, lld, openssl) +- - check-success=build (clang, 15, bfd, auto) ++ # test build check only when specific files are changed ... ++ - or: ++ - -files~=^(\S+\/meson\.build|\.github\/workflows\/\S+|meson_options\.txt|src\/\S+|test\/fuzz\/\S+) ++ - and: ++ - check-success=build (gcc, 11, bfd, gcrypt) ++ - check-success=build (gcc, 12, gold, openssl) ++ - check-success=build (clang, 13, mold, gcrypt) ++ - check-success=build (clang, 14, lld, openssl) ++ - check-success=build (clang, 15, bfd, auto) + # Unit tests + - check-success=build (GCC, auto) + - check-success=build (GCC_ASAN_UBSAN, auto) +@@ -103,7 +114,10 @@ pull_request_rules: + - check-success=CentOS CI (CentOS Stream 9) + - check-success=CentOS CI (CentOS Stream 9 + sanitizers) + # CodeQL +- - check-success=CodeQL ++ # test CodeQL check only when specific files are changed ... ++ - or: ++ - -files~=^(\S+\/meson\.build|\.github\/\S+\/codeql|src\/\S+|test\/\S+|tools\/\S+) ++ - check-success=CodeQL + # Packit + - check-success=rpm-build:centos-stream-9-aarch64 + - check-success=rpm-build:centos-stream-9-x86_64 diff --git a/SOURCES/0239-ci-add-NOTICE-to-also-update-regexp-in-.mergify.yml-.patch b/SOURCES/0239-ci-add-NOTICE-to-also-update-regexp-in-.mergify.yml-.patch new file mode 100644 index 0000000..65f65cd --- /dev/null +++ b/SOURCES/0239-ci-add-NOTICE-to-also-update-regexp-in-.mergify.yml-.patch @@ -0,0 +1,38 @@ +From e6c01cbcf4cd9b7a3d4ed93e5c6693d83b735c0e Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Thu, 27 Apr 2023 18:29:26 +0200 +Subject: [PATCH] ci: add NOTICE to also update regexp in `.mergify.yml` when + updating `paths` property + +rhel-only + +Related: #2100440 +--- + .github/workflows/build_test.yml | 1 + + .github/workflows/codeql.yml | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml +index cd6937e390..fdd5a462b6 100644 +--- a/.github/workflows/build_test.yml ++++ b/.github/workflows/build_test.yml +@@ -6,6 +6,7 @@ name: Build test + on: + pull_request: + paths: ++ # If changed, also change regexp in `.mergify.yml` + - '**/meson.build' + - '.github/workflows/**' + - 'meson_options.txt' +diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml +index e8236b1857..3ee772b370 100644 +--- a/.github/workflows/codeql.yml ++++ b/.github/workflows/codeql.yml +@@ -10,6 +10,7 @@ on: + - main + - rhel-9.*.0 + paths: ++ # If changed, also change regexp in `.mergify.yml` + - '**/meson.build' + - '.github/**/codeql*' + - 'src/**' diff --git a/SOURCES/0240-Support-etc-system-update-for-OSTree-systems.patch b/SOURCES/0240-Support-etc-system-update-for-OSTree-systems.patch new file mode 100644 index 0000000..8d12a2f --- /dev/null +++ b/SOURCES/0240-Support-etc-system-update-for-OSTree-systems.patch @@ -0,0 +1,205 @@ +From a986415fec990de0ed0c8919d64b1eb6b78c485a Mon Sep 17 00:00:00 2001 +From: Eric Curtin +Date: Mon, 17 Apr 2023 22:09:24 +0100 +Subject: [PATCH] Support /etc/system-update for OSTree systems + +(cherry picked from commit b9dac418372401742609bd600f05267ae3a724de) + +Resolves: #2203133 +--- + man/systemd-system-update-generator.xml | 2 +- + man/systemd.offline-updates.xml | 46 +++++++++++-------- + man/systemd.special.xml | 9 ++-- + .../system-update-generator.c | 25 ++++++---- + units/system-update-cleanup.service | 4 +- + 5 files changed, 51 insertions(+), 35 deletions(-) + +diff --git a/man/systemd-system-update-generator.xml b/man/systemd-system-update-generator.xml +index 8711be26e3..1611a71550 100644 +--- a/man/systemd-system-update-generator.xml ++++ b/man/systemd-system-update-generator.xml +@@ -30,7 +30,7 @@ + systemd-system-update-generator is a + generator that automatically redirects the boot process to + system-update.target, if +- /system-update exists. This is required to ++ /system-update or /etc/system-update exists. This is required to + implement the logic explained in the + systemd.offline-updates7. + +diff --git a/man/systemd.offline-updates.xml b/man/systemd.offline-updates.xml +index 6706451766..7285f9e263 100644 +--- a/man/systemd.offline-updates.xml ++++ b/man/systemd.offline-updates.xml +@@ -40,18 +40,20 @@ + + + +- When the user OK'ed the update, the symlink /system-update is +- created that points to /var/lib/system-update (or +- wherever the directory with the upgrade files is located) and the system is rebooted. This +- symlink is in the root directory, since we need to check for it very early at boot, at a +- time where /var/ is not available yet. ++ When the user OK'ed the update, the symlink /system-update or ++ /etc/system-update is created that points to ++ /var/lib/system-update (or wherever the directory with ++ the upgrade files is located) and the system is rebooted. This symlink is in the root ++ directory, since we need to check for it very early at boot, at a time where ++ /var/ is not available yet. + + + + Very early in the new boot + systemd-system-update-generator8 +- checks whether /system-update exists. If so, it (temporarily and for +- this boot only) redirects (i.e. symlinks) default.target to ++ checks whether /system-update or ++ /etc/system-update exists. If so, it (temporarily and for this boot ++ only) redirects (i.e. symlinks) default.target to + system-update.target, a special target that pulls in the base system + (i.e. sysinit.target, so that all file systems are mounted but little + else) and the system update units. +@@ -68,12 +70,13 @@ + + + As the first step, an update service should check if the +- /system-update symlink points to the location used by that update +- service. In case it does not exist or points to a different location, the service must exit +- without error. It is possible for multiple update services to be installed, and for multiple +- update services to be launched in parallel, and only the one that corresponds to the tool +- that created the symlink before reboot should perform any actions. It +- is unsafe to run multiple updates in parallel. ++ /system-update or /etc/system-update symlink ++ points to the location used by that update service. In case it does not exist or points to a ++ different location, the service must exit without error. It is possible for multiple update ++ services to be installed, and for multiple update services to be launched in parallel, and ++ only the one that corresponds to the tool that created the symlink ++ before reboot should perform any actions. It is unsafe to run multiple updates in ++ parallel. + + + +@@ -88,14 +91,16 @@ + The update scripts should exit only after the update is finished. It is expected + that the service which performs the update will cause the machine to reboot after it + is done. If the system-update.target is successfully reached, i.e. +- all update services have run, and the /system-update symlink still +- exists, it will be removed and the machine rebooted as a safety measure. ++ all update services have run, and the /system-update or ++ /etc/system-update symlink still exists, it will be removed and ++ the machine rebooted as a safety measure. + + + +- After a reboot, now that the /system-update symlink is gone, +- the generator won't redirect default.target anymore and the system +- now boots into the default target again. ++ After a reboot, now that the /system-update and ++ /etc/system-update symlink is gone, the generator won't redirect ++ default.target anymore and the system now boots into the default ++ target again. + + + +@@ -115,8 +120,9 @@ + + + +- Make sure to remove the /system-update symlink as early as +- possible in the update script to avoid reboot loops in case the update fails. ++ Make sure to remove the /system-update and ++ /etc/system-update symlinks as early as possible in the update ++ script to avoid reboot loops in case the update fails. + + + +diff --git a/man/systemd.special.xml b/man/systemd.special.xml +index 85eb8ad076..1620895511 100644 +--- a/man/systemd.special.xml ++++ b/man/systemd.special.xml +@@ -753,8 +753,8 @@ + + A special target unit that is used for offline system updates. + systemd-system-update-generator8 +- will redirect the boot process to this target if /system-update +- exists. For more information see ++ will redirect the boot process to this target if /system-update or ++ /etc/system-update exists. For more information see + systemd.offline-updates7. + + +@@ -764,9 +764,10 @@ + system-update-pre.target but not pull it in. Services which want to + run during system updates only, but before the actual system update is executed should + order themselves before this unit and pull it in. As a safety measure, if this does not +- happen, and /system-update still exists after ++ happen, and /system-update or ++ /etc/system-update still exists after + system-update.target is reached, +- system-update-cleanup.service will remove this symlink and reboot ++ system-update-cleanup.service will remove the symlinks and reboot + the machine. + + +diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c +index fc5aaa9bac..08b357f356 100644 +--- a/src/system-update-generator/system-update-generator.c ++++ b/src/system-update-generator/system-update-generator.c +@@ -6,6 +6,7 @@ + #include "fs-util.h" + #include "generator.h" + #include "log.h" ++#include "path-util.h" + #include "proc-cmdline.h" + #include "special.h" + #include "string-util.h" +@@ -19,19 +20,25 @@ + static const char *arg_dest = NULL; + + static int generate_symlink(void) { +- const char *p = NULL; ++ _cleanup_free_ char *j = NULL; + +- if (laccess("/system-update", F_OK) < 0) { +- if (errno == ENOENT) +- return 0; ++ FOREACH_STRING(p, "/system-update", "/etc/system-update") { ++ if (laccess(p, F_OK) >= 0) ++ goto link_found; + +- log_error_errno(errno, "Failed to check for system update: %m"); +- return -EINVAL; ++ if (errno != ENOENT) ++ log_warning_errno(errno, "Failed to check if %s symlink exists, ignoring: %m", p); + } + +- p = strjoina(arg_dest, "/" SPECIAL_DEFAULT_TARGET); +- if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", p) < 0) +- return log_error_errno(errno, "Failed to create symlink %s: %m", p); ++ return 0; ++ ++link_found: ++ j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET); ++ if (!j) ++ return log_oom(); ++ ++ if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0) ++ return log_error_errno(errno, "Failed to create symlink %s: %m", j); + + return 1; + } +diff --git a/units/system-update-cleanup.service b/units/system-update-cleanup.service +index 5a5dd725a1..a54e74567e 100644 +--- a/units/system-update-cleanup.service ++++ b/units/system-update-cleanup.service +@@ -29,7 +29,9 @@ SuccessAction=reboot + # reboot or some other action on its own. + ConditionPathExists=|/system-update + ConditionPathIsSymbolicLink=|/system-update ++ConditionPathExists=|/etc/system-update ++ConditionPathIsSymbolicLink=|/etc/system-update + + [Service] + Type=oneshot +-ExecStart=rm -fv /system-update ++ExecStart=rm -fv /system-update /etc/system-update diff --git a/SOURCES/0236-journal-def-fix-type-of-signature-to-match-the-actua.patch b/SOURCES/0241-journal-def-fix-type-of-signature-to-match-the-actua.patch similarity index 92% rename from SOURCES/0236-journal-def-fix-type-of-signature-to-match-the-actua.patch rename to SOURCES/0241-journal-def-fix-type-of-signature-to-match-the-actua.patch index 8a14d47..c614291 100644 --- a/SOURCES/0236-journal-def-fix-type-of-signature-to-match-the-actua.patch +++ b/SOURCES/0241-journal-def-fix-type-of-signature-to-match-the-actua.patch @@ -1,4 +1,4 @@ -From 6b6f61668c539329bc95fb7f3c3b644b793dfb52 Mon Sep 17 00:00:00 2001 +From 05b7dfdcc4893fac9adcbf80bcc3f6a8f8f520c1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 25 Jan 2023 18:47:05 +0100 Subject: [PATCH] journal-def: fix type of signature to match the actual field @@ -6,7 +6,7 @@ Subject: [PATCH] journal-def: fix type of signature to match the actual field (cherry picked from commit 6fe167d0a77f72086b457125fad6931ca02a4baf) -Related: #2184929 +Related: #2183546 --- src/libsystemd/sd-journal/journal-def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES/0237-journal-use-compound-initialization-for-journal-file.patch b/SOURCES/0242-journal-use-compound-initialization-for-journal-file.patch similarity index 97% rename from SOURCES/0237-journal-use-compound-initialization-for-journal-file.patch rename to SOURCES/0242-journal-use-compound-initialization-for-journal-file.patch index 721ae3c..0457663 100644 --- a/SOURCES/0237-journal-use-compound-initialization-for-journal-file.patch +++ b/SOURCES/0242-journal-use-compound-initialization-for-journal-file.patch @@ -1,4 +1,4 @@ -From de2a4abb178021ab6700f0bc4038daf88f92cb03 Mon Sep 17 00:00:00 2001 +From b418b2d17e258f10211b529f9beb8b090283307f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 25 Jan 2023 18:48:31 +0100 Subject: [PATCH] journal: use compound initialization for journal file Header @@ -6,7 +6,7 @@ Subject: [PATCH] journal: use compound initialization for journal file Header (cherry picked from commit c3dd0dcb888fd8da7ce4e5299caf45e90ddcd41b) -Related: #2184929 +Related: #2183546 --- src/libsystemd/sd-journal/journal-file.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/SOURCES/0238-journald-fix-log-message.patch b/SOURCES/0243-journald-fix-log-message.patch similarity index 92% rename from SOURCES/0238-journald-fix-log-message.patch rename to SOURCES/0243-journald-fix-log-message.patch index e9f779f..5e7344c 100644 --- a/SOURCES/0238-journald-fix-log-message.patch +++ b/SOURCES/0243-journald-fix-log-message.patch @@ -1,11 +1,11 @@ -From de88fa23f060ab5f554f4c0d41b0f93430f1db8a Mon Sep 17 00:00:00 2001 +From 27c91e79d3cbb79efa9efdd10a7ed5a06c80cba6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Apr 2023 17:11:28 +0900 Subject: [PATCH] journald: fix log message (cherry picked from commit 01aa59979bc61125f599a5b8a6c911fff5daaee7) -Resolves: #2184929 +Resolves: #2183546 --- src/journal/journald-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES/0239-sd-journal-cache-results-of-parsing-environment-vari.patch b/SOURCES/0244-sd-journal-cache-results-of-parsing-environment-vari.patch similarity index 96% rename from SOURCES/0239-sd-journal-cache-results-of-parsing-environment-vari.patch rename to SOURCES/0244-sd-journal-cache-results-of-parsing-environment-vari.patch index 9f71699..d792c81 100644 --- a/SOURCES/0239-sd-journal-cache-results-of-parsing-environment-vari.patch +++ b/SOURCES/0244-sd-journal-cache-results-of-parsing-environment-vari.patch @@ -1,11 +1,11 @@ -From c7919b02b504e2c0ccacf02c6f21f65c3f18ea4c Mon Sep 17 00:00:00 2001 +From 509b535eaad77038984604eac486b0bb76accc6d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Apr 2023 16:43:44 +0900 Subject: [PATCH] sd-journal: cache results of parsing environment variables (cherry picked from commit 9dfbae203e3afa500163bc46e0070c4cb2180aac) -Resolves: #2184929 +Resolves: #2183546 --- src/libsystemd/sd-journal/journal-file.c | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/SOURCES/0240-compress-introduce-compression_supported-helper-func.patch b/SOURCES/0245-compress-introduce-compression_supported-helper-func.patch similarity index 95% rename from SOURCES/0240-compress-introduce-compression_supported-helper-func.patch rename to SOURCES/0245-compress-introduce-compression_supported-helper-func.patch index 9983288..0fe03c2 100644 --- a/SOURCES/0240-compress-introduce-compression_supported-helper-func.patch +++ b/SOURCES/0245-compress-introduce-compression_supported-helper-func.patch @@ -1,11 +1,11 @@ -From c926e4ff48022a71665e7e7833fd59a1bf2ad5fb Mon Sep 17 00:00:00 2001 +From 2c755739d84e409a6331902f5c15943a192a40f4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Apr 2023 14:34:32 +0900 Subject: [PATCH] compress: introduce compression_supported() helper function (cherry picked from commit 83f3d73da8d132773dd91aae0fa7babb74920774) -Resolves: #2184929 +Resolves: #2183546 --- src/basic/compress.c | 10 ++++++++++ src/basic/compress.h | 3 +++ diff --git a/SOURCES/0241-sd-journal-always-use-the-compression-algorithm-spec.patch b/SOURCES/0246-sd-journal-always-use-the-compression-algorithm-spec.patch similarity index 98% rename from SOURCES/0241-sd-journal-always-use-the-compression-algorithm-spec.patch rename to SOURCES/0246-sd-journal-always-use-the-compression-algorithm-spec.patch index 8972152..831b6d9 100644 --- a/SOURCES/0241-sd-journal-always-use-the-compression-algorithm-spec.patch +++ b/SOURCES/0246-sd-journal-always-use-the-compression-algorithm-spec.patch @@ -1,4 +1,4 @@ -From 3baac68b2bcad46062b12aa11e15adf8e6d80a40 Mon Sep 17 00:00:00 2001 +From 0eb906f1a10a8667ead6f1dc5c308f07c9c2b691 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Apr 2023 18:22:50 +0900 Subject: [PATCH] sd-journal: always use the compression algorithm specified in @@ -9,7 +9,7 @@ mentioned in the header. (cherry picked from commit 2360352ef02548723ac0c8eaf5ff6905eb9eeca5) -Resolves: #2184929 +Resolves: #2183546 --- src/libsystemd/sd-journal/journal-file.c | 40 ++++++++++++++---------- src/libsystemd/sd-journal/journal-file.h | 12 +++++-- diff --git a/SOURCES/0242-sd-journal-allow-to-specify-compression-algorithm-th.patch b/SOURCES/0247-sd-journal-allow-to-specify-compression-algorithm-th.patch similarity index 97% rename from SOURCES/0242-sd-journal-allow-to-specify-compression-algorithm-th.patch rename to SOURCES/0247-sd-journal-allow-to-specify-compression-algorithm-th.patch index 4a7998d..d616cdd 100644 --- a/SOURCES/0242-sd-journal-allow-to-specify-compression-algorithm-th.patch +++ b/SOURCES/0247-sd-journal-allow-to-specify-compression-algorithm-th.patch @@ -1,4 +1,4 @@ -From 6d0fb28f2d7b64146361673be99bc2586e3763ce Mon Sep 17 00:00:00 2001 +From 7816037425c80202ed375cff0cc6249c2bc91e2c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Apr 2023 14:19:51 +0900 Subject: [PATCH] sd-journal: allow to specify compression algorithm through @@ -14,7 +14,7 @@ algorithm. Co-authored-by: Colin Walters (cherry picked from commit 1f06ea747b5939a1083c436dd7dae97b37bedee7) -Resolves: #2184929 +Resolves: #2183546 --- docs/ENVIRONMENT.md | 8 +++++ src/libsystemd/sd-journal/journal-file.c | 44 +++++++++++++++++++++++- diff --git a/SOURCES/0243-test-add-test-case-that-journal-file-is-created-with.patch b/SOURCES/0248-test-add-test-case-that-journal-file-is-created-with.patch similarity index 96% rename from SOURCES/0243-test-add-test-case-that-journal-file-is-created-with.patch rename to SOURCES/0248-test-add-test-case-that-journal-file-is-created-with.patch index 69e12fd..97ee1ef 100644 --- a/SOURCES/0243-test-add-test-case-that-journal-file-is-created-with.patch +++ b/SOURCES/0248-test-add-test-case-that-journal-file-is-created-with.patch @@ -1,4 +1,4 @@ -From 7c20d0bfec62de66e81f6b6e1c7ce9f3a3b3d5cf Mon Sep 17 00:00:00 2001 +From 1ed71d6c6613509cc851a3099de8dc6a4d181f56 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Apr 2023 15:03:35 +0900 Subject: [PATCH] test: add test case that journal file is created with the @@ -6,7 +6,7 @@ Subject: [PATCH] test: add test case that journal file is created with the (cherry picked from commit d23a1c52a93206b0dbabcb4336752ccb796c11c3) -Resolves: #2184929 +Resolves: #2183546 --- test/units/testsuite-04.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/SOURCES/0249-rules-do-not-online-CPU-automatically-on-IBM-platfor.patch b/SOURCES/0249-rules-do-not-online-CPU-automatically-on-IBM-platfor.patch new file mode 100644 index 0000000..1683b3f --- /dev/null +++ b/SOURCES/0249-rules-do-not-online-CPU-automatically-on-IBM-platfor.patch @@ -0,0 +1,31 @@ +From 94c7e260b499cd9e5ad8d99d95b9413df2d50cc6 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Thu, 30 Mar 2023 14:56:16 +0200 +Subject: [PATCH] rules: do not online CPU automatically on IBM platforms + +RHEL-only + +Resolves: #2143107 +--- + rules.d/40-redhat.rules | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/rules.d/40-redhat.rules b/rules.d/40-redhat.rules +index 3c95cd2df0..efb866966e 100644 +--- a/rules.d/40-redhat.rules ++++ b/rules.d/40-redhat.rules +@@ -1,7 +1,13 @@ + # do not edit this file, it will be overwritten on update + + # CPU hotadd request +-SUBSYSTEM=="cpu", ACTION=="add", TEST=="online", ATTR{online}=="0", ATTR{online}="1" ++SUBSYSTEM!="cpu", GOTO="cpu_online_end" ++ACTION!="add", GOTO="cpu_online_end" ++CONST{arch}=="s390*|ppc64*", GOTO="cpu_online_end" ++ ++TEST=="online", ATTR{online}=="0", ATTR{online}="1" ++ ++LABEL="cpu_online_end" + + # Memory hotadd request + SUBSYSTEM!="memory", GOTO="memory_hotplug_end" diff --git a/SOURCES/0250-ci-update-permissions-for-source-git-automation-work.patch b/SOURCES/0250-ci-update-permissions-for-source-git-automation-work.patch new file mode 100644 index 0000000..6238446 --- /dev/null +++ b/SOURCES/0250-ci-update-permissions-for-source-git-automation-work.patch @@ -0,0 +1,30 @@ +From d5de6c135caa4cb5871ccfa7d739e0ab46bf02e5 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 19 May 2023 16:37:37 +0200 +Subject: [PATCH] ci: update permissions for source-git automation workflows + +new version of `redhat-plumbers-in-action/advanced-commit-linter` requires new permission: +`checks: write`. + +https://github.com/redhat-plumbers-in-action/advanced-commit-linter/commit/f1bb35fcdeff83d40eb67b5e7c58baad6be689b2 + +rhel-only + +Related: #2170883 +--- + .github/workflows/source-git-automation.yml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml +index 140f21b116..e653e28a7f 100644 +--- a/.github/workflows/source-git-automation.yml ++++ b/.github/workflows/source-git-automation.yml +@@ -33,7 +33,7 @@ jobs: + validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }} + + permissions: +- statuses: write ++ checks: write + pull-requests: write + + steps: diff --git a/SOURCES/0251-pstore-fixes-for-dmesg.txt-reconstruction.patch b/SOURCES/0251-pstore-fixes-for-dmesg.txt-reconstruction.patch new file mode 100644 index 0000000..87450e2 --- /dev/null +++ b/SOURCES/0251-pstore-fixes-for-dmesg.txt-reconstruction.patch @@ -0,0 +1,492 @@ +From a6d9977a0cafaaf1dcf5c7658d958aea8e5284f0 Mon Sep 17 00:00:00 2001 +From: Eric DeVolder +Date: Mon, 21 Nov 2022 11:27:27 -0500 +Subject: [PATCH] pstore: fixes for dmesg.txt reconstruction + +This patch fixes problems with the re-assembly of the dmesg +from the records stored in pstore. + +The current code simply ignores the last 6 characters of the +file name to form a base record id, which then groups any +pstore files with this base id into the reconstructed dmesg.txt. +This approach fails when the following oops generated the +following in pstore: + + -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286101001 + -rw-------. 1 root root 1341 Oct 27 22:07 dmesg-efi-166692286101002 + -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286102001 + -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286102002 + -rw-------. 1 root root 1807 Oct 27 22:07 dmesg-efi-166692286103001 + -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286103002 + -rw-------. 1 root root 1773 Oct 27 22:07 dmesg-efi-166692286104001 + -rw-------. 1 root root 1801 Oct 27 22:07 dmesg-efi-166692286104002 + -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286105001 + -rw-------. 1 root root 1809 Oct 27 22:07 dmesg-efi-166692286105002 + -rw-------. 1 root root 1804 Oct 27 22:07 dmesg-efi-166692286106001 + -rw-------. 1 root root 1817 Oct 27 22:07 dmesg-efi-166692286106002 + -rw-------. 1 root root 1792 Oct 27 22:07 dmesg-efi-166692286107001 + -rw-------. 1 root root 1810 Oct 27 22:07 dmesg-efi-166692286107002 + -rw-------. 1 root root 1717 Oct 27 22:07 dmesg-efi-166692286108001 + -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286108002 + -rw-------. 1 root root 1764 Oct 27 22:07 dmesg-efi-166692286109001 + -rw-------. 1 root root 1765 Oct 27 22:07 dmesg-efi-166692286109002 + -rw-------. 1 root root 1796 Oct 27 22:07 dmesg-efi-166692286110001 + -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286110002 + -rw-------. 1 root root 1793 Oct 27 22:07 dmesg-efi-166692286111001 + -rw-------. 1 root root 1751 Oct 27 22:07 dmesg-efi-166692286111002 + -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286112001 + -rw-------. 1 root root 1786 Oct 27 22:07 dmesg-efi-166692286112002 + -rw-------. 1 root root 1754 Oct 27 22:07 dmesg-efi-166692286113001 + -rw-------. 1 root root 1752 Oct 27 22:07 dmesg-efi-166692286113002 + -rw-------. 1 root root 1803 Oct 27 22:07 dmesg-efi-166692286114001 + -rw-------. 1 root root 1759 Oct 27 22:07 dmesg-efi-166692286114002 + -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286115001 + -rw-------. 1 root root 1787 Oct 27 22:07 dmesg-efi-166692286115002 + -rw-------. 1 root root 1815 Oct 27 22:07 dmesg-efi-166692286116001 + -rw-------. 1 root root 1771 Oct 27 22:07 dmesg-efi-166692286116002 + -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286117002 + -rw-------. 1 root root 1388 Oct 27 22:07 dmesg-efi-166692286701003 + -rw-------. 1 root root 1824 Oct 27 22:07 dmesg-efi-166692286702003 + -rw-------. 1 root root 1795 Oct 27 22:07 dmesg-efi-166692286703003 + -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286704003 + -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286705003 + -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286706003 + -rw-------. 1 root root 1814 Oct 27 22:07 dmesg-efi-166692286707003 + -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286708003 + -rw-------. 1 root root 1769 Oct 27 22:07 dmesg-efi-166692286709003 + -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286710003 + -rw-------. 1 root root 1755 Oct 27 22:07 dmesg-efi-166692286711003 + -rw-------. 1 root root 1790 Oct 27 22:07 dmesg-efi-166692286712003 + -rw-------. 1 root root 1756 Oct 27 22:07 dmesg-efi-166692286713003 + -rw-------. 1 root root 1763 Oct 27 22:07 dmesg-efi-166692286714003 + -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286715003 + -rw-------. 1 root root 1775 Oct 27 22:07 dmesg-efi-166692286716003 + -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286717003 + +The "reconstructed" dmesg.txt that resulted from the above contained +the following (ignoring actual contents, just providing the Part info): + + Emergency#3 Part17 + Emergency#3 Part16 + Emergency#3 Part15 + Emergency#3 Part14 + Emergency#3 Part13 + Emergency#3 Part12 + Emergency#3 Part11 + Emergency#3 Part10 + Emergency#3 Part9 + Emergency#3 Part8 + Emergency#3 Part7 + Emergency#3 Part6 + Emergency#3 Part5 + Emergency#3 Part4 + Emergency#3 Part3 + Emergency#3 Part2 + Emergency#3 Part1 + Panic#2 Part17 + Panic#2 Part16 + Oops#1 Part16 + Panic#2 Part15 + Oops#1 Part15 + Panic#2 Part14 + Oops#1 Part14 + Panic#2 Part13 + Oops#1 Part13 + Panic#2 Part12 + Oops#1 Part12 + Panic#2 Part11 + Oops#1 Part11 + Panic#2 Part10 + Oops#1 Part10 + Panic#2 Part9 + Oops#1 Part9 + Panic#2 Part8 + Oops#1 Part8 + Panic#2 Part7 + Oops#1 Part7 + Panic#2 Part6 + Oops#1 Part6 + Panic#2 Part5 + Oops#1 Part5 + Panic#2 Part4 + Oops#1 Part4 + Panic#2 Part3 + Oops#1 Part3 + Panic#2 Part2 + Oops#1 Part2 + Panic#2 Part1 + Oops#1 Part1 + +The above is a interleaved mess of three dmesg dumps. + +This patch fixes the above problems, and simplifies the dmesg +reconstruction process. The code now distinguishes between +records on EFI vs ERST, which have differently formatted +record identifiers. Using knowledge of the format of the +record ids allows vastly improved reconstruction process. + +With this change in place, the above pstore records now +result in the following: + + # ls -alR /var/lib/systemd/pstore + 1666922861: + total 8 + drwxr-xr-x. 4 root root 28 Nov 18 14:58 . + drwxr-xr-x. 7 root root 144 Nov 18 14:58 .. + drwxr-xr-x. 2 root root 4096 Nov 18 14:58 001 + drwxr-xr-x. 2 root root 4096 Nov 18 14:58 002 + + 1666922861/001: + total 100 + drwxr-xr-x. 2 root root 4096 Nov 18 14:58 . + drwxr-xr-x. 4 root root 28 Nov 18 14:58 .. + -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286101001 + -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286102001 + -rw-------. 1 root root 1807 Oct 27 22:07 dmesg-efi-166692286103001 + -rw-------. 1 root root 1773 Oct 27 22:07 dmesg-efi-166692286104001 + -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286105001 + -rw-------. 1 root root 1804 Oct 27 22:07 dmesg-efi-166692286106001 + -rw-------. 1 root root 1792 Oct 27 22:07 dmesg-efi-166692286107001 + -rw-------. 1 root root 1717 Oct 27 22:07 dmesg-efi-166692286108001 + -rw-------. 1 root root 1764 Oct 27 22:07 dmesg-efi-166692286109001 + -rw-------. 1 root root 1796 Oct 27 22:07 dmesg-efi-166692286110001 + -rw-------. 1 root root 1793 Oct 27 22:07 dmesg-efi-166692286111001 + -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286112001 + -rw-------. 1 root root 1754 Oct 27 22:07 dmesg-efi-166692286113001 + -rw-------. 1 root root 1803 Oct 27 22:07 dmesg-efi-166692286114001 + -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286115001 + -rw-------. 1 root root 1815 Oct 27 22:07 dmesg-efi-166692286116001 + -rw-r-----. 1 root root 28677 Nov 18 14:58 dmesg.txt + + 1666922861/002: + total 104 + drwxr-xr-x. 2 root root 4096 Nov 18 14:58 . + drwxr-xr-x. 4 root root 28 Nov 18 14:58 .. + -rw-------. 1 root root 1341 Oct 27 22:07 dmesg-efi-166692286101002 + -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286102002 + -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286103002 + -rw-------. 1 root root 1801 Oct 27 22:07 dmesg-efi-166692286104002 + -rw-------. 1 root root 1809 Oct 27 22:07 dmesg-efi-166692286105002 + -rw-------. 1 root root 1817 Oct 27 22:07 dmesg-efi-166692286106002 + -rw-------. 1 root root 1810 Oct 27 22:07 dmesg-efi-166692286107002 + -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286108002 + -rw-------. 1 root root 1765 Oct 27 22:07 dmesg-efi-166692286109002 + -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286110002 + -rw-------. 1 root root 1751 Oct 27 22:07 dmesg-efi-166692286111002 + -rw-------. 1 root root 1786 Oct 27 22:07 dmesg-efi-166692286112002 + -rw-------. 1 root root 1752 Oct 27 22:07 dmesg-efi-166692286113002 + -rw-------. 1 root root 1759 Oct 27 22:07 dmesg-efi-166692286114002 + -rw-------. 1 root root 1787 Oct 27 22:07 dmesg-efi-166692286115002 + -rw-------. 1 root root 1771 Oct 27 22:07 dmesg-efi-166692286116002 + -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286117002 + -rw-r-----. 1 root root 30000 Nov 18 14:58 dmesg.txt + + 1666922867: + total 4 + drwxr-xr-x. 3 root root 17 Nov 18 14:58 . + drwxr-xr-x. 7 root root 144 Nov 18 14:58 .. + drwxr-xr-x. 2 root root 4096 Nov 18 14:58 003 + + 1666922867/003: + total 104 + drwxr-xr-x. 2 root root 4096 Nov 18 14:58 . + drwxr-xr-x. 3 root root 17 Nov 18 14:58 .. + -rw-------. 1 root root 1388 Oct 27 22:07 dmesg-efi-166692286701003 + -rw-------. 1 root root 1824 Oct 27 22:07 dmesg-efi-166692286702003 + -rw-------. 1 root root 1795 Oct 27 22:07 dmesg-efi-166692286703003 + -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286704003 + -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286705003 + -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286706003 + -rw-------. 1 root root 1814 Oct 27 22:07 dmesg-efi-166692286707003 + -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286708003 + -rw-------. 1 root root 1769 Oct 27 22:07 dmesg-efi-166692286709003 + -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286710003 + -rw-------. 1 root root 1755 Oct 27 22:07 dmesg-efi-166692286711003 + -rw-------. 1 root root 1790 Oct 27 22:07 dmesg-efi-166692286712003 + -rw-------. 1 root root 1756 Oct 27 22:07 dmesg-efi-166692286713003 + -rw-------. 1 root root 1763 Oct 27 22:07 dmesg-efi-166692286714003 + -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286715003 + -rw-------. 1 root root 1775 Oct 27 22:07 dmesg-efi-166692286716003 + -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286717003 + -rw-r-----. 1 root root 30111 Nov 18 14:58 dmesg.txt + +Furthemore, pstore records on ERST are now able to accurately +identify the change in timestamp sequence in order to start a +new dmesg.txt, as needed. + +(cherry picked from commit 5fbaa757077bde2db8d33b1c358518c41b990339) + +Related: #2170883 +--- + src/pstore/pstore.c | 204 ++++++++++++++++++-------------------------- + 1 file changed, 83 insertions(+), 121 deletions(-) + +diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c +index d820ceb9f6..cfce994bec 100644 +--- a/src/pstore/pstore.c ++++ b/src/pstore/pstore.c +@@ -115,7 +115,7 @@ static int compare_pstore_entries(const PStoreEntry *a, const PStoreEntry *b) { + return strcmp(a->dirent.d_name, b->dirent.d_name); + } + +-static int move_file(PStoreEntry *pe, const char *subdir) { ++static int move_file(PStoreEntry *pe, const char *subdir1, const char *subdir2) { + _cleanup_free_ char *ifd_path = NULL, *ofd_path = NULL; + _cleanup_free_ void *field = NULL; + const char *suffix, *message; +@@ -129,7 +129,7 @@ static int move_file(PStoreEntry *pe, const char *subdir) { + if (!ifd_path) + return log_oom(); + +- ofd_path = path_join(arg_archivedir, subdir, pe->dirent.d_name); ++ ofd_path = path_join(arg_archivedir, subdir1, subdir2, pe->dirent.d_name); + if (!ofd_path) + return log_oom(); + +@@ -172,153 +172,115 @@ static int move_file(PStoreEntry *pe, const char *subdir) { + return 0; + } + +-static int write_dmesg(const char *dmesg, size_t size, const char *id) { +- _cleanup_(unlink_and_freep) char *tmp_path = NULL; ++static int append_dmesg(PStoreEntry *pe, const char *subdir1, const char *subdir2) { ++ /* Append dmesg chunk to end, create if needed */ + _cleanup_free_ char *ofd_path = NULL; + _cleanup_close_ int ofd = -1; + ssize_t wr; +- int r; + +- if (size == 0) +- return 0; ++ assert(pe); + +- assert(dmesg); ++ if (pe->content_size == 0) ++ return 0; + +- ofd_path = path_join(arg_archivedir, id, "dmesg.txt"); ++ ofd_path = path_join(arg_archivedir, subdir1, subdir2, "dmesg.txt"); + if (!ofd_path) + return log_oom(); + +- ofd = open_tmpfile_linkable(ofd_path, O_CLOEXEC|O_CREAT|O_TRUNC|O_WRONLY, &tmp_path); ++ ofd = open(ofd_path, O_CREAT|O_NOFOLLOW|O_NOCTTY|O_CLOEXEC|O_APPEND|O_WRONLY, 0640); + if (ofd < 0) +- return log_error_errno(ofd, "Failed to open temporary file %s: %m", ofd_path); +- wr = write(ofd, dmesg, size); ++ return log_error_errno(ofd, "Failed to open file %s: %m", ofd_path); ++ wr = write(ofd, pe->content, pe->content_size); + if (wr < 0) + return log_error_errno(errno, "Failed to store dmesg to %s: %m", ofd_path); +- if (wr != (ssize_t)size) +- return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to store dmesg to %s. %zu bytes are lost.", ofd_path, size - wr); +- r = link_tmpfile(ofd, tmp_path, ofd_path); +- if (r < 0) +- return log_error_errno(r, "Failed to write temporary file %s: %m", ofd_path); +- tmp_path = mfree(tmp_path); ++ if ((size_t)wr != pe->content_size) ++ return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to store dmesg to %s. %zu bytes are lost.", ofd_path, pe->content_size - wr); + + return 0; + } + +-static void process_dmesg_files(PStoreList *list) { ++static int process_dmesg_files(PStoreList *list) { + /* Move files, reconstruct dmesg.txt */ +- _cleanup_free_ char *dmesg = NULL, *dmesg_id = NULL; +- size_t dmesg_size = 0; +- bool dmesg_bad = false; +- PStoreEntry *pe; ++ _cleanup_free_ char *erst_subdir = NULL; ++ uint64_t last_record_id = 0; ++ ++ /* When dmesg is written into pstore, it is done so in small chunks, whatever the exchange buffer ++ * size is with the underlying pstore backend (ie. EFI may be ~2KiB), which means an example ++ * pstore with approximately 64KB of storage may have up to roughly 32 dmesg files, some likely ++ * related. ++ * ++ * Here we look at the dmesg filename and try to discern if files are part of a related group, ++ * meaning the same original dmesg. ++ * ++ * The dmesg- filename contains the backend-type and the Common Platform Error Record, CPER, ++ * record id, a 64-bit number. ++ * ++ * Files are processed in reverse lexigraphical order so as to properly reconstruct original dmesg.*/ + +- /* Handle each dmesg file: files processed in reverse +- * order so as to properly reconstruct original dmesg */ + for (size_t n = list->n_entries; n > 0; n--) { +- bool move_file_and_continue = false; +- _cleanup_free_ char *pe_id = NULL; ++ PStoreEntry *pe; + char *p; +- size_t plen; + + pe = &list->entries[n-1]; + + if (pe->handled) + continue; +- if (!startswith(pe->dirent.d_name, "dmesg-")) +- continue; +- + if (endswith(pe->dirent.d_name, ".enc.z")) /* indicates a problem */ +- move_file_and_continue = true; +- p = strrchr(pe->dirent.d_name, '-'); +- if (!p) +- move_file_and_continue = true; +- +- if (move_file_and_continue) { +- /* A dmesg file on which we do NO additional processing */ +- (void) move_file(pe, NULL); +- continue; +- } +- +- /* See if this file is one of a related group of files +- * in order to reconstruct dmesg */ +- +- /* When dmesg is written into pstore, it is done so in +- * small chunks, whatever the exchange buffer size is +- * with the underlying pstore backend (ie. EFI may be +- * ~2KiB), which means an example pstore with approximately +- * 64KB of storage may have up to roughly 32 dmesg files +- * that could be related, depending upon the size of the +- * original dmesg. +- * +- * Here we look at the dmesg filename and try to discern +- * if files are part of a related group, meaning the same +- * original dmesg. +- * +- * The two known pstore backends are EFI and ERST. These +- * backends store data in the Common Platform Error +- * Record, CPER, format. The dmesg- filename contains the +- * CPER record id, a 64bit number (in decimal notation). +- * In Linux, the record id is encoded with two digits for +- * the dmesg part (chunk) number and 3 digits for the +- * count number. So allowing an additional digit to +- * compensate for advancing time, this code ignores the +- * last six digits of the filename in determining the +- * record id. +- * +- * For the EFI backend, the record id encodes an id in the +- * upper 32 bits, and a timestamp in the lower 32-bits. +- * So ignoring the least significant 6 digits has proven +- * to generally identify related dmesg entries. */ +-#define PSTORE_FILENAME_IGNORE 6 +- +- /* determine common portion of record id */ +- ++p; /* move beyond dmesg- */ +- plen = strlen(p); +- if (plen > PSTORE_FILENAME_IGNORE) { +- pe_id = memdup_suffix0(p, plen - PSTORE_FILENAME_IGNORE); +- if (!pe_id) { +- log_oom(); +- return; +- } +- } else +- pe_id = mfree(pe_id); +- +- /* Now move file from pstore to archive storage */ +- move_file(pe, pe_id); +- +- if (dmesg_bad) + continue; +- +- /* If the current record id is NOT the same as the +- * previous record id, then start a new dmesg.txt file */ +- if (!streq_ptr(pe_id, dmesg_id)) { +- /* Encountered a new dmesg group, close out old one, open new one */ +- (void) write_dmesg(dmesg, dmesg_size, dmesg_id); +- dmesg_size = 0; +- +- /* now point dmesg_id to storage of pe_id */ +- free_and_replace(dmesg_id, pe_id); +- } +- +- /* Reconstruction of dmesg is done as a useful courtesy: do not fail, but don't write garbled +- * output either. */ +- size_t needed = strlen(pe->dirent.d_name) + strlen(":\n") + pe->content_size + 1; +- if (!GREEDY_REALLOC(dmesg, dmesg_size + needed)) { +- log_oom(); +- dmesg_bad = true; ++ if (!startswith(pe->dirent.d_name, "dmesg-")) + continue; +- } +- +- dmesg_size += sprintf(dmesg + dmesg_size, "%s:\n", pe->dirent.d_name); +- if (pe->content) { +- memcpy(dmesg + dmesg_size, pe->content, pe->content_size); +- dmesg_size += pe->content_size; +- } + +- pe_id = mfree(pe_id); ++ if ((p = startswith(pe->dirent.d_name, "dmesg-efi-"))) { ++ /* For the EFI backend, the 3 least significant digits of record id encodes a ++ * "count" number, the next 2 least significant digits for the dmesg part ++ * (chunk) number, and the remaining digits as the timestamp. See ++ * linux/drivers/firmware/efi/efi-pstore.c in efi_pstore_write(). */ ++ _cleanup_free_ char *subdir1 = NULL, *subdir2 = NULL; ++ size_t plen = strlen(p); ++ ++ if (plen < 6) ++ continue; ++ ++ /* Extract base record id */ ++ subdir1 = strndup(p, plen - 5); ++ if (!subdir1) ++ return log_oom(); ++ /* Extract "count" field */ ++ subdir2 = strndup(p + plen - 3, 3); ++ if (!subdir2) ++ return log_oom(); ++ ++ /* Now move file from pstore to archive storage */ ++ (void) move_file(pe, subdir1, subdir2); ++ ++ /* Append to the dmesg */ ++ (void) append_dmesg(pe, subdir1, subdir2); ++ } else if ((p = startswith(pe->dirent.d_name, "dmesg-erst-"))) { ++ /* For the ERST backend, the record is a monotonically increasing number, seeded as ++ * a timestamp. See linux/drivers/acpi/apei/erst.c in erst_writer(). */ ++ uint64_t record_id; ++ ++ if (safe_atou64(p, &record_id) < 0) ++ continue; ++ if (last_record_id - 1 != record_id) ++ /* A discontinuity in the number has been detected, this current record id ++ * will become the directory name for all pieces of the dmesg in this ++ * series. */ ++ if (free_and_strdup(&erst_subdir, p) < 0) ++ return log_oom(); ++ ++ /* Now move file from pstore to archive storage */ ++ (void) move_file(pe, erst_subdir, NULL); ++ ++ /* Append to the dmesg */ ++ (void) append_dmesg(pe, erst_subdir, NULL); ++ ++ /* Update, but keep erst_subdir for next file */ ++ last_record_id = record_id; ++ } else ++ log_debug("Unknown backend, ignoring \"%s\".", pe->dirent.d_name); + } +- +- if (!dmesg_bad) +- (void) write_dmesg(dmesg, dmesg_size, dmesg_id); ++ return 0; + } + + static int list_files(PStoreList *list, const char *sourcepath) { +@@ -394,11 +356,11 @@ static int run(int argc, char *argv[]) { + typesafe_qsort(list.entries, list.n_entries, compare_pstore_entries); + + /* Process known file types */ +- process_dmesg_files(&list); ++ (void) process_dmesg_files(&list); + + /* Move left over files out of pstore */ + for (size_t n = 0; n < list.n_entries; n++) +- move_file(&list.entries[n], NULL); ++ (void) move_file(&list.entries[n], NULL, NULL); + + return 0; + } diff --git a/SOURCES/0252-pstore-explicitly-set-the-base-when-converting-recor.patch b/SOURCES/0252-pstore-explicitly-set-the-base-when-converting-recor.patch new file mode 100644 index 0000000..b93b2fb --- /dev/null +++ b/SOURCES/0252-pstore-explicitly-set-the-base-when-converting-recor.patch @@ -0,0 +1,37 @@ +From f781f42f512b77b4283f0b96cc87907306075b52 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Fri, 28 Apr 2023 11:09:22 +0200 +Subject: [PATCH] pstore: explicitly set the base when converting record ID + +(cherry picked from commit a95d96a2430db171b40fc2e50589807236f8f746) + +Related: #2170883 +--- + src/pstore/pstore.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c +index cfce994bec..066d8ebb81 100644 +--- a/src/pstore/pstore.c ++++ b/src/pstore/pstore.c +@@ -202,7 +202,7 @@ static int append_dmesg(PStoreEntry *pe, const char *subdir1, const char *subdir + static int process_dmesg_files(PStoreList *list) { + /* Move files, reconstruct dmesg.txt */ + _cleanup_free_ char *erst_subdir = NULL; +- uint64_t last_record_id = 0; ++ unsigned long long last_record_id = 0; + + /* When dmesg is written into pstore, it is done so in small chunks, whatever the exchange buffer + * size is with the underlying pstore backend (ie. EFI may be ~2KiB), which means an example +@@ -258,9 +258,9 @@ static int process_dmesg_files(PStoreList *list) { + } else if ((p = startswith(pe->dirent.d_name, "dmesg-erst-"))) { + /* For the ERST backend, the record is a monotonically increasing number, seeded as + * a timestamp. See linux/drivers/acpi/apei/erst.c in erst_writer(). */ +- uint64_t record_id; ++ unsigned long long record_id; + +- if (safe_atou64(p, &record_id) < 0) ++ if (safe_atollu_full(p, 10, &record_id) < 0) + continue; + if (last_record_id - 1 != record_id) + /* A discontinuity in the number has been detected, this current record id diff --git a/SOURCES/0253-pstore-avoid-opening-the-dmesg.txt-file-if-not-reque.patch b/SOURCES/0253-pstore-avoid-opening-the-dmesg.txt-file-if-not-reque.patch new file mode 100644 index 0000000..45aafcb --- /dev/null +++ b/SOURCES/0253-pstore-avoid-opening-the-dmesg.txt-file-if-not-reque.patch @@ -0,0 +1,68 @@ +From 4c6c7127a96f086b919b4c082b9da6b29f791bb8 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Fri, 28 Apr 2023 11:50:33 +0200 +Subject: [PATCH] pstore: avoid opening the dmesg.txt file if not requested + +Even with Storage=journal we would still attempt to open the final +dmesg.txt file which causes a lot of noise in the journal: + +``` +[ 5.764111] H testsuite-82.sh[658]: + systemctl start systemd-pstore +[ 5.806385] H systemd[1]: Starting modprobe@efi_pstore.service... +[ 5.808656] H systemd[1]: modprobe@efi_pstore.service: Deactivated successfully. +[ 5.808971] H systemd[1]: Finished modprobe@efi_pstore.service. +[ 5.818845] H kernel: audit: type=1130 audit(1682630623.637:114): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=modprobe@efi_pstore comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? termin> +[ 5.818865] H kernel: audit: type=1131 audit(1682630623.637:115): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=modprobe@efi_pstore comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? termin> +[ 5.816052] H systemd[1]: Starting systemd-pstore.service... +[ 5.840703] H systemd-pstore[806]: PStore dmesg-efi-168263062313014. +[ 5.841239] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.841428] H systemd-pstore[806]: PStore dmesg-efi-168263062312014. +[ 5.841575] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.841712] H systemd-pstore[806]: PStore dmesg-efi-168263062311014. +[ 5.841839] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.841989] H systemd-pstore[806]: PStore dmesg-efi-168263062310014. +[ 5.842141] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.842274] H systemd-pstore[806]: PStore dmesg-efi-168263062309014. +[ 5.842423] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.842589] H systemd-pstore[806]: PStore dmesg-efi-168263062308014. +[ 5.842722] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.842865] H systemd-pstore[806]: PStore dmesg-efi-168263062307014. +[ 5.843003] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.843153] H systemd-pstore[806]: PStore dmesg-efi-168263062306014. +[ 5.843280] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.843434] H systemd-pstore[806]: PStore dmesg-efi-168263062305014. +[ 5.843570] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.843702] H systemd-pstore[806]: PStore dmesg-efi-168263062304014. +[ 5.843831] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.843958] H systemd-pstore[806]: PStore dmesg-efi-168263062303014. +[ 5.844093] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.844250] H systemd-pstore[806]: PStore dmesg-efi-168263062302014. +[ 5.844412] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.844619] H systemd-pstore[806]: PStore dmesg-efi-168263062301014. +[ 5.844781] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.844956] H systemd-pstore[806]: PStore dmesg-efi-168263062300014. +[ 5.845168] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted +[ 5.851101] H systemd[1]: Finished systemd-pstore.service. +``` + +(cherry picked from commit ad5980803adac8dc1cf980447a07cb18962c238b) + +Related: #2170883 +--- + src/pstore/pstore.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c +index 066d8ebb81..7fff6cee62 100644 +--- a/src/pstore/pstore.c ++++ b/src/pstore/pstore.c +@@ -180,6 +180,9 @@ static int append_dmesg(PStoreEntry *pe, const char *subdir1, const char *subdir + + assert(pe); + ++ if (arg_storage != PSTORE_STORAGE_EXTERNAL) ++ return 0; ++ + if (pe->content_size == 0) + return 0; + diff --git a/SOURCES/0254-test-add-a-couple-of-tests-for-systemd-pstore.patch b/SOURCES/0254-test-add-a-couple-of-tests-for-systemd-pstore.patch new file mode 100644 index 0000000..ef45874 --- /dev/null +++ b/SOURCES/0254-test-add-a-couple-of-tests-for-systemd-pstore.patch @@ -0,0 +1,240 @@ +From 356247b0fb704e62bf378a7940a8190677358daa Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Thu, 27 Apr 2023 23:17:52 +0200 +Subject: [PATCH] test: add a couple of tests for systemd-pstore + +(cherry picked from commit 6858e32d730fd5574eaa3d7fbf4cb12aacaea336) + +Related: #2170883 +--- + test/units/testsuite-74.pstore.sh | 221 ++++++++++++++++++++++++++++++ + 1 file changed, 221 insertions(+) + create mode 100755 test/units/testsuite-74.pstore.sh + +diff --git a/test/units/testsuite-74.pstore.sh b/test/units/testsuite-74.pstore.sh +new file mode 100755 +index 0000000000..b4e442c1be +--- /dev/null ++++ b/test/units/testsuite-74.pstore.sh +@@ -0,0 +1,221 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++systemctl log-level info ++ ++if systemd-detect-virt -cq; then ++ echo "Running in a container, skipping the systemd-pstore test..." ++ exit 0 ++fi ++ ++DUMMY_DMESG_1="$(mktemp)" ++cat >"$DUMMY_DMESG_1" <<\EOF ++6,17159,5340096332127,-;usb 1-4: USB disconnect, device number 124 ++6,17160,5340109662397,-;input: WH-1000XM3 (AVRCP) as /devices/virtual/input/input293 ++6,17161,5343126458360,-;loop0: detected capacity change from 0 to 3145728 ++6,17162,5343126766065,-; loop0: p1 p2 ++6,17163,5343126815038,-;EXT4-fs (loop0p1): mounted filesystem with ordered data mode. Quota mode: none. ++6,17164,5343158037334,-;EXT4-fs (loop0p1): unmounting filesystem. ++6,17165,5343158072598,-;loop0: detected capacity change from 0 to 3145728 ++6,17166,5343158073563,-; loop0: p1 p2 ++6,17167,5343158074325,-; loop0: p1 p2 ++6,17168,5343158140859,-;EXT4-fs (loop0p1): mounted filesystem with ordered data mode. Quota mode: none. ++6,17169,5343158182977,-;EXT4-fs (loop0p1): unmounting filesystem. ++6,17170,5343158700241,-;loop0: detected capacity change from 0 to 3145728 ++6,17171,5343158700439,-; loop0: p1 p2 ++6,17172,5343158701120,-; loop0: p1 p2 ++EOF ++ ++DUMMY_DMESG_2="$(mktemp)" ++cat >"$DUMMY_DMESG_2" <<\EOF ++Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a quickstepu. ++Příliš žluťoučký kůň úpěl ďábelské ódy. ++Zvlášť zákeřný učeň s ďolíčky běží podél zóny úlů. ++Vyciď křišťálový nůž, ó učiň úděsné líbivým! ++Loď čeří kýlem tůň obzvlášť v Grónské úžině ++Ó, náhlý déšť již zvířil prach a čilá laň teď běží s houfcem gazel k úkrytům. ++Vypätá dcéra grófa Maxwella s IQ nižším ako kôň núti čeľaď hrýzť hŕbu jabĺk. ++Kŕdeľ šťastných ďatľov učí pri ústí Váhu mĺkveho koňa obhrýzať kôru a žrať čerstvé mäso. ++Stróż pchnął kość w quiz gędźb vel fax myjń. ++Portez ce vieux whisky au juge blond qui fume! ++EOF ++ ++file_count() { find "${1:?}" -type f | wc -l; } ++file_size() { wc -l <"${1:?}"; } ++random_efi_timestamp() { printf "%0.10d" "$((1000000000 + RANDOM))"; } ++ ++# The dmesg- filename contains the backend-type and the Common Platform Error Record, CPER, ++# record id, a 64-bit number. ++# ++# Files are processed in reverse lexigraphical order so as to properly reconstruct original dmesg. ++ ++prepare_efi_logs() { ++ local file="${1:?}" ++ local timestamp="${2:?}" ++ local chunk count filename ++ ++ # For the EFI backend, the 3 least significant digits of record id encodes a ++ # "count" number, the next 2 least significant digits for the dmesg part ++ # (chunk) number, and the remaining digits as the timestamp. See ++ # linux/drivers/firmware/efi/efi-pstore.c in efi_pstore_write(). ++ count="$(file_size "$file")" ++ chunk=0 ++ # The sed in the process substitution below just reverses the file ++ while read -r line; do ++ filename="$(printf "dmesg-efi-%0.10d%0.2d%0.3d" "$timestamp" "$chunk" "$count")" ++ echo "$line" >"/sys/fs/pstore/$filename" ++ chunk=$((chunk + 1)) ++ done < <(sed '1!G;h;$!d' "$file") ++ ++ if [[ "$chunk" -eq 0 ]]; then ++ echo >&2 "No dmesg-efi files were created" ++ exit 1 ++ fi ++} ++ ++prepare_erst_logs() { ++ local file="${1:?}" ++ local start_id="${2:?}" ++ local id filename ++ ++ # For the ERST backend, the record is a monotonically increasing number, seeded as ++ # a timestamp. See linux/drivers/acpi/apei/erst.c in erst_writer(). ++ id="$start_id" ++ # The sed in the process substitution below just reverses the file ++ while read -r line; do ++ filename="$(printf "dmesg-erst-%0.16d" "$id")" ++ echo "$line" >"/sys/fs/pstore/$filename" ++ id=$((id + 1)) ++ done < <(sed '1!G;h;$!d' "$file") ++ ++ if [[ "$id" -eq "$start_id" ]]; then ++ echo >&2 "No dmesg-erst files were created" ++ exit 1 ++ fi ++ ++ # ID of the last dmesg file will be the ID of the erst subfolder ++ echo "$((id - 1))" ++} ++ ++prepare_pstore_config() { ++ local storage="${1:?}" ++ local unlink="${2:?}" ++ ++ systemctl stop systemd-pstore ++ ++ rm -fr /sys/fs/pstore/* /var/lib/systemd/pstore/* ++ ++ mkdir -p /run/systemd/pstore.conf.d ++ cat >"/run/systemd/pstore.conf.d/99-test.conf" </sys/fs/pstore/foo.bar ++ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)" ++ start_pstore ++ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] ++ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]] ++ filename_1="$(printf "/var/lib/systemd/pstore/%s/%0.3d/dmesg.txt" "$timestamp_1" "$(file_size "$DUMMY_DMESG_1")")" ++ diff "$DUMMY_DMESG_1" "$filename_1" ++ filename_2="$(printf "/var/lib/systemd/pstore/%s/%0.3d/dmesg.txt" "$timestamp_2" "$(file_size "$DUMMY_DMESG_2")")" ++ diff "$DUMMY_DMESG_2" "$filename_2" ++ grep "hello world" "/var/lib/systemd/pstore/foo.bar" ++ ++ : "Backend: EFI; Storage: journal; Unlink: $unlink" ++ timestamp="$(random_efi_timestamp)" ++ prepare_pstore_config "journal" "$unlink" ++ prepare_efi_logs "$DUMMY_DMESG_1" "$timestamp" ++ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)" ++ start_pstore ++ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] ++ [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]] ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++ ++ : "Backend: ERST; Storage: external; Unlink: $unlink" ++ prepare_pstore_config "external" "$unlink" ++ last_id="$(prepare_erst_logs "$DUMMY_DMESG_1" 0)" ++ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)" ++ start_pstore ++ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] ++ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]] ++ # We always log to journal ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++ filename="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id")" ++ diff "$DUMMY_DMESG_1" "$filename" ++ ++ : "Backend: ERST; Storage: external; Unlink: $unlink; multiple dmesg files" ++ prepare_pstore_config "external" "$unlink" ++ last_id_1="$(prepare_erst_logs "$DUMMY_DMESG_1" 0)" ++ last_id_2="$(prepare_erst_logs "$DUMMY_DMESG_2" "$((last_id_1 + 10))")" ++ # Add one "random" (non-dmesg) file as well ++ echo "hello world" >/sys/fs/pstore/foo.bar ++ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)" ++ start_pstore ++ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] ++ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]] ++ filename_1="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id_1")" ++ diff "$DUMMY_DMESG_1" "$filename_1" ++ filename_2="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id_2")" ++ diff "$DUMMY_DMESG_2" "$filename_2" ++ grep "hello world" "/var/lib/systemd/pstore/foo.bar" ++ ++ : "Backend: ERST; Storage: journal; Unlink: $unlink" ++ prepare_pstore_config "journal" "$unlink" ++ last_id="$(prepare_erst_logs "$DUMMY_DMESG_1" 0)" ++ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)" ++ start_pstore ++ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] ++ [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]] ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++done diff --git a/SOURCES/0255-test-match-all-messages-with-the-FILE-field.patch b/SOURCES/0255-test-match-all-messages-with-the-FILE-field.patch new file mode 100644 index 0000000..eaaef05 --- /dev/null +++ b/SOURCES/0255-test-match-all-messages-with-the-FILE-field.patch @@ -0,0 +1,57 @@ +From ea861dba363ac970a838a183c71e333f9f201f02 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Sat, 29 Apr 2023 09:33:18 +0200 +Subject: [PATCH] test: match all messages with the FILE field + +As the systemd-pstore process is quite short lived, it might sometimes +lack the necessary metadata to make matching against a unit or a syslog +tag work. Since we already use a cursor file to make the matching window +small as possible, let's just drop the unit match completely and hope +for the best. + +Resolves: #27453 +(cherry picked from commit edea0d6ac57610b7af603b833b19a846327e3638) + +Related: #2170883 +--- + test/units/testsuite-74.pstore.sh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/test/units/testsuite-74.pstore.sh b/test/units/testsuite-74.pstore.sh +index b4e442c1be..b8bf5534a1 100755 +--- a/test/units/testsuite-74.pstore.sh ++++ b/test/units/testsuite-74.pstore.sh +@@ -150,7 +150,7 @@ for unlink in yes no; do + [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] + [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]] + # We always log to journal +- diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") + filename="$(printf "/var/lib/systemd/pstore/%s/%0.3d/dmesg.txt" "$timestamp" "$(file_size "$DUMMY_DMESG_1")")" + diff "$DUMMY_DMESG_1" "$filename" + +@@ -180,7 +180,7 @@ for unlink in yes no; do + start_pstore + [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] + [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]] +- diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") + + : "Backend: ERST; Storage: external; Unlink: $unlink" + prepare_pstore_config "external" "$unlink" +@@ -190,7 +190,7 @@ for unlink in yes no; do + [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] + [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]] + # We always log to journal +- diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") + filename="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id")" + diff "$DUMMY_DMESG_1" "$filename" + +@@ -217,5 +217,5 @@ for unlink in yes no; do + start_pstore + [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]] + [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]] +- diff "$DUMMY_DMESG_1" <(journalctl -o cat -u systemd-pstore --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") ++ diff "$DUMMY_DMESG_1" <(journalctl -o cat --output-fields=FILE --cursor-file=/tmp/journal.cursor | sed "/^$/d") + done diff --git a/SOURCES/0256-test-build-the-SELinux-test-module-on-the-host.patch b/SOURCES/0256-test-build-the-SELinux-test-module-on-the-host.patch new file mode 100644 index 0000000..7bbcf42 --- /dev/null +++ b/SOURCES/0256-test-build-the-SELinux-test-module-on-the-host.patch @@ -0,0 +1,116 @@ +From 0baa19a28f07328fa4357efc97a522bc0e29f74e Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Fri, 19 May 2023 11:45:11 +0200 +Subject: [PATCH] test: build the SELinux test module on the host + +Let's save some time and build the SELinux test module on the host +instead of a possibly unaccelerated VM. This brings the runtime of +TEST-06-SELINUX from ~12 minutes down to a ~1 minute. + +(cherry picked from commit 038efe6df154b04a4c2a1d9da7263e5f49d2a1b0) + +Related: #2170883 +--- + test/TEST-06-SELINUX/test.sh | 68 ++++++++++--------- + .../load-systemd-test-module.service | 2 +- + 2 files changed, 36 insertions(+), 34 deletions(-) + +diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh +index a867dea4b7..5d72638ec6 100755 +--- a/test/TEST-06-SELINUX/test.sh ++++ b/test/TEST-06-SELINUX/test.sh +@@ -7,7 +7,6 @@ IMAGE_NAME="selinux" + TEST_NO_NSPAWN=1 + + # Requirements: +-# Fedora 23 + # selinux-policy-targeted + # selinux-policy-devel + +@@ -21,38 +20,41 @@ SETUP_SELINUX=yes + KERNEL_APPEND="${KERNEL_APPEND:=} selinux=1 security=selinux" + + test_append_files() { +- ( +- local workspace="${1:?}" +- local policy_headers_dir=/usr/share/selinux/devel +- local modules_dir=/var/lib/selinux +- +- setup_selinux +- # Make sure we never expand this to "/..." +- rm -rf "${workspace:?}/$modules_dir" +- +- if ! cp -ar "$modules_dir" "$workspace/$modules_dir"; then +- dfatal "Failed to copy $modules_dir" +- exit 1 +- fi +- +- rm -rf "${workspace:?}/$policy_headers_dir" +- inst_dir /usr/share/selinux +- +- if ! cp -ar "$policy_headers_dir" "$workspace/$policy_headers_dir"; then +- dfatal "Failed to copy $policy_headers_dir" +- exit 1 +- fi +- +- mkdir "$workspace/systemd-test-module" +- cp systemd_test.te "$workspace/systemd-test-module" +- cp systemd_test.if "$workspace/systemd-test-module" +- cp systemd_test.fc "$workspace/systemd-test-module" +- image_install -o sesearch +- image_install runcon +- image_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile +- image_install -o /usr/libexec/selinux/hll/pp # Fedora/RHEL/... +- image_install -o /usr/lib/selinux/hll/pp # Debian/Ubuntu/... +- ) ++ local workspace="${1:?}" ++ local policy_headers_dir=/usr/share/selinux/devel ++ local modules_dir=/var/lib/selinux ++ ++ setup_selinux ++ # Make sure we never expand this to "/..." ++ rm -rf "${workspace:?}/$modules_dir" ++ ++ if ! cp -ar "$modules_dir" "$workspace/$modules_dir"; then ++ dfatal "Failed to copy $modules_dir" ++ exit 1 ++ fi ++ ++ rm -rf "${workspace:?}/$policy_headers_dir" ++ inst_dir /usr/share/selinux ++ ++ if ! cp -ar "$policy_headers_dir" "$workspace/$policy_headers_dir"; then ++ dfatal "Failed to copy $policy_headers_dir" ++ exit 1 ++ fi ++ ++ mkdir "$workspace/systemd-test-module" ++ cp systemd_test.te "$workspace/systemd-test-module" ++ cp systemd_test.if "$workspace/systemd-test-module" ++ cp systemd_test.fc "$workspace/systemd-test-module" ++ image_install -o sesearch ++ image_install runcon ++ image_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile ++ image_install -o /usr/libexec/selinux/hll/pp # Fedora/RHEL/... ++ image_install -o /usr/lib/selinux/hll/pp # Debian/Ubuntu/... ++ ++ if ! chroot "$workspace" make -C /systemd-test-module -f /usr/share/selinux/devel/Makefile clean systemd_test.pp; then ++ dfatal "Failed to build the systemd test module" ++ exit 1 ++ fi + } + + do_test "$@" +diff --git a/test/testsuite-06.units/load-systemd-test-module.service b/test/testsuite-06.units/load-systemd-test-module.service +index 3a22c15b25..2d15a62715 100644 +--- a/test/testsuite-06.units/load-systemd-test-module.service ++++ b/test/testsuite-06.units/load-systemd-test-module.service +@@ -9,7 +9,7 @@ Before=sysinit.target shutdown.target autorelabel.service + ConditionSecurity=selinux + + [Service] +-ExecStart=sh -x -c 'echo 0 >/sys/fs/selinux/enforce && cd /systemd-test-module && make -f /usr/share/selinux/devel/Makefile clean load' ++ExecStart=sh -x -c 'echo 0 >/sys/fs/selinux/enforce && make -C /systemd-test-module -f /usr/share/selinux/devel/Makefile load' + Type=oneshot + TimeoutSec=0 + RemainAfterExit=yes diff --git a/SOURCES/0257-test-make-the-stress-test-slightly-less-stressful-on.patch b/SOURCES/0257-test-make-the-stress-test-slightly-less-stressful-on.patch new file mode 100644 index 0000000..43d5b7d --- /dev/null +++ b/SOURCES/0257-test-make-the-stress-test-slightly-less-stressful-on.patch @@ -0,0 +1,32 @@ +From 36426e030fc9f2afc5926b2c484b9943f9970529 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Fri, 19 May 2023 10:48:15 +0200 +Subject: [PATCH] test: make the stress test slightly less stressful on slower + machines + +Without acceleration this part of the test takes over 10 minutes (!), +which feels quite unnecessary. Let's cut down the number of stuff we +dump to the journal in such case, but keep the original value if we run +with acceleration (since in that case it takes less than 10 seconds). + +(cherry picked from commit ff40235b9bd2a944131c36b1c7ccfd88f49a194e) + +Related: #2170883 +--- + test/units/testsuite-04.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/test/units/testsuite-04.sh b/test/units/testsuite-04.sh +index bb41045809..b5ff2ff704 100755 +--- a/test/units/testsuite-04.sh ++++ b/test/units/testsuite-04.sh +@@ -8,7 +8,8 @@ trap "journalctl --rotate --vacuum-size=16M" EXIT + + # Rotation/flush test, see https://github.com/systemd/systemd/issues/19895 + journalctl --relinquish-var +-for _ in {0..50}; do ++[[ "$(systemd-detect-virt -v)" == "qemu" ]] && ITERATIONS=10 || ITERATIONS=50 ++for ((i = 0; i < ITERATIONS; i++)); do + dd if=/dev/urandom bs=1M count=1 | base64 | systemd-cat + done + journalctl --rotate diff --git a/SOURCES/0258-coredump-use-unaligned_read_ne-32-64-to-parse-auxv.patch b/SOURCES/0258-coredump-use-unaligned_read_ne-32-64-to-parse-auxv.patch new file mode 100644 index 0000000..c9c0f0b --- /dev/null +++ b/SOURCES/0258-coredump-use-unaligned_read_ne-32-64-to-parse-auxv.patch @@ -0,0 +1,202 @@ +From 58aba81d1e530d53e462ec4ae542570cd537264a Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 22 Mar 2023 08:49:49 +0900 +Subject: [PATCH] coredump: use unaligned_read_ne{32,64}() to parse auxv + +Fixes a bug introduced by 3e4d0f6cf99f8677edd6a237382a65bfe758de03. + +The auxv metadata is unaligned, as the length of the prefix +"COREDUMP_PROC_AUXV=" is 19. Hence, parse_auxv{32,64}() may triger +an undefined behavior (or at least cause slow down), which can be +detected when running on an undefined behavior sanitizer. + +This also introduces a macro to define `parse_auxv{32,64}()`. + +Fixes #26912. + +(cherry picked from commit 9b032f932c4172fac379234d9d42cf2b266ccaea) + +Related: #2170883 +--- + src/coredump/coredump.c | 149 ++++++++++++++++------------------------ + 1 file changed, 60 insertions(+), 89 deletions(-) + +diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c +index ea3d8c415a..b9c5f3ad04 100644 +--- a/src/coredump/coredump.c ++++ b/src/coredump/coredump.c +@@ -48,6 +48,7 @@ + #include "sync-util.h" + #include "tmpfile-util.h" + #include "uid-alloc-range.h" ++#include "unaligned.h" + #include "user-util.h" + + /* The maximum size up to which we process coredumps. We use 1G on 32bit systems, and 32G on 64bit systems */ +@@ -339,95 +340,65 @@ static int make_filename(const Context *context, char **ret) { + return 0; + } + +-static int parse_auxv64( +- const uint64_t *auxv, +- size_t size_bytes, +- int *at_secure, +- uid_t *uid, +- uid_t *euid, +- gid_t *gid, +- gid_t *egid) { +- +- assert(auxv || size_bytes == 0); +- +- if (size_bytes % (2 * sizeof(uint64_t)) != 0) +- return log_warning_errno(SYNTHETIC_ERRNO(EIO), "Incomplete auxv structure (%zu bytes).", size_bytes); +- +- size_t words = size_bytes / sizeof(uint64_t); +- +- /* Note that we set output variables even on error. */ +- +- for (size_t i = 0; i + 1 < words; i += 2) +- switch (auxv[i]) { +- case AT_SECURE: +- *at_secure = auxv[i + 1] != 0; +- break; +- case AT_UID: +- *uid = auxv[i + 1]; +- break; +- case AT_EUID: +- *euid = auxv[i + 1]; +- break; +- case AT_GID: +- *gid = auxv[i + 1]; +- break; +- case AT_EGID: +- *egid = auxv[i + 1]; +- break; +- case AT_NULL: +- if (auxv[i + 1] != 0) +- goto error; +- return 0; +- } +- error: +- return log_warning_errno(SYNTHETIC_ERRNO(ENODATA), +- "AT_NULL terminator not found, cannot parse auxv structure."); +-} +- +-static int parse_auxv32( +- const uint32_t *auxv, +- size_t size_bytes, +- int *at_secure, +- uid_t *uid, +- uid_t *euid, +- gid_t *gid, +- gid_t *egid) { +- +- assert(auxv || size_bytes == 0); +- +- size_t words = size_bytes / sizeof(uint32_t); +- +- if (size_bytes % (2 * sizeof(uint32_t)) != 0) +- return log_warning_errno(SYNTHETIC_ERRNO(EIO), "Incomplete auxv structure (%zu bytes).", size_bytes); ++#define _DEFINE_PARSE_AUXV(size, type, unaligned_read) \ ++ static int parse_auxv##size( \ ++ const void *auxv, \ ++ size_t size_bytes, \ ++ int *at_secure, \ ++ uid_t *uid, \ ++ uid_t *euid, \ ++ gid_t *gid, \ ++ gid_t *egid) { \ ++ \ ++ assert(auxv || size_bytes == 0); \ ++ \ ++ if (size_bytes % (2 * sizeof(type)) != 0) \ ++ return log_warning_errno(SYNTHETIC_ERRNO(EIO), \ ++ "Incomplete auxv structure (%zu bytes).", \ ++ size_bytes); \ ++ \ ++ size_t words = size_bytes / sizeof(type); \ ++ \ ++ /* Note that we set output variables even on error. */ \ ++ \ ++ for (size_t i = 0; i + 1 < words; i += 2) { \ ++ type key, val; \ ++ \ ++ key = unaligned_read((uint8_t*) auxv + i * sizeof(type)); \ ++ val = unaligned_read((uint8_t*) auxv + (i + 1) * sizeof(type)); \ ++ \ ++ switch (key) { \ ++ case AT_SECURE: \ ++ *at_secure = val != 0; \ ++ break; \ ++ case AT_UID: \ ++ *uid = val; \ ++ break; \ ++ case AT_EUID: \ ++ *euid = val; \ ++ break; \ ++ case AT_GID: \ ++ *gid = val; \ ++ break; \ ++ case AT_EGID: \ ++ *egid = val; \ ++ break; \ ++ case AT_NULL: \ ++ if (val != 0) \ ++ goto error; \ ++ return 0; \ ++ } \ ++ } \ ++ error: \ ++ return log_warning_errno(SYNTHETIC_ERRNO(ENODATA), \ ++ "AT_NULL terminator not found, cannot parse auxv structure."); \ ++ } + +- /* Note that we set output variables even on error. */ ++#define DEFINE_PARSE_AUXV(size)\ ++ _DEFINE_PARSE_AUXV(size, uint##size##_t, unaligned_read_ne##size) + +- for (size_t i = 0; i + 1 < words; i += 2) +- switch (auxv[i]) { +- case AT_SECURE: +- *at_secure = auxv[i + 1] != 0; +- break; +- case AT_UID: +- *uid = auxv[i + 1]; +- break; +- case AT_EUID: +- *euid = auxv[i + 1]; +- break; +- case AT_GID: +- *gid = auxv[i + 1]; +- break; +- case AT_EGID: +- *egid = auxv[i + 1]; +- break; +- case AT_NULL: +- if (auxv[i + 1] != 0) +- goto error; +- return 0; +- } +- error: +- return log_warning_errno(SYNTHETIC_ERRNO(ENODATA), +- "AT_NULL terminator not found, cannot parse auxv structure."); +-} ++DEFINE_PARSE_AUXV(32); ++DEFINE_PARSE_AUXV(64); + + static int grant_user_access(int core_fd, const Context *context) { + int at_secure = -1; +@@ -464,11 +435,11 @@ static int grant_user_access(int core_fd, const Context *context) { + "Core file has non-native endianness, not adjusting permissions."); + + if (elf[EI_CLASS] == ELFCLASS64) +- r = parse_auxv64((const uint64_t*) context->meta[META_PROC_AUXV], ++ r = parse_auxv64(context->meta[META_PROC_AUXV], + context->meta_size[META_PROC_AUXV], + &at_secure, &uid, &euid, &gid, &egid); + else +- r = parse_auxv32((const uint32_t*) context->meta[META_PROC_AUXV], ++ r = parse_auxv32(context->meta[META_PROC_AUXV], + context->meta_size[META_PROC_AUXV], + &at_secure, &uid, &euid, &gid, &egid); + if (r < 0) diff --git a/SOURCES/0259-core-transaction-make-merge_unit_ids-always-return-N.patch b/SOURCES/0259-core-transaction-make-merge_unit_ids-always-return-N.patch new file mode 100644 index 0000000..3ad1378 --- /dev/null +++ b/SOURCES/0259-core-transaction-make-merge_unit_ids-always-return-N.patch @@ -0,0 +1,57 @@ +From 1c7d14785d8975df5f6400d22fa5eae4693f7288 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sat, 18 Mar 2023 12:12:01 +0900 +Subject: [PATCH] core/transaction: make merge_unit_ids() always return + NUL-terminated string + +Follow-up for 924775e8ce49817f96df19c2b06356c12ecfc754. + +The loop run with `STRV_FOREACH_PAIR()`, hence `if (*(unit_id+1))` is +not a good way to detect if there exist a next entry. + +Fixes #26872. + +(cherry picked from commit 366eced4c81a15a25b9225347fa203aa67798b02) + +Related: #2170883 +--- + src/core/transaction.c | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/src/core/transaction.c b/src/core/transaction.c +index 8ec853d58d..043998078c 100644 +--- a/src/core/transaction.c ++++ b/src/core/transaction.c +@@ -323,22 +323,25 @@ _pure_ static bool unit_matters_to_anchor(Unit *u, Job *job) { + return false; + } + +-static char* merge_unit_ids(const char* unit_log_field, char **pairs) { +- char *ans = NULL; +- size_t size = 0, next; ++static char* merge_unit_ids(const char* unit_log_field, char * const* pairs) { ++ _cleanup_free_ char *ans = NULL; ++ size_t size = 0; + + STRV_FOREACH_PAIR(unit_id, job_type, pairs) { ++ size_t next; ++ ++ if (size > 0) ++ ans[size - 1] = '\n'; ++ + next = strlen(unit_log_field) + strlen(*unit_id); + if (!GREEDY_REALLOC(ans, size + next + 1)) +- return mfree(ans); ++ return NULL; + + sprintf(ans + size, "%s%s", unit_log_field, *unit_id); +- if (*(unit_id+1)) +- ans[size + next] = '\n'; + size += next + 1; + } + +- return ans; ++ return TAKE_PTR(ans); + } + + static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, sd_bus_error *e) { diff --git a/SOURCES/0260-core-transaction-make-merge_unit_ids-return-non-NULL.patch b/SOURCES/0260-core-transaction-make-merge_unit_ids-return-non-NULL.patch new file mode 100644 index 0000000..fc68b6e --- /dev/null +++ b/SOURCES/0260-core-transaction-make-merge_unit_ids-return-non-NULL.patch @@ -0,0 +1,27 @@ +From dbdeb09d8893a680c8241b4af3fd096c7aabe03f Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sat, 18 Mar 2023 12:17:54 +0900 +Subject: [PATCH] core/transaction: make merge_unit_ids() return non-NULL on + success + +(cherry picked from commit 999f16514367224cbc50cb3ccc1e4392e43f6811) + +Related: #2170883 +--- + src/core/transaction.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/core/transaction.c b/src/core/transaction.c +index 043998078c..7c862f35be 100644 +--- a/src/core/transaction.c ++++ b/src/core/transaction.c +@@ -341,6 +341,9 @@ static char* merge_unit_ids(const char* unit_log_field, char * const* pairs) { + size += next + 1; + } + ++ if (!ans) ++ return strdup(""); ++ + return TAKE_PTR(ans); + } + diff --git a/SOURCES/0261-core-transaction-do-not-log-null.patch b/SOURCES/0261-core-transaction-do-not-log-null.patch new file mode 100644 index 0000000..a30a0fe --- /dev/null +++ b/SOURCES/0261-core-transaction-do-not-log-null.patch @@ -0,0 +1,45 @@ +From 8e0b41ea9bf9afedcda713934f424b17195f9add Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sat, 18 Mar 2023 12:15:10 +0900 +Subject: [PATCH] core/transaction: do not log "(null)" + +As we ignores the failure in merge_unit_ids(), so unit_ids may be NULL. + +(cherry picked from commit 5803c24da5cf543a55c4fce9009a9c5f2b18519a) + +Related: #2170883 +--- + src/core/transaction.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/core/transaction.c b/src/core/transaction.c +index 7c862f35be..bb51f51318 100644 +--- a/src/core/transaction.c ++++ b/src/core/transaction.c +@@ -400,7 +400,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi + "Found %s on %s/%s", + unit_id == array ? "ordering cycle" : "dependency", + *unit_id, *job_type), +- "%s", unit_ids); ++ "%s", strna(unit_ids)); + + if (delete) { + const char *status; +@@ -410,7 +410,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi + "Job %s/%s deleted to break ordering cycle starting with %s/%s", + delete->unit->id, job_type_to_string(delete->type), + j->unit->id, job_type_to_string(j->type)), +- "%s", unit_ids); ++ "%s", strna(unit_ids)); + + if (log_get_show_color()) + status = ANSI_HIGHLIGHT_RED " SKIP " ANSI_NORMAL; +@@ -429,7 +429,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi + log_struct(LOG_ERR, + LOG_UNIT_MESSAGE(j->unit, "Unable to break cycle starting with %s/%s", + j->unit->id, job_type_to_string(j->type)), +- "%s", unit_ids); ++ "%s", strna(unit_ids)); + + return sd_bus_error_setf(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, + "Transaction order is cyclic. See system logs for details."); diff --git a/SOURCES/0262-ci-allow-RHEL-only-labels-to-mark-downstream-only-co.patch b/SOURCES/0262-ci-allow-RHEL-only-labels-to-mark-downstream-only-co.patch new file mode 100644 index 0000000..0a4ea8b --- /dev/null +++ b/SOURCES/0262-ci-allow-RHEL-only-labels-to-mark-downstream-only-co.patch @@ -0,0 +1,24 @@ +From ea5817de22075c8770775e8ee113a90417517fee Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Mon, 10 Jul 2023 12:31:05 +0200 +Subject: [PATCH] ci: allow `RHEL-only` labels to mark downstream-only commits + +RHEL-only + +Related: #2170883 +--- + .github/advanced-commit-linter.yml | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml +index 491836abbb..327af0467a 100644 +--- a/.github/advanced-commit-linter.yml ++++ b/.github/advanced-commit-linter.yml +@@ -6,6 +6,7 @@ policy: + exception: + note: + - rhel-only ++ - RHEL-only + tracker: + - keyword: + - 'Resolves: #?' diff --git a/SOURCES/0246-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch b/SOURCES/0263-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch similarity index 97% rename from SOURCES/0246-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch rename to SOURCES/0263-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch index fef3ddf..62f468d 100644 --- a/SOURCES/0246-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch +++ b/SOURCES/0263-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch @@ -1,4 +1,4 @@ -From ea011ddb65272c74d6378deae3f3a3365aadd77d Mon Sep 17 00:00:00 2001 +From 7924438d595c7c77ead2e9ed475212fab7792fe4 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Tue, 20 Jun 2023 16:06:31 +0000 Subject: [PATCH] elf-util: discard PT_LOAD segment early based on the start @@ -47,7 +47,7 @@ https://sourceware.org/pipermail/elfutils-devel/2023q2/006225.html. (cherry picked from commit 21a2c735e2bfdc3bfdc42f894d6e3d00f4a38dcd) -Resolves: #2222259 +Resolves: #2215412 --- src/shared/elf-util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SOURCES/0247-elf-util-check-for-overflow-when-computing-end-of-co.patch b/SOURCES/0264-elf-util-check-for-overflow-when-computing-end-of-co.patch similarity index 95% rename from SOURCES/0247-elf-util-check-for-overflow-when-computing-end-of-co.patch rename to SOURCES/0264-elf-util-check-for-overflow-when-computing-end-of-co.patch index d3e2bcf..533926c 100644 --- a/SOURCES/0247-elf-util-check-for-overflow-when-computing-end-of-co.patch +++ b/SOURCES/0264-elf-util-check-for-overflow-when-computing-end-of-co.patch @@ -1,4 +1,4 @@ -From 2fcb340ec5faf51a8d9b0cb2ddd8386b4db6a33d Mon Sep 17 00:00:00 2001 +From 57d92dd0f1fd55f2bb2ff7f4228ca01b29dbd054 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Thu, 22 Jun 2023 16:05:18 +0000 Subject: [PATCH] elf-util: check for overflow when computing end of core's @@ -6,7 +6,7 @@ Subject: [PATCH] elf-util: check for overflow when computing end of core's (cherry picked from commit 3965f173eae4701a014113cfaf4a28a6bb63bed7) -Resolves: #2222259 +Related: #2215412 --- src/shared/elf-util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SOURCES/0265-sulogin-use-DEFINE_MAIN_FUNCTION.patch b/SOURCES/0265-sulogin-use-DEFINE_MAIN_FUNCTION.patch new file mode 100644 index 0000000..c5d2778 --- /dev/null +++ b/SOURCES/0265-sulogin-use-DEFINE_MAIN_FUNCTION.patch @@ -0,0 +1,46 @@ +From b3053fa0f83a55bb9fb8148eab51089171da21cb Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Tue, 14 Feb 2023 22:10:13 -0500 +Subject: [PATCH] sulogin: use DEFINE_MAIN_FUNCTION() + +Let's use DEFINE_MAIN_FUNCTION() as the other commands for consistency. + +This commit should be no functional change. + +(cherry picked from commit 2ffbf44344983d64949e032e74edb19c48b16cc0) + +Related: #2169959 +--- + src/sulogin-shell/sulogin-shell.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c +index 5648dfd83b..e3601de8d4 100644 +--- a/src/sulogin-shell/sulogin-shell.c ++++ b/src/sulogin-shell/sulogin-shell.c +@@ -14,6 +14,7 @@ + #include "def.h" + #include "env-util.h" + #include "log.h" ++#include "main-func.h" + #include "process-util.h" + #include "signal-util.h" + #include "special.h" +@@ -86,7 +87,7 @@ static void print_mode(const char* mode) { + fflush(stdout); + } + +-int main(int argc, char *argv[]) { ++static int run(int argc, char *argv[]) { + const char* sulogin_cmdline[] = { + SULOGIN, + NULL, /* --force */ +@@ -115,5 +116,7 @@ int main(int argc, char *argv[]) { + r = start_default_target(bus); + } + +- return r >= 0 ? EXIT_SUCCESS : EXIT_FAILURE; ++ return r; + } ++ ++DEFINE_MAIN_FUNCTION(run); diff --git a/SOURCES/0266-sulogin-fix-control-lost-of-the-current-terminal-whe.patch b/SOURCES/0266-sulogin-fix-control-lost-of-the-current-terminal-whe.patch new file mode 100644 index 0000000..5ad5216 --- /dev/null +++ b/SOURCES/0266-sulogin-fix-control-lost-of-the-current-terminal-whe.patch @@ -0,0 +1,131 @@ +From 348854f8023fa6233ce7549b32eb8319b91c24e6 Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Sun, 12 Feb 2023 12:15:08 +0000 +Subject: [PATCH] sulogin: fix control lost of the current terminal when + default.target is rescue.target + +When default.target is rescue.target, exiting from the single-user shell +results in lost of the control of the current terminal. This is because the +operation performed to continue to boot is systemctl default but default.target +is now rescue.target and it is already active. Hence, no new process that +controls the current terminal is created. Users need to make hardware reset to +recover the situation. + +This sounds like a bit corner case issue and some might feel configuring +default.target as rescue.target is odd because there are several other ways to +transition to rescue.mode without configuring default.target to rescue.target +such as systemctl rescue or systemd.unit=rescue.target something like +that. However, users unfamiliar with systemd operations tend to come up with +systemctl set-default rescue.target. + +To fix this issue, let's transition to default.target only when default.target +is inactive. Otherwise, invoke the single-user shell again to keep control of +the current terminal for users. + +This new logic depends on whether D-Bus working well. Exiting without any check +of result of systemctl default could lead to again the control lost of the +current terminal. Hence, add checking results of each D-Bus operations +including systemctl default and invoke the single-user shell if they fail. + +(cherry picked from commit 937ca8330d11e406b8ef343bead6f4f6244e39c7) + +Resolves: #2169959 +--- + src/sulogin-shell/sulogin-shell.c | 59 +++++++++++++++++++++++++------ + 1 file changed, 49 insertions(+), 10 deletions(-) + +diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c +index e3601de8d4..f1660c69e0 100644 +--- a/src/sulogin-shell/sulogin-shell.c ++++ b/src/sulogin-shell/sulogin-shell.c +@@ -18,6 +18,7 @@ + #include "process-util.h" + #include "signal-util.h" + #include "special.h" ++#include "unit-def.h" + + static int reload_manager(sd_bus *bus) { + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; +@@ -42,6 +43,28 @@ static int reload_manager(sd_bus *bus) { + return 0; + } + ++static int default_target_is_inactive(sd_bus *bus) { ++ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; ++ _cleanup_free_ char *path = NULL, *state = NULL; ++ int r; ++ ++ path = unit_dbus_path_from_name(SPECIAL_DEFAULT_TARGET); ++ if (!path) ++ return log_oom(); ++ ++ r = sd_bus_get_property_string(bus, ++ "org.freedesktop.systemd1", ++ path, ++ "org.freedesktop.systemd1.Unit", ++ "ActiveState", ++ &error, ++ &state); ++ if (r < 0) ++ return log_error_errno(r, "Failed to retrieve unit state: %s", bus_error_message(&error, r)); ++ ++ return streq_ptr(state, "inactive"); ++} ++ + static int start_default_target(sd_bus *bus) { + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; +@@ -93,7 +116,6 @@ static int run(int argc, char *argv[]) { + NULL, /* --force */ + NULL + }; +- _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; + int r; + + log_setup(); +@@ -104,19 +126,36 @@ static int run(int argc, char *argv[]) { + /* allows passwordless logins if root account is locked. */ + sulogin_cmdline[1] = "--force"; + +- (void) fork_wait(sulogin_cmdline); ++ for (;;) { ++ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; ++ ++ (void) fork_wait(sulogin_cmdline); ++ ++ r = bus_connect_system_systemd(&bus); ++ if (r < 0) { ++ log_warning_errno(r, "Failed to get D-Bus connection: %m"); ++ goto fallback; ++ } + +- r = bus_connect_system_systemd(&bus); +- if (r < 0) { +- log_warning_errno(r, "Failed to get D-Bus connection: %m"); +- r = 0; +- } else { +- (void) reload_manager(bus); ++ if (reload_manager(bus) < 0) ++ goto fallback; + +- r = start_default_target(bus); ++ r = default_target_is_inactive(bus); ++ if (r < 0) ++ goto fallback; ++ if (!r) { ++ log_warning(SPECIAL_DEFAULT_TARGET" is not inactive. Please review the "SPECIAL_DEFAULT_TARGET" setting.\n"); ++ goto fallback; ++ } ++ ++ if (start_default_target(bus) >= 0) ++ break; ++ ++ fallback: ++ log_warning("Fallback to the single-user shell.\n"); + } + +- return r; ++ return 0; + } + + DEFINE_MAIN_FUNCTION(run); diff --git a/SOURCES/0267-journal-vacuum-count-size-of-all-journal-files.patch b/SOURCES/0267-journal-vacuum-count-size-of-all-journal-files.patch new file mode 100644 index 0000000..896db74 --- /dev/null +++ b/SOURCES/0267-journal-vacuum-count-size-of-all-journal-files.patch @@ -0,0 +1,90 @@ +From 407e6bbb46a67200ea27a04c10c931dba9727cdd Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Wed, 22 Mar 2023 12:36:54 +0100 +Subject: [PATCH] journal-vacuum: count size of all journal files + +Currently, active journal files are excluded, which means that vacuuming +may not remove anything even if *MaxUse= has been exceeded. + +(cherry picked from commit 9ea46af4f2368b41d57705bac09774778126507f) + +Resolves: #2182632 +--- + src/libsystemd/sd-journal/journal-vacuum.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/src/libsystemd/sd-journal/journal-vacuum.c b/src/libsystemd/sd-journal/journal-vacuum.c +index eac3500202..23497af28e 100644 +--- a/src/libsystemd/sd-journal/journal-vacuum.c ++++ b/src/libsystemd/sd-journal/journal-vacuum.c +@@ -158,6 +158,8 @@ int journal_directory_vacuum( + if (!S_ISREG(st.st_mode)) + continue; + ++ size = 512UL * (uint64_t) st.st_blocks; ++ + q = strlen(de->d_name); + + if (endswith(de->d_name, ".journal")) { +@@ -167,6 +169,7 @@ int journal_directory_vacuum( + + if (q < 1 + 32 + 1 + 16 + 1 + 16 + 8) { + n_active_files++; ++ sum += size; + continue; + } + +@@ -174,6 +177,7 @@ int journal_directory_vacuum( + de->d_name[q-8-16-1-16-1] != '-' || + de->d_name[q-8-16-1-16-1-32-1] != '@') { + n_active_files++; ++ sum += size; + continue; + } + +@@ -186,11 +190,13 @@ int journal_directory_vacuum( + de->d_name[q-8-16-1-16-1] = 0; + if (sd_id128_from_string(de->d_name + q-8-16-1-16-1-32, &seqnum_id) < 0) { + n_active_files++; ++ sum += size; + continue; + } + + if (sscanf(de->d_name + q-8-16-1-16, "%16llx-%16llx.journal", &seqnum, &realtime) != 2) { + n_active_files++; ++ sum += size; + continue; + } + +@@ -206,12 +212,14 @@ int journal_directory_vacuum( + + if (q < 1 + 16 + 1 + 16 + 8 + 1) { + n_active_files++; ++ sum += size; + continue; + } + + if (de->d_name[q-1-8-16-1] != '-' || + de->d_name[q-1-8-16-1-16-1] != '@') { + n_active_files++; ++ sum += size; + continue; + } + +@@ -223,6 +231,7 @@ int journal_directory_vacuum( + + if (sscanf(de->d_name + q-1-8-16-1-16, "%16llx-%16llx.journal~", &realtime, &tmp) != 2) { + n_active_files++; ++ sum += size; + continue; + } + +@@ -233,8 +242,6 @@ int journal_directory_vacuum( + continue; + } + +- size = 512UL * (uint64_t) st.st_blocks; +- + r = journal_file_empty(dirfd(d), p); + if (r < 0) { + log_debug_errno(r, "Failed check if %s is empty, ignoring: %m", p); diff --git a/SOURCES/0268-memory-util-add-a-concept-for-gcc-cleanup-attribute-.patch b/SOURCES/0268-memory-util-add-a-concept-for-gcc-cleanup-attribute-.patch new file mode 100644 index 0000000..2fc5a0e --- /dev/null +++ b/SOURCES/0268-memory-util-add-a-concept-for-gcc-cleanup-attribute-.patch @@ -0,0 +1,133 @@ +From f49fbc3ebbb026f87b974c11c40808cc777bd277 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 22 Feb 2023 23:10:25 +0100 +Subject: [PATCH] memory-util: add a concept for gcc cleanup attribute based + array destruction + +(cherry picked from commit ff3f1464ec2dd40c9d8eb92e1474cb4d1c8c676b) + +Related: #2182632 +--- + src/basic/alloc-util.h | 1 + + src/basic/memory-util.h | 34 +++++++++++++++++++++++++++++ + src/test/meson.build | 2 ++ + src/test/test-memory-util.c | 43 +++++++++++++++++++++++++++++++++++++ + 4 files changed, 80 insertions(+) + create mode 100644 src/test/test-memory-util.c + +diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h +index b38db7d473..e4c8b71a2b 100644 +--- a/src/basic/alloc-util.h ++++ b/src/basic/alloc-util.h +@@ -14,6 +14,7 @@ + + typedef void (*free_func_t)(void *p); + typedef void* (*mfree_func_t)(void *p); ++typedef void (*free_array_func_t)(void *p, size_t n); + + /* If for some reason more than 4M are allocated on the stack, let's abort immediately. It's better than + * proceeding and smashing the stack limits. Note that by default RLIMIT_STACK is 8M on Linux. */ +diff --git a/src/basic/memory-util.h b/src/basic/memory-util.h +index 6e3280b9df..8d75befed5 100644 +--- a/src/basic/memory-util.h ++++ b/src/basic/memory-util.h +@@ -121,3 +121,37 @@ static inline void erase_and_freep(void *p) { + static inline void erase_char(char *p) { + explicit_bzero_safe(p, sizeof(char)); + } ++ ++/* An automatic _cleanup_-like logic for destroy arrays (i.e. pointers + size) when leaving scope */ ++struct ArrayCleanup { ++ void **parray; ++ size_t *pn; ++ free_array_func_t pfunc; ++}; ++ ++static inline void array_cleanup(struct ArrayCleanup *c) { ++ assert(c); ++ ++ assert(!c->parray == !c->pn); ++ ++ if (!c->parray) ++ return; ++ ++ if (*c->parray) { ++ assert(c->pfunc); ++ c->pfunc(*c->parray, *c->pn); ++ *c->parray = NULL; ++ } ++ ++ *c->pn = 0; ++} ++ ++#define CLEANUP_ARRAY(array, n, func) \ ++ _cleanup_(array_cleanup) _unused_ struct ArrayCleanup CONCATENATE(_cleanup_array_, UNIQ) = { \ ++ .parray = (void**) &(array), \ ++ .pn = &(n), \ ++ .pfunc = (free_array_func_t) ({ \ ++ void (*_f)(typeof(array[0]) *a, size_t b) = func; \ ++ _f; \ ++ }), \ ++ } +diff --git a/src/test/meson.build b/src/test/meson.build +index 2a4dfe26db..536ab08652 100644 +--- a/src/test/meson.build ++++ b/src/test/meson.build +@@ -213,6 +213,8 @@ tests += [ + [], + [libm]], + ++ [files('test-memory-util.c')], ++ + [files('test-mkdir.c')], + + [files('test-json.c'), +diff --git a/src/test/test-memory-util.c b/src/test/test-memory-util.c +new file mode 100644 +index 0000000000..a81b0e0120 +--- /dev/null ++++ b/src/test/test-memory-util.c +@@ -0,0 +1,43 @@ ++/* SPDX-License-Identifier: LGPL-2.1-or-later */ ++ ++#include "memory-util.h" ++#include "tests.h" ++ ++static void my_destructor(struct iovec *iov, size_t n) { ++ /* not really a destructor, just something we can use to check if the destruction worked */ ++ memset(iov, 'y', sizeof(struct iovec) * n); ++} ++ ++TEST(cleanup_array) { ++ struct iovec *iov, *saved_iov; ++ size_t n, saved_n; ++ ++ n = 7; ++ iov = new(struct iovec, n); ++ assert_se(iov); ++ ++ memset(iov, 'x', sizeof(struct iovec) * n); ++ ++ saved_iov = iov; ++ saved_n = n; ++ ++ { ++ assert_se(memeqbyte('x', saved_iov, sizeof(struct iovec) * saved_n)); ++ assert_se(iov); ++ assert_se(n > 0); ++ ++ CLEANUP_ARRAY(iov, n, my_destructor); ++ ++ assert_se(memeqbyte('x', saved_iov, sizeof(struct iovec) * saved_n)); ++ assert_se(iov); ++ assert_se(n > 0); ++ } ++ ++ assert_se(memeqbyte('y', saved_iov, sizeof(struct iovec) * saved_n)); ++ assert_se(!iov); ++ assert_se(n == 0); ++ ++ free(saved_iov); ++} ++ ++DEFINE_TEST_MAIN(LOG_INFO); diff --git a/SOURCES/0269-macro-introduce-FOREACH_ARRAY-macro.patch b/SOURCES/0269-macro-introduce-FOREACH_ARRAY-macro.patch new file mode 100644 index 0000000..33e186d --- /dev/null +++ b/SOURCES/0269-macro-introduce-FOREACH_ARRAY-macro.patch @@ -0,0 +1,94 @@ +From b9f50b820804113811bcf291f586793de434fcdc Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 5 Mar 2023 14:56:15 +0900 +Subject: [PATCH] macro: introduce FOREACH_ARRAY() macro + +The pattern that runs all array element is quite common. +But, sometimes, the number of element may be in a signed integer, or the +array may be NULL. + +(cherry picked from commit 5716c27e1f52d2aba9dd02916c01d6271d9d0b16) + +Related: #2182632 +--- + src/basic/macro.h | 7 ++++++ + src/test/test-macro.c | 50 +++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 57 insertions(+) + +diff --git a/src/basic/macro.h b/src/basic/macro.h +index 237117db12..b977730e54 100644 +--- a/src/basic/macro.h ++++ b/src/basic/macro.h +@@ -329,6 +329,13 @@ static inline int __coverity_check_and_return__(int condition) { + #endif + #endif + ++#define _FOREACH_ARRAY(i, array, num, m, s) \ ++ for (typeof(num) m = (num); m > 0; m = 0) \ ++ for (typeof(array[0]) *s = (array), *i = s; s && i < s + m; i++) ++ ++#define FOREACH_ARRAY(i, array, num) \ ++ _FOREACH_ARRAY(i, array, num, UNIQ_T(m, UNIQ), UNIQ_T(s, UNIQ)) ++ + #define DEFINE_TRIVIAL_DESTRUCTOR(name, type, func) \ + static inline void name(type *p) { \ + func(p); \ +diff --git a/src/test/test-macro.c b/src/test/test-macro.c +index 049ea2c14e..6a5f4bbeb7 100644 +--- a/src/test/test-macro.c ++++ b/src/test/test-macro.c +@@ -521,4 +521,54 @@ TEST(ISPOWEROF2) { + assert_se(!ISPOWEROF2(u)); + } + ++TEST(FOREACH_ARRAY) { ++ int a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; ++ int b[10] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; ++ int x, n; ++ ++ x = n = 0; ++ FOREACH_ARRAY(i, a, 10) { ++ x += *i; ++ n++; ++ } ++ assert_se(x == 45); ++ assert_se(n == 10); ++ ++ x = n = 0; ++ FOREACH_ARRAY(i, a, 10) ++ FOREACH_ARRAY(j, b, 10) { ++ x += (*i) * (*j); ++ n++; ++ } ++ assert_se(x == 45 * 45); ++ assert_se(n == 10 * 10); ++ ++ x = n = 0; ++ FOREACH_ARRAY(i, a, 5) ++ FOREACH_ARRAY(j, b, 5) { ++ x += (*i) * (*j); ++ n++; ++ } ++ assert_se(x == 10 * 35); ++ assert_se(n == 5 * 5); ++ ++ x = n = 0; ++ FOREACH_ARRAY(i, a, 0) ++ FOREACH_ARRAY(j, b, 0) { ++ x += (*i) * (*j); ++ n++; ++ } ++ assert_se(x == 0); ++ assert_se(n == 0); ++ ++ x = n = 0; ++ FOREACH_ARRAY(i, a, -1) ++ FOREACH_ARRAY(j, b, -1) { ++ x += (*i) * (*j); ++ n++; ++ } ++ assert_se(x == 0); ++ assert_se(n == 0); ++} ++ + DEFINE_TEST_MAIN(LOG_INFO); diff --git a/SOURCES/0270-journal-vacuum-rename-function-to-match-struct-name.patch b/SOURCES/0270-journal-vacuum-rename-function-to-match-struct-name.patch new file mode 100644 index 0000000..769b20e --- /dev/null +++ b/SOURCES/0270-journal-vacuum-rename-function-to-match-struct-name.patch @@ -0,0 +1,64 @@ +From 2f59a7790dc32bd9ba9e76331dbef6c80d07b705 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Wed, 22 Mar 2023 12:43:25 +0100 +Subject: [PATCH] journal-vacuum: rename function to match struct name + +(cherry picked from commit 646d5df49e1806b8c6322854ddb21903d906f471) + +Related: #2182632 +--- + src/libsystemd/sd-journal/journal-vacuum.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/libsystemd/sd-journal/journal-vacuum.c b/src/libsystemd/sd-journal/journal-vacuum.c +index 23497af28e..e3d691a1e9 100644 +--- a/src/libsystemd/sd-journal/journal-vacuum.c ++++ b/src/libsystemd/sd-journal/journal-vacuum.c +@@ -19,7 +19,7 @@ + #include "time-util.h" + #include "xattr-util.h" + +-struct vacuum_info { ++typedef struct vacuum_info { + uint64_t usage; + char *filename; + +@@ -28,9 +28,9 @@ struct vacuum_info { + sd_id128_t seqnum_id; + uint64_t seqnum; + bool have_seqnum; +-}; ++} vacuum_info; + +-static int vacuum_compare(const struct vacuum_info *a, const struct vacuum_info *b) { ++static int vacuum_info_compare(const vacuum_info *a, const vacuum_info *b) { + int r; + + if (a->have_seqnum && b->have_seqnum && +@@ -125,7 +125,7 @@ int journal_directory_vacuum( + uint64_t sum = 0, freed = 0, n_active_files = 0; + size_t n_list = 0, i; + _cleanup_closedir_ DIR *d = NULL; +- struct vacuum_info *list = NULL; ++ vacuum_info *list = NULL; + usec_t retention_limit = 0; + int r; + +@@ -270,7 +270,7 @@ int journal_directory_vacuum( + goto finish; + } + +- list[n_list++] = (struct vacuum_info) { ++ list[n_list++] = (vacuum_info) { + .filename = TAKE_PTR(p), + .usage = size, + .seqnum = seqnum, +@@ -282,7 +282,7 @@ int journal_directory_vacuum( + sum += size; + } + +- typesafe_qsort(list, n_list, vacuum_compare); ++ typesafe_qsort(list, n_list, vacuum_info_compare); + + for (i = 0; i < n_list; i++) { + uint64_t left; diff --git a/SOURCES/0271-journal-vacuum-use-CLEANUP_ARRAY.patch b/SOURCES/0271-journal-vacuum-use-CLEANUP_ARRAY.patch new file mode 100644 index 0000000..ededf9f --- /dev/null +++ b/SOURCES/0271-journal-vacuum-use-CLEANUP_ARRAY.patch @@ -0,0 +1,107 @@ +From e548d975a79204ab88ab6638aa5b24c173402723 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Wed, 22 Mar 2023 12:53:20 +0100 +Subject: [PATCH] journal-vacuum: use CLEANUP_ARRAY + +(cherry picked from commit 567cb18cc9185900ac6f701f0783a7d378e213cf) + +Related: #2182632 +--- + src/libsystemd/sd-journal/journal-vacuum.c | 41 +++++++++++----------- + 1 file changed, 20 insertions(+), 21 deletions(-) + +diff --git a/src/libsystemd/sd-journal/journal-vacuum.c b/src/libsystemd/sd-journal/journal-vacuum.c +index e3d691a1e9..6f8aaaee4c 100644 +--- a/src/libsystemd/sd-journal/journal-vacuum.c ++++ b/src/libsystemd/sd-journal/journal-vacuum.c +@@ -47,6 +47,16 @@ static int vacuum_info_compare(const vacuum_info *a, const vacuum_info *b) { + return strcmp(a->filename, b->filename); + } + ++static void vacuum_info_array_free(vacuum_info *list, size_t n) { ++ if (!list) ++ return; ++ ++ FOREACH_ARRAY(i, list, n) ++ free(i->filename); ++ ++ free(list); ++} ++ + static void patch_realtime( + int fd, + const char *fn, +@@ -129,6 +139,8 @@ int journal_directory_vacuum( + usec_t retention_limit = 0; + int r; + ++ CLEANUP_ARRAY(list, n_list, vacuum_info_array_free); ++ + assert(directory); + + if (max_use <= 0 && max_retention_usec <= 0 && n_max_files <= 0) +@@ -141,7 +153,7 @@ int journal_directory_vacuum( + if (!d) + return -errno; + +- FOREACH_DIRENT_ALL(de, d, r = -errno; goto finish) { ++ FOREACH_DIRENT_ALL(de, d, return -errno) { + unsigned long long seqnum = 0, realtime; + _cleanup_free_ char *p = NULL; + sd_id128_t seqnum_id; +@@ -182,10 +194,8 @@ int journal_directory_vacuum( + } + + p = strdup(de->d_name); +- if (!p) { +- r = -ENOMEM; +- goto finish; +- } ++ if (!p) ++ return -ENOMEM; + + de->d_name[q-8-16-1-16-1] = 0; + if (sd_id128_from_string(de->d_name + q-8-16-1-16-1-32, &seqnum_id) < 0) { +@@ -224,10 +234,8 @@ int journal_directory_vacuum( + } + + p = strdup(de->d_name); +- if (!p) { +- r = -ENOMEM; +- goto finish; +- } ++ if (!p) ++ return -ENOMEM; + + if (sscanf(de->d_name + q-1-8-16-1-16, "%16llx-%16llx.journal~", &realtime, &tmp) != 2) { + n_active_files++; +@@ -265,10 +273,8 @@ int journal_directory_vacuum( + + patch_realtime(dirfd(d), p, &st, &realtime); + +- if (!GREEDY_REALLOC(list, n_list + 1)) { +- r = -ENOMEM; +- goto finish; +- } ++ if (!GREEDY_REALLOC(list, n_list + 1)) ++ return -ENOMEM; + + list[n_list++] = (vacuum_info) { + .filename = TAKE_PTR(p), +@@ -312,15 +318,8 @@ int journal_directory_vacuum( + if (oldest_usec && i < n_list && (*oldest_usec == 0 || list[i].realtime < *oldest_usec)) + *oldest_usec = list[i].realtime; + +- r = 0; +- +-finish: +- for (i = 0; i < n_list; i++) +- free(list[i].filename); +- free(list); +- + log_full(verbose ? LOG_INFO : LOG_DEBUG, "Vacuuming done, freed %s of archived journals from %s.", + FORMAT_BYTES(freed), directory); + +- return r; ++ return 0; + } diff --git a/SOURCES/0272-pam-add-call-to-pam_umask.patch b/SOURCES/0272-pam-add-call-to-pam_umask.patch new file mode 100644 index 0000000..68f910e --- /dev/null +++ b/SOURCES/0272-pam-add-call-to-pam_umask.patch @@ -0,0 +1,28 @@ +From 12894fae724cee1e5b94e6b36708e0b6752c9cec Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Wed, 31 May 2023 18:50:12 +0200 +Subject: [PATCH] pam: add call to pam_umask + +Setting umask for user sessions via UMASK setting in /etc/login.defs is +a well-known feature. Let's make sure that user manager also runs with +this umask value. + +Follow-up for 5e37d1930b41b24c077ce37c6db0e36c745106c7. + +(cherry picked from commit 159f1b78576ce91c3932f4867f07361a530875d3) + +Resolves: #2210145 +--- + src/login/systemd-user.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/login/systemd-user.in b/src/login/systemd-user.in +index 39bcbd71fe..5906a7481b 100644 +--- a/src/login/systemd-user.in ++++ b/src/login/systemd-user.in +@@ -18,4 +18,5 @@ session optional pam_keyinit.so force revoke + {% if ENABLE_HOMED %} + -session optional pam_systemd_home.so + {% endif %} ++session optional pam_umask.so silent + session optional pam_systemd.so diff --git a/SOURCES/0273-udev-builtin-net_id-align-VF-representor-names-with-.patch b/SOURCES/0273-udev-builtin-net_id-align-VF-representor-names-with-.patch new file mode 100644 index 0000000..009789f --- /dev/null +++ b/SOURCES/0273-udev-builtin-net_id-align-VF-representor-names-with-.patch @@ -0,0 +1,196 @@ +From ac7fc3fd00a6f468b14ba05b80d7e2d41b46d485 Mon Sep 17 00:00:00 2001 +From: Ivan Vecera +Date: Thu, 22 Jun 2023 10:06:27 +0200 +Subject: [PATCH] udev-builtin-net_id: align VF representor names with VF names + +Certain cards support to set their eswitch to switchdev mode. In this +mode for each created VF there is also created so called VF representor. +This representor is helper network interface used for configuration of +mentioned eswitch and belongs to an appropriate PF. + +VF representors are identified by the specific value of phys_port_name +attribute and the value has format "pfMvfN" where M is PF function +number and N is VF number inside this PF. + +As the VF representor interfaces belong to PF PCI device the naming +scheme used for them is the same like for other PCI devices. In this +case name of PF interface is used and phys_port_name suffix is appended. + +E.g. + PF=enp65s0f0np0 # phys_port_name for PF interface is 'p0' + VF=enp65s0f0np0v0 # v0 is appended for VF0 in case of NAMING_SR_IOV_V +REP=enp65s0f0np0pf0vf0 # phys_port_name for VF0 representor is 'pf0vf0' + +First as the phys_port_name for representors is long (6+ chars) then the +generated name does not fit into IFNAMSIZ so this name is used only as +alternate interface name and for the primary one is used generic one +like eth. Second 'f0' and 'pf0' in REP name is redundant. + +This patch fixes this issue by introducing another naming scheme for VF +representors and appending 'rN' suffix to PF interface name for them. +N is VF number so the name used for representor interface is similar to +VF interface and differs only by the suffix. + +For the example above we get: + PF=enp65s0f0np0 + VF=enp65s0f0np0v0 +REP=enp65s0f0np0r0 + +This eases for userspace to determine which representor interface +represents particular VF. + +Signed-off-by: Ivan Vecera +(cherry picked from commit 88d2bda8120dcc375a90e28b64de06b9646ab3b6) + +Resolves: #2218886 +--- + man/systemd.net-naming-scheme.xml | 22 ++++++++++++++++++++++ + src/shared/netif-naming-scheme.h | 2 ++ + src/udev/udev-builtin-net_id.c | 25 ++++++++++++++++++++----- + 3 files changed, 44 insertions(+), 5 deletions(-) + +diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml +index 0886369c9b..ade4e27e31 100644 +--- a/man/systemd.net-naming-scheme.xml ++++ b/man/systemd.net-naming-scheme.xml +@@ -158,6 +158,7 @@ + ID_NET_NAME_SLOT=prefix[Pdomain]sslot[ffunction][nport_name|ddev_port]bnumber + ID_NET_NAME_SLOT=prefix[Pdomain]sslot[ffunction][nport_name|ddev_port]uport…[cconfig][iinterface] + ID_NET_NAME_SLOT=prefix[Pdomain]sslot[ffunction][nport_name|ddev_port]vslot ++ ID_NET_NAME_SLOT=prefix[Pdomain]sslot[ffunction][nport_name|ddev_port]rslot + + This property describes the slot position. Different schemes are used depending on + the bus type, as described in the table below. In case of USB, BCMA, and SR-VIO devices, the full +@@ -205,6 +206,11 @@ + … vslot + SR-VIO slot number + ++ ++ ++ … rslot ++ SR-IOV slot number ++ + + + +@@ -225,6 +231,11 @@ + v and the virtual device number, with any leading zeros removed. The bus + number is ignored. + ++ SR-IOV virtual device representors are named based on the name of the physical device ++ interface, with a suffix of r and the number of the virtual device that ++ is linked to the particular representor, with any leading zeros removed. The physical port ++ name and the bus number are ignored. ++ + In some configurations a parent PCI bridge of a given network controller may be associated + with a slot. In such case we don't generate this device property to avoid possible naming conflicts. + +@@ -472,6 +483,17 @@ + Same as naming scheme rhel-9.0. + + ++ ++ rhel-9.3 ++ ++ Naming was changed for SR-IOV virtual device representors. ++ ++ The rslot suffix was added to differentiate SR-IOV ++ virtual device representors attached to a single physical device interface. ++ ++ ++ ++ + + + Note that latest may be used to denote the latest scheme known (to this +diff --git a/src/shared/netif-naming-scheme.h b/src/shared/netif-naming-scheme.h +index 3e35c5e2fa..fb3c8eb9b3 100644 +--- a/src/shared/netif-naming-scheme.h ++++ b/src/shared/netif-naming-scheme.h +@@ -38,6 +38,7 @@ typedef enum NamingSchemeFlags { + NAMING_XEN_VIF = 1 << 13, /* Generate names for Xen netfront devices */ + NAMING_BRIDGE_MULTIFUNCTION_SLOT = 1 << 14, /* Use PCI hotplug slot information associated with bridge, but only if PCI device is multifunction */ + NAMING_DEVICETREE_ALIASES = 1 << 15, /* Generate names from devicetree aliases */ ++ NAMING_SR_IOV_R = 1 << 17, /* Use "r" suffix for SR-IOV VF representors */ + + /* And now the masks that combine the features above */ + NAMING_V238 = 0, +@@ -54,6 +55,7 @@ typedef enum NamingSchemeFlags { + NAMING_RHEL_9_0 = NAMING_V250 | NAMING_BRIDGE_MULTIFUNCTION_SLOT, + NAMING_RHEL_9_1 = NAMING_RHEL_9_0, + NAMING_RHEL_9_2 = NAMING_RHEL_9_0, ++ NAMING_RHEL_9_3 = NAMING_RHEL_9_0 | NAMING_SR_IOV_R, + + EXTRA_NET_NAMING_SCHEMES + +diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c +index d4e9dcb60d..c57568f8cb 100644 +--- a/src/udev/udev-builtin-net_id.c ++++ b/src/udev/udev-builtin-net_id.c +@@ -80,6 +80,7 @@ typedef struct LinkInfo { + int ifindex; + int iflink; + int iftype; ++ int vf_representor_id; + const char *devtype; + const char *phys_port_name; + struct hw_addr_data hw_addr; +@@ -208,7 +209,10 @@ static int dev_pci_onboard(sd_device *dev, const LinkInfo *info, NetNames *names + s = names->pci_onboard; + l = sizeof(names->pci_onboard); + l = strpcpyf(&s, l, "o%lu", idx); +- if (!isempty(info->phys_port_name)) ++ if (naming_scheme_has(NAMING_SR_IOV_R) && info->vf_representor_id >= 0) ++ /* For VF representor append 'r' and not phys_port_name */ ++ l = strpcpyf(&s, l, "r%d", info->vf_representor_id); ++ else if (!isempty(info->phys_port_name)) + /* kernel provided front panel port name for multiple port PCI device */ + l = strpcpyf(&s, l, "n%s", info->phys_port_name); + else if (dev_port > 0) +@@ -391,7 +395,10 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) { + l = strpcpyf(&s, l, "p%us%u", bus, slot); + if (func > 0 || is_pci_multifunction(names->pcidev) > 0) + l = strpcpyf(&s, l, "f%u", func); +- if (!isempty(info->phys_port_name)) ++ if (naming_scheme_has(NAMING_SR_IOV_R) && info->vf_representor_id >= 0) ++ /* For VF representor append 'r' and not phys_port_name */ ++ l = strpcpyf(&s, l, "r%d", info->vf_representor_id); ++ else if (!isempty(info->phys_port_name)) + /* kernel provided front panel port name for multi-port PCI device */ + l = strpcpyf(&s, l, "n%s", info->phys_port_name); + else if (dev_port > 0) +@@ -485,7 +492,10 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) { + l = strpcpyf(&s, l, "s%"PRIu32, hotplug_slot); + if (func > 0 || is_pci_multifunction(names->pcidev) > 0) + l = strpcpyf(&s, l, "f%u", func); +- if (!isempty(info->phys_port_name)) ++ if (naming_scheme_has(NAMING_SR_IOV_R) && info->vf_representor_id >= 0) ++ /* For VF representor append 'r' and not phys_port_name */ ++ l = strpcpyf(&s, l, "r%d", info->vf_representor_id); ++ else if (!isempty(info->phys_port_name)) + l = strpcpyf(&s, l, "n%s", info->phys_port_name); + else if (dev_port > 0) + l = strpcpyf(&s, l, "d%lu", dev_port); +@@ -1082,7 +1092,10 @@ static int get_link_info(sd_device *dev, LinkInfo *info) { + if (r < 0 && r != -ENOENT) + return r; + +- (void) sd_device_get_sysattr_value(dev, "phys_port_name", &info->phys_port_name); ++ r = sd_device_get_sysattr_value(dev, "phys_port_name", &info->phys_port_name); ++ if (r >= 0) ++ /* Check if phys_port_name indicates virtual device representor */ ++ (void) sscanf(info->phys_port_name, "pf%*uvf%d", &info->vf_representor_id); + + r = sd_device_get_sysattr_value(dev, "address", &s); + if (r < 0 && r != -ENOENT) +@@ -1099,7 +1112,9 @@ static int get_link_info(sd_device *dev, LinkInfo *info) { + static int builtin_net_id(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) { + const char *prefix; + NetNames names = {}; +- LinkInfo info = {}; ++ LinkInfo info = { ++ .vf_representor_id = -1, ++ }; + int r; + + r = get_link_info(dev, &info); diff --git a/SOURCES/0274-pam-add-a-call-to-pam_namespace.patch b/SOURCES/0274-pam-add-a-call-to-pam_namespace.patch new file mode 100644 index 0000000..23493eb --- /dev/null +++ b/SOURCES/0274-pam-add-a-call-to-pam_namespace.patch @@ -0,0 +1,42 @@ +From 7c717362136027e8efa82edba061158f4bb1fd07 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 23 Nov 2022 16:09:56 +0100 +Subject: [PATCH] pam: add a call to pam_namespace + +A call to pam_namespace is required so that children of user@.service end up in +a namespace as expected. pam_namespace gets called as part of the stack that +creates a session (login, sshd, gdm, etc.) and those processes end up in a +namespace, but it also needs to be called from our stack which is parallel and +descends from pid1 itself. + +The call to pam_namespace is similar to the call to pam_keyinit that was added +in ab79099d1684457d040ee7c28b2012e8c1ea9a4f. The pam stack for user@.service +creates a new session which is disconnected from the parent environment. Both +calls are not suitable for inclusion in the shared part of the stack (e.g. +@system-auth on Fedora/RHEL systems), because for example su/sudo/runuser +should not include them. + +Fixes #17043 (Allow to execute user service into dedicated namespace + if pam_namespace enabled) +Related to https://bugzilla.redhat.com/show_bug.cgi?id=1861836 +(Polyinstantiation is ignored/bypassed in GNOME sessions) + +(cherry picked from commit 0ef48896d9f23b9fd547a532a4e6e6b8f8b12901) + +Resolves: #2218184 +--- + src/login/systemd-user.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/login/systemd-user.in b/src/login/systemd-user.in +index 5906a7481b..8805306908 100644 +--- a/src/login/systemd-user.in ++++ b/src/login/systemd-user.in +@@ -15,6 +15,7 @@ session required pam_selinux.so nottys open + {% endif %} + session required pam_loginuid.so + session optional pam_keyinit.so force revoke ++session required pam_namespace.so + {% if ENABLE_HOMED %} + -session optional pam_systemd_home.so + {% endif %} diff --git a/SOURCES/0275-rules-online-CPU-automatically-on-IBM-s390x-platform.patch b/SOURCES/0275-rules-online-CPU-automatically-on-IBM-s390x-platform.patch new file mode 100644 index 0000000..360d2de --- /dev/null +++ b/SOURCES/0275-rules-online-CPU-automatically-on-IBM-s390x-platform.patch @@ -0,0 +1,39 @@ +From 65d993c2efe52d683396dc3181cc79f29698bf39 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= +Date: Wed, 21 Jun 2023 17:10:46 +0200 +Subject: [PATCH] rules: online CPU automatically on IBM s390x platforms when + configured +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RHEL-only + +Fix CPU hotplug regression on s390x introduced by commit 94c7e260b499 ("rules: +do not online CPU automatically on IBM platforms"). After discussion with IBM, +CPUs should be auto-enabled when in the configured state after a hotplug. +However, if the CPU is deconfigured, it should not. + +This is because on zVM and KVM hotplugged CPUs are configured and on LPAR/DPM +they are deconfigured. + +Resolves: #2212612 +Signed-off-by: Cédric Le Goater +--- + rules.d/40-redhat.rules | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/rules.d/40-redhat.rules b/rules.d/40-redhat.rules +index efb866966e..00c02a59bd 100644 +--- a/rules.d/40-redhat.rules ++++ b/rules.d/40-redhat.rules +@@ -3,7 +3,8 @@ + # CPU hotadd request + SUBSYSTEM!="cpu", GOTO="cpu_online_end" + ACTION!="add", GOTO="cpu_online_end" +-CONST{arch}=="s390*|ppc64*", GOTO="cpu_online_end" ++CONST{arch}=="ppc64*", GOTO="cpu_online_end" ++CONST{arch}=="s390*", ATTR{configure}=="0", GOTO="cpu_online_end" + + TEST=="online", ATTR{online}=="0", ATTR{online}="1" + diff --git a/SOURCES/0276-core-mount-escape-invalid-UTF8-char-in-dbus-reply.patch b/SOURCES/0276-core-mount-escape-invalid-UTF8-char-in-dbus-reply.patch new file mode 100644 index 0000000..17de88d --- /dev/null +++ b/SOURCES/0276-core-mount-escape-invalid-UTF8-char-in-dbus-reply.patch @@ -0,0 +1,106 @@ +From fcdec60764cd1d6f2d859558303390fffcec3633 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 11 May 2023 19:21:57 +0900 +Subject: [PATCH] core/mount: escape invalid UTF8 char in dbus reply + +When What= or Options= may contain invalid UTF8 chars. + +Replaces aaf7b0e41105d7b7cf30912cdac32820f011a219 (#27541). + +(cherry picked from commit 4804da58536ab7ad46178a03f4d2da49fd8e4ba2) + +Resolves: #2208240 +--- + src/core/dbus-mount.c | 67 +++++++++++++++++++++++++++++++++++-------- + 1 file changed, 55 insertions(+), 12 deletions(-) + +diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c +index 73702b1a16..55ad4f2c98 100644 +--- a/src/core/dbus-mount.c ++++ b/src/core/dbus-mount.c +@@ -9,21 +9,66 @@ + #include "mount.h" + #include "string-util.h" + #include "unit.h" ++#include "utf8.h" ++ ++static int property_get_what( ++ sd_bus *bus, ++ const char *path, ++ const char *interface, ++ const char *property, ++ sd_bus_message *reply, ++ void *userdata, ++ sd_bus_error *error) { ++ ++ _cleanup_free_ char *escaped = NULL; ++ Mount *m = ASSERT_PTR(userdata); ++ const char *s = NULL; ++ ++ assert(bus); ++ assert(reply); + +-static const char *mount_get_what(const Mount *m) { + if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what) +- return m->parameters_proc_self_mountinfo.what; +- if (m->from_fragment && m->parameters_fragment.what) +- return m->parameters_fragment.what; +- return NULL; ++ s = m->parameters_proc_self_mountinfo.what; ++ else if (m->from_fragment && m->parameters_fragment.what) ++ s = m->parameters_fragment.what; ++ ++ if (s) { ++ escaped = utf8_escape_invalid(s); ++ if (!escaped) ++ return -ENOMEM; ++ } ++ ++ return sd_bus_message_append_basic(reply, 's', escaped); + } + +-static const char *mount_get_options(const Mount *m) { ++static int property_get_options( ++ sd_bus *bus, ++ const char *path, ++ const char *interface, ++ const char *property, ++ sd_bus_message *reply, ++ void *userdata, ++ sd_bus_error *error) { ++ ++ _cleanup_free_ char *escaped = NULL; ++ Mount *m = ASSERT_PTR(userdata); ++ const char *s = NULL; ++ ++ assert(bus); ++ assert(reply); ++ + if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.options) +- return m->parameters_proc_self_mountinfo.options; +- if (m->from_fragment && m->parameters_fragment.options) +- return m->parameters_fragment.options; +- return NULL; ++ s = m->parameters_proc_self_mountinfo.options; ++ else if (m->from_fragment && m->parameters_fragment.options) ++ s = m->parameters_fragment.options; ++ ++ if (s) { ++ escaped = utf8_escape_invalid(s); ++ if (!escaped) ++ return -ENOMEM; ++ } ++ ++ return sd_bus_message_append_basic(reply, 's', escaped); + } + + static const char *mount_get_fstype(const Mount *m) { +@@ -34,8 +79,6 @@ static const char *mount_get_fstype(const Mount *m) { + return NULL; + } + +-static BUS_DEFINE_PROPERTY_GET(property_get_what, "s", Mount, mount_get_what); +-static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Mount, mount_get_options); + static BUS_DEFINE_PROPERTY_GET(property_get_type, "s", Mount, mount_get_fstype); + static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, mount_result, MountResult); + diff --git a/SOURCES/0227-Revert-user-delegate-cpu-controller-assign-weights-t.patch b/SOURCES/0277-Revert-user-delegate-cpu-controller-assign-weights-t.patch similarity index 96% rename from SOURCES/0227-Revert-user-delegate-cpu-controller-assign-weights-t.patch rename to SOURCES/0277-Revert-user-delegate-cpu-controller-assign-weights-t.patch index adb705c..d4b1ae8 100644 --- a/SOURCES/0227-Revert-user-delegate-cpu-controller-assign-weights-t.patch +++ b/SOURCES/0277-Revert-user-delegate-cpu-controller-assign-weights-t.patch @@ -1,4 +1,4 @@ -From a540b3e604d921200ee35f859770c9fbed6b669a Mon Sep 17 00:00:00 2001 +From 1d38915c7ac741cd1772521b3921b4e1655af9f8 Mon Sep 17 00:00:00 2001 From: Michal Sekletar Date: Fri, 3 Mar 2023 10:58:37 +0100 Subject: [PATCH] Revert "user: delegate cpu controller, assign weights to user @@ -6,7 +6,7 @@ Subject: [PATCH] Revert "user: delegate cpu controller, assign weights to user This reverts commit b8df7f8629cb310beac982a4779b27eabe5362c6. -Resolves: #2173996 +Resolves: #2176899 --- TODO | 2 -- units/user/app.slice | 3 --- diff --git a/SOURCES/0278-udev-rules-fix-nvme-symlink-creation-on-namespace-ch.patch b/SOURCES/0278-udev-rules-fix-nvme-symlink-creation-on-namespace-ch.patch new file mode 100644 index 0000000..9bd440f --- /dev/null +++ b/SOURCES/0278-udev-rules-fix-nvme-symlink-creation-on-namespace-ch.patch @@ -0,0 +1,61 @@ +From b4bf6261b5025dabf92997bf124f57e2e314935e Mon Sep 17 00:00:00 2001 +From: Thomas Blume +Date: Thu, 2 Mar 2023 12:06:13 +0100 +Subject: [PATCH] udev-rules: fix nvme symlink creation on namespace changes + +The nvme by-id symlink changes to the latest namespace when a new namespace gets +added, for example by connecting multiple NVMe/TCP host controllers via nvme +connect-all. +That is incorrect for persistent device links. +The persistent symbolic device link should continue to point to the same NVMe +namespace throughout the lifetime of the current boot. +Therefore the namespace id needs to be added to the link name. + +(cherry picked from commit c5ba7a2a4dd19a2d31b8a9d52d3c4bdde78387f0) + +Resolves: #2172509 +--- + rules.d/60-persistent-storage.rules | 8 ++++++++ + test/units/testsuite-64.sh | 2 ++ + 2 files changed, 10 insertions(+) + +diff --git a/rules.d/60-persistent-storage.rules b/rules.d/60-persistent-storage.rules +index 18588e4c45..d6612daf7d 100644 +--- a/rules.d/60-persistent-storage.rules ++++ b/rules.d/60-persistent-storage.rules +@@ -37,14 +37,22 @@ KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{serial}=="?*", ENV{ID_S + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{wwid}=="?*", ENV{ID_WWN}="$attr{wwid}" + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}" + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{firmware_rev}=="?*", ENV{ID_REVISION}="$attr{firmware_rev}" ++KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{nsid}=="?*", ENV{ID_NSID}="$attr{nsid}" ++# obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}" ++KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*",\ ++ OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}_$env{ID_NSID}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}" + + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}" + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}" + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{firmware_rev}=="?*", ENV{ID_REVISION}="$attr{firmware_rev}" ++KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{nsid}=="?*", ENV{ID_NSID}="$attr{nsid}" ++# obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" ++KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*",\ ++ OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}_$env{ID_NSID}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" + + # virtio-blk + KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}" +diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh +index 201a673d06..f7298ed0d6 100755 +--- a/test/units/testsuite-64.sh ++++ b/test/units/testsuite-64.sh +@@ -182,6 +182,8 @@ testcase_nvme_subsystem() { + local expected_symlinks=( + # Controller(s) + /dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_deadbeef ++ /dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_deadbeef_16 ++ /dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_deadbeef_17 + # Shared namespaces + /dev/disk/by-path/pci-*-nvme-16 + /dev/disk/by-path/pci-*-nvme-17 diff --git a/SOURCES/0279-rules-add-whitespace-after-comma-before-the-line-con.patch b/SOURCES/0279-rules-add-whitespace-after-comma-before-the-line-con.patch new file mode 100644 index 0000000..6086dce --- /dev/null +++ b/SOURCES/0279-rules-add-whitespace-after-comma-before-the-line-con.patch @@ -0,0 +1,35 @@ +From b3a19cc848f1f7046fb19c6a27b56fa3bf341728 Mon Sep 17 00:00:00 2001 +From: "Dmitry V. Levin" +Date: Sat, 25 Mar 2023 08:00:00 +0000 +Subject: [PATCH] rules: add whitespace after comma before the line + continuation + +(cherry picked from commit 519044f565cf32f4ebd0ecca5eb162555aa006b2) + +Related: #2172509 +--- + rules.d/60-persistent-storage.rules | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/rules.d/60-persistent-storage.rules b/rules.d/60-persistent-storage.rules +index d6612daf7d..f5178ed6bd 100644 +--- a/rules.d/60-persistent-storage.rules ++++ b/rules.d/60-persistent-storage.rules +@@ -41,7 +41,7 @@ KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{nsid}=="?*", ENV{ID_NSI + # obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}" +-KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*",\ ++KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}_$env{ID_NSID}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}" + + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}" +@@ -51,7 +51,7 @@ KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{nsid}=="?*" + # obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" +-KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*",\ ++KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}_$env{ID_NSID}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" + + # virtio-blk diff --git a/SOURCES/0280-udev-restore-compat-symlink-for-nvme-devices.patch b/SOURCES/0280-udev-restore-compat-symlink-for-nvme-devices.patch new file mode 100644 index 0000000..c65bab4 --- /dev/null +++ b/SOURCES/0280-udev-restore-compat-symlink-for-nvme-devices.patch @@ -0,0 +1,61 @@ +From b4c71f09f1933324593aef453f70e986d0175b70 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 6 Apr 2023 12:28:14 +0200 +Subject: [PATCH] udev: restore compat symlink for nvme devices + +In 5118e8e71dda211d20e34ec8d3012186ba27d3d3, the rules were changed to add +OPTIONS="string_escape=replace" to creation of +ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", so that "/" would be +escaped. But this also changes how the symlink looks for devices that do not +have "/". This adds back the old symlink for compat, except when a slash +is present. + +In the meantime, we changed the symlink format to include ${ND_NSID}. Since +the symlink with unescaped characters are older than that, for compat we +only need to cover the older type. (Symlinks without escaping and with ${ND_NSID} +were never created.) This makes it slightly easier on users: the non-deprecated +symlinks are with "_${ND_NSID}", so they are easier to distinguish. + +Fixes #27155. + +Mostly untested :( I only have a boring nvme device with no special characters +in the id, and the symlinks are unchanged for it by this patch. + +(cherry picked from commit d05e1be86e6b14bd22d57af17efcc3b8fb7ecd82) + +Related: #2172509 + +[msekleta: it is not strictly necessary to include this commit in RHEL-9 +because the we never had the previous version of non-escaped symlinks in +RHEL-9. However, by including it we are making a life a bit easier for +folks that are doing in-place upgrade from RHEL-8.] +--- + rules.d/60-persistent-storage.rules | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/rules.d/60-persistent-storage.rules b/rules.d/60-persistent-storage.rules +index f5178ed6bd..8269c3cfd9 100644 +--- a/rules.d/60-persistent-storage.rules ++++ b/rules.d/60-persistent-storage.rules +@@ -38,6 +38,10 @@ KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{wwid}=="?*", ENV{ID_WWN + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}" + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{firmware_rev}=="?*", ENV{ID_REVISION}="$attr{firmware_rev}" + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{nsid}=="?*", ENV{ID_NSID}="$attr{nsid}" ++# obsolete symlink with non-escaped characters, kept for backward compatiblity ++KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ ++ ENV{ID_MODEL}!="*/*", ENV{ID_SERIAL_SHORT}!="*/*", \ ++ ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}" + # obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}" +@@ -48,6 +52,10 @@ KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{serial}=="? + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}" + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{firmware_rev}=="?*", ENV{ID_REVISION}="$attr{firmware_rev}" + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ATTRS{nsid}=="?*", ENV{ID_NSID}="$attr{nsid}" ++# obsolete symlink with non-escaped characters, kept for backward compatiblity ++KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ ++ ENV{ID_MODEL}!="*/*", ENV{ID_SERIAL_SHORT}!="*/*", \ ++ ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" + # obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" diff --git a/SOURCES/0281-rules-drop-doubled-space.patch b/SOURCES/0281-rules-drop-doubled-space.patch new file mode 100644 index 0000000..b2a0e1c --- /dev/null +++ b/SOURCES/0281-rules-drop-doubled-space.patch @@ -0,0 +1,25 @@ +From 5e92f162bc25197b67d9ffd7669d803a9168b4e6 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sat, 8 Apr 2023 03:36:44 +0900 +Subject: [PATCH] rules: drop doubled space + +(cherry picked from commit 49e3e219b01132ef269297574a9bc7b7b34d9398) + +Related: #2172509 +--- + rules.d/60-persistent-storage.rules | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/rules.d/60-persistent-storage.rules b/rules.d/60-persistent-storage.rules +index 8269c3cfd9..10b347e191 100644 +--- a/rules.d/60-persistent-storage.rules ++++ b/rules.d/60-persistent-storage.rules +@@ -59,7 +59,7 @@ KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="? + # obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility + KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" +-KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*", \ ++KERNEL=="nvme*[0-9]n*[0-9]p*[0-9]", ENV{DEVTYPE}=="partition", ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*", \ + OPTIONS="string_escape=replace", ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}_$env{ID_NSID}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}-part%n" + + # virtio-blk diff --git a/SOURCES/0248-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch b/SOURCES/0282-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch similarity index 96% rename from SOURCES/0248-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch rename to SOURCES/0282-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch index 8413fcd..844834e 100644 --- a/SOURCES/0248-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch +++ b/SOURCES/0282-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch @@ -1,4 +1,4 @@ -From 6c4090a8bdf54928e43c21d7443d2e6825ed6d1f Mon Sep 17 00:00:00 2001 +From b7b6493dd0a58931afbb7c7d818c1ebb6460b2bc Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Tue, 9 May 2023 13:15:06 +0200 Subject: [PATCH] manager: don't taint the host if cgroups v1 is used @@ -8,7 +8,7 @@ This is not true for RHEL, don't taint the host when cgroups v1 are enabled. rhel-only -Resolves: #2196479 +Resolves: #2193456 --- man/org.freedesktop.systemd1.xml | 6 ------ src/core/manager.c | 3 --- diff --git a/SOURCES/0283-core-service-when-resetting-PID-also-reset-known-fla.patch b/SOURCES/0283-core-service-when-resetting-PID-also-reset-known-fla.patch new file mode 100644 index 0000000..372a6ae --- /dev/null +++ b/SOURCES/0283-core-service-when-resetting-PID-also-reset-known-fla.patch @@ -0,0 +1,43 @@ +From 14d3ca976102d1c013b4b634586a365aadcd94c4 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 22 May 2023 17:44:30 +0200 +Subject: [PATCH] core/service: when resetting PID also reset known flag + +Re-watching pids on cgroup v1 (needed because of unreliability of cgroup +empty notifications in containers) is handled bellow at the end of +service_sigchld_event() and depends on value main_pid_known flag. + +In CentOS Stream 8 container on cgroup v1 the stop action would get stuck +indefinitely on unit like this, + +$ cat /run/systemd/system/foo.service +[Service] +ExecStart=/bin/bash -c 'trap "nohup sleep 1 & exit 0" TERM; sleep infinity' +ExecStop=/bin/bash -c 'kill -s TERM $MAINPID' +TimeoutSec=0 + +However, upstream works "fine" because in upstream version of systemd we +actually never wait on processes killed in containers and proceed +immediately to sending SIGKILL hence re-watching of pids in the cgroup +is not necessary. But for the sake of correctness we should merge the +patch also upstream. + +(cherry picked from commit ff32060f2ed37b68dc26256b05e2e69013b0ecfe) + +Resolves: #2210237 +--- + src/core/service.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/core/service.c b/src/core/service.c +index 1e14cdc6ca..e5127a4ccf 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -3507,6 +3507,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { + return; + + s->main_pid = 0; ++ s->main_pid_known = false; + exec_status_exit(&s->main_exec_status, &s->exec_context, pid, code, status); + + if (s->main_command) { diff --git a/SOURCES/0284-ci-drop-systemd-stable-from-advanced-commit-linter-c.patch b/SOURCES/0284-ci-drop-systemd-stable-from-advanced-commit-linter-c.patch new file mode 100644 index 0000000..7003a2b --- /dev/null +++ b/SOURCES/0284-ci-drop-systemd-stable-from-advanced-commit-linter-c.patch @@ -0,0 +1,28 @@ +From 7885b4384b422db6b2d6ad1771dc89c4a3c3461b Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Thu, 13 Jul 2023 14:21:20 +0200 +Subject: [PATCH] ci: drop systemd-stable from advanced-commit-linter config + +It's sufficient enough to check only the `systemd/systemd` repo. + +Related to https://github.com/redhat-plumbers-in-action/advanced-commit-linter/issues/62 + +rhel-only + +Related: #2170883 +--- + .github/advanced-commit-linter.yml | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml +index 327af0467a..0fb74a9dc8 100644 +--- a/.github/advanced-commit-linter.yml ++++ b/.github/advanced-commit-linter.yml +@@ -2,7 +2,6 @@ policy: + cherry-pick: + upstream: + - github: systemd/systemd +- - github: systemd/systemd-stable + exception: + note: + - rhel-only diff --git a/SOURCES/0285-Revert-core-service-when-resetting-PID-also-reset-kn.patch b/SOURCES/0285-Revert-core-service-when-resetting-PID-also-reset-kn.patch new file mode 100644 index 0000000..e0eb92d --- /dev/null +++ b/SOURCES/0285-Revert-core-service-when-resetting-PID-also-reset-kn.patch @@ -0,0 +1,43 @@ +From 85631eff66cb440ba253d36ca5b5bd6d131b0f18 Mon Sep 17 00:00:00 2001 +From: msizanoen +Date: Mon, 12 Jun 2023 10:30:12 +0700 +Subject: [PATCH] Revert "core/service: when resetting PID also reset known + flag" + +This reverts commit ff32060f2ed37b68dc26256b05e2e69013b0ecfe. + +This change is incorrect as we don't want to mark the PID as invalid but +only mark it as dead. + +The change in question also breaks user level socket activation for +`podman.service` as the termination of the main `podman system service` +process is not properly handled, causing any application accessing the +socket to hang. + +This is because the user-level `podman.service` unit also hosts two +non-main processes: `rootlessport` and `rootlessport-child` which causes +the `cgroup_good` check to still succeed. + +The original submitter of this commit is recommended to find another +more correct way to fix the cgroupsv1 issue on CentOS 8. + +(cherry picked from commit 996b00ede87d6a870332e63974a7d4def3c2f1b0) + +Resolves: #2225667 +Reverts: #2210237 +--- + src/core/service.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/core/service.c b/src/core/service.c +index e5127a4ccf..1e14cdc6ca 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -3507,7 +3507,6 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { + return; + + s->main_pid = 0; +- s->main_pid_known = false; + exec_status_exit(&s->main_exec_status, &s->exec_context, pid, code, status); + + if (s->main_command) { diff --git a/SOURCES/0286-ci-explicitly-install-python3-lldb-COMPILER_VERSION.patch b/SOURCES/0286-ci-explicitly-install-python3-lldb-COMPILER_VERSION.patch new file mode 100644 index 0000000..300ca65 --- /dev/null +++ b/SOURCES/0286-ci-explicitly-install-python3-lldb-COMPILER_VERSION.patch @@ -0,0 +1,42 @@ +From 3f2e5cdddd0a11947b493143fbf2ac3c18c9a082 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Thu, 27 Jul 2023 13:20:17 +0200 +Subject: [PATCH] ci: explicitly install python3-lldb-$COMPILER_VERSION + +To avoid apt complaining: + + + apt-get -y install clang-15 lldb-15 lld-15 clangd-15 +Reading package lists... +Building dependency tree... +Reading state information... +Some packages could not be installed. This may mean that you have +requested an impossible situation or if you are using the unstable +distribution that some required packages have not yet been created +or been moved out of Incoming. +The following information may help to resolve the situation: + +The following packages have unmet dependencies: + python3-lldb-14 : Conflicts: python3-lldb-x.y + python3-lldb-15 : Conflicts: python3-lldb-x.y +E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages. + +(cherry picked from commit c5afbac31bb33e7b1f4d59b253425af991a630a4) + +Related: #2225667 +--- + .github/workflows/build_test.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.github/workflows/build_test.sh b/.github/workflows/build_test.sh +index b60db29efc..745d2e5cbd 100755 +--- a/.github/workflows/build_test.sh ++++ b/.github/workflows/build_test.sh +@@ -86,7 +86,7 @@ if [[ "$COMPILER" == clang ]]; then + "$RELEASE" "$RELEASE" "$COMPILER_VERSION" >/etc/apt/sources.list.d/llvm-toolchain.list + fi + +- PACKAGES+=("clang-$COMPILER_VERSION" "lldb-$COMPILER_VERSION" "lld-$COMPILER_VERSION" "clangd-$COMPILER_VERSION") ++ PACKAGES+=("clang-$COMPILER_VERSION" "lldb-$COMPILER_VERSION" "python3-lldb-$COMPILER_VERSION" "lld-$COMPILER_VERSION" "clangd-$COMPILER_VERSION") + elif [[ "$COMPILER" == gcc ]]; then + CC="gcc-$COMPILER_VERSION" + CXX="g++-$COMPILER_VERSION" diff --git a/SOURCES/0287-doc-add-downstream-CONTRIBUTING-document.patch b/SOURCES/0287-doc-add-downstream-CONTRIBUTING-document.patch new file mode 100644 index 0000000..3807328 --- /dev/null +++ b/SOURCES/0287-doc-add-downstream-CONTRIBUTING-document.patch @@ -0,0 +1,83 @@ +From df138e1005d2eab39f55aea3bd128b660e1e6a15 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 1 Aug 2023 16:18:06 +0200 +Subject: [PATCH] doc: add downstream CONTRIBUTING document + +rhel-only + +Related: #2170883 +--- + CONTRIBUTING.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 64 insertions(+) + create mode 100644 CONTRIBUTING.md + +diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md +new file mode 100644 +index 0000000000..86a742ea43 +--- /dev/null ++++ b/CONTRIBUTING.md +@@ -0,0 +1,64 @@ ++# Contributing ++ ++Welcome to systemd source-git for CentOS Stream and RHEL. When contributing, please follow the guide below. ++ ++## Workflow ++ ++```mermaid ++flowchart LR ++ A(Issue) --> B{is fixed\nupstream} ++ B -->|YES| C(backport\nupstream patch) ++ B -->|NO| D(upstream\nsubmit issue or PR) ++ D --> E{accepted\nand fixed} ++ E -->|YES| C ++ E -->|NO| F(rhel-only patch) --> G ++ C --> G(submit PR) ++``` ++ ++## Filing issues ++ ++When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue by using Bugzilla ticket systemd - [link](https://bugzilla.redhat.com/enter_bug.cgi?classification=Red%20Hat) ++GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose). ++ ++## Posting Pull Requests ++ ++Every Pull Request has to comply with the following rules: ++ ++- Each commit has to reference [upstream](https://github.com/systemd/systemd) commit. ++- Each commit has to reference the approved issue/tracker. ++- Pull requests have to pass mandatory CI validation and testing ++- Pull requests have to be approved by at least one systemd downstream maintainer ++ ++### Upstream reference ++ ++When doing a back-port of an upstream commit, always use `cherry-pick -x `. Consider proposing a change upstream first when an upstream commit doesn't exist. ++If the change isn't upstream relevant or accepted by upstream, mark the commit with the `rhel-only` string. ++ ++```md ++doc: Fix TYPO ++ ++rhel-only ++ ++Resolves: #1234567 ++``` ++ ++### Issue reference ++ ++Each commit has to reference the relevant approved systemd issue (see: [Filling issues section](#filing-issues)). For referencing issues, we use the following keywords: ++ ++- **Resolves** for commits that directly resolve issues described in a referenced tracker ++- **Relates** for commits related to the referenced issue, but they don't fix it. Usually, tests and documentation. ++- **Reverts** for commits that reverts previously merged commit ++ ++```md ++doc: Fix TYPO ++ ++(cherry picked from commit c5afbac31bb33e7b1f4d59b253425af991a630a4) ++ ++Resolves: #1234567 ++``` ++ ++### Validation and testing ++ ++Each Pull Request has to pass all enabled tests that are automatically run using GitHub Actions, CentOS Stream CI, and others. ++If CI failure is unrelated to the change introduced in Pull Request, the downstream maintainer will set the `ci-waived` label and explain why CI was waived. diff --git a/SOURCES/0288-doc-improve-CONTRIBUTING-document.patch b/SOURCES/0288-doc-improve-CONTRIBUTING-document.patch new file mode 100644 index 0000000..6625d93 --- /dev/null +++ b/SOURCES/0288-doc-improve-CONTRIBUTING-document.patch @@ -0,0 +1,57 @@ +From 2c849b9750ff4978a865e2bb377af69a86038da4 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 8 Aug 2023 11:37:32 +0200 +Subject: [PATCH] doc: improve CONTRIBUTING document + +based on feedback from: https://github.com/redhat-plumbers/systemd-rhel8/pull/407 + +rhel-only + +Related: #2170883 +--- + CONTRIBUTING.md | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md +index 86a742ea43..361366d899 100644 +--- a/CONTRIBUTING.md ++++ b/CONTRIBUTING.md +@@ -17,7 +17,8 @@ flowchart LR + + ## Filing issues + +-When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue by using Bugzilla ticket systemd - [link](https://bugzilla.redhat.com/enter_bug.cgi?classification=Red%20Hat) ++When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssue!default.jspa) (set Project to **RHEL** and Component to **systemd**). ++ + GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose). + + ## Posting Pull Requests +@@ -39,7 +40,7 @@ doc: Fix TYPO + + rhel-only + +-Resolves: #1234567 ++Resolves: RHEL-678 + ``` + + ### Issue reference +@@ -47,15 +48,17 @@ Resolves: #1234567 + Each commit has to reference the relevant approved systemd issue (see: [Filling issues section](#filing-issues)). For referencing issues, we use the following keywords: + + - **Resolves** for commits that directly resolve issues described in a referenced tracker +-- **Relates** for commits related to the referenced issue, but they don't fix it. Usually, tests and documentation. ++- **Related** for commits related to the referenced issue, but they don't fix it. Usually, tests and documentation. + - **Reverts** for commits that reverts previously merged commit + ++When referencing issues, use following structure: `: `. See the example below: ++ + ```md + doc: Fix TYPO + + (cherry picked from commit c5afbac31bb33e7b1f4d59b253425af991a630a4) + +-Resolves: #1234567 ++Resolves: RHEL-678 + ``` + + ### Validation and testing diff --git a/SOURCES/0289-doc-use-link-with-prefilled-Jira-issue.patch b/SOURCES/0289-doc-use-link-with-prefilled-Jira-issue.patch new file mode 100644 index 0000000..fc4d203 --- /dev/null +++ b/SOURCES/0289-doc-use-link-with-prefilled-Jira-issue.patch @@ -0,0 +1,25 @@ +From eff259c8c7677bbbe64890873bd64349871dd6c5 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 8 Aug 2023 13:07:06 +0200 +Subject: [PATCH] doc: use link with prefilled Jira issue + +rhel-only + +Related: #2170883 +--- + CONTRIBUTING.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md +index 361366d899..1de2b88995 100644 +--- a/CONTRIBUTING.md ++++ b/CONTRIBUTING.md +@@ -17,7 +17,7 @@ flowchart LR + + ## Filing issues + +-When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssue!default.jspa) (set Project to **RHEL** and Component to **systemd**). ++When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&issuetype=1&components=12380515). + + GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose). + diff --git a/SOURCES/0290-docs-link-downstream-CONTRIBUTING-in-README.patch b/SOURCES/0290-docs-link-downstream-CONTRIBUTING-in-README.patch new file mode 100644 index 0000000..70662eb --- /dev/null +++ b/SOURCES/0290-docs-link-downstream-CONTRIBUTING-in-README.patch @@ -0,0 +1,52 @@ +From 581094db0528e22af351912849474ad322502c28 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Thu, 10 Aug 2023 15:16:29 +0200 +Subject: [PATCH] docs: link downstream CONTRIBUTING in README + +This should increase the visibility of the downstream CONTRIBUTING. + +Also fix some wording and update links. + +rhel-only + +Related: #2170883 +--- + CONTRIBUTING.md | 4 ++-- + README.md | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md +index 1de2b88995..bd17067be2 100644 +--- a/CONTRIBUTING.md ++++ b/CONTRIBUTING.md +@@ -17,7 +17,7 @@ flowchart LR + + ## Filing issues + +-When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&issuetype=1&components=12380515). ++When you find an issue with systemd used in **CentOS Stream** or **RHEL**, please file an issue in Red Hat [Jira ticket system](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&issuetype=1&components=12380515&priority=10300). + + GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose). + +@@ -51,7 +51,7 @@ Each commit has to reference the relevant approved systemd issue (see: [Filling + - **Related** for commits related to the referenced issue, but they don't fix it. Usually, tests and documentation. + - **Reverts** for commits that reverts previously merged commit + +-When referencing issues, use following structure: `: `. See the example below: ++When referencing issues, use the following structure: `: `. See the example below: + + ```md + doc: Fix TYPO +diff --git a/README.md b/README.md +index e507c4cb57..11a1b38038 100644 +--- a/README.md ++++ b/README.md +@@ -30,7 +30,7 @@ Please see the [Code Map](docs/ARCHITECTURE.md) for information about this repos + + Please see the [Hacking guide](docs/HACKING.md) for information on how to hack on systemd and test your modifications. + +-Please see our [Contribution Guidelines](docs/CONTRIBUTING.md) for more information about filing GitHub Issues and posting GitHub Pull Requests. ++Please see our [Contribution Guidelines](CONTRIBUTING.md) for more information about filing GitHub Issues and posting GitHub Pull Requests. + + When preparing patches for systemd, please follow our [Coding Style Guidelines](docs/CODING_STYLE.md). + diff --git a/SOURCES/0291-bpf-fix-restrict_fs-on-s390x.patch b/SOURCES/0291-bpf-fix-restrict_fs-on-s390x.patch new file mode 100644 index 0000000..8768196 --- /dev/null +++ b/SOURCES/0291-bpf-fix-restrict_fs-on-s390x.patch @@ -0,0 +1,51 @@ +From b544c7bfd7812458516d29a11511498ece02b9ee Mon Sep 17 00:00:00 2001 +From: Ilya Leoshkevich +Date: Mon, 30 Jan 2023 21:21:48 +0100 +Subject: [PATCH] bpf: fix restrict_fs on s390x + +Linux kernel's bpf-next contains BPF LSM support for s390x. systemd's +test-bpf-lsm currently fails with this kernel. + +This is an endianness issue: in the restrict_fs bpf program, +magic_number has type unsigned long (64 bits on s390x), but magic_map +keys are uint32_t (32 bits). Accessing magic_map using 64-bit keys may +work by accident on little-endian systems, but fails hard on big-endian +ones. + +Fix by casting magic_number to uint32_t. + +(cherry picked from commit 907046282c27ee2ced5e22abb80ed8df2e157baf) + +Resolves: #2230364 +--- + src/core/bpf/restrict_fs/restrict-fs.bpf.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/core/bpf/restrict_fs/restrict-fs.bpf.c b/src/core/bpf/restrict_fs/restrict-fs.bpf.c +index 522a029785..eb5ed3e7fe 100644 +--- a/src/core/bpf/restrict_fs/restrict-fs.bpf.c ++++ b/src/core/bpf/restrict_fs/restrict-fs.bpf.c +@@ -39,16 +39,20 @@ struct { + SEC("lsm/file_open") + int BPF_PROG(restrict_filesystems, struct file *file, int ret) + { +- unsigned long magic_number; ++ unsigned long raw_magic_number; + uint64_t cgroup_id; +- uint32_t *value, *magic_map, zero = 0, *is_allow; ++ uint32_t *value, *magic_map, magic_number, zero = 0, *is_allow; + + /* ret is the return value from the previous BPF program or 0 if it's + * the first hook */ + if (ret != 0) + return ret; + +- BPF_CORE_READ_INTO(&magic_number, file, f_inode, i_sb, s_magic); ++ BPF_CORE_READ_INTO(&raw_magic_number, file, f_inode, i_sb, s_magic); ++ /* super_block.s_magic is unsigned long, but magic_map keys are ++ * uint32_t. Using s_magic as-is would fail on big-endian systems, ++ * which have 64-bit unsigned long. So cast it. */ ++ magic_number = (uint32_t)raw_magic_number; + + cgroup_id = bpf_get_current_cgroup_id(); + diff --git a/SOURCES/0292-udev-net_id-use-naming-scheme-for-RHEL-9.3.patch b/SOURCES/0292-udev-net_id-use-naming-scheme-for-RHEL-9.3.patch new file mode 100644 index 0000000..b9567a3 --- /dev/null +++ b/SOURCES/0292-udev-net_id-use-naming-scheme-for-RHEL-9.3.patch @@ -0,0 +1,24 @@ +From fb3db0b1e27b2e60b86677907c761cb6d0a31c5e Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Mon, 14 Aug 2023 15:44:11 +0200 +Subject: [PATCH] udev/net_id: use naming scheme for RHEL-9.3 + +rhel-only + +Resolves: #2231845 +--- + src/shared/netif-naming-scheme.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c +index d846c794a8..0f50533279 100644 +--- a/src/shared/netif-naming-scheme.c ++++ b/src/shared/netif-naming-scheme.c +@@ -28,6 +28,7 @@ static const NamingScheme naming_schemes[] = { + { "rhel-9.0", NAMING_RHEL_9_0 }, + { "rhel-9.1", NAMING_RHEL_9_1 }, + { "rhel-9.2", NAMING_RHEL_9_2 }, ++ { "rhel-9.3", NAMING_RHEL_9_3 }, + /* … add more schemes here, as the logic to name devices is updated … */ + + EXTRA_NET_NAMING_MAP diff --git a/SOURCES/0293-core-timer-Always-use-inactive_exit_timestamp-if-it-.patch b/SOURCES/0293-core-timer-Always-use-inactive_exit_timestamp-if-it-.patch new file mode 100644 index 0000000..4a6bed8 --- /dev/null +++ b/SOURCES/0293-core-timer-Always-use-inactive_exit_timestamp-if-it-.patch @@ -0,0 +1,46 @@ +From 87e554ca8567647afef3ba79f75bc98d67716fdb Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Tue, 23 May 2023 16:24:47 +0200 +Subject: [PATCH] core/timer: Always use inactive_exit_timestamp if it is set + +If we're doing a daemon-reload, we'll be going from TIMER_DEAD => TIMER_WAITING, +so we won't use inactive_exit_timestamp because TIMER_DEAD != UNIT_ACTIVE, even +though inactive_exit_timestamp is serialized/deserialized and will be valid after +the daemon-reload. + +This issue can lead to timers never firing as we'll always calculate the next +elapse based on the current realtime on daemon-reload, so if daemon-reload happens +often enough, the elapse interval will be moved into the future every time, which +means the timer will never trigger. + +To fix the issue, let's always use inactive_exit_timestamp if it is set, and only +fall back to the current realtime if it is not set. + +(cherry picked from commit 6546045fa0bf84737bd8b2e1e8bf7dd3941d8352) + +Resolves: #2211065 +--- + src/core/timer.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/src/core/timer.c b/src/core/timer.c +index b6810c8599..711500313d 100644 +--- a/src/core/timer.c ++++ b/src/core/timer.c +@@ -401,12 +401,10 @@ static void timer_enter_waiting(Timer *t, bool time_change) { + + if (t->last_trigger.realtime > 0) + b = t->last_trigger.realtime; +- else { +- if (state_translation_table[t->state] == UNIT_ACTIVE) +- b = UNIT(t)->inactive_exit_timestamp.realtime; +- else +- b = ts.realtime; +- } ++ else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp)) ++ b = UNIT(t)->inactive_exit_timestamp.realtime; ++ else ++ b = ts.realtime; + + r = calendar_spec_next_usec(v->calendar_spec, b, &v->next_elapse); + if (r < 0) diff --git a/SOURCES/0294-timer-Use-dual_timestamp_is_set-in-one-more-place.patch b/SOURCES/0294-timer-Use-dual_timestamp_is_set-in-one-more-place.patch new file mode 100644 index 0000000..647b894 --- /dev/null +++ b/SOURCES/0294-timer-Use-dual_timestamp_is_set-in-one-more-place.patch @@ -0,0 +1,25 @@ +From 9974ff3bce3b309f086585929b21ac29d4d4f582 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Wed, 24 May 2023 11:41:37 +0200 +Subject: [PATCH] timer: Use dual_timestamp_is_set() in one more place + +(cherry picked from commit e21f75afcd95a46261a36a2614712eff6bc119f4) + +Related: #2211065 +--- + src/core/timer.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/timer.c b/src/core/timer.c +index 711500313d..60e8fea79f 100644 +--- a/src/core/timer.c ++++ b/src/core/timer.c +@@ -399,7 +399,7 @@ static void timer_enter_waiting(Timer *t, bool time_change) { + * to that. If we don't, just start from + * the activation time. */ + +- if (t->last_trigger.realtime > 0) ++ if (dual_timestamp_is_set(&t->last_trigger)) + b = t->last_trigger.realtime; + else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp)) + b = UNIT(t)->inactive_exit_timestamp.realtime; diff --git a/SOURCES/0295-loginctl-list-users-also-show-state.patch b/SOURCES/0295-loginctl-list-users-also-show-state.patch new file mode 100644 index 0000000..542536a --- /dev/null +++ b/SOURCES/0295-loginctl-list-users-also-show-state.patch @@ -0,0 +1,77 @@ +From 5c1e6fb6440f86d59720d2d3673eb81c9255c5e8 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 11 May 2023 13:05:39 +0800 +Subject: [PATCH] loginctl: list-users: also show state + +(cherry picked from commit bae05711b5d06f330423f69d4d6500c907b8d322) + +Related: #2209912 +--- + src/login/loginctl.c | 35 ++++++++++++++++++++++++++++++----- + 1 file changed, 30 insertions(+), 5 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 4dbfa0db44..8b72ebae57 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -205,13 +205,15 @@ static int list_users(int argc, char *argv[], void *userdata) { + if (r < 0) + return bus_log_parse_error(r); + +- table = table_new("uid", "user", "linger"); ++ table = table_new("uid", "user", "linger", "state"); + if (!table) + return log_oom(); + + (void) table_set_align_percent(table, TABLE_HEADER_CELL(0), 100); + + for (;;) { ++ _cleanup_(sd_bus_error_free) sd_bus_error error_property = SD_BUS_ERROR_NULL; ++ _cleanup_free_ char *state = NULL; + const char *user, *object; + uint32_t uid; + int linger; +@@ -227,16 +229,39 @@ static int list_users(int argc, char *argv[], void *userdata) { + object, + "org.freedesktop.login1.User", + "Linger", +- &error, ++ &error_property, + 'b', + &linger); +- if (r < 0) +- return log_error_errno(r, "Failed to get linger status: %s", bus_error_message(&error, r)); ++ if (r < 0) { ++ if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) ++ /* The user logged out when we're querying the property */ ++ continue; ++ ++ return log_error_errno(r, "Failed to get linger status for user %s: %s", ++ user, bus_error_message(&error_property, r)); ++ } ++ ++ r = sd_bus_get_property_string(bus, ++ "org.freedesktop.login1", ++ object, ++ "org.freedesktop.login1.User", ++ "State", ++ &error_property, ++ &state); ++ if (r < 0) { ++ if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) ++ /* The user logged out when we're querying the property */ ++ continue; ++ ++ return log_error_errno(r, "Failed to get state for user %s: %s", ++ user, bus_error_message(&error_property, r)); ++ } + + r = table_add_many(table, + TABLE_UID, (uid_t) uid, + TABLE_STRING, user, +- TABLE_BOOLEAN, linger); ++ TABLE_BOOLEAN, linger, ++ TABLE_STRING, state); + if (r < 0) + return table_log_add_error(r); + } diff --git a/SOURCES/0296-loginctl-list-sessions-minor-modernization.patch b/SOURCES/0296-loginctl-list-sessions-minor-modernization.patch new file mode 100644 index 0000000..f87261f --- /dev/null +++ b/SOURCES/0296-loginctl-list-sessions-minor-modernization.patch @@ -0,0 +1,67 @@ +From 327f02ddb69c6f908db86e250d240c1036b5c394 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 11 May 2023 13:17:59 +0800 +Subject: [PATCH] loginctl: list-sessions: minor modernization + +(cherry picked from commit 486f61a8c908d63c47625c352e456d80c88b4687) + +Related: #2209912 +--- + src/login/loginctl.c | 37 +++++++++++++++++++------------------ + 1 file changed, 19 insertions(+), 18 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 8b72ebae57..9c21b97bb5 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -141,9 +141,9 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + (void) table_set_align_percent(table, TABLE_HEADER_CELL(1), 100); + + for (;;) { +- _cleanup_(sd_bus_error_free) sd_bus_error error_tty = SD_BUS_ERROR_NULL; +- _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply_tty = NULL; +- const char *id, *user, *seat, *object, *tty = NULL; ++ _cleanup_(sd_bus_error_free) sd_bus_error error_property = SD_BUS_ERROR_NULL; ++ _cleanup_free_ char *tty = NULL; ++ const char *id, *user, *seat, *object; + uint32_t uid; + + r = sd_bus_message_read(reply, "(susso)", &id, &uid, &user, &seat, &object); +@@ -152,21 +152,22 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + if (r == 0) + break; + +- r = sd_bus_get_property( +- bus, +- "org.freedesktop.login1", +- object, +- "org.freedesktop.login1.Session", +- "TTY", +- &error_tty, +- &reply_tty, +- "s"); +- if (r < 0) +- log_warning_errno(r, "Failed to get TTY for session %s: %s", id, bus_error_message(&error_tty, r)); +- else { +- r = sd_bus_message_read(reply_tty, "s", &tty); +- if (r < 0) +- return bus_log_parse_error(r); ++ r = sd_bus_get_property_string(bus, ++ "org.freedesktop.login1", ++ object, ++ "org.freedesktop.login1.Session", ++ "TTY", ++ &error_property, ++ &tty); ++ if (r < 0) { ++ if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) ++ /* The session is already closed when we're querying the property */ ++ continue; ++ ++ log_warning_errno(r, "Failed to get TTY for session %s, ignoring: %s", ++ id, bus_error_message(&error_property, r)); ++ ++ sd_bus_error_free(&error_property); + } + + r = table_add_many(table, diff --git a/SOURCES/0297-loginctl-list-sessions-also-show-state.patch b/SOURCES/0297-loginctl-list-sessions-also-show-state.patch new file mode 100644 index 0000000..261500a --- /dev/null +++ b/SOURCES/0297-loginctl-list-sessions-also-show-state.patch @@ -0,0 +1,65 @@ +From a6b868dd39b60199862e306a272b54d2ef617317 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 11 May 2023 13:21:37 +0800 +Subject: [PATCH] loginctl: list-sessions: also show state + +(cherry picked from commit 8b6c039a1ac73da006bfe9d5735515bba12ef3c4) + +Related: #2209912 +--- + src/login/loginctl.c | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 9c21b97bb5..0bea31796d 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -132,7 +132,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + if (r < 0) + return bus_log_parse_error(r); + +- table = table_new("session", "uid", "user", "seat", "tty"); ++ table = table_new("session", "uid", "user", "seat", "tty", "state"); + if (!table) + return log_oom(); + +@@ -142,7 +142,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + + for (;;) { + _cleanup_(sd_bus_error_free) sd_bus_error error_property = SD_BUS_ERROR_NULL; +- _cleanup_free_ char *tty = NULL; ++ _cleanup_free_ char *tty = NULL, *state = NULL; + const char *id, *user, *seat, *object; + uint32_t uid; + +@@ -170,12 +170,29 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + sd_bus_error_free(&error_property); + } + ++ r = sd_bus_get_property_string(bus, ++ "org.freedesktop.login1", ++ object, ++ "org.freedesktop.login1.Session", ++ "State", ++ &error_property, ++ &state); ++ if (r < 0) { ++ if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) ++ /* The session is already closed when we're querying the property */ ++ continue; ++ ++ return log_error_errno(r, "Failed to get state for session %s: %s", ++ id, bus_error_message(&error_property, r)); ++ } ++ + r = table_add_many(table, + TABLE_STRING, id, + TABLE_UID, (uid_t) uid, + TABLE_STRING, user, + TABLE_STRING, seat, +- TABLE_STRING, strna(tty)); ++ TABLE_STRING, strna(tty), ++ TABLE_STRING, state); + if (r < 0) + return table_log_add_error(r); + } diff --git a/SOURCES/0298-test-add-test-for-state-in-loginctl-list-users-sessi.patch b/SOURCES/0298-test-add-test-for-state-in-loginctl-list-users-sessi.patch new file mode 100644 index 0000000..e34aa0c --- /dev/null +++ b/SOURCES/0298-test-add-test-for-state-in-loginctl-list-users-sessi.patch @@ -0,0 +1,59 @@ +From 89f043cce92c336105e1b36b9eac4ba3bd1333b9 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Mon, 15 May 2023 13:45:33 +0800 +Subject: [PATCH] test: add test for state in loginctl list-{users,sessions} + +(cherry picked from commit 306ff2e29798f571fba573577abaeb812f7e3166) + +Related: #2209912 +--- + test/units/testsuite-35.sh | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh +index 85925f2471..c9b2417bb7 100755 +--- a/test/units/testsuite-35.sh ++++ b/test/units/testsuite-35.sh +@@ -520,7 +520,7 @@ test_session_properties() { + /usr/lib/systemd/tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}" + } + +-test_list_users() { ++test_list_users_sessions() { + if [[ ! -c /dev/tty2 ]]; then + echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}." + return +@@ -531,12 +531,22 @@ test_list_users() { + + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $1 }')" "$(id -ru logind-test-user)" + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" no ++ assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $4 }')" active ++ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $6 }')" active + + loginctl enable-linger logind-test-user +- + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" yes +-} + ++ for s in $(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $1 }'); do ++ loginctl terminate-session "$s" ++ done ++ if ! timeout 30 bash -c "while loginctl --no-legend | grep -q logind-test-user; do sleep 1; done"; then ++ echo "WARNING: session for logind-test-user still active, ignoring." ++ return ++ fi ++ ++ assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $4 }')" lingering ++} + + teardown_stop_idle_session() ( + set +eux +@@ -585,7 +595,7 @@ test_sanity_check + test_session + test_lock_idle_action + test_session_properties +-test_list_users ++test_list_users_sessions + test_stop_idle_session + + touch /testok diff --git a/SOURCES/0299-test-add-a-missing-session-activation.patch b/SOURCES/0299-test-add-a-missing-session-activation.patch new file mode 100644 index 0000000..dc9a136 --- /dev/null +++ b/SOURCES/0299-test-add-a-missing-session-activation.patch @@ -0,0 +1,45 @@ +From 3d3681dd81ad5bbae8eab7c1b4487f97678cc875 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 22 May 2023 15:08:29 +0200 +Subject: [PATCH] test: add a missing session activation + +Otherwise test_list_user_sessions() would fail unless ordered after +test_session(), which activates the session. + +(cherry picked from commit 587ae50d5529d4f312cc95ce8f0ece688c9672dc) + +Related: #2209912 +--- + test/units/testsuite-35.sh | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh +index c9b2417bb7..09009fc257 100755 +--- a/test/units/testsuite-35.sh ++++ b/test/units/testsuite-35.sh +@@ -529,6 +529,9 @@ test_list_users_sessions() { + trap cleanup_session RETURN + create_session + ++ # Activate the session ++ loginctl activate "$(loginctl --no-legend | awk '$3 == "logind-test-user" { print $1 }')" ++ + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $1 }')" "$(id -ru logind-test-user)" + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" no + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $4 }')" active +@@ -586,6 +589,7 @@ EOF + : >/failed + + setup_test_user ++test_list_users_sessions + test_enable_debug + test_properties + test_started +@@ -595,7 +599,6 @@ test_sanity_check + test_session + test_lock_idle_action + test_session_properties +-test_list_users_sessions + test_stop_idle_session + + touch /testok diff --git a/SOURCES/0300-test-extend-test-for-loginctl-list.patch b/SOURCES/0300-test-extend-test-for-loginctl-list.patch new file mode 100644 index 0000000..f829f39 --- /dev/null +++ b/SOURCES/0300-test-extend-test-for-loginctl-list.patch @@ -0,0 +1,57 @@ +From f515f2a2182e98a93b669ea744b3809be883d7fa Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 19 May 2023 14:21:44 +0200 +Subject: [PATCH] test: extend test for loginctl list-* + +(cherry picked from commit 98a155962d384ad2dd1cd11449a0143b5cfae8ef) + +Related: #2209912 +--- + test/units/testsuite-35.sh | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh +index 09009fc257..c817bc82bb 100755 +--- a/test/units/testsuite-35.sh ++++ b/test/units/testsuite-35.sh +@@ -520,7 +520,9 @@ test_session_properties() { + /usr/lib/systemd/tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}" + } + +-test_list_users_sessions() { ++test_list_users_sessions_seats() { ++ local session seat ++ + if [[ ! -c /dev/tty2 ]]; then + echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}." + return +@@ -532,10 +534,19 @@ test_list_users_sessions() { + # Activate the session + loginctl activate "$(loginctl --no-legend | awk '$3 == "logind-test-user" { print $1 }')" + ++ session=$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $1 }') ++ : check that we got a valid session id ++ busctl get-property org.freedesktop.login1 "/org/freedesktop/login1/session/_3${session?}" org.freedesktop.login1.Session Id ++ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $2 }')" "$(id -ru logind-test-user)" ++ seat=$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $4 }') ++ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $5 }')" tty2 ++ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $6 }')" active ++ ++ loginctl list-seats --no-legend | grep -Fwq "${seat?}" ++ + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $1 }')" "$(id -ru logind-test-user)" + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" no + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $4 }')" active +- assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $6 }')" active + + loginctl enable-linger logind-test-user + assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" yes +@@ -589,7 +600,7 @@ EOF + : >/failed + + setup_test_user +-test_list_users_sessions ++test_list_users_sessions_seats + test_enable_debug + test_properties + test_started diff --git a/SOURCES/0301-loginctl-shorten-variable-name.patch b/SOURCES/0301-loginctl-shorten-variable-name.patch new file mode 100644 index 0000000..14a3bdc --- /dev/null +++ b/SOURCES/0301-loginctl-shorten-variable-name.patch @@ -0,0 +1,66 @@ +From d2a9e9536aa881c130af938ccdc444252fff6412 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Tue, 23 May 2023 10:48:15 +0200 +Subject: [PATCH] loginctl: shorten variable name + +(cherry picked from commit 86f128558d57586bd28c55eb63968eab3dc4b36e) + +Related: #2209912 +--- + src/login/loginctl.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 0bea31796d..fad09cbe55 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -141,7 +141,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + (void) table_set_align_percent(table, TABLE_HEADER_CELL(1), 100); + + for (;;) { +- _cleanup_(sd_bus_error_free) sd_bus_error error_property = SD_BUS_ERROR_NULL; ++ _cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL; + _cleanup_free_ char *tty = NULL, *state = NULL; + const char *id, *user, *seat, *object; + uint32_t uid; +@@ -157,17 +157,17 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + object, + "org.freedesktop.login1.Session", + "TTY", +- &error_property, ++ &e, + &tty); + if (r < 0) { +- if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) ++ if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT)) + /* The session is already closed when we're querying the property */ + continue; + + log_warning_errno(r, "Failed to get TTY for session %s, ignoring: %s", +- id, bus_error_message(&error_property, r)); ++ id, bus_error_message(&e, r)); + +- sd_bus_error_free(&error_property); ++ sd_bus_error_free(&e); + } + + r = sd_bus_get_property_string(bus, +@@ -175,15 +175,15 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + object, + "org.freedesktop.login1.Session", + "State", +- &error_property, ++ &e, + &state); + if (r < 0) { +- if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) ++ if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT)) + /* The session is already closed when we're querying the property */ + continue; + + return log_error_errno(r, "Failed to get state for session %s: %s", +- id, bus_error_message(&error_property, r)); ++ id, bus_error_message(&e, r)); + } + + r = table_add_many(table, diff --git a/SOURCES/0302-loginctl-use-bus_map_all_properties.patch b/SOURCES/0302-loginctl-use-bus_map_all_properties.patch new file mode 100644 index 0000000..8cf61ac --- /dev/null +++ b/SOURCES/0302-loginctl-use-bus_map_all_properties.patch @@ -0,0 +1,150 @@ +From f8a5e518f0bfd44b37d3b52a8e88e67ced716889 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 19 May 2023 13:33:58 +0200 +Subject: [PATCH] loginctl: use bus_map_all_properties + +(cherry picked from commit 5b7d1536d0c2ccf0b7688490f31c92c1e766ea44) + +Related: #2209912 +--- + src/login/loginctl.c | 84 ++++++++++++++++++-------------------------- + 1 file changed, 34 insertions(+), 50 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index fad09cbe55..9a09bfc82c 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -53,6 +53,27 @@ static OutputMode arg_output = OUTPUT_SHORT; + + STATIC_DESTRUCTOR_REGISTER(arg_property, strv_freep); + ++typedef struct SessionStatusInfo { ++ const char *id; ++ uid_t uid; ++ const char *name; ++ struct dual_timestamp timestamp; ++ unsigned vtnr; ++ const char *seat; ++ const char *tty; ++ const char *display; ++ bool remote; ++ const char *remote_host; ++ const char *remote_user; ++ const char *service; ++ pid_t leader; ++ const char *type; ++ const char *class; ++ const char *state; ++ const char *scope; ++ const char *desktop; ++} SessionStatusInfo; ++ + static OutputFlags get_output_flags(void) { + + return +@@ -114,6 +135,13 @@ static int show_table(Table *table, const char *word) { + } + + static int list_sessions(int argc, char *argv[], void *userdata) { ++ ++ static const struct bus_properties_map map[] = { ++ { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, ++ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, ++ {}, ++ }; ++ + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; + _cleanup_(table_unrefp) Table *table = NULL; +@@ -142,9 +170,10 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + + for (;;) { + _cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL; +- _cleanup_free_ char *tty = NULL, *state = NULL; + const char *id, *user, *seat, *object; + uint32_t uid; ++ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; ++ SessionStatusInfo i = {}; + + r = sd_bus_message_read(reply, "(susso)", &id, &uid, &user, &seat, &object); + if (r < 0) +@@ -152,38 +181,14 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + if (r == 0) + break; + +- r = sd_bus_get_property_string(bus, +- "org.freedesktop.login1", +- object, +- "org.freedesktop.login1.Session", +- "TTY", +- &e, +- &tty); ++ r = bus_map_all_properties(bus, "org.freedesktop.login1", object, map, BUS_MAP_BOOLEAN_AS_BOOL, &e, &m, &i); + if (r < 0) { + if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT)) + /* The session is already closed when we're querying the property */ + continue; + +- log_warning_errno(r, "Failed to get TTY for session %s, ignoring: %s", ++ log_warning_errno(r, "Failed to get properties of session %s, ignoring: %s", + id, bus_error_message(&e, r)); +- +- sd_bus_error_free(&e); +- } +- +- r = sd_bus_get_property_string(bus, +- "org.freedesktop.login1", +- object, +- "org.freedesktop.login1.Session", +- "State", +- &e, +- &state); +- if (r < 0) { +- if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT)) +- /* The session is already closed when we're querying the property */ +- continue; +- +- return log_error_errno(r, "Failed to get state for session %s: %s", +- id, bus_error_message(&e, r)); + } + + r = table_add_many(table, +@@ -191,8 +196,8 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + TABLE_UID, (uid_t) uid, + TABLE_STRING, user, + TABLE_STRING, seat, +- TABLE_STRING, strna(tty), +- TABLE_STRING, state); ++ TABLE_STRING, strna(i.tty), ++ TABLE_STRING, i.state); + if (r < 0) + return table_log_add_error(r); + } +@@ -375,27 +380,6 @@ static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit + return 0; + } + +-typedef struct SessionStatusInfo { +- const char *id; +- uid_t uid; +- const char *name; +- struct dual_timestamp timestamp; +- unsigned vtnr; +- const char *seat; +- const char *tty; +- const char *display; +- bool remote; +- const char *remote_host; +- const char *remote_user; +- const char *service; +- pid_t leader; +- const char *type; +- const char *class; +- const char *state; +- const char *scope; +- const char *desktop; +-} SessionStatusInfo; +- + typedef struct UserStatusInfo { + uid_t uid; + bool linger; diff --git a/SOURCES/0303-loginctl-show-session-idle-status-in-list-sessions.patch b/SOURCES/0303-loginctl-show-session-idle-status-in-list-sessions.patch new file mode 100644 index 0000000..fd72279 --- /dev/null +++ b/SOURCES/0303-loginctl-show-session-idle-status-in-list-sessions.patch @@ -0,0 +1,96 @@ +From b4e164914c66eb8aeb71170c1d7615589783f467 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 19 May 2023 14:03:09 +0200 +Subject: [PATCH] loginctl: show session idle status in list-sessions + +(cherry picked from commit 556723e738b96a5c2b2d45a96b87b7b80e0c5664) + +Resolves: #2209912 +--- + src/login/loginctl.c | 31 +++++++++++++++++++++---------- + test/units/testsuite-35.sh | 2 ++ + 2 files changed, 23 insertions(+), 10 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 9a09bfc82c..967ae230ab 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -72,6 +72,8 @@ typedef struct SessionStatusInfo { + const char *state; + const char *scope; + const char *desktop; ++ bool idle_hint; ++ dual_timestamp idle_hint_timestamp; + } SessionStatusInfo; + + static OutputFlags get_output_flags(void) { +@@ -137,8 +139,10 @@ static int show_table(Table *table, const char *word) { + static int list_sessions(int argc, char *argv[], void *userdata) { + + static const struct bus_properties_map map[] = { +- { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, +- { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, ++ { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) }, ++ { "IdleSinceHintMonotonic", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp.monotonic) }, ++ { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, ++ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, + {}, + }; + +@@ -160,7 +164,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + if (r < 0) + return bus_log_parse_error(r); + +- table = table_new("session", "uid", "user", "seat", "tty", "state"); ++ table = table_new("session", "uid", "user", "seat", "tty", "state", "idle", "since"); + if (!table) + return log_oom(); + +@@ -183,12 +187,11 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + + r = bus_map_all_properties(bus, "org.freedesktop.login1", object, map, BUS_MAP_BOOLEAN_AS_BOOL, &e, &m, &i); + if (r < 0) { +- if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT)) +- /* The session is already closed when we're querying the property */ +- continue; +- +- log_warning_errno(r, "Failed to get properties of session %s, ignoring: %s", +- id, bus_error_message(&e, r)); ++ log_full_errno(sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT) ? LOG_DEBUG : LOG_WARNING, ++ r, ++ "Failed to get properties of session %s, ignoring: %s", ++ id, bus_error_message(&e, r)); ++ continue; + } + + r = table_add_many(table, +@@ -197,7 +200,15 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + TABLE_STRING, user, + TABLE_STRING, seat, + TABLE_STRING, strna(i.tty), +- TABLE_STRING, i.state); ++ TABLE_STRING, i.state, ++ TABLE_BOOLEAN, i.idle_hint); ++ if (r < 0) ++ return table_log_add_error(r); ++ ++ if (i.idle_hint) ++ r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &i.idle_hint_timestamp.monotonic); ++ else ++ r = table_add_cell(table, NULL, TABLE_EMPTY, NULL); + if (r < 0) + return table_log_add_error(r); + } +diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh +index c817bc82bb..1863c535a4 100755 +--- a/test/units/testsuite-35.sh ++++ b/test/units/testsuite-35.sh +@@ -541,6 +541,8 @@ test_list_users_sessions_seats() { + seat=$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $4 }') + assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $5 }')" tty2 + assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $6 }')" active ++ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $7 }')" no ++ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $8 }')" '' + + loginctl list-seats --no-legend | grep -Fwq "${seat?}" + diff --git a/SOURCES/0304-loginctl-some-modernizations.patch b/SOURCES/0304-loginctl-some-modernizations.patch new file mode 100644 index 0000000..9083fec --- /dev/null +++ b/SOURCES/0304-loginctl-some-modernizations.patch @@ -0,0 +1,184 @@ +From 1cb097a7c664b253556b3b63b7899d76d7e4cba5 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Wed, 24 May 2023 19:42:03 +0800 +Subject: [PATCH] loginctl: some modernizations + +(cherry picked from commit c9443393b5a1e6f8941e04e2641135ab3936a8a0) + +Related: #2209912 +--- + src/login/loginctl.c | 85 +++++++++++++++++++++++--------------------- + 1 file changed, 44 insertions(+), 41 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 967ae230ab..25e5787c11 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -57,7 +57,7 @@ typedef struct SessionStatusInfo { + const char *id; + uid_t uid; + const char *name; +- struct dual_timestamp timestamp; ++ dual_timestamp timestamp; + unsigned vtnr; + const char *seat; + const char *tty; +@@ -76,8 +76,36 @@ typedef struct SessionStatusInfo { + dual_timestamp idle_hint_timestamp; + } SessionStatusInfo; + +-static OutputFlags get_output_flags(void) { ++typedef struct UserStatusInfo { ++ uid_t uid; ++ bool linger; ++ const char *name; ++ dual_timestamp timestamp; ++ const char *state; ++ char **sessions; ++ const char *display; ++ const char *slice; ++} UserStatusInfo; + ++typedef struct SeatStatusInfo { ++ const char *id; ++ const char *active_session; ++ char **sessions; ++} SeatStatusInfo; ++ ++static void user_status_info_done(UserStatusInfo *info) { ++ assert(info); ++ ++ strv_free(info->sessions); ++} ++ ++static void seat_status_info_done(SeatStatusInfo *info) { ++ assert(info); ++ ++ strv_free(info->sessions); ++} ++ ++static OutputFlags get_output_flags(void) { + return + FLAGS_SET(arg_print_flags, BUS_PRINT_PROPERTY_SHOW_EMPTY) * OUTPUT_SHOW_ALL | + (arg_full || !on_tty() || pager_have()) * OUTPUT_FULL_WIDTH | +@@ -86,8 +114,13 @@ static OutputFlags get_output_flags(void) { + + static int get_session_path(sd_bus *bus, const char *session_id, sd_bus_error *error, char **path) { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; +- int r; + char *ans; ++ int r; ++ ++ assert(bus); ++ assert(session_id); ++ assert(error); ++ assert(path); + + r = bus_call_method(bus, bus_login_mgr, "GetSession", error, &reply, "s", session_id); + if (r < 0) +@@ -391,41 +424,13 @@ static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit + return 0; + } + +-typedef struct UserStatusInfo { +- uid_t uid; +- bool linger; +- const char *name; +- struct dual_timestamp timestamp; +- const char *state; +- char **sessions; +- const char *display; +- const char *slice; +-} UserStatusInfo; +- +-typedef struct SeatStatusInfo { +- const char *id; +- const char *active_session; +- char **sessions; +-} SeatStatusInfo; +- +-static void user_status_info_clear(UserStatusInfo *info) { +- if (info) { +- strv_free(info->sessions); +- zero(*info); +- } +-} +- +-static void seat_status_info_clear(SeatStatusInfo *info) { +- if (info) { +- strv_free(info->sessions); +- zero(*info); +- } +-} +- + static int prop_map_first_of_struct(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { + const char *contents; + int r; + ++ assert(bus); ++ assert(m); ++ + r = sd_bus_message_peek_type(m, NULL, &contents); + if (r < 0) + return r; +@@ -473,7 +478,7 @@ static int prop_map_sessions_strv(sd_bus *bus, const char *member, sd_bus_messag + + static int print_session_status_info(sd_bus *bus, const char *path, bool *new_line) { + +- static const struct bus_properties_map map[] = { ++ static const struct bus_properties_map map[] = { + { "Id", "s", NULL, offsetof(SessionStatusInfo, id) }, + { "Name", "s", NULL, offsetof(SessionStatusInfo, name) }, + { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, +@@ -608,7 +613,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li + + static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) { + +- static const struct bus_properties_map map[] = { ++ static const struct bus_properties_map map[] = { + { "Name", "s", NULL, offsetof(UserStatusInfo, name) }, + { "Linger", "b", NULL, offsetof(UserStatusInfo, linger) }, + { "Slice", "s", NULL, offsetof(UserStatusInfo, slice) }, +@@ -623,7 +628,7 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) + + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; +- _cleanup_(user_status_info_clear) UserStatusInfo i = {}; ++ _cleanup_(user_status_info_done) UserStatusInfo i = {}; + int r; + + r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, BUS_MAP_BOOLEAN_AS_BOOL, &error, &m, &i); +@@ -685,7 +690,7 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) + + static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line) { + +- static const struct bus_properties_map map[] = { ++ static const struct bus_properties_map map[] = { + { "Id", "s", NULL, offsetof(SeatStatusInfo, id) }, + { "ActiveSession", "(so)", prop_map_first_of_struct, offsetof(SeatStatusInfo, active_session) }, + { "Sessions", "a(so)", prop_map_sessions_strv, offsetof(SeatStatusInfo, sessions) }, +@@ -694,7 +699,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line) + + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; +- _cleanup_(seat_status_info_clear) SeatStatusInfo i = {}; ++ _cleanup_(seat_status_info_done) SeatStatusInfo i = {}; + int r; + + r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, 0, &error, &m, &i); +@@ -1009,7 +1014,6 @@ static int activate(int argc, char *argv[], void *userdata) { + } + + for (int i = 1; i < argc; i++) { +- + r = bus_call_method( + bus, + bus_login_mgr, +@@ -1039,7 +1043,6 @@ static int kill_session(int argc, char *argv[], void *userdata) { + arg_kill_whom = "all"; + + for (int i = 1; i < argc; i++) { +- + r = bus_call_method( + bus, + bus_login_mgr, diff --git a/SOURCES/0305-loginctl-list-sessions-fix-timestamp-for-idle-hint.patch b/SOURCES/0305-loginctl-list-sessions-fix-timestamp-for-idle-hint.patch new file mode 100644 index 0000000..6b61cc8 --- /dev/null +++ b/SOURCES/0305-loginctl-list-sessions-fix-timestamp-for-idle-hint.patch @@ -0,0 +1,55 @@ +From 0884a1675b2ad20fdf7f98849ad6592a10b893e4 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 25 May 2023 01:20:45 +0800 +Subject: [PATCH] loginctl: list-sessions: fix timestamp for idle hint + +Follow-up for 556723e738b96a5c2b2d45a96b87b7b80e0c5664 + +TABLE_TIMESTAMP_RELATIVE takes a realtime timestamp. + +(cherry picked from commit be88af3d9646c8bd1aaea3d4a00520e97ee8674d) + +Related: #2209912 +--- + src/login/loginctl.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 25e5787c11..598acf766d 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -73,7 +73,7 @@ typedef struct SessionStatusInfo { + const char *scope; + const char *desktop; + bool idle_hint; +- dual_timestamp idle_hint_timestamp; ++ usec_t idle_hint_timestamp; + } SessionStatusInfo; + + typedef struct UserStatusInfo { +@@ -171,11 +171,11 @@ static int show_table(Table *table, const char *word) { + + static int list_sessions(int argc, char *argv[], void *userdata) { + +- static const struct bus_properties_map map[] = { +- { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) }, +- { "IdleSinceHintMonotonic", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp.monotonic) }, +- { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, +- { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, ++ static const struct bus_properties_map map[] = { ++ { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) }, ++ { "IdleSinceHint", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp) }, ++ { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, ++ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, + {}, + }; + +@@ -239,7 +239,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + return table_log_add_error(r); + + if (i.idle_hint) +- r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &i.idle_hint_timestamp.monotonic); ++ r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &i.idle_hint_timestamp); + else + r = table_add_cell(table, NULL, TABLE_EMPTY, NULL); + if (r < 0) diff --git a/SOURCES/0306-loginctl-list-users-use-bus_map_all_properties.patch b/SOURCES/0306-loginctl-list-users-use-bus_map_all_properties.patch new file mode 100644 index 0000000..9f87e46 --- /dev/null +++ b/SOURCES/0306-loginctl-list-users-use-bus_map_all_properties.patch @@ -0,0 +1,103 @@ +From 837b3a3ba22efd133c8b39e142994405cc1aa322 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Tue, 23 May 2023 18:27:05 +0800 +Subject: [PATCH] loginctl: list-users: use bus_map_all_properties + +(cherry picked from commit 8b0da9971afabd47e2e0b72be82dc37c06caabee) + +Related: #2209912 +--- + src/login/loginctl.c | 58 ++++++++++++++++++-------------------------- + 1 file changed, 24 insertions(+), 34 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 598acf766d..98bb87bd87 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -254,6 +254,13 @@ static int list_sessions(int argc, char *argv[], void *userdata) { + } + + static int list_users(int argc, char *argv[], void *userdata) { ++ ++ static const struct bus_properties_map property_map[] = { ++ { "Linger", "b", NULL, offsetof(UserStatusInfo, linger) }, ++ { "State", "s", NULL, offsetof(UserStatusInfo, state) }, ++ {}, ++ }; ++ + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; + _cleanup_(table_unrefp) Table *table = NULL; +@@ -280,10 +287,10 @@ static int list_users(int argc, char *argv[], void *userdata) { + + for (;;) { + _cleanup_(sd_bus_error_free) sd_bus_error error_property = SD_BUS_ERROR_NULL; +- _cleanup_free_ char *state = NULL; ++ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply_property = NULL; ++ _cleanup_(user_status_info_done) UserStatusInfo info = {}; + const char *user, *object; + uint32_t uid; +- int linger; + + r = sd_bus_message_read(reply, "(uso)", &uid, &user, &object); + if (r < 0) +@@ -291,44 +298,27 @@ static int list_users(int argc, char *argv[], void *userdata) { + if (r == 0) + break; + +- r = sd_bus_get_property_trivial(bus, +- "org.freedesktop.login1", +- object, +- "org.freedesktop.login1.User", +- "Linger", +- &error_property, +- 'b', +- &linger); ++ r = bus_map_all_properties(bus, ++ "org.freedesktop.login1", ++ object, ++ property_map, ++ BUS_MAP_BOOLEAN_AS_BOOL, ++ &error_property, ++ &reply_property, ++ &info); + if (r < 0) { +- if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) +- /* The user logged out when we're querying the property */ +- continue; +- +- return log_error_errno(r, "Failed to get linger status for user %s: %s", +- user, bus_error_message(&error_property, r)); +- } +- +- r = sd_bus_get_property_string(bus, +- "org.freedesktop.login1", +- object, +- "org.freedesktop.login1.User", +- "State", +- &error_property, +- &state); +- if (r < 0) { +- if (sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT)) +- /* The user logged out when we're querying the property */ +- continue; +- +- return log_error_errno(r, "Failed to get state for user %s: %s", +- user, bus_error_message(&error_property, r)); ++ log_full_errno(sd_bus_error_has_name(&error_property, SD_BUS_ERROR_UNKNOWN_OBJECT) ? LOG_DEBUG : LOG_WARNING, ++ r, ++ "Failed to get properties of user %s, ignoring: %s", ++ user, bus_error_message(&error_property, r)); ++ continue; + } + + r = table_add_many(table, + TABLE_UID, (uid_t) uid, + TABLE_STRING, user, +- TABLE_BOOLEAN, linger, +- TABLE_STRING, state); ++ TABLE_BOOLEAN, info.linger, ++ TABLE_STRING, info.state); + if (r < 0) + return table_log_add_error(r); + } diff --git a/SOURCES/0307-loginctl-also-show-idle-hint-in-session-status.patch b/SOURCES/0307-loginctl-also-show-idle-hint-in-session-status.patch new file mode 100644 index 0000000..5f5fe33 --- /dev/null +++ b/SOURCES/0307-loginctl-also-show-idle-hint-in-session-status.patch @@ -0,0 +1,78 @@ +From e9d8b5a3d251007444f7722e34cd43ca4c1d628b Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Tue, 23 May 2023 18:54:30 +0800 +Subject: [PATCH] loginctl: also show idle hint in session-status + +(cherry picked from commit 82449055af97cf92466dbe132a89c9d889440c3d) + +Related: #2209912 +--- + src/login/loginctl.c | 48 ++++++++++++++++++++++++++------------------ + 1 file changed, 29 insertions(+), 19 deletions(-) + +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index 98bb87bd87..e2eda66da7 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -469,25 +469,27 @@ static int prop_map_sessions_strv(sd_bus *bus, const char *member, sd_bus_messag + static int print_session_status_info(sd_bus *bus, const char *path, bool *new_line) { + + static const struct bus_properties_map map[] = { +- { "Id", "s", NULL, offsetof(SessionStatusInfo, id) }, +- { "Name", "s", NULL, offsetof(SessionStatusInfo, name) }, +- { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, +- { "Display", "s", NULL, offsetof(SessionStatusInfo, display) }, +- { "RemoteHost", "s", NULL, offsetof(SessionStatusInfo, remote_host) }, +- { "RemoteUser", "s", NULL, offsetof(SessionStatusInfo, remote_user) }, +- { "Service", "s", NULL, offsetof(SessionStatusInfo, service) }, +- { "Desktop", "s", NULL, offsetof(SessionStatusInfo, desktop) }, +- { "Type", "s", NULL, offsetof(SessionStatusInfo, type) }, +- { "Class", "s", NULL, offsetof(SessionStatusInfo, class) }, +- { "Scope", "s", NULL, offsetof(SessionStatusInfo, scope) }, +- { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, +- { "VTNr", "u", NULL, offsetof(SessionStatusInfo, vtnr) }, +- { "Leader", "u", NULL, offsetof(SessionStatusInfo, leader) }, +- { "Remote", "b", NULL, offsetof(SessionStatusInfo, remote) }, +- { "Timestamp", "t", NULL, offsetof(SessionStatusInfo, timestamp.realtime) }, +- { "TimestampMonotonic", "t", NULL, offsetof(SessionStatusInfo, timestamp.monotonic) }, +- { "User", "(uo)", prop_map_first_of_struct, offsetof(SessionStatusInfo, uid) }, +- { "Seat", "(so)", prop_map_first_of_struct, offsetof(SessionStatusInfo, seat) }, ++ { "Id", "s", NULL, offsetof(SessionStatusInfo, id) }, ++ { "Name", "s", NULL, offsetof(SessionStatusInfo, name) }, ++ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) }, ++ { "Display", "s", NULL, offsetof(SessionStatusInfo, display) }, ++ { "RemoteHost", "s", NULL, offsetof(SessionStatusInfo, remote_host) }, ++ { "RemoteUser", "s", NULL, offsetof(SessionStatusInfo, remote_user) }, ++ { "Service", "s", NULL, offsetof(SessionStatusInfo, service) }, ++ { "Desktop", "s", NULL, offsetof(SessionStatusInfo, desktop) }, ++ { "Type", "s", NULL, offsetof(SessionStatusInfo, type) }, ++ { "Class", "s", NULL, offsetof(SessionStatusInfo, class) }, ++ { "Scope", "s", NULL, offsetof(SessionStatusInfo, scope) }, ++ { "State", "s", NULL, offsetof(SessionStatusInfo, state) }, ++ { "VTNr", "u", NULL, offsetof(SessionStatusInfo, vtnr) }, ++ { "Leader", "u", NULL, offsetof(SessionStatusInfo, leader) }, ++ { "Remote", "b", NULL, offsetof(SessionStatusInfo, remote) }, ++ { "Timestamp", "t", NULL, offsetof(SessionStatusInfo, timestamp.realtime) }, ++ { "TimestampMonotonic", "t", NULL, offsetof(SessionStatusInfo, timestamp.monotonic) }, ++ { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) }, ++ { "IdleSinceHint", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp) }, ++ { "User", "(uo)", prop_map_first_of_struct, offsetof(SessionStatusInfo, uid) }, ++ { "Seat", "(so)", prop_map_first_of_struct, offsetof(SessionStatusInfo, seat) }, + {} + }; + +@@ -578,6 +580,14 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li + if (i.state) + printf("\t State: %s\n", i.state); + ++ if (i.idle_hint && timestamp_is_set(i.idle_hint_timestamp)) ++ printf("\t Idle: %s since %s (%s)\n", ++ yes_no(i.idle_hint), ++ FORMAT_TIMESTAMP(i.idle_hint_timestamp), ++ FORMAT_TIMESTAMP_RELATIVE(i.idle_hint_timestamp)); ++ else ++ printf("\t Idle: %s\n", yes_no(i.idle_hint)); ++ + if (i.scope) { + printf("\t Unit: %s\n", i.scope); + show_unit_cgroup(bus, "org.freedesktop.systemd1.Scope", i.scope, i.leader); diff --git a/SOURCES/0308-memory-util-make-ArrayCleanup-passed-to-array_cleanu.patch b/SOURCES/0308-memory-util-make-ArrayCleanup-passed-to-array_cleanu.patch new file mode 100644 index 0000000..afc6704 --- /dev/null +++ b/SOURCES/0308-memory-util-make-ArrayCleanup-passed-to-array_cleanu.patch @@ -0,0 +1,45 @@ +From 0b4518d1f00543a25b5fc30a6203cd59c84cf8c4 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 7 May 2023 18:34:35 +0900 +Subject: [PATCH] memory-util: make ArrayCleanup passed to array_cleanup() + const + +Should not change any behavior, preparation for later commits. + +(cherry picked from commit 3facdc7da8ad424a38ce9c673fbb94a41e070a7d) + +Related: #2190226 +--- + src/basic/memory-util.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/basic/memory-util.h b/src/basic/memory-util.h +index 8d75befed5..eea9c0e92f 100644 +--- a/src/basic/memory-util.h ++++ b/src/basic/memory-util.h +@@ -123,13 +123,13 @@ static inline void erase_char(char *p) { + } + + /* An automatic _cleanup_-like logic for destroy arrays (i.e. pointers + size) when leaving scope */ +-struct ArrayCleanup { ++typedef struct ArrayCleanup { + void **parray; + size_t *pn; + free_array_func_t pfunc; +-}; ++} ArrayCleanup; + +-static inline void array_cleanup(struct ArrayCleanup *c) { ++static inline void array_cleanup(const ArrayCleanup *c) { + assert(c); + + assert(!c->parray == !c->pn); +@@ -147,7 +147,7 @@ static inline void array_cleanup(struct ArrayCleanup *c) { + } + + #define CLEANUP_ARRAY(array, n, func) \ +- _cleanup_(array_cleanup) _unused_ struct ArrayCleanup CONCATENATE(_cleanup_array_, UNIQ) = { \ ++ _cleanup_(array_cleanup) _unused_ const ArrayCleanup CONCATENATE(_cleanup_array_, UNIQ) = { \ + .parray = (void**) &(array), \ + .pn = &(n), \ + .pfunc = (free_array_func_t) ({ \ diff --git a/SOURCES/0309-static-destruct-several-cleanups.patch b/SOURCES/0309-static-destruct-several-cleanups.patch new file mode 100644 index 0000000..d1629a4 --- /dev/null +++ b/SOURCES/0309-static-destruct-several-cleanups.patch @@ -0,0 +1,87 @@ +From 8d45c6b730d7c56e970708767301700397756b52 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 7 May 2023 18:37:13 +0900 +Subject: [PATCH] static-destruct: several cleanups + +No functional changes, preparation for later commits. + +(cherry picked from commit 555ead898539183a435e18c6e1e4d5fb89499231) + +Related: #2190226 +--- + src/basic/static-destruct.h | 42 ++++++++++++++++++------------------- + 1 file changed, 21 insertions(+), 21 deletions(-) + +diff --git a/src/basic/static-destruct.h b/src/basic/static-destruct.h +index 97baac7abb..4bc82889be 100644 +--- a/src/basic/static-destruct.h ++++ b/src/basic/static-destruct.h +@@ -10,6 +10,21 @@ + * feel a bit like the gcc cleanup attribute, but for static variables. Note that this does not work for static + * variables declared in .so's, as the list is private to the same linking unit. But maybe that's a good thing. */ + ++#define _common_static_destruct_attrs_ \ ++ /* Older compilers don't know "retain" attribute. */ \ ++ _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ ++ /* The actual destructor structure we place in a special section to find it. */ \ ++ _section_("SYSTEMD_STATIC_DESTRUCT") \ ++ /* Use pointer alignment, since that is apparently what gcc does for static variables. */ \ ++ _alignptr_ \ ++ /* Make sure this is not dropped from the image despite not being explicitly referenced. */ \ ++ _used_ \ ++ /* Prevent garbage collection by the linker. */ \ ++ _retain_ \ ++ /* Make sure that AddressSanitizer doesn't pad this variable: we want everything in this section ++ * packed next to each other so that we can enumerate it. */ \ ++ _variable_no_sanitize_address_ ++ + typedef struct StaticDestructor { + void *data; + free_func_t destroy; +@@ -24,19 +39,7 @@ typedef struct StaticDestructor { + typeof(variable) *q = p; \ + func(q); \ + } \ +- /* Older compilers don't know "retain" attribute. */ \ +- _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ +- /* The actual destructor structure we place in a special section to find it. */ \ +- _section_("SYSTEMD_STATIC_DESTRUCT") \ +- /* Use pointer alignment, since that is apparently what gcc does for static variables. */ \ +- _alignptr_ \ +- /* Make sure this is not dropped from the image despite not being explicitly referenced. */ \ +- _used_ \ +- /* Prevent garbage collection by the linker. */ \ +- _retain_ \ +- /* Make sure that AddressSanitizer doesn't pad this variable: we want everything in this section +- * packed next to each other so that we can enumerate it. */ \ +- _variable_no_sanitize_address_ \ ++ _common_static_destruct_attrs_ \ + static const StaticDestructor UNIQ_T(static_destructor_entry, uq) = { \ + .data = &(variable), \ + .destroy = UNIQ_T(static_destructor_wrapper, uq), \ +@@ -44,20 +47,17 @@ typedef struct StaticDestructor { + + /* Beginning and end of our section listing the destructors. We define these as weak as we want this to work + * even if no destructors are defined and the section is missing. */ +-extern const struct StaticDestructor _weak_ __start_SYSTEMD_STATIC_DESTRUCT[]; +-extern const struct StaticDestructor _weak_ __stop_SYSTEMD_STATIC_DESTRUCT[]; ++extern const StaticDestructor _weak_ __start_SYSTEMD_STATIC_DESTRUCT[]; ++extern const StaticDestructor _weak_ __stop_SYSTEMD_STATIC_DESTRUCT[]; + + /* The function to destroy everything. (Note that this must be static inline, as it's key that it remains in + * the same linking unit as the variables we want to destroy.) */ + static inline void static_destruct(void) { +- const StaticDestructor *d; +- + if (!__start_SYSTEMD_STATIC_DESTRUCT) + return; + +- d = ALIGN_PTR(__start_SYSTEMD_STATIC_DESTRUCT); +- while (d < __stop_SYSTEMD_STATIC_DESTRUCT) { ++ for (const StaticDestructor *d = ALIGN_PTR(__start_SYSTEMD_STATIC_DESTRUCT); ++ d < __stop_SYSTEMD_STATIC_DESTRUCT; ++ d = ALIGN_PTR(d + 1)) + d->destroy(d->data); +- d = ALIGN_PTR(d + 1); +- } + } diff --git a/SOURCES/0310-static-destruct-introduce-STATIC_ARRAY_DESTRUCTOR_RE.patch b/SOURCES/0310-static-destruct-introduce-STATIC_ARRAY_DESTRUCTOR_RE.patch new file mode 100644 index 0000000..a81f904 --- /dev/null +++ b/SOURCES/0310-static-destruct-introduce-STATIC_ARRAY_DESTRUCTOR_RE.patch @@ -0,0 +1,172 @@ +From a8f31096dcd402b4c8d57c2a8f86b52146077ce3 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Tue, 9 May 2023 06:44:27 +0900 +Subject: [PATCH] static-destruct: introduce STATIC_ARRAY_DESTRUCTOR_REGISTER() + +(cherry picked from commit 9695b0c01bf3d4b260432fb6754c7fbe9173c7db) + +Related: #2190226 +--- + src/basic/static-destruct.h | 50 ++++++++++++++++++++++++++++++--- + src/test/test-static-destruct.c | 41 ++++++++++++++++++++++++--- + 2 files changed, 83 insertions(+), 8 deletions(-) + +diff --git a/src/basic/static-destruct.h b/src/basic/static-destruct.h +index 4bc82889be..2ffc6516f8 100644 +--- a/src/basic/static-destruct.h ++++ b/src/basic/static-destruct.h +@@ -4,6 +4,7 @@ + + #include "alloc-util.h" + #include "macro.h" ++#include "memory-util.h" + + /* A framework for registering static variables that shall be freed on shutdown of a process. It's a bit like gcc's + * destructor attribute, but allows us to precisely schedule when we want to free the variables. This is supposed to +@@ -25,9 +26,24 @@ + * packed next to each other so that we can enumerate it. */ \ + _variable_no_sanitize_address_ + +-typedef struct StaticDestructor { ++typedef enum StaticDestructorType { ++ STATIC_DESTRUCTOR_SIMPLE, ++ STATIC_DESTRUCTOR_ARRAY, ++ _STATIC_DESTRUCTOR_TYPE_MAX, ++ _STATIC_DESTRUCTOR_INVALID = -EINVAL, ++} StaticDestructorType; ++ ++typedef struct SimpleCleanup { + void *data; + free_func_t destroy; ++} SimpleCleanup; ++ ++typedef struct StaticDestructor { ++ StaticDestructorType type; ++ union { ++ SimpleCleanup simple; ++ ArrayCleanup array; ++ }; + } StaticDestructor; + + #define STATIC_DESTRUCTOR_REGISTER(variable, func) \ +@@ -41,10 +57,25 @@ typedef struct StaticDestructor { + } \ + _common_static_destruct_attrs_ \ + static const StaticDestructor UNIQ_T(static_destructor_entry, uq) = { \ +- .data = &(variable), \ +- .destroy = UNIQ_T(static_destructor_wrapper, uq), \ ++ .type = STATIC_DESTRUCTOR_SIMPLE, \ ++ .simple.data = &(variable), \ ++ .simple.destroy = UNIQ_T(static_destructor_wrapper, uq), \ + } + ++#define STATIC_ARRAY_DESTRUCTOR_REGISTER(a, n, func) \ ++ _STATIC_ARRAY_DESTRUCTOR_REGISTER(UNIQ, a, n, func) ++ ++#define _STATIC_ARRAY_DESTRUCTOR_REGISTER(uq, a, n, func) \ ++ /* Type-safety check */ \ ++ _unused_ static void (* UNIQ_T(static_destructor_wrapper, uq))(typeof(a[0]) *x, size_t y) = (func); \ ++ _common_static_destruct_attrs_ \ ++ static const StaticDestructor UNIQ_T(static_destructor_entry, uq) = { \ ++ .type = STATIC_DESTRUCTOR_ARRAY, \ ++ .array.parray = (void**) &(a), \ ++ .array.pn = &(n), \ ++ .array.pfunc = (free_array_func_t) (func), \ ++ }; ++ + /* Beginning and end of our section listing the destructors. We define these as weak as we want this to work + * even if no destructors are defined and the section is missing. */ + extern const StaticDestructor _weak_ __start_SYSTEMD_STATIC_DESTRUCT[]; +@@ -59,5 +90,16 @@ static inline void static_destruct(void) { + for (const StaticDestructor *d = ALIGN_PTR(__start_SYSTEMD_STATIC_DESTRUCT); + d < __stop_SYSTEMD_STATIC_DESTRUCT; + d = ALIGN_PTR(d + 1)) +- d->destroy(d->data); ++ switch (d->type) { ++ case STATIC_DESTRUCTOR_SIMPLE: ++ d->simple.destroy(d->simple.data); ++ break; ++ ++ case STATIC_DESTRUCTOR_ARRAY: ++ array_cleanup(&d->array); ++ break; ++ ++ default: ++ assert_not_reached(); ++ } + } +diff --git a/src/test/test-static-destruct.c b/src/test/test-static-destruct.c +index cb518ea362..ef8648f588 100644 +--- a/src/test/test-static-destruct.c ++++ b/src/test/test-static-destruct.c +@@ -2,17 +2,38 @@ + + #include "alloc-util.h" + #include "static-destruct.h" ++#include "strv.h" + #include "tests.h" + + static int foo = 0; + static int bar = 0; + static int baz = 0; +-static char* memory = NULL; ++static char *memory = NULL; ++static char **strings = NULL; ++static size_t n_strings = 0; ++static int *integers = NULL; ++static size_t n_integers = 0; + + static void test_destroy(int *b) { + (*b)++; + } + ++static void test_strings_destroy(char **array, size_t n) { ++ assert_se(n == 3); ++ assert_se(strv_equal(array, STRV_MAKE("a", "bbb", "ccc"))); ++ ++ strv_free(array); ++} ++ ++static void test_integers_destroy(int *array, size_t n) { ++ assert_se(n == 10); ++ ++ for (size_t i = 0; i < n; i++) ++ assert_se(array[i] == (int)(i * i)); ++ ++ free(array); ++} ++ + STATIC_DESTRUCTOR_REGISTER(foo, test_destroy); + STATIC_DESTRUCTOR_REGISTER(bar, test_destroy); + STATIC_DESTRUCTOR_REGISTER(bar, test_destroy); +@@ -20,15 +41,27 @@ STATIC_DESTRUCTOR_REGISTER(baz, test_destroy); + STATIC_DESTRUCTOR_REGISTER(baz, test_destroy); + STATIC_DESTRUCTOR_REGISTER(baz, test_destroy); + STATIC_DESTRUCTOR_REGISTER(memory, freep); ++STATIC_ARRAY_DESTRUCTOR_REGISTER(strings, n_strings, test_strings_destroy); ++STATIC_ARRAY_DESTRUCTOR_REGISTER(integers, n_integers, test_integers_destroy); + + TEST(static_destruct) { ++ assert_se(foo == 0 && bar == 0 && baz == 0); + assert_se(memory = strdup("hallo")); ++ assert_se(strings = strv_new("a", "bbb", "ccc")); ++ n_strings = strv_length(strings); ++ n_integers = 10; ++ assert_se(integers = new(int, n_integers)); ++ for (size_t i = 0; i < n_integers; i++) ++ integers[i] = i * i; + +- assert_se(foo == 0 && bar == 0 && baz == 0); + static_destruct(); +- assert_se(foo == 1 && bar == 2 && baz == 3); + +- assert_se(memory == NULL); ++ assert_se(foo == 1 && bar == 2 && baz == 3); ++ assert_se(!memory); ++ assert_se(!strings); ++ assert_se(n_strings == 0); ++ assert_se(!integers); ++ assert_se(n_integers == 0); + } + + DEFINE_TEST_MAIN(LOG_INFO); diff --git a/SOURCES/0311-macro-support-the-case-that-the-number-of-elements-h.patch b/SOURCES/0311-macro-support-the-case-that-the-number-of-elements-h.patch new file mode 100644 index 0000000..ae48e42 --- /dev/null +++ b/SOURCES/0311-macro-support-the-case-that-the-number-of-elements-h.patch @@ -0,0 +1,40 @@ +From 7ca6eafaa28848cb917a2cd4af78a9c85c3fd51a Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 9 Mar 2023 13:14:12 +0900 +Subject: [PATCH] macro: support the case that the number of elements has const + qualifier + +Follow-up for 5716c27e1f52d2aba9dd02916c01d6271d9d0b16. + +Addresses https://github.com/systemd/systemd/pull/26303#issuecomment-1460712007. + +(cherry picked from commit b9872fe1ddb61a7f930c652887c04e2f82b43be4) + +Related: #2190226 +--- + src/basic/macro.h | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/src/basic/macro.h b/src/basic/macro.h +index b977730e54..72a2c7267e 100644 +--- a/src/basic/macro.h ++++ b/src/basic/macro.h +@@ -329,12 +329,14 @@ static inline int __coverity_check_and_return__(int condition) { + #endif + #endif + +-#define _FOREACH_ARRAY(i, array, num, m, s) \ +- for (typeof(num) m = (num); m > 0; m = 0) \ +- for (typeof(array[0]) *s = (array), *i = s; s && i < s + m; i++) ++#define _FOREACH_ARRAY(i, array, num, m, end) \ ++ for (typeof(array[0]) *i = (array), *end = ({ \ ++ typeof(num) m = (num); \ ++ (i && m > 0) ? i + m : NULL; \ ++ }); end && i < end; i++) + + #define FOREACH_ARRAY(i, array, num) \ +- _FOREACH_ARRAY(i, array, num, UNIQ_T(m, UNIQ), UNIQ_T(s, UNIQ)) ++ _FOREACH_ARRAY(i, array, num, UNIQ_T(m, UNIQ), UNIQ_T(end, UNIQ)) + + #define DEFINE_TRIVIAL_DESTRUCTOR(name, type, func) \ + static inline void name(type *p) { \ diff --git a/SOURCES/0312-shared-generator-apply-similar-config-reordering-of-.patch b/SOURCES/0312-shared-generator-apply-similar-config-reordering-of-.patch new file mode 100644 index 0000000..ec97068 --- /dev/null +++ b/SOURCES/0312-shared-generator-apply-similar-config-reordering-of-.patch @@ -0,0 +1,74 @@ +From b663e9f1256c62fa0e1c0fb80e6cd4a3c055716d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 28 Sep 2022 13:38:56 +0200 +Subject: [PATCH] shared/generator: apply similar config reordering of + generated units + +(cherry picked from commit ce37fb0d92ca8af31215c81b573ebaac81ed6fd2) + +Related: #2190226 +--- + src/shared/generator.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/src/shared/generator.c b/src/shared/generator.c +index 5d019f4f4e..4c684fc3e7 100644 +--- a/src/shared/generator.c ++++ b/src/shared/generator.c +@@ -116,6 +116,7 @@ static int write_fsck_sysroot_service( + "[Unit]\n" + "Description=File System Check on %2$s\n" + "Documentation=man:%3$s(8)\n" ++ "\n" + "DefaultDependencies=no\n" + "BindsTo=%4$s\n" + "Conflicts=shutdown.target\n" +@@ -409,11 +410,13 @@ int generator_hook_up_mkswap( + "[Unit]\n" + "Description=Make Swap on %%f\n" + "Documentation=man:systemd-mkswap@.service(8)\n" ++ "\n" + "DefaultDependencies=no\n" + "BindsTo=%%i.device\n" +- "Conflicts=shutdown.target\n" + "After=%%i.device\n" +- "Before=shutdown.target %s\n" ++ "Before=%s\n" ++ "Conflicts=shutdown.target\n" ++ "Before=shutdown.target\n" + "\n" + "[Service]\n" + "Type=oneshot\n" +@@ -486,13 +489,15 @@ int generator_hook_up_mkfs( + "[Unit]\n" + "Description=Make File System on %%f\n" + "Documentation=man:systemd-makefs@.service(8)\n" ++ "\n" + "DefaultDependencies=no\n" + "BindsTo=%%i.device\n" +- "Conflicts=shutdown.target\n" + "After=%%i.device\n" + /* fsck might or might not be used, so let's be safe and order + * ourselves before both systemd-fsck@.service and the mount unit. */ +- "Before=shutdown.target systemd-fsck@%%i.service %s\n" ++ "Before=systemd-fsck@%%i.service %s\n" ++ "Conflicts=shutdown.target\n" ++ "Before=shutdown.target\n" + "\n" + "[Service]\n" + "Type=oneshot\n" +@@ -624,11 +629,12 @@ int generator_write_cryptsetup_unit_section( + fprintf(f, "SourcePath=%s\n", source); + + fprintf(f, ++ "\n" + "DefaultDependencies=no\n" +- "IgnoreOnIsolate=true\n" + "After=cryptsetup-pre.target systemd-udevd-kernel.socket\n" + "Before=blockdev@dev-mapper-%%i.target\n" +- "Wants=blockdev@dev-mapper-%%i.target\n"); ++ "Wants=blockdev@dev-mapper-%%i.target\n" ++ "IgnoreOnIsolate=true\n"); + + return 0; + } diff --git a/SOURCES/0313-nulstr-util-make-ret_size-in-strv_make_nulstr-option.patch b/SOURCES/0313-nulstr-util-make-ret_size-in-strv_make_nulstr-option.patch new file mode 100644 index 0000000..a549102 --- /dev/null +++ b/SOURCES/0313-nulstr-util-make-ret_size-in-strv_make_nulstr-option.patch @@ -0,0 +1,34 @@ +From 0770b3b7af5f11a65bc11307789c2ed45e5c8155 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 May 2023 20:06:33 +0900 +Subject: [PATCH] nulstr-util: make ret_size in strv_make_nulstr() optional + +(cherry picked from commit 16cda99c737714d6d259e45808e39f94408d90bd) + +Related: #2190226 +--- + src/basic/strv.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/basic/strv.c b/src/basic/strv.c +index 24fc56a1a5..66b70befd6 100644 +--- a/src/basic/strv.c ++++ b/src/basic/strv.c +@@ -706,7 +706,6 @@ int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) { + size_t n = 0; + + assert(ret); +- assert(ret_size); + + STRV_FOREACH(i, l) { + size_t z; +@@ -731,7 +730,8 @@ int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) { + + assert(n > 0); + *ret = TAKE_PTR(m); +- *ret_size = n - 1; ++ if (ret_size) ++ *ret_size = n - 1; + + return 0; + } diff --git a/SOURCES/0314-generator-teach-generator_add_symlink-to-instantiate.patch b/SOURCES/0314-generator-teach-generator_add_symlink-to-instantiate.patch new file mode 100644 index 0000000..8747255 --- /dev/null +++ b/SOURCES/0314-generator-teach-generator_add_symlink-to-instantiate.patch @@ -0,0 +1,105 @@ +From d175d6d2260cd4b2116669953058fa9bef7ae478 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Sun, 16 Oct 2022 22:39:31 +0200 +Subject: [PATCH] generator: teach generator_add_symlink() to instantiate + specified unit + +if we want generators to instantiate a template service, we need to +teach generator_add_symlink() the concept. + +Just some preparation for a later commit. + +While we are at it, modernize the function around +path_extract_filename() + path_extract_directory() + +(cherry picked from commit 0ba07f907721941f611eaca9521937c467bdfff2) + +Related: #2190226 +--- + src/shared/generator.c | 51 ++++++++++++++++++++++++++++++++++-------- + src/shared/generator.h | 6 ++++- + 2 files changed, 47 insertions(+), 10 deletions(-) + +diff --git a/src/shared/generator.c b/src/shared/generator.c +index 4c684fc3e7..6001b2778c 100644 +--- a/src/shared/generator.c ++++ b/src/shared/generator.c +@@ -59,19 +59,52 @@ int generator_open_unit_file( + return 0; + } + +-int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src) { +- /* Adds a symlink from ./ to (if src is absolute) +- * or ../ (otherwise). */ ++int generator_add_symlink_full( ++ const char *dir, ++ const char *dst, ++ const char *dep_type, ++ const char *src, ++ const char *instance) { ++ ++ _cleanup_free_ char *dn = NULL, *fn = NULL, *instantiated = NULL, *to = NULL, *from = NULL; ++ int r; ++ ++ assert(dir); ++ assert(dst); ++ assert(dep_type); ++ assert(src); ++ ++ /* Adds a symlink from ./ to (if src is absolute) or ../ (otherwise). If ++ * is specified, then must be a template unit name, and we'll instantiate it. */ + +- const char *from, *to; ++ r = path_extract_directory(src, &dn); ++ if (r < 0 && r != -EDESTADDRREQ) /* EDESTADDRREQ → just a file name was passed */ ++ return log_error_errno(r, "Failed to extract directory name from '%s': %m", src); + +- from = path_is_absolute(src) ? src : strjoina("../", src); +- to = strjoina(dir, "/", dst, ".", dep_type, "/", basename(src)); ++ r = path_extract_filename(src, &fn); ++ if (r < 0) ++ return log_error_errno(r, "Failed to extract file name from '%s': %m", src); ++ if (r == O_DIRECTORY) ++ return log_error_errno(SYNTHETIC_ERRNO(EISDIR), "Expected path to regular file name, but got '%s', refusing.", src); ++ ++ if (instance) { ++ r = unit_name_replace_instance(fn, instance, &instantiated); ++ if (r < 0) ++ return log_error_errno(r, "Failed to instantiate '%s' for '%s': %m", fn, instance); ++ } ++ ++ from = path_join(dn ?: "..", fn); ++ if (!from) ++ return log_oom(); ++ ++ to = strjoin(dir, "/", dst, ".", dep_type, "/", instantiated ?: fn); ++ if (!to) ++ return log_oom(); + + (void) mkdir_parents_label(to, 0755); +- if (symlink(from, to) < 0) +- if (errno != EEXIST) +- return log_error_errno(errno, "Failed to create symlink \"%s\": %m", to); ++ ++ if (symlink(from, to) < 0 && errno != EEXIST) ++ return log_error_errno(errno, "Failed to create symlink \"%s\": %m", to); + + return 0; + } +diff --git a/src/shared/generator.h b/src/shared/generator.h +index 1b4f36ac53..a4049dbd8f 100644 +--- a/src/shared/generator.h ++++ b/src/shared/generator.h +@@ -12,7 +12,11 @@ int generator_open_unit_file( + const char *name, + FILE **file); + +-int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src); ++int generator_add_symlink_full(const char *dir, const char *dst, const char *dep_type, const char *src, const char *instance); ++ ++static inline int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src) { ++ return generator_add_symlink_full(dir, dst, dep_type, src, NULL); ++} + + int generator_write_fsck_deps( + FILE *f, diff --git a/SOURCES/0315-units-rework-growfs-units-to-be-just-a-regular-unit-.patch b/SOURCES/0315-units-rework-growfs-units-to-be-just-a-regular-unit-.patch new file mode 100644 index 0000000..bb9cd3e --- /dev/null +++ b/SOURCES/0315-units-rework-growfs-units-to-be-just-a-regular-unit-.patch @@ -0,0 +1,270 @@ +From 09fd7becfe7bd05ea354fdd9326cd6175ca7143d Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Sun, 16 Oct 2022 22:45:17 +0200 +Subject: [PATCH] units: rework growfs units to be just a regular unit that is + instantiated + +The systemd-growfs@.service units are currently written in full for each +file system to grow. Which is kinda pointless given that (besides an +optional ordering dep) they contain always the same definition. Let's +fix that and add a static template for this logic, that the generator +simply instantiates (and adds an ordering dep for). + +This mimics how systemd-fsck@.service is handled. Similar to the wait +that for root fs there's a special instance systemd-fsck-root.service +we also add a special instance systemd-growfs-root.service for the root +fs, since it has slightly different deps. + +Fixes: #20788 +See: #10014 +(cherry picked from commit 50072ccf1bfee8a53563a083a3a52b26f0d5678f) + +Related: #2190226 +--- + src/basic/special.h | 2 + + src/shared/generator.c | 126 ++++++++++++++++----------- + units/meson.build | 2 + + units/systemd-growfs-root.service.in | 22 +++++ + units/systemd-growfs@.service.in | 23 +++++ + 5 files changed, 126 insertions(+), 49 deletions(-) + create mode 100644 units/systemd-growfs-root.service.in + create mode 100644 units/systemd-growfs@.service.in + +diff --git a/src/basic/special.h b/src/basic/special.h +index 5d1111fd71..9bb36c5732 100644 +--- a/src/basic/special.h ++++ b/src/basic/special.h +@@ -87,6 +87,8 @@ + #define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service" + #define SPECIAL_VOLATILE_ROOT_SERVICE "systemd-volatile-root.service" + #define SPECIAL_UDEVD_SERVICE "systemd-udevd.service" ++#define SPECIAL_GROWFS_SERVICE "systemd-growfs@.service" ++#define SPECIAL_GROWFS_ROOT_SERVICE "systemd-growfs-root.service" + + /* Services systemd relies on */ + #define SPECIAL_DBUS_SERVICE "dbus.service" +diff --git a/src/shared/generator.c b/src/shared/generator.c +index 6001b2778c..5d617bbe99 100644 +--- a/src/shared/generator.c ++++ b/src/shared/generator.c +@@ -109,6 +109,64 @@ int generator_add_symlink_full( + return 0; + } + ++static int generator_add_ordering( ++ const char *dir, ++ const char *src, ++ const char *order, ++ const char *dst, ++ const char *instance) { ++ ++ _cleanup_free_ char *instantiated = NULL, *p = NULL, *fn = NULL; ++ _cleanup_fclose_ FILE *f = NULL; ++ const char *to; ++ int r; ++ ++ assert(dir); ++ assert(src); ++ assert(order); ++ assert(dst); ++ ++ /* Adds in an explicit ordering dependency of type from to . If is ++ * specified, it is inserted into . */ ++ ++ if (instance) { ++ r = unit_name_replace_instance(dst, instance, &instantiated); ++ if (r < 0) ++ return log_error_errno(r, "Failed to instantiate '%s' for '%s': %m", dst, instance); ++ ++ to = instantiated; ++ } else ++ to = dst; ++ ++ fn = strjoin(src, ".d/50-order-", to, ".conf"); ++ if (!fn) ++ return log_oom(); ++ ++ p = path_join(dir, fn); ++ if (!p) ++ return log_oom(); ++ ++ (void) mkdir_parents_label(p, 0755); ++ ++ r = fopen_unlocked(p, "wxe", &f); ++ if (r < 0) ++ return log_error_errno(r, "Failed to create '%s': %m", p); ++ ++ fprintf(f, ++ "# Automatically generated by %s\n\n" ++ "[Unit]\n" ++ "%s=%s\n", ++ program_invocation_short_name, ++ order, ++ to); ++ ++ r = fflush_and_check(f); ++ if (r < 0) ++ return log_error_errno(r, "Failed to write drop-in '%s': %m", p); ++ ++ return 0; ++} ++ + static int write_fsck_sysroot_service( + const char *unit, /* Either SPECIAL_FSCK_ROOT_SERVICE or SPECIAL_FSCK_USR_SERVICE */ + const char *dir, +@@ -555,66 +613,36 @@ int generator_hook_up_growfs( + const char *where, + const char *target) { + +- _cleanup_free_ char *unit = NULL, *escaped = NULL, *where_unit = NULL, *unit_file = NULL; +- _cleanup_fclose_ FILE *f = NULL; ++ const char *growfs_unit, *growfs_unit_path; ++ _cleanup_free_ char *where_unit = NULL, *instance = NULL; + int r; + + assert(dir); + assert(where); + +- escaped = cescape(where); +- if (!escaped) +- return log_oom(); +- +- r = unit_name_from_path_instance("systemd-growfs", where, ".service", &unit); +- if (r < 0) +- return log_error_errno(r, "Failed to make unit instance name from path \"%s\": %m", +- where); +- + r = unit_name_from_path(where, ".mount", &where_unit); + if (r < 0) +- return log_error_errno(r, "Failed to make unit name from path \"%s\": %m", +- where); +- +- unit_file = path_join(dir, unit); +- if (!unit_file) +- return log_oom(); +- +- log_debug("Creating %s", unit_file); +- +- f = fopen(unit_file, "wxe"); +- if (!f) +- return log_error_errno(errno, "Failed to create unit file %s: %m", +- unit_file); ++ return log_error_errno(r, "Failed to make unit name from path '%s': %m", where); + +- fprintf(f, +- "# Automatically generated by %s\n\n" +- "[Unit]\n" +- "Description=Grow File System on %%f\n" +- "Documentation=man:systemd-growfs@.service(8)\n" +- "DefaultDependencies=no\n" +- "BindsTo=%%i.mount\n" +- "Conflicts=shutdown.target\n" +- "After=systemd-repart.service %%i.mount\n" +- "Before=shutdown.target%s%s\n", +- program_invocation_short_name, +- target ? " " : "", +- strempty(target)); ++ if (empty_or_root(where)) { ++ growfs_unit = SPECIAL_GROWFS_ROOT_SERVICE; ++ growfs_unit_path = SYSTEM_DATA_UNIT_DIR "/" SPECIAL_GROWFS_ROOT_SERVICE; ++ } else { ++ growfs_unit = SPECIAL_GROWFS_SERVICE; ++ growfs_unit_path = SYSTEM_DATA_UNIT_DIR "/" SPECIAL_GROWFS_SERVICE; + +- if (empty_or_root(where)) /* Make sure the root fs is actually writable before we resize it */ +- fprintf(f, +- "After=systemd-remount-fs.service\n"); ++ r = unit_name_path_escape(where, &instance); ++ if (r < 0) ++ return log_error_errno(r, "Failed to escape path '%s': %m", where); ++ } + +- fprintf(f, +- "\n" +- "[Service]\n" +- "Type=oneshot\n" +- "RemainAfterExit=yes\n" +- "ExecStart="SYSTEMD_GROWFS_PATH " %s\n" +- "TimeoutSec=0\n", +- escaped); ++ if (target) { ++ r = generator_add_ordering(dir, target, "After", growfs_unit, instance); ++ if (r < 0) ++ return r; ++ } + +- return generator_add_symlink(dir, where_unit, "wants", unit); ++ return generator_add_symlink_full(dir, where_unit, "wants", growfs_unit_path, instance); + } + + int generator_enable_remount_fs_service(const char *dir) { +diff --git a/units/meson.build b/units/meson.build +index eae7394731..a99f27adc5 100644 +--- a/units/meson.build ++++ b/units/meson.build +@@ -264,6 +264,8 @@ in_units = [ + 'sysinit.target.wants/'], + ['systemd-pcrphase.service', 'HAVE_GNU_EFI HAVE_OPENSSL HAVE_TPM2', + 'sysinit.target.wants/'], ++ ['systemd-growfs-root.service', ''], ++ ['systemd-growfs@.service', ''], + ] + + add_wants = [] +diff --git a/units/systemd-growfs-root.service.in b/units/systemd-growfs-root.service.in +new file mode 100644 +index 0000000000..295bafd5af +--- /dev/null ++++ b/units/systemd-growfs-root.service.in +@@ -0,0 +1,22 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++# ++# This file is part of systemd. ++# ++# systemd is free software; you can redistribute it and/or modify it ++# under the terms of the GNU Lesser General Public License as published by ++# the Free Software Foundation; either version 2.1 of the License, or ++# (at your option) any later version. ++ ++[Unit] ++Description=Grow Root File System ++Documentation=man:systemd-growfs-root.service(8) ++DefaultDependencies=no ++Conflicts=shutdown.target ++After=systemd-repart.service systemd-remount-fs.service ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart={{ROOTLIBEXECDIR}}/systemd-growfs / ++TimeoutSec=0 +diff --git a/units/systemd-growfs@.service.in b/units/systemd-growfs@.service.in +new file mode 100644 +index 0000000000..7154e4ca76 +--- /dev/null ++++ b/units/systemd-growfs@.service.in +@@ -0,0 +1,23 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++# ++# This file is part of systemd. ++# ++# systemd is free software; you can redistribute it and/or modify it ++# under the terms of the GNU Lesser General Public License as published by ++# the Free Software Foundation; either version 2.1 of the License, or ++# (at your option) any later version. ++ ++[Unit] ++Description=Grow File System on %f ++Documentation=man:systemd-growfs@.service(8) ++DefaultDependencies=no ++BindsTo=%i.mount ++Conflicts=shutdown.target ++After=systemd-repart.service %i.mount ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart={{ROOTLIBEXECDIR}}/systemd-growfs %f ++TimeoutSec=0 diff --git a/SOURCES/0316-fstab-generator-use-correct-targets-when-sysroot-is-.patch b/SOURCES/0316-fstab-generator-use-correct-targets-when-sysroot-is-.patch new file mode 100644 index 0000000..c8811b7 --- /dev/null +++ b/SOURCES/0316-fstab-generator-use-correct-targets-when-sysroot-is-.patch @@ -0,0 +1,159 @@ +From 2739a62abe692e9ca5792fc46f03cd4618a65000 Mon Sep 17 00:00:00 2001 +From: Lily Foster +Date: Wed, 25 Jan 2023 19:05:08 -0500 +Subject: [PATCH] fstab-generator: use correct targets when /sysroot is + specificied in fstab only + +(cherry picked from commit dfce61dda7b7b15b910221e5ca1673b371554368) + +Related: #2190226 +--- + man/systemd-fstab-generator.xml | 7 ++- + src/fstab-generator/fstab-generator.c | 63 +++++++++++++++++++++------ + 2 files changed, 54 insertions(+), 16 deletions(-) + +diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml +index b7908377a4..30204f5d8a 100644 +--- a/man/systemd-fstab-generator.xml ++++ b/man/systemd-fstab-generator.xml +@@ -81,12 +81,15 @@ + + Configures the operating system's root filesystem to mount when running in the + initrd. This accepts a device node path (usually /dev/disk/by-uuid/… or +- /dev/disk/by-label/… or similar), or the special values gpt-auto +- and tmpfs. ++ /dev/disk/by-label/… or similar), or the special values gpt-auto, ++ fstab, and tmpfs. + + Use gpt-auto to explicitly request automatic root file system discovery via + systemd-gpt-auto-generator8. + ++ Use fstab to explicitly request automatic root file system discovery via ++ the initrd /etc/fstab rather than via kernel command line. ++ + Use tmpfs in order to mount a tmpfs5 file + system as root file system of the OS. This is useful in combination with +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index e76de45a0f..9bf5f04d1d 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -633,6 +633,19 @@ static const char* sysroot_fstab_path(void) { + return getenv("SYSTEMD_SYSROOT_FSTAB") ?: "/sysroot/etc/fstab"; + } + ++static int add_sysusr_sysroot_usr_bind_mount(const char *source) { ++ return add_mount(source, ++ arg_dest, ++ "/sysusr/usr", ++ "/sysroot/usr", ++ NULL, ++ NULL, ++ "bind", ++ 0, ++ 0, ++ SPECIAL_INITRD_FS_TARGET); ++} ++ + static int parse_fstab(bool initrd) { + _cleanup_endmntent_ FILE *f = NULL; + const char *fstab; +@@ -734,7 +747,7 @@ static int parse_fstab(bool initrd) { + if (streq(me->mnt_type, "swap")) + k = add_swap(fstab, what, me, flags); + else { +- bool rw_only, automount; ++ bool rw_only, automount, is_sysroot, is_sysroot_usr; + + rw_only = fstab_test_option(me->mnt_opts, "x-systemd.rw-only\0"); + automount = fstab_test_option(me->mnt_opts, +@@ -744,21 +757,43 @@ static int parse_fstab(bool initrd) { + flags |= rw_only * MOUNT_RW_ONLY | + automount * MOUNT_AUTOMOUNT; + ++ is_sysroot = in_initrd() && path_equal(where, "/sysroot"); ++ /* See comment from add_sysroot_usr_mount about the need for extra indirection ++ * in case /usr needs to be mounted in order for the root fs to be synthesized ++ * based on configuration included in /usr/, e.g. systemd-repart. */ ++ is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); ++ + const char *target_unit = + initrd ? SPECIAL_INITRD_FS_TARGET : ++ is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : ++ is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : + mount_is_network(me) ? SPECIAL_REMOTE_FS_TARGET : + SPECIAL_LOCAL_FS_TARGET; + ++ if (is_sysroot && is_device_path(what)) { ++ r = generator_write_initrd_root_device_deps(arg_dest, what); ++ if (r < 0) ++ return r; ++ } ++ + k = add_mount(fstab, + arg_dest, + what, +- canonical_where ?: where, +- canonical_where ? where: NULL, ++ is_sysroot_usr ? "/sysusr/usr" : canonical_where ?: where, ++ !is_sysroot_usr && canonical_where ? where : NULL, + me->mnt_type, + me->mnt_opts, + me->mnt_passno, + flags, + target_unit); ++ ++ if (is_sysroot_usr && k >= 0) { ++ log_debug("Synthesizing fstab entry what=/sysusr/usr where=/sysroot/usr opts=bind"); ++ ++ r = add_sysusr_sysroot_usr_bind_mount(fstab); ++ if (r != 0) ++ k = r; ++ } + } + + if (arg_sysroot_check && k > 0) +@@ -836,6 +871,10 @@ static int add_sysroot_mount(void) { + /* This is handled by gpt-auto-generator */ + log_debug("Skipping root directory handling, as gpt-auto was requested."); + return 0; ++ } else if (streq(arg_root_what, "fstab")) { ++ /* This is handled by parse_fstab */ ++ log_debug("Using initrd's fstab for /sysroot/ configuration."); ++ return 0; + } + + r = sysroot_is_nfsroot(); +@@ -951,6 +990,11 @@ static int add_sysroot_usr_mount(void) { + log_debug("Skipping /usr/ directory handling, as gpt-auto was requested."); + return 1; /* systemd-gpt-auto-generator will generate a unit for this, hence report that a + * unit file is being created for the host /usr/ mount. */ ++ } else if (streq(arg_usr_what, "fstab")) { ++ /* This is handled by parse_fstab */ ++ log_debug("Using initrd's fstab for /sysroot/usr/ configuration."); ++ return 1; /* parse_fstab will generate a unit for this, hence report that a ++ * unit file is being created for the host /usr/ mount. */ + } + + if (path_equal(arg_usr_what, "/dev/nfs")) { +@@ -992,18 +1036,9 @@ static int add_sysroot_usr_mount(void) { + if (r < 0) + return r; + +- log_debug("Synthesizing entry what=/sysusr/usr where=/sysrootr/usr opts=bind"); ++ log_debug("Synthesizing entry what=/sysusr/usr where=/sysroot/usr opts=bind"); + +- r = add_mount("/proc/cmdline", +- arg_dest, +- "/sysusr/usr", +- "/sysroot/usr", +- NULL, +- NULL, +- "bind", +- 0, +- 0, +- SPECIAL_INITRD_FS_TARGET); ++ r = add_sysusr_sysroot_usr_bind_mount("/proc/cmdline"); + if (r < 0) + return r; + diff --git a/SOURCES/0317-fstab-generator-add-SYSTEMD_SYSFS_CHECK-env-var.patch b/SOURCES/0317-fstab-generator-add-SYSTEMD_SYSFS_CHECK-env-var.patch new file mode 100644 index 0000000..3eedcd9 --- /dev/null +++ b/SOURCES/0317-fstab-generator-add-SYSTEMD_SYSFS_CHECK-env-var.patch @@ -0,0 +1,70 @@ +From 77a8682a6ee41a92aa1e07b557607c65e94d904b Mon Sep 17 00:00:00 2001 +From: Lily Foster +Date: Wed, 25 Jan 2023 18:52:06 -0500 +Subject: [PATCH] fstab-generator: add SYSTEMD_SYSFS_CHECK env var + +This forces processing of /dev entries in fstab when running in a +container is detected (checked as the existence of read-only /sys). + +(cherry picked from commit 905dd992f8fbfe486e68808ce88e1662c970ab35) + +Related: #2190226 +--- + docs/ENVIRONMENT.md | 4 ++++ + src/fstab-generator/fstab-generator.c | 14 +++++++++++--- + 2 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md +index 70fac2e361..f1a4692b59 100644 +--- a/docs/ENVIRONMENT.md ++++ b/docs/ENVIRONMENT.md +@@ -54,6 +54,10 @@ All tools: + * `$SYSTEMD_SYSROOT_FSTAB` — if set, use this path instead of + `/sysroot/etc/fstab`. Only useful for debugging `systemd-fstab-generator`. + ++* `$SYSTEMD_SYSFS_CHECK` — takes a boolean. If set, overrides sysfs container ++ detection that ignores `/dev/` entries in fstab. Only useful for debugging ++ `systemd-fstab-generator`. ++ + * `$SYSTEMD_CRYPTTAB` — if set, use this path instead of `/etc/crypttab`. Only + useful for debugging. Currently only supported by + `systemd-cryptsetup-generator`. +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 9bf5f04d1d..bbd669e477 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -8,6 +8,7 @@ + #include "bus-error.h" + #include "bus-locator.h" + #include "chase-symlinks.h" ++#include "env-util.h" + #include "fd-util.h" + #include "fileio.h" + #include "fstab-util.h" +@@ -650,7 +651,7 @@ static int parse_fstab(bool initrd) { + _cleanup_endmntent_ FILE *f = NULL; + const char *fstab; + struct mntent *me; +- int r = 0; ++ int r = 0, sysfs_check = -1; + + if (initrd) + fstab = sysroot_fstab_path(); +@@ -688,8 +689,15 @@ static int parse_fstab(bool initrd) { + continue; + } + +- if (is_device_path(what)) { +- log_info("Running in a container, ignoring fstab device entry for %s.", what); ++ if (sysfs_check < 0) { ++ r = getenv_bool_secure("SYSTEMD_SYSFS_CHECK"); ++ if (r < 0 && r != -ENXIO) ++ log_debug_errno(r, "Failed to parse $SYSTEMD_SYSFS_CHECK, ignoring: %m"); ++ sysfs_check = r != 0; ++ } ++ ++ if (sysfs_check && is_device_path(what)) { ++ log_info("/sys/ is read-only (running in a container?), ignoring fstab device entry for %s.", what); + continue; + } + } diff --git a/SOURCES/0318-test-add-fstab-file-support-for-fstab-generator-test.patch b/SOURCES/0318-test-add-fstab-file-support-for-fstab-generator-test.patch new file mode 100644 index 0000000..f1be324 --- /dev/null +++ b/SOURCES/0318-test-add-fstab-file-support-for-fstab-generator-test.patch @@ -0,0 +1,155 @@ +From 337826320020e4e1e8f6be62c3c65d5b157bb58d Mon Sep 17 00:00:00 2001 +From: Lily Foster +Date: Wed, 25 Jan 2023 18:52:30 -0500 +Subject: [PATCH] test: add fstab file support for fstab-generator tests + +(cherry picked from commit ef0c7ab6ac1ad2a38988fd4aa959aaa0408f2f4b) + +Related: #2190226 +--- + test/test-fstab-generator.sh | 6 +++++- + .../initrd-fs.target.requires/sysroot-usr.mount | 0 + .../50-root-device.conf | 5 +++++ + .../initrd-root-fs.target.requires/sysroot.mount | 0 + .../initrd-usr-fs.target.requires/sysroot.mount | 0 + .../sysusr-usr.mount | 0 + .../sysroot-usr.mount | 11 +++++++++++ + .../sysroot.mount | 13 +++++++++++++ + .../systemd-fsck-root.service | 16 ++++++++++++++++ + .../sysusr-usr.mount | 11 +++++++++++ + .../test-17-initrd-sysroot.fstab.input | 2 ++ + 11 files changed, 63 insertions(+), 1 deletion(-) + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-device.target.d/50-root-device.conf + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot-usr.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysusr-usr.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.input + +diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh +index 7c060dfac7..c86914a107 100755 +--- a/test/test-fstab-generator.sh ++++ b/test/test-fstab-generator.sh +@@ -26,7 +26,11 @@ for f in "$src"/test-*.input; do + trap "rm -rf '$out'" EXIT INT QUIT PIPE + + # shellcheck disable=SC2046 +- SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" ++ if [[ "$f" == *.fstab.input ]]; then ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$f" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" ++ else ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" ++ fi + + if [[ -f "$out"/systemd-fsck-root.service ]]; then + # For split-usr system +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-device.target.d/50-root-device.conf b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-device.target.d/50-root-device.conf +new file mode 100644 +index 0000000000..47c4232223 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-device.target.d/50-root-device.conf +@@ -0,0 +1,5 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Requires=dev-sdx1.device ++After=dev-sdx1.device +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot-usr.mount +new file mode 100644 +index 0000000000..69be9c17d4 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot-usr.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=initrd-fs.target ++ ++[Mount] ++What=/sysusr/usr ++Where=/sysroot/usr ++Options=bind +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot.mount +new file mode 100644 +index 0000000000..0e8a701be9 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysroot.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=initrd-root-fs.target ++Requires=systemd-fsck-root.service ++After=systemd-fsck-root.service ++After=blockdev@dev-sdx1.target ++ ++[Mount] ++What=/dev/sdx1 ++Where=/sysroot +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service +new file mode 100644 +index 0000000000..7f914fdd14 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service +@@ -0,0 +1,16 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=File System Check on /dev/sdx1 ++Documentation=man:systemd-fsck-root.service(8) ++DefaultDependencies=no ++BindsTo=dev-sdx1.device ++Conflicts=shutdown.target ++After=initrd-root-device.target local-fs-pre.target dev-sdx1.device ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1 ++TimeoutSec=0 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysusr-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysusr-usr.mount +new file mode 100644 +index 0000000000..63fcb10340 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/sysusr-usr.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=initrd-usr-fs.target ++After=blockdev@dev-sdx2.target ++ ++[Mount] ++What=/dev/sdx2 ++Where=/sysusr/usr +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.input b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.input +new file mode 100644 +index 0000000000..1ba9b0624e +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.input +@@ -0,0 +1,2 @@ ++/dev/sdx1 /sysroot auto defaults 0 1 ++/dev/sdx2 /sysroot/usr auto defaults 0 0 diff --git a/SOURCES/0319-test-fstab-generator-also-check-file-contents.patch b/SOURCES/0319-test-fstab-generator-also-check-file-contents.patch new file mode 100644 index 0000000..93a55f8 --- /dev/null +++ b/SOURCES/0319-test-fstab-generator-also-check-file-contents.patch @@ -0,0 +1,345 @@ +From 8a964936a2c117b3e6706781026a239dd5727975 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Fri, 12 May 2023 03:54:13 +0900 +Subject: [PATCH] test-fstab-generator: also check file contents + +Since e683878c0f03a4ffa123e37b27933fbf7e144901, only filenames are +checked. Let's check contents of generated unit files. + +(cherry picked from commit 70bf9f62b9f3c46bb7d111342889bfac7c9ca45e) + +Related: #2190226 +--- + test/test-fstab-generator.sh | 55 ++++++++++++++++--- + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../systemd-fsck-root.service | 1 + + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../systemd-fsck-root.service | 1 + + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../systemd-fsck-root.service | 1 + + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../systemd-fsck-root.service | 1 + + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../sysroot-usr.mount | 1 + + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../sysusr-usr.mount | 1 + + .../systemd-fsck-root.service | 1 + + 20 files changed, 67 insertions(+), 7 deletions(-) + mode change 100644 => 120000 test/test-fstab-generator/test-12-dev-sdx.expected/initrd-root-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-12-dev-sdx.expected/initrd-usr-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-13-label.expected/initrd-root-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-13-label.expected/initrd-usr-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-14-uuid.expected/initrd-root-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-14-uuid.expected/initrd-usr-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-15-partuuid.expected/initrd-root-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-15-partuuid.expected/initrd-usr-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-16-tmpfs.expected/initrd-root-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-16-tmpfs.expected/initrd-usr-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount + mode change 100644 => 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount + mode change 100644 => 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount + +diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh +index c86914a107..c844d0dae1 100755 +--- a/test/test-fstab-generator.sh ++++ b/test/test-fstab-generator.sh +@@ -1,6 +1,8 @@ + #!/usr/bin/env bash + # SPDX-License-Identifier: LGPL-2.1-or-later + set -e ++shopt -s nullglob ++shopt -s globstar + + if [[ -n "$1" ]]; then + generator=$1 +@@ -25,23 +27,62 @@ for f in "$src"/test-*.input; do + # shellcheck disable=SC2064 + trap "rm -rf '$out'" EXIT INT QUIT PIPE + +- # shellcheck disable=SC2046 +- if [[ "$f" == *.fstab.input ]]; then ++ exp="${f%.input}.expected" ++ ++ if [[ "${f##*/}" =~ \.fstab\.input ]]; then + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$f" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" + else + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" + fi + +- if [[ -f "$out"/systemd-fsck-root.service ]]; then +- # For split-usr system +- sed -i -e 's:ExecStart=/lib/systemd/systemd-fsck:ExecStart=/usr/lib/systemd/systemd-fsck:' "$out"/systemd-fsck-root.service ++ # For split-usr system ++ for i in "$out"/systemd-*.service; do ++ sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" ++ done ++ ++ if [[ "${f##*/}" =~ \.fstab\.input ]]; then ++ for i in "$out"/*.{automount,mount,swap}; do ++ sed -i -e 's:SourcePath=.*$:SourcePath=/etc/fstab:' "$i" ++ done + fi + +- # We store empty files rather than symlinks, so that they don't get pruned when packaged up, so compare ++ # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare + # the list of filenames rather than their content +- if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "${f%.input}.expected" -printf '%P\n' | sort); then ++ if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then ++ echo "**** Unexpected output for $f" ++ exit 1 ++ fi ++ ++ # Check the main units. ++ if ! diff -u "$out" "$exp"; then + echo "**** Unexpected output for $f" + exit 1 + fi ++ ++ # Also check drop-ins. ++ for i in "$out"/*; do ++ [[ -d "$i" ]] || continue ++ ++ dir="${i##*/}" ++ ++ for j in "$i"/*; do ++ fname="${j##*/}" ++ expf="$exp/$dir/$fname" ++ ++ if [[ -L "$j" && ! -e "$j" ]]; then ++ # For dead symlink, we store an empty file. ++ if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then ++ echo "**** Unexpected symlink $j created by $f" ++ exit 1 ++ fi ++ continue ++ fi ++ ++ if ! diff -u "$j" "$expf"; then ++ echo "**** Unexpected output in $j for $f" ++ exit 1 ++ fi ++ done ++ done + ) || exit 1 + done +diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-root-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-usr-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-12-dev-sdx.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service +index 7f914fdd14..95d943b87a 100644 +--- a/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service +@@ -3,6 +3,7 @@ + [Unit] + Description=File System Check on /dev/sdx1 + Documentation=man:systemd-fsck-root.service(8) ++ + DefaultDependencies=no + BindsTo=dev-sdx1.device + Conflicts=shutdown.target +diff --git a/test/test-fstab-generator/test-13-label.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-13-label.expected/initrd-root-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-13-label.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-13-label.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-13-label.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-13-label.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-13-label.expected/initrd-usr-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-13-label.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-13-label.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-13-label.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service +index a1327396ca..d6c59ff608 100644 +--- a/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service +@@ -3,6 +3,7 @@ + [Unit] + Description=File System Check on /dev/disk/by-label/Root + Documentation=man:systemd-fsck-root.service(8) ++ + DefaultDependencies=no + BindsTo=dev-disk-by\x2dlabel-Root.device + Conflicts=shutdown.target +diff --git a/test/test-fstab-generator/test-14-uuid.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-14-uuid.expected/initrd-root-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-14-uuid.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-14-uuid.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-14-uuid.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-14-uuid.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-14-uuid.expected/initrd-usr-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-14-uuid.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-14-uuid.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-14-uuid.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service +index 5945560287..cd9583c4dd 100644 +--- a/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service +@@ -3,6 +3,7 @@ + [Unit] + Description=File System Check on /dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 + Documentation=man:systemd-fsck-root.service(8) ++ + DefaultDependencies=no + BindsTo=dev-disk-by\x2duuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device + Conflicts=shutdown.target +diff --git a/test/test-fstab-generator/test-15-partuuid.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-15-partuuid.expected/initrd-root-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-15-partuuid.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-15-partuuid.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-15-partuuid.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-15-partuuid.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-15-partuuid.expected/initrd-usr-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-15-partuuid.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-15-partuuid.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-15-partuuid.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service +index aa1d455ecd..650ed8070a 100644 +--- a/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service +@@ -3,6 +3,7 @@ + [Unit] + Description=File System Check on /dev/disk/by-partuuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 + Documentation=man:systemd-fsck-root.service(8) ++ + DefaultDependencies=no + BindsTo=dev-disk-by\x2dpartuuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device + Conflicts=shutdown.target +diff --git a/test/test-fstab-generator/test-16-tmpfs.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-16-tmpfs.expected/initrd-root-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-16-tmpfs.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-16-tmpfs.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-16-tmpfs.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-16-tmpfs.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-16-tmpfs.expected/initrd-usr-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-16-tmpfs.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-16-tmpfs.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-16-tmpfs.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount +new file mode 120000 +index 0000000000..8bcbb16eae +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-fs.target.requires/sysroot-usr.mount +@@ -0,0 +1 @@ ++../sysroot-usr.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount +new file mode 120000 +index 0000000000..8fb2e18647 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/initrd-usr-fs.target.requires/sysusr-usr.mount +@@ -0,0 +1 @@ ++../sysusr-usr.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service +index 7f914fdd14..95d943b87a 100644 +--- a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service +@@ -3,6 +3,7 @@ + [Unit] + Description=File System Check on /dev/sdx1 + Documentation=man:systemd-fsck-root.service(8) ++ + DefaultDependencies=no + BindsTo=dev-sdx1.device + Conflicts=shutdown.target diff --git a/SOURCES/0320-test-fstab-generator-add-tests-for-mount-options.patch b/SOURCES/0320-test-fstab-generator-add-tests-for-mount-options.patch new file mode 100644 index 0000000..9979b77 --- /dev/null +++ b/SOURCES/0320-test-fstab-generator-add-tests-for-mount-options.patch @@ -0,0 +1,667 @@ +From 9afc07262dd2b37a20094909ab0a8cddb29cefc8 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Fri, 19 May 2023 09:31:51 +0900 +Subject: [PATCH] test-fstab-generator: add tests for mount options + +(cherry picked from commit 82c29dbee0ae4c438d25482083facc75f84bc5ee) + +Related: #2190226 +--- + test/test-fstab-generator.sh | 9 +++++++++ + .../foo.service.requires/mnt-requiredby.mount | 1 + + .../foo.service.wants/mnt-wantedby.mount | 1 + + .../50-root-device.conf | 5 +++++ + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + ...rder-systemd-growfs@mnt-growfs.service.conf | 4 ++++ + .../local-fs.target.requires/mnt-after.mount | 1 + + .../mnt-automount1.automount | 1 + + .../local-fs.target.requires/mnt-before.mount | 1 + + .../local-fs.target.requires/mnt-growfs.mount | 1 + + .../local-fs.target.requires/mnt-mkfs.mount | 1 + + .../local-fs.target.requires/mnt-pcrfs.mount | 1 + + .../mnt-reqmounts.mount | 1 + + .../mnt-requires.mount | 1 + + .../local-fs.target.requires/mnt-rwonly.mount | 1 + + .../local-fs.target.requires/mnt-timeout.mount | 1 + + .../mnt-automount2.automount | 1 + + .../local-fs.target.wants/mnt-nofail.mount | 1 + + .../mnt-after.mount | 13 +++++++++++++ + .../mnt-automount1.automount | 9 +++++++++ + .../mnt-automount1.mount | 12 ++++++++++++ + .../mnt-automount2.automount | 8 ++++++++ + .../mnt-automount2.mount | 11 +++++++++++ + .../mnt-before.mount | 13 +++++++++++++ + .../mnt-growfs.mount | 12 ++++++++++++ + .../systemd-growfs@mnt-growfs.service | 0 + .../mnt-mkfs.mount | 13 +++++++++++++ + .../systemd-makefs@dev-sdx12.service | 1 + + .../mnt-noauto.mount | 12 ++++++++++++ + .../mnt-nofail.mount | 11 +++++++++++ + .../mnt-pcrfs.mount | 12 ++++++++++++ + .../mnt-reqmounts.mount | 13 +++++++++++++ + .../mnt-requiredby.mount | 12 ++++++++++++ + .../mnt-requires.mount | 14 ++++++++++++++ + .../mnt-rwonly.mount | 13 +++++++++++++ + .../mnt-timeout.mount | 13 +++++++++++++ + .../mnt-wantedby.mount | 12 ++++++++++++ + .../sysroot.mount | 13 +++++++++++++ + .../systemd-fsck-root.service | 17 +++++++++++++++++ + .../systemd-makefs@dev-sdx12.service | 18 ++++++++++++++++++ + .../test-18-options.fstab.input | 16 ++++++++++++++++ + 42 files changed, 302 insertions(+) + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/foo.service.requires/mnt-requiredby.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/foo.service.wants/mnt-wantedby.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-device.target.d/50-root-device.conf + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-fs.target.requires/sysroot.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-after.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-automount1.automount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-before.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-growfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-mkfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-pcrfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-reqmounts.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-requires.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-rwonly.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-timeout.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-automount2.automount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-nofail.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-after.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.automount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.automount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-before.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-noauto.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-nofail.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-pcrfs.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-reqmounts.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-requiredby.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-requires.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-rwonly.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-timeout.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/mnt-wantedby.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/sysroot.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.input + +diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh +index c844d0dae1..7df67ce305 100755 +--- a/test/test-fstab-generator.sh ++++ b/test/test-fstab-generator.sh +@@ -35,6 +35,15 @@ for f in "$src"/test-*.input; do + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" + fi + ++ # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. ++ # The system that the test is currently running on may not have or may have outdated unit file. ++ # Let's replace the symlink with an empty file. ++ for i in "$out"/*/systemd-growfs@*.service; do ++ [[ -L "$i" ]] || continue ++ rm "$i" ++ touch "$i" ++ done ++ + # For split-usr system + for i in "$out"/systemd-*.service; do + sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/foo.service.requires/mnt-requiredby.mount b/test/test-fstab-generator/test-18-options.fstab.expected/foo.service.requires/mnt-requiredby.mount +new file mode 120000 +index 0000000000..6b012b09ef +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/foo.service.requires/mnt-requiredby.mount +@@ -0,0 +1 @@ ++../mnt-requiredby.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/foo.service.wants/mnt-wantedby.mount b/test/test-fstab-generator/test-18-options.fstab.expected/foo.service.wants/mnt-wantedby.mount +new file mode 120000 +index 0000000000..cdf21276b6 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/foo.service.wants/mnt-wantedby.mount +@@ -0,0 +1 @@ ++../mnt-wantedby.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-device.target.d/50-root-device.conf b/test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-device.target.d/50-root-device.conf +new file mode 100644 +index 0000000000..47c4232223 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-device.target.d/50-root-device.conf +@@ -0,0 +1,5 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Requires=dev-sdx1.device ++After=dev-sdx1.device +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf +new file mode 100644 +index 0000000000..ac770bcb51 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf +@@ -0,0 +1,4 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++After=systemd-growfs@mnt-growfs.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-after.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-after.mount +new file mode 120000 +index 0000000000..68364ef19c +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-after.mount +@@ -0,0 +1 @@ ++../mnt-after.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-automount1.automount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-automount1.automount +new file mode 120000 +index 0000000000..3638a8c90e +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-automount1.automount +@@ -0,0 +1 @@ ++../mnt-automount1.automount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-before.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-before.mount +new file mode 120000 +index 0000000000..3a50a40d5f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-before.mount +@@ -0,0 +1 @@ ++../mnt-before.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-growfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-growfs.mount +new file mode 120000 +index 0000000000..cb05081e45 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-growfs.mount +@@ -0,0 +1 @@ ++../mnt-growfs.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-mkfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-mkfs.mount +new file mode 120000 +index 0000000000..51f897e419 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-mkfs.mount +@@ -0,0 +1 @@ ++../mnt-mkfs.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-pcrfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-pcrfs.mount +new file mode 120000 +index 0000000000..276dfc0731 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-pcrfs.mount +@@ -0,0 +1 @@ ++../mnt-pcrfs.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-reqmounts.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-reqmounts.mount +new file mode 120000 +index 0000000000..7efce8da9a +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-reqmounts.mount +@@ -0,0 +1 @@ ++../mnt-reqmounts.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-requires.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-requires.mount +new file mode 120000 +index 0000000000..34a6aad26f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-requires.mount +@@ -0,0 +1 @@ ++../mnt-requires.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-rwonly.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-rwonly.mount +new file mode 120000 +index 0000000000..d03abd2353 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-rwonly.mount +@@ -0,0 +1 @@ ++../mnt-rwonly.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-timeout.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-timeout.mount +new file mode 120000 +index 0000000000..b0ec730825 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.requires/mnt-timeout.mount +@@ -0,0 +1 @@ ++../mnt-timeout.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-automount2.automount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-automount2.automount +new file mode 120000 +index 0000000000..a30481ec1f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-automount2.automount +@@ -0,0 +1 @@ ++../mnt-automount2.automount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-nofail.mount b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-nofail.mount +new file mode 120000 +index 0000000000..b82bbad730 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/local-fs.target.wants/mnt-nofail.mount +@@ -0,0 +1 @@ ++../mnt-nofail.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-after.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-after.mount +new file mode 100644 +index 0000000000..2aebb686a7 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-after.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=foo.service ++Before=local-fs.target ++After=blockdev@dev-sdx3.target ++ ++[Mount] ++What=/dev/sdx3 ++Where=/mnt/after ++Options=x-systemd.after=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.automount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.automount +new file mode 100644 +index 0000000000..e376689b67 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.automount +@@ -0,0 +1,9 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++SourcePath=/etc/fstab ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++ ++[Automount] ++Where=/mnt/automount1 ++TimeoutIdleSec=30min +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.mount +new file mode 100644 +index 0000000000..1413292c79 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount1.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx9.target ++ ++[Mount] ++What=/dev/sdx9 ++Where=/mnt/automount1 ++Options=x-systemd.automount,x-systemd.idle-timeout=30m +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.automount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.automount +new file mode 100644 +index 0000000000..e05d3976ef +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.automount +@@ -0,0 +1,8 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++SourcePath=/etc/fstab ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++ ++[Automount] ++Where=/mnt/automount2 +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.mount +new file mode 100644 +index 0000000000..1eba08c9f7 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-automount2.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=blockdev@dev-sdx10.target ++ ++[Mount] ++What=/dev/sdx10 ++Where=/mnt/automount2 ++Options=x-systemd.automount,nofail +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-before.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-before.mount +new file mode 100644 +index 0000000000..eea084b7b6 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-before.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=foo.service ++Before=local-fs.target ++After=blockdev@dev-sdx4.target ++ ++[Mount] ++What=/dev/sdx4 ++Where=/mnt/before ++Options=x-systemd.before=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount +new file mode 100644 +index 0000000000..bbe958c076 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx13.target ++ ++[Mount] ++What=/dev/sdx13 ++Where=/mnt/growfs ++Options=x-systemd.growfs +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount +new file mode 100644 +index 0000000000..be4c8fa17f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx12.target ++ ++[Mount] ++What=/dev/sdx12 ++Where=/mnt/mkfs ++Type=ext4 ++Options=x-systemd.makefs +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service +new file mode 120000 +index 0000000000..fe80548a68 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service +@@ -0,0 +1 @@ ++../systemd-makefs@dev-sdx12.service +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-noauto.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-noauto.mount +new file mode 100644 +index 0000000000..4d52a6e698 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-noauto.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx15.target ++ ++[Mount] ++What=/dev/sdx15 ++Where=/mnt/noauto ++Options=noauto +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-nofail.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-nofail.mount +new file mode 100644 +index 0000000000..3c20b652b0 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-nofail.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=blockdev@dev-sdx16.target ++ ++[Mount] ++What=/dev/sdx16 ++Where=/mnt/nofail ++Options=nofail +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-pcrfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-pcrfs.mount +new file mode 100644 +index 0000000000..2c070e695a +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-pcrfs.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx14.target ++ ++[Mount] ++What=/dev/sdx14 ++Where=/mnt/pcrfs ++Options=x-systemd.pcrfs +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-reqmounts.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-reqmounts.mount +new file mode 100644 +index 0000000000..c21ccd27ba +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-reqmounts.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++RequiresMountsFor=/hoge ++Before=local-fs.target ++After=blockdev@dev-sdx6.target ++ ++[Mount] ++What=/dev/sdx6 ++Where=/mnt/reqmounts ++Options=x-systemd.requires-mounts-for=/hoge +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-requiredby.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-requiredby.mount +new file mode 100644 +index 0000000000..5edc4ddf22 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-requiredby.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx8.target ++ ++[Mount] ++What=/dev/sdx8 ++Where=/mnt/requiredby ++Options=x-systemd.required-by=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-requires.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-requires.mount +new file mode 100644 +index 0000000000..8386616593 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-requires.mount +@@ -0,0 +1,14 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=foo.service ++Requires=foo.service ++Before=local-fs.target ++After=blockdev@dev-sdx5.target ++ ++[Mount] ++What=/dev/sdx5 ++Where=/mnt/requires ++Options=x-systemd.requires=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-rwonly.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-rwonly.mount +new file mode 100644 +index 0000000000..8649734386 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-rwonly.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx11.target ++ ++[Mount] ++What=/dev/sdx11 ++Where=/mnt/rwonly ++Options=x-systemd.rw-only ++ReadWriteOnly=yes +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-timeout.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-timeout.mount +new file mode 100644 +index 0000000000..09d772a52b +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-timeout.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx2.target ++ ++[Mount] ++What=/dev/sdx2 ++Where=/mnt/timeout ++TimeoutSec=10min ++Options=x-systemd.mount-timeout=10m +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/mnt-wantedby.mount b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-wantedby.mount +new file mode 100644 +index 0000000000..e12df820d4 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/mnt-wantedby.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx7.target ++ ++[Mount] ++What=/dev/sdx7 ++Where=/mnt/wantedby ++Options=x-systemd.wanted-by=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected/sysroot.mount +new file mode 100644 +index 0000000000..0e8a701be9 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/sysroot.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=initrd-root-fs.target ++Requires=systemd-fsck-root.service ++After=systemd-fsck-root.service ++After=blockdev@dev-sdx1.target ++ ++[Mount] ++What=/dev/sdx1 ++Where=/sysroot +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service +new file mode 100644 +index 0000000000..95d943b87a +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service +@@ -0,0 +1,17 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=File System Check on /dev/sdx1 ++Documentation=man:systemd-fsck-root.service(8) ++ ++DefaultDependencies=no ++BindsTo=dev-sdx1.device ++Conflicts=shutdown.target ++After=initrd-root-device.target local-fs-pre.target dev-sdx1.device ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1 ++TimeoutSec=0 +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service +new file mode 100644 +index 0000000000..303c1ee680 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service +@@ -0,0 +1,18 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=Make File System on %f ++Documentation=man:systemd-makefs@.service(8) ++ ++DefaultDependencies=no ++BindsTo=%i.device ++After=%i.device ++Before=systemd-fsck@%i.service mnt-mkfs.mount ++Conflicts=shutdown.target ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-makefs ext4 /dev/sdx12 ++TimeoutSec=0 +diff --git a/test/test-fstab-generator/test-18-options.fstab.input b/test/test-fstab-generator/test-18-options.fstab.input +new file mode 100644 +index 0000000000..98ef0b9fba +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.input +@@ -0,0 +1,16 @@ ++/dev/sdx1 /sysroot auto defaults 0 1 ++/dev/sdx2 /mnt/timeout auto x-systemd.mount-timeout=10m 0 0 ++/dev/sdx3 /mnt/after auto x-systemd.after=foo.service 0 0 ++/dev/sdx4 /mnt/before auto x-systemd.before=foo.service 0 0 ++/dev/sdx5 /mnt/requires auto x-systemd.requires=foo.service 0 0 ++/dev/sdx6 /mnt/reqmounts auto x-systemd.requires-mounts-for=/hoge 0 0 ++/dev/sdx7 /mnt/wantedby auto x-systemd.wanted-by=foo.service 0 0 ++/dev/sdx8 /mnt/requiredby auto x-systemd.required-by=foo.service 0 0 ++/dev/sdx9 /mnt/automount1 auto x-systemd.automount,x-systemd.idle-timeout=30m 0 0 ++/dev/sdx10 /mnt/automount2 auto x-systemd.automount,nofail 0 0 ++/dev/sdx11 /mnt/rwonly auto x-systemd.rw-only 0 0 ++/dev/sdx12 /mnt/mkfs ext4 x-systemd.makefs 0 0 ++/dev/sdx13 /mnt/growfs auto x-systemd.growfs 0 0 ++/dev/sdx14 /mnt/pcrfs auto x-systemd.pcrfs 0 0 ++/dev/sdx15 /mnt/noauto auto noauto 0 0 ++/dev/sdx16 /mnt/nofail auto nofail 0 0 diff --git a/SOURCES/0321-fstab-generator-split-out-several-functions-from-par.patch b/SOURCES/0321-fstab-generator-split-out-several-functions-from-par.patch new file mode 100644 index 0000000..3ec6671 --- /dev/null +++ b/SOURCES/0321-fstab-generator-split-out-several-functions-from-par.patch @@ -0,0 +1,408 @@ +From ddcdc462b935fc210677f664d61cf556fb2abe0f Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 May 2023 19:45:34 +0900 +Subject: [PATCH] fstab-generator: split out several functions from + parse_fstab() + +No functional changes, just refactoring and preparation for later +commits. + +(cherry picked from commit cfeb4d378ecd1ea50c0a0248c384e49983511fa8) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 323 ++++++++++++++------------ + 1 file changed, 171 insertions(+), 152 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index bbd669e477..4ea95f29eb 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -99,7 +99,7 @@ static int write_what(FILE *f, const char *what) { + static int add_swap( + const char *source, + const char *what, +- struct mntent *me, ++ const char *options, + MountPointFlags flags) { + + _cleanup_free_ char *name = NULL; +@@ -107,7 +107,6 @@ static int add_swap( + int r; + + assert(what); +- assert(me); + + if (!arg_swap_enabled) { + log_info("Swap unit generation disabled on kernel command line, ignoring fstab swap entry for %s.", what); +@@ -155,7 +154,7 @@ static int add_swap( + if (r < 0) + return r; + +- r = write_options(f, me->mnt_opts); ++ r = write_options(f, options); + if (r < 0) + return r; + +@@ -164,7 +163,7 @@ static int add_swap( + return log_error_errno(r, "Failed to write unit file %s: %m", name); + + /* use what as where, to have a nicer error message */ +- r = generator_write_timeouts(arg_dest, what, what, me->mnt_opts, NULL); ++ r = generator_write_timeouts(arg_dest, what, what, options, NULL); + if (r < 0) + return r; + +@@ -188,18 +187,14 @@ static int add_swap( + return true; + } + +-static bool mount_is_network(struct mntent *me) { +- assert(me); +- +- return fstab_test_option(me->mnt_opts, "_netdev\0") || +- fstype_is_network(me->mnt_type); ++static bool mount_is_network(const char *fstype, const char *options) { ++ return fstab_test_option(options, "_netdev\0") || ++ (fstype && fstype_is_network(fstype)); + } + +-static bool mount_in_initrd(struct mntent *me) { +- assert(me); +- +- return fstab_test_option(me->mnt_opts, "x-initrd.mount\0") || +- path_equal(me->mnt_dir, "/usr"); ++static bool mount_in_initrd(const char *where, const char *options) { ++ return fstab_test_option(options, "x-initrd.mount\0") || ++ (where && path_equal(where, "/usr")); + } + + static int write_timeout( +@@ -634,6 +629,20 @@ static const char* sysroot_fstab_path(void) { + return getenv("SYSTEMD_SYSROOT_FSTAB") ?: "/sysroot/etc/fstab"; + } + ++static bool sysfs_check(void) { ++ static int cached = -1; ++ int r; ++ ++ if (cached < 0) { ++ r = getenv_bool_secure("SYSTEMD_SYSFS_CHECK"); ++ if (r < 0 && r != -ENXIO) ++ log_debug_errno(r, "Failed to parse $SYSTEMD_SYSFS_CHECK, ignoring: %m"); ++ cached = r != 0; ++ } ++ ++ return cached; ++} ++ + static int add_sysusr_sysroot_usr_bind_mount(const char *source) { + return add_mount(source, + arg_dest, +@@ -647,11 +656,153 @@ static int add_sysusr_sysroot_usr_bind_mount(const char *source) { + SPECIAL_INITRD_FS_TARGET); + } + ++static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap) { ++ MountPointFlags flags = 0; ++ ++ if (fstab_test_option(options, "x-systemd.makefs\0")) ++ flags |= MOUNT_MAKEFS; ++ if (fstab_test_option(options, "x-systemd.growfs\0")) ++ flags |= MOUNT_GROWFS; ++ if (fstab_test_yes_no_option(options, "noauto\0" "auto\0")) ++ flags |= MOUNT_NOAUTO; ++ if (fstab_test_yes_no_option(options, "nofail\0" "fail\0")) ++ flags |= MOUNT_NOFAIL; ++ ++ if (!is_swap) { ++ if (fstab_test_option(options, "x-systemd.rw-only\0")) ++ flags |= MOUNT_RW_ONLY; ++ if (fstab_test_option(options, ++ "comment=systemd.automount\0" ++ "x-systemd.automount\0")) ++ flags |= MOUNT_AUTOMOUNT; ++ } ++ ++ return flags; ++} ++ ++static int parse_fstab_one( ++ const char *source, ++ const char *what_original, ++ const char *where_original, ++ const char *fstype, ++ const char *options, ++ int passno, ++ bool initrd) { ++ ++ _cleanup_free_ char *what = NULL, *where = NULL, *canonical_where = NULL; ++ MountPointFlags flags; ++ int r; ++ ++ assert(what_original); ++ assert(where_original); ++ assert(fstype); ++ assert(options); ++ ++ if (initrd && !mount_in_initrd(where_original, options)) ++ return 0; ++ ++ what = fstab_node_to_udev_node(what_original); ++ if (!what) ++ return log_oom(); ++ ++ if (path_is_read_only_fs("/sys") > 0 && ++ (streq(what, "sysfs") || ++ (sysfs_check() && is_device_path(what)))) { ++ log_info("/sys/ is read-only (running in a container?), ignoring mount for %s.", what); ++ return 0; ++ } ++ ++ where = strdup(where_original); ++ if (!where) ++ return log_oom(); ++ ++ if (is_path(where)) { ++ path_simplify(where); ++ ++ /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for ++ * mount units, but causes problems since it historically worked to have symlinks in e.g. ++ * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case ++ * where a symlink refers to another mount target; this works assuming the sub-mountpoint ++ * target is the final directory. ++ * ++ * FIXME: when chase() learns to chase non-existent paths, use this here and ++ * drop the prefixing with /sysroot on error below. ++ */ ++ r = chase_symlinks(where, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, ++ &canonical_where, NULL); ++ if (r < 0) { ++ /* If we can't canonicalize, continue as if it wasn't a symlink */ ++ log_debug_errno(r, "Failed to read symlink target for %s, using as-is: %m", where); ++ ++ if (initrd) { ++ canonical_where = path_join("/sysroot", where); ++ if (!canonical_where) ++ return log_oom(); ++ } ++ ++ } else if (streq(canonical_where, where)) /* If it was fully canonicalized, suppress the change */ ++ canonical_where = mfree(canonical_where); ++ else ++ log_debug("Canonicalized what=%s where=%s to %s", what, where, canonical_where); ++ } ++ ++ flags = fstab_options_to_flags(options, streq_ptr(fstype, "swap")); ++ ++ log_debug("Found entry what=%s where=%s type=%s makefs=%s growfs=%s noauto=%s nofail=%s", ++ what, where, strna(fstype), ++ yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), ++ yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL)); ++ ++ if (streq_ptr(fstype, "swap")) ++ return add_swap(source, what, options, flags); ++ ++ bool is_sysroot = in_initrd() && path_equal(where, "/sysroot"); ++ /* See comment from add_sysroot_usr_mount() about the need for extra indirection in case /usr needs ++ * to be mounted in order for the root fs to be synthesized based on configuration included in /usr/, ++ * e.g. systemd-repart. */ ++ bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); ++ ++ const char *target_unit = ++ initrd ? SPECIAL_INITRD_FS_TARGET : ++ is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : ++ is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : ++ mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : ++ SPECIAL_LOCAL_FS_TARGET; ++ ++ if (is_sysroot && is_device_path(what)) { ++ r = generator_write_initrd_root_device_deps(arg_dest, what); ++ if (r < 0) ++ return r; ++ } ++ ++ r = add_mount(source, ++ arg_dest, ++ what, ++ is_sysroot_usr ? "/sysusr/usr" : canonical_where ?: where, ++ !is_sysroot_usr && canonical_where ? where : NULL, ++ fstype, ++ options, ++ passno, ++ flags, ++ target_unit); ++ if (r <= 0) ++ return r; ++ ++ if (is_sysroot_usr) { ++ log_debug("Synthesizing fstab entry what=/sysusr/usr where=/sysroot/usr opts=bind"); ++ r = add_sysusr_sysroot_usr_bind_mount(source); ++ if (r < 0) ++ return r; ++ } ++ ++ return true; ++} ++ + static int parse_fstab(bool initrd) { + _cleanup_endmntent_ FILE *f = NULL; + const char *fstab; + struct mntent *me; +- int r = 0, sysfs_check = -1; ++ int r, ret = 0; + + if (initrd) + fstab = sysroot_fstab_path(); +@@ -671,146 +822,14 @@ static int parse_fstab(bool initrd) { + } + + while ((me = getmntent(f))) { +- _cleanup_free_ char *where = NULL, *what = NULL, *canonical_where = NULL; +- bool makefs, growfs, noauto, nofail; +- MountPointFlags flags; +- int k; +- +- if (initrd && !mount_in_initrd(me)) +- continue; +- +- what = fstab_node_to_udev_node(me->mnt_fsname); +- if (!what) +- return log_oom(); +- +- if (path_is_read_only_fs("/sys") > 0) { +- if (streq(what, "sysfs")) { +- log_info("Running in a container, ignoring fstab entry for %s.", what); +- continue; +- } +- +- if (sysfs_check < 0) { +- r = getenv_bool_secure("SYSTEMD_SYSFS_CHECK"); +- if (r < 0 && r != -ENXIO) +- log_debug_errno(r, "Failed to parse $SYSTEMD_SYSFS_CHECK, ignoring: %m"); +- sysfs_check = r != 0; +- } +- +- if (sysfs_check && is_device_path(what)) { +- log_info("/sys/ is read-only (running in a container?), ignoring fstab device entry for %s.", what); +- continue; +- } +- } +- +- where = strdup(me->mnt_dir); +- if (!where) +- return log_oom(); +- +- if (is_path(where)) { +- path_simplify(where); +- +- /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for +- * mount units, but causes problems since it historically worked to have symlinks in e.g. +- * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case +- * where a symlink refers to another mount target; this works assuming the sub-mountpoint +- * target is the final directory. +- * +- * FIXME: when chase_symlinks() learns to chase non-existent paths, use this here and +- * drop the prefixing with /sysroot on error below. +- */ +- k = chase_symlinks(where, initrd ? "/sysroot" : NULL, +- CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, +- &canonical_where, NULL); +- if (k < 0) { +- /* If we can't canonicalize, continue as if it wasn't a symlink */ +- log_debug_errno(k, "Failed to read symlink target for %s, using as-is: %m", where); +- +- if (initrd) { +- canonical_where = path_join("/sysroot", where); +- if (!canonical_where) +- return log_oom(); +- } +- +- } else if (streq(canonical_where, where)) /* If it was fully canonicalized, suppress the change */ +- canonical_where = mfree(canonical_where); +- else +- log_debug("Canonicalized what=%s where=%s to %s", what, where, canonical_where); +- } +- +- makefs = fstab_test_option(me->mnt_opts, "x-systemd.makefs\0"); +- growfs = fstab_test_option(me->mnt_opts, "x-systemd.growfs\0"); +- noauto = fstab_test_yes_no_option(me->mnt_opts, "noauto\0" "auto\0"); +- nofail = fstab_test_yes_no_option(me->mnt_opts, "nofail\0" "fail\0"); +- +- log_debug("Found entry what=%s where=%s type=%s makefs=%s growfs=%s noauto=%s nofail=%s", +- what, where, me->mnt_type, +- yes_no(makefs), yes_no(growfs), +- yes_no(noauto), yes_no(nofail)); +- +- flags = makefs * MOUNT_MAKEFS | +- growfs * MOUNT_GROWFS | +- noauto * MOUNT_NOAUTO | +- nofail * MOUNT_NOFAIL; +- +- if (streq(me->mnt_type, "swap")) +- k = add_swap(fstab, what, me, flags); +- else { +- bool rw_only, automount, is_sysroot, is_sysroot_usr; +- +- rw_only = fstab_test_option(me->mnt_opts, "x-systemd.rw-only\0"); +- automount = fstab_test_option(me->mnt_opts, +- "comment=systemd.automount\0" +- "x-systemd.automount\0"); +- +- flags |= rw_only * MOUNT_RW_ONLY | +- automount * MOUNT_AUTOMOUNT; +- +- is_sysroot = in_initrd() && path_equal(where, "/sysroot"); +- /* See comment from add_sysroot_usr_mount about the need for extra indirection +- * in case /usr needs to be mounted in order for the root fs to be synthesized +- * based on configuration included in /usr/, e.g. systemd-repart. */ +- is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); +- +- const char *target_unit = +- initrd ? SPECIAL_INITRD_FS_TARGET : +- is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : +- is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : +- mount_is_network(me) ? SPECIAL_REMOTE_FS_TARGET : +- SPECIAL_LOCAL_FS_TARGET; +- +- if (is_sysroot && is_device_path(what)) { +- r = generator_write_initrd_root_device_deps(arg_dest, what); +- if (r < 0) +- return r; +- } +- +- k = add_mount(fstab, +- arg_dest, +- what, +- is_sysroot_usr ? "/sysusr/usr" : canonical_where ?: where, +- !is_sysroot_usr && canonical_where ? where : NULL, +- me->mnt_type, +- me->mnt_opts, +- me->mnt_passno, +- flags, +- target_unit); +- +- if (is_sysroot_usr && k >= 0) { +- log_debug("Synthesizing fstab entry what=/sysusr/usr where=/sysroot/usr opts=bind"); +- +- r = add_sysusr_sysroot_usr_bind_mount(fstab); +- if (r != 0) +- k = r; +- } +- } +- +- if (arg_sysroot_check && k > 0) ++ r = parse_fstab_one(fstab, me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, initrd); ++ if (r < 0 && ret >= 0) ++ ret = r; ++ if (arg_sysroot_check && r > 0) + return true; /* We found a mount or swap that would be started… */ +- if (r >= 0 && k < 0) +- r = k; + } + +- return r; ++ return ret; + } + + static int sysroot_is_nfsroot(void) { diff --git a/SOURCES/0322-fstab-generator-call-add_swap-earlier.patch b/SOURCES/0322-fstab-generator-call-add_swap-earlier.patch new file mode 100644 index 0000000..99dea3f --- /dev/null +++ b/SOURCES/0322-fstab-generator-call-add_swap-earlier.patch @@ -0,0 +1,81 @@ +From 90c66a0982b41c38cfd027a2bb3e6b33d0744e68 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Fri, 12 May 2023 16:08:32 +0900 +Subject: [PATCH] fstab-generator: call add_swap() earlier + +As 'where' field will be ignored for swap entry. + +(cherry picked from commit 256604ccddd41a16de329ff792c5f49d6750e510) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 4ea95f29eb..742a84b485 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -128,6 +128,11 @@ static int add_swap( + return true; + } + ++ log_debug("Found swap entry what=%s makefs=%s growfs=%s noauto=%s nofail=%s", ++ what, ++ yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), ++ yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL)); ++ + r = unit_name_from_path(what, ".swap", &name); + if (r < 0) + return log_error_errno(r, "Failed to generate unit name: %m"); +@@ -691,16 +696,18 @@ static int parse_fstab_one( + + _cleanup_free_ char *what = NULL, *where = NULL, *canonical_where = NULL; + MountPointFlags flags; ++ bool is_swap; + int r; + + assert(what_original); +- assert(where_original); + assert(fstype); + assert(options); + + if (initrd && !mount_in_initrd(where_original, options)) + return 0; + ++ is_swap = streq_ptr(fstype, "swap"); ++ + what = fstab_node_to_udev_node(what_original); + if (!what) + return log_oom(); +@@ -712,6 +719,13 @@ static int parse_fstab_one( + return 0; + } + ++ flags = fstab_options_to_flags(options, is_swap); ++ ++ if (is_swap) ++ return add_swap(source, what, options, flags); ++ ++ assert(where_original); /* 'where' is not necessary for swap entry. */ ++ + where = strdup(where_original); + if (!where) + return log_oom(); +@@ -746,16 +760,11 @@ static int parse_fstab_one( + log_debug("Canonicalized what=%s where=%s to %s", what, where, canonical_where); + } + +- flags = fstab_options_to_flags(options, streq_ptr(fstype, "swap")); +- + log_debug("Found entry what=%s where=%s type=%s makefs=%s growfs=%s noauto=%s nofail=%s", + what, where, strna(fstype), + yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), + yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL)); + +- if (streq_ptr(fstype, "swap")) +- return add_swap(source, what, options, flags); +- + bool is_sysroot = in_initrd() && path_equal(where, "/sysroot"); + /* See comment from add_sysroot_usr_mount() about the need for extra indirection in case /usr needs + * to be mounted in order for the root fs to be synthesized based on configuration included in /usr/, diff --git a/SOURCES/0323-fstab-generator-refuse-to-add-swap-earlier-if-disabl.patch b/SOURCES/0323-fstab-generator-refuse-to-add-swap-earlier-if-disabl.patch new file mode 100644 index 0000000..b6b3bd2 --- /dev/null +++ b/SOURCES/0323-fstab-generator-refuse-to-add-swap-earlier-if-disabl.patch @@ -0,0 +1,41 @@ +From 6858b1611dd198607c246b835d8840d15d8f09e5 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 24 May 2023 07:24:52 +0900 +Subject: [PATCH] fstab-generator: refuse to add swap earlier if disabled + +No functional change, preparation for later commits. + +(cherry picked from commit 9445623363fc47ee5a9265adeb9f4ca1a80ebfe4) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 742a84b485..2cd4de29f0 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -108,11 +108,6 @@ static int add_swap( + + assert(what); + +- if (!arg_swap_enabled) { +- log_info("Swap unit generation disabled on kernel command line, ignoring fstab swap entry for %s.", what); +- return 0; +- } +- + if (access("/proc/swaps", F_OK) < 0) { + log_info("Swap not supported, ignoring fstab swap entry for %s.", what); + return 0; +@@ -707,6 +702,10 @@ static int parse_fstab_one( + return 0; + + is_swap = streq_ptr(fstype, "swap"); ++ if (is_swap && !arg_swap_enabled) { ++ log_info("Swap unit generation disabled on kernel command line, ignoring swap entry for %s.", what); ++ return 0; ++ } + + what = fstab_node_to_udev_node(what_original); + if (!what) diff --git a/SOURCES/0324-fstab-generator-refuse-invalid-mount-point-path-in-f.patch b/SOURCES/0324-fstab-generator-refuse-invalid-mount-point-path-in-f.patch new file mode 100644 index 0000000..c412fad --- /dev/null +++ b/SOURCES/0324-fstab-generator-refuse-invalid-mount-point-path-in-f.patch @@ -0,0 +1,119 @@ +From 38d81fc89f325801922971229a894038fe207eae Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 24 May 2023 07:04:06 +0900 +Subject: [PATCH] fstab-generator: refuse invalid mount point path in fstab + earlier + +(cherry picked from commit 6742eca13497dd9dd548ba3e2ced2588d82720ac) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 68 +++++++++++++-------------- + 1 file changed, 34 insertions(+), 34 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 2cd4de29f0..bd1508bc30 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -689,7 +689,7 @@ static int parse_fstab_one( + int passno, + bool initrd) { + +- _cleanup_free_ char *what = NULL, *where = NULL, *canonical_where = NULL; ++ _cleanup_free_ char *what = NULL, *where = NULL; + MountPointFlags flags; + bool is_swap; + int r; +@@ -725,50 +725,50 @@ static int parse_fstab_one( + + assert(where_original); /* 'where' is not necessary for swap entry. */ + +- where = strdup(where_original); +- if (!where) +- return log_oom(); +- +- if (is_path(where)) { +- path_simplify(where); ++ if (!is_path(where_original)) { ++ log_warning("Mount point %s is not a valid path, ignoring.", where); ++ return 0; ++ } + +- /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for +- * mount units, but causes problems since it historically worked to have symlinks in e.g. +- * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case +- * where a symlink refers to another mount target; this works assuming the sub-mountpoint +- * target is the final directory. +- * +- * FIXME: when chase() learns to chase non-existent paths, use this here and +- * drop the prefixing with /sysroot on error below. +- */ +- r = chase_symlinks(where, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, +- &canonical_where, NULL); +- if (r < 0) { +- /* If we can't canonicalize, continue as if it wasn't a symlink */ +- log_debug_errno(r, "Failed to read symlink target for %s, using as-is: %m", where); +- +- if (initrd) { +- canonical_where = path_join("/sysroot", where); +- if (!canonical_where) +- return log_oom(); +- } ++ /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for ++ * mount units, but causes problems since it historically worked to have symlinks in e.g. ++ * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case ++ * where a symlink refers to another mount target; this works assuming the sub-mountpoint ++ * target is the final directory. ++ * ++ * FIXME: when chase() learns to chase non-existent paths, use this here and ++ * drop the prefixing with /sysroot on error below. ++ */ ++ r = chase_symlinks(where_original, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &where, NULL); ++ if (r < 0) { ++ /* If we can't canonicalize, continue as if it wasn't a symlink */ ++ log_debug_errno(r, "Failed to read symlink target for %s, using as-is: %m", where_original); + +- } else if (streq(canonical_where, where)) /* If it was fully canonicalized, suppress the change */ +- canonical_where = mfree(canonical_where); ++ if (initrd) ++ where = path_join("/sysroot", where_original); + else +- log_debug("Canonicalized what=%s where=%s to %s", what, where, canonical_where); ++ where = strdup(where_original); ++ if (!where) ++ return log_oom(); ++ ++ path_simplify(where); + } + ++ if (streq(where, where_original)) /* If it was fully canonicalized, suppress the change */ ++ where = mfree(where); ++ else ++ log_debug("Canonicalized what=%s where=%s to %s", what, where_original, where); ++ + log_debug("Found entry what=%s where=%s type=%s makefs=%s growfs=%s noauto=%s nofail=%s", + what, where, strna(fstype), + yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), + yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL)); + +- bool is_sysroot = in_initrd() && path_equal(where, "/sysroot"); ++ bool is_sysroot = in_initrd() && path_equal(where ?: where_original, "/sysroot"); + /* See comment from add_sysroot_usr_mount() about the need for extra indirection in case /usr needs + * to be mounted in order for the root fs to be synthesized based on configuration included in /usr/, + * e.g. systemd-repart. */ +- bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); ++ bool is_sysroot_usr = in_initrd() && path_equal(where ?: where_original, "/sysroot/usr"); + + const char *target_unit = + initrd ? SPECIAL_INITRD_FS_TARGET : +@@ -786,8 +786,8 @@ static int parse_fstab_one( + r = add_mount(source, + arg_dest, + what, +- is_sysroot_usr ? "/sysusr/usr" : canonical_where ?: where, +- !is_sysroot_usr && canonical_where ? where : NULL, ++ is_sysroot_usr ? "/sysusr/usr" : where ?: where_original, ++ !is_sysroot_usr && where ? where_original : NULL, + fstype, + options, + passno, diff --git a/SOURCES/0325-fstab-generator-fix-error-code-propagation-in-run_ge.patch b/SOURCES/0325-fstab-generator-fix-error-code-propagation-in-run_ge.patch new file mode 100644 index 0000000..53601c5 --- /dev/null +++ b/SOURCES/0325-fstab-generator-fix-error-code-propagation-in-run_ge.patch @@ -0,0 +1,75 @@ +From 00f65b3c9b052007857558ec0776944ffe3979d4 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 May 2023 19:47:17 +0900 +Subject: [PATCH] fstab-generator: fix error code propagation in + run_generator() + +Previously, some errors might be ignored. + +(cherry picked from commit 2646f1844553b5d9c6109ad6b1b86da0b6b1f248) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 29 +++++++++++++++++++-------- + 1 file changed, 21 insertions(+), 8 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index bd1508bc30..c53feb6154 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -1265,7 +1265,7 @@ static int determine_usr(void) { + * with /sysroot/etc/fstab available, and then we can write additional units based + * on that file. */ + static int run_generator(void) { +- int r, r2 = 0, r3 = 0; ++ int r, ret = 0; + + r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0); + if (r < 0) +@@ -1286,26 +1286,39 @@ static int run_generator(void) { + /* Always honour root= and usr= in the kernel command line if we are in an initrd */ + if (in_initrd()) { + r = add_sysroot_mount(); ++ if (r < 0 && ret >= 0) ++ ret = r; + +- r2 = add_sysroot_usr_mount_or_fallback(); ++ r = add_sysroot_usr_mount_or_fallback(); ++ if (r < 0 && ret >= 0) ++ ret = r; + +- r3 = add_volatile_root(); +- } else ++ r = add_volatile_root(); ++ if (r < 0 && ret >= 0) ++ ret = r; ++ } else { + r = add_volatile_var(); ++ if (r < 0 && ret >= 0) ++ ret = r; ++ } + + /* Honour /etc/fstab only when that's enabled */ + if (arg_fstab_enabled) { + /* Parse the local /etc/fstab, possibly from the initrd */ +- r2 = parse_fstab(false); ++ r = parse_fstab(false); ++ if (r < 0 && ret >= 0) ++ ret = r; + + /* If running in the initrd also parse the /etc/fstab from the host */ + if (in_initrd()) +- r3 = parse_fstab(true); ++ r = parse_fstab(true); + else +- r3 = generator_enable_remount_fs_service(arg_dest); ++ r = generator_enable_remount_fs_service(arg_dest); ++ if (r < 0 && ret >= 0) ++ ret = r; + } + +- return r < 0 ? r : r2 < 0 ? r2 : r3; ++ return ret; + } + + static int run(int argc, char **argv) { diff --git a/SOURCES/0326-fstab-generator-support-defining-mount-units-through.patch b/SOURCES/0326-fstab-generator-support-defining-mount-units-through.patch new file mode 100644 index 0000000..e547b2e --- /dev/null +++ b/SOURCES/0326-fstab-generator-support-defining-mount-units-through.patch @@ -0,0 +1,307 @@ +From 752ce62315bb38bd1267bd49dccc4dad2e9d05ee Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 May 2023 19:49:33 +0900 +Subject: [PATCH] fstab-generator: support defining mount units through kernel + command line + +Now, the following kernel command line options are supported: + systemd.mount-extra=what:where:fstype:options + systemd.swap-extra=what:options + +Closes #27260. + +(cherry picked from commit 55365b0a233ae3024411fd0815ad930e20f6a3d6) + +Resolves: #2190226 +--- + man/systemd-fstab-generator.xml | 27 +++++ + src/fstab-generator/fstab-generator.c | 164 +++++++++++++++++++++++++- + 2 files changed, 186 insertions(+), 5 deletions(-) + +diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml +index 30204f5d8a..b29022fab7 100644 +--- a/man/systemd-fstab-generator.xml ++++ b/man/systemd-fstab-generator.xml +@@ -239,6 +239,33 @@ + any swap devices configured in /etc/fstab. + Defaults to enabled. + ++ ++ ++ systemd.mount-extra=WHAT:WHERE[:FSTYPE[:OPTIONS]] ++ ++ ++ Specifies the mount unit. Takes at least two and at most four fields separated with a colon ++ (:). Each field is handled as the corresponding fstab field. This option can be ++ specified multiple times. ++ Example: ++ ++systemd.mount-extra=/dev/sda1:/mount-point:ext4:rw,noatime ++ ++ ++ ++ ++ ++ systemd.swap-extra=WHAT[:OPTIONS] ++ ++ ++ Specifies the swap unit. Takes the block device to be used as a swap device, and optionally ++ takes mount options followed by a colon (:). ++ Example: ++ ++systemd.swap=/dev/sda2:x-systemd.makefs ++ ++ ++ + + + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index c53feb6154..910e29d26b 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -20,6 +20,7 @@ + #include "mount-setup.h" + #include "mount-util.h" + #include "mountpoint-util.h" ++#include "nulstr-util.h" + #include "parse-util.h" + #include "path-util.h" + #include "proc-cmdline.h" +@@ -43,6 +44,15 @@ typedef enum MountPointFlags { + MOUNT_RW_ONLY = 1 << 5, + } MountPointFlags; + ++typedef struct Mount { ++ char *what; ++ char *where; ++ char *fstype; ++ char *options; ++} Mount; ++ ++static void mount_array_free(Mount *mounts, size_t n); ++ + static bool arg_sysroot_check = false; + static const char *arg_dest = NULL; + static const char *arg_dest_late = NULL; +@@ -58,6 +68,8 @@ static char *arg_usr_fstype = NULL; + static char *arg_usr_options = NULL; + static char *arg_usr_hash = NULL; + static VolatileMode arg_volatile_mode = _VOLATILE_MODE_INVALID; ++static Mount *arg_mounts = NULL; ++static size_t arg_n_mounts = 0; + + STATIC_DESTRUCTOR_REGISTER(arg_root_what, freep); + STATIC_DESTRUCTOR_REGISTER(arg_root_fstype, freep); +@@ -67,6 +79,101 @@ STATIC_DESTRUCTOR_REGISTER(arg_usr_what, freep); + STATIC_DESTRUCTOR_REGISTER(arg_usr_fstype, freep); + STATIC_DESTRUCTOR_REGISTER(arg_usr_options, freep); + STATIC_DESTRUCTOR_REGISTER(arg_usr_hash, freep); ++STATIC_ARRAY_DESTRUCTOR_REGISTER(arg_mounts, arg_n_mounts, mount_array_free); ++ ++static void mount_done(Mount *m) { ++ assert(m); ++ ++ free(m->what); ++ free(m->where); ++ free(m->fstype); ++ free(m->options); ++} ++ ++static void mount_array_free(Mount *mounts, size_t n) { ++ FOREACH_ARRAY(m, mounts, n) ++ mount_done(m); ++ ++ free(mounts); ++} ++ ++static int mount_array_add_internal(char *in_what, char *in_where, const char *in_fstype, const char *in_options) { ++ _cleanup_free_ char *what = NULL, *where = NULL, *fstype = NULL, *options = NULL; ++ int r; ++ ++ /* This takes what and where. */ ++ ++ what = ASSERT_PTR(in_what); ++ where = in_where; ++ ++ fstype = strdup(isempty(in_fstype) ? "auto" : in_fstype); ++ if (!fstype) ++ return -ENOMEM; ++ ++ if (streq(fstype, "swap")) ++ where = mfree(where); ++ ++ if (!isempty(in_options)) { ++ _cleanup_strv_free_ char **options_strv = NULL; ++ ++ r = strv_split_full(&options_strv, in_options, ",", 0); ++ if (r < 0) ++ return r; ++ ++ r = strv_make_nulstr(options_strv, &options, NULL); ++ } else ++ r = strv_make_nulstr(STRV_MAKE("defaults"), &options, NULL); ++ if (r < 0) ++ return r; ++ ++ if (!GREEDY_REALLOC(arg_mounts, arg_n_mounts + 1)) ++ return -ENOMEM; ++ ++ arg_mounts[arg_n_mounts++] = (Mount) { ++ .what = TAKE_PTR(what), ++ .where = TAKE_PTR(where), ++ .fstype = TAKE_PTR(fstype), ++ .options = TAKE_PTR(options), ++ }; ++ ++ return 0; ++} ++ ++static int mount_array_add(const char *str) { ++ _cleanup_free_ char *what = NULL, *where = NULL, *fstype = NULL, *options = NULL; ++ int r; ++ ++ assert(str); ++ ++ r = extract_many_words(&str, ":", EXTRACT_CUNESCAPE | EXTRACT_DONT_COALESCE_SEPARATORS, ++ &what, &where, &fstype, &options, NULL); ++ if (r < 0) ++ return r; ++ if (r < 2) ++ return -EINVAL; ++ if (!isempty(str)) ++ return -EINVAL; ++ ++ return mount_array_add_internal(TAKE_PTR(what), TAKE_PTR(where), fstype, options); ++} ++ ++static int mount_array_add_swap(const char *str) { ++ _cleanup_free_ char *what = NULL, *options = NULL; ++ int r; ++ ++ assert(str); ++ ++ r = extract_many_words(&str, ":", EXTRACT_CUNESCAPE | EXTRACT_DONT_COALESCE_SEPARATORS, ++ &what, &options, NULL); ++ if (r < 0) ++ return r; ++ if (r < 1) ++ return -EINVAL; ++ if (!isempty(str)) ++ return -EINVAL; ++ ++ return mount_array_add_internal(TAKE_PTR(what), NULL, "swap", options); ++} + + static int write_options(FILE *f, const char *options) { + _cleanup_free_ char *o = NULL; +@@ -109,12 +216,12 @@ static int add_swap( + assert(what); + + if (access("/proc/swaps", F_OK) < 0) { +- log_info("Swap not supported, ignoring fstab swap entry for %s.", what); ++ log_info("Swap not supported, ignoring swap entry for %s.", what); + return 0; + } + + if (detect_container() > 0) { +- log_info("Running in a container, ignoring fstab swap entry for %s.", what); ++ log_info("Running in a container, ignoring swap entry for %s.", what); + return 0; + } + +@@ -687,7 +794,8 @@ static int parse_fstab_one( + const char *fstype, + const char *options, + int passno, +- bool initrd) { ++ bool initrd, ++ bool use_swap_enabled) { + + _cleanup_free_ char *what = NULL, *where = NULL; + MountPointFlags flags; +@@ -702,7 +810,7 @@ static int parse_fstab_one( + return 0; + + is_swap = streq_ptr(fstype, "swap"); +- if (is_swap && !arg_swap_enabled) { ++ if (is_swap && use_swap_enabled && !arg_swap_enabled) { + log_info("Swap unit generation disabled on kernel command line, ignoring swap entry for %s.", what); + return 0; + } +@@ -830,7 +938,9 @@ static int parse_fstab(bool initrd) { + } + + while ((me = getmntent(f))) { +- r = parse_fstab_one(fstab, me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, initrd); ++ r = parse_fstab_one(fstab, ++ me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, ++ initrd, /* use_swap_enabled = */ true); + if (r < 0 && ret >= 0) + ret = r; + if (arg_sysroot_check && r > 0) +@@ -1129,6 +1239,28 @@ static int add_volatile_var(void) { + SPECIAL_LOCAL_FS_TARGET); + } + ++static int add_mounts_from_cmdline(void) { ++ int r, ret = 0; ++ ++ /* Handle each entries found in cmdline as a fstab entry. */ ++ ++ FOREACH_ARRAY(m, arg_mounts, arg_n_mounts) { ++ r = parse_fstab_one( ++ "/proc/cmdline", ++ m->what, ++ m->where, ++ m->fstype, ++ m->options, ++ /* passno = */ 0, ++ /* initrd = */ false, ++ /* use_swap_enabled = */ false); ++ if (r < 0 && ret >= 0) ++ ret = r; ++ } ++ ++ return ret; ++} ++ + static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { + int r; + +@@ -1225,6 +1357,24 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat + log_warning("Failed to parse systemd.swap switch %s. Ignoring.", value); + else + arg_swap_enabled = r; ++ ++ } else if (streq(key, "systemd.mount-extra")) { ++ ++ if (proc_cmdline_value_missing(key, value)) ++ return 0; ++ ++ r = mount_array_add(value); ++ if (r < 0) ++ log_warning("Failed to parse systemd.mount-extra= option, ignoring: %s", value); ++ ++ } else if (streq(key, "systemd.swap-extra")) { ++ ++ if (proc_cmdline_value_missing(key, value)) ++ return 0; ++ ++ r = mount_array_add_swap(value); ++ if (r < 0) ++ log_warning("Failed to parse systemd.swap-extra= option, ignoring: %s", value); + } + + return 0; +@@ -1318,6 +1468,10 @@ static int run_generator(void) { + ret = r; + } + ++ r = add_mounts_from_cmdline(); ++ if (r < 0 && ret >= 0) ++ ret = r; ++ + return ret; + } + diff --git a/SOURCES/0327-test-add-test-cases-for-defining-mount-and-swap-unit.patch b/SOURCES/0327-test-add-test-cases-for-defining-mount-and-swap-unit.patch new file mode 100644 index 0000000..0839028 --- /dev/null +++ b/SOURCES/0327-test-add-test-cases-for-defining-mount-and-swap-unit.patch @@ -0,0 +1,412 @@ +From 329afb79232d9206d8e64fc9cfa3a0e71dda532f Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Fri, 12 May 2023 03:55:46 +0900 +Subject: [PATCH] test: add test cases for defining mount and swap units from + kernel cmdline + +(cherry picked from commit 93ec924c41cece471c9b530cfddcc7cbfd536969) + +Related: #2190226 +--- + test/test-fstab-generator.sh | 20 ++++++++++++++++++- + .../hoge-without_fstype.mount | 11 ++++++++++ + .../hoge-without_options.mount | 11 ++++++++++ + .../hoge-withx20space.mount | 12 +++++++++++ + .../50-root-device.conf | 5 +++++ + .../sysroot.mount | 1 + + .../sysroot.mount | 1 + + .../hoge-without_fstype.mount | 1 + + .../hoge-without_options.mount | 1 + + .../hoge-withx20space.mount | 1 + + .../sysroot.mount | 11 ++++++++++ + .../test-19-mounts-from-cmdline.input | 5 +++++ + .../sysroot.mount | 0 + .../dev-sdy1.swap | 9 +++++++++ + .../dev-sdy2.swap | 10 ++++++++++ + .../systemd-mkswap@dev-sdy2.service | 1 + + .../dev-sdy3.swap | 10 ++++++++++ + .../systemd-mkswap@dev-sdy3.service | 1 + + .../dev-sdy4.swap | 9 +++++++++ + .../sysroot.mount | 0 + .../swap.target.requires/dev-sdy1.swap | 1 + + .../swap.target.requires/dev-sdy2.swap | 1 + + .../swap.target.requires/dev-sdy3.swap | 1 + + .../swap.target.requires/dev-sdy4.swap | 1 + + .../systemd-mkswap@dev-sdy2.service | 18 +++++++++++++++++ + .../systemd-mkswap@dev-sdy3.service | 18 +++++++++++++++++ + .../test-20-swap-from-cmdline.input | 4 ++++ + 27 files changed, 163 insertions(+), 1 deletion(-) + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-withx20space.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-device.target.d/50-root-device.conf + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-fs.target.requires/sysroot.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_fstype.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_options.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/remote-fs.target.requires/hoge-withx20space.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.input + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected.container/initrd-usr-fs.target.requires/sysroot.mount + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy1.swap + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap.requires/systemd-mkswap@dev-sdy2.service + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap.requires/systemd-mkswap@dev-sdy3.service + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy4.swap + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy1.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy2.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy3.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy4.swap + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.input + +diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh +index 7df67ce305..68c9d0631e 100755 +--- a/test/test-fstab-generator.sh ++++ b/test/test-fstab-generator.sh +@@ -28,11 +28,14 @@ for f in "$src"/test-*.input; do + trap "rm -rf '$out'" EXIT INT QUIT PIPE + + exp="${f%.input}.expected" ++ if [[ "${f##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then ++ exp="${exp}.container" ++ fi + + if [[ "${f##*/}" =~ \.fstab\.input ]]; then + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$f" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" + else +- SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" + fi + + # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. +@@ -55,6 +58,21 @@ for f in "$src"/test-*.input; do + done + fi + ++ # .deb packager seems to dislike files named with backslash. So, as a workaround, we store files ++ # without backslash in .expected. ++ for i in "$out"/**/*\\*.{mount,swap}; do ++ k="${i//\\/}" ++ if [[ "$i" != "$k" ]]; then ++ if [[ -f "$i" ]]; then ++ mv "$i" "$k" ++ elif [[ -L "$i" ]]; then ++ dest=$(readlink "$i") ++ rm "$i" ++ ln -s "${dest//\\/}" "$k" ++ fi ++ fi ++ done ++ + # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare + # the list of filenames rather than their content + if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount +new file mode 100644 +index 0000000000..4d7d975cc0 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=local-fs.target ++After=blockdev@dev-sdx3.target ++ ++[Mount] ++What=/dev/sdx3 ++Where=/hoge/without_fstype +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount +new file mode 100644 +index 0000000000..4f16d2e40b +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=local-fs.target ++After=blockdev@dev-sdx2.target ++ ++[Mount] ++What=/dev/sdx2 ++Where=/hoge/without_options +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-withx20space.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-withx20space.mount +new file mode 100644 +index 0000000000..e9ffb4bbd9 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-withx20space.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=remote-fs.target ++ ++[Mount] ++What=//foo￾bar ++Where=/hoge/with space ++Type=cifs ++Options=rw +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-device.target.d/50-root-device.conf b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-device.target.d/50-root-device.conf +new file mode 100644 +index 0000000000..47c4232223 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-device.target.d/50-root-device.conf +@@ -0,0 +1,5 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Requires=dev-sdx1.device ++After=dev-sdx1.device +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-root-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_fstype.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_fstype.mount +new file mode 120000 +index 0000000000..d46cee354e +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_fstype.mount +@@ -0,0 +1 @@ ++../hoge-without_fstype.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_options.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_options.mount +new file mode 120000 +index 0000000000..9c790fb248 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/local-fs.target.requires/hoge-without_options.mount +@@ -0,0 +1 @@ ++../hoge-without_options.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/remote-fs.target.requires/hoge-withx20space.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/remote-fs.target.requires/hoge-withx20space.mount +new file mode 120000 +index 0000000000..2404d7619f +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/remote-fs.target.requires/hoge-withx20space.mount +@@ -0,0 +1 @@ ++../hoge-withx20space.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount +new file mode 100644 +index 0000000000..c8547fa539 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=initrd-root-fs.target ++After=blockdev@dev-sdx1.target ++ ++[Mount] ++What=/dev/sdx1 ++Where=/sysroot +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.input b/test/test-fstab-generator/test-19-mounts-from-cmdline.input +new file mode 100644 +index 0000000000..4312d01e52 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.input +@@ -0,0 +1,5 @@ ++systemd.mount-extra=/dev/sdx1:/sysroot:auto:defaults ++systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto ++systemd.mount-extra=/dev/sdx3:/hoge/without_fstype ++systemd.mount-extra=/dev/sdx4 ++systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.container/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.container/initrd-usr-fs.target.requires/sysroot.mount +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy1.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy1.swap +new file mode 100644 +index 0000000000..f515bc149e +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy1.swap +@@ -0,0 +1,9 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy1.target ++ ++[Swap] ++What=/dev/sdy1 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap +new file mode 100644 +index 0000000000..104260a60d +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap +@@ -0,0 +1,10 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy2.target ++ ++[Swap] ++What=/dev/sdy2 ++Options=x-systemd.makefs +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap.requires/systemd-mkswap@dev-sdy2.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap.requires/systemd-mkswap@dev-sdy2.service +new file mode 120000 +index 0000000000..5248a5f8b7 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy2.swap.requires/systemd-mkswap@dev-sdy2.service +@@ -0,0 +1 @@ ++../systemd-mkswap@dev-sdy2.service +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap +new file mode 100644 +index 0000000000..3b6563d216 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap +@@ -0,0 +1,10 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy3.target ++ ++[Swap] ++What=/dev/sdy3 ++Options=x-systemd.makefs +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap.requires/systemd-mkswap@dev-sdy3.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap.requires/systemd-mkswap@dev-sdy3.service +new file mode 120000 +index 0000000000..e41d758141 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy3.swap.requires/systemd-mkswap@dev-sdy3.service +@@ -0,0 +1 @@ ++../systemd-mkswap@dev-sdy3.service +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy4.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy4.swap +new file mode 100644 +index 0000000000..37d90f7b64 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy4.swap +@@ -0,0 +1,9 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy4.target ++ ++[Swap] ++What=/dev/sdy4 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/initrd-usr-fs.target.requires/sysroot.mount +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy1.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy1.swap +new file mode 120000 +index 0000000000..a899ff84c0 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy1.swap +@@ -0,0 +1 @@ ++../dev-sdy1.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy2.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy2.swap +new file mode 120000 +index 0000000000..14df9d6acc +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy2.swap +@@ -0,0 +1 @@ ++../dev-sdy2.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy3.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy3.swap +new file mode 120000 +index 0000000000..19663fe046 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy3.swap +@@ -0,0 +1 @@ ++../dev-sdy3.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy4.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy4.swap +new file mode 120000 +index 0000000000..9bfd9d8316 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy4.swap +@@ -0,0 +1 @@ ++../dev-sdy4.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service +new file mode 100644 +index 0000000000..0911f03f62 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service +@@ -0,0 +1,18 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=Make Swap on %f ++Documentation=man:systemd-mkswap@.service(8) ++ ++DefaultDependencies=no ++BindsTo=%i.device ++After=%i.device ++Before=dev-sdy2.swap ++Conflicts=shutdown.target ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-makefs swap /dev/sdy2 ++TimeoutSec=0 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service +new file mode 100644 +index 0000000000..6201fec86b +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service +@@ -0,0 +1,18 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=Make Swap on %f ++Documentation=man:systemd-mkswap@.service(8) ++ ++DefaultDependencies=no ++BindsTo=%i.device ++After=%i.device ++Before=dev-sdy3.swap ++Conflicts=shutdown.target ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-makefs swap /dev/sdy3 ++TimeoutSec=0 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.input b/test/test-fstab-generator/test-20-swap-from-cmdline.input +new file mode 100644 +index 0000000000..953c09ff10 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.input +@@ -0,0 +1,4 @@ ++systemd.mount-extra=/dev/sdy1:none:swap ++systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs ++systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail ++systemd.swap-extra=/dev/sdy4 diff --git a/SOURCES/0328-generators-change-TimeoutSec-0-to-TimeoutSec-infinit.patch b/SOURCES/0328-generators-change-TimeoutSec-0-to-TimeoutSec-infinit.patch new file mode 100644 index 0000000..84f4ece --- /dev/null +++ b/SOURCES/0328-generators-change-TimeoutSec-0-to-TimeoutSec-infinit.patch @@ -0,0 +1,221 @@ +From cfff52ac273243140b894b735221c0eef2891fe8 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 6 Jun 2023 09:29:51 +0200 +Subject: [PATCH] generators: change TimeoutSec=0 to TimeoutSec=infinity + +With these settings we intend to turn off timeouts for possibly +interactive/slow commands. The officially documented way to turn off the +time-outs is to setting them to infinity. So far we set them to zero +here though. + +This lead to some confusiong, for example #18224. Let's fix this by +uniformly spelling out TimeoutSec=infinity. + +This doesn't change behaviour. It just makes our generated files match +what we document, without relying on historic compat support. + +Fixes: #18224 +(cherry picked from commit a9b837aa34a2d0bff1687427c66bed3b74cf0fed) + +Related: #2190226 +--- + src/cryptsetup/cryptsetup-generator.c | 3 ++- + src/gpt-auto-generator/gpt-auto-generator.c | 2 +- + src/hibernate-resume/hibernate-resume-generator.c | 3 ++- + src/integritysetup/integritysetup-generator.c | 2 +- + src/shared/generator.c | 8 ++++---- + .../test-12-dev-sdx.expected/systemd-fsck-root.service | 2 +- + .../test-13-label.expected/systemd-fsck-root.service | 2 +- + .../test-14-uuid.expected/systemd-fsck-root.service | 2 +- + .../test-15-partuuid.expected/systemd-fsck-root.service | 2 +- + .../systemd-fsck-root.service | 2 +- + .../systemd-fsck-root.service | 2 +- + .../systemd-makefs@dev-sdx12.service | 2 +- + .../systemd-mkswap@dev-sdy2.service | 2 +- + .../systemd-mkswap@dev-sdy3.service | 2 +- + 14 files changed, 19 insertions(+), 17 deletions(-) + +diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c +index 07903f1044..9e8e7e746f 100644 +--- a/src/cryptsetup/cryptsetup-generator.c ++++ b/src/cryptsetup/cryptsetup-generator.c +@@ -551,7 +551,8 @@ static int create_disk( + if (!noauto && !nofail) { + r = write_drop_in(arg_dest, dmname, 40, "device-timeout", + "# Automatically generated by systemd-cryptsetup-generator\n\n" +- "[Unit]\nJobTimeoutSec=0"); ++ "[Unit]\n" ++ "JobTimeoutSec=infinity\n"); + if (r < 0) + log_warning_errno(r, "Failed to write device timeout drop-in: %m"); + } +diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c +index 143faa0c39..0bab43e69a 100644 +--- a/src/gpt-auto-generator/gpt-auto-generator.c ++++ b/src/gpt-auto-generator/gpt-auto-generator.c +@@ -112,7 +112,7 @@ static int add_cryptsetup( + r = write_drop_in_format(arg_dest, dmname, 50, "job-timeout", + "# Automatically generated by systemd-gpt-auto-generator\n\n" + "[Unit]\n" +- "JobTimeoutSec=0"); /* the binary handles timeouts anyway */ ++ "JobTimeoutSec=infinity"); /* the binary handles timeouts anyway */ + if (r < 0) + log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m"); + +diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c +index 82c2a56493..6714fbf408 100644 +--- a/src/hibernate-resume/hibernate-resume-generator.c ++++ b/src/hibernate-resume/hibernate-resume-generator.c +@@ -94,7 +94,8 @@ static int process_resume(void) { + + r = write_drop_in(arg_dest, device_unit, 40, "device-timeout", + "# Automatically generated by systemd-hibernate-resume-generator\n\n" +- "[Unit]\nJobTimeoutSec=0"); ++ "[Unit]\n" ++ "JobTimeoutSec=infinity\n"); + if (r < 0) + log_warning_errno(r, "Failed to write device timeout drop-in: %m"); + +diff --git a/src/integritysetup/integritysetup-generator.c b/src/integritysetup/integritysetup-generator.c +index 15f508902d..5df6d81a84 100644 +--- a/src/integritysetup/integritysetup-generator.c ++++ b/src/integritysetup/integritysetup-generator.c +@@ -100,7 +100,7 @@ static int create_disk( + "[Service]\n" + "Type=oneshot\n" + "RemainAfterExit=yes\n" +- "TimeoutSec=0\n" ++ "TimeoutSec=infinity\n" + "ExecStart=" ROOTLIBEXECDIR "/systemd-integritysetup attach '%s' '%s' '%s' '%s'\n" + "ExecStop=" ROOTLIBEXECDIR "/systemd-integritysetup detach '%s'\n", + name_escaped, device, empty_to_dash(key_file_escaped), empty_to_dash(options), +diff --git a/src/shared/generator.c b/src/shared/generator.c +index 5d617bbe99..f1c5e506ab 100644 +--- a/src/shared/generator.c ++++ b/src/shared/generator.c +@@ -218,7 +218,7 @@ static int write_fsck_sysroot_service( + "Type=oneshot\n" + "RemainAfterExit=yes\n" + "ExecStart=" SYSTEMD_FSCK_PATH " %7$s\n" +- "TimeoutSec=0\n", ++ "TimeoutSec=infinity\n", + program_invocation_short_name, + escaped, + unit, +@@ -513,7 +513,7 @@ int generator_hook_up_mkswap( + "Type=oneshot\n" + "RemainAfterExit=yes\n" + "ExecStart="SYSTEMD_MAKEFS_PATH " swap %s\n" +- "TimeoutSec=0\n", ++ "TimeoutSec=infinity\n", + program_invocation_short_name, + where_unit, + escaped); +@@ -594,7 +594,7 @@ int generator_hook_up_mkfs( + "Type=oneshot\n" + "RemainAfterExit=yes\n" + "ExecStart="SYSTEMD_MAKEFS_PATH " %s %s\n" +- "TimeoutSec=0\n", ++ "TimeoutSec=infinity\n", + program_invocation_short_name, + where_unit, + type, +@@ -738,7 +738,7 @@ int generator_write_cryptsetup_service_section( + "[Service]\n" + "Type=oneshot\n" + "RemainAfterExit=yes\n" +- "TimeoutSec=0\n" /* The binary handles timeouts on its own */ ++ "TimeoutSec=infinity\n" /* The binary handles timeouts on its own */ + "KeyringMode=shared\n" /* Make sure we can share cached keys among instances */ + "OOMScoreAdjust=500\n" /* Unlocking can allocate a lot of memory if Argon2 is used */ + "ExecStart=" SYSTEMD_CRYPTSETUP_PATH " attach '%s' '%s' '%s' '%s'\n" +diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service +index 95d943b87a..147348899d 100644 +--- a/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service +@@ -14,4 +14,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service +index d6c59ff608..85c1936bce 100644 +--- a/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service +@@ -14,4 +14,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-label/Root +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service +index cd9583c4dd..1c7eaea103 100644 +--- a/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service +@@ -14,4 +14,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service +index 650ed8070a..ab27bfd79c 100644 +--- a/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service +@@ -14,4 +14,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-partuuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service +index 95d943b87a..147348899d 100644 +--- a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service +@@ -14,4 +14,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service +index 95d943b87a..147348899d 100644 +--- a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service +@@ -14,4 +14,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service +index 303c1ee680..4670c23e27 100644 +--- a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service ++++ b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service +@@ -15,4 +15,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-makefs ext4 /dev/sdx12 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service +index 0911f03f62..0b0e7270ba 100644 +--- a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service +@@ -15,4 +15,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-makefs swap /dev/sdy2 +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service +index 6201fec86b..1164c99476 100644 +--- a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service +@@ -15,4 +15,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/systemd/systemd-makefs swap /dev/sdy3 +-TimeoutSec=0 ++TimeoutSec=infinity diff --git a/SOURCES/0329-units-change-TimeoutSec-0-to-TimeoutSec-infinity.patch b/SOURCES/0329-units-change-TimeoutSec-0-to-TimeoutSec-infinity.patch new file mode 100644 index 0000000..6439628 --- /dev/null +++ b/SOURCES/0329-units-change-TimeoutSec-0-to-TimeoutSec-infinity.patch @@ -0,0 +1,98 @@ +From 169bb520f7032ea699d3cdf46121d2819f562b51 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 6 Jun 2023 09:29:51 +0200 +Subject: [PATCH] units: change TimeoutSec=0 to TimeoutSec=infinity + +Follow-up for #27936 + +Let's also update a bunch of static unit files, matching what we just +did for the generators. + +(cherry picked from commit 1775872679f1ace1771a14294306aa6782b5b263) + +Related: #2190226 +--- + test/units/autorelabel.service | 2 +- + units/rc-local.service.in | 2 +- + units/systemd-fsck-root.service.in | 2 +- + units/systemd-fsck@.service.in | 2 +- + units/systemd-growfs-root.service.in | 2 +- + units/systemd-growfs@.service.in | 2 +- + units/systemd-quotacheck.service.in | 2 +- + 7 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/test/units/autorelabel.service b/test/units/autorelabel.service +index 1da1002cde..224981f76a 100644 +--- a/test/units/autorelabel.service ++++ b/test/units/autorelabel.service +@@ -12,7 +12,7 @@ ConditionPathExists=|/.autorelabel + [Service] + ExecStart=sh -x -c 'echo 0 >/sys/fs/selinux/enforce && fixfiles -f -F relabel && rm /.autorelabel && systemctl --force reboot' + Type=oneshot +-TimeoutSec=0 ++TimeoutSec=infinity + RemainAfterExit=yes + + [Install] +diff --git a/units/rc-local.service.in b/units/rc-local.service.in +index 0eee722154..40ffc15c99 100644 +--- a/units/rc-local.service.in ++++ b/units/rc-local.service.in +@@ -19,6 +19,6 @@ Wants=network-online.target + [Service] + Type=forking + ExecStart={{RC_LOCAL_PATH}} start +-TimeoutSec=0 ++TimeoutSec=infinity + RemainAfterExit=yes + GuessMainPID=no +diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in +index 8378df84c7..8cfbe7ce98 100644 +--- a/units/systemd-fsck-root.service.in ++++ b/units/systemd-fsck-root.service.in +@@ -21,4 +21,4 @@ OnFailureJobMode=replace-irreversibly + Type=oneshot + RemainAfterExit=yes + ExecStart={{ROOTLIBEXECDIR}}/systemd-fsck +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/units/systemd-fsck@.service.in b/units/systemd-fsck@.service.in +index 06b91aea39..d773229812 100644 +--- a/units/systemd-fsck@.service.in ++++ b/units/systemd-fsck@.service.in +@@ -20,4 +20,4 @@ Before=systemd-quotacheck.service shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart={{ROOTLIBEXECDIR}}/systemd-fsck %f +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/units/systemd-growfs-root.service.in b/units/systemd-growfs-root.service.in +index 295bafd5af..1bbd26e0d7 100644 +--- a/units/systemd-growfs-root.service.in ++++ b/units/systemd-growfs-root.service.in +@@ -19,4 +19,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart={{ROOTLIBEXECDIR}}/systemd-growfs / +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/units/systemd-growfs@.service.in b/units/systemd-growfs@.service.in +index 7154e4ca76..ff10a3f54e 100644 +--- a/units/systemd-growfs@.service.in ++++ b/units/systemd-growfs@.service.in +@@ -20,4 +20,4 @@ Before=shutdown.target + Type=oneshot + RemainAfterExit=yes + ExecStart={{ROOTLIBEXECDIR}}/systemd-growfs %f +-TimeoutSec=0 ++TimeoutSec=infinity +diff --git a/units/systemd-quotacheck.service.in b/units/systemd-quotacheck.service.in +index c3e936d220..8e9e9d0691 100644 +--- a/units/systemd-quotacheck.service.in ++++ b/units/systemd-quotacheck.service.in +@@ -19,4 +19,4 @@ ConditionPathExists={{QUOTACHECK}} + Type=oneshot + RemainAfterExit=yes + ExecStart={{ROOTLIBEXECDIR}}/systemd-quotacheck +-TimeoutSec=0 ++TimeoutSec=infinity diff --git a/SOURCES/0330-fstab-generator-use-correct-swap-name-var.patch b/SOURCES/0330-fstab-generator-use-correct-swap-name-var.patch new file mode 100644 index 0000000..810bb6a --- /dev/null +++ b/SOURCES/0330-fstab-generator-use-correct-swap-name-var.patch @@ -0,0 +1,27 @@ +From 34694c7d927e1ac9ff92db95136ebc0a7859e5d5 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Fri, 26 May 2023 14:05:40 +0200 +Subject: [PATCH] fstab-generator: use correct swap name var + +Follow-up to 9445623363. + +(cherry picked from commit 3aed25932891d447b5a7ceec6ab61813c06fb0ec) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 910e29d26b..b92fb40f9b 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -811,7 +811,7 @@ static int parse_fstab_one( + + is_swap = streq_ptr(fstype, "swap"); + if (is_swap && use_swap_enabled && !arg_swap_enabled) { +- log_info("Swap unit generation disabled on kernel command line, ignoring swap entry for %s.", what); ++ log_info("Swap unit generation disabled on kernel command line, ignoring swap entry for %s.", what_original); + return 0; + } + diff --git a/SOURCES/0331-fstab-generator-add-more-parameter-name-comments.patch b/SOURCES/0331-fstab-generator-add-more-parameter-name-comments.patch new file mode 100644 index 0000000..6e95564 --- /dev/null +++ b/SOURCES/0331-fstab-generator-add-more-parameter-name-comments.patch @@ -0,0 +1,41 @@ +From 25d1a4f55fec8713995eadd8f1830365f872a201 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 23 Jun 2023 22:49:55 +0200 +Subject: [PATCH] fstab-generator: add more parameter name comments + +(cherry picked from commit 3a065dfc29aa061906ab9dd886093581410b666a) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index b92fb40f9b..e403a4c096 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -1425,7 +1425,7 @@ static int run_generator(void) { + (void) determine_usr(); + + if (arg_sysroot_check) { +- r = parse_fstab(true); ++ r = parse_fstab(/* initrd= */ true); + if (r == 0) + log_debug("Nothing interesting found, not doing daemon-reload."); + if (r > 0) +@@ -1455,13 +1455,13 @@ static int run_generator(void) { + /* Honour /etc/fstab only when that's enabled */ + if (arg_fstab_enabled) { + /* Parse the local /etc/fstab, possibly from the initrd */ +- r = parse_fstab(false); ++ r = parse_fstab(/* initrd= */ false); + if (r < 0 && ret >= 0) + ret = r; + + /* If running in the initrd also parse the /etc/fstab from the host */ + if (in_initrd()) +- r = parse_fstab(true); ++ r = parse_fstab(/* initrd= */ true); + else + r = generator_enable_remount_fs_service(arg_dest); + if (r < 0 && ret >= 0) diff --git a/SOURCES/0332-fstab-generator-unify-initrd-root-device.target-depe.patch b/SOURCES/0332-fstab-generator-unify-initrd-root-device.target-depe.patch new file mode 100644 index 0000000..18cc831 --- /dev/null +++ b/SOURCES/0332-fstab-generator-unify-initrd-root-device.target-depe.patch @@ -0,0 +1,59 @@ +From 0d6c4277b6841ad69e7aef6fff5c4c2b29357717 Mon Sep 17 00:00:00 2001 +From: Lily Foster +Date: Thu, 6 Jul 2023 16:13:53 -0400 +Subject: [PATCH] fstab-generator: unify initrd-root-device.target dependency + handling code + +This fixes a bug from #26038 where it would actually write generator +stuff during sysroot check when it was only supposed to check for daemon +reload. + +(cherry picked from commit 9cf2203524baad8d7ebd298d46633e900daad821) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 17 ++++++----------- + 1 file changed, 6 insertions(+), 11 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index e403a4c096..6756885478 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -601,6 +601,12 @@ static int add_mount( + if (r < 0) + return r; + ++ if (in_initrd() && path_equal(where, "/sysroot") && is_device_path(what)) { ++ r = generator_write_initrd_root_device_deps(dest, what); ++ if (r < 0) ++ return r; ++ } ++ + r = write_mount_timeout(f, where, opts); + if (r < 0) + return r; +@@ -885,12 +891,6 @@ static int parse_fstab_one( + mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : + SPECIAL_LOCAL_FS_TARGET; + +- if (is_sysroot && is_device_path(what)) { +- r = generator_write_initrd_root_device_deps(arg_dest, what); +- if (r < 0) +- return r; +- } +- + r = add_mount(source, + arg_dest, + what, +@@ -1077,11 +1077,6 @@ static int add_sysroot_mount(void) { + + log_debug("Found entry what=%s where=/sysroot type=%s opts=%s", what, strna(arg_root_fstype), strempty(opts)); + +- if (is_device_path(what)) { +- r = generator_write_initrd_root_device_deps(arg_dest, what); +- if (r < 0) +- return r; +- } + + return add_mount("/proc/cmdline", + arg_dest, diff --git a/SOURCES/0333-fstab-util-add-fstab_is_bind.patch b/SOURCES/0333-fstab-util-add-fstab_is_bind.patch new file mode 100644 index 0000000..c000c70 --- /dev/null +++ b/SOURCES/0333-fstab-util-add-fstab_is_bind.patch @@ -0,0 +1,72 @@ +From fd613a23cb8763da1ac47fcd1d7faacc8fd550d2 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 13 Jul 2023 23:13:10 +0800 +Subject: [PATCH] fstab-util: add fstab_is_bind + +(cherry picked from commit 35df78cd88e784abafd5df4545feeb3dd98e14a4) + +Related: #2190226 +--- + src/core/mount.c | 9 +-------- + src/shared/fstab-util.c | 13 +++++++++++++ + src/shared/fstab-util.h | 2 ++ + 3 files changed, 16 insertions(+), 8 deletions(-) + +diff --git a/src/core/mount.c b/src/core/mount.c +index ba55f7dd86..a46ac804d8 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -119,14 +119,7 @@ static bool mount_is_loop(const MountParameters *p) { + + static bool mount_is_bind(const MountParameters *p) { + assert(p); +- +- if (fstab_test_option(p->options, "bind\0" "rbind\0")) +- return true; +- +- if (p->fstype && STR_IN_SET(p->fstype, "bind", "rbind")) +- return true; +- +- return false; ++ return fstab_is_bind(p->options, p->fstype); + } + + static bool mount_is_bound_to_device(Mount *m) { +diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c +index f683f05981..35e0d0d6f7 100644 +--- a/src/shared/fstab-util.c ++++ b/src/shared/fstab-util.c +@@ -19,6 +19,8 @@ int fstab_has_fstype(const char *fstype) { + _cleanup_endmntent_ FILE *f = NULL; + struct mntent *m; + ++ assert(fstype); ++ + f = setmntent(fstab_path(), "re"); + if (!f) + return errno == ENOENT ? false : -errno; +@@ -286,3 +288,14 @@ char *fstab_node_to_udev_node(const char *p) { + + return strdup(p); + } ++ ++bool fstab_is_bind(const char *options, const char *fstype) { ++ ++ if (fstab_test_option(options, "bind\0" "rbind\0")) ++ return true; ++ ++ if (fstype && STR_IN_SET(fstype, "bind", "rbind")) ++ return true; ++ ++ return false; ++} +diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h +index 6b596baafa..5979b476b6 100644 +--- a/src/shared/fstab-util.h ++++ b/src/shared/fstab-util.h +@@ -40,3 +40,5 @@ char *fstab_node_to_udev_node(const char *p); + static inline const char* fstab_path(void) { + return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab"; + } ++ ++bool fstab_is_bind(const char *options, const char *fstype); diff --git a/SOURCES/0334-fstab-generator-resolve-bind-mount-source-when-in-in.patch b/SOURCES/0334-fstab-generator-resolve-bind-mount-source-when-in-in.patch new file mode 100644 index 0000000..9e53ff2 --- /dev/null +++ b/SOURCES/0334-fstab-generator-resolve-bind-mount-source-when-in-in.patch @@ -0,0 +1,150 @@ +From e47358d080fb705b4aa89f8506c4bf0e0fce6910 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 13 Jul 2023 22:44:19 +0800 +Subject: [PATCH] fstab-generator: resolve bind mount source when in initrd + +We currently prepend /sysroot to mount points for entries +in /sysroot/etc/fstab. But when it comes to bind mounts, +the source needs to canonicalized too. + +Fixes #6827 +Replaces #7894 + +(cherry picked from commit b5fd3956ecaff8ef5f0b1826076965cab5fce604) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 79 ++++++++++++++++++--------- + 1 file changed, 53 insertions(+), 26 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 6756885478..4885d6d722 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -793,6 +793,40 @@ static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap) + return flags; + } + ++static int canonicalize_mount_path(const char *path, const char *type, bool initrd, char **ret) { ++ _cleanup_free_ char *p = NULL; ++ bool changed; ++ int r; ++ ++ assert(path); ++ assert(type); ++ assert(STR_IN_SET(type, "where", "what")); ++ assert(ret); ++ ++ // FIXME: when chase() learns to chase non-existent paths, use this here and drop the prefixing with ++ // /sysroot on error below. ++ r = chase_symlinks(path, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL); ++ if (r < 0) { ++ log_debug_errno(r, "Failed to chase '%s', using as-is: %m", path); ++ ++ if (initrd) ++ p = path_join("/sysroot", path); ++ else ++ p = strdup(path); ++ if (!p) ++ return log_oom(); ++ ++ path_simplify(p); ++ } ++ ++ changed = !streq(path, p); ++ if (changed) ++ log_debug("Canonicalized %s=%s to %s", type, path, p); ++ ++ *ret = TAKE_PTR(p); ++ return changed; ++} ++ + static int parse_fstab_one( + const char *source, + const char *what_original, +@@ -805,7 +839,7 @@ static int parse_fstab_one( + + _cleanup_free_ char *what = NULL, *where = NULL; + MountPointFlags flags; +- bool is_swap; ++ bool is_swap, where_changed; + int r; + + assert(what_original); +@@ -840,7 +874,7 @@ static int parse_fstab_one( + assert(where_original); /* 'where' is not necessary for swap entry. */ + + if (!is_path(where_original)) { +- log_warning("Mount point %s is not a valid path, ignoring.", where); ++ log_warning("Mount point %s is not a valid path, ignoring.", where_original); + return 0; + } + +@@ -848,41 +882,34 @@ static int parse_fstab_one( + * mount units, but causes problems since it historically worked to have symlinks in e.g. + * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case + * where a symlink refers to another mount target; this works assuming the sub-mountpoint +- * target is the final directory. +- * +- * FIXME: when chase() learns to chase non-existent paths, use this here and +- * drop the prefixing with /sysroot on error below. +- */ +- r = chase_symlinks(where_original, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &where, NULL); +- if (r < 0) { +- /* If we can't canonicalize, continue as if it wasn't a symlink */ +- log_debug_errno(r, "Failed to read symlink target for %s, using as-is: %m", where_original); ++ * target is the final directory. */ ++ r = canonicalize_mount_path(where_original, "where", initrd, &where); ++ if (r < 0) ++ return r; ++ where_changed = r > 0; + +- if (initrd) +- where = path_join("/sysroot", where_original); +- else +- where = strdup(where_original); +- if (!where) +- return log_oom(); ++ if (initrd && fstab_is_bind(options, fstype)) { ++ /* When in initrd, the source of bind mount needs to be prepended with /sysroot as well. */ ++ _cleanup_free_ char *p = NULL; ++ ++ r = canonicalize_mount_path(what, "what", initrd, &p); ++ if (r < 0) ++ return r; + +- path_simplify(where); ++ free_and_replace(what, p); + } + +- if (streq(where, where_original)) /* If it was fully canonicalized, suppress the change */ +- where = mfree(where); +- else +- log_debug("Canonicalized what=%s where=%s to %s", what, where_original, where); + + log_debug("Found entry what=%s where=%s type=%s makefs=%s growfs=%s noauto=%s nofail=%s", + what, where, strna(fstype), + yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), + yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL)); + +- bool is_sysroot = in_initrd() && path_equal(where ?: where_original, "/sysroot"); ++ bool is_sysroot = in_initrd() && path_equal(where, "/sysroot"); + /* See comment from add_sysroot_usr_mount() about the need for extra indirection in case /usr needs + * to be mounted in order for the root fs to be synthesized based on configuration included in /usr/, + * e.g. systemd-repart. */ +- bool is_sysroot_usr = in_initrd() && path_equal(where ?: where_original, "/sysroot/usr"); ++ bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); + + const char *target_unit = + initrd ? SPECIAL_INITRD_FS_TARGET : +@@ -894,8 +921,8 @@ static int parse_fstab_one( + r = add_mount(source, + arg_dest, + what, +- is_sysroot_usr ? "/sysusr/usr" : where ?: where_original, +- !is_sysroot_usr && where ? where_original : NULL, ++ is_sysroot_usr ? "/sysusr/usr" : where, ++ !is_sysroot_usr && where_changed ? where_original : NULL, + fstype, + options, + passno, diff --git a/SOURCES/0335-fstab-generator-rename-initrd-flag-to-prefix_sysroot.patch b/SOURCES/0335-fstab-generator-rename-initrd-flag-to-prefix_sysroot.patch new file mode 100644 index 0000000..f33a746 --- /dev/null +++ b/SOURCES/0335-fstab-generator-rename-initrd-flag-to-prefix_sysroot.patch @@ -0,0 +1,147 @@ +From a6a19f42916248badbc087d75c28e9c96a8ddb28 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 03:17:01 +0900 +Subject: [PATCH] fstab-generator: rename 'initrd' flag to 'prefix_sysroot' + +The name 'initrd' is confusing with 'in_initrd()'. + +(cherry picked from commit 8f88e57397bc6d4f897c4547770e67abd849498d) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 32 +++++++++++++-------------- + 1 file changed, 16 insertions(+), 16 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 4885d6d722..07f5ae5b73 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -793,7 +793,7 @@ static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap) + return flags; + } + +-static int canonicalize_mount_path(const char *path, const char *type, bool initrd, char **ret) { ++static int canonicalize_mount_path(const char *path, const char *type, bool prefix_sysroot, char **ret) { + _cleanup_free_ char *p = NULL; + bool changed; + int r; +@@ -805,11 +805,11 @@ static int canonicalize_mount_path(const char *path, const char *type, bool init + + // FIXME: when chase() learns to chase non-existent paths, use this here and drop the prefixing with + // /sysroot on error below. +- r = chase_symlinks(path, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL); ++ r = chase_symlinks(path, prefix_sysroot ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL); + if (r < 0) { + log_debug_errno(r, "Failed to chase '%s', using as-is: %m", path); + +- if (initrd) ++ if (prefix_sysroot) + p = path_join("/sysroot", path); + else + p = strdup(path); +@@ -834,7 +834,7 @@ static int parse_fstab_one( + const char *fstype, + const char *options, + int passno, +- bool initrd, ++ bool prefix_sysroot, + bool use_swap_enabled) { + + _cleanup_free_ char *what = NULL, *where = NULL; +@@ -846,7 +846,7 @@ static int parse_fstab_one( + assert(fstype); + assert(options); + +- if (initrd && !mount_in_initrd(where_original, options)) ++ if (prefix_sysroot && !mount_in_initrd(where_original, options)) + return 0; + + is_swap = streq_ptr(fstype, "swap"); +@@ -883,16 +883,16 @@ static int parse_fstab_one( + * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case + * where a symlink refers to another mount target; this works assuming the sub-mountpoint + * target is the final directory. */ +- r = canonicalize_mount_path(where_original, "where", initrd, &where); ++ r = canonicalize_mount_path(where_original, "where", prefix_sysroot, &where); + if (r < 0) + return r; + where_changed = r > 0; + +- if (initrd && fstab_is_bind(options, fstype)) { ++ if (prefix_sysroot && fstab_is_bind(options, fstype)) { + /* When in initrd, the source of bind mount needs to be prepended with /sysroot as well. */ + _cleanup_free_ char *p = NULL; + +- r = canonicalize_mount_path(what, "what", initrd, &p); ++ r = canonicalize_mount_path(what, "what", prefix_sysroot, &p); + if (r < 0) + return r; + +@@ -912,7 +912,7 @@ static int parse_fstab_one( + bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); + + const char *target_unit = +- initrd ? SPECIAL_INITRD_FS_TARGET : ++ prefix_sysroot ? SPECIAL_INITRD_FS_TARGET : + is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : + is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : + mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : +@@ -941,13 +941,13 @@ static int parse_fstab_one( + return true; + } + +-static int parse_fstab(bool initrd) { ++static int parse_fstab(bool prefix_sysroot) { + _cleanup_endmntent_ FILE *f = NULL; + const char *fstab; + struct mntent *me; + int r, ret = 0; + +- if (initrd) ++ if (prefix_sysroot) + fstab = sysroot_fstab_path(); + else { + fstab = fstab_path(); +@@ -967,7 +967,7 @@ static int parse_fstab(bool initrd) { + while ((me = getmntent(f))) { + r = parse_fstab_one(fstab, + me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, +- initrd, /* use_swap_enabled = */ true); ++ prefix_sysroot, /* use_swap_enabled = */ true); + if (r < 0 && ret >= 0) + ret = r; + if (arg_sysroot_check && r > 0) +@@ -1274,7 +1274,7 @@ static int add_mounts_from_cmdline(void) { + m->fstype, + m->options, + /* passno = */ 0, +- /* initrd = */ false, ++ /* prefix_sysroot = */ false, + /* use_swap_enabled = */ false); + if (r < 0 && ret >= 0) + ret = r; +@@ -1447,7 +1447,7 @@ static int run_generator(void) { + (void) determine_usr(); + + if (arg_sysroot_check) { +- r = parse_fstab(/* initrd= */ true); ++ r = parse_fstab(/* prefix_sysroot = */ true); + if (r == 0) + log_debug("Nothing interesting found, not doing daemon-reload."); + if (r > 0) +@@ -1477,13 +1477,13 @@ static int run_generator(void) { + /* Honour /etc/fstab only when that's enabled */ + if (arg_fstab_enabled) { + /* Parse the local /etc/fstab, possibly from the initrd */ +- r = parse_fstab(/* initrd= */ false); ++ r = parse_fstab(/* prefix_sysroot = */ false); + if (r < 0 && ret >= 0) + ret = r; + + /* If running in the initrd also parse the /etc/fstab from the host */ + if (in_initrd()) +- r = parse_fstab(/* initrd= */ true); ++ r = parse_fstab(/* prefix_sysroot = */ true); + else + r = generator_enable_remount_fs_service(arg_dest); + if (r < 0 && ret >= 0) diff --git a/SOURCES/0336-fstab-generator-fix-target-of-sysroot-usr.patch b/SOURCES/0336-fstab-generator-fix-target-of-sysroot-usr.patch new file mode 100644 index 0000000..6a5c2d4 --- /dev/null +++ b/SOURCES/0336-fstab-generator-fix-target-of-sysroot-usr.patch @@ -0,0 +1,31 @@ +From 8ad2a47f14cd674644d1a4893ec7996c6bcb9be4 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 09:31:54 +0900 +Subject: [PATCH] fstab-generator: fix target of /sysroot/usr + +If /usr mount is picked from the main system's fstab file (prefix_sysroot +is true, and the path is prefixed as /sysroot/usr), then previously it +was installed in the wrong target unit. + +(cherry picked from commit b93d9e06fc6abbd496ec3fb150a4e01c3b7ec72b) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 07f5ae5b73..a7c34cfdf7 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -912,9 +912,9 @@ static int parse_fstab_one( + bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); + + const char *target_unit = +- prefix_sysroot ? SPECIAL_INITRD_FS_TARGET : + is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : + is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : ++ prefix_sysroot ? SPECIAL_INITRD_FS_TARGET : + mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : + SPECIAL_LOCAL_FS_TARGET; + diff --git a/SOURCES/0337-fstab-generator-add-rd.systemd.mount-extra-and-frien.patch b/SOURCES/0337-fstab-generator-add-rd.systemd.mount-extra-and-frien.patch new file mode 100644 index 0000000..4db0e73 --- /dev/null +++ b/SOURCES/0337-fstab-generator-add-rd.systemd.mount-extra-and-frien.patch @@ -0,0 +1,201 @@ +From a1b1037640e6b01116ad637bbc7abe8612d6e0f4 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 04:17:27 +0900 +Subject: [PATCH] fstab-generator: add rd.systemd.mount-extra= and friends + +Previously, mounts specified in systemd.mount-extra= are equally handled +both in initrd and the main system. So, the mounts for the main system +are also mounted in initrd. + +This introduces rd.systemd.mount-extra=, which specifies mounts in initrd. +Then, mounts specified in systemd.mount-extra= are still mounted both in +initrd and the main system, but prefixed with /sysroot/ when running in +initrd. + +Fixes #28516. + +(cherry picked from commit 45c535ddb009d89f2740bdf3a5c88594962759fb) + +Related: #2190226 +--- + man/systemd-fstab-generator.xml | 11 +++++-- + src/fstab-generator/fstab-generator.c | 31 +++++++++++++------ + .../test-19-mounts-from-cmdline.input | 10 +++--- + .../test-20-swap-from-cmdline.input | 8 ++--- + 4 files changed, 39 insertions(+), 21 deletions(-) + +diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml +index b29022fab7..66289d6be3 100644 +--- a/man/systemd-fstab-generator.xml ++++ b/man/systemd-fstab-generator.xml +@@ -242,11 +242,15 @@ + + + systemd.mount-extra=WHAT:WHERE[:FSTYPE[:OPTIONS]] ++ rd.systemd.mount-extra=WHAT:WHERE[:FSTYPE[:OPTIONS]] + + + Specifies the mount unit. Takes at least two and at most four fields separated with a colon + (:). Each field is handled as the corresponding fstab field. This option can be +- specified multiple times. ++ specified multiple times. rd.systemd.mount-extra= is honored only in the initrd, ++ while systemd.mount-extra= is honored by both the main system and the initrd. ++ In the initrd, the mount point (and also source path if the mount is bind mount) specified in ++ systemd.mount-extra= is prefixed with /sysroot/. + Example: + + systemd.mount-extra=/dev/sda1:/mount-point:ext4:rw,noatime +@@ -256,10 +260,13 @@ systemd.mount-extra=/dev/sda1:/mount-point:ext4:rw,noatime + + + systemd.swap-extra=WHAT[:OPTIONS] ++ rd.systemd.swap-extra=WHAT[:OPTIONS] + + + Specifies the swap unit. Takes the block device to be used as a swap device, and optionally +- takes mount options followed by a colon (:). ++ takes mount options followed by a colon (:). This option can be specified ++ multiple times. rd.systemd.swap-extra= is honored only in the initrd, while ++ systemd.swap-extra= is honored by both the main system and the initrd. + Example: + + systemd.swap=/dev/sda2:x-systemd.makefs +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index a7c34cfdf7..f91a863a1d 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -45,6 +45,7 @@ typedef enum MountPointFlags { + } MountPointFlags; + + typedef struct Mount { ++ bool for_initrd; + char *what; + char *where; + char *fstype; +@@ -97,7 +98,13 @@ static void mount_array_free(Mount *mounts, size_t n) { + free(mounts); + } + +-static int mount_array_add_internal(char *in_what, char *in_where, const char *in_fstype, const char *in_options) { ++static int mount_array_add_internal( ++ bool for_initrd, ++ char *in_what, ++ char *in_where, ++ const char *in_fstype, ++ const char *in_options) { ++ + _cleanup_free_ char *what = NULL, *where = NULL, *fstype = NULL, *options = NULL; + int r; + +@@ -130,6 +137,7 @@ static int mount_array_add_internal(char *in_what, char *in_where, const char *i + return -ENOMEM; + + arg_mounts[arg_n_mounts++] = (Mount) { ++ .for_initrd = for_initrd, + .what = TAKE_PTR(what), + .where = TAKE_PTR(where), + .fstype = TAKE_PTR(fstype), +@@ -139,7 +147,7 @@ static int mount_array_add_internal(char *in_what, char *in_where, const char *i + return 0; + } + +-static int mount_array_add(const char *str) { ++static int mount_array_add(bool for_initrd, const char *str) { + _cleanup_free_ char *what = NULL, *where = NULL, *fstype = NULL, *options = NULL; + int r; + +@@ -154,10 +162,10 @@ static int mount_array_add(const char *str) { + if (!isempty(str)) + return -EINVAL; + +- return mount_array_add_internal(TAKE_PTR(what), TAKE_PTR(where), fstype, options); ++ return mount_array_add_internal(for_initrd, TAKE_PTR(what), TAKE_PTR(where), fstype, options); + } + +-static int mount_array_add_swap(const char *str) { ++static int mount_array_add_swap(bool for_initrd, const char *str) { + _cleanup_free_ char *what = NULL, *options = NULL; + int r; + +@@ -172,7 +180,7 @@ static int mount_array_add_swap(const char *str) { + if (!isempty(str)) + return -EINVAL; + +- return mount_array_add_internal(TAKE_PTR(what), NULL, "swap", options); ++ return mount_array_add_internal(for_initrd, TAKE_PTR(what), NULL, "swap", options); + } + + static int write_options(FILE *f, const char *options) { +@@ -1267,6 +1275,9 @@ static int add_mounts_from_cmdline(void) { + /* Handle each entries found in cmdline as a fstab entry. */ + + FOREACH_ARRAY(m, arg_mounts, arg_n_mounts) { ++ if (m->for_initrd && !in_initrd()) ++ continue; ++ + r = parse_fstab_one( + "/proc/cmdline", + m->what, +@@ -1274,7 +1285,7 @@ static int add_mounts_from_cmdline(void) { + m->fstype, + m->options, + /* passno = */ 0, +- /* prefix_sysroot = */ false, ++ /* prefix_sysroot = */ !m->for_initrd && in_initrd(), + /* use_swap_enabled = */ false); + if (r < 0 && ret >= 0) + ret = r; +@@ -1380,21 +1391,21 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat + else + arg_swap_enabled = r; + +- } else if (streq(key, "systemd.mount-extra")) { ++ } else if (STR_IN_SET(key, "systemd.mount-extra", "rd.systemd.mount-extra")) { + + if (proc_cmdline_value_missing(key, value)) + return 0; + +- r = mount_array_add(value); ++ r = mount_array_add(startswith(key, "rd."), value); + if (r < 0) + log_warning("Failed to parse systemd.mount-extra= option, ignoring: %s", value); + +- } else if (streq(key, "systemd.swap-extra")) { ++ } else if (STR_IN_SET(key, "systemd.swap-extra", "rd.systemd.swap-extra")) { + + if (proc_cmdline_value_missing(key, value)) + return 0; + +- r = mount_array_add_swap(value); ++ r = mount_array_add_swap(startswith(key, "rd."), value); + if (r < 0) + log_warning("Failed to parse systemd.swap-extra= option, ignoring: %s", value); + } +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.input b/test/test-fstab-generator/test-19-mounts-from-cmdline.input +index 4312d01e52..f2cc6fc075 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.input ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.input +@@ -1,5 +1,5 @@ +-systemd.mount-extra=/dev/sdx1:/sysroot:auto:defaults +-systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto +-systemd.mount-extra=/dev/sdx3:/hoge/without_fstype +-systemd.mount-extra=/dev/sdx4 +-systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel ++rd.systemd.mount-extra=/dev/sdx1:/sysroot:auto:defaults ++rd.systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto ++rd.systemd.mount-extra=/dev/sdx3:/hoge/without_fstype ++rd.systemd.mount-extra=/dev/sdx4 ++rd.systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.input b/test/test-fstab-generator/test-20-swap-from-cmdline.input +index 953c09ff10..d92c5300e2 100644 +--- a/test/test-fstab-generator/test-20-swap-from-cmdline.input ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.input +@@ -1,4 +1,4 @@ +-systemd.mount-extra=/dev/sdy1:none:swap +-systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs +-systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail +-systemd.swap-extra=/dev/sdy4 ++rd.systemd.mount-extra=/dev/sdy1:none:swap ++rd.systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs ++rd.systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail ++rd.systemd.swap-extra=/dev/sdy4 diff --git a/SOURCES/0338-fstab-generator-add-a-flag-to-accept-entry-for-in-in.patch b/SOURCES/0338-fstab-generator-add-a-flag-to-accept-entry-for-in-in.patch new file mode 100644 index 0000000..1253ad6 --- /dev/null +++ b/SOURCES/0338-fstab-generator-add-a-flag-to-accept-entry-for-in-in.patch @@ -0,0 +1,79 @@ +From c22461b748ca92c3d2bdb799f0b7cd26ce72b03c Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 09:39:23 +0900 +Subject: [PATCH] fstab-generator: add a flag to accept entry for "/" in initrd + +When both prefix_sysroot and accept_root is true, the entry for "/" will +be accepted and converted to "/sysroot/". + +Why? If the entry is read from the main system's fstab, then we already +mounted /sysroot/, hence it is not and should not re-add the .mount unit +for /sysroot/. However, if we want to specify the root mount through the +kernel command line or credential, without this change, we need to +specify the same entry in the two options. E.g. +=== +systemd.mount-extra=/dev/sda1:/:auto:defaults +rd.systemd.mount-extra=/dev/sda1:/sysroot:auto:defaults +=== +That's inconvenient. Of course, we can dedup that by using traditional +options, but cannot when defined in credential. + +(cherry picked from commit 22f5a825e40ad9c8eeae18b763676759d24bb434) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index f91a863a1d..cf3ff4f598 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -307,9 +307,9 @@ static bool mount_is_network(const char *fstype, const char *options) { + (fstype && fstype_is_network(fstype)); + } + +-static bool mount_in_initrd(const char *where, const char *options) { ++static bool mount_in_initrd(const char *where, const char *options, bool accept_root) { + return fstab_test_option(options, "x-initrd.mount\0") || +- (where && path_equal(where, "/usr")); ++ (where && PATH_IN_SET(where, "/usr", accept_root ? "/" : NULL)); + } + + static int write_timeout( +@@ -843,6 +843,7 @@ static int parse_fstab_one( + const char *options, + int passno, + bool prefix_sysroot, ++ bool accept_root, /* This takes an effect only when prefix_sysroot is true. */ + bool use_swap_enabled) { + + _cleanup_free_ char *what = NULL, *where = NULL; +@@ -854,7 +855,7 @@ static int parse_fstab_one( + assert(fstype); + assert(options); + +- if (prefix_sysroot && !mount_in_initrd(where_original, options)) ++ if (prefix_sysroot && !mount_in_initrd(where_original, options, accept_root)) + return 0; + + is_swap = streq_ptr(fstype, "swap"); +@@ -975,7 +976,9 @@ static int parse_fstab(bool prefix_sysroot) { + while ((me = getmntent(f))) { + r = parse_fstab_one(fstab, + me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, +- prefix_sysroot, /* use_swap_enabled = */ true); ++ prefix_sysroot, ++ /* accept_root = */ false, ++ /* use_swap_enabled = */ true); + if (r < 0 && ret >= 0) + ret = r; + if (arg_sysroot_check && r > 0) +@@ -1286,6 +1289,7 @@ static int add_mounts_from_cmdline(void) { + m->options, + /* passno = */ 0, + /* prefix_sysroot = */ !m->for_initrd && in_initrd(), ++ /* accept_root = */ true, + /* use_swap_enabled = */ false); + if (r < 0 && ret >= 0) + ret = r; diff --git a/SOURCES/0339-test-fstab-generator-extract-core-part-as-a-function.patch b/SOURCES/0339-test-fstab-generator-extract-core-part-as-a-function.patch new file mode 100644 index 0000000..017e77f --- /dev/null +++ b/SOURCES/0339-test-fstab-generator-extract-core-part-as-a-function.patch @@ -0,0 +1,223 @@ +From 6933334a0d98b65f502abea4183f74275f11a50c Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 06:30:37 +0900 +Subject: [PATCH] test-fstab-generator: extract core part as a function + +No functional change, preparation for later commits. + +(cherry picked from commit 7f8c67c9965a5f70a6c1592db4f5339f4851a5de) + +Related: #2190226 +--- + test/test-fstab-generator.sh | 184 ++++++++++++++++++----------------- + 1 file changed, 96 insertions(+), 88 deletions(-) + +diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh +index 68c9d0631e..d5844b8c3f 100755 +--- a/test/test-fstab-generator.sh ++++ b/test/test-fstab-generator.sh +@@ -1,10 +1,10 @@ + #!/usr/bin/env bash + # SPDX-License-Identifier: LGPL-2.1-or-later +-set -e ++set -eux + shopt -s nullglob + shopt -s globstar + +-if [[ -n "$1" ]]; then ++if [[ -n "${1:-}" ]]; then + generator=$1 + elif [[ -x /usr/lib/systemd/system-generators/systemd-fstab-generator ]]; then + generator=/usr/lib/systemd/system-generators/systemd-fstab-generator +@@ -19,97 +19,105 @@ src="$(dirname "$0")/testdata/test-fstab-generator" + # fsck(8) is located in /usr/sbin on Debian + PATH=$PATH:/usr/sbin + +-for f in "$src"/test-*.input; do +- echo "*** Running $f" +- +- ( +- out=$(mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX") +- # shellcheck disable=SC2064 +- trap "rm -rf '$out'" EXIT INT QUIT PIPE +- +- exp="${f%.input}.expected" +- if [[ "${f##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then +- exp="${exp}.container" +- fi +- +- if [[ "${f##*/}" =~ \.fstab\.input ]]; then +- SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$f" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" +- else +- SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" +- fi +- +- # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. +- # The system that the test is currently running on may not have or may have outdated unit file. +- # Let's replace the symlink with an empty file. +- for i in "$out"/*/systemd-growfs@*.service; do +- [[ -L "$i" ]] || continue +- rm "$i" +- touch "$i" ++test_one() ( ++ local input out exp i j k dir fname expf ++ ++ input=${1?} ++ ++ : "*** Running $input" ++ ++ out=$(mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX") ++ # shellcheck disable=SC2064 ++ trap "rm -rf '$out'" EXIT INT QUIT PIPE ++ ++ exp="${input%.input}.expected" ++ if [[ "${input##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then ++ exp="${exp}.container" ++ fi ++ ++ if [[ "${input##*/}" =~ \.fstab\.input ]]; then ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$input" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" ++ else ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$input")" $generator "$out" "$out" "$out" ++ fi ++ ++ # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. ++ # The system that the test is currently running on may not have or may have outdated unit file. ++ # Let's replace the symlink with an empty file. ++ for i in "$out"/*/systemd-growfs@*.service; do ++ [[ -L "$i" ]] || continue ++ rm "$i" ++ touch "$i" ++ done ++ ++ # For split-usr system ++ for i in "$out"/systemd-*.service; do ++ sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" ++ done ++ ++ if [[ "${input##*/}" =~ \.fstab\.input ]]; then ++ for i in "$out"/*.{automount,mount,swap}; do ++ sed -i -e 's:SourcePath=.*$:SourcePath=/etc/fstab:' "$i" + done +- +- # For split-usr system +- for i in "$out"/systemd-*.service; do +- sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" +- done +- +- if [[ "${f##*/}" =~ \.fstab\.input ]]; then +- for i in "$out"/*.{automount,mount,swap}; do +- sed -i -e 's:SourcePath=.*$:SourcePath=/etc/fstab:' "$i" +- done ++ fi ++ ++ # .deb packager seems to dislike files named with backslash. So, as a workaround, we store files ++ # without backslash in .expected. ++ for i in "$out"/**/*\\*.{mount,swap}; do ++ k="${i//\\/}" ++ if [[ "$i" != "$k" ]]; then ++ if [[ -f "$i" ]]; then ++ mv "$i" "$k" ++ elif [[ -L "$i" ]]; then ++ dest=$(readlink "$i") ++ rm "$i" ++ ln -s "${dest//\\/}" "$k" ++ fi + fi +- +- # .deb packager seems to dislike files named with backslash. So, as a workaround, we store files +- # without backslash in .expected. +- for i in "$out"/**/*\\*.{mount,swap}; do +- k="${i//\\/}" +- if [[ "$i" != "$k" ]]; then +- if [[ -f "$i" ]]; then +- mv "$i" "$k" +- elif [[ -L "$i" ]]; then +- dest=$(readlink "$i") +- rm "$i" +- ln -s "${dest//\\/}" "$k" ++ done ++ ++ # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare ++ # the list of filenames rather than their content ++ if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then ++ : "**** Unexpected output for $input" ++ return 1 ++ fi ++ ++ # Check the main units. ++ if ! diff -u "$out" "$exp"; then ++ : "**** Unexpected output for $input" ++ return 1 ++ fi ++ ++ # Also check drop-ins. ++ for i in "$out"/*; do ++ [[ -d "$i" ]] || continue ++ ++ dir="${i##*/}" ++ ++ for j in "$i"/*; do ++ fname="${j##*/}" ++ expf="$exp/$dir/$fname" ++ ++ if [[ -L "$j" && ! -e "$j" ]]; then ++ # For dead symlink, we store an empty file. ++ if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then ++ : "**** Unexpected symlink $j created by $input" ++ return 1 + fi ++ continue + fi +- done + +- # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare +- # the list of filenames rather than their content +- if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then +- echo "**** Unexpected output for $f" +- exit 1 +- fi +- +- # Check the main units. +- if ! diff -u "$out" "$exp"; then +- echo "**** Unexpected output for $f" +- exit 1 +- fi +- +- # Also check drop-ins. +- for i in "$out"/*; do +- [[ -d "$i" ]] || continue +- +- dir="${i##*/}" +- +- for j in "$i"/*; do +- fname="${j##*/}" +- expf="$exp/$dir/$fname" ++ if ! diff -u "$j" "$expf"; then ++ : "**** Unexpected output in $j for $input" ++ return 1 ++ fi ++ done ++ done + +- if [[ -L "$j" && ! -e "$j" ]]; then +- # For dead symlink, we store an empty file. +- if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then +- echo "**** Unexpected symlink $j created by $f" +- exit 1 +- fi +- continue +- fi ++ return 0 ++) + +- if ! diff -u "$j" "$expf"; then +- echo "**** Unexpected output in $j for $f" +- exit 1 +- fi +- done +- done +- ) || exit 1 ++for f in "$src"/test-*.input; do ++ test_one "$f" + done diff --git a/SOURCES/0340-test-fstab-generator-also-test-with-SYSTEMD_IN_INITR.patch b/SOURCES/0340-test-fstab-generator-also-test-with-SYSTEMD_IN_INITR.patch new file mode 100644 index 0000000..7ca3142 --- /dev/null +++ b/SOURCES/0340-test-fstab-generator-also-test-with-SYSTEMD_IN_INITR.patch @@ -0,0 +1,738 @@ +From aa4e0d1737d0a2ed6cf6c7851009d1de3ffe93da Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 07:04:48 +0900 +Subject: [PATCH] test-fstab-generator: also test with SYSTEMD_IN_INITRD=no + +(cherry picked from commit aeded6b0b5a41f80d2f4663d8f023af2888b444d) + +Related: #2190226 +--- + test/test-fstab-generator.sh | 31 +++++++++++++------ + .../sysroot-usr.mount | 1 + + .../local-fs.target.requires/sysroot.mount | 1 + + .../systemd-remount-fs.service | 0 + .../sysroot-usr.mount | 11 +++++++ + .../sysroot.mount | 13 ++++++++ + .../foo.service.requires/mnt-requiredby.mount | 1 + + .../foo.service.wants/mnt-wantedby.mount | 1 + + ...der-systemd-growfs@mnt-growfs.service.conf | 4 +++ + .../local-fs.target.requires/mnt-after.mount | 1 + + .../mnt-automount1.automount | 1 + + .../local-fs.target.requires/mnt-before.mount | 1 + + .../local-fs.target.requires/mnt-growfs.mount | 1 + + .../local-fs.target.requires/mnt-mkfs.mount | 1 + + .../local-fs.target.requires/mnt-pcrfs.mount | 1 + + .../mnt-reqmounts.mount | 1 + + .../mnt-requires.mount | 1 + + .../local-fs.target.requires/mnt-rwonly.mount | 1 + + .../mnt-timeout.mount | 1 + + .../local-fs.target.requires/sysroot.mount | 1 + + .../mnt-automount2.automount | 1 + + .../local-fs.target.wants/mnt-nofail.mount | 1 + + .../systemd-remount-fs.service | 0 + .../mnt-after.mount | 13 ++++++++ + .../mnt-automount1.automount | 9 ++++++ + .../mnt-automount1.mount | 12 +++++++ + .../mnt-automount2.automount | 8 +++++ + .../mnt-automount2.mount | 11 +++++++ + .../mnt-before.mount | 13 ++++++++ + .../mnt-growfs.mount | 12 +++++++ + .../systemd-growfs@mnt-growfs.service | 0 + .../mnt-mkfs.mount | 13 ++++++++ + .../systemd-makefs@dev-sdx12.service | 1 + + .../mnt-noauto.mount | 12 +++++++ + .../mnt-nofail.mount | 11 +++++++ + .../mnt-pcrfs.mount | 12 +++++++ + .../mnt-reqmounts.mount | 13 ++++++++ + .../mnt-requiredby.mount | 12 +++++++ + .../mnt-requires.mount | 14 +++++++++ + .../mnt-rwonly.mount | 13 ++++++++ + .../mnt-timeout.mount | 13 ++++++++ + .../mnt-wantedby.mount | 12 +++++++ + .../sysroot.mount | 13 ++++++++ + .../systemd-makefs@dev-sdx12.service | 18 +++++++++++ + 44 files changed, 301 insertions(+), 10 deletions(-) + create mode 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount + create mode 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount + create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount + create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount + create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service + +diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh +index d5844b8c3f..76097874f4 100755 +--- a/test/test-fstab-generator.sh ++++ b/test/test-fstab-generator.sh +@@ -20,11 +20,12 @@ src="$(dirname "$0")/testdata/test-fstab-generator" + PATH=$PATH:/usr/sbin + + test_one() ( +- local input out exp i j k dir fname expf ++ local initrd input out exp i j k dir fname expf + + input=${1?} ++ initrd=${2?} + +- : "*** Running $input" ++ : "*** Running $input (initrd=$initrd)" + + out=$(mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX") + # shellcheck disable=SC2064 +@@ -34,17 +35,21 @@ test_one() ( + if [[ "${input##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then + exp="${exp}.container" + fi ++ if [[ "$initrd" == no ]]; then ++ exp="${exp}.sysroot" ++ fi + + if [[ "${input##*/}" =~ \.fstab\.input ]]; then +- SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$input" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD="$initrd" SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$input" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" + else +- SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$input")" $generator "$out" "$out" "$out" ++ SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD="$initrd" SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$input")" $generator "$out" "$out" "$out" + fi + + # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. ++ # Also, when $initrd is no, symlink to systemd-remount-fs.service is created. + # The system that the test is currently running on may not have or may have outdated unit file. + # Let's replace the symlink with an empty file. +- for i in "$out"/*/systemd-growfs@*.service; do ++ for i in "$out"/*/systemd-growfs@*.service "$out"/local-fs.target.wants/systemd-remount-fs.service; do + [[ -L "$i" ]] || continue + rm "$i" + touch "$i" +@@ -76,16 +81,21 @@ test_one() ( + fi + done + ++ # We do not store empty directory. ++ if [[ -z "$(ls -A "$out")" && ! -d "$exp" ]]; then ++ return 0 ++ fi ++ + # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare + # the list of filenames rather than their content + if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then +- : "**** Unexpected output for $input" ++ : "**** Unexpected output for $input (initrd=$initrd)" + return 1 + fi + + # Check the main units. + if ! diff -u "$out" "$exp"; then +- : "**** Unexpected output for $input" ++ : "**** Unexpected output for $input (initrd=$initrd)" + return 1 + fi + +@@ -102,14 +112,14 @@ test_one() ( + if [[ -L "$j" && ! -e "$j" ]]; then + # For dead symlink, we store an empty file. + if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then +- : "**** Unexpected symlink $j created by $input" ++ : "**** Unexpected symlink $j created by $input (initrd=$initrd)" + return 1 + fi + continue + fi + + if ! diff -u "$j" "$expf"; then +- : "**** Unexpected output in $j for $input" ++ : "**** Unexpected output in $j for $input (initrd=$initrd)" + return 1 + fi + done +@@ -119,5 +129,6 @@ test_one() ( + ) + + for f in "$src"/test-*.input; do +- test_one "$f" ++ test_one "$f" yes ++ test_one "$f" no + done +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount +new file mode 120000 +index 0000000000..8bcbb16eae +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount +@@ -0,0 +1 @@ ++../sysroot-usr.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount +new file mode 100644 +index 0000000000..effb6fc6d8 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx2.target ++ ++[Mount] ++What=/dev/sdx2 ++Where=/sysroot/usr +diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount +new file mode 100644 +index 0000000000..56cecc05a0 +--- /dev/null ++++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++Requires=systemd-fsck@dev-sdx1.service ++After=systemd-fsck@dev-sdx1.service ++After=blockdev@dev-sdx1.target ++ ++[Mount] ++What=/dev/sdx1 ++Where=/sysroot +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount +new file mode 120000 +index 0000000000..6b012b09ef +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount +@@ -0,0 +1 @@ ++../mnt-requiredby.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount +new file mode 120000 +index 0000000000..cdf21276b6 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount +@@ -0,0 +1 @@ ++../mnt-wantedby.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf +new file mode 100644 +index 0000000000..ac770bcb51 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf +@@ -0,0 +1,4 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++After=systemd-growfs@mnt-growfs.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount +new file mode 120000 +index 0000000000..68364ef19c +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount +@@ -0,0 +1 @@ ++../mnt-after.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount +new file mode 120000 +index 0000000000..3638a8c90e +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount +@@ -0,0 +1 @@ ++../mnt-automount1.automount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount +new file mode 120000 +index 0000000000..3a50a40d5f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount +@@ -0,0 +1 @@ ++../mnt-before.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount +new file mode 120000 +index 0000000000..cb05081e45 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount +@@ -0,0 +1 @@ ++../mnt-growfs.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount +new file mode 120000 +index 0000000000..51f897e419 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount +@@ -0,0 +1 @@ ++../mnt-mkfs.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount +new file mode 120000 +index 0000000000..276dfc0731 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount +@@ -0,0 +1 @@ ++../mnt-pcrfs.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount +new file mode 120000 +index 0000000000..7efce8da9a +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount +@@ -0,0 +1 @@ ++../mnt-reqmounts.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount +new file mode 120000 +index 0000000000..34a6aad26f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount +@@ -0,0 +1 @@ ++../mnt-requires.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount +new file mode 120000 +index 0000000000..d03abd2353 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount +@@ -0,0 +1 @@ ++../mnt-rwonly.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount +new file mode 120000 +index 0000000000..b0ec730825 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount +@@ -0,0 +1 @@ ++../mnt-timeout.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount +new file mode 120000 +index 0000000000..0c969cdbd4 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount +@@ -0,0 +1 @@ ++../sysroot.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount +new file mode 120000 +index 0000000000..a30481ec1f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount +@@ -0,0 +1 @@ ++../mnt-automount2.automount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount +new file mode 120000 +index 0000000000..b82bbad730 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount +@@ -0,0 +1 @@ ++../mnt-nofail.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount +new file mode 100644 +index 0000000000..2aebb686a7 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=foo.service ++Before=local-fs.target ++After=blockdev@dev-sdx3.target ++ ++[Mount] ++What=/dev/sdx3 ++Where=/mnt/after ++Options=x-systemd.after=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount +new file mode 100644 +index 0000000000..e376689b67 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount +@@ -0,0 +1,9 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++SourcePath=/etc/fstab ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++ ++[Automount] ++Where=/mnt/automount1 ++TimeoutIdleSec=30min +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount +new file mode 100644 +index 0000000000..1413292c79 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx9.target ++ ++[Mount] ++What=/dev/sdx9 ++Where=/mnt/automount1 ++Options=x-systemd.automount,x-systemd.idle-timeout=30m +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount +new file mode 100644 +index 0000000000..e05d3976ef +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount +@@ -0,0 +1,8 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++SourcePath=/etc/fstab ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++ ++[Automount] ++Where=/mnt/automount2 +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount +new file mode 100644 +index 0000000000..1eba08c9f7 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=blockdev@dev-sdx10.target ++ ++[Mount] ++What=/dev/sdx10 ++Where=/mnt/automount2 ++Options=x-systemd.automount,nofail +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount +new file mode 100644 +index 0000000000..eea084b7b6 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=foo.service ++Before=local-fs.target ++After=blockdev@dev-sdx4.target ++ ++[Mount] ++What=/dev/sdx4 ++Where=/mnt/before ++Options=x-systemd.before=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount +new file mode 100644 +index 0000000000..bbe958c076 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx13.target ++ ++[Mount] ++What=/dev/sdx13 ++Where=/mnt/growfs ++Options=x-systemd.growfs +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount +new file mode 100644 +index 0000000000..be4c8fa17f +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx12.target ++ ++[Mount] ++What=/dev/sdx12 ++Where=/mnt/mkfs ++Type=ext4 ++Options=x-systemd.makefs +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service +new file mode 120000 +index 0000000000..fe80548a68 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service +@@ -0,0 +1 @@ ++../systemd-makefs@dev-sdx12.service +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount +new file mode 100644 +index 0000000000..4d52a6e698 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx15.target ++ ++[Mount] ++What=/dev/sdx15 ++Where=/mnt/noauto ++Options=noauto +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount +new file mode 100644 +index 0000000000..3c20b652b0 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=blockdev@dev-sdx16.target ++ ++[Mount] ++What=/dev/sdx16 ++Where=/mnt/nofail ++Options=nofail +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount +new file mode 100644 +index 0000000000..2c070e695a +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx14.target ++ ++[Mount] ++What=/dev/sdx14 ++Where=/mnt/pcrfs ++Options=x-systemd.pcrfs +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount +new file mode 100644 +index 0000000000..c21ccd27ba +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++RequiresMountsFor=/hoge ++Before=local-fs.target ++After=blockdev@dev-sdx6.target ++ ++[Mount] ++What=/dev/sdx6 ++Where=/mnt/reqmounts ++Options=x-systemd.requires-mounts-for=/hoge +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount +new file mode 100644 +index 0000000000..5edc4ddf22 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx8.target ++ ++[Mount] ++What=/dev/sdx8 ++Where=/mnt/requiredby ++Options=x-systemd.required-by=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount +new file mode 100644 +index 0000000000..8386616593 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount +@@ -0,0 +1,14 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++After=foo.service ++Requires=foo.service ++Before=local-fs.target ++After=blockdev@dev-sdx5.target ++ ++[Mount] ++What=/dev/sdx5 ++Where=/mnt/requires ++Options=x-systemd.requires=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount +new file mode 100644 +index 0000000000..8649734386 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx11.target ++ ++[Mount] ++What=/dev/sdx11 ++Where=/mnt/rwonly ++Options=x-systemd.rw-only ++ReadWriteOnly=yes +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount +new file mode 100644 +index 0000000000..09d772a52b +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx2.target ++ ++[Mount] ++What=/dev/sdx2 ++Where=/mnt/timeout ++TimeoutSec=10min ++Options=x-systemd.mount-timeout=10m +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount +new file mode 100644 +index 0000000000..e12df820d4 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++After=blockdev@dev-sdx7.target ++ ++[Mount] ++What=/dev/sdx7 ++Where=/mnt/wantedby ++Options=x-systemd.wanted-by=foo.service +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount +new file mode 100644 +index 0000000000..56cecc05a0 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/etc/fstab ++Before=local-fs.target ++Requires=systemd-fsck@dev-sdx1.service ++After=systemd-fsck@dev-sdx1.service ++After=blockdev@dev-sdx1.target ++ ++[Mount] ++What=/dev/sdx1 ++Where=/sysroot +diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service +new file mode 100644 +index 0000000000..4670c23e27 +--- /dev/null ++++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service +@@ -0,0 +1,18 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=Make File System on %f ++Documentation=man:systemd-makefs@.service(8) ++ ++DefaultDependencies=no ++BindsTo=%i.device ++After=%i.device ++Before=systemd-fsck@%i.service mnt-mkfs.mount ++Conflicts=shutdown.target ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-makefs ext4 /dev/sdx12 ++TimeoutSec=infinity diff --git a/SOURCES/0341-test-fstab-generator-add-more-tests-for-systemd.moun.patch b/SOURCES/0341-test-fstab-generator-add-more-tests-for-systemd.moun.patch new file mode 100644 index 0000000..d14a205 --- /dev/null +++ b/SOURCES/0341-test-fstab-generator-add-more-tests-for-systemd.moun.patch @@ -0,0 +1,295 @@ +From 51fc4ab85319890e7af8cdc3ac1314e8d9e00a6e Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 26 Jul 2023 07:37:29 +0900 +Subject: [PATCH] test-fstab-generator: add more tests for systemd.mount-extra= + and friends + +(cherry picked from commit 03de154a1ecea1acef36a469157548b6a55921a5) + +Related: #2190226 +--- + .../foo-also_in_initrd.mount | 12 ++++++++++++ + .../foo-not_in_initrd.mount | 11 +++++++++++ + .../foo-also_in_initrd.mount | 1 + + .../foo-not_in_initrd.mount | 1 + + .../local-fs.target.requires/usr.mount | 1 + + .../usr.mount | 11 +++++++++++ + .../sysroot-foo-also_in_initrd.mount | 1 + + .../initrd-fs.target.requires/sysroot-usr.mount | 1 + + .../initrd-usr-fs.target.requires/sysusr-usr.mount | 1 + + .../sysroot-foo-also_in_initrd.mount | 13 +++++++++++++ + .../sysroot-usr.mount | 11 +++++++++++ + .../sysusr-usr.mount | 11 +++++++++++ + .../test-19-mounts-from-cmdline.input | 3 +++ + .../dev-sdy5.swap | 10 ++++++++++ + .../dev-sdy6.swap | 9 +++++++++ + .../swap.target.requires/dev-sdy5.swap | 1 + + .../swap.target.requires/dev-sdy6.swap | 1 + + .../dev-sdy5.swap | 10 ++++++++++ + .../swap.target.requires/dev-sdy5.swap | 1 + + .../test-20-swap-from-cmdline.input | 2 ++ + 20 files changed, 112 insertions(+) + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount + create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap + create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap + create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap + +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount +new file mode 100644 +index 0000000000..8cc17c5d92 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount +@@ -0,0 +1,12 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=local-fs.target ++After=blockdev@dev-sdx6.target ++ ++[Mount] ++What=/dev/sdx6 ++Where=/foo/also_in_initrd ++Options=x-initrd.mount +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount +new file mode 100644 +index 0000000000..8a5e28ebbf +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=local-fs.target ++After=blockdev@dev-sdx7.target ++ ++[Mount] ++What=/dev/sdx7 ++Where=/foo/not_in_initrd +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount +new file mode 120000 +index 0000000000..e4b2711fb9 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount +@@ -0,0 +1 @@ ++../foo-also_in_initrd.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount +new file mode 120000 +index 0000000000..85965fe86e +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount +@@ -0,0 +1 @@ ++../foo-not_in_initrd.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount +new file mode 120000 +index 0000000000..a570574e46 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount +@@ -0,0 +1 @@ ++../usr.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount +new file mode 100644 +index 0000000000..ff01ec4fde +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=local-fs.target ++After=blockdev@dev-sdx5.target ++ ++[Mount] ++What=/dev/sdx5 ++Where=/usr +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount +new file mode 120000 +index 0000000000..314c46cccf +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount +@@ -0,0 +1 @@ ++../sysroot-foo-also_in_initrd.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount +new file mode 120000 +index 0000000000..8bcbb16eae +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount +@@ -0,0 +1 @@ ++../sysroot-usr.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount +new file mode 120000 +index 0000000000..8fb2e18647 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount +@@ -0,0 +1 @@ ++../sysusr-usr.mount +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount +new file mode 100644 +index 0000000000..8baf1568b1 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount +@@ -0,0 +1,13 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=initrd-fs.target ++After=blockdev@dev-sdx6.target ++ ++[Mount] ++What=/dev/sdx6 ++# Canonicalized from /foo/also_in_initrd ++Where=/sysroot/foo/also_in_initrd ++Options=x-initrd.mount +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount +new file mode 100644 +index 0000000000..7f6d33cb3d +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=initrd-fs.target ++ ++[Mount] ++What=/sysusr/usr ++Where=/sysroot/usr ++Options=bind +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount +new file mode 100644 +index 0000000000..f1fedb3775 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount +@@ -0,0 +1,11 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++Before=initrd-usr-fs.target ++After=blockdev@dev-sdx5.target ++ ++[Mount] ++What=/dev/sdx5 ++Where=/sysusr/usr +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.input b/test/test-fstab-generator/test-19-mounts-from-cmdline.input +index f2cc6fc075..f16e494ecb 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.input ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.input +@@ -3,3 +3,6 @@ rd.systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto + rd.systemd.mount-extra=/dev/sdx3:/hoge/without_fstype + rd.systemd.mount-extra=/dev/sdx4 + rd.systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel ++systemd.mount-extra=/dev/sdx5:/usr:auto:defaults ++systemd.mount-extra=/dev/sdx6:/foo/also_in_initrd:auto:x-initrd.mount ++systemd.mount-extra=/dev/sdx7:/foo/not_in_initrd:auto:defaults +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap +new file mode 100644 +index 0000000000..a9009ce3bc +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap +@@ -0,0 +1,10 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy5.target ++ ++[Swap] ++What=/dev/sdy5 ++Options=x-initrd.mount +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap +new file mode 100644 +index 0000000000..383a8c3865 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap +@@ -0,0 +1,9 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy6.target ++ ++[Swap] ++What=/dev/sdy6 +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap +new file mode 120000 +index 0000000000..04565dbf44 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap +@@ -0,0 +1 @@ ++../dev-sdy5.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap +new file mode 120000 +index 0000000000..3b36226323 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap +@@ -0,0 +1 @@ ++../dev-sdy6.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap +new file mode 100644 +index 0000000000..a9009ce3bc +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap +@@ -0,0 +1,10 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Documentation=man:fstab(5) man:systemd-fstab-generator(8) ++SourcePath=/proc/cmdline ++After=blockdev@dev-sdy5.target ++ ++[Swap] ++What=/dev/sdy5 ++Options=x-initrd.mount +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap +new file mode 120000 +index 0000000000..04565dbf44 +--- /dev/null ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap +@@ -0,0 +1 @@ ++../dev-sdy5.swap +\ No newline at end of file +diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.input b/test/test-fstab-generator/test-20-swap-from-cmdline.input +index d92c5300e2..adde91e180 100644 +--- a/test/test-fstab-generator/test-20-swap-from-cmdline.input ++++ b/test/test-fstab-generator/test-20-swap-from-cmdline.input +@@ -2,3 +2,5 @@ rd.systemd.mount-extra=/dev/sdy1:none:swap + rd.systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs + rd.systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail + rd.systemd.swap-extra=/dev/sdy4 ++systemd.swap-extra=/dev/sdy5:x-initrd.mount ++systemd.swap-extra=/dev/sdy6 diff --git a/SOURCES/0342-fstab-generator-enable-fsck-for-block-device-mounts-.patch b/SOURCES/0342-fstab-generator-enable-fsck-for-block-device-mounts-.patch new file mode 100644 index 0000000..a0a0bf8 --- /dev/null +++ b/SOURCES/0342-fstab-generator-enable-fsck-for-block-device-mounts-.patch @@ -0,0 +1,206 @@ +From accb88b9c080f1da1f9543921ae25b5f0296ec2a Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Fri, 28 Jul 2023 06:07:17 +0900 +Subject: [PATCH] fstab-generator: enable fsck for block device mounts + specified in systemd.mount-extra= + +Like we do for root= or so. + +Another possible option is adding support of fifth (sixth?) field in +systemd.mount-extra=. But that may be overkill, hence let's do that +later if someone request that. + +Fixes fsck part of issue #28541. + +(cherry picked from commit 239cce3870438aab69b2495ccb980a9d90140217) + +Related: #2190226 +--- + src/fstab-generator/fstab-generator.c | 5 ++++- + .../foo-also_in_initrd.mount | 2 ++ + .../foo-not_in_initrd.mount | 2 ++ + .../usr.mount | 2 ++ + .../hoge-without_fstype.mount | 2 ++ + .../hoge-without_options.mount | 2 ++ + .../sysroot-foo-also_in_initrd.mount | 2 ++ + .../sysroot.mount | 2 ++ + .../systemd-fsck-root.service | 17 +++++++++++++++++ + .../systemd-fsck-usr.service | 17 +++++++++++++++++ + .../sysusr-usr.mount | 2 ++ + 11 files changed, 54 insertions(+), 1 deletion(-) + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-root.service + create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-usr.service + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index cf3ff4f598..c3fe285344 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -880,6 +880,9 @@ static int parse_fstab_one( + if (is_swap) + return add_swap(source, what, options, flags); + ++ if (passno < 0) ++ passno = is_device_path(what); ++ + assert(where_original); /* 'where' is not necessary for swap entry. */ + + if (!is_path(where_original)) { +@@ -1287,7 +1290,7 @@ static int add_mounts_from_cmdline(void) { + m->where, + m->fstype, + m->options, +- /* passno = */ 0, ++ /* passno = */ -1, + /* prefix_sysroot = */ !m->for_initrd && in_initrd(), + /* accept_root = */ true, + /* use_swap_enabled = */ false); +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount +index 8cc17c5d92..ed72fb283f 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=local-fs.target ++Requires=systemd-fsck@dev-sdx6.service ++After=systemd-fsck@dev-sdx6.service + After=blockdev@dev-sdx6.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount +index 8a5e28ebbf..11b52788df 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=local-fs.target ++Requires=systemd-fsck@dev-sdx7.service ++After=systemd-fsck@dev-sdx7.service + After=blockdev@dev-sdx7.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount +index ff01ec4fde..bfdede543a 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=local-fs.target ++Wants=systemd-fsck@dev-sdx5.service ++After=systemd-fsck@dev-sdx5.service + After=blockdev@dev-sdx5.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount +index 4d7d975cc0..a7c6ee9913 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_fstype.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=local-fs.target ++Requires=systemd-fsck@dev-sdx3.service ++After=systemd-fsck@dev-sdx3.service + After=blockdev@dev-sdx3.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount +index 4f16d2e40b..157ae2b6a4 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/hoge-without_options.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=local-fs.target ++Requires=systemd-fsck@dev-sdx2.service ++After=systemd-fsck@dev-sdx2.service + After=blockdev@dev-sdx2.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount +index 8baf1568b1..098961dc9e 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=initrd-fs.target ++Requires=systemd-fsck@dev-sdx6.service ++After=systemd-fsck@dev-sdx6.service + After=blockdev@dev-sdx6.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount +index c8547fa539..f46b71a1f0 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=initrd-root-fs.target ++Requires=systemd-fsck-root.service ++After=systemd-fsck-root.service + After=blockdev@dev-sdx1.target + + [Mount] +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-root.service +new file mode 100644 +index 0000000000..147348899d +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-root.service +@@ -0,0 +1,17 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=File System Check on /dev/sdx1 ++Documentation=man:systemd-fsck-root.service(8) ++ ++DefaultDependencies=no ++BindsTo=dev-sdx1.device ++Conflicts=shutdown.target ++After=initrd-root-device.target local-fs-pre.target dev-sdx1.device ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-usr.service b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-usr.service +new file mode 100644 +index 0000000000..512e7b1636 +--- /dev/null ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/systemd-fsck-usr.service +@@ -0,0 +1,17 @@ ++# Automatically generated by systemd-fstab-generator ++ ++[Unit] ++Description=File System Check on /dev/sdx5 ++Documentation=man:systemd-fsck-usr.service(8) ++ ++DefaultDependencies=no ++BindsTo=dev-sdx5.device ++Conflicts=shutdown.target ++After=local-fs-pre.target dev-sdx5.device ++Before=shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx5 ++TimeoutSec=infinity +diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount +index f1fedb3775..bfee6a4ff7 100644 +--- a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount ++++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount +@@ -4,6 +4,8 @@ + Documentation=man:fstab(5) man:systemd-fstab-generator(8) + SourcePath=/proc/cmdline + Before=initrd-usr-fs.target ++Requires=systemd-fsck-usr.service ++After=systemd-fsck-usr.service + After=blockdev@dev-sdx5.target + + [Mount] diff --git a/SOURCES/0343-core-use-correct-scope-of-looking-up-units.patch b/SOURCES/0343-core-use-correct-scope-of-looking-up-units.patch new file mode 100644 index 0000000..65a9ed8 --- /dev/null +++ b/SOURCES/0343-core-use-correct-scope-of-looking-up-units.patch @@ -0,0 +1,48 @@ +From cf363a503bf7cc4827dbbcd9a670987bf680d5b4 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 7 Dec 2022 12:01:59 +0900 +Subject: [PATCH] core: use correct scope of looking up units + +Fixes a bug introduced by 3b3557c410c7910fae0990599dcb82711cf5fbb7. + +Fixes #25625. + +(cherry picked from commit 47c57b4813c81187db86ed6e33ecf11f8a25825a) + +Resolves: #2226980 +--- + src/core/dbus-manager.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c +index 2db12721a1..00380cc9c1 100644 +--- a/src/core/dbus-manager.c ++++ b/src/core/dbus-manager.c +@@ -2629,11 +2629,10 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd + + static int method_get_unit_file_links(sd_bus_message *message, void *userdata, sd_bus_error *error) { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; ++ Manager *m = ASSERT_PTR(userdata); + InstallChange *changes = NULL; + size_t n_changes = 0, i; +- UnitFileFlags flags; + const char *name; +- char **p; + int runtime, r; + + r = sd_bus_message_read(message, "sb", &name, &runtime); +@@ -2648,11 +2647,9 @@ static int method_get_unit_file_links(sd_bus_message *message, void *userdata, s + if (r < 0) + return r; + +- p = STRV_MAKE(name); +- flags = UNIT_FILE_DRY_RUN | +- (runtime ? UNIT_FILE_RUNTIME : 0); +- +- r = unit_file_disable(LOOKUP_SCOPE_SYSTEM, flags, NULL, p, &changes, &n_changes); ++ r = unit_file_disable(m->unit_file_scope, ++ UNIT_FILE_DRY_RUN | (runtime ? UNIT_FILE_RUNTIME : 0), ++ NULL, STRV_MAKE(name), &changes, &n_changes); + if (r < 0) { + log_error_errno(r, "Failed to get file links for %s: %m", name); + goto finish; diff --git a/SOURCES/0344-test-merge-unit-file-related-tests-into-TEST-23-UNIT.patch b/SOURCES/0344-test-merge-unit-file-related-tests-into-TEST-23-UNIT.patch new file mode 100644 index 0000000..bc09b57 --- /dev/null +++ b/SOURCES/0344-test-merge-unit-file-related-tests-into-TEST-23-UNIT.patch @@ -0,0 +1,1009 @@ +From c2e66d6e79bd840c63fae87f0656faae1c3ea2b4 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 8 May 2023 22:38:34 +0200 +Subject: [PATCH] test: merge unit file related tests into TEST-23-UNIT-FILE + +Rename TEST-23-TYPE-EXEC to TEST-23-UNIT-FILE and merge it with +following tests: + - TEST-37-RUNTIMEDIRECTORYPRESERV + - TEST-40-EXEC-COMMAND-EX + - TEST-41-ONESHOT-RESTART + - TEST-42-EXECSTOPPOST + - TEST-57-ONSUCCESS-UPHOLD + +(cherry picked from commit 539af5c4413efbcdb57713b7ad563440217b28a5) + +Related: #2213521 +--- + .../Makefile | 0 + .../test.sh | 2 +- + .../TEST-37-RUNTIMEDIRECTORYPRESERVE/Makefile | 1 - + test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh | 12 --- + test/TEST-39-EXECRELOAD/Makefile | 1 - + test/TEST-39-EXECRELOAD/test.sh | 10 -- + test/TEST-40-EXEC-COMMAND-EX/Makefile | 1 - + .../deny-list-ubuntu-ci-arm64 | 0 + test/TEST-40-EXEC-COMMAND-EX/test.sh | 10 -- + test/TEST-41-ONESHOT-RESTART/Makefile | 1 - + test/TEST-41-ONESHOT-RESTART/test.sh | 10 -- + test/TEST-42-EXECSTOPPOST/Makefile | 1 - + test/TEST-42-EXECSTOPPOST/test.sh | 10 -- + test/TEST-57-ONSUCCESS-UPHOLD/Makefile | 1 - + test/TEST-57-ONSUCCESS-UPHOLD/test.sh | 9 -- + ....service => testsuite-23-binds-to.service} | 6 +- + ....service => testsuite-23-bound-by.service} | 0 + ...fail.service => testsuite-23-fail.service} | 2 +- + test/units/testsuite-23-prop-stop-one.service | 10 ++ + ...ice => testsuite-23-prop-stop-two.service} | 0 + ...rvice => testsuite-23-short-lived.service} | 2 +- + test/units/testsuite-23-short-lived.sh | 18 ++++ + ...s.service => testsuite-23-success.service} | 2 +- + ...ld.service => testsuite-23-uphold.service} | 2 +- + ...suite-39.sh => testsuite-23.ExecReload.sh} | 6 +- + ...ite-42.sh => testsuite-23.ExecStopPost.sh} | 6 +- + ... testsuite-23.RuntimeDirectoryPreserve.sh} | 6 +- + test/units/testsuite-23.Upholds.sh | 69 +++++++++++++ + ...-40.sh => testsuite-23.exec-command-ex.sh} | 6 +- + ...-41.sh => testsuite-23.oneshot-restart.sh} | 18 ++-- + test/units/testsuite-23.sh | 97 ++++++++++--------- + test/units/testsuite-23.type-exec.sh | 63 ++++++++++++ + test/units/testsuite-37.service | 8 -- + test/units/testsuite-39.service | 8 -- + test/units/testsuite-40.service | 8 -- + test/units/testsuite-41.service | 8 -- + test/units/testsuite-42.service | 10 -- + test/units/testsuite-57-prop-stop-one.service | 10 -- + test/units/testsuite-57-short-lived.sh | 18 ---- + test/units/testsuite-57.service | 8 -- + test/units/testsuite-57.sh | 69 ------------- + 41 files changed, 233 insertions(+), 296 deletions(-) + rename test/{TEST-23-TYPE-EXEC => TEST-23-UNIT-FILE}/Makefile (100%) + rename test/{TEST-23-TYPE-EXEC => TEST-23-UNIT-FILE}/test.sh (74%) + delete mode 120000 test/TEST-37-RUNTIMEDIRECTORYPRESERVE/Makefile + delete mode 100755 test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh + delete mode 120000 test/TEST-39-EXECRELOAD/Makefile + delete mode 100755 test/TEST-39-EXECRELOAD/test.sh + delete mode 120000 test/TEST-40-EXEC-COMMAND-EX/Makefile + delete mode 100644 test/TEST-40-EXEC-COMMAND-EX/deny-list-ubuntu-ci-arm64 + delete mode 100755 test/TEST-40-EXEC-COMMAND-EX/test.sh + delete mode 120000 test/TEST-41-ONESHOT-RESTART/Makefile + delete mode 100755 test/TEST-41-ONESHOT-RESTART/test.sh + delete mode 120000 test/TEST-42-EXECSTOPPOST/Makefile + delete mode 100755 test/TEST-42-EXECSTOPPOST/test.sh + delete mode 120000 test/TEST-57-ONSUCCESS-UPHOLD/Makefile + delete mode 100755 test/TEST-57-ONSUCCESS-UPHOLD/test.sh + rename test/units/{testsuite-57-binds-to.service => testsuite-23-binds-to.service} (74%) + rename test/units/{testsuite-57-bound-by.service => testsuite-23-bound-by.service} (100%) + rename test/units/{testsuite-57-fail.service => testsuite-23-fail.service} (74%) + create mode 100644 test/units/testsuite-23-prop-stop-one.service + rename test/units/{testsuite-57-prop-stop-two.service => testsuite-23-prop-stop-two.service} (100%) + rename test/units/{testsuite-57-short-lived.service => testsuite-23-short-lived.service} (79%) + create mode 100755 test/units/testsuite-23-short-lived.sh + rename test/units/{testsuite-57-success.service => testsuite-23-success.service} (75%) + rename test/units/{testsuite-57-uphold.service => testsuite-23-uphold.service} (74%) + rename test/units/{testsuite-39.sh => testsuite-23.ExecReload.sh} (98%) + rename test/units/{testsuite-42.sh => testsuite-23.ExecStopPost.sh} (98%) + rename test/units/{testsuite-37.sh => testsuite-23.RuntimeDirectoryPreserve.sh} (92%) + create mode 100755 test/units/testsuite-23.Upholds.sh + rename test/units/{testsuite-40.sh => testsuite-23.exec-command-ex.sh} (97%) + rename test/units/{testsuite-41.sh => testsuite-23.oneshot-restart.sh} (76%) + create mode 100755 test/units/testsuite-23.type-exec.sh + delete mode 100644 test/units/testsuite-37.service + delete mode 100644 test/units/testsuite-39.service + delete mode 100644 test/units/testsuite-40.service + delete mode 100644 test/units/testsuite-41.service + delete mode 100644 test/units/testsuite-42.service + delete mode 100644 test/units/testsuite-57-prop-stop-one.service + delete mode 100755 test/units/testsuite-57-short-lived.sh + delete mode 100644 test/units/testsuite-57.service + delete mode 100755 test/units/testsuite-57.sh + +diff --git a/test/TEST-23-TYPE-EXEC/Makefile b/test/TEST-23-UNIT-FILE/Makefile +similarity index 100% +rename from test/TEST-23-TYPE-EXEC/Makefile +rename to test/TEST-23-UNIT-FILE/Makefile +diff --git a/test/TEST-23-TYPE-EXEC/test.sh b/test/TEST-23-UNIT-FILE/test.sh +similarity index 74% +rename from test/TEST-23-TYPE-EXEC/test.sh +rename to test/TEST-23-UNIT-FILE/test.sh +index 7268cde837..335f2fdd2b 100755 +--- a/test/TEST-23-TYPE-EXEC/test.sh ++++ b/test/TEST-23-UNIT-FILE/test.sh +@@ -2,7 +2,7 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + set -e + +-TEST_DESCRIPTION="test Type=exec" ++TEST_DESCRIPTION="Tests for various unit file settings" + + # shellcheck source=test/test-functions + . "${TEST_BASE_DIR:?}/test-functions" +diff --git a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/Makefile b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh +deleted file mode 100755 +index 2f65908515..0000000000 +--- a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh ++++ /dev/null +@@ -1,12 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +-# ex: ts=8 sw=4 sts=4 et filetype=sh +-set -e +- +-TEST_DESCRIPTION="test RuntimeDirectoryPreserve=yes" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/TEST-39-EXECRELOAD/Makefile b/test/TEST-39-EXECRELOAD/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-39-EXECRELOAD/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-39-EXECRELOAD/test.sh b/test/TEST-39-EXECRELOAD/test.sh +deleted file mode 100755 +index c7565c6488..0000000000 +--- a/test/TEST-39-EXECRELOAD/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="Test ExecReload= (PR #13098)" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/TEST-40-EXEC-COMMAND-EX/Makefile b/test/TEST-40-EXEC-COMMAND-EX/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-40-EXEC-COMMAND-EX/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-40-EXEC-COMMAND-EX/deny-list-ubuntu-ci-arm64 b/test/TEST-40-EXEC-COMMAND-EX/deny-list-ubuntu-ci-arm64 +deleted file mode 100644 +index e69de29bb2..0000000000 +diff --git a/test/TEST-40-EXEC-COMMAND-EX/test.sh b/test/TEST-40-EXEC-COMMAND-EX/test.sh +deleted file mode 100755 +index 6101f2ccf5..0000000000 +--- a/test/TEST-40-EXEC-COMMAND-EX/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="test ExecXYZEx= service unit dbus hookups" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/TEST-41-ONESHOT-RESTART/Makefile b/test/TEST-41-ONESHOT-RESTART/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-41-ONESHOT-RESTART/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-41-ONESHOT-RESTART/test.sh b/test/TEST-41-ONESHOT-RESTART/test.sh +deleted file mode 100755 +index 2e1879a7cb..0000000000 +--- a/test/TEST-41-ONESHOT-RESTART/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="Test oneshot unit restart on failure" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/TEST-42-EXECSTOPPOST/Makefile b/test/TEST-42-EXECSTOPPOST/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-42-EXECSTOPPOST/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-42-EXECSTOPPOST/test.sh b/test/TEST-42-EXECSTOPPOST/test.sh +deleted file mode 100755 +index 9d75bac2b6..0000000000 +--- a/test/TEST-42-EXECSTOPPOST/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="test that ExecStopPost= is always run" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/TEST-57-ONSUCCESS-UPHOLD/Makefile b/test/TEST-57-ONSUCCESS-UPHOLD/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-57-ONSUCCESS-UPHOLD/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-57-ONSUCCESS-UPHOLD/test.sh b/test/TEST-57-ONSUCCESS-UPHOLD/test.sh +deleted file mode 100755 +index 8181ac508f..0000000000 +--- a/test/TEST-57-ONSUCCESS-UPHOLD/test.sh ++++ /dev/null +@@ -1,9 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="test OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo=" +-# shellcheck source=test/test-functions +-. "$TEST_BASE_DIR/test-functions" +- +-do_test "$@" 57 +diff --git a/test/units/testsuite-57-binds-to.service b/test/units/testsuite-23-binds-to.service +similarity index 74% +rename from test/units/testsuite-57-binds-to.service +rename to test/units/testsuite-23-binds-to.service +index c542896d94..d81676a8c3 100644 +--- a/test/units/testsuite-57-binds-to.service ++++ b/test/units/testsuite-23-binds-to.service +@@ -1,10 +1,10 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + [Unit] + Description=Unit with BindsTo= +-BindsTo=testsuite-57-bound-by.service +-After=testsuite-57-bound-by.service ++BindsTo=testsuite-23-bound-by.service ++After=testsuite-23-bound-by.service + + [Service] + ExecStart=/bin/sleep infinity + # --kill-who= (no 'm') to check that the short form is accepted +-ExecStopPost=systemctl kill --kill-who=main -sRTMIN+1 testsuite-57.service ++ExecStopPost=systemctl kill --kill-who=main -sRTMIN+1 testsuite-23.service +diff --git a/test/units/testsuite-57-bound-by.service b/test/units/testsuite-23-bound-by.service +similarity index 100% +rename from test/units/testsuite-57-bound-by.service +rename to test/units/testsuite-23-bound-by.service +diff --git a/test/units/testsuite-57-fail.service b/test/units/testsuite-23-fail.service +similarity index 74% +rename from test/units/testsuite-57-fail.service +rename to test/units/testsuite-23-fail.service +index 54d2330742..36f8baa6ba 100644 +--- a/test/units/testsuite-57-fail.service ++++ b/test/units/testsuite-23-fail.service +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + [Unit] + Description=Failing unit +-OnFailure=testsuite-57-uphold.service ++OnFailure=testsuite-23-uphold.service + + [Service] + ExecStart=/bin/false +diff --git a/test/units/testsuite-23-prop-stop-one.service b/test/units/testsuite-23-prop-stop-one.service +new file mode 100644 +index 0000000000..f068daf2b3 +--- /dev/null ++++ b/test/units/testsuite-23-prop-stop-one.service +@@ -0,0 +1,10 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++Description=Stop Propagation Receiver ++Wants=testsuite-23-prop-stop-two.service ++After=testsuite-23-prop-stop-two.service ++StopPropagatedFrom=testsuite-23-prop-stop-two.service ++ ++[Service] ++ExecStart=/bin/sleep infinity ++ExecStopPost=systemctl kill --kill-whom=main -sUSR2 testsuite-23.service +diff --git a/test/units/testsuite-57-prop-stop-two.service b/test/units/testsuite-23-prop-stop-two.service +similarity index 100% +rename from test/units/testsuite-57-prop-stop-two.service +rename to test/units/testsuite-23-prop-stop-two.service +diff --git a/test/units/testsuite-57-short-lived.service b/test/units/testsuite-23-short-lived.service +similarity index 79% +rename from test/units/testsuite-57-short-lived.service +rename to test/units/testsuite-23-short-lived.service +index cd8b51477f..2dcb2ae228 100644 +--- a/test/units/testsuite-57-short-lived.service ++++ b/test/units/testsuite-23-short-lived.service +@@ -8,4 +8,4 @@ StartLimitBurst=15 + StartLimitIntervalSec=1h + + [Service] +-ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-57-short-lived.sh ++ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-23-short-lived.sh +diff --git a/test/units/testsuite-23-short-lived.sh b/test/units/testsuite-23-short-lived.sh +new file mode 100755 +index 0000000000..4a12c7f498 +--- /dev/null ++++ b/test/units/testsuite-23-short-lived.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -ex ++ ++if [ -f /tmp/testsuite-23.counter ] ; then ++ read -r counter < /tmp/testsuite-23.counter ++ counter=$((counter + 1)) ++else ++ counter=0 ++fi ++ ++echo "$counter" >/tmp/testsuite-23.counter ++ ++if [ "$counter" -eq 5 ] ; then ++ systemctl kill --kill-whom=main -sUSR1 testsuite-23.service ++fi ++ ++exec sleep 1.5 +diff --git a/test/units/testsuite-57-success.service b/test/units/testsuite-23-success.service +similarity index 75% +rename from test/units/testsuite-57-success.service +rename to test/units/testsuite-23-success.service +index ae1f46f30c..410d4f83c3 100644 +--- a/test/units/testsuite-57-success.service ++++ b/test/units/testsuite-23-success.service +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + [Unit] + Description=Succeeding unit +-OnSuccess=testsuite-57-fail.service ++OnSuccess=testsuite-23-fail.service + + [Service] + ExecStart=/bin/true +diff --git a/test/units/testsuite-57-uphold.service b/test/units/testsuite-23-uphold.service +similarity index 74% +rename from test/units/testsuite-57-uphold.service +rename to test/units/testsuite-23-uphold.service +index eba97f509d..3549d6a8f5 100644 +--- a/test/units/testsuite-57-uphold.service ++++ b/test/units/testsuite-23-uphold.service +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + [Unit] + Description=Upholding Unit +-Upholds=testsuite-57-short-lived.service ++Upholds=testsuite-23-short-lived.service + + [Service] + ExecStart=/bin/sleep infinity +diff --git a/test/units/testsuite-39.sh b/test/units/testsuite-23.ExecReload.sh +similarity index 98% +rename from test/units/testsuite-39.sh +rename to test/units/testsuite-23.ExecReload.sh +index 5b77bbbaf1..c890bd7fb5 100755 +--- a/test/units/testsuite-39.sh ++++ b/test/units/testsuite-23.ExecReload.sh +@@ -3,6 +3,8 @@ + set -eux + set -o pipefail + ++# Test ExecReload= (PR #13098) ++ + systemd-analyze log-level debug + + export SYSTEMD_PAGER= +@@ -57,7 +59,3 @@ systemctl status "$SERVICE_NAME" + systemctl stop "$SERVICE_NAME" + + systemd-analyze log-level info +- +-echo OK >/testok +- +-exit 0 +diff --git a/test/units/testsuite-42.sh b/test/units/testsuite-23.ExecStopPost.sh +similarity index 98% +rename from test/units/testsuite-42.sh +rename to test/units/testsuite-23.ExecStopPost.sh +index 9476df86dd..1464f6c1b5 100755 +--- a/test/units/testsuite-42.sh ++++ b/test/units/testsuite-23.ExecStopPost.sh +@@ -2,6 +2,8 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + set -eux + ++# Test that ExecStopPost= is always run ++ + systemd-analyze log-level debug + + systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple1' true +@@ -94,7 +96,3 @@ systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=t + test -f /run/idle2 + + systemd-analyze log-level info +- +-echo OK >/testok +- +-exit 0 +diff --git a/test/units/testsuite-37.sh b/test/units/testsuite-23.RuntimeDirectoryPreserve.sh +similarity index 92% +rename from test/units/testsuite-37.sh +rename to test/units/testsuite-23.RuntimeDirectoryPreserve.sh +index 1aec383c0c..b60b612d82 100755 +--- a/test/units/testsuite-37.sh ++++ b/test/units/testsuite-23.RuntimeDirectoryPreserve.sh +@@ -5,6 +5,8 @@ + set -eux + set -o pipefail + ++# Test RuntimeDirectoryPreserve=yes ++ + systemd-mount -p RuntimeDirectory=hoge -p RuntimeDirectoryPreserve=yes -t tmpfs tmpfs /tmp/aaa + + touch /run/hoge/foo +@@ -14,7 +16,3 @@ systemctl restart tmp-aaa.mount + + test -e /run/hoge/foo + test ! -e /tmp/aaa/bbb +- +-echo OK >/testok +- +-exit 0 +diff --git a/test/units/testsuite-23.Upholds.sh b/test/units/testsuite-23.Upholds.sh +new file mode 100755 +index 0000000000..bcc2400ae7 +--- /dev/null ++++ b/test/units/testsuite-23.Upholds.sh +@@ -0,0 +1,69 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++ ++set -eux ++set -o pipefail ++ ++# Test OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo= ++ ++systemd-analyze log-level debug ++systemd-analyze log-target journal ++ ++# Idea is this: ++# 1. we start testsuite-23-success.service ++# 2. which through OnSuccess= starts testsuite-23-fail.service, ++# 3. which through OnFailure= starts testsuite-23-uphold.service, ++# 4. which through Uphold= starts/keeps testsuite-23-short-lived.service running, ++# 5. which will sleep 1s when invoked, and on the 5th invocation send us a SIGUSR1 ++# 6. once we got that we finish cleanly ++ ++sigusr1=0 ++trap sigusr1=1 SIGUSR1 ++ ++trap -p SIGUSR1 ++ ++systemctl start testsuite-23-success.service ++ ++while [ "$sigusr1" -eq 0 ] ; do ++ sleep .5 ++done ++ ++systemctl stop testsuite-23-uphold.service ++ ++# Idea is this: ++# 1. we start testsuite-23-prop-stop-one.service ++# 2. which through Wants=/After= pulls in testsuite-23-prop-stop-two.service as well ++# 3. testsuite-23-prop-stop-one.service then sleeps indefinitely ++# 4. testsuite-23-prop-stop-two.service sleeps a short time and exits ++# 5. the StopPropagatedFrom= dependency between the two should ensure *both* will exit as result ++# 6. an ExecStopPost= line on testsuite-23-prop-stop-one.service will send us a SIGUSR2 ++# 7. once we got that we finish cleanly ++ ++sigusr2=0 ++trap sigusr2=1 SIGUSR2 ++ ++systemctl start testsuite-23-prop-stop-one.service ++ ++while [ "$sigusr2" -eq 0 ] ; do ++ sleep .5 ++done ++ ++ ++# Idea is this: ++# 1. we start testsuite-23-binds-to.service ++# 2. which through BindsTo=/After= pulls in testsuite-23-bound-by.service as well ++# 3. testsuite-23-bound-by.service suddenly dies ++# 4. testsuite-23-binds-to.service should then also be pulled down (it otherwise just hangs) ++# 6. an ExecStopPost= line on testsuite-23-binds-to.service will send us a SIGRTMIN1+1 ++# 7. once we got that we finish cleanly ++ ++sigrtmin1=0 ++trap sigrtmin1=1 SIGRTMIN+1 ++ ++systemctl start testsuite-23-binds-to.service ++ ++while [ "$sigrtmin1" -eq 0 ] ; do ++ sleep .5 ++done ++ ++systemd-analyze log-level info +diff --git a/test/units/testsuite-40.sh b/test/units/testsuite-23.exec-command-ex.sh +similarity index 97% +rename from test/units/testsuite-40.sh +rename to test/units/testsuite-23.exec-command-ex.sh +index cec1fd3a7a..f926e7dea8 100755 +--- a/test/units/testsuite-40.sh ++++ b/test/units/testsuite-23.exec-command-ex.sh +@@ -3,6 +3,8 @@ + set -eux + set -o pipefail + ++# Test ExecXYZEx= service unit dbus hookups ++ + systemd-analyze log-level debug + + declare -A property +@@ -40,7 +42,3 @@ for c in "${!property_ex[@]}"; do + done + + systemd-analyze log-level info +- +-echo OK >/testok +- +-exit 0 +diff --git a/test/units/testsuite-41.sh b/test/units/testsuite-23.oneshot-restart.sh +similarity index 76% +rename from test/units/testsuite-41.sh +rename to test/units/testsuite-23.oneshot-restart.sh +index 13bc684c2d..f643891037 100755 +--- a/test/units/testsuite-41.sh ++++ b/test/units/testsuite-23.oneshot-restart.sh +@@ -3,21 +3,23 @@ + set -eux + set -o pipefail + ++# Test oneshot unit restart on failure ++ + # wait this many secs for each test service to succeed in what is being tested + MAX_SECS=60 + + systemd-analyze log-level debug + + # test one: Restart=on-failure should restart the service +-systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1" \ ++systemd-run --unit=oneshot-restart-one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1" \ + && { echo 'unexpected success'; exit 1; } + + for ((secs = 0; secs < MAX_SECS; secs++)); do +- [[ "$(systemctl show one.service -P NRestarts)" -le 0 ]] || break +- sleep 1 ++ [[ "$(systemctl show oneshot-restart-one.service -P NRestarts)" -le 0 ]] || break ++ sleep 1 + done +-if [[ "$(systemctl show one.service -P NRestarts)" -le 0 ]]; then +- exit 1 ++if [[ "$(systemctl show oneshot-restart-one.service -P NRestarts)" -le 0 ]]; then ++ exit 1 + fi + + TMP_FILE="/tmp/test-41-oneshot-restart-test" +@@ -26,7 +28,7 @@ TMP_FILE="/tmp/test-41-oneshot-restart-test" + + # test two: make sure StartLimitBurst correctly limits the number of restarts + # and restarts execution of the unit from the first ExecStart= +-systemd-run --unit=two \ ++systemd-run --unit=oneshot-restart-two \ + -p StartLimitIntervalSec=120 \ + -p StartLimitBurst=3 \ + -p Type=oneshot \ +@@ -50,7 +52,3 @@ if [[ $(cat $TMP_FILE) != "aaa" ]]; then + fi + + systemd-analyze log-level info +- +-echo OK >/testok +- +-exit 0 +diff --git a/test/units/testsuite-23.sh b/test/units/testsuite-23.sh +index e8f99ff60d..a6b8da34c9 100755 +--- a/test/units/testsuite-23.sh ++++ b/test/units/testsuite-23.sh +@@ -3,63 +3,64 @@ + set -eux + set -o pipefail + +-systemd-analyze log-level debug ++: >/failed + +-# Create a binary for which execve() will fail +-touch /tmp/brokenbinary +-chmod +x /tmp/brokenbinary ++declare -i CHILD_PID=0 + +-# These three commands should succeed. +-systemd-run --unit=one -p Type=simple /bin/sleep infinity +-systemd-run --unit=two -p Type=simple -p User=idontexist /bin/sleep infinity +-systemd-run --unit=three -p Type=simple /tmp/brokenbinary ++# Note: all the signal shenanigans are necessary for the Upholds= tests + +-# And now, do the same with Type=exec, where the latter two should fail +-systemd-run --unit=four -p Type=exec /bin/sleep infinity +-systemd-run --unit=five -p Type=exec -p User=idontexist /bin/sleep infinity && { echo 'unexpected success'; exit 1; } +-systemd-run --unit=six -p Type=exec /tmp/brokenbinary && { echo 'unexpected success'; exit 1; } ++# Like trap, but passes the signal name as the first argument ++trap_with_sig() { ++ local fun="${1:?}" ++ local sig ++ shift + +-systemd-run --unit=seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity +-# Both TERM and SIGINT happen to have the same number on all architectures +-test "$(systemctl show --value -p KillSignal seven.service)" -eq 15 +-test "$(systemctl show --value -p RestartKillSignal seven.service)" -eq 2 ++ for sig in "$@"; do ++ # shellcheck disable=SC2064 ++ trap "$fun $sig" "$sig" ++ done ++} + +-systemctl restart seven.service +-systemctl stop seven.service ++# Propagate the caught signal to the current child process ++handle_signal() { ++ local sig="${1:?}" + +-# For issue #20933 ++ if [[ $CHILD_PID -gt 0 ]]; then ++ echo "Propagating signal $sig to child process $CHILD_PID" ++ kill -s "$sig" "$CHILD_PID" ++ fi ++} + +-# Should work normally +-busctl call \ +- org.freedesktop.systemd1 /org/freedesktop/systemd1 \ +- org.freedesktop.systemd1.Manager StartTransientUnit \ +- "ssa(sv)a(sa(sv))" test-20933-ok.service replace 1 \ +- ExecStart "a(sasb)" 1 \ +- /usr/bin/sleep 2 /usr/bin/sleep 1 true \ +- 0 ++# In order to make the handle_signal() stuff above work, we have to execute ++# each script asynchronously, since bash won't execute traps until the currently ++# executed command finishes. This, however, introduces another issue regarding ++# how bash's wait works. Quoting: ++# ++# When bash is waiting for an asynchronous command via the wait builtin, ++# the reception of a signal for which a trap has been set will cause the wait ++# builtin to return immediately with an exit status greater than 128, ++# immediately after which the trap is executed. ++# ++# In other words - every time we propagate a signal, wait returns with ++# 128+signal, so we have to wait again - repeat until the process dies. ++wait_harder() { ++ local pid="${1:?}" + +-# DBus call should fail but not crash systemd +-busctl call \ +- org.freedesktop.systemd1 /org/freedesktop/systemd1 \ +- org.freedesktop.systemd1.Manager StartTransientUnit \ +- "ssa(sv)a(sa(sv))" test-20933-bad.service replace 1 \ +- ExecStart "a(sasb)" 1 \ +- /usr/bin/sleep 0 true \ +- 0 && { echo 'unexpected success'; exit 1; } ++ while kill -0 "$pid"; do ++ wait "$pid" || : ++ done + +-# Same but with the empty argv in the middle +-busctl call \ +- org.freedesktop.systemd1 /org/freedesktop/systemd1 \ +- org.freedesktop.systemd1.Manager StartTransientUnit \ +- "ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace 1 \ +- ExecStart "a(sasb)" 3 \ +- /usr/bin/sleep 2 /usr/bin/sleep 1 true \ +- /usr/bin/sleep 0 true \ +- /usr/bin/sleep 2 /usr/bin/sleep 1 true \ +- 0 && { echo 'unexpected success'; exit 1; } ++ wait "$pid" ++} + +-systemd-analyze log-level info ++trap_with_sig handle_signal SIGUSR1 SIGUSR2 SIGRTMIN+1 + +-echo OK >/testok ++for script in "${0%.sh}".*.sh; do ++ echo "Running $script" ++ "./$script" & ++ CHILD_PID=$! ++ wait_harder "$CHILD_PID" ++done + +-exit 0 ++touch /testok ++rm /failed +diff --git a/test/units/testsuite-23.type-exec.sh b/test/units/testsuite-23.type-exec.sh +new file mode 100755 +index 0000000000..87f32ccb58 +--- /dev/null ++++ b/test/units/testsuite-23.type-exec.sh +@@ -0,0 +1,63 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# Test Type=exec ++ ++systemd-analyze log-level debug ++ ++# Create a binary for which execve() will fail ++touch /tmp/brokenbinary ++chmod +x /tmp/brokenbinary ++ ++# These three commands should succeed. ++systemd-run --unit=exec-one -p Type=simple /bin/sleep infinity ++systemd-run --unit=exec-two -p Type=simple -p User=idontexist /bin/sleep infinity ++systemd-run --unit=exec-three -p Type=simple /tmp/brokenbinary ++ ++# And now, do the same with Type=exec, where the latter two should fail ++systemd-run --unit=exec-four -p Type=exec /bin/sleep infinity ++(! systemd-run --unit=exec-five -p Type=exec -p User=idontexist /bin/sleep infinity) ++(! systemd-run --unit=exec-six -p Type=exec /tmp/brokenbinary) ++ ++systemd-run --unit=exec-seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity ++# Both TERM and SIGINT happen to have the same number on all architectures ++test "$(systemctl show --value -p KillSignal exec-seven.service)" -eq 15 ++test "$(systemctl show --value -p RestartKillSignal exec-seven.service)" -eq 2 ++ ++systemctl restart exec-seven.service ++systemctl stop exec-seven.service ++ ++# For issue #20933 ++ ++# Should work normally ++busctl call \ ++ org.freedesktop.systemd1 /org/freedesktop/systemd1 \ ++ org.freedesktop.systemd1.Manager StartTransientUnit \ ++ "ssa(sv)a(sa(sv))" test-20933-ok.service replace 1 \ ++ ExecStart "a(sasb)" 1 \ ++ /usr/bin/sleep 2 /usr/bin/sleep 1 true \ ++ 0 ++ ++# DBus call should fail but not crash systemd ++(! busctl call \ ++ org.freedesktop.systemd1 /org/freedesktop/systemd1 \ ++ org.freedesktop.systemd1.Manager StartTransientUnit \ ++ "ssa(sv)a(sa(sv))" test-20933-bad.service replace 1 \ ++ ExecStart "a(sasb)" 1 \ ++ /usr/bin/sleep 0 true \ ++ 0) ++ ++# Same but with the empty argv in the middle ++(! busctl call \ ++ org.freedesktop.systemd1 /org/freedesktop/systemd1 \ ++ org.freedesktop.systemd1.Manager StartTransientUnit \ ++ "ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace 1 \ ++ ExecStart "a(sasb)" 3 \ ++ /usr/bin/sleep 2 /usr/bin/sleep 1 true \ ++ /usr/bin/sleep 0 true \ ++ /usr/bin/sleep 2 /usr/bin/sleep 1 true \ ++ 0) ++ ++systemd-analyze log-level info +diff --git a/test/units/testsuite-37.service b/test/units/testsuite-37.service +deleted file mode 100644 +index ccad5e2d31..0000000000 +--- a/test/units/testsuite-37.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-37-RUNTIMEDIRECTORYPRESERVE +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-39.service b/test/units/testsuite-39.service +deleted file mode 100644 +index 1567dfaa08..0000000000 +--- a/test/units/testsuite-39.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-39-EXECRELOAD +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-40.service b/test/units/testsuite-40.service +deleted file mode 100644 +index eec4ddc99a..0000000000 +--- a/test/units/testsuite-40.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-40-EXEC-COMMAND-EX +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-41.service b/test/units/testsuite-41.service +deleted file mode 100644 +index bbd8a72d7c..0000000000 +--- a/test/units/testsuite-41.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-41-ONESHOT-RESTART +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-42.service b/test/units/testsuite-42.service +deleted file mode 100644 +index f57e616466..0000000000 +--- a/test/units/testsuite-42.service ++++ /dev/null +@@ -1,10 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-42-EXECSTOPPOST +-Before=getty-pre.target +-Wants=getty-pre.target +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-57-prop-stop-one.service b/test/units/testsuite-57-prop-stop-one.service +deleted file mode 100644 +index a942b529e3..0000000000 +--- a/test/units/testsuite-57-prop-stop-one.service ++++ /dev/null +@@ -1,10 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=Stop Propagation Receiver +-Wants=testsuite-57-prop-stop-two.service +-After=testsuite-57-prop-stop-two.service +-StopPropagatedFrom=testsuite-57-prop-stop-two.service +- +-[Service] +-ExecStart=/bin/sleep infinity +-ExecStopPost=systemctl kill --kill-whom=main -sUSR2 testsuite-57.service +diff --git a/test/units/testsuite-57-short-lived.sh b/test/units/testsuite-57-short-lived.sh +deleted file mode 100755 +index cd797a16e1..0000000000 +--- a/test/units/testsuite-57-short-lived.sh ++++ /dev/null +@@ -1,18 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -ex +- +-if [ -f /tmp/testsuite-57.counter ] ; then +- read -r counter < /tmp/testsuite-57.counter +- counter=$(("$counter" + 1)) +-else +- counter=0 +-fi +- +-echo "$counter" > /tmp/testsuite-57.counter +- +-if [ "$counter" -eq 5 ] ; then +- systemctl kill --kill-whom=main -sUSR1 testsuite-57.service +-fi +- +-exec sleep 1.5 +diff --git a/test/units/testsuite-57.service b/test/units/testsuite-57.service +deleted file mode 100644 +index d3ec955d4d..0000000000 +--- a/test/units/testsuite-57.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-57-ONSUCCESS-UPHOLD +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-57.sh b/test/units/testsuite-57.sh +deleted file mode 100755 +index 66d946bebc..0000000000 +--- a/test/units/testsuite-57.sh ++++ /dev/null +@@ -1,69 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +- +-set -eux +-set -o pipefail +- +-systemd-analyze log-level debug +-systemd-analyze log-target journal +- +-# Idea is this: +-# 1. we start testsuite-57-success.service +-# 2. which through OnSuccess= starts testsuite-57-fail.service, +-# 3. which through OnFailure= starts testsuite-57-uphold.service, +-# 4. which through Uphold= starts/keeps testsuite-57-short-lived.service running, +-# 5. which will sleep 1s when invoked, and on the 5th invocation send us a SIGUSR1 +-# 6. once we got that we finish cleanly +- +-sigusr1=0 +-trap sigusr1=1 SIGUSR1 +- +-systemctl start testsuite-57-success.service +- +-while [ "$sigusr1" -eq 0 ] ; do +- sleep .5 +-done +- +-systemctl stop testsuite-57-uphold.service +- +-# Idea is this: +-# 1. we start testsuite-57-prop-stop-one.service +-# 2. which through Wants=/After= pulls in testsuite-57-prop-stop-two.service as well +-# 3. testsuite-57-prop-stop-one.service then sleeps indefinitely +-# 4. testsuite-57-prop-stop-two.service sleeps a short time and exits +-# 5. the StopPropagatedFrom= dependency between the two should ensure *both* will exit as result +-# 6. an ExecStopPost= line on testsuite-57-prop-stop-one.service will send us a SIGUSR2 +-# 7. once we got that we finish cleanly +- +-sigusr2=0 +-trap sigusr2=1 SIGUSR2 +- +-systemctl start testsuite-57-prop-stop-one.service +- +-while [ "$sigusr2" -eq 0 ] ; do +- sleep .5 +-done +- +- +-# Idea is this: +-# 1. we start testsuite-57-binds-to.service +-# 2. which through BindsTo=/After= pulls in testsuite-57-bound-by.service as well +-# 3. testsuite-57-bound-by.service suddenly dies +-# 4. testsuite-57-binds-to.service should then also be pulled down (it otherwise just hangs) +-# 6. an ExecStopPost= line on testsuite-57-binds-to.service will send us a SIGRTMIN1+1 +-# 7. once we got that we finish cleanly +- +-sigrtmin1=0 +-trap sigrtmin1=1 SIGRTMIN+1 +- +-systemctl start testsuite-57-binds-to.service +- +-while [ "$sigrtmin1" -eq 0 ] ; do +- sleep .5 +-done +- +-systemd-analyze log-level info +- +-echo OK >/testok +- +-exit 0 diff --git a/SOURCES/0345-test-rename-TEST-07-ISSUE-1981-to-TEST-07-PID1.patch b/SOURCES/0345-test-rename-TEST-07-ISSUE-1981-to-TEST-07-PID1.patch new file mode 100644 index 0000000..e288c0d --- /dev/null +++ b/SOURCES/0345-test-rename-TEST-07-ISSUE-1981-to-TEST-07-PID1.patch @@ -0,0 +1,140 @@ +From b186204ab9a7eb51fc2b2bbaa99d2865198e15e6 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 12:38:57 +0200 +Subject: [PATCH] test: rename TEST-07-ISSUE-1981 to TEST-07-PID1 + +(cherry picked from commit 09c033a2763fe7f0e625901f199e646b3f132e84) + +Related: #2213521 +--- + .../Makefile | 0 + .../test.sh | 5 +- + test/units/testsuite-07.issue-1981.sh | 47 +++++++++++++++++++ + test/units/testsuite-07.sh | 33 ++----------- + 4 files changed, 52 insertions(+), 33 deletions(-) + rename test/{TEST-07-ISSUE-1981 => TEST-07-PID1}/Makefile (100%) + rename test/{TEST-07-ISSUE-1981 => TEST-07-PID1}/test.sh (62%) + create mode 100755 test/units/testsuite-07.issue-1981.sh + +diff --git a/test/TEST-07-ISSUE-1981/Makefile b/test/TEST-07-PID1/Makefile +similarity index 100% +rename from test/TEST-07-ISSUE-1981/Makefile +rename to test/TEST-07-PID1/Makefile +diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-PID1/test.sh +similarity index 62% +rename from test/TEST-07-ISSUE-1981/test.sh +rename to test/TEST-07-PID1/test.sh +index 5bc41386b5..2b9dd418b8 100755 +--- a/test/TEST-07-ISSUE-1981/test.sh ++++ b/test/TEST-07-PID1/test.sh +@@ -2,12 +2,9 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + set -e + +-TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981" +-TEST_NO_QEMU=1 ++TEST_DESCRIPTION="Tests for core PID1 functionality" + + # shellcheck source=test/test-functions + . "${TEST_BASE_DIR:?}/test-functions" + +-NSPAWN_TIMEOUT=30 +- + do_test "$@" +diff --git a/test/units/testsuite-07.issue-1981.sh b/test/units/testsuite-07.issue-1981.sh +new file mode 100755 +index 0000000000..6eb802c93f +--- /dev/null ++++ b/test/units/testsuite-07.issue-1981.sh +@@ -0,0 +1,47 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# Segmentation fault in timer_enter_waiting while masking a unit ++# Issue: https://github.com/systemd/systemd/issues/1981 ++ ++at_exit() { ++ set +e ++ ++ systemctl stop my.timer my.service ++ rm -f /run/systemd/system/my.{service,timer} ++ systemctl daemon-reload ++} ++ ++trap at_exit EXIT ++ ++mkdir -p /run/systemd/system ++ ++cat >/run/systemd/system/my.service <<\EOF ++[Service] ++Type=oneshot ++ExecStartPre=sh -c 'test "$TRIGGER_UNIT" = my.timer' ++ExecStartPre=sh -c 'test -n "$TRIGGER_TIMER_REALTIME_USEC"' ++ExecStartPre=sh -c 'test -n "$TRIGGER_TIMER_MONOTONIC_USEC"' ++ExecStart=/bin/echo Timer runs me ++EOF ++ ++cat >/run/systemd/system/my.timer </run/systemd/system/my.timer.d/override.conf </failed + +-cat >/lib/systemd/system/my.service </lib/systemd/system/my.timer </etc/systemd/system/my.timer.d/override.conf < +Date: Wed, 10 May 2023 13:07:26 +0200 +Subject: [PATCH] test: merge TEST-08-ISSUE-2730 into TEST-07-PID1 + +(cherry picked from commit cd62ba42a40e5d87a83a98bc421419bd2778d4ec) + +Related: #2213521 +--- + test/TEST-07-PID1/test.sh | 19 +++++++++++++++++++ + test/TEST-08-ISSUE-2730/Makefile | 1 - + test/TEST-08-ISSUE-2730/test.sh | 14 -------------- + test/meson.build | 12 ------------ + test/testsuite-08.units/-.mount | 12 ------------ + .../local-fs.target.wants/-.mount | 1 - + test/testsuite-08.units/root.mount | 1 - + .../systemd-remount-fs.service | 12 ------------ + test/units/testsuite-07.sh | 4 ++++ + test/units/testsuite-08.service | 8 -------- + 10 files changed, 23 insertions(+), 61 deletions(-) + delete mode 120000 test/TEST-08-ISSUE-2730/Makefile + delete mode 100755 test/TEST-08-ISSUE-2730/test.sh + delete mode 100644 test/testsuite-08.units/-.mount + delete mode 120000 test/testsuite-08.units/local-fs.target.wants/-.mount + delete mode 120000 test/testsuite-08.units/root.mount + delete mode 100644 test/testsuite-08.units/systemd-remount-fs.service + delete mode 100644 test/units/testsuite-08.service + +diff --git a/test/TEST-07-PID1/test.sh b/test/TEST-07-PID1/test.sh +index 2b9dd418b8..c241840327 100755 +--- a/test/TEST-07-PID1/test.sh ++++ b/test/TEST-07-PID1/test.sh +@@ -7,4 +7,23 @@ TEST_DESCRIPTION="Tests for core PID1 functionality" + # shellcheck source=test/test-functions + . "${TEST_BASE_DIR:?}/test-functions" + ++test_append_files() { ++ local workspace="${1:?}" ++ ++ # Issue: https://github.com/systemd/systemd/issues/2730 ++ mkdir -p "$workspace/etc/systemd/system/" ++ cat >"$workspace/etc/systemd/system/issue2730.mount" </failed + ++# Issue: https://github.com/systemd/systemd/issues/2730 ++# See TEST-07-PID1/test.sh for the first "half" of the test ++mountpoint /issue2730 ++ + for script in "${0%.sh}".*.sh; do + echo "Running $script" + "./$script" +diff --git a/test/units/testsuite-08.service b/test/units/testsuite-08.service +deleted file mode 100644 +index d6937663e2..0000000000 +--- a/test/units/testsuite-08.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-08-ISSUE-2730 +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=sh -x -c 'mount -o remount,rw /dev/sda1 && echo OK >/testok; systemctl poweroff' +-Type=oneshot diff --git a/SOURCES/0347-test-merge-TEST-09-ISSUE-2691-into-TEST-07-PID1.patch b/SOURCES/0347-test-merge-TEST-09-ISSUE-2691-into-TEST-07-PID1.patch new file mode 100644 index 0000000..c0426a9 --- /dev/null +++ b/SOURCES/0347-test-merge-TEST-09-ISSUE-2691-into-TEST-07-PID1.patch @@ -0,0 +1,76 @@ +From 53da89d4a318cca04a9ec75e5d4431c36e10c140 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 13:13:12 +0200 +Subject: [PATCH] test: merge TEST-09-ISSUE-2691 into TEST-07-PID1 + +(cherry picked from commit 4966a31ba3ef1eae37733a81bf318f4b18d11a96) + +Related: #2213521 +--- + test/TEST-09-ISSUE-2691/Makefile | 1 - + test/TEST-09-ISSUE-2691/test.sh | 11 ----------- + test/units/testsuite-07.service | 6 +++++- + test/units/testsuite-09.service | 11 ----------- + 4 files changed, 5 insertions(+), 24 deletions(-) + delete mode 120000 test/TEST-09-ISSUE-2691/Makefile + delete mode 100755 test/TEST-09-ISSUE-2691/test.sh + delete mode 100644 test/units/testsuite-09.service + +diff --git a/test/TEST-09-ISSUE-2691/Makefile b/test/TEST-09-ISSUE-2691/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-09-ISSUE-2691/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh +deleted file mode 100755 +index 3fc243cc55..0000000000 +--- a/test/TEST-09-ISSUE-2691/test.sh ++++ /dev/null +@@ -1,11 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691" +-TEST_NO_NSPAWN=1 +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/units/testsuite-07.service b/test/units/testsuite-07.service +index c478e12360..f45b9c7c5b 100644 +--- a/test/units/testsuite-07.service ++++ b/test/units/testsuite-07.service +@@ -3,6 +3,10 @@ + Description=TEST-07-ISSUE-1981 + + [Service] ++Type=oneshot + ExecStartPre=rm -f /failed /testok + ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot ++# Issue: https://github.com/systemd/systemd/issues/2691 ++ExecStop=sh -c 'kill -SEGV $$$$' ++RemainAfterExit=yes ++TimeoutStopSec=270s +diff --git a/test/units/testsuite-09.service b/test/units/testsuite-09.service +deleted file mode 100644 +index 6f6cd9c522..0000000000 +--- a/test/units/testsuite-09.service ++++ /dev/null +@@ -1,11 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-09-ISSUE-2691 +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=sh -c '>/testok' +-ExecStop=sh -c 'kill -SEGV $$$$' +-Type=oneshot +-RemainAfterExit=yes +-TimeoutStopSec=270s diff --git a/SOURCES/0348-test-merge-TEST-10-ISSUE-2467-with-TEST-07-PID1.patch b/SOURCES/0348-test-merge-TEST-10-ISSUE-2467-with-TEST-07-PID1.patch new file mode 100644 index 0000000..c26cd03 --- /dev/null +++ b/SOURCES/0348-test-merge-TEST-10-ISSUE-2467-with-TEST-07-PID1.patch @@ -0,0 +1,158 @@ +From a001c9160b0722ce1c0943646b2a32d3841cddd5 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 13:41:03 +0200 +Subject: [PATCH] test: merge TEST-10-ISSUE-2467 with TEST-07-PID1 + +(cherry picked from commit a8faac7dae6f54e88aad08d2d8c34e165ce6e922) + +Related: #2213521 +--- + test/TEST-07-PID1/test.sh | 8 +++++++ + test/TEST-10-ISSUE-2467/Makefile | 1 - + test/TEST-10-ISSUE-2467/test.sh | 22 ------------------- + test/meson.build | 3 +++ + .../issue2467.service} | 2 +- + .../issue2467.socket} | 0 + test/units/testsuite-07.issue-2467.sh | 17 ++++++++++++++ + test/units/testsuite-10.service | 16 -------------- + 8 files changed, 29 insertions(+), 40 deletions(-) + delete mode 120000 test/TEST-10-ISSUE-2467/Makefile + delete mode 100755 test/TEST-10-ISSUE-2467/test.sh + rename test/{testsuite-10.units/test10.service => testsuite-07.units/issue2467.service} (90%) + rename test/{testsuite-10.units/test10.socket => testsuite-07.units/issue2467.socket} (100%) + create mode 100755 test/units/testsuite-07.issue-2467.sh + delete mode 100644 test/units/testsuite-10.service + +diff --git a/test/TEST-07-PID1/test.sh b/test/TEST-07-PID1/test.sh +index c241840327..1c3d7137fe 100755 +--- a/test/TEST-07-PID1/test.sh ++++ b/test/TEST-07-PID1/test.sh +@@ -10,6 +10,14 @@ TEST_DESCRIPTION="Tests for core PID1 functionality" + test_append_files() { + local workspace="${1:?}" + ++ # Collecting coverage slows this particular test quite a bit, causing ++ # it to fail with the default settings (20 triggers per 2 secs). ++ # Let's help it a bit in such case. ++ if get_bool "$IS_BUILT_WITH_COVERAGE"; then ++ mkdir -p "$workspace/etc/systemd/system/issue2467.socket.d" ++ printf "[Socket]\nTriggerLimitIntervalSec=10\n" >"$workspace/etc/systemd/system/issue2467.socket.d/coverage-override.conf" ++ fi ++ + # Issue: https://github.com/systemd/systemd/issues/2730 + mkdir -p "$workspace/etc/systemd/system/" + cat >"$workspace/etc/systemd/system/issue2730.mount" <"${initdir:?}/etc/systemd/system/test10.socket.d/coverage-override.conf" +- fi +- ) +-} +- +-do_test "$@" +diff --git a/test/meson.build b/test/meson.build +index 044ae781ee..92c92dcb3b 100644 +--- a/test/meson.build ++++ b/test/meson.build +@@ -36,6 +36,9 @@ if install_tests + install_subdir('testsuite-06.units', + exclude_files : '.gitattributes', + install_dir : testdata_dir) ++ install_subdir('testsuite-07.units', ++ exclude_files : '.gitattributes', ++ install_dir : testdata_dir) + install_subdir('testsuite-10.units', + exclude_files : '.gitattributes', + install_dir : testdata_dir) +diff --git a/test/testsuite-10.units/test10.service b/test/testsuite-07.units/issue2467.service +similarity index 90% +rename from test/testsuite-10.units/test10.service +rename to test/testsuite-07.units/issue2467.service +index fc8fad9327..99d886f025 100644 +--- a/test/testsuite-10.units/test10.service ++++ b/test/testsuite-07.units/issue2467.service +@@ -1,6 +1,6 @@ + # SPDX-License-Identifier: LGPL-2.1-or-later + [Unit] +-Requires=test10.socket ++Requires=issue2467.socket + ConditionPathExistsGlob=/tmp/nonexistent + # Make sure we hit the socket trigger limit in the test and not the service start limit. + StartLimitInterval=1000 +diff --git a/test/testsuite-10.units/test10.socket b/test/testsuite-07.units/issue2467.socket +similarity index 100% +rename from test/testsuite-10.units/test10.socket +rename to test/testsuite-07.units/issue2467.socket +diff --git a/test/units/testsuite-07.issue-2467.sh b/test/units/testsuite-07.issue-2467.sh +new file mode 100755 +index 0000000000..a5dcfd55dd +--- /dev/null ++++ b/test/units/testsuite-07.issue-2467.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# Don't start services every few ms if condition fails ++# Issue: https://github.com/systemd/systemd/issues/2467 ++ ++rm -f /tmp/nonexistent ++systemctl start issue2467.socket ++nc -w20 -U /run/test.ctl || : ++ ++# TriggerLimitIntervalSec= by default is set to 2s. A "sleep 10" should give ++# systemd enough time even on slower machines, to reach the trigger limit. ++# shellcheck disable=SC2016 ++timeout 10 bash -c 'while ! [[ "$(systemctl show issue2467.socket -P ActiveState)" == failed ]]; do sleep .5; done' ++[[ "$(systemctl show issue2467.socket -P Result)" == trigger-limit-hit ]] +diff --git a/test/units/testsuite-10.service b/test/units/testsuite-10.service +deleted file mode 100644 +index 9fcfd673c6..0000000000 +--- a/test/units/testsuite-10.service ++++ /dev/null +@@ -1,16 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-10-ISSUE-2467 +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-Type=oneshot +-ExecStart=rm -f /tmp/nonexistent +-ExecStart=systemctl start test10.socket +-ExecStart=-nc -w20 -U /run/test.ctl +-# TriggerLimitIntervalSec= by default is set to 2s. A "sleep 10" should give +-# systemd enough time even on slower machines, to reach the trigger limit. +-ExecStart=sleep 10 +-ExecStart=sh -x -c 'test "$(systemctl show test10.socket -P ActiveState)" = failed' +-ExecStart=sh -x -c 'test "$(systemctl show test10.socket -P Result)" = trigger-limit-hit' +-ExecStart=sh -x -c 'echo OK >/testok' diff --git a/SOURCES/0349-test-merge-TEST-11-ISSUE-3166-into-TEST-07-PID1.patch b/SOURCES/0349-test-merge-TEST-11-ISSUE-3166-into-TEST-07-PID1.patch new file mode 100644 index 0000000..06d5a0e --- /dev/null +++ b/SOURCES/0349-test-merge-TEST-11-ISSUE-3166-into-TEST-07-PID1.patch @@ -0,0 +1,108 @@ +From b04b14f0fda07377721362d9ff384f85a754ef18 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 13:49:34 +0200 +Subject: [PATCH] test: merge TEST-11-ISSUE-3166 into TEST-07-PID1 + +(cherry picked from commit 33dff897b9ad1e24b2c737de1e41b21c4543c8e1) + +Related: #2213521 +--- + test/TEST-11-ISSUE-3166/Makefile | 1 - + test/TEST-11-ISSUE-3166/test.sh | 11 ----------- + .../issue3166-fail-on-restart.service} | 0 + test/units/testsuite-07.issue-3166.sh | 16 ++++++++++++++++ + test/units/testsuite-11.service | 8 -------- + test/units/testsuite-11.sh | 14 -------------- + 6 files changed, 16 insertions(+), 34 deletions(-) + delete mode 120000 test/TEST-11-ISSUE-3166/Makefile + delete mode 100755 test/TEST-11-ISSUE-3166/test.sh + rename test/{testsuite-11.units/fail-on-restart.service => testsuite-07.units/issue3166-fail-on-restart.service} (100%) + create mode 100755 test/units/testsuite-07.issue-3166.sh + delete mode 100644 test/units/testsuite-11.service + delete mode 100755 test/units/testsuite-11.sh + +diff --git a/test/TEST-11-ISSUE-3166/Makefile b/test/TEST-11-ISSUE-3166/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-11-ISSUE-3166/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh +deleted file mode 100755 +index 12dabd704d..0000000000 +--- a/test/TEST-11-ISSUE-3166/test.sh ++++ /dev/null +@@ -1,11 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" +-TEST_NO_NSPAWN=1 +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/testsuite-11.units/fail-on-restart.service b/test/testsuite-07.units/issue3166-fail-on-restart.service +similarity index 100% +rename from test/testsuite-11.units/fail-on-restart.service +rename to test/testsuite-07.units/issue3166-fail-on-restart.service +diff --git a/test/units/testsuite-07.issue-3166.sh b/test/units/testsuite-07.issue-3166.sh +new file mode 100755 +index 0000000000..6677901358 +--- /dev/null ++++ b/test/units/testsuite-07.issue-3166.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# Service doesn't enter the "failed" state ++# Issue: https://github.com/systemd/systemd/issues/3166 ++ ++systemctl --no-block start issue3166-fail-on-restart.service ++active_state="$(systemctl show --value --property ActiveState issue3166-fail-on-restart.service)" ++while [[ "$active_state" == "activating" || "$active_state" =~ ^(in)?active$ ]]; do ++ sleep .5 ++ active_state="$(systemctl show --value --property ActiveState issue3166-fail-on-restart.service)" ++done ++systemctl is-failed issue3166-fail-on-restart.service || exit 1 ++[[ "$(systemctl show --value --property NRestarts issue3166-fail-on-restart.service)" -le 3 ]] || exit 1 +diff --git a/test/units/testsuite-11.service b/test/units/testsuite-11.service +deleted file mode 100644 +index 5dfcf50e3f..0000000000 +--- a/test/units/testsuite-11.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-11-ISSUE-3166 +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-11.sh b/test/units/testsuite-11.sh +deleted file mode 100755 +index 7e1391d8ea..0000000000 +--- a/test/units/testsuite-11.sh ++++ /dev/null +@@ -1,14 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -eux +-set -o pipefail +- +-systemctl --no-block start fail-on-restart.service +-active_state=$(systemctl show --value --property ActiveState fail-on-restart.service) +-while [[ "$active_state" == "activating" || "$active_state" =~ ^(in)?active$ ]]; do +- sleep .5 +- active_state=$(systemctl show --value --property ActiveState fail-on-restart.service) +-done +-systemctl is-failed fail-on-restart.service || exit 1 +-[[ "$(systemctl show --value --property NRestarts fail-on-restart.service)" -le 3 ]] || exit 1 +-touch /testok diff --git a/SOURCES/0350-test-merge-TEST-12-ISSUE-3171-into-TEST-07-PID1.patch b/SOURCES/0350-test-merge-TEST-12-ISSUE-3171-into-TEST-07-PID1.patch new file mode 100644 index 0000000..0901e53 --- /dev/null +++ b/SOURCES/0350-test-merge-TEST-12-ISSUE-3171-into-TEST-07-PID1.patch @@ -0,0 +1,172 @@ +From 4fcfb4f333470be69b0929a787509e64ebe96b33 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 13:58:13 +0200 +Subject: [PATCH] test: merge TEST-12-ISSUE-3171 into TEST-07-PID1 + +(cherry picked from commit 51b6dbf75ad48a816e6a1503fd5d7c4b9ba2b1d6) + +Related: #2213521 +--- + test/TEST-12-ISSUE-3171/Makefile | 1 - + test/TEST-12-ISSUE-3171/test.sh | 11 ------ + test/units/testsuite-07.issue-3171.sh | 50 +++++++++++++++++++++++++++ + test/units/testsuite-12.service | 9 ----- + test/units/testsuite-12.sh | 49 -------------------------- + 5 files changed, 50 insertions(+), 70 deletions(-) + delete mode 120000 test/TEST-12-ISSUE-3171/Makefile + delete mode 100755 test/TEST-12-ISSUE-3171/test.sh + create mode 100755 test/units/testsuite-07.issue-3171.sh + delete mode 100644 test/units/testsuite-12.service + delete mode 100755 test/units/testsuite-12.sh + +diff --git a/test/TEST-12-ISSUE-3171/Makefile b/test/TEST-12-ISSUE-3171/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-12-ISSUE-3171/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-12-ISSUE-3171/test.sh b/test/TEST-12-ISSUE-3171/test.sh +deleted file mode 100755 +index 977e04ee3f..0000000000 +--- a/test/TEST-12-ISSUE-3171/test.sh ++++ /dev/null +@@ -1,11 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171" +-TEST_NO_QEMU=1 +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/units/testsuite-07.issue-3171.sh b/test/units/testsuite-07.issue-3171.sh +new file mode 100755 +index 0000000000..db17c25f90 +--- /dev/null ++++ b/test/units/testsuite-07.issue-3171.sh +@@ -0,0 +1,50 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# SocketGroup lost on daemon-reload with unit moving away temporarily ++# Issue: https://github.com/systemd/systemd/issues/3171 ++ ++echo "g adm - - -" | systemd-sysusers - ++ ++U=/run/systemd/system/issue-3171.socket ++cat >$U </run/systemd/system/issue-3171@.service <$U </run/systemd/system/test12@.service < +Date: Wed, 10 May 2023 14:02:54 +0200 +Subject: [PATCH] test: move TEST-23's units into a dedicated subfolder + +To remain consistent with other tests. + +(cherry picked from commit 8412cdf4fd0576428d4d22949ef831bd4d51326d) + +Related: #2213521 +--- + test/meson.build | 3 +++ + .../testsuite-23-binds-to.service | 0 + .../testsuite-23-bound-by.service | 0 + test/{units => testsuite-23.units}/testsuite-23-fail.service | 0 + .../testsuite-23-prop-stop-one.service | 0 + .../testsuite-23-prop-stop-two.service | 0 + .../testsuite-23-short-lived.service | 0 + .../{units => testsuite-23.units}/testsuite-23-success.service | 0 + test/{units => testsuite-23.units}/testsuite-23-uphold.service | 0 + 9 files changed, 3 insertions(+) + rename test/{units => testsuite-23.units}/testsuite-23-binds-to.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-bound-by.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-fail.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-prop-stop-one.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-prop-stop-two.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-short-lived.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-success.service (100%) + rename test/{units => testsuite-23.units}/testsuite-23-uphold.service (100%) + +diff --git a/test/meson.build b/test/meson.build +index 92c92dcb3b..3ca544690a 100644 +--- a/test/meson.build ++++ b/test/meson.build +@@ -48,6 +48,9 @@ if install_tests + install_subdir('testsuite-16.units', + exclude_files : '.gitattributes', + install_dir : testdata_dir) ++ install_subdir('testsuite-23.units', ++ exclude_files : '.gitattributes', ++ install_dir : testdata_dir) + install_subdir('testsuite-28.units', + exclude_files : '.gitattributes', + install_dir : testdata_dir) +diff --git a/test/units/testsuite-23-binds-to.service b/test/testsuite-23.units/testsuite-23-binds-to.service +similarity index 100% +rename from test/units/testsuite-23-binds-to.service +rename to test/testsuite-23.units/testsuite-23-binds-to.service +diff --git a/test/units/testsuite-23-bound-by.service b/test/testsuite-23.units/testsuite-23-bound-by.service +similarity index 100% +rename from test/units/testsuite-23-bound-by.service +rename to test/testsuite-23.units/testsuite-23-bound-by.service +diff --git a/test/units/testsuite-23-fail.service b/test/testsuite-23.units/testsuite-23-fail.service +similarity index 100% +rename from test/units/testsuite-23-fail.service +rename to test/testsuite-23.units/testsuite-23-fail.service +diff --git a/test/units/testsuite-23-prop-stop-one.service b/test/testsuite-23.units/testsuite-23-prop-stop-one.service +similarity index 100% +rename from test/units/testsuite-23-prop-stop-one.service +rename to test/testsuite-23.units/testsuite-23-prop-stop-one.service +diff --git a/test/units/testsuite-23-prop-stop-two.service b/test/testsuite-23.units/testsuite-23-prop-stop-two.service +similarity index 100% +rename from test/units/testsuite-23-prop-stop-two.service +rename to test/testsuite-23.units/testsuite-23-prop-stop-two.service +diff --git a/test/units/testsuite-23-short-lived.service b/test/testsuite-23.units/testsuite-23-short-lived.service +similarity index 100% +rename from test/units/testsuite-23-short-lived.service +rename to test/testsuite-23.units/testsuite-23-short-lived.service +diff --git a/test/units/testsuite-23-success.service b/test/testsuite-23.units/testsuite-23-success.service +similarity index 100% +rename from test/units/testsuite-23-success.service +rename to test/testsuite-23.units/testsuite-23-success.service +diff --git a/test/units/testsuite-23-uphold.service b/test/testsuite-23.units/testsuite-23-uphold.service +similarity index 100% +rename from test/units/testsuite-23-uphold.service +rename to test/testsuite-23.units/testsuite-23-uphold.service diff --git a/SOURCES/0352-test-merge-TEST-47-ISSUE-14566-into-TEST-07-PID1.patch b/SOURCES/0352-test-merge-TEST-47-ISSUE-14566-into-TEST-07-PID1.patch new file mode 100644 index 0000000..75b31bd --- /dev/null +++ b/SOURCES/0352-test-merge-TEST-47-ISSUE-14566-into-TEST-07-PID1.patch @@ -0,0 +1,150 @@ +From da8a864aae13f8b54b0f8ba619a704c026e0f2d2 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 14:19:40 +0200 +Subject: [PATCH] test: merge TEST-47-ISSUE-14566 into TEST-07-PID1 + +(cherry picked from commit 11562ee585d5f2e42cb583f06aa01c7383d85f55) + +Related: #2213521 +--- + test/TEST-47-ISSUE-14566/Makefile | 1 - + test/TEST-47-ISSUE-14566/test.sh | 10 ------ + .../issue14566-repro.service} | 2 +- + .../issue14566-repro.sh} | 0 + test/units/testsuite-07.issue-14566.sh | 31 +++++++++++++++++++ + test/units/testsuite-47.service | 8 ----- + test/units/testsuite-47.sh | 25 --------------- + 7 files changed, 32 insertions(+), 45 deletions(-) + delete mode 120000 test/TEST-47-ISSUE-14566/Makefile + delete mode 100755 test/TEST-47-ISSUE-14566/test.sh + rename test/{units/testsuite-47-repro.service => testsuite-07.units/issue14566-repro.service} (66%) + rename test/{units/testsuite-47-repro.sh => testsuite-07.units/issue14566-repro.sh} (100%) + create mode 100755 test/units/testsuite-07.issue-14566.sh + delete mode 100644 test/units/testsuite-47.service + delete mode 100755 test/units/testsuite-47.sh + +diff --git a/test/TEST-47-ISSUE-14566/Makefile b/test/TEST-47-ISSUE-14566/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-47-ISSUE-14566/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-47-ISSUE-14566/test.sh b/test/TEST-47-ISSUE-14566/test.sh +deleted file mode 100755 +index 8bdbe14b97..0000000000 +--- a/test/TEST-47-ISSUE-14566/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="Test that KillMode=mixed does not leave left over processes with ExecStopPost=" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/units/testsuite-47-repro.service b/test/testsuite-07.units/issue14566-repro.service +similarity index 66% +rename from test/units/testsuite-47-repro.service +rename to test/testsuite-07.units/issue14566-repro.service +index 1508ac6242..56805963b4 100644 +--- a/test/units/testsuite-47-repro.service ++++ b/test/testsuite-07.units/issue14566-repro.service +@@ -3,6 +3,6 @@ + Description=Issue 14566 Repro + + [Service] +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh ++ExecStart=/usr/lib/systemd/tests/testdata/testsuite-07.units/%N.sh + ExecStopPost=/bin/true + KillMode=mixed +diff --git a/test/units/testsuite-47-repro.sh b/test/testsuite-07.units/issue14566-repro.sh +similarity index 100% +rename from test/units/testsuite-47-repro.sh +rename to test/testsuite-07.units/issue14566-repro.sh +diff --git a/test/units/testsuite-07.issue-14566.sh b/test/units/testsuite-07.issue-14566.sh +new file mode 100755 +index 0000000000..e17c3934c1 +--- /dev/null ++++ b/test/units/testsuite-07.issue-14566.sh +@@ -0,0 +1,31 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# Test that KillMode=mixed does not leave left over processes with ExecStopPost= ++# Issue: https://github.com/systemd/systemd/issues/14566 ++ ++if [[ -n "${ASAN_OPTIONS:-}" ]]; then ++ # Temporarily skip this test when running with sanitizers due to a deadlock ++ # See: https://bugzilla.redhat.com/show_bug.cgi?id=2098125 ++ echo "Sanitizers detected, skipping the test..." ++ exit 0 ++fi ++ ++systemd-analyze log-level debug ++ ++systemctl start issue14566-repro ++sleep 4 ++systemctl status issue14566-repro ++ ++leaked_pid=$(cat /leakedtestpid) ++ ++systemctl stop issue14566-repro ++sleep 4 ++ ++# Leaked PID will still be around if we're buggy. ++# I personally prefer to see 42. ++ps -p "$leaked_pid" && exit 42 ++ ++systemd-analyze log-level info +diff --git a/test/units/testsuite-47.service b/test/units/testsuite-47.service +deleted file mode 100644 +index d5ad480108..0000000000 +--- a/test/units/testsuite-47.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-47-ISSUE-14566 +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-47.sh b/test/units/testsuite-47.sh +deleted file mode 100755 +index 529e9617a5..0000000000 +--- a/test/units/testsuite-47.sh ++++ /dev/null +@@ -1,25 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -eux +-set -o pipefail +- +-systemd-analyze log-level debug +- +-systemctl start testsuite-47-repro +-sleep 4 +-systemctl status testsuite-47-repro +- +-leaked_pid=$(cat /leakedtestpid) +- +-systemctl stop testsuite-47-repro +-sleep 4 +- +-# Leaked PID will still be around if we're buggy. +-# I personally prefer to see 42. +-ps -p "$leaked_pid" && exit 42 +- +-systemd-analyze log-level info +- +-echo OK >/testok +- +-exit 0 diff --git a/SOURCES/0353-test-merge-TEST-51-ISSUE-16115-into-TEST-07-PID1.patch b/SOURCES/0353-test-merge-TEST-51-ISSUE-16115-into-TEST-07-PID1.patch new file mode 100644 index 0000000..02151b8 --- /dev/null +++ b/SOURCES/0353-test-merge-TEST-51-ISSUE-16115-into-TEST-07-PID1.patch @@ -0,0 +1,120 @@ +From 44a272e129174f72c4b150fec333011c4f9c7c69 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 14:26:08 +0200 +Subject: [PATCH] test: merge TEST-51-ISSUE-16115 into TEST-07-PID1 + +(cherry picked from commit d8d8380a35c494b6cb7ec5ee12dbe93002bd2f2f) + +Related: #2213521 +--- + test/TEST-51-ISSUE-16115/Makefile | 1 - + test/TEST-51-ISSUE-16115/test.sh | 10 ---------- + .../issue16115-repro-1.service} | 0 + .../issue16115-repro-2.service} | 0 + .../issue16115-repro-3.service} | 0 + test/units/testsuite-07.issue-16115.sh | 16 ++++++++++++++++ + test/units/testsuite-51.service | 8 -------- + test/units/testsuite-51.sh | 15 --------------- + 8 files changed, 16 insertions(+), 34 deletions(-) + delete mode 120000 test/TEST-51-ISSUE-16115/Makefile + delete mode 100755 test/TEST-51-ISSUE-16115/test.sh + rename test/{units/testsuite-51-repro-1.service => testsuite-07.units/issue16115-repro-1.service} (100%) + rename test/{units/testsuite-51-repro-2.service => testsuite-07.units/issue16115-repro-2.service} (100%) + rename test/{units/testsuite-51-repro-3.service => testsuite-07.units/issue16115-repro-3.service} (100%) + create mode 100755 test/units/testsuite-07.issue-16115.sh + delete mode 100644 test/units/testsuite-51.service + delete mode 100755 test/units/testsuite-51.sh + +diff --git a/test/TEST-51-ISSUE-16115/Makefile b/test/TEST-51-ISSUE-16115/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-51-ISSUE-16115/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-51-ISSUE-16115/test.sh b/test/TEST-51-ISSUE-16115/test.sh +deleted file mode 100755 +index 7b306fa57b..0000000000 +--- a/test/TEST-51-ISSUE-16115/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="Test ExecCondition= does not restart on abnormal or failure" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/units/testsuite-51-repro-1.service b/test/testsuite-07.units/issue16115-repro-1.service +similarity index 100% +rename from test/units/testsuite-51-repro-1.service +rename to test/testsuite-07.units/issue16115-repro-1.service +diff --git a/test/units/testsuite-51-repro-2.service b/test/testsuite-07.units/issue16115-repro-2.service +similarity index 100% +rename from test/units/testsuite-51-repro-2.service +rename to test/testsuite-07.units/issue16115-repro-2.service +diff --git a/test/units/testsuite-51-repro-3.service b/test/testsuite-07.units/issue16115-repro-3.service +similarity index 100% +rename from test/units/testsuite-51-repro-3.service +rename to test/testsuite-07.units/issue16115-repro-3.service +diff --git a/test/units/testsuite-07.issue-16115.sh b/test/units/testsuite-07.issue-16115.sh +new file mode 100755 +index 0000000000..8f638269cd +--- /dev/null ++++ b/test/units/testsuite-07.issue-16115.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++# Test ExecCondition= does not restart on abnormal or failure ++# Issue: https://github.com/systemd/systemd/issues/16115 ++ ++systemctl start issue16115-repro-1 ++systemctl start issue16115-repro-2 ++systemctl start issue16115-repro-3 ++sleep 5 # wait a bit in case there are restarts so we can count them below ++ ++[[ "$(systemctl show issue16115-repro-1 -P NRestarts)" == "0" ]] ++[[ "$(systemctl show issue16115-repro-2 -P NRestarts)" == "0" ]] ++[[ "$(systemctl show issue16115-repro-3 -P NRestarts)" == "0" ]] +diff --git a/test/units/testsuite-51.service b/test/units/testsuite-51.service +deleted file mode 100644 +index c241262c27..0000000000 +--- a/test/units/testsuite-51.service ++++ /dev/null +@@ -1,8 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-51-ISSUE-16115 +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +diff --git a/test/units/testsuite-51.sh b/test/units/testsuite-51.sh +deleted file mode 100755 +index e603d953a4..0000000000 +--- a/test/units/testsuite-51.sh ++++ /dev/null +@@ -1,15 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -eux +-set -o pipefail +- +-systemctl start testsuite-51-repro-1 +-systemctl start testsuite-51-repro-2 +-systemctl start testsuite-51-repro-3 +-sleep 5 # wait a bit in case there are restarts so we can count them below +- +-[[ "$(systemctl show testsuite-51-repro-1 -P NRestarts)" == "0" ]] +-[[ "$(systemctl show testsuite-51-repro-2 -P NRestarts)" == "0" ]] +-[[ "$(systemctl show testsuite-51-repro-3 -P NRestarts)" == "0" ]] +- +-touch /testok diff --git a/SOURCES/0354-test-merge-TEST-20-MAINPIDGAMES-into-TEST-07-PID1.patch b/SOURCES/0354-test-merge-TEST-20-MAINPIDGAMES-into-TEST-07-PID1.patch new file mode 100644 index 0000000..c3cb51f --- /dev/null +++ b/SOURCES/0354-test-merge-TEST-20-MAINPIDGAMES-into-TEST-07-PID1.patch @@ -0,0 +1,273 @@ +From 77827462f17ba6de2c56c7e242d1468f9c112cb3 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 20:17:19 +0200 +Subject: [PATCH] test: merge TEST-20-MAINPIDGAMES into TEST-07-PID1 + +(cherry picked from commit 3a4b86264eef6bd51e880386388e8b3f95cbaa33) + +Related: #2213521 +--- + test/TEST-20-MAINPIDGAMES/Makefile | 1 - + test/TEST-20-MAINPIDGAMES/test.sh | 10 --- + ...-20.sh => testsuite-07.main-PID-change.sh} | 90 +++++++++++-------- + test/units/testsuite-07.service | 1 + + test/units/testsuite-20.service | 11 --- + 5 files changed, 52 insertions(+), 61 deletions(-) + delete mode 120000 test/TEST-20-MAINPIDGAMES/Makefile + delete mode 100755 test/TEST-20-MAINPIDGAMES/test.sh + rename test/units/{testsuite-20.sh => testsuite-07.main-PID-change.sh} (55%) + delete mode 100644 test/units/testsuite-20.service + +diff --git a/test/TEST-20-MAINPIDGAMES/Makefile b/test/TEST-20-MAINPIDGAMES/Makefile +deleted file mode 120000 +index e9f93b1104..0000000000 +--- a/test/TEST-20-MAINPIDGAMES/Makefile ++++ /dev/null +@@ -1 +0,0 @@ +-../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-20-MAINPIDGAMES/test.sh b/test/TEST-20-MAINPIDGAMES/test.sh +deleted file mode 100755 +index b663201efb..0000000000 +--- a/test/TEST-20-MAINPIDGAMES/test.sh ++++ /dev/null +@@ -1,10 +0,0 @@ +-#!/usr/bin/env bash +-# SPDX-License-Identifier: LGPL-2.1-or-later +-set -e +- +-TEST_DESCRIPTION="test changing main PID" +- +-# shellcheck source=test/test-functions +-. "${TEST_BASE_DIR:?}/test-functions" +- +-do_test "$@" +diff --git a/test/units/testsuite-20.sh b/test/units/testsuite-07.main-PID-change.sh +similarity index 55% +rename from test/units/testsuite-20.sh +rename to test/units/testsuite-07.main-PID-change.sh +index 338769aacc..be4631f10d 100755 +--- a/test/units/testsuite-20.sh ++++ b/test/units/testsuite-07.main-PID-change.sh +@@ -3,9 +3,13 @@ + set -eux + set -o pipefail + ++# Test changing the main PID ++ + systemd-analyze log-level debug + +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++# The main service PID should be the parent bash process ++MAINPID="${PPID:?}" ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + + # Start a test process inside of our own cgroup + sleep infinity & +@@ -13,48 +17,48 @@ INTERNALPID=$! + disown + + # Start a test process outside of our own cgroup +-systemd-run -p DynamicUser=1 --unit=test20-sleep.service /bin/sleep infinity +-EXTERNALPID="$(systemctl show -P MainPID test20-sleep.service)" ++systemd-run -p DynamicUser=1 --unit=test-sleep.service /bin/sleep infinity ++EXTERNALPID="$(systemctl show -P MainPID test-sleep.service)" + + # Update our own main PID to the external test PID, this should work + systemd-notify MAINPID="$EXTERNALPID" +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq "$EXTERNALPID" ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$EXTERNALPID" + + # Update our own main PID to the internal test PID, this should work, too + systemd-notify MAINPID=$INTERNALPID +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq "$INTERNALPID" ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$INTERNALPID" + + # Update it back to our own PID, this should also work +-systemd-notify MAINPID=$$ +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++systemd-notify MAINPID="$MAINPID" ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + + # Try to set it to PID 1, which it should ignore, because that's the manager + systemd-notify MAINPID=1 +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + + # Try to set it to PID 0, which is invalid and should be ignored + systemd-notify MAINPID=0 +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + + # Try to set it to a valid but non-existing PID, which should be ignored. (Note + # that we set the PID to a value well above any known /proc/sys/kernel/pid_max, + # which means we can be pretty sure it doesn't exist by coincidence) + systemd-notify MAINPID=1073741824 +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + + # Change it again to the external PID, without privileges this time. This should be ignored, because the PID is from outside of our cgroup and we lack privileges. + systemd-notify --uid=1000 MAINPID="$EXTERNALPID" +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + + # Change it again to the internal PID, without privileges this time. This should work, as the process is on our cgroup, and that's enough even if we lack privileges. + systemd-notify --uid=1000 MAINPID="$INTERNALPID" +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq "$INTERNALPID" ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$INTERNALPID" + + # Update it back to our own PID, this should also work +-systemd-notify --uid=1000 MAINPID=$$ +-test "$(systemctl show -P MainPID testsuite-20.service)" -eq $$ ++systemd-notify --uid=1000 MAINPID="$MAINPID" ++test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID" + +-cat >/tmp/test20-mainpid.sh </tmp/test-mainpid.sh <<\EOF + #!/usr/bin/env bash + + set -eux +@@ -65,20 +69,26 @@ sleep infinity & + disown + + sleep infinity & +-MAINPID=\$! ++MAINPID=$! + disown + + sleep infinity & + disown + +-echo \$MAINPID >/run/mainpidsh/pid ++echo $MAINPID >/run/mainpidsh/pid + EOF +-chmod +x /tmp/test20-mainpid.sh ++chmod +x /tmp/test-mainpid.sh + +-systemd-run --unit=test20-mainpidsh.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh -p PIDFile=/run/mainpidsh/pid /tmp/test20-mainpid.sh +-test "$(systemctl show -P MainPID test20-mainpidsh.service)" -eq "$(cat /run/mainpidsh/pid)" ++systemd-run --unit=test-mainpidsh.service \ ++ -p StandardOutput=tty \ ++ -p StandardError=tty \ ++ -p Type=forking \ ++ -p RuntimeDirectory=mainpidsh \ ++ -p PIDFile=/run/mainpidsh/pid \ ++ /tmp/test-mainpid.sh ++test "$(systemctl show -P MainPID test-mainpidsh.service)" -eq "$(cat /run/mainpidsh/pid)" + +-cat >/tmp/test20-mainpid2.sh </tmp/test-mainpid2.sh <<\EOF + #!/usr/bin/env bash + + set -eux +@@ -89,21 +99,27 @@ sleep infinity & + disown + + sleep infinity & +-MAINPID=\$! ++MAINPID=$! + disown + + sleep infinity & + disown + +-echo \$MAINPID >/run/mainpidsh2/pid ++echo $MAINPID >/run/mainpidsh2/pid + chown 1001:1001 /run/mainpidsh2/pid + EOF +-chmod +x /tmp/test20-mainpid2.sh ++chmod +x /tmp/test-mainpid2.sh + +-systemd-run --unit=test20-mainpidsh2.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh2 -p PIDFile=/run/mainpidsh2/pid /tmp/test20-mainpid2.sh +-test "$(systemctl show -P MainPID test20-mainpidsh2.service)" -eq "$(cat /run/mainpidsh2/pid)" ++systemd-run --unit=test-mainpidsh2.service \ ++ -p StandardOutput=tty \ ++ -p StandardError=tty \ ++ -p Type=forking \ ++ -p RuntimeDirectory=mainpidsh2 \ ++ -p PIDFile=/run/mainpidsh2/pid \ ++ /tmp/test-mainpid2.sh ++test "$(systemctl show -P MainPID test-mainpidsh2.service)" -eq "$(cat /run/mainpidsh2/pid)" + +-cat >/dev/shm/test20-mainpid3.sh </dev/shm/test-mainpid3.sh </testok +- +-exit 0 +diff --git a/test/units/testsuite-07.service b/test/units/testsuite-07.service +index f45b9c7c5b..cc0a747a88 100644 +--- a/test/units/testsuite-07.service ++++ b/test/units/testsuite-07.service +@@ -6,6 +6,7 @@ Description=TEST-07-ISSUE-1981 + Type=oneshot + ExecStartPre=rm -f /failed /testok + ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh ++NotifyAccess=all + # Issue: https://github.com/systemd/systemd/issues/2691 + ExecStop=sh -c 'kill -SEGV $$$$' + RemainAfterExit=yes +diff --git a/test/units/testsuite-20.service b/test/units/testsuite-20.service +deleted file mode 100644 +index 4228d0b875..0000000000 +--- a/test/units/testsuite-20.service ++++ /dev/null +@@ -1,11 +0,0 @@ +-# SPDX-License-Identifier: LGPL-2.1-or-later +-[Unit] +-Description=TEST-20-MAINPIDGAMES +-Before=getty-pre.target +-Wants=getty-pre.target +- +-[Service] +-ExecStartPre=rm -f /failed /testok +-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +-Type=oneshot +-NotifyAccess=all diff --git a/SOURCES/0355-test-abstract-the-common-test-parts-into-a-utility-s.patch b/SOURCES/0355-test-abstract-the-common-test-parts-into-a-utility-s.patch new file mode 100644 index 0000000..65b3578 --- /dev/null +++ b/SOURCES/0355-test-abstract-the-common-test-parts-into-a-utility-s.patch @@ -0,0 +1,312 @@ +From 47664038ed253f30518f434fb2967286c9382e7f Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 10 May 2023 21:12:01 +0200 +Subject: [PATCH] test: abstract the common test parts into a utility script + +Also, instead of bailing out on the first failed subtest, always run all +subtests and print a summary at the end (with an appropriate exit code). + +(cherry picked from commit 15bbc0c1071c439d83e711ef7786d401b6c0a0d4) + +Related: #2213521 +--- + test/units/test-control.sh | 126 +++++++++++++++++++++++++++++++++++++ + test/units/testsuite-07.sh | 8 +-- + test/units/testsuite-17.sh | 7 ++- + test/units/testsuite-22.sh | 7 ++- + test/units/testsuite-23.sh | 59 ++--------------- + test/units/testsuite-74.sh | 8 +-- + 6 files changed, 146 insertions(+), 69 deletions(-) + create mode 100644 test/units/test-control.sh + +diff --git a/test/units/test-control.sh b/test/units/test-control.sh +new file mode 100644 +index 0000000000..dd28939cbf +--- /dev/null ++++ b/test/units/test-control.sh +@@ -0,0 +1,126 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++# shellcheck shell=bash ++ ++if [[ "${BASH_SOURCE[0]}" -ef "$0" ]]; then ++ echo >&2 "This file should not be executed directly" ++ exit 1 ++fi ++ ++declare -i CHILD_PID=0 ++PASSED_TESTS=() ++FAILED_TESTS=() ++ ++# Like trap, but passes the signal name as the first argument ++trap_with_sig() { ++ local fun="${1:?}" ++ local sig ++ shift ++ ++ for sig in "$@"; do ++ # shellcheck disable=SC2064 ++ trap "$fun $sig" "$sig" ++ done ++} ++ ++# Propagate the caught signal to the current child process ++handle_signal() { ++ local sig="${1:?}" ++ ++ if [[ $CHILD_PID -gt 0 ]]; then ++ echo "Propagating signal $sig to child process $CHILD_PID" ++ kill -s "$sig" "$CHILD_PID" ++ fi ++} ++ ++# In order to make the handle_signal() stuff above work, we have to execute ++# each script asynchronously, since bash won't execute traps until the currently ++# executed command finishes. This, however, introduces another issue regarding ++# how bash's wait works. Quoting: ++# ++# When bash is waiting for an asynchronous command via the wait builtin, ++# the reception of a signal for which a trap has been set will cause the wait ++# builtin to return immediately with an exit status greater than 128, ++# immediately after which the trap is executed. ++# ++# In other words - every time we propagate a signal, wait returns with ++# 128+signal, so we have to wait again - repeat until the process dies. ++wait_harder() { ++ local pid="${1:?}" ++ ++ while kill -0 "$pid" &>/dev/null; do ++ wait "$pid" || : ++ done ++ ++ wait "$pid" ++} ++ ++# Like run_subtests, but propagate specified signals to the subtest script ++run_subtests_with_signals() { ++ local subtests=("${0%.sh}".*.sh) ++ local subtest ++ ++ if [[ "${#subtests[@]}" -eq 0 ]]; then ++ echo >&2 "No subtests found for file $0" ++ exit 1 ++ fi ++ ++ if [[ "$#" -eq 0 ]]; then ++ echo >&2 "No signals to propagate were specified" ++ exit 1 ++ fi ++ ++ trap_with_sig handle_signal "$@" ++ ++ for subtest in "${subtests[@]}"; do ++ : "--- $subtest BEGIN ---" ++ "./$subtest" & ++ CHILD_PID=$! ++ wait_harder "$CHILD_PID" && PASSED_TESTS+=("$subtest") || FAILED_TESTS+=("$subtest") ++ : "--- $subtest END ---" ++ done ++ ++ show_summary ++} ++ ++run_subtests() { ++ local subtests=("${0%.sh}".*.sh) ++ local subtest ++ ++ if [[ "${#subtests[@]}" -eq 0 ]]; then ++ echo >&2 "No subtests found for file $0" ++ exit 1 ++ fi ++ ++ for subtest in "${subtests[@]}"; do ++ : "--- $subtest BEGIN ---" ++ "./$subtest" && PASSED_TESTS+=("$subtest") || FAILED_TESTS+=("$subtest") ++ : "--- $subtest END ---" ++ done ++ ++ show_summary ++} ++ ++show_summary() {( ++ set +x ++ ++ if [[ ${#PASSED_TESTS[@]} -eq 0 && ${#FAILED_TESTS[@]} -eq 0 ]]; then ++ echo >&2 "No tests were executed, this is most likely an error" ++ exit 1 ++ fi ++ ++ printf "PASSED TESTS: %3d:\n" "${#PASSED_TESTS[@]}" ++ echo "------------------" ++ for t in "${PASSED_TESTS[@]}"; do ++ echo "$t" ++ done ++ ++ if [[ "${#FAILED_TESTS[@]}" -ne 0 ]]; then ++ printf "FAILED TESTS: %3d:\n" "${#FAILED_TESTS[@]}" ++ echo "------------------" ++ for t in "${FAILED_TESTS[@]}"; do ++ echo "$t" ++ done ++ fi ++ ++ [[ "${#FAILED_TESTS[@]}" -eq 0 ]] ++)} +diff --git a/test/units/testsuite-07.sh b/test/units/testsuite-07.sh +index 8c004a72e5..58d278e1f1 100755 +--- a/test/units/testsuite-07.sh ++++ b/test/units/testsuite-07.sh +@@ -3,16 +3,16 @@ + set -eux + set -o pipefail + ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/test-control.sh ++ + : >/failed + + # Issue: https://github.com/systemd/systemd/issues/2730 + # See TEST-07-PID1/test.sh for the first "half" of the test + mountpoint /issue2730 + +-for script in "${0%.sh}".*.sh; do +- echo "Running $script" +- "./$script" +-done ++run_subtests + + touch /testok + rm /failed +diff --git a/test/units/testsuite-17.sh b/test/units/testsuite-17.sh +index b389875ef1..72040f69d8 100755 +--- a/test/units/testsuite-17.sh ++++ b/test/units/testsuite-17.sh +@@ -3,13 +3,14 @@ + set -eux + set -o pipefail + ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/test-control.sh ++ + : >/failed + + udevadm settle + +-for t in "${0%.sh}".*.sh; do +- echo "Running $t"; ./"$t" +-done ++run_subtests + + touch /testok + rm /failed +diff --git a/test/units/testsuite-22.sh b/test/units/testsuite-22.sh +index 43823f1d46..5a07e7b78c 100755 +--- a/test/units/testsuite-22.sh ++++ b/test/units/testsuite-22.sh +@@ -3,11 +3,12 @@ + set -eux + set -o pipefail + ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/test-control.sh ++ + : >/failed + +-for t in "${0%.sh}".*.sh; do +- echo "Running $t"; ./"$t" +-done ++run_subtests + + touch /testok + rm /failed +diff --git a/test/units/testsuite-23.sh b/test/units/testsuite-23.sh +index a6b8da34c9..3be645e20a 100755 +--- a/test/units/testsuite-23.sh ++++ b/test/units/testsuite-23.sh +@@ -5,62 +5,11 @@ set -o pipefail + + : >/failed + +-declare -i CHILD_PID=0 ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/test-control.sh + +-# Note: all the signal shenanigans are necessary for the Upholds= tests +- +-# Like trap, but passes the signal name as the first argument +-trap_with_sig() { +- local fun="${1:?}" +- local sig +- shift +- +- for sig in "$@"; do +- # shellcheck disable=SC2064 +- trap "$fun $sig" "$sig" +- done +-} +- +-# Propagate the caught signal to the current child process +-handle_signal() { +- local sig="${1:?}" +- +- if [[ $CHILD_PID -gt 0 ]]; then +- echo "Propagating signal $sig to child process $CHILD_PID" +- kill -s "$sig" "$CHILD_PID" +- fi +-} +- +-# In order to make the handle_signal() stuff above work, we have to execute +-# each script asynchronously, since bash won't execute traps until the currently +-# executed command finishes. This, however, introduces another issue regarding +-# how bash's wait works. Quoting: +-# +-# When bash is waiting for an asynchronous command via the wait builtin, +-# the reception of a signal for which a trap has been set will cause the wait +-# builtin to return immediately with an exit status greater than 128, +-# immediately after which the trap is executed. +-# +-# In other words - every time we propagate a signal, wait returns with +-# 128+signal, so we have to wait again - repeat until the process dies. +-wait_harder() { +- local pid="${1:?}" +- +- while kill -0 "$pid"; do +- wait "$pid" || : +- done +- +- wait "$pid" +-} +- +-trap_with_sig handle_signal SIGUSR1 SIGUSR2 SIGRTMIN+1 +- +-for script in "${0%.sh}".*.sh; do +- echo "Running $script" +- "./$script" & +- CHILD_PID=$! +- wait_harder "$CHILD_PID" +-done ++# Note: the signal shenanigans are necessary for the Upholds= tests ++run_subtests_with_signals SIGUSR1 SIGUSR2 SIGRTMIN+1 + + touch /testok + rm /failed +diff --git a/test/units/testsuite-74.sh b/test/units/testsuite-74.sh +index 13c767e490..5a07e7b78c 100755 +--- a/test/units/testsuite-74.sh ++++ b/test/units/testsuite-74.sh +@@ -3,12 +3,12 @@ + set -eux + set -o pipefail + ++# shellcheck source=test/units/test-control.sh ++. "$(dirname "$0")"/test-control.sh ++ + : >/failed + +-for script in "${0%.sh}".*.sh; do +- echo "Running $script" +- "./$script" +-done ++run_subtests + + touch /testok + rm /failed diff --git a/SOURCES/0356-test-add-tests-for-JoinsNamespaceOf.patch b/SOURCES/0356-test-add-tests-for-JoinsNamespaceOf.patch new file mode 100644 index 0000000..a35d2c2 --- /dev/null +++ b/SOURCES/0356-test-add-tests-for-JoinsNamespaceOf.patch @@ -0,0 +1,208 @@ +From c8d082c62be5c14f74270739144bc8e49360ba47 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 25 May 2023 06:48:16 +0900 +Subject: [PATCH] test: add tests for JoinsNamespaceOf= + +To illustrate the current behavior of the dependency. + +(cherry picked from commit 8493a82d0bd5915eb951512cff5e570c43386283) + +Related: #2213521 +--- + .../testsuite-23-joins-namespace-of-1.service | 7 +++++ + .../testsuite-23-joins-namespace-of-2.service | 10 ++++++ + .../testsuite-23-joins-namespace-of-3.service | 10 ++++++ + .../testsuite-23-joins-namespace-of-4.service | 10 ++++++ + .../testsuite-23-joins-namespace-of-5.service | 6 ++++ + .../testsuite-23-joins-namespace-of-6.service | 10 ++++++ + .../testsuite-23-joins-namespace-of-7.service | 11 +++++++ + .../testsuite-23-joins-namespace-of-8.service | 9 ++++++ + .../testsuite-23-joins-namespace-of-9.service | 11 +++++++ + test/units/testsuite-23.JoinsNamespaceOf.sh | 31 +++++++++++++++++++ + 10 files changed, 115 insertions(+) + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-1.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-2.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-3.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-4.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-6.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service + create mode 100644 test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service + create mode 100755 test/units/testsuite-23.JoinsNamespaceOf.sh + +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-1.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-1.service +new file mode 100644 +index 0000000000..9919a9fa82 +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-1.service +@@ -0,0 +1,7 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Service] ++Type=notify ++NotifyAccess=all ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=/bin/bash -c 'touch /tmp/shared-private-file && systemd-notify --ready && sleep infinity' +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-2.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-2.service +new file mode 100644 +index 0000000000..36b4c272fd +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-2.service +@@ -0,0 +1,10 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++JoinsNamespaceOf=testsuite-23-joins-namespace-of-1.service ++ ++[Service] ++Type=oneshot ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=test -e /tmp/shared-private-file ++ExecStart=touch /tmp/hoge +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-3.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-3.service +new file mode 100644 +index 0000000000..9094445020 +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-3.service +@@ -0,0 +1,10 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++JoinsNamespaceOf=testsuite-23-joins-namespace-of-1.service ++ ++[Service] ++Type=oneshot ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=test -e /tmp/shared-private-file ++ExecStart=test -e /tmp/hoge +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-4.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-4.service +new file mode 100644 +index 0000000000..5e823a1778 +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-4.service +@@ -0,0 +1,10 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++JoinsNamespaceOf=testsuite-23-joins-namespace-of-5.service ++ ++[Service] ++Type=notify ++NotifyAccess=all ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=/bin/bash -c 'touch /tmp/shared-private-file && systemd-notify --ready && sleep infinity' +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service +new file mode 100644 +index 0000000000..80594ccba2 +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service +@@ -0,0 +1,6 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Service] ++Type=oneshot ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=test ! -e /tmp/shared-private-file +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-6.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-6.service +new file mode 100644 +index 0000000000..bbbfd7c67d +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-6.service +@@ -0,0 +1,10 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service ++ ++[Service] ++Type=notify ++NotifyAccess=all ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=/bin/bash -c 'touch /tmp/shared-private-file-x && systemd-notify --ready && sleep infinity' +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service +new file mode 100644 +index 0000000000..6c7bbdb097 +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service +@@ -0,0 +1,11 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service ++ ++[Service] ++Type=oneshot ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=test ! -e /tmp/shared-private-file-x ++ExecStart=test ! -e /tmp/shared-private-file-y ++ExecStart=touch /tmp/hoge +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service +new file mode 100644 +index 0000000000..f3ec0668de +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service +@@ -0,0 +1,9 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Service] ++Type=notify ++NotifyAccess=all ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStartPre=test ! -e /tmp/shared-private-file-x ++ExecStartPre=test ! -e /tmp/hoge ++ExecStart=/bin/bash -c 'touch /tmp/shared-private-file-y && systemd-notify --ready && sleep infinity' +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service +new file mode 100644 +index 0000000000..01de7f9054 +--- /dev/null ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service +@@ -0,0 +1,11 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++[Unit] ++JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service ++ ++[Service] ++Type=oneshot ++MountAPIVFS=yes ++PrivateTmp=yes ++ExecStart=test ! -e /tmp/shared-private-file-x ++ExecStart=test -e /tmp/shared-private-file-y ++ExecStart=test ! -e /tmp/hoge +diff --git a/test/units/testsuite-23.JoinsNamespaceOf.sh b/test/units/testsuite-23.JoinsNamespaceOf.sh +new file mode 100755 +index 0000000000..68ba465072 +--- /dev/null ++++ b/test/units/testsuite-23.JoinsNamespaceOf.sh +@@ -0,0 +1,31 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++ ++set -eux ++set -o pipefail ++ ++# Test JoinsNamespaceOf= with PrivateTmp=yes ++ ++systemd-analyze log-level debug ++systemd-analyze log-target journal ++ ++# simple case ++systemctl start testsuite-23-joins-namespace-of-1.service ++systemctl start testsuite-23-joins-namespace-of-2.service ++systemctl start testsuite-23-joins-namespace-of-3.service ++systemctl stop testsuite-23-joins-namespace-of-1.service ++ ++# inverse dependency ++systemctl start testsuite-23-joins-namespace-of-4.service ++systemctl start testsuite-23-joins-namespace-of-5.service ++systemctl stop testsuite-23-joins-namespace-of-4.service ++ ++# transitive dependency ++systemctl start testsuite-23-joins-namespace-of-6.service ++systemctl start testsuite-23-joins-namespace-of-7.service ++systemctl start testsuite-23-joins-namespace-of-8.service ++systemctl start testsuite-23-joins-namespace-of-9.service ++systemctl stop testsuite-23-joins-namespace-of-6.service ++systemctl stop testsuite-23-joins-namespace-of-8.service ++ ++systemd-analyze log-level info diff --git a/SOURCES/0357-core-unit-drop-doubled-empty-line.patch b/SOURCES/0357-core-unit-drop-doubled-empty-line.patch new file mode 100644 index 0000000..29a3df5 --- /dev/null +++ b/SOURCES/0357-core-unit-drop-doubled-empty-line.patch @@ -0,0 +1,24 @@ +From bb6af3b07f6ef66d193bdee0345cc2b3a782e8b3 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Tue, 23 May 2023 06:03:52 +0900 +Subject: [PATCH] core/unit: drop doubled empty line + +(cherry picked from commit 512df9de23890fcfd5fdbfe633250fe848195d4b) + +Related: #2213521 +--- + src/core/unit.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/core/unit.c b/src/core/unit.c +index 0d1a590a3f..0faf66413b 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -987,7 +987,6 @@ static int unit_per_dependency_type_hashmap_update( + if (r < 0) + return r; + +- + return 1; + } + diff --git a/SOURCES/0358-core-unit-make-JoinsNamespaceOf-implies-the-inverse-.patch b/SOURCES/0358-core-unit-make-JoinsNamespaceOf-implies-the-inverse-.patch new file mode 100644 index 0000000..d5c7939 --- /dev/null +++ b/SOURCES/0358-core-unit-make-JoinsNamespaceOf-implies-the-inverse-.patch @@ -0,0 +1,113 @@ +From 096cfb2903d48b115e417010767388ff5c49b282 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Tue, 23 May 2023 06:36:44 +0900 +Subject: [PATCH] core/unit: make JoinsNamespaceOf= implies the inverse + dependency + +Previously, even if a.service has JoinsNamespaceOf=b.service, the +inverse direction of reference was not introduced. +Hence, a.service is started earlier than b.service, the namespace will +not shared with b.service. +Also, even if a.service had the reference to b.service, b.service did not. +If b.service is freed earlier, then unit_clear_dependencies() does not clear +the reference from a to b, and will cause use-after-free on unit_free() for +a.service. + +Let's make JoinsNamespaceOf=b.service in a.service implies the inverse +dependency, i.e. JoinsNamespaceOf=a.service for b.service. Then, we can safely +free b.service. + +(cherry picked from commit a60f96fcf55c3452e5b13d6daec537af1909eda3) + +Related: #2213521 +--- + man/systemd.unit.xml | 12 +++++++----- + src/core/unit.c | 11 +++++------ + .../testsuite-23-joins-namespace-of-5.service | 2 +- + .../testsuite-23-joins-namespace-of-8.service | 2 +- + .../testsuite-23-joins-namespace-of-9.service | 2 +- + 5 files changed, 15 insertions(+), 14 deletions(-) + +diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml +index 8e1a3464df..d41909bcc6 100644 +--- a/man/systemd.unit.xml ++++ b/man/systemd.unit.xml +@@ -858,16 +858,18 @@ + JoinsNamespaceOf= + + For units that start processes (such as service units), lists one or more other units +- whose network and/or temporary file namespace to join. This only applies to unit types which support +- the PrivateNetwork=, NetworkNamespacePath=, ++ whose network and/or temporary file namespace to join. If this is specified on a unit (say, a.service ++ has JoinsNamespaceOf=b.service), then this the inverse dependency ++ (JoinsNamespaceOf=a.service for b.service) is implied. This only applies to unit ++ types which support the PrivateNetwork=, NetworkNamespacePath=, + PrivateIPC=, IPCNamespacePath=, and + PrivateTmp= directives (see + systemd.exec5 for + details). If a unit that has this setting set is started, its processes will see the same + /tmp/, /var/tmp/, IPC namespace and network namespace as +- one listed unit that is started. If multiple listed units are already started, it is not defined +- which namespace is joined. Note that this setting only has an effect if +- PrivateNetwork=/NetworkNamespacePath=, ++ one listed unit that is started. If multiple listed units are already started and these do not share ++ their namespace, then it is not defined which namespace is joined. Note that this setting only has an ++ effect if PrivateNetwork=/NetworkNamespacePath=, + PrivateIPC=/IPCNamespacePath= and/or + PrivateTmp= is enabled for both the unit that joins the namespace and the unit + whose namespace is joined. +diff --git a/src/core/unit.c b/src/core/unit.c +index 0faf66413b..8b66139ad9 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -3108,12 +3108,11 @@ int unit_add_dependency( + return r; + notify = r > 0; + +- if (inverse_table[d] != _UNIT_DEPENDENCY_INVALID && inverse_table[d] != d) { +- r = unit_add_dependency_hashmap(&other->dependencies, inverse_table[d], u, 0, mask); +- if (r < 0) +- return r; +- notify_other = r > 0; +- } ++ assert(inverse_table[d] >= 0 && inverse_table[d] < _UNIT_DEPENDENCY_MAX); ++ r = unit_add_dependency_hashmap(&other->dependencies, inverse_table[d], u, 0, mask); ++ if (r < 0) ++ return r; ++ notify_other = r > 0; + + if (add_reference) { + r = unit_add_dependency_hashmap(&u->dependencies, UNIT_REFERENCES, other, mask, 0); +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service +index 80594ccba2..c3d316bfa2 100644 +--- a/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service +@@ -3,4 +3,4 @@ + Type=oneshot + MountAPIVFS=yes + PrivateTmp=yes +-ExecStart=test ! -e /tmp/shared-private-file ++ExecStart=test -e /tmp/shared-private-file +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service +index f3ec0668de..42053b99f8 100644 +--- a/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service +@@ -4,6 +4,6 @@ Type=notify + NotifyAccess=all + MountAPIVFS=yes + PrivateTmp=yes +-ExecStartPre=test ! -e /tmp/shared-private-file-x ++ExecStartPre=test -e /tmp/shared-private-file-x + ExecStartPre=test ! -e /tmp/hoge + ExecStart=/bin/bash -c 'touch /tmp/shared-private-file-y && systemd-notify --ready && sleep infinity' +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service +index 01de7f9054..a50a7fcdc2 100644 +--- a/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service +@@ -7,5 +7,5 @@ Type=oneshot + MountAPIVFS=yes + PrivateTmp=yes + ExecStart=test ! -e /tmp/shared-private-file-x +-ExecStart=test -e /tmp/shared-private-file-y ++ExecStart=test ! -e /tmp/shared-private-file-y + ExecStart=test ! -e /tmp/hoge diff --git a/SOURCES/0359-core-unit-search-shared-namespace-in-transitive-rela.patch b/SOURCES/0359-core-unit-search-shared-namespace-in-transitive-rela.patch new file mode 100644 index 0000000..7d5813a --- /dev/null +++ b/SOURCES/0359-core-unit-search-shared-namespace-in-transitive-rela.patch @@ -0,0 +1,140 @@ +From 7ce47c0fc8b624d08f238f5ef364275ec8a791f5 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 25 May 2023 18:08:37 +0900 +Subject: [PATCH] core/unit: search shared namespace in transitive relation of + JoinsNamespaceOf= + +Previously, dependency chain of JoinsNamespaceOf= did not work, e.g. +- a.service has JoinsNamespaceOf=b.service +- b.service has JoinsNamespaceOf=c.service +if, first c.service, next a.service, finally b.service is started, +then a.service is not joined to the namespace of c.service. And, as +mentioned in the document, the namespace used by b.service is not +deterministic. + +This makes when searching exsiting namespace to be joined, all units in +the transitive dependency of JoinsNamespaceOf= are checked. + +(cherry picked from commit 83123a44989c095f9b7a89841db9917417fc451a) + +Related: #2213521 +--- + src/core/unit.c | 36 ++++++++++++++++++- + src/core/unit.h | 1 + + .../testsuite-23-joins-namespace-of-7.service | 2 +- + .../testsuite-23-joins-namespace-of-8.service | 2 +- + .../testsuite-23-joins-namespace-of-9.service | 6 ++-- + 5 files changed, 41 insertions(+), 6 deletions(-) + +diff --git a/src/core/unit.c b/src/core/unit.c +index 8b66139ad9..6acc63e091 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -4718,6 +4718,7 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask) + } + + int unit_setup_exec_runtime(Unit *u) { ++ _cleanup_set_free_ Set *units = NULL; + ExecRuntime **rt; + size_t offset; + Unit *other; +@@ -4731,9 +4732,15 @@ int unit_setup_exec_runtime(Unit *u) { + if (*rt) + return 0; + ++ r = unit_get_transitive_dependency_set(u, UNIT_ATOM_JOINS_NAMESPACE_OF, &units); ++ if (r < 0) ++ return r; ++ + /* Try to get it from somebody else */ +- UNIT_FOREACH_DEPENDENCY(other, u, UNIT_ATOM_JOINS_NAMESPACE_OF) { ++ SET_FOREACH(other, units) { + r = exec_runtime_acquire(u->manager, NULL, other->id, false, rt); ++ if (r < 0) ++ return r; + if (r == 1) + return 1; + } +@@ -5921,6 +5928,33 @@ int unit_get_dependency_array(const Unit *u, UnitDependencyAtom atom, Unit ***re + return (int) n; + } + ++int unit_get_transitive_dependency_set(Unit *u, UnitDependencyAtom atom, Set **ret) { ++ _cleanup_set_free_ Set *units = NULL, *queue = NULL; ++ Unit *other; ++ int r; ++ ++ assert(u); ++ assert(ret); ++ ++ /* Similar to unit_get_dependency_array(), but also search the same dependency in other units. */ ++ ++ do { ++ UNIT_FOREACH_DEPENDENCY(other, u, atom) { ++ r = set_ensure_put(&units, NULL, other); ++ if (r < 0) ++ return r; ++ if (r == 0) ++ continue; ++ r = set_ensure_put(&queue, NULL, other); ++ if (r < 0) ++ return r; ++ } ++ } while ((u = set_steal_first(queue))); ++ ++ *ret = TAKE_PTR(units); ++ return 0; ++} ++ + const ActivationDetailsVTable * const activation_details_vtable[_UNIT_TYPE_MAX] = { + [UNIT_PATH] = &activation_details_path_vtable, + [UNIT_TIMER] = &activation_details_timer_vtable, +diff --git a/src/core/unit.h b/src/core/unit.h +index 3bc7de3d1c..e79b5322b4 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -805,6 +805,7 @@ static inline const UnitVTable* UNIT_VTABLE(const Unit *u) { + + Unit* unit_has_dependency(const Unit *u, UnitDependencyAtom atom, Unit *other); + int unit_get_dependency_array(const Unit *u, UnitDependencyAtom atom, Unit ***ret_array); ++int unit_get_transitive_dependency_set(Unit *u, UnitDependencyAtom atom, Set **ret); + + static inline Hashmap* unit_get_dependencies(Unit *u, UnitDependency d) { + return hashmap_get(u->dependencies, UNIT_DEPENDENCY_TO_PTR(d)); +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service +index 6c7bbdb097..60c083a3f4 100644 +--- a/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-7.service +@@ -6,6 +6,6 @@ JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service + Type=oneshot + MountAPIVFS=yes + PrivateTmp=yes +-ExecStart=test ! -e /tmp/shared-private-file-x ++ExecStart=test -e /tmp/shared-private-file-x + ExecStart=test ! -e /tmp/shared-private-file-y + ExecStart=touch /tmp/hoge +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service +index 42053b99f8..dac1cea7bd 100644 +--- a/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service +@@ -5,5 +5,5 @@ NotifyAccess=all + MountAPIVFS=yes + PrivateTmp=yes + ExecStartPre=test -e /tmp/shared-private-file-x +-ExecStartPre=test ! -e /tmp/hoge ++ExecStartPre=test -e /tmp/hoge + ExecStart=/bin/bash -c 'touch /tmp/shared-private-file-y && systemd-notify --ready && sleep infinity' +diff --git a/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service b/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service +index a50a7fcdc2..6c64873b24 100644 +--- a/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service ++++ b/test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service +@@ -6,6 +6,6 @@ JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service + Type=oneshot + MountAPIVFS=yes + PrivateTmp=yes +-ExecStart=test ! -e /tmp/shared-private-file-x +-ExecStart=test ! -e /tmp/shared-private-file-y +-ExecStart=test ! -e /tmp/hoge ++ExecStart=test -e /tmp/shared-private-file-x ++ExecStart=test -e /tmp/shared-private-file-y ++ExecStart=test -e /tmp/hoge diff --git a/SOURCES/0360-core-unit-update-bidirectional-dependency-simultaneo.patch b/SOURCES/0360-core-unit-update-bidirectional-dependency-simultaneo.patch new file mode 100644 index 0000000..da6b616 --- /dev/null +++ b/SOURCES/0360-core-unit-update-bidirectional-dependency-simultaneo.patch @@ -0,0 +1,236 @@ +From 08c48bbe717a0be0f8c41a4652473d8483e0fbde Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Tue, 23 May 2023 17:49:16 +0900 +Subject: [PATCH] core/unit: update bidirectional dependency simultaneously + +Previously, if unit_add_dependency_hashmap() failed, then a +one-directional unit dependency reference might be created, and +triggeres use-after-free. See issue #27742 for more details. + +This makes unit dependency always bidirectional, and cleanly revert +partial update on failure. + +Fixes #27742. + +(cherry picked from commit 831108245eb757f41fe0ebbccf1b42c9dd0ce297) + +Resolves: #2213521 +--- + src/core/unit.c | 164 ++++++++++++++++++++++++++++++------------------ + 1 file changed, 103 insertions(+), 61 deletions(-) + +diff --git a/src/core/unit.c b/src/core/unit.c +index 6acc63e091..438213a47a 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -990,46 +990,6 @@ static int unit_per_dependency_type_hashmap_update( + return 1; + } + +-static int unit_add_dependency_hashmap( +- Hashmap **dependencies, +- UnitDependency d, +- Unit *other, +- UnitDependencyMask origin_mask, +- UnitDependencyMask destination_mask) { +- +- Hashmap *per_type; +- int r; +- +- assert(dependencies); +- assert(other); +- assert(origin_mask < _UNIT_DEPENDENCY_MASK_FULL); +- assert(destination_mask < _UNIT_DEPENDENCY_MASK_FULL); +- assert(origin_mask > 0 || destination_mask > 0); +- +- /* Ensure the top-level dependency hashmap exists that maps UnitDependency → Hashmap(Unit* → +- * UnitDependencyInfo) */ +- r = hashmap_ensure_allocated(dependencies, NULL); +- if (r < 0) +- return r; +- +- /* Acquire the inner hashmap, that maps Unit* → UnitDependencyInfo, for the specified dependency +- * type, and if it's missing allocate it and insert it. */ +- per_type = hashmap_get(*dependencies, UNIT_DEPENDENCY_TO_PTR(d)); +- if (!per_type) { +- per_type = hashmap_new(NULL); +- if (!per_type) +- return -ENOMEM; +- +- r = hashmap_put(*dependencies, UNIT_DEPENDENCY_TO_PTR(d), per_type); +- if (r < 0) { +- hashmap_free(per_type); +- return r; +- } +- } +- +- return unit_per_dependency_type_hashmap_update(per_type, other, origin_mask, destination_mask); +-} +- + static void unit_merge_dependencies(Unit *u, Unit *other) { + Hashmap *deps; + void *dt; /* Actually of type UnitDependency, except that we don't bother casting it here, +@@ -3002,11 +2962,38 @@ bool unit_job_is_applicable(Unit *u, JobType j) { + } + } + +-int unit_add_dependency( ++static Hashmap *unit_get_dependency_hashmap_per_type(Unit *u, UnitDependency d) { ++ Hashmap *deps; ++ ++ assert(u); ++ assert(d >= 0 && d < _UNIT_DEPENDENCY_MAX); ++ ++ deps = hashmap_get(u->dependencies, UNIT_DEPENDENCY_TO_PTR(d)); ++ if (!deps) { ++ _cleanup_hashmap_free_ Hashmap *h = NULL; ++ ++ h = hashmap_new(NULL); ++ if (!h) ++ return NULL; ++ ++ if (hashmap_ensure_put(&u->dependencies, NULL, UNIT_DEPENDENCY_TO_PTR(d), h) < 0) ++ return NULL; ++ ++ deps = TAKE_PTR(h); ++ } ++ ++ return deps; ++} ++ ++typedef enum NotifyDependencyFlags { ++ NOTIFY_DEPENDENCY_UPDATE_FROM = 1 << 0, ++ NOTIFY_DEPENDENCY_UPDATE_TO = 1 << 1, ++} NotifyDependencyFlags; ++ ++static int unit_add_dependency_impl( + Unit *u, + UnitDependency d, + Unit *other, +- bool add_reference, + UnitDependencyMask mask) { + + static const UnitDependency inverse_table[_UNIT_DEPENDENCY_MAX] = { +@@ -3042,12 +3029,78 @@ int unit_add_dependency( + [UNIT_IN_SLICE] = UNIT_SLICE_OF, + [UNIT_SLICE_OF] = UNIT_IN_SLICE, + }; ++ ++ Hashmap *u_deps, *other_deps; ++ UnitDependencyInfo u_info, u_info_old, other_info, other_info_old; ++ NotifyDependencyFlags flags = 0; ++ int r; ++ ++ assert(u); ++ assert(other); ++ assert(d >= 0 && d < _UNIT_DEPENDENCY_MAX); ++ assert(inverse_table[d] >= 0 && inverse_table[d] < _UNIT_DEPENDENCY_MAX); ++ assert(mask > 0 && mask < _UNIT_DEPENDENCY_MASK_FULL); ++ ++ /* Ensure the following two hashmaps for each unit exist: ++ * - the top-level dependency hashmap that maps UnitDependency → Hashmap(Unit* → UnitDependencyInfo), ++ * - the inner hashmap, that maps Unit* → UnitDependencyInfo, for the specified dependency type. */ ++ u_deps = unit_get_dependency_hashmap_per_type(u, d); ++ if (!u_deps) ++ return -ENOMEM; ++ ++ other_deps = unit_get_dependency_hashmap_per_type(other, inverse_table[d]); ++ if (!other_deps) ++ return -ENOMEM; ++ ++ /* Save the original dependency info. */ ++ u_info.data = u_info_old.data = hashmap_get(u_deps, other); ++ other_info.data = other_info_old.data = hashmap_get(other_deps, u); ++ ++ /* Update dependency info. */ ++ u_info.origin_mask |= mask; ++ other_info.destination_mask |= mask; ++ ++ /* Save updated dependency info. */ ++ if (u_info.data != u_info_old.data) { ++ r = hashmap_replace(u_deps, other, u_info.data); ++ if (r < 0) ++ return r; ++ ++ flags = NOTIFY_DEPENDENCY_UPDATE_FROM; ++ } ++ ++ if (other_info.data != other_info_old.data) { ++ r = hashmap_replace(other_deps, u, other_info.data); ++ if (r < 0) { ++ if (u_info.data != u_info_old.data) { ++ /* Restore the old dependency. */ ++ if (u_info_old.data) ++ (void) hashmap_update(u_deps, other, u_info_old.data); ++ else ++ hashmap_remove(u_deps, other); ++ } ++ return r; ++ } ++ ++ flags |= NOTIFY_DEPENDENCY_UPDATE_TO; ++ } ++ ++ return flags; ++} ++ ++int unit_add_dependency( ++ Unit *u, ++ UnitDependency d, ++ Unit *other, ++ bool add_reference, ++ UnitDependencyMask mask) { ++ + UnitDependencyAtom a; + int r; + + /* Helper to know whether sending a notification is necessary or not: if the dependency is already + * there, no need to notify! */ +- bool notify, notify_other = false; ++ NotifyDependencyFlags notify_flags; + + assert(u); + assert(d >= 0 && d < _UNIT_DEPENDENCY_MAX); +@@ -3103,35 +3156,24 @@ int unit_add_dependency( + return log_unit_error_errno(u, SYNTHETIC_ERRNO(EINVAL), + "Requested dependency SliceOf=%s refused (%s is not a cgroup unit).", other->id, other->id); + +- r = unit_add_dependency_hashmap(&u->dependencies, d, other, mask, 0); +- if (r < 0) +- return r; +- notify = r > 0; +- +- assert(inverse_table[d] >= 0 && inverse_table[d] < _UNIT_DEPENDENCY_MAX); +- r = unit_add_dependency_hashmap(&other->dependencies, inverse_table[d], u, 0, mask); ++ r = unit_add_dependency_impl(u, d, other, mask); + if (r < 0) + return r; +- notify_other = r > 0; ++ notify_flags = r; + + if (add_reference) { +- r = unit_add_dependency_hashmap(&u->dependencies, UNIT_REFERENCES, other, mask, 0); +- if (r < 0) +- return r; +- notify = notify || r > 0; +- +- r = unit_add_dependency_hashmap(&other->dependencies, UNIT_REFERENCED_BY, u, 0, mask); ++ r = unit_add_dependency_impl(u, UNIT_REFERENCES, other, mask); + if (r < 0) + return r; +- notify_other = notify_other || r > 0; ++ notify_flags |= r; + } + +- if (notify) ++ if (FLAGS_SET(notify_flags, NOTIFY_DEPENDENCY_UPDATE_FROM)) + unit_add_to_dbus_queue(u); +- if (notify_other) ++ if (FLAGS_SET(notify_flags, NOTIFY_DEPENDENCY_UPDATE_TO)) + unit_add_to_dbus_queue(other); + +- return notify || notify_other; ++ return notify_flags != 0; + } + + int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference, UnitDependencyMask mask) { diff --git a/SOURCES/0361-resolvectl-fix-type-of-ifindex-D-Bus-field-and-make-.patch b/SOURCES/0361-resolvectl-fix-type-of-ifindex-D-Bus-field-and-make-.patch new file mode 100644 index 0000000..a3875e2 --- /dev/null +++ b/SOURCES/0361-resolvectl-fix-type-of-ifindex-D-Bus-field-and-make-.patch @@ -0,0 +1,29 @@ +From e5b40438543324acd504bbcf5d9b4cd71b46d931 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 4 Jan 2023 16:29:34 +0100 +Subject: [PATCH] resolvectl: fix type of ifindex D-Bus field, and make sure to + initialize to zero in all code paths + +(cherry picked from commit a5e6c8498ca375bafa865d5e46fa95e9313871ad) + +Related: #2161260 +--- + src/resolve/resolvectl.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c +index c52773508f..2fd6c4914f 100644 +--- a/src/resolve/resolvectl.c ++++ b/src/resolve/resolvectl.c +@@ -1208,9 +1208,10 @@ static int reset_server_features(int argc, char **argv, void *userdata) { + static int read_dns_server_one(sd_bus_message *m, bool with_ifindex, bool extended, char **ret) { + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_free_ char *pretty = NULL; +- int ifindex, family, r, k; + union in_addr_union a; + const char *name = NULL; ++ int32_t ifindex = 0; ++ int family, r, k; + uint16_t port = 0; + + assert(m); diff --git a/SOURCES/0362-resolved-add-some-line-breaks-comments.patch b/SOURCES/0362-resolved-add-some-line-breaks-comments.patch new file mode 100644 index 0000000..bf06bf7 --- /dev/null +++ b/SOURCES/0362-resolved-add-some-line-breaks-comments.patch @@ -0,0 +1,100 @@ +From cae4b6abbd66770e6761f6bd47f85cf271cc870b Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 4 Jan 2023 16:32:51 +0100 +Subject: [PATCH] resolved: add some line-breaks/comments + +Let's make this a bit more readable. + +(cherry picked from commit 5707fb12978e6818afba379b803da307050f541b) + +Related: #2161260 +--- + src/resolve/resolvectl.c | 20 +++++++++++++++----- + src/resolve/resolved-bus.c | 12 ++++++++++-- + 2 files changed, 25 insertions(+), 7 deletions(-) + +diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c +index 2fd6c4914f..1cb16430e4 100644 +--- a/src/resolve/resolvectl.c ++++ b/src/resolve/resolvectl.c +@@ -1217,7 +1217,11 @@ static int read_dns_server_one(sd_bus_message *m, bool with_ifindex, bool extend + assert(m); + assert(ret); + +- r = sd_bus_message_enter_container(m, 'r', with_ifindex ? (extended ? "iiayqs" : "iiay") : (extended ? "iayqs" : "iay")); ++ r = sd_bus_message_enter_container( ++ m, ++ 'r', ++ with_ifindex ? (extended ? "iiayqs" : "iiay") : ++ (extended ? "iayqs" : "iay")); + if (r <= 0) + return r; + +@@ -1262,7 +1266,6 @@ static int read_dns_server_one(sd_bus_message *m, bool with_ifindex, bool extend + return r; + + *ret = TAKE_PTR(pretty); +- + return 1; + } + +@@ -1731,7 +1734,14 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode + return 0; + } + +-static int map_global_dns_servers_internal(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata, bool extended) { ++static int map_global_dns_servers_internal( ++ sd_bus *bus, ++ const char *member, ++ sd_bus_message *m, ++ sd_bus_error *error, ++ void *userdata, ++ bool extended) { ++ + char ***l = ASSERT_PTR(userdata); + int r; + +@@ -1768,11 +1778,11 @@ static int map_global_dns_servers_internal(sd_bus *bus, const char *member, sd_b + } + + static int map_global_dns_servers(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { +- return map_global_dns_servers_internal(bus, member, m, error, userdata, false); ++ return map_global_dns_servers_internal(bus, member, m, error, userdata, /* extended= */ false); + } + + static int map_global_dns_servers_ex(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { +- return map_global_dns_servers_internal(bus, member, m, error, userdata, true); ++ return map_global_dns_servers_internal(bus, member, m, error, userdata, /* extended= */ true); + } + + static int map_global_current_dns_server(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { +diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c +index 2e3941da39..c818e1d52f 100644 +--- a/src/resolve/resolved-bus.c ++++ b/src/resolve/resolved-bus.c +@@ -1371,7 +1371,11 @@ static int bus_method_resolve_service(sd_bus_message *message, void *userdata, s + return 1; + } + +-int bus_dns_server_append(sd_bus_message *reply, DnsServer *s, bool with_ifindex, bool extended) { ++int bus_dns_server_append( ++ sd_bus_message *reply, ++ DnsServer *s, ++ bool with_ifindex, /* include "ifindex" field */ ++ bool extended) { /* also include port number and server name */ + int r; + + assert(reply); +@@ -1390,7 +1394,11 @@ int bus_dns_server_append(sd_bus_message *reply, DnsServer *s, bool with_ifindex + } + } + +- r = sd_bus_message_open_container(reply, 'r', with_ifindex ? (extended ? "iiayqs" : "iiay") : (extended ? "iayqs" : "iay")); ++ r = sd_bus_message_open_container( ++ reply, ++ 'r', ++ with_ifindex ? (extended ? "iiayqs" : "iiay") : ++ (extended ? "iayqs" : "iay")); + if (r < 0) + return r; + diff --git a/SOURCES/0363-resolvectl-don-t-filter-loopback-DNS-server-from-glo.patch b/SOURCES/0363-resolvectl-don-t-filter-loopback-DNS-server-from-glo.patch new file mode 100644 index 0000000..9ff37c7 --- /dev/null +++ b/SOURCES/0363-resolvectl-don-t-filter-loopback-DNS-server-from-glo.patch @@ -0,0 +1,122 @@ +From 94bcb43713447d943c5123dc8baac96c4e37bb26 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 4 Jan 2023 16:36:15 +0100 +Subject: [PATCH] resolvectl: don't filter loopback DNS server from global DNS + server list + +"resolvectl status" shows per-link DNS servers separately from global +ones. When querying the global list, it will contain both per-link and +global servers however. Thus, to not show duplicate info we filter all +entries that actually have a non-zero ifindex set (under the assumption +that that's a per-link server). + +This doesn't work if people configured 127.0.0.1 as global server +though, as we'll add ifindex 1 to it since +6e32414a66ff8dbcef233981a7066684d903ee9f unconditionally even for global +servers. + +Let's address that by excluding entries with ifindex 1 from suppression. +This is safe as resolved ignores loopback ifaces, hence never will have +per-link servers on ifindex 1. + +Note that this splits up the "with_ifindex" parameter into a second +parameter "only_global", since they semantically do two different +things. One controls whether we shall expect/parse an ifindex dbus +field. The other controls whether we shall filter all ifindex values set +!= 0. These are effectively always used in conjunction hence making them +the same actually worked. However this is utterly confusing I think, +which as I guess is resulting in the confusion around #25796 (which +removes the whole check) + +(cherry picked from commit 889a1b9f4e799b31f1be06db74708aa8beb70829) + +Resolves: #2161260 +--- + src/resolve/resolvectl.c | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c +index 1cb16430e4..e22e06d054 100644 +--- a/src/resolve/resolvectl.c ++++ b/src/resolve/resolvectl.c +@@ -1205,7 +1205,13 @@ static int reset_server_features(int argc, char **argv, void *userdata) { + return 0; + } + +-static int read_dns_server_one(sd_bus_message *m, bool with_ifindex, bool extended, char **ret) { ++static int read_dns_server_one( ++ sd_bus_message *m, ++ bool with_ifindex, /* read "ifindex" reply that also carries an interface index */ ++ bool extended, /* read "extended" reply, i.e. with port number and server name */ ++ bool only_global, /* suppress entries with an (non-loopback) ifindex set (i.e. which are specific to some interface) */ ++ char **ret) { ++ + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_free_ char *pretty = NULL; + union in_addr_union a; +@@ -1255,8 +1261,8 @@ static int read_dns_server_one(sd_bus_message *m, bool with_ifindex, bool extend + return 1; + } + +- if (with_ifindex && ifindex != 0) { +- /* only show the global ones here */ ++ if (only_global && ifindex > 0 && ifindex != LOOPBACK_IFINDEX) { ++ /* This one has an (non-loopback) ifindex set, and we were told to suppress those. Hence do so. */ + *ret = NULL; + return 1; + } +@@ -1284,7 +1290,7 @@ static int map_link_dns_servers_internal(sd_bus *bus, const char *member, sd_bus + for (;;) { + _cleanup_free_ char *pretty = NULL; + +- r = read_dns_server_one(m, false, extended, &pretty); ++ r = read_dns_server_one(m, /* with_ifindex= */ false, extended, /* only_global= */ false, &pretty); + if (r < 0) + return r; + if (r == 0) +@@ -1317,14 +1323,14 @@ static int map_link_current_dns_server(sd_bus *bus, const char *member, sd_bus_m + assert(m); + assert(userdata); + +- return read_dns_server_one(m, false, false, userdata); ++ return read_dns_server_one(m, /* with_ifindex= */ false, /* extended= */ false, /* only_global= */ false, userdata); + } + + static int map_link_current_dns_server_ex(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { + assert(m); + assert(userdata); + +- return read_dns_server_one(m, false, true, userdata); ++ return read_dns_server_one(m, /* with_ifindex= */ false, /* extended= */ true, /* only_global= */ false, userdata); + } + + static int read_domain_one(sd_bus_message *m, bool with_ifindex, char **ret) { +@@ -1756,7 +1762,7 @@ static int map_global_dns_servers_internal( + for (;;) { + _cleanup_free_ char *pretty = NULL; + +- r = read_dns_server_one(m, true, extended, &pretty); ++ r = read_dns_server_one(m, /* with_ifindex= */ true, extended, /* only_global= */ true, &pretty); + if (r < 0) + return r; + if (r == 0) +@@ -1786,17 +1792,11 @@ static int map_global_dns_servers_ex(sd_bus *bus, const char *member, sd_bus_mes + } + + static int map_global_current_dns_server(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { +- assert(m); +- assert(userdata); +- +- return read_dns_server_one(m, true, false, userdata); ++ return read_dns_server_one(m, /* with_ifindex= */ true, /* extended= */ false, /* only_global= */ true, userdata); + } + + static int map_global_current_dns_server_ex(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { +- assert(m); +- assert(userdata); +- +- return read_dns_server_one(m, true, true, userdata); ++ return read_dns_server_one(m, /* with_ifindex= */ true, /* extended= */ true, /* only_global= */ true, userdata); + } + + static int map_global_domains(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { diff --git a/SOURCES/0364-blockdev-util-add-simple-wrapper-around-BLKSSZGET.patch b/SOURCES/0364-blockdev-util-add-simple-wrapper-around-BLKSSZGET.patch new file mode 100644 index 0000000..4293103 --- /dev/null +++ b/SOURCES/0364-blockdev-util-add-simple-wrapper-around-BLKSSZGET.patch @@ -0,0 +1,75 @@ +From 1d569167f70a59d4e1b44378fc29f282e98f9148 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jan 2023 20:12:30 +0100 +Subject: [PATCH] blockdev-util: add simple wrapper around BLKSSZGET + +Just adds some typesafety and generates an error if the field is not +initialized in the block device yet. + +(cherry picked from commit 65046b92dcdc017f34e170a0e0f46ffc80b1dcdc) + +Related: #2170883 +--- + src/shared/blockdev-util.c | 15 +++++++++++++++ + src/shared/blockdev-util.h | 2 ++ + src/shared/loop-util.c | 12 ++++++------ + 3 files changed, 23 insertions(+), 6 deletions(-) + +diff --git a/src/shared/blockdev-util.c b/src/shared/blockdev-util.c +index 72fad160ed..27d3d075d9 100644 +--- a/src/shared/blockdev-util.c ++++ b/src/shared/blockdev-util.c +@@ -788,3 +788,18 @@ int blockdev_reread_partition_table(sd_device *dev) { + + return 0; + } ++ ++int blockdev_get_sector_size(int fd, uint32_t *ret) { ++ int ssz = 0; ++ ++ assert(fd >= 0); ++ assert(ret); ++ ++ if (ioctl(fd, BLKSSZGET, &ssz) < 0) ++ return -errno; ++ if (ssz <= 0) /* make sure the field is initialized */ ++ return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Block device reported invalid sector size %i.", ssz); ++ ++ *ret = ssz; ++ return 0; ++} +diff --git a/src/shared/blockdev-util.h b/src/shared/blockdev-util.h +index b2c14102ae..5b27d23e8a 100644 +--- a/src/shared/blockdev-util.h ++++ b/src/shared/blockdev-util.h +@@ -54,3 +54,5 @@ int partition_enumerator_new(sd_device *dev, sd_device_enumerator **ret); + int block_device_remove_all_partitions(sd_device *dev, int fd); + int block_device_has_partitions(sd_device *dev); + int blockdev_reread_partition_table(sd_device *dev); ++ ++int blockdev_get_sector_size(int fd, uint32_t *ret); +diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c +index fb7e80b1b5..1c66fb779d 100644 +--- a/src/shared/loop-util.c ++++ b/src/shared/loop-util.c +@@ -124,14 +124,14 @@ static int loop_configure_verify(int fd, const struct loop_config *c) { + assert(c); + + if (c->block_size != 0) { +- int z; ++ uint32_t ssz; + +- if (ioctl(fd, BLKSSZGET, &z) < 0) +- return -errno; ++ r = blockdev_get_sector_size(fd, &ssz); ++ if (r < 0) ++ return r; + +- assert(z >= 0); +- if ((uint32_t) z != c->block_size) +- log_debug("LOOP_CONFIGURE didn't honour requested block size %u, got %i instead. Ignoring.", c->block_size, z); ++ if (ssz != c->block_size) ++ log_debug("LOOP_CONFIGURE didn't honour requested block size %" PRIu32 ", got %" PRIu32 " instead. Ignoring.", c->block_size, ssz); + } + + if (c->info.lo_sizelimit != 0) { diff --git a/SOURCES/0365-loop-util-insist-on-setting-the-sector-size-correctl.patch b/SOURCES/0365-loop-util-insist-on-setting-the-sector-size-correctl.patch new file mode 100644 index 0000000..dd92818 --- /dev/null +++ b/SOURCES/0365-loop-util-insist-on-setting-the-sector-size-correctl.patch @@ -0,0 +1,62 @@ +From 7c3d3404ded062e3bff9384cf2c009dcc71d2dba Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jan 2023 15:49:31 +0100 +Subject: [PATCH] loop-util: insist on setting the sector size correctly + +If we attach a disk image to a loopback device the sector size of the +image must match the one of the loopback device, hence be more careful +here. + +(cherry picked from commit 1163ddb386ef46f63942171e6eab0ca64eb818e4) + +Related: #2170883 +--- + src/shared/loop-util.c | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c +index 1c66fb779d..4e0b06ad83 100644 +--- a/src/shared/loop-util.c ++++ b/src/shared/loop-util.c +@@ -130,8 +130,10 @@ static int loop_configure_verify(int fd, const struct loop_config *c) { + if (r < 0) + return r; + +- if (ssz != c->block_size) ++ if (ssz != c->block_size) { + log_debug("LOOP_CONFIGURE didn't honour requested block size %" PRIu32 ", got %" PRIu32 " instead. Ignoring.", c->block_size, ssz); ++ broken = true; ++ } + } + + if (c->info.lo_sizelimit != 0) { +@@ -172,6 +174,7 @@ static int loop_configure_verify(int fd, const struct loop_config *c) { + + static int loop_configure_fallback(int fd, const struct loop_config *c) { + struct loop_info64 info_copy; ++ int r; + + assert(fd >= 0); + assert(c); +@@ -219,6 +222,21 @@ static int loop_configure_fallback(int fd, const struct loop_config *c) { + if (ioctl(fd, BLKFLSBUF, 0) < 0) + log_debug_errno(errno, "Failed to issue BLKFLSBUF ioctl, ignoring: %m"); + ++ /* If a block size is requested then try to configure it. If that doesn't work, ignore errors, but ++ * afterwards, let's validate what is in effect, and if it doesn't match what we want, fail */ ++ if (c->block_size != 0) { ++ uint32_t ssz; ++ ++ if (ioctl(fd, LOOP_SET_BLOCK_SIZE, (unsigned long) c->block_size) < 0) ++ log_debug_errno(errno, "Failed to set sector size, ignoring: %m"); ++ ++ r = blockdev_get_sector_size(fd, &ssz); ++ if (r < 0) ++ return log_debug_errno(r, "Failed to read sector size: %m"); ++ if (ssz != c->block_size) ++ return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Sector size of loopback device doesn't match what we requested, refusing."); ++ } ++ + /* LO_FLAGS_DIRECT_IO is a flags we need to configure via explicit ioctls. */ + if (FLAGS_SET(c->info.lo_flags, LO_FLAGS_DIRECT_IO)) + if (ioctl(fd, LOOP_SET_DIRECT_IO, 1UL) < 0) diff --git a/SOURCES/0366-dissect-image-add-probe_sector_size-helper-for-detec.patch b/SOURCES/0366-dissect-image-add-probe_sector_size-helper-for-detec.patch new file mode 100644 index 0000000..d0e25c9 --- /dev/null +++ b/SOURCES/0366-dissect-image-add-probe_sector_size-helper-for-detec.patch @@ -0,0 +1,134 @@ +From f86ffe711102f53b793c6529c82017b31389cbab Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jan 2023 18:06:05 +0100 +Subject: [PATCH] dissect-image: add probe_sector_size() helper for detecting + sector size of a GPT disk image + +When we operate with DDIs with sector sizes != 512 we need to configure +the loopback device to match it, otherwise the image and the kernel +block device will disagree what things are. + +Let's add a prober that tries to determine the sector size of a GPT DDI. +It does this by looking for the GPT partition table header at the +various byte offsets they must be located on, given a specific sector +size. It will try sector size 512, 1024, 2048 and 4096. Of these only +the 512 and 4096 really make sense IRL I guess, but let's be thorough. + +(cherry picked from commit 05c4c59ff127668ddaa85f0a9fd67cee3c41ce00) + +Related: #2170883 +--- + src/shared/dissect-image.c | 82 ++++++++++++++++++++++++++++++++++++++ + src/shared/dissect-image.h | 2 + + 2 files changed, 84 insertions(+) + +diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c +index 462ee4b3e8..5c7d26d6cf 100644 +--- a/src/shared/dissect-image.c ++++ b/src/shared/dissect-image.c +@@ -61,6 +61,7 @@ + #include "raw-clone.h" + #include "resize-fs.h" + #include "signal-util.h" ++#include "sparse-endian.h" + #include "stat-util.h" + #include "stdio-util.h" + #include "string-table.h" +@@ -74,6 +75,87 @@ + /* how many times to wait for the device nodes to appear */ + #define N_DEVICE_NODE_LIST_ATTEMPTS 10 + ++int probe_sector_size(int fd, uint32_t *ret) { ++ ++ struct gpt_header { ++ char signature[8]; ++ le32_t revision; ++ le32_t header_size; ++ le32_t crc32; ++ le32_t reserved; ++ le64_t my_lba; ++ le64_t alternate_lba; ++ le64_t first_usable_lba; ++ le64_t last_usable_lba; ++ sd_id128_t disk_guid; ++ le64_t partition_entry_lba; ++ le32_t number_of_partition_entries; ++ le32_t size_of_partition_entry; ++ le32_t partition_entry_array_crc32; ++ } _packed_; ++ ++ /* Disk images might be for 512B or for 4096 sector sizes, let's try to auto-detect that by searching ++ * for the GPT headers at the relevant byte offsets */ ++ ++ assert_cc(sizeof(struct gpt_header) == 92); ++ ++ /* We expect a sector size in the range 512…4096. The GPT header is located in the second ++ * sector. Hence it could be at byte 512 at the earliest, and at byte 4096 at the latest. And we must ++ * read with granularity of the largest sector size we care about. Which means 8K. */ ++ uint8_t sectors[2 * 4096]; ++ uint32_t found = 0; ++ ssize_t n; ++ ++ assert(fd >= 0); ++ assert(ret); ++ ++ n = pread(fd, sectors, sizeof(sectors), 0); ++ if (n < 0) ++ return -errno; ++ if (n != sizeof(sectors)) /* too short? */ ++ goto not_found; ++ ++ /* Let's see if we find the GPT partition header with various expected sector sizes */ ++ for (uint32_t sz = 512; sz <= 4096; sz <<= 1) { ++ struct gpt_header *p; ++ ++ assert(sizeof(sectors) >= sz * 2); ++ p = (struct gpt_header*) (sectors + sz); ++ ++ if (memcmp(p->signature, (const char[8]) { 'E', 'F', 'I', ' ', 'P', 'A', 'R', 'T' }, 8) != 0) ++ continue; ++ ++ if (le32toh(p->revision) != UINT32_C(0x00010000)) /* the only known revision of the spec: 1.0 */ ++ continue; ++ ++ if (le32toh(p->header_size) < sizeof(struct gpt_header)) ++ continue; ++ ++ if (le32toh(p->header_size) > 4096) /* larger than a sector? something is off… */ ++ continue; ++ ++ if (le64toh(p->my_lba) != 1) /* this sector must claim to be at sector offset 1 */ ++ continue; ++ ++ if (found != 0) ++ return log_debug_errno(SYNTHETIC_ERRNO(ENOTUNIQ), ++ "Detected valid partition table at offsets matching multiple sector sizes, refusing."); ++ ++ found = sz; ++ } ++ ++ if (found != 0) { ++ log_debug("Determined sector size %" PRIu32 " based on discovered partition table.", found); ++ *ret = found; ++ return 1; /* indicate we *did* find it */ ++ } ++ ++not_found: ++ log_debug("Couldn't find any partition table to derive sector size of."); ++ *ret = 512; /* pick the traditional default */ ++ return 0; /* indicate we didn't find it */ ++} ++ + int probe_filesystem_full(int fd, const char *path, char **ret_fstype) { + /* Try to find device content type and return it in *ret_fstype. If nothing is found, + * 0/NULL will be returned. -EUCLEAN will be returned for ambiguous results, and an +diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h +index 631d4c7a04..2c7b84f15b 100644 +--- a/src/shared/dissect-image.h ++++ b/src/shared/dissect-image.h +@@ -315,3 +315,5 @@ bool dissected_image_verity_sig_ready(const DissectedImage *image, PartitionDesi + int mount_image_privately_interactively(const char *path, DissectImageFlags flags, char **ret_directory, LoopDevice **ret_loop_device); + + int verity_dissect_and_mount(int src_fd, const char *src, const char *dest, const MountOptions *options, const char *required_host_os_release_id, const char *required_host_os_release_version_id, const char *required_host_os_release_sysext_level, const char *required_sysext_scope); ++ ++int probe_sector_size(int fd, uint32_t *ret); diff --git a/SOURCES/0367-loop-util-always-tell-kernel-explicitly-about-loopba.patch b/SOURCES/0367-loop-util-always-tell-kernel-explicitly-about-loopba.patch new file mode 100644 index 0000000..62542e1 --- /dev/null +++ b/SOURCES/0367-loop-util-always-tell-kernel-explicitly-about-loopba.patch @@ -0,0 +1,370 @@ +From 108dd8030923d241ebc3ac9a58099a020996f911 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jan 2023 18:50:59 +0100 +Subject: [PATCH] loop-util: always tell kernel explicitly about loopback + sector size + +Let's not leave the sector size unspecified: either set a user supplied +value, or auto-detect the right size by probing the disk image +accordingly. + +(cherry picked from commit 22ee78a8987f29e7f837efab86ed090ab78c1170) + +Related: #2170883 +--- + src/core/namespace.c | 1 + + src/dissect/dissect.c | 1 + + src/home/homework-luks.c | 20 +++++++++++-- + src/nspawn/nspawn.c | 1 + + src/portable/portable.c | 2 +- + src/shared/discover-image.c | 2 +- + src/shared/dissect-image.c | 15 +++++++++- + src/shared/dissect-image.h | 2 ++ + src/shared/loop-util.c | 60 +++++++++++++++++++++++++++++++++---- + src/shared/loop-util.h | 5 ++-- + src/sysext/sysext.c | 1 + + 11 files changed, 98 insertions(+), 12 deletions(-) + +diff --git a/src/core/namespace.c b/src/core/namespace.c +index 96b05303eb..8fd7ed0269 100644 +--- a/src/core/namespace.c ++++ b/src/core/namespace.c +@@ -2093,6 +2093,7 @@ int setup_namespace( + r = loop_device_make_by_path( + root_image, + FLAGS_SET(dissect_image_flags, DISSECT_IMAGE_DEVICE_READ_ONLY) ? O_RDONLY : -1 /* < 0 means writable if possible, read-only as fallback */, ++ /* sector_size= */ UINT32_MAX, + FLAGS_SET(dissect_image_flags, DISSECT_IMAGE_NO_PARTITION_TABLE) ? 0 : LO_FLAGS_PARTSCAN, + LOCK_SH, + &loop_device); +diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c +index c1d731dc82..b7c47561bc 100644 +--- a/src/dissect/dissect.c ++++ b/src/dissect/dissect.c +@@ -931,6 +931,7 @@ static int run(int argc, char *argv[]) { + r = loop_device_make_by_path( + arg_image, + FLAGS_SET(arg_flags, DISSECT_IMAGE_DEVICE_READ_ONLY) ? O_RDONLY : O_RDWR, ++ /* sector_size= */ UINT32_MAX, + FLAGS_SET(arg_flags, DISSECT_IMAGE_NO_PARTITION_TABLE) ? 0 : LO_FLAGS_PARTSCAN, + LOCK_SH, + &d); +diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c +index 5e1d5bbd65..53fa61b103 100644 +--- a/src/home/homework-luks.c ++++ b/src/home/homework-luks.c +@@ -1378,7 +1378,15 @@ int home_setup_luks( + return r; + } + +- r = loop_device_make(setup->image_fd, O_RDWR, offset, size, user_record_luks_sector_size(h), 0, LOCK_UN, &setup->loop); ++ r = loop_device_make( ++ setup->image_fd, ++ O_RDWR, ++ offset, ++ size, ++ h->luks_sector_size == UINT64_MAX ? UINT32_MAX : user_record_luks_sector_size(h), /* if sector size is not specified, select UINT32_MAX, i.e. auto-probe */ ++ /* loop_flags= */ 0, ++ LOCK_UN, ++ &setup->loop); + if (r == -ENOENT) { + log_error_errno(r, "Loopback block device support is not available on this system."); + return -ENOLINK; /* make recognizable */ +@@ -2302,7 +2310,15 @@ int home_create_luks( + + log_info("Writing of partition table completed."); + +- r = loop_device_make(setup->image_fd, O_RDWR, partition_offset, partition_size, user_record_luks_sector_size(h), 0, LOCK_EX, &setup->loop); ++ r = loop_device_make( ++ setup->image_fd, ++ O_RDWR, ++ partition_offset, ++ partition_size, ++ user_record_luks_sector_size(h), ++ 0, ++ LOCK_EX, ++ &setup->loop); + if (r < 0) { + if (r == -ENOENT) { /* this means /dev/loop-control doesn't exist, i.e. we are in a container + * or similar and loopback bock devices are not available, return a +diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c +index 57723aa3cf..cdebe8e5c4 100644 +--- a/src/nspawn/nspawn.c ++++ b/src/nspawn/nspawn.c +@@ -5737,6 +5737,7 @@ static int run(int argc, char *argv[]) { + r = loop_device_make_by_path( + arg_image, + arg_read_only ? O_RDONLY : O_RDWR, ++ /* sector_size= */ UINT32_MAX, + FLAGS_SET(dissect_image_flags, DISSECT_IMAGE_NO_PARTITION_TABLE) ? 0 : LO_FLAGS_PARTSCAN, + LOCK_SH, + &loop); +diff --git a/src/portable/portable.c b/src/portable/portable.c +index 570751f05b..8a989ed526 100644 +--- a/src/portable/portable.c ++++ b/src/portable/portable.c +@@ -335,7 +335,7 @@ static int portable_extract_by_path( + + assert(path); + +- r = loop_device_make_by_path(path, O_RDONLY, LO_FLAGS_PARTSCAN, LOCK_SH, &d); ++ r = loop_device_make_by_path(path, O_RDONLY, /* sector_size= */ UINT32_MAX, LO_FLAGS_PARTSCAN, LOCK_SH, &d); + if (r == -EISDIR) { + _cleanup_free_ char *image_name = NULL; + +diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c +index 5d740de266..0488e215fd 100644 +--- a/src/shared/discover-image.c ++++ b/src/shared/discover-image.c +@@ -1192,7 +1192,7 @@ int image_read_metadata(Image *i) { + _cleanup_(loop_device_unrefp) LoopDevice *d = NULL; + _cleanup_(dissected_image_unrefp) DissectedImage *m = NULL; + +- r = loop_device_make_by_path(i->path, O_RDONLY, LO_FLAGS_PARTSCAN, LOCK_SH, &d); ++ r = loop_device_make_by_path(i->path, O_RDONLY, /* sector_size= */ UINT32_MAX, LO_FLAGS_PARTSCAN, LOCK_SH, &d); + if (r < 0) + return r; + +diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c +index 5c7d26d6cf..d2abd5a087 100644 +--- a/src/shared/dissect-image.c ++++ b/src/shared/dissect-image.c +@@ -443,6 +443,7 @@ static int dissect_image( + assert(!verity || verity->root_hash_sig || verity->root_hash_sig_size == 0); + assert(!verity || (verity->root_hash || !verity->root_hash_sig)); + assert(!((flags & DISSECT_IMAGE_GPT_ONLY) && (flags & DISSECT_IMAGE_NO_PARTITION_TABLE))); ++ assert(m->sector_size > 0); + + /* Probes a disk image, and returns information about what it found in *ret. + * +@@ -489,6 +490,11 @@ static int dissect_image( + if (r != 0) + return errno_or_else(ENOMEM); + ++ errno = 0; ++ r = blkid_probe_set_sectorsize(b, m->sector_size); ++ if (r != 0) ++ return errno_or_else(EIO); ++ + if ((flags & DISSECT_IMAGE_GPT_ONLY) == 0) { + /* Look for file system superblocks, unless we only shall look for GPT partition tables */ + blkid_probe_enable_superblocks(b, 1); +@@ -1328,6 +1334,10 @@ int dissect_image_file( + if (r < 0) + return r; + ++ r = probe_sector_size(fd, &m->sector_size); ++ if (r < 0) ++ return r; ++ + r = dissect_image(m, fd, path, verity, mount_options, flags); + if (r < 0) + return r; +@@ -3116,6 +3126,7 @@ int dissect_loop_device( + return r; + + m->loop = loop_device_ref(loop); ++ m->sector_size = m->loop->sector_size; + + r = dissect_image(m, loop->fd, loop->node, verity, mount_options, flags); + if (r < 0) +@@ -3295,6 +3306,7 @@ int mount_image_privately_interactively( + r = loop_device_make_by_path( + image, + FLAGS_SET(flags, DISSECT_IMAGE_DEVICE_READ_ONLY) ? O_RDONLY : O_RDWR, ++ /* sector_size= */ UINT32_MAX, + FLAGS_SET(flags, DISSECT_IMAGE_NO_PARTITION_TABLE) ? 0 : LO_FLAGS_PARTSCAN, + LOCK_SH, + &d); +@@ -3414,7 +3426,8 @@ int verity_dissect_and_mount( + * accepted by LOOP_CONFIGURE, so just let loop_device_make_by_path reopen it as a regular FD. */ + r = loop_device_make_by_path( + src_fd >= 0 ? FORMAT_PROC_FD_PATH(src_fd) : src, +- -1, ++ /* open_flags= */ -1, ++ /* sector_size= */ UINT32_MAX, + verity.data_path ? 0 : LO_FLAGS_PARTSCAN, + LOCK_SH, + &loop_device); +diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h +index 2c7b84f15b..becd69c26e 100644 +--- a/src/shared/dissect-image.h ++++ b/src/shared/dissect-image.h +@@ -231,6 +231,8 @@ struct DissectedImage { + DissectedPartition partitions[_PARTITION_DESIGNATOR_MAX]; + DecryptedImage *decrypted_image; + ++ uint32_t sector_size; ++ + /* Meta information extracted from /etc/os-release and similar */ + char *image_name; + char *hostname; +diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c +index 4e0b06ad83..468ef7a40a 100644 +--- a/src/shared/loop-util.c ++++ b/src/shared/loop-util.c +@@ -19,6 +19,7 @@ + #include "blockdev-util.h" + #include "device-util.h" + #include "devnum-util.h" ++#include "dissect-image.h" + #include "env-util.h" + #include "errno-util.h" + #include "fd-util.h" +@@ -408,6 +409,7 @@ static int loop_configure( + .diskseq = diskseq, + .uevent_seqnum_not_before = seqnum, + .timestamp_not_before = timestamp, ++ .sector_size = c->block_size, + }; + + *ret = TAKE_PTR(d); +@@ -420,7 +422,7 @@ static int loop_device_make_internal( + int open_flags, + uint64_t offset, + uint64_t size, +- uint32_t block_size, ++ uint32_t sector_size, + uint32_t loop_flags, + int lock_op, + LoopDevice **ret) { +@@ -491,9 +493,50 @@ static int loop_device_make_internal( + if (control < 0) + return -errno; + ++ if (sector_size == 0) ++ /* If no sector size is specified, default to the classic default */ ++ sector_size = 512; ++ else if (sector_size == UINT32_MAX) { ++ ++ if (S_ISBLK(st.st_mode)) ++ /* If the sector size is specified as UINT32_MAX we'll propagate the sector size of ++ * the underlying block device. */ ++ r = blockdev_get_sector_size(fd, §or_size); ++ else { ++ _cleanup_close_ int non_direct_io_fd = -1; ++ int probe_fd; ++ ++ assert(S_ISREG(st.st_mode)); ++ ++ /* If sector size is specified as UINT32_MAX, we'll try to probe the right sector ++ * size of the image in question by looking for the GPT partition header at various ++ * offsets. This of course only works if the image already has a disk label. ++ * ++ * So here we actually want to read the file contents ourselves. This is quite likely ++ * not going to work if we managed to enable O_DIRECT, because in such a case there ++ * are some pretty strict alignment requirements to offset, size and target, but ++ * there's no way to query what alignment specifically is actually required. Hence, ++ * let's avoid the mess, and temporarily open an fd without O_DIRECT for the probing ++ * logic. */ ++ ++ if (FLAGS_SET(loop_flags, LO_FLAGS_DIRECT_IO)) { ++ non_direct_io_fd = fd_reopen(fd, O_RDONLY|O_CLOEXEC|O_NONBLOCK); ++ if (non_direct_io_fd < 0) ++ return non_direct_io_fd; ++ ++ probe_fd = non_direct_io_fd; ++ } else ++ probe_fd = fd; ++ ++ r = probe_sector_size(probe_fd, §or_size); ++ } ++ if (r < 0) ++ return r; ++ } ++ + config = (struct loop_config) { + .fd = fd, +- .block_size = block_size, ++ .block_size = sector_size, + .info = { + /* Use the specified flags, but configure the read-only flag from the open flags, and force autoclear */ + .lo_flags = (loop_flags & ~LO_FLAGS_READ_ONLY) | ((open_flags & O_ACCMODE) == O_RDONLY ? LO_FLAGS_READ_ONLY : 0) | LO_FLAGS_AUTOCLEAR, +@@ -577,7 +620,7 @@ int loop_device_make( + int open_flags, + uint64_t offset, + uint64_t size, +- uint32_t block_size, ++ uint32_t sector_size, + uint32_t loop_flags, + int lock_op, + LoopDevice **ret) { +@@ -591,7 +634,7 @@ int loop_device_make( + open_flags, + offset, + size, +- block_size, ++ sector_size, + loop_flags_mangle(loop_flags), + lock_op, + ret); +@@ -600,6 +643,7 @@ int loop_device_make( + int loop_device_make_by_path( + const char *path, + int open_flags, ++ uint32_t sector_size, + uint32_t loop_flags, + int lock_op, + LoopDevice **ret) { +@@ -655,7 +699,7 @@ int loop_device_make_by_path( + direct ? "enabled" : "disabled", + direct != (direct_flags != 0) ? " (O_DIRECT was requested but not supported)" : ""); + +- return loop_device_make_internal(path, fd, open_flags, 0, 0, 0, loop_flags, lock_op, ret); ++ return loop_device_make_internal(path, fd, open_flags, 0, 0, sector_size, loop_flags, lock_op, ret); + } + + static LoopDevice* loop_device_free(LoopDevice *d) { +@@ -797,6 +841,11 @@ int loop_device_open( + if (r < 0 && r != -EOPNOTSUPP) + return r; + ++ uint32_t sector_size; ++ r = blockdev_get_sector_size(fd, §or_size); ++ if (r < 0) ++ return r; ++ + r = sd_device_get_devnum(dev, &devnum); + if (r < 0) + return r; +@@ -826,6 +875,7 @@ int loop_device_open( + .diskseq = diskseq, + .uevent_seqnum_not_before = UINT64_MAX, + .timestamp_not_before = USEC_INFINITY, ++ .sector_size = sector_size, + }; + + *ret = d; +diff --git a/src/shared/loop-util.h b/src/shared/loop-util.h +index e466a5abbd..6e838cef0b 100644 +--- a/src/shared/loop-util.h ++++ b/src/shared/loop-util.h +@@ -23,13 +23,14 @@ struct LoopDevice { + uint64_t diskseq; /* Block device sequence number, monothonically incremented by the kernel on create/attach, or 0 if we don't know */ + uint64_t uevent_seqnum_not_before; /* uevent sequm right before we attached the loopback device, or UINT64_MAX if we don't know */ + usec_t timestamp_not_before; /* CLOCK_MONOTONIC timestamp taken immediately before attaching the loopback device, or USEC_INFINITY if we don't know */ ++ uint32_t sector_size; + }; + + /* Returns true if LoopDevice object is not actually a loopback device but some other block device we just wrap */ + #define LOOP_DEVICE_IS_FOREIGN(d) ((d)->nr < 0) + +-int loop_device_make(int fd, int open_flags, uint64_t offset, uint64_t size, uint32_t block_size, uint32_t loop_flags, int lock_op, LoopDevice **ret); +-int loop_device_make_by_path(const char *path, int open_flags, uint32_t loop_flags, int lock_op, LoopDevice **ret); ++int loop_device_make(int fd, int open_flags, uint64_t offset, uint64_t size, uint32_t sector_size, uint32_t loop_flags, int lock_op, LoopDevice **ret); ++int loop_device_make_by_path(const char *path, int open_flags, uint32_t sector_size, uint32_t loop_flags, int lock_op, LoopDevice **ret); + int loop_device_open(sd_device *dev, int open_flags, int lock_op, LoopDevice **ret); + int loop_device_open_from_fd(int fd, int open_flags, int lock_op, LoopDevice **ret); + int loop_device_open_from_path(const char *path, int open_flags, int lock_op, LoopDevice **ret); +diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c +index c57293b0e5..e1bf627528 100644 +--- a/src/sysext/sysext.c ++++ b/src/sysext/sysext.c +@@ -534,6 +534,7 @@ static int merge_subprocess(Hashmap *images, const char *workspace) { + r = loop_device_make_by_path( + img->path, + O_RDONLY, ++ /* sector_size= */ UINT32_MAX, + FLAGS_SET(flags, DISSECT_IMAGE_NO_PARTITION_TABLE) ? 0 : LO_FLAGS_PARTSCAN, + LOCK_SH, + &d); diff --git a/SOURCES/0368-Revert-Treat-EPERM-as-not-available-too.patch b/SOURCES/0368-Revert-Treat-EPERM-as-not-available-too.patch new file mode 100644 index 0000000..359b0af --- /dev/null +++ b/SOURCES/0368-Revert-Treat-EPERM-as-not-available-too.patch @@ -0,0 +1,25 @@ +From 2f4fd9002d0f438f7643ec98368bed709cb49442 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Tue, 14 Mar 2023 16:06:39 +0100 +Subject: [PATCH] Revert "Treat EPERM as "not available" too" + +This reverts commit 9e51ecd3ec0484d7ffefb0ceaf242e96b31195bb. + +Resolves: #2178222 +--- + src/nspawn/nspawn.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c +index cdebe8e5c4..df7b37ec4e 100644 +--- a/src/nspawn/nspawn.c ++++ b/src/nspawn/nspawn.c +@@ -3806,7 +3806,7 @@ static int outer_child( + arg_uid_shift != 0) { + + r = remount_idmap(directory, arg_uid_shift, arg_uid_range, UID_INVALID, REMOUNT_IDMAPPING_HOST_ROOT); +- if (IN_SET(r, -EINVAL, -EPERM) || ERRNO_IS_NOT_SUPPORTED(r)) { ++ if (r == -EINVAL || ERRNO_IS_NOT_SUPPORTED(r)) { + /* This might fail because the kernel or file system doesn't support idmapping. We + * can't really distinguish this nicely, nor do we have any guarantees about the + * error codes we see, could be EOPNOTSUPP or EINVAL. */ diff --git a/SOURCES/0369-Revert-test-accept-EPERM-for-unavailable-idmapped-mo.patch b/SOURCES/0369-Revert-test-accept-EPERM-for-unavailable-idmapped-mo.patch new file mode 100644 index 0000000..7491336 --- /dev/null +++ b/SOURCES/0369-Revert-test-accept-EPERM-for-unavailable-idmapped-mo.patch @@ -0,0 +1,26 @@ +From 3aab4694f97f96fc7d3608fb3a7bff047e390b4e Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Tue, 14 Mar 2023 16:07:28 +0100 +Subject: [PATCH] Revert "test: accept EPERM for unavailable idmapped mounts as + well" + +This reverts commit d2ccb0bf2b2078e13fc4cb1c2e2eb8079fa57df0. + +Related: #2178222 +--- + test/units/testsuite-13.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/units/testsuite-13.sh b/test/units/testsuite-13.sh +index 2b6e6df8a3..4ad7431e42 100755 +--- a/test/units/testsuite-13.sh ++++ b/test/units/testsuite-13.sh +@@ -74,7 +74,7 @@ function check_rootidmap { + --register=no -D "$_root" \ + --bind=/tmp/rootidmapdir:/mnt:rootidmap \ + /bin/sh -c "$_command" |& tee nspawn.out; then +- if grep -Eq "Failed to map ids for bind mount.*: (Function not implemented|Operation not permitted)" nspawn.out; then ++ if grep -q "Failed to map ids for bind mount.*: Function not implemented" nspawn.out; then + echo "idmapped mounts are not supported, skipping the test..." + return 0 + fi diff --git a/SOURCES/systemd-user b/SOURCES/systemd-user index 8607d4f..3a4cd2e 100644 --- a/SOURCES/systemd-user +++ b/SOURCES/systemd-user @@ -8,4 +8,7 @@ account include system-auth session required pam_selinux.so close session required pam_selinux.so nottys open session required pam_loginuid.so +session optional pam_keyinit.so force revoke +session optional pam_umask.so silent +session required pam_namespace.so session include system-auth diff --git a/SOURCES/sysusers.generate-pre.sh b/SOURCES/sysusers.generate-pre.sh index 6c481c3..4a87d53 100755 --- a/SOURCES/sysusers.generate-pre.sh +++ b/SOURCES/sysusers.generate-pre.sh @@ -1,79 +1,96 @@ #!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: true; tab-width: 4; -*- # This script turns sysuser.d files into scriptlets mandated by Fedora # packaging guidelines. The general idea is to define users using the # declarative syntax but to turn this into traditional scriptlets. user() { - user="$1" - uid="$2" - desc="$3" - group="$4" - home="$5" - shell="$6" + user="$1" + uid="$2" + desc="$3" + group="$4" + home="$5" + shell="$6" -[ "$desc" = '-' ] && desc= -[ "$home" = '-' -o "$home" = '' ] && home=/ -[ "$shell" = '-' -o "$shell" = '' ] && shell=/sbin/nologin + [ "$desc" = '-' ] && desc= + { [ "$home" = '-' ] || [ "$home" = '' ]; } && home=/ + { [ "$shell" = '-' ] || [ "$shell" = '' ]; } && shell=/usr/sbin/nologin -if [ "$uid" = '-' -o "$uid" = '' ]; then - cat </dev/null || \\ - useradd -r -g '$group' -d '$home' -s '$shell' -c '$desc' '$user' -EOF -else - cat </dev/null ; then - if ! getent passwd '$uid' >/dev/null ; then - useradd -r -u '$uid' -g '$group' -d '$home' -s /sbin/nologin -c '$desc' '$user' - else - useradd -r -g '$group' -d '$home' -s /sbin/nologin -c '$desc' '$user' - fi -fi + if [ "$uid" = '-' ] || [ "$uid" = '' ]; then + cat <<-EOF + getent passwd '$user' >/dev/null || \\ + useradd -r -g ${group@Q} -d ${home@Q} -s ${shell@Q} -c ${desc@Q} ${user@Q} || : + EOF + else + cat <<-EOF + if ! getent passwd ${user@Q} >/dev/null; then + if ! getent passwd ${uid@Q} >/dev/null; then + useradd -r -u ${uid@Q} -g ${group@Q} -d ${home@Q} -s ${shell@Q} -c ${desc@Q} ${user@Q} || : + else + useradd -r -g ${group@Q} -d ${home@Q} -s ${shell@Q} -c ${desc@Q} ${user@Q} || : + fi + fi -EOF -fi + EOF + fi } group() { - group="$1" - gid="$2" -if [ "$gid" = '-' ]; then - cat </dev/null || groupadd -r '$group' -EOF -else - cat </dev/null || groupadd -f -g '$gid' -r '$group' -EOF -fi + group="$1" + gid="$2" + + if [ "$gid" = '-' ]; then + cat <<-EOF + getent group ${group@Q} >/dev/null || groupadd -r ${group@Q} || : + EOF + else + cat <<-EOF + getent group ${group@Q} >/dev/null || groupadd -f -g ${gid@Q} -r ${group@Q} || : + EOF + fi +} + +usermod() { + user="$1" + group="$2" + + cat <<-EOF + if getent group ${group@Q} >/dev/null; then + usermod -a -G ${group@Q} '$user' || : + fi + EOF } parse() { - while read line || [ "$line" ]; do - [ "${line:0:1}" = '#' -o "${line:0:1}" = ';' ] && continue - line="${line## *}" - [ -z "$line" ] && continue - eval arr=( $line ) - case "${arr[0]}" in - ('u') - group "${arr[1]}" "${arr[2]}" - user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}" - # TODO: user:group support - ;; - ('g') - group "${arr[1]}" "${arr[2]}" - ;; - ('m') - group "${arr[2]}" "-" - user "${arr[1]}" "-" "" "${arr[2]}" - ;; - esac - done + while read -r line || [ -n "$line" ] ; do + { [ "${line:0:1}" = '#' ] || [ "${line:0:1}" = ';' ]; } && continue + line="${line## *}" + [ -z "$line" ] && continue + eval "arr=( $line )" + case "${arr[0]}" in + ('u') + if [[ "${arr[2]}" == *":"* ]]; then + user "${arr[1]}" "${arr[2]%:*}" "${arr[3]}" "${arr[2]#*:}" "${arr[4]}" "${arr[5]}" + else + group "${arr[1]}" "${arr[2]}" + user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}" + fi + ;; + ('g') + group "${arr[1]}" "${arr[2]}" + ;; + ('m') + group "${arr[2]}" "-" + user "${arr[1]}" "-" "" "${arr[1]}" "" "" + usermod "${arr[1]}" "${arr[2]}" + ;; + esac + done } for fn in "$@"; do - [ -e "$fn" ] || continue - echo "# generated from $(basename $fn)" - parse < "$fn" + [ -e "$fn" ] || continue + echo "# generated from $(basename "$fn")" + parse <"$fn" done diff --git a/SPECS/systemd.spec b/SPECS/systemd.spec index 61e7d0c..778682a 100644 --- a/SPECS/systemd.spec +++ b/SPECS/systemd.spec @@ -21,7 +21,7 @@ Name: systemd Url: https://systemd.io Version: 252 -Release: 14%{?dist}.3 +Release: 18%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -304,28 +304,149 @@ Patch0223: 0223-test-add-coverage-for-26467.patch Patch0224: 0224-test-add-coverage-for-24177.patch Patch0225: 0225-logind-session-make-stopping-of-idle-session-visible.patch Patch0226: 0226-journal-file-Fix-return-value-in-bump_entry_array.patch -Patch0227: 0227-Revert-user-delegate-cpu-controller-assign-weights-t.patch -Patch0228: 0228-systemd-Support-OOMPolicy-in-scope-units.patch -Patch0229: 0229-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch -Patch0230: 0230-man-rework-description-of-OOMPolicy-a-bit.patch -Patch0231: 0231-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch -Patch0232: 0232-meson-Store-fuzz-tests-in-structured-way.patch -Patch0233: 0233-meson-Generate-fuzzer-inputs-with-directives.patch -Patch0234: 0234-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch -Patch0235: 0235-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch -Patch0236: 0236-journal-def-fix-type-of-signature-to-match-the-actua.patch -Patch0237: 0237-journal-use-compound-initialization-for-journal-file.patch -Patch0238: 0238-journald-fix-log-message.patch -Patch0239: 0239-sd-journal-cache-results-of-parsing-environment-vari.patch -Patch0240: 0240-compress-introduce-compression_supported-helper-func.patch -Patch0241: 0241-sd-journal-always-use-the-compression-algorithm-spec.patch -Patch0242: 0242-sd-journal-allow-to-specify-compression-algorithm-th.patch -Patch0243: 0243-test-add-test-case-that-journal-file-is-created-with.patch -Patch0244: 0244-ci-workflow-for-gathering-metadata-for-source-git-au.patch -Patch0245: 0245-ci-first-part-of-the-source-git-automation-commit-li.patch -Patch0246: 0246-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch -Patch0247: 0247-elf-util-check-for-overflow-when-computing-end-of-co.patch -Patch0248: 0248-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch +Patch0227: 0227-systemd-Support-OOMPolicy-in-scope-units.patch +Patch0228: 0228-systemd-Default-to-OOMPolicy-continue-for-login-sess.patch +Patch0229: 0229-man-rework-description-of-OOMPolicy-a-bit.patch +Patch0230: 0230-core-man-add-missing-integration-of-OOMPolicy-in-sco.patch +Patch0231: 0231-meson-Store-fuzz-tests-in-structured-way.patch +Patch0232: 0232-meson-Generate-fuzzer-inputs-with-directives.patch +Patch0233: 0233-oss-fuzz-include-generated-corpora-in-the-final-zip-.patch +Patch0234: 0234-unit-In-cgroupv1-gracefully-terminate-delegated-scop.patch +Patch0235: 0235-ci-trigger-differential-shellcheck-workflow-on-push.patch +Patch0236: 0236-ci-workflow-for-gathering-metadata-for-source-git-au.patch +Patch0237: 0237-ci-first-part-of-the-source-git-automation-commit-li.patch +Patch0238: 0238-ci-Mergify-check-CodeQL-and-build-workflows-based-on.patch +Patch0239: 0239-ci-add-NOTICE-to-also-update-regexp-in-.mergify.yml-.patch +Patch0240: 0240-Support-etc-system-update-for-OSTree-systems.patch +Patch0241: 0241-journal-def-fix-type-of-signature-to-match-the-actua.patch +Patch0242: 0242-journal-use-compound-initialization-for-journal-file.patch +Patch0243: 0243-journald-fix-log-message.patch +Patch0244: 0244-sd-journal-cache-results-of-parsing-environment-vari.patch +Patch0245: 0245-compress-introduce-compression_supported-helper-func.patch +Patch0246: 0246-sd-journal-always-use-the-compression-algorithm-spec.patch +Patch0247: 0247-sd-journal-allow-to-specify-compression-algorithm-th.patch +Patch0248: 0248-test-add-test-case-that-journal-file-is-created-with.patch +Patch0249: 0249-rules-do-not-online-CPU-automatically-on-IBM-platfor.patch +Patch0250: 0250-ci-update-permissions-for-source-git-automation-work.patch +Patch0251: 0251-pstore-fixes-for-dmesg.txt-reconstruction.patch +Patch0252: 0252-pstore-explicitly-set-the-base-when-converting-recor.patch +Patch0253: 0253-pstore-avoid-opening-the-dmesg.txt-file-if-not-reque.patch +Patch0254: 0254-test-add-a-couple-of-tests-for-systemd-pstore.patch +Patch0255: 0255-test-match-all-messages-with-the-FILE-field.patch +Patch0256: 0256-test-build-the-SELinux-test-module-on-the-host.patch +Patch0257: 0257-test-make-the-stress-test-slightly-less-stressful-on.patch +Patch0258: 0258-coredump-use-unaligned_read_ne-32-64-to-parse-auxv.patch +Patch0259: 0259-core-transaction-make-merge_unit_ids-always-return-N.patch +Patch0260: 0260-core-transaction-make-merge_unit_ids-return-non-NULL.patch +Patch0261: 0261-core-transaction-do-not-log-null.patch +Patch0262: 0262-ci-allow-RHEL-only-labels-to-mark-downstream-only-co.patch +Patch0263: 0263-elf-util-discard-PT_LOAD-segment-early-based-on-the-.patch +Patch0264: 0264-elf-util-check-for-overflow-when-computing-end-of-co.patch +Patch0265: 0265-sulogin-use-DEFINE_MAIN_FUNCTION.patch +Patch0266: 0266-sulogin-fix-control-lost-of-the-current-terminal-whe.patch +Patch0267: 0267-journal-vacuum-count-size-of-all-journal-files.patch +Patch0268: 0268-memory-util-add-a-concept-for-gcc-cleanup-attribute-.patch +Patch0269: 0269-macro-introduce-FOREACH_ARRAY-macro.patch +Patch0270: 0270-journal-vacuum-rename-function-to-match-struct-name.patch +Patch0271: 0271-journal-vacuum-use-CLEANUP_ARRAY.patch +Patch0272: 0272-pam-add-call-to-pam_umask.patch +Patch0273: 0273-udev-builtin-net_id-align-VF-representor-names-with-.patch +Patch0274: 0274-pam-add-a-call-to-pam_namespace.patch +Patch0275: 0275-rules-online-CPU-automatically-on-IBM-s390x-platform.patch +Patch0276: 0276-core-mount-escape-invalid-UTF8-char-in-dbus-reply.patch +Patch0277: 0277-Revert-user-delegate-cpu-controller-assign-weights-t.patch +Patch0278: 0278-udev-rules-fix-nvme-symlink-creation-on-namespace-ch.patch +Patch0279: 0279-rules-add-whitespace-after-comma-before-the-line-con.patch +Patch0280: 0280-udev-restore-compat-symlink-for-nvme-devices.patch +Patch0281: 0281-rules-drop-doubled-space.patch +Patch0282: 0282-manager-don-t-taint-the-host-if-cgroups-v1-is-used.patch +Patch0283: 0283-core-service-when-resetting-PID-also-reset-known-fla.patch +Patch0284: 0284-ci-drop-systemd-stable-from-advanced-commit-linter-c.patch +Patch0285: 0285-Revert-core-service-when-resetting-PID-also-reset-kn.patch +Patch0286: 0286-ci-explicitly-install-python3-lldb-COMPILER_VERSION.patch +Patch0287: 0287-doc-add-downstream-CONTRIBUTING-document.patch +Patch0288: 0288-doc-improve-CONTRIBUTING-document.patch +Patch0289: 0289-doc-use-link-with-prefilled-Jira-issue.patch +Patch0290: 0290-docs-link-downstream-CONTRIBUTING-in-README.patch +Patch0291: 0291-bpf-fix-restrict_fs-on-s390x.patch +Patch0292: 0292-udev-net_id-use-naming-scheme-for-RHEL-9.3.patch +Patch0293: 0293-core-timer-Always-use-inactive_exit_timestamp-if-it-.patch +Patch0294: 0294-timer-Use-dual_timestamp_is_set-in-one-more-place.patch +Patch0295: 0295-loginctl-list-users-also-show-state.patch +Patch0296: 0296-loginctl-list-sessions-minor-modernization.patch +Patch0297: 0297-loginctl-list-sessions-also-show-state.patch +Patch0298: 0298-test-add-test-for-state-in-loginctl-list-users-sessi.patch +Patch0299: 0299-test-add-a-missing-session-activation.patch +Patch0300: 0300-test-extend-test-for-loginctl-list.patch +Patch0301: 0301-loginctl-shorten-variable-name.patch +Patch0302: 0302-loginctl-use-bus_map_all_properties.patch +Patch0303: 0303-loginctl-show-session-idle-status-in-list-sessions.patch +Patch0304: 0304-loginctl-some-modernizations.patch +Patch0305: 0305-loginctl-list-sessions-fix-timestamp-for-idle-hint.patch +Patch0306: 0306-loginctl-list-users-use-bus_map_all_properties.patch +Patch0307: 0307-loginctl-also-show-idle-hint-in-session-status.patch +Patch0308: 0308-memory-util-make-ArrayCleanup-passed-to-array_cleanu.patch +Patch0309: 0309-static-destruct-several-cleanups.patch +Patch0310: 0310-static-destruct-introduce-STATIC_ARRAY_DESTRUCTOR_RE.patch +Patch0311: 0311-macro-support-the-case-that-the-number-of-elements-h.patch +Patch0312: 0312-shared-generator-apply-similar-config-reordering-of-.patch +Patch0313: 0313-nulstr-util-make-ret_size-in-strv_make_nulstr-option.patch +Patch0314: 0314-generator-teach-generator_add_symlink-to-instantiate.patch +Patch0315: 0315-units-rework-growfs-units-to-be-just-a-regular-unit-.patch +Patch0316: 0316-fstab-generator-use-correct-targets-when-sysroot-is-.patch +Patch0317: 0317-fstab-generator-add-SYSTEMD_SYSFS_CHECK-env-var.patch +Patch0318: 0318-test-add-fstab-file-support-for-fstab-generator-test.patch +Patch0319: 0319-test-fstab-generator-also-check-file-contents.patch +Patch0320: 0320-test-fstab-generator-add-tests-for-mount-options.patch +Patch0321: 0321-fstab-generator-split-out-several-functions-from-par.patch +Patch0322: 0322-fstab-generator-call-add_swap-earlier.patch +Patch0323: 0323-fstab-generator-refuse-to-add-swap-earlier-if-disabl.patch +Patch0324: 0324-fstab-generator-refuse-invalid-mount-point-path-in-f.patch +Patch0325: 0325-fstab-generator-fix-error-code-propagation-in-run_ge.patch +Patch0326: 0326-fstab-generator-support-defining-mount-units-through.patch +Patch0327: 0327-test-add-test-cases-for-defining-mount-and-swap-unit.patch +Patch0328: 0328-generators-change-TimeoutSec-0-to-TimeoutSec-infinit.patch +Patch0329: 0329-units-change-TimeoutSec-0-to-TimeoutSec-infinity.patch +Patch0330: 0330-fstab-generator-use-correct-swap-name-var.patch +Patch0331: 0331-fstab-generator-add-more-parameter-name-comments.patch +Patch0332: 0332-fstab-generator-unify-initrd-root-device.target-depe.patch +Patch0333: 0333-fstab-util-add-fstab_is_bind.patch +Patch0334: 0334-fstab-generator-resolve-bind-mount-source-when-in-in.patch +Patch0335: 0335-fstab-generator-rename-initrd-flag-to-prefix_sysroot.patch +Patch0336: 0336-fstab-generator-fix-target-of-sysroot-usr.patch +Patch0337: 0337-fstab-generator-add-rd.systemd.mount-extra-and-frien.patch +Patch0338: 0338-fstab-generator-add-a-flag-to-accept-entry-for-in-in.patch +Patch0339: 0339-test-fstab-generator-extract-core-part-as-a-function.patch +Patch0340: 0340-test-fstab-generator-also-test-with-SYSTEMD_IN_INITR.patch +Patch0341: 0341-test-fstab-generator-add-more-tests-for-systemd.moun.patch +Patch0342: 0342-fstab-generator-enable-fsck-for-block-device-mounts-.patch +Patch0343: 0343-core-use-correct-scope-of-looking-up-units.patch +Patch0344: 0344-test-merge-unit-file-related-tests-into-TEST-23-UNIT.patch +Patch0345: 0345-test-rename-TEST-07-ISSUE-1981-to-TEST-07-PID1.patch +Patch0346: 0346-test-merge-TEST-08-ISSUE-2730-into-TEST-07-PID1.patch +Patch0347: 0347-test-merge-TEST-09-ISSUE-2691-into-TEST-07-PID1.patch +Patch0348: 0348-test-merge-TEST-10-ISSUE-2467-with-TEST-07-PID1.patch +Patch0349: 0349-test-merge-TEST-11-ISSUE-3166-into-TEST-07-PID1.patch +Patch0350: 0350-test-merge-TEST-12-ISSUE-3171-into-TEST-07-PID1.patch +Patch0351: 0351-test-move-TEST-23-s-units-into-a-dedicated-subfolder.patch +Patch0352: 0352-test-merge-TEST-47-ISSUE-14566-into-TEST-07-PID1.patch +Patch0353: 0353-test-merge-TEST-51-ISSUE-16115-into-TEST-07-PID1.patch +Patch0354: 0354-test-merge-TEST-20-MAINPIDGAMES-into-TEST-07-PID1.patch +Patch0355: 0355-test-abstract-the-common-test-parts-into-a-utility-s.patch +Patch0356: 0356-test-add-tests-for-JoinsNamespaceOf.patch +Patch0357: 0357-core-unit-drop-doubled-empty-line.patch +Patch0358: 0358-core-unit-make-JoinsNamespaceOf-implies-the-inverse-.patch +Patch0359: 0359-core-unit-search-shared-namespace-in-transitive-rela.patch +Patch0360: 0360-core-unit-update-bidirectional-dependency-simultaneo.patch +Patch0361: 0361-resolvectl-fix-type-of-ifindex-D-Bus-field-and-make-.patch +Patch0362: 0362-resolved-add-some-line-breaks-comments.patch +Patch0363: 0363-resolvectl-don-t-filter-loopback-DNS-server-from-glo.patch +Patch0364: 0364-blockdev-util-add-simple-wrapper-around-BLKSSZGET.patch +Patch0365: 0365-loop-util-insist-on-setting-the-sector-size-correctl.patch +Patch0366: 0366-dissect-image-add-probe_sector_size-helper-for-detec.patch +Patch0367: 0367-loop-util-always-tell-kernel-explicitly-about-loopba.patch +Patch0368: 0368-Revert-Treat-EPERM-as-not-available-too.patch +Patch0369: 0369-Revert-test-accept-EPERM-for-unavailable-idmapped-mo.patch # Downstream-only patches (9000–9999) @@ -982,24 +1103,24 @@ fi %{?ldconfig} function mod_nss() { - if [ -f "$1" ] ; then - # Add nss-systemd to passwd and group - grep -E -q '^(passwd|group):.* systemd' "$1" || + if [ $1 -eq 1 ] && [ -f "$2" ]; then + # Add nss-systemd to passwd (only once, on install) + grep -E -q '^(passwd|group):.* systemd' "$2" || sed -i.bak -r -e ' s/^(passwd|group):(.*)/\1:\2 systemd/ - ' "$1" &>/dev/null || : + ' "$2" &>/dev/null || : fi } FILE="$(readlink /etc/nsswitch.conf || echo /etc/nsswitch.conf)" if [ "$FILE" = "/etc/authselect/nsswitch.conf" ] && authselect check &>/dev/null; then - mod_nss "/etc/authselect/user-nsswitch.conf" + mod_nss $1 "/etc/authselect/user-nsswitch.conf" authselect apply-changes &> /dev/null || : else - mod_nss "$FILE" + mod_nss $1 "$FILE" # also apply the same changes to user-nsswitch.conf to affect # possible future authselect configuration - mod_nss "/etc/authselect/user-nsswitch.conf" + mod_nss $1 "/etc/authselect/user-nsswitch.conf" fi # check if nobody or nfsnobody is defined @@ -1147,49 +1268,159 @@ getent passwd systemd-oom &>/dev/null || useradd -r -l -g systemd-oom -d / -s /s %files standalone-sysusers -f .file-list-standalone-sysusers %changelog -* Mon Jul 17 2023 systemd maintenance team - 252-14.3 -- manager: don't taint the host if cgroups v1 is used (#2196479) +* Tue Aug 22 2023 systemd maintenance team - 252-18 +- doc: add downstream CONTRIBUTING document (#2170883) +- doc: improve CONTRIBUTING document (#2170883) +- doc: use link with prefilled Jira issue (#2170883) +- docs: link downstream CONTRIBUTING in README (#2170883) +- bpf: fix restrict_fs on s390x (#2230364) +- udev/net_id: use naming scheme for RHEL-9.3 (#2231845) +- core/timer: Always use inactive_exit_timestamp if it is set (#2211065) +- timer: Use dual_timestamp_is_set() in one more place (#2211065) +- loginctl: list-users: also show state (#2209912) +- loginctl: list-sessions: minor modernization (#2209912) +- loginctl: list-sessions: also show state (#2209912) +- test: add test for state in loginctl list-{users,sessions} (#2209912) +- test: add a missing session activation (#2209912) +- test: extend test for loginctl list-* (#2209912) +- loginctl: shorten variable name (#2209912) +- loginctl: use bus_map_all_properties (#2209912) +- loginctl: show session idle status in list-sessions (#2209912) +- loginctl: some modernizations (#2209912) +- loginctl: list-sessions: fix timestamp for idle hint (#2209912) +- loginctl: list-users: use bus_map_all_properties (#2209912) +- loginctl: also show idle hint in session-status (#2209912) +- memory-util: make ArrayCleanup passed to array_cleanup() const (#2190226) +- static-destruct: several cleanups (#2190226) +- static-destruct: introduce STATIC_ARRAY_DESTRUCTOR_REGISTER() (#2190226) +- macro: support the case that the number of elements has const qualifier (#2190226) +- shared/generator: apply similar config reordering of generated units (#2190226) +- nulstr-util: make ret_size in strv_make_nulstr() optional (#2190226) +- generator: teach generator_add_symlink() to instantiate specified unit (#2190226) +- units: rework growfs units to be just a regular unit that is instantiated (#2190226) +- fstab-generator: use correct targets when /sysroot is specificied in fstab only (#2190226) +- fstab-generator: add SYSTEMD_SYSFS_CHECK env var (#2190226) +- test: add fstab file support for fstab-generator tests (#2190226) +- test-fstab-generator: also check file contents (#2190226) +- test-fstab-generator: add tests for mount options (#2190226) +- fstab-generator: split out several functions from parse_fstab() (#2190226) +- fstab-generator: call add_swap() earlier (#2190226) +- fstab-generator: refuse to add swap earlier if disabled (#2190226) +- fstab-generator: refuse invalid mount point path in fstab earlier (#2190226) +- fstab-generator: fix error code propagation in run_generator() (#2190226) +- fstab-generator: support defining mount units through kernel command line (#2190226) +- test: add test cases for defining mount and swap units from kernel cmdline (#2190226) +- generators: change TimeoutSec=0 to TimeoutSec=infinity (#2190226) +- units: change TimeoutSec=0 to TimeoutSec=infinity (#2190226) +- fstab-generator: use correct swap name var (#2190226) +- fstab-generator: add more parameter name comments (#2190226) +- fstab-generator: unify initrd-root-device.target dependency handling code (#2190226) +- fstab-util: add fstab_is_bind (#2190226) +- fstab-generator: resolve bind mount source when in initrd (#2190226) +- fstab-generator: rename 'initrd' flag to 'prefix_sysroot' (#2190226) +- fstab-generator: fix target of /sysroot/usr (#2190226) +- fstab-generator: add rd.systemd.mount-extra= and friends (#2190226) +- fstab-generator: add a flag to accept entry for "/" in initrd (#2190226) +- test-fstab-generator: extract core part as a function (#2190226) +- test-fstab-generator: also test with SYSTEMD_IN_INITRD=no (#2190226) +- test-fstab-generator: add more tests for systemd.mount-extra= and friends (#2190226) +- fstab-generator: enable fsck for block device mounts specified in systemd.mount-extra= (#2190226) +- core: use correct scope of looking up units (#2226980) +- test: merge unit file related tests into TEST-23-UNIT-FILE (#2213521) +- test: rename TEST-07-ISSUE-1981 to TEST-07-PID1 (#2213521) +- test: merge TEST-08-ISSUE-2730 into TEST-07-PID1 (#2213521) +- test: merge TEST-09-ISSUE-2691 into TEST-07-PID1 (#2213521) +- test: merge TEST-10-ISSUE-2467 with TEST-07-PID1 (#2213521) +- test: merge TEST-11-ISSUE-3166 into TEST-07-PID1 (#2213521) +- test: merge TEST-12-ISSUE-3171 into TEST-07-PID1 (#2213521) +- test: move TEST-23's units into a dedicated subfolder (#2213521) +- test: merge TEST-47-ISSUE-14566 into TEST-07-PID1 (#2213521) +- test: merge TEST-51-ISSUE-16115 into TEST-07-PID1 (#2213521) +- test: merge TEST-20-MAINPIDGAMES into TEST-07-PID1 (#2213521) +- test: abstract the common test parts into a utility script (#2213521) +- test: add tests for JoinsNamespaceOf= (#2213521) +- core/unit: drop doubled empty line (#2213521) +- core/unit: make JoinsNamespaceOf= implies the inverse dependency (#2213521) +- core/unit: search shared namespace in transitive relation of JoinsNamespaceOf= (#2213521) +- core/unit: update bidirectional dependency simultaneously (#2213521) +- resolvectl: fix type of ifindex D-Bus field, and make sure to initialize to zero in all code paths (#2161260) +- resolved: add some line-breaks/comments (#2161260) +- resolvectl: don't filter loopback DNS server from global DNS server list (#2161260) +- blockdev-util: add simple wrapper around BLKSSZGET (#2170883) +- loop-util: insist on setting the sector size correctly (#2170883) +- dissect-image: add probe_sector_size() helper for detecting sector size of a GPT disk image (#2170883) +- loop-util: always tell kernel explicitly about loopback sector size (#2170883) +- Revert "Treat EPERM as "not available" too" (#2178222) +- Revert "test: accept EPERM for unavailable idmapped mounts as well" (#2178222) -* Thu Jul 13 2023 systemd maintenance team - 252-14.2 -- elf-util: discard PT_LOAD segment early based on the start address. (#2222259) -- elf-util: check for overflow when computing end of core's PT_LOAD segments (#2222259) +* Fri Aug 04 2023 systemd maintenance team - 252-17 +- Revert "core/service: when resetting PID also reset known flag" (#2225667 +#2210237) +- ci: explicitly install python3-lldb-$COMPILER_VERSION (#2225667) -* Wed May 24 2023 systemd maintenance team - 252-14.1 -- Bump version to 252-14.1 to make sure that NEVRA is higher than systemd-252-14.el9.rhaos4.13 (#2184929) +* Mon Jul 17 2023 systemd maintenance team - 252-16 +- ci: update permissions for source-git automation workflows (#2170883) +- pstore: fixes for dmesg.txt reconstruction (#2170883) +- pstore: explicitly set the base when converting record ID (#2170883) +- pstore: avoid opening the dmesg.txt file if not requested (#2170883) +- test: add a couple of tests for systemd-pstore (#2170883) +- test: match all messages with the FILE field (#2170883) +- test: build the SELinux test module on the host (#2170883) +- test: make the stress test slightly less stressful on slower machines (#2170883) +- coredump: use unaligned_read_ne{32,64}() to parse auxv (#2170883) +- core/transaction: make merge_unit_ids() always return NUL-terminated string (#2170883) +- core/transaction: make merge_unit_ids() return non-NULL on success (#2170883) +- core/transaction: do not log "(null)" (#2170883) +- ci: allow `RHEL-only` labels to mark downstream-only commits (#2170883) +- elf-util: discard PT_LOAD segment early based on the start address. (#2215412) +- elf-util: check for overflow when computing end of core's PT_LOAD segments (#2215412) +- sulogin: use DEFINE_MAIN_FUNCTION() (#2169959) +- sulogin: fix control lost of the current terminal when default.target is rescue.target (#2169959) +- journal-vacuum: count size of all journal files (#2182632) +- memory-util: add a concept for gcc cleanup attribute based array destruction (#2182632) +- macro: introduce FOREACH_ARRAY() macro (#2182632) +- journal-vacuum: rename function to match struct name (#2182632) +- journal-vacuum: use CLEANUP_ARRAY (#2182632) +- pam: add call to pam_umask (#2210145) +- udev-builtin-net_id: align VF representor names with VF names (#2218886) +- pam: add a call to pam_namespace (#2218184) +- rules: online CPU automatically on IBM s390x platforms when configured (#2212612) +- core/mount: escape invalid UTF8 char in dbus reply (#2208240) +- Revert "user: delegate cpu controller, assign weights to user slices" (#2176899) +- udev-rules: fix nvme symlink creation on namespace changes (#2172509) +- rules: add whitespace after comma before the line continuation (#2172509) +- udev: restore compat symlink for nvme devices (#2172509) +- rules: drop doubled space (#2172509) +- manager: don't taint the host if cgroups v1 is used (#2193456) +- core/service: when resetting PID also reset known flag (#2210237) +- ci: drop systemd-stable from advanced-commit-linter config (#2170883) -* Thu May 18 2023 systemd maintenance team - 252-13.1 -- journal-def: fix type of signature to match the actual field in the Header structure (#2184929) -- journal: use compound initialization for journal file Header structure (#2184929) -- journald: fix log message (#2184929) -- sd-journal: cache results of parsing environment variables (#2184929) -- compress: introduce compression_supported() helper function (#2184929) -- sd-journal: always use the compression algorithm specified in the header (#2184929) -- sd-journal: allow to specify compression algorithm through env (#2184929) -- test: add test case that journal file is created with the requested compression algorithm (#2184929) -- ci: workflow for gathering metadata for source-git automation (#2184929) -- ci: first part of the source-git automation - commit linter (#2184929) +* Thu May 18 2023 systemd maintenance team - 252-15 +- ci: trigger `differential-shellcheck` workflow on push (#2100440) +- ci: workflow for gathering metadata for source-git automation (#2100440) +- ci: first part of the source-git automation - commit linter (#2100440) +- ci(Mergify): check CodeQL and build workflows based on changed files (#2100440) +- ci: add NOTICE to also update regexp in `.mergify.yml` when updating `paths` property (#2100440) +- Support /etc/system-update for OSTree systems (#2203133) +- journal-def: fix type of signature to match the actual field in the Header structure (#2183546) +- journal: use compound initialization for journal file Header structure (#2183546) +- journald: fix log message (#2183546) +- sd-journal: cache results of parsing environment variables (#2183546) +- compress: introduce compression_supported() helper function (#2183546) +- sd-journal: always use the compression algorithm specified in the header (#2183546) +- sd-journal: allow to specify compression algorithm through env (#2183546) +- test: add test case that journal file is created with the requested compression algorithm (#2183546) +- rules: do not online CPU automatically on IBM platforms (#2143107) -* Mon Mar 20 2023 systemd maintenance team - 252-13 -- spec: release bump (#2179165) - -* Mon Mar 20 2023 systemd maintenance team - 252-12 -- unit: In cgroupv1, gracefully terminate delegated scopes again (#2179165) - -* Tue Mar 14 2023 systemd maintenance team - 252-11 -- spec: release bump (#2175619) - -* Fri Mar 10 2023 systemd maintenance team - 252-10 -- spec: move man for sd-boot into boot-unsigned subpackage (#2175619) - -* Fri Mar 10 2023 systemd maintenance team - 252-9 -- Revert "user: delegate cpu controller, assign weights to user slices" (#2173996) -- systemd: Support OOMPolicy in scope units (#2175619) -- systemd: Default to OOMPolicy=continue for login session scopes (#2175619) -- man: rework description of OOMPolicy= a bit (#2175619) -- core,man: add missing integration of OOMPolicy= in scopes (#2175619) -- meson: Store fuzz tests in structured way (#2175619) -- meson: Generate fuzzer inputs with directives (#2175619) -- oss-fuzz: include generated corpora in the final zip file (#2175619) +* Tue Mar 21 2023 systemd maintenance team - 252-14 +- systemd: Support OOMPolicy in scope units (#2176918) +- systemd: Default to OOMPolicy=continue for login session scopes (#2176918) +- man: rework description of OOMPolicy= a bit (#2176918) +- core,man: add missing integration of OOMPolicy= in scopes (#2176918) +- meson: Store fuzz tests in structured way (#2176918) +- meson: Generate fuzzer inputs with directives (#2176918) +- oss-fuzz: include generated corpora in the final zip file (#2176918) +- unit: In cgroupv1, gracefully terminate delegated scopes again (#2180120) * Mon Feb 27 2023 systemd maintenance team - 252-8 - journal-file: Fix return value in bump_entry_array() (#2173682)