systemd-239-79

Resolves: RHEL-1087,RHEL-6213
This commit is contained in:
Jan Macku 2024-01-08 10:25:04 +01:00
parent ef967387bc
commit 2294de3d20
11 changed files with 1371 additions and 1 deletions

View File

@ -0,0 +1,196 @@
From 1628f48a0ecd13db92b79b7689e74b0ed4cb31a0 Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Thu, 14 Sep 2023 13:54:12 +0200
Subject: [PATCH] ci: Extend source-git-automation
* on schedule and on demand workflows
* Added Tracker validation for Bugzilla and Jira
rhel-only
Resolves: RHEL-1087
---
.github/tracker-validator.yml | 13 +++
.../source-git-automation-on-demand.yml | 99 +++++++++++++++++++
.github/workflows/source-git-automation.yml | 29 +++++-
3 files changed, 139 insertions(+), 2 deletions(-)
create mode 100644 .github/tracker-validator.yml
create mode 100644 .github/workflows/source-git-automation-on-demand.yml
diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml
new file mode 100644
index 0000000000..10ead63eaa
--- /dev/null
+++ b/.github/tracker-validator.yml
@@ -0,0 +1,13 @@
+labels:
+ missing-tracker: tracker/missing
+ invalid-product: tracker/invalid-product
+ invalid-component: tracker/invalid-component
+ unapproved: tracker/unapproved
+products:
+ - CentOS Stream 8
+ - rhel-8.2.0
+ - rhel-8.4.0
+ - rhel-8.6.0
+ - rhel-8.8.0
+ - rhel-8.9.0
+ - rhel-8.10.0
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
new file mode 100644
index 0000000000..92a65c8cc7
--- /dev/null
+++ b/.github/workflows/source-git-automation-on-demand.yml
@@ -0,0 +1,99 @@
+---
+
+name: Source git Automation Scheduled/On Demand
+on:
+ schedule:
+ # Workflow runs every 15 minutes
+ - cron: '*/15 * * * *'
+ workflow_dispatch:
+ inputs:
+ pr-number:
+ description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs'
+ required: true
+ default: '0'
+
+permissions:
+ contents: read
+
+jobs:
+ # Get all open PRs
+ gather-pull-requests:
+ if: github.repository == 'redhat-plumbers/systemd-rhel8'
+ runs-on: ubuntu-latest
+
+ outputs:
+ pr-numbers: ${{ steps.get-pr-numbers.outputs.result }}
+ pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }}
+
+ steps:
+ - id: get-pr-numbers
+ if: inputs.pr-number == '0'
+ name: Get all open PRs
+ uses: actions/github-script@v6
+ with:
+ # !FIXME: this is not working if there is more than 100 PRs opened
+ script: |
+ const { data: pullRequests } = await github.rest.pulls.list({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ state: 'open',
+ per_page: 100
+ });
+ return pullRequests.map(pr => pr.number);
+
+ - id: parse-manual-input
+ if: inputs.pr-number != '0'
+ name: Parse manual input
+ run: |
+ echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT
+ shell: bash
+
+ validate-pr:
+ name: 'Validation of Pull Request #${{ matrix.pr-number }}'
+ needs: [ gather-pull-requests ]
+ runs-on: ubuntu-latest
+
+ strategy:
+ fail-fast: false
+ matrix:
+ pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
+
+ permissions:
+ statuses: write
+ checks: write
+ pull-requests: write
+
+ steps:
+ - name: Repository checkout
+ uses: actions/checkout@v3
+
+ - id: metadata
+ name: Gather Pull Request Metadata
+ uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
+ with:
+ pr-number: ${{ matrix.pr-number }}
+
+ - id: commit-linter
+ name: Lint Commits
+ uses: redhat-plumbers-in-action/advanced-commit-linter@v2
+ with:
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ # Validates tracker, changes tracker status, updates PR title
+ - id: tracker-validator
+ name: Validate Tracker
+ uses: redhat-plumbers-in-action/tracker-validator@v1
+ with:
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
+ component: systemd
+ tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
+ tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
+ bugzilla-instance: https://bugzilla.redhat.com
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
+ jira-instance: https://issues.redhat.com
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ # TODO: merge PR if all checks passed
+ # TODO: add comment to Tracker that PR was merged ...
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
index e653e28a7f..16c6f83d77 100644
--- a/.github/workflows/source-git-automation.yml
+++ b/.github/workflows/source-git-automation.yml
@@ -12,7 +12,8 @@ jobs:
download-metadata:
if: >
github.event.workflow_run.event == 'pull_request' &&
- github.event.workflow_run.conclusion == 'success'
+ github.event.workflow_run.conclusion == 'success' &&
+ github.repository == 'redhat-plumbers/systemd-rhel8'
runs-on: ubuntu-latest
outputs:
@@ -33,13 +34,37 @@ jobs:
validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
permissions:
+ statuses: write
checks: write
pull-requests: write
steps:
- id: commit-linter
name: Lint Commits
- uses: redhat-plumbers-in-action/advanced-commit-linter@v1
+ uses: redhat-plumbers-in-action/advanced-commit-linter@v2
with:
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
token: ${{ secrets.GITHUB_TOKEN }}
+
+ # Validates tracker, changes tracker status, updates PR title
+ tracker-validation:
+ needs: [ download-metadata, commit-linter ]
+ runs-on: ubuntu-latest
+
+ permissions:
+ checks: write
+ pull-requests: write
+
+ steps:
+ - name: Validate Tracker
+ uses: redhat-plumbers-in-action/tracker-validator@v1
+ with:
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
+ component: systemd
+ tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
+ tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
+ bugzilla-instance: https://bugzilla.redhat.com
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
+ jira-instance: https://issues.redhat.com
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
+ token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,32 @@
From 21200fc506b1d15be6ed6d5b9ac70f1ec865f9bc Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Tue, 19 Sep 2023 09:53:35 +0200
Subject: [PATCH] ci: add missing configuration for commit linter
rhel-only
Related: RHEL-1087
---
.github/advanced-commit-linter.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml
index 0fb74a9dc8..86f0e911f2 100644
--- a/.github/advanced-commit-linter.yml
+++ b/.github/advanced-commit-linter.yml
@@ -11,6 +11,7 @@ policy:
- 'Resolves: #?'
- 'Related: #?'
- 'Reverts: #?'
+ type: bugzilla
issue-format:
- '\d+$'
url: 'https://bugzilla.redhat.com/show_bug.cgi?id='
@@ -18,6 +19,7 @@ policy:
- 'Resolves: '
- 'Related: '
- 'Reverts: '
+ type: jira
issue-format:
- 'RHEL-\d+$'
url: 'https://issues.redhat.com/browse/'

View File

@ -0,0 +1,25 @@
From ffd775b4b96ce0d772bcbb2fe2fbc62ed06bb4a4 Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Tue, 19 Sep 2023 15:17:48 +0200
Subject: [PATCH] ci: add `Red Hat Enterprise Linux 8` to the list of supported
products
rhel-only
Related: RHEL-1087
---
.github/tracker-validator.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml
index 10ead63eaa..500dce3d92 100644
--- a/.github/tracker-validator.yml
+++ b/.github/tracker-validator.yml
@@ -4,6 +4,7 @@ labels:
invalid-component: tracker/invalid-component
unapproved: tracker/unapproved
products:
+ - Red Hat Enterprise Linux 8
- CentOS Stream 8
- rhel-8.2.0
- rhel-8.4.0

View File

@ -0,0 +1,95 @@
From bf728def0c6eebdf8d2b8912232ba7806e109293 Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Fri, 20 Oct 2023 13:32:22 +0200
Subject: [PATCH] ci: enable source-git automation to validate reviews and ci
results
rhel-only
Related: RHEL-1087
---
.github/pull-request-validator.yml | 4 ++++
.../source-git-automation-on-demand.yml | 14 ++++++++++----
.github/workflows/source-git-automation.yml | 18 +++++++++++++++++-
3 files changed, 31 insertions(+), 5 deletions(-)
create mode 100644 .github/pull-request-validator.yml
diff --git a/.github/pull-request-validator.yml b/.github/pull-request-validator.yml
new file mode 100644
index 0000000000..4bb5bbec12
--- /dev/null
+++ b/.github/pull-request-validator.yml
@@ -0,0 +1,4 @@
+labels:
+ missing-review: pr/needs-review
+ changes-requested: pr/changes-requested
+ missing-failing-ci: pr/needs-ci
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
index 92a65c8cc7..e70ba4857a 100644
--- a/.github/workflows/source-git-automation-on-demand.yml
+++ b/.github/workflows/source-git-automation-on-demand.yml
@@ -73,7 +73,8 @@ jobs:
with:
pr-number: ${{ matrix.pr-number }}
- - id: commit-linter
+ - if: ${{ !cancelled() }}
+ id: commit-linter
name: Lint Commits
uses: redhat-plumbers-in-action/advanced-commit-linter@v2
with:
@@ -81,7 +82,8 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
# Validates tracker, changes tracker status, updates PR title
- - id: tracker-validator
+ - if: ${{ !cancelled() }}
+ id: tracker-validator
name: Validate Tracker
uses: redhat-plumbers-in-action/tracker-validator@v1
with:
@@ -95,5 +97,9 @@ jobs:
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
- # TODO: merge PR if all checks passed
- # TODO: add comment to Tracker that PR was merged ...
+ - if: ${{ !cancelled() }}
+ name: Pull Request Validator
+ uses: redhat-plumbers-in-action/pull-request-validator@v1
+ with:
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
+ token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
index 16c6f83d77..9faaaca099 100644
--- a/.github/workflows/source-git-automation.yml
+++ b/.github/workflows/source-git-automation.yml
@@ -47,7 +47,8 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
# Validates tracker, changes tracker status, updates PR title
- tracker-validation:
+ tracker-validator:
+ if: ${{ !cancelled() }}
needs: [ download-metadata, commit-linter ]
runs-on: ubuntu-latest
@@ -68,3 +69,18 @@ jobs:
jira-instance: https://issues.redhat.com
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
+
+ pull-request-validator:
+ needs: [ download-metadata ]
+ runs-on: ubuntu-latest
+
+ permissions:
+ checks: write
+ pull-requests: write
+
+ steps:
+ - name: Pull Request Validator
+ uses: redhat-plumbers-in-action/pull-request-validator@v1
+ with:
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
+ token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,52 @@
From 36266d377ee5e57e24cd3c45f6db2a29919798f3 Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Fri, 20 Oct 2023 13:33:38 +0200
Subject: [PATCH] ci: remove Mergify config - replaced by Pull Request
Validator
rhel-only
Related: RHEL-1087
---
.mergify.yml | 32 --------------------------------
1 file changed, 32 deletions(-)
delete mode 100644 .mergify.yml
diff --git a/.mergify.yml b/.mergify.yml
deleted file mode 100644
index 624eb7291d..0000000000
--- a/.mergify.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-# doc: https://docs.mergify.com
----
-
-pull_request_rules:
- - name: Add `needs-ci` label on CI fail
- conditions:
- - label!=ci-waived
- - or:
- # Unit tests
- - -check-success=build (stream8, GCC)
- - -check-success=build (stream8, GCC_ASAN)
- # CentOS Stream CI
- - -check-success=CentOS CI (CentOS Stream 8)
- actions:
- label:
- add:
- - needs-ci
-
- - name: Remove `needs-ci` label on CI success
- conditions:
- - or:
- - label=ci-waived
- - and:
- # Unit tests
- - check-success=build (stream8, GCC)
- - check-success=build (stream8, GCC_ASAN)
- # CentOS Stream CI
- - check-success=CentOS CI (CentOS Stream 8)
- actions:
- label:
- remove:
- - needs-ci

View File

@ -0,0 +1,84 @@
From 73b327eeeb3e2f17cbc1abd19aa5b87c28fcf509 Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Fri, 3 Nov 2023 14:07:04 +0100
Subject: [PATCH] ci: enable auto-merge GH Action
rhel-only
Related: RHEL-1087
---
.github/auto-merge.yml | 4 ++++
.../source-git-automation-on-demand.yml | 14 ++++++++++++
.github/workflows/source-git-automation.yml | 22 +++++++++++++++++++
3 files changed, 40 insertions(+)
create mode 100644 .github/auto-merge.yml
diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml
new file mode 100644
index 0000000000..35c2539295
--- /dev/null
+++ b/.github/auto-merge.yml
@@ -0,0 +1,4 @@
+labels:
+ dont-merge: dont-merge
+ manual-merge: pr/needs-manual-merge
+target-branch': ['main']
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
index e70ba4857a..948708916d 100644
--- a/.github/workflows/source-git-automation-on-demand.yml
+++ b/.github/workflows/source-git-automation-on-demand.yml
@@ -59,6 +59,7 @@ jobs:
pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
permissions:
+ contents: write
statuses: write
checks: write
pull-requests: write
@@ -103,3 +104,16 @@ jobs:
with:
pr-metadata: ${{ steps.metadata.outputs.metadata }}
token: ${{ secrets.GITHUB_TOKEN }}
+
+ - id: auto-merge
+ name: Auto Merge
+ uses: redhat-plumbers-in-action/auto-merge@v1
+ with:
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
+ tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
+ tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
+ bugzilla-instance: https://bugzilla.redhat.com
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
+ jira-instance: https://issues.redhat.com
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
+ token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
index 9faaaca099..95819baa8b 100644
--- a/.github/workflows/source-git-automation.yml
+++ b/.github/workflows/source-git-automation.yml
@@ -84,3 +84,25 @@ jobs:
with:
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
token: ${{ secrets.GITHUB_TOKEN }}
+
+ auto-merge:
+ needs: [ download-metadata, commit-linter, tracker-validator, pull-request-validator ]
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: write
+ checks: write
+ pull-requests: write
+
+ steps:
+ - name: Auto Merge
+ uses: redhat-plumbers-in-action/auto-merge@v1
+ with:
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
+ tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
+ tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
+ bugzilla-instance: https://bugzilla.redhat.com
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
+ jira-instance: https://issues.redhat.com
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
+ token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,179 @@
From d0f59d4190a9f1e0e6db4b22b5e87bec2db4f7fb Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <fsumsal@redhat.com>
Date: Mon, 27 Nov 2023 15:20:47 +0100
Subject: [PATCH] fstab-generator: allow overriding /etc/fstab with
$SYSTEMD_FSTAB
Based on: ed4ad4889723a9acdf75ed86f10cee0024bbbcbc
Related: RHEL-1087
rhel-only
---
src/cryptsetup/cryptsetup.c | 3 ++-
src/fstab-generator/fstab-generator.c | 28 ++++++++++++++-------------
src/remount-fs/remount-fs.c | 5 +++--
src/shared/fstab-util.c | 4 ++--
src/shared/fstab-util.h | 4 ++++
5 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 11162eb722..de4bc9579c 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -13,6 +13,7 @@
#include "device-util.h"
#include "escape.h"
#include "fileio.h"
+#include "fstab-util.h"
#include "log.h"
#include "mount-util.h"
#include "parse-util.h"
@@ -318,7 +319,7 @@ static char *disk_mount_point(const char *label) {
if (asprintf(&device, "/dev/mapper/%s", label) < 0)
return NULL;
- f = setmntent("/etc/fstab", "re");
+ f = setmntent(fstab_path(), "re");
if (!f)
return NULL;
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index f24c1d29da..105ddd2fd0 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -105,15 +105,17 @@ static int add_swap(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
- r = generator_open_unit_file(arg_dest, "/etc/fstab", name, &f);
+ r = generator_open_unit_file(arg_dest, fstab_path(), name, &f);
if (r < 0)
return r;
- fputs("# Automatically generated by systemd-fstab-generator\n\n"
- "[Unit]\n"
- "SourcePath=/etc/fstab\n"
- "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
- "[Swap]\n", f);
+ fprintf(f,
+ "# Automatically generated by systemd-fstab-generator\n\n"
+ "[Unit]\n"
+ "SourcePath=%s\n"
+ "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
+ "[Swap]\n",
+ fstab_path());
r = write_what(f, what);
if (r < 0)
@@ -334,7 +336,7 @@ static int add_mount(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
- r = generator_open_unit_file(dest, "/etc/fstab", name, &f);
+ r = generator_open_unit_file(dest, fstab_path(), name, &f);
if (r < 0)
return r;
@@ -451,7 +453,7 @@ static int add_mount(
fclose(f);
- r = generator_open_unit_file(dest, "/etc/fstab", automount_name, &f);
+ r = generator_open_unit_file(dest, fstab_path(), automount_name, &f);
if (r < 0)
return r;
@@ -503,17 +505,17 @@ static int add_mount(
static int parse_fstab(bool initrd) {
_cleanup_endmntent_ FILE *f = NULL;
- const char *fstab_path;
+ const char *fstab;
struct mntent *me;
int r = 0;
- fstab_path = initrd ? "/sysroot/etc/fstab" : "/etc/fstab";
- f = setmntent(fstab_path, "re");
+ fstab = initrd ? "/sysroot/etc/fstab" : fstab_path();
+ f = setmntent(fstab, "re");
if (!f) {
if (errno == ENOENT)
return 0;
- return log_error_errno(errno, "Failed to open %s: %m", fstab_path);
+ return log_error_errno(errno, "Failed to open %s: %m", fstab);
}
while ((me = getmntent(f))) {
@@ -592,7 +594,7 @@ static int parse_fstab(bool initrd) {
me->mnt_passno,
makefs*MAKEFS | growfs*GROWFS | noauto*NOAUTO | nofail*NOFAIL | automount*AUTOMOUNT,
post,
- fstab_path);
+ fstab);
}
if (r >= 0 && k < 0)
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
index 9220a00215..5bcee999cc 100644
--- a/src/remount-fs/remount-fs.c
+++ b/src/remount-fs/remount-fs.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include "exit-status.h"
+#include "fstab-util.h"
#include "log.h"
#include "mount-setup.h"
#include "mount-util.h"
@@ -39,14 +40,14 @@ int main(int argc, char *argv[]) {
umask(0022);
- f = setmntent("/etc/fstab", "re");
+ f = setmntent(fstab_path(), "re");
if (!f) {
if (errno == ENOENT) {
r = 0;
goto finish;
}
- r = log_error_errno(errno, "Failed to open /etc/fstab: %m");
+ r = log_error_errno(errno, "Failed to open %s: %m", fstab_path());
goto finish;
}
diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c
index 6fd9866c00..bc0c047509 100644
--- a/src/shared/fstab-util.c
+++ b/src/shared/fstab-util.c
@@ -21,7 +21,7 @@ int fstab_has_fstype(const char *fstype) {
_cleanup_endmntent_ FILE *f = NULL;
struct mntent *m;
- f = setmntent("/etc/fstab", "re");
+ f = setmntent(fstab_path(), "re");
if (!f)
return errno == ENOENT ? false : -errno;
@@ -41,7 +41,7 @@ int fstab_is_mount_point(const char *mount) {
_cleanup_endmntent_ FILE *f = NULL;
struct mntent *m;
- f = setmntent("/etc/fstab", "re");
+ f = setmntent(fstab_path(), "re");
if (!f)
return errno == ENOENT ? false : -errno;
diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h
index 9820f78ca8..9ec6db068c 100644
--- a/src/shared/fstab-util.h
+++ b/src/shared/fstab-util.h
@@ -33,3 +33,7 @@ static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no
}
char *fstab_node_to_udev_node(const char *p);
+
+static inline const char *fstab_path(void) {
+ return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab";
+}

View File

@ -0,0 +1,37 @@
From f4a9bdf74c23a55ea96de696155ce9a5dfa43850 Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <fsumsal@redhat.com>
Date: Mon, 27 Nov 2023 16:16:40 +0100
Subject: [PATCH] fstab-generator: allow overriding path to /sysroot/etc/fstab
too
Based on: 99e3d4767932bce5febb45e8543162d729d17425
Related: RHEL-1087
rhel-only
---
src/fstab-generator/fstab-generator.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 105ddd2fd0..02f0bccd2f 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -503,13 +503,17 @@ static int add_mount(
return 0;
}
+static const char *sysroot_fstab_path(void) {
+ return getenv("SYSTEMD_SYSROOT_FSTAB") ?: "/sysroot/etc/fstab";
+}
+
static int parse_fstab(bool initrd) {
_cleanup_endmntent_ FILE *f = NULL;
const char *fstab;
struct mntent *me;
int r = 0;
- fstab = initrd ? "/sysroot/etc/fstab" : fstab_path();
+ fstab = initrd ? sysroot_fstab_path() : fstab_path();
f = setmntent(fstab, "re");
if (!f) {
if (errno == ENOENT)

View File

@ -0,0 +1,611 @@
From 52026032996f021963f5af8d625a5b9653d3f815 Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <fsumsal@redhat.com>
Date: Mon, 27 Nov 2023 14:54:15 +0100
Subject: [PATCH] test: backport TEST-81-GENERATORS (fstab-generator only)
Some fstab-generator features are not present on RHEL 8 or they behave
differently - in such case there's an inline comment explaining what's
different with a reference to an upstream commit that introduced the
changed behavior.
Related: RHEL-1087
rhel-only
---
test/TEST-81-GENERATORS/Makefile | 1 +
test/TEST-81-GENERATORS/generator-utils.sh | 78 ++++
test/TEST-81-GENERATORS/test.sh | 50 +++
.../testsuite.fstab-generator.sh | 397 ++++++++++++++++++
test/TEST-81-GENERATORS/testsuite.sh | 14 +
test/test-functions | 2 +-
6 files changed, 541 insertions(+), 1 deletion(-)
create mode 120000 test/TEST-81-GENERATORS/Makefile
create mode 100755 test/TEST-81-GENERATORS/generator-utils.sh
create mode 100755 test/TEST-81-GENERATORS/test.sh
create mode 100755 test/TEST-81-GENERATORS/testsuite.fstab-generator.sh
create mode 100755 test/TEST-81-GENERATORS/testsuite.sh
diff --git a/test/TEST-81-GENERATORS/Makefile b/test/TEST-81-GENERATORS/Makefile
new file mode 120000
index 0000000000..e9f93b1104
--- /dev/null
+++ b/test/TEST-81-GENERATORS/Makefile
@@ -0,0 +1 @@
+../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-81-GENERATORS/generator-utils.sh b/test/TEST-81-GENERATORS/generator-utils.sh
new file mode 100755
index 0000000000..fb62747fa1
--- /dev/null
+++ b/test/TEST-81-GENERATORS/generator-utils.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+link_endswith() {
+ [[ -h "${1:?}" && "$(readlink "${1:?}")" =~ ${2:?}$ ]]
+}
+
+link_eq() {
+ [[ -h "${1:?}" && "$(readlink "${1:?}")" == "${2:?}" ]]
+}
+
+# Get the value from a 'key=value' assignment
+opt_get_arg() {
+ local arg
+
+ IFS="=" read -r _ arg <<< "${1:?}"
+ test -n "$arg"
+ echo "$arg"
+}
+
+in_initrd() {
+ [[ "${SYSTEMD_IN_INITRD:-0}" -ne 0 ]]
+}
+
+# Check if we're parsing host's fstab in initrd
+in_initrd_host() {
+ in_initrd && [[ "${SYSTEMD_SYSROOT_FSTAB:-/dev/null}" != /dev/null ]]
+}
+
+in_container() {
+ systemd-detect-virt -qc
+}
+
+opt_filter() (
+ set +x
+ local opt split_options filtered_options
+
+ IFS="," read -ra split_options <<< "${1:?}"
+ for opt in "${split_options[@]}"; do
+ if [[ "$opt" =~ ${2:?} ]]; then
+ continue
+ fi
+
+ filtered_options+=("$opt")
+ done
+
+ IFS=","; printf "%s" "${filtered_options[*]}"
+)
+
+# Run the given generator $1 with target directory $2 - clean the target
+# directory beforehand
+run_and_list() {
+ local generator="${1:?}"
+ local out_dir="${2:?}"
+ local environ
+
+ # If $PID1_ENVIRON is set temporarily overmount /proc/1/environ with
+ # a temporary file that contains contents of $PID1_ENVIRON. This is
+ # necessary in cases where the generator reads the environment through
+ # getenv_for_pid(1, ...) or similar like getty-generator does.
+ #
+ # Note: $PID1_ENVIRON should be a NUL separated list of env assignments
+ if [[ -n "${PID1_ENVIRON:-}" ]]; then
+ environ="$(mktemp)"
+ echo -ne "${PID1_ENVIRON}\0" >"${environ:?}"
+ mount -v --bind "$environ" /proc/1/environ
+ fi
+
+ rm -fr "${out_dir:?}"/*
+ mkdir -p "$out_dir"/{normal,early,late}
+ SYSTEMD_LOG_LEVEL="${SYSTEMD_LOG_LEVEL:-debug}" "$generator" "$out_dir/normal" "$out_dir/early" "$out_dir/late"
+ ls -lR "$out_dir"
+
+ if [[ -n "${environ:-}" ]]; then
+ umount /proc/1/environ
+ rm -f "$environ"
+ fi
+}
diff --git a/test/TEST-81-GENERATORS/test.sh b/test/TEST-81-GENERATORS/test.sh
new file mode 100755
index 0000000000..ec9c608c60
--- /dev/null
+++ b/test/TEST-81-GENERATORS/test.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -e
+TEST_DESCRIPTION="Test systemd generators"
+
+# shellcheck source=test/test-functions
+. "$TEST_BASE_DIR/test-functions"
+
+test_setup() {
+ create_empty_image
+ mkdir -p "${TESTDIR:?}/root"
+ mount "${LOOPDEV:?}p1" "$TESTDIR/root"
+
+ (
+ LOG_LEVEL=5
+ # shellcheck disable=SC2046
+ eval $(udevadm info --export --query=env --name="${LOOPDEV}p2")
+
+ setup_basic_environment
+
+ # mask some services that we do not want to run in these tests
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-hwdb-update.service"
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-journal-catalog-update.service"
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-networkd.service"
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-networkd.socket"
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-resolved.service"
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-machined.service"
+
+ # setup the testsuite service
+ cat >"$initdir/etc/systemd/system/testsuite.service" <<EOF
+[Unit]
+Description=Testsuite service
+
+[Service]
+ExecStart=/bin/bash -x /testsuite.sh
+Type=oneshot
+StandardOutput=tty
+StandardError=tty
+NotifyAccess=all
+EOF
+ cp generator-utils.sh testsuite*.sh "$initdir/"
+
+ setup_testsuite
+ ) || return 1
+ setup_nspawn_root
+
+ ddebug "umount $TESTDIR/root"
+ umount "$TESTDIR/root"
+}
+
+do_test "$@"
diff --git a/test/TEST-81-GENERATORS/testsuite.fstab-generator.sh b/test/TEST-81-GENERATORS/testsuite.fstab-generator.sh
new file mode 100755
index 0000000000..705fd5e5c7
--- /dev/null
+++ b/test/TEST-81-GENERATORS/testsuite.fstab-generator.sh
@@ -0,0 +1,397 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# shellcheck disable=SC2235,SC2233
+set -eux
+set -o pipefail
+
+# shellcheck source=test/TEST-81-GENERATORS/generator-utils.sh
+. "$(dirname "$0")/generator-utils.sh"
+
+GENERATOR_BIN="/usr/lib/systemd/system-generators/systemd-fstab-generator"
+NETWORK_FS_RX="^(afs|ceph|cifs|gfs|gfs2|ncp|ncpfs|nfs|nfs4|ocfs2|orangefs|pvfs2|smb3|smbfs|davfs|glusterfs|lustre|sshfs)$"
+OUT_DIR="$(mktemp -d /tmp/fstab-generator.XXX)"
+FSTAB="$(mktemp)"
+
+at_exit() {
+ rm -fr "${OUT_DIR:?}" "${FSTAB:?}"
+}
+
+trap at_exit EXIT
+
+test -x "${GENERATOR_BIN:?}"
+
+FSTAB_GENERAL=(
+ # Valid entries
+ "/dev/test2 /nofail ext4 nofail 0 0"
+ "/dev/test3 /regular btrfs defaults 0 0"
+ "/dev/test4 /x-systemd.requires xfs x-systemd.requires=foo.service 0 0"
+ "/dev/test5 /x-systemd.before-after xfs x-systemd.before=foo.service,x-systemd.after=bar.mount 0 0"
+# Not supported on RHEL 8
+# "/dev/test6 /x-systemd.wanted-required-by xfs x-systemd.wanted-by=foo.service,x-systemd.required-by=bar.device 0 0"
+ "/dev/test7 /x-systemd.requires-mounts-for xfs x-systemd.requires-mounts-for=/foo/bar/baz 0 0"
+ "/dev/test8 /x-systemd.automount-idle-timeout vfat x-systemd.automount,x-systemd.idle-timeout=50s 0 0"
+ "/dev/test9 /x-systemd.makefs xfs x-systemd.makefs 0 0"
+ "/dev/test10 /x-systemd.growfs xfs x-systemd.growfs 0 0"
+ "/dev/test11 /_netdev ext4 defaults,_netdev 0 0"
+# Not supported on RHEL 8
+# "/dev/test12 /_rwonly ext4 x-systemd.rw-only 0 0"
+ "/dev/test13 /chaos1 zfs x-systemd.requires=hello.service,x-systemd.after=my.device 0 0"
+ "/dev/test14 /chaos2 zfs x-systemd.growfs,x-systemd.makefs 0 0"
+ "/dev/test15 /fstype/auto auto defaults 0 0"
+ "/dev/test16 /fsck/me ext4 defaults 0 1"
+ "/dev/test17 /also/fsck/me ext4 defaults,x-systemd.requires-mounts-for=/var/lib/foo 0 99"
+ "/dev/test18 /swap swap defaults 0 0"
+ "/dev/test19 /swap/makefs swap defaults,x-systemd.makefs 0 0"
+ "/dev/test20 /var xfs defaults,x-systemd.device-timeout=1h 0 0"
+ "/dev/test21 /usr ext4 defaults 0 1"
+ "/dev/test22 /initrd/mount ext2 defaults,x-initrd.mount 0 1"
+ "/dev/test23 /initrd/mount/nofail ext3 defaults,nofail,x-initrd.mount 0 1"
+ "/dev/test24 /initrd/mount/deps ext4 x-initrd.mount,x-systemd.before=early.service,x-systemd.after=late.service 0 1"
+
+ # Incomplete, but valid entries
+ "/dev/incomplete1 /incomplete1"
+ "/dev/incomplete2 /incomplete2 ext4"
+ "/dev/incomplete3 /incomplete3 ext4 defaults"
+ "/dev/incomplete4 /incomplete4 ext4 defaults 0"
+
+ # Remote filesystems
+ "/dev/remote1 /nfs nfs bg 0 0"
+ "/dev/remote2 /nfs4 nfs4 bg 0 0"
+ "bar.tld:/store /remote/storage nfs ro,x-systemd.after=store.service 0 0"
+ "user@host.tld:/remote/dir /remote/top-secret sshfs rw,x-systemd.before=naughty.service 0 0"
+ "foo.tld:/hello /hello/world ceph defaults 0 0"
+ "//192.168.0.1/storage /cifs-storage cifs automount,nofail 0 0"
+)
+
+FSTAB_GENERAL_ROOT=(
+ # rootfs with bunch of options we should ignore and fsck enabled
+ "/dev/test1 / ext4 noauto,nofail,x-systemd.automount,x-systemd.wanted-by=foo,x-systemd.required-by=bar 0 1"
+ "${FSTAB_GENERAL[@]}"
+)
+
+FSTAB_MINIMAL=(
+ "/dev/loop1 /foo/bar ext3 defaults 0 0"
+)
+
+FSTAB_DUPLICATE=(
+ "/dev/dup1 / ext4 defaults 0 1"
+ "/dev/dup2 / ext4 defaults,x-systemd.requires=foo.mount 0 2"
+)
+
+FSTAB_INVALID=(
+ # Ignored entries
+ "/dev/ignored1 /sys/fs/cgroup/foo ext4 defaults 0 0"
+ "/dev/ignored2 /sys/fs/selinux ext4 defaults 0 0"
+ "/dev/ignored3 /dev/console ext4 defaults 0 0"
+ "/dev/ignored4 /proc/kmsg ext4 defaults 0 0"
+ "/dev/ignored5 /proc/sys ext4 defaults 0 0"
+# Not ignored on RHEL 8, see 6f997852c8830ca073c55241b0068ebbf1f94a72
+# "/dev/ignored6 /proc/sys/kernel/random/boot_id ext4 defaults 0 0"
+# "/dev/ignored7 /run/host ext4 defaults 0 0"
+# "/dev/ignored8 /run/host/foo ext4 defaults 0 0"
+ "/dev/ignored9 /autofs autofs defaults 0 0"
+ "/dev/invalid1 not-a-path ext4 defaults 0 0"
+ ""
+ "/dev/invalid1"
+ " "
+ "\\"
+ "$"
+)
+
+check_fstab_mount_units() {
+ local what where fstype opts passno unit
+ local item opt split_options filtered_options supp service device arg
+ local array_name="${1:?}"
+ local out_dir="${2:?}/normal"
+ # Get a reference to the array from its name
+ local -n fstab_entries="$array_name"
+
+ # Running the checks in a container is pretty much useless, since we don't
+ # generate any mounts, but don't skip the whole test to test the "skip"
+ # paths as well
+ in_container && return 0
+
+ for item in "${fstab_entries[@]}"; do
+ # Don't use a pipe here, as it would make the variables out of scope
+ read -r what where fstype opts _ passno <<< "$item"
+
+ # Skip non-initrd mounts in initrd
+ if in_initrd_host && ! [[ "$opts" =~ x-initrd.mount ]]; then
+ continue
+ fi
+
+ if [[ "$fstype" == swap ]]; then
+ unit="$(systemd-escape --suffix=swap --path "${what:?}")"
+ cat "$out_dir/$unit"
+
+ grep -qE "^What=$what$" "$out_dir/$unit"
+ if [[ "$opts" != defaults ]]; then
+ grep -qE "^Options=$opts$" "$out_dir/$unit"
+ fi
+
+ if [[ "$opts" =~ x-systemd.makefs ]]; then
+ service="$(systemd-escape --template=systemd-mkswap@.service --path "$what")"
+ test -e "$out_dir/$service"
+ fi
+
+ continue
+ fi
+
+ # If we're parsing host's fstab in initrd, prefix all mount targets
+ # with /sysroot
+ in_initrd_host && where="/sysroot${where:?}"
+ unit="$(systemd-escape --suffix=mount --path "${where:?}")"
+ cat "$out_dir/$unit"
+
+ # Check the general stuff
+ grep -qE "^What=$what$" "$out_dir/$unit"
+ grep -qE "^Where=$where$" "$out_dir/$unit"
+ if [[ -n "$fstype" ]] && [[ "$fstype" != auto ]]; then
+ grep -qE "^Type=$fstype$" "$out_dir/$unit"
+ fi
+ if [[ -n "$opts" ]] && [[ "$opts" != defaults ]]; then
+ # Some options are not propagated to the generated unit
+ if [[ "$where" == / ]]; then
+ filtered_options="$(opt_filter "$opts" "(noauto|nofail|x-systemd.(wanted-by=|required-by=|automount|device-timeout=))")"
+ else
+ filtered_options="$(opt_filter "$opts" "^x-systemd.device-timeout=")"
+ fi
+
+ if [[ "${filtered_options[*]}" != defaults ]]; then
+ grep -qE "^Options=.*$filtered_options.*$" "$out_dir/$unit"
+ fi
+ fi
+
+ if ! [[ "$opts" =~ (noauto|x-systemd.(wanted-by=|required-by=|automount)) ]]; then
+ # We don't create the Requires=/Wants= symlinks for noauto/automount mounts
+ # and for mounts that use x-systemd.wanted-by=/required-by=
+ if in_initrd_host; then
+ if [[ "$where" == / ]] || ! [[ "$opts" =~ nofail ]]; then
+ link_eq "$out_dir/initrd-fs.target.requires/$unit" "../$unit"
+ else
+ link_eq "$out_dir/initrd-fs.target.wants/$unit" "../$unit"
+ fi
+ elif [[ "$fstype" =~ $NETWORK_FS_RX || "$opts" =~ _netdev ]]; then
+ # Units with network filesystems should have a Requires= dependency
+ # on the remote-fs.target, unless they use nofail or are an nfs "bg"
+ # mounts, in which case the dependency is downgraded to Wants=
+ if [[ "$opts" =~ nofail ]] || [[ "$fstype" =~ ^(nfs|nfs4) && "$opts" =~ bg ]]; then
+ link_eq "$out_dir/remote-fs.target.wants/$unit" "../$unit"
+ else
+ link_eq "$out_dir/remote-fs.target.requires/$unit" "../$unit"
+ fi
+ else
+ # Similarly, local filesystems should have a Requires= dependency on
+ # the local-fs.target, unless they use nofail, in which case the
+ # dependency is downgraded to Wants=. Rootfs is a special case,
+ # since we always ignore nofail there
+ if [[ "$where" == / ]] || ! [[ "$opts" =~ nofail ]]; then
+ link_eq "$out_dir/local-fs.target.requires/$unit" "../$unit"
+ else
+ link_eq "$out_dir/local-fs.target.wants/$unit" "../$unit"
+ fi
+ fi
+ fi
+
+ if [[ "${passno:=0}" -ne 0 ]]; then
+ # Generate systemd-fsck@.service dependencies, if applicable
+ if in_initrd && [[ "$where" == / || "$where" == /usr ]]; then
+ continue
+ fi
+
+ if [[ "$where" == / ]]; then
+ link_endswith "$out_dir/local-fs.target.wants/systemd-fsck-root.service" "/lib/systemd/system/systemd-fsck-root.service"
+ else
+ service="$(systemd-escape --template=systemd-fsck@.service --path "$what")"
+ grep -qE "^After=$service$" "$out_dir/$unit"
+ # On RHEL 8 this is always a Requires= dependency, even when the target
+ # is /usr, see afacf3fc8af0090620383228c6c84345ad63b6f8
+ grep -qE "^Requires=$service$" "$out_dir/$unit"
+ fi
+ fi
+
+ # Check various x-systemd options
+ #
+ # First, split them into an array to make splitting them even further
+ # easier
+ IFS="," read -ra split_options <<< "$opts"
+ # and process them one by one.
+ #
+ # Note: the "machinery" below might (and probably does) miss some
+ # combinations of supported options, so tread carefully
+ for opt in "${split_options[@]}"; do
+ if [[ "$opt" =~ ^x-systemd.requires= ]]; then
+ service="$(opt_get_arg "$opt")"
+ grep -qE "^Requires=$service$" "$out_dir/$unit"
+ grep -qE "^After=$service$" "$out_dir/$unit"
+ elif [[ "$opt" =~ ^x-systemd.before= ]]; then
+ service="$(opt_get_arg "$opt")"
+ grep -qE "^Before=$service$" "$out_dir/$unit"
+ elif [[ "$opt" =~ ^x-systemd.after= ]]; then
+ service="$(opt_get_arg "$opt")"
+ grep -qE "^After=$service$" "$out_dir/$unit"
+ elif [[ "$opt" =~ ^x-systemd.wanted-by= ]]; then
+ service="$(opt_get_arg "$opt")"
+ if [[ "$where" == / ]]; then
+ # This option is ignored for rootfs mounts
+ (! link_eq "$out_dir/$service.wants/$unit" "../$unit")
+ else
+ link_eq "$out_dir/$service.wants/$unit" "../$unit"
+ fi
+ elif [[ "$opt" =~ ^x-systemd.required-by= ]]; then
+ service="$(opt_get_arg "$opt")"
+ if [[ "$where" == / ]]; then
+ # This option is ignored for rootfs mounts
+ (! link_eq "$out_dir/$service.requires/$unit" "../$unit")
+ else
+ link_eq "$out_dir/$service.requires/$unit" "../$unit"
+ fi
+ elif [[ "$opt" =~ ^x-systemd.requires-mounts-for= ]]; then
+ arg="$(opt_get_arg "$opt")"
+ grep -qE "^RequiresMountsFor=$arg$" "$out_dir/$unit"
+ elif [[ "$opt" == x-systemd.device-bound ]]; then
+ # This is implied for fstab mounts
+ :
+ elif [[ "$opt" == x-systemd.automount ]]; then
+ # The $unit should have an accompanying automount unit
+ supp="$(systemd-escape --suffix=automount --path "$where")"
+ if [[ "$where" == / ]]; then
+ # This option is ignored for rootfs mounts
+ test ! -e "$out_dir/$supp"
+ (! link_eq "$out_dir/local-fs.target.requires/$supp" "../$supp")
+ else
+ test -e "$out_dir/$supp"
+ link_eq "$out_dir/local-fs.target.requires/$supp" "../$supp"
+ fi
+ elif [[ "$opt" =~ ^x-systemd.idle-timeout= ]]; then
+ # The timeout applies to the automount unit, not the original
+ # mount one
+ arg="$(opt_get_arg "$opt")"
+ supp="$(systemd-escape --suffix=automount --path "$where")"
+ grep -qE "^TimeoutIdleSec=$arg$" "$out_dir/$supp"
+ elif [[ "$opt" =~ ^x-systemd.device-timeout= ]]; then
+ arg="$(opt_get_arg "$opt")"
+ device="$(systemd-escape --suffix=device --path "$what")"
+ grep -qE "^JobRunningTimeoutSec=$arg$" "$out_dir/${device}.d/50-device-timeout.conf"
+ elif [[ "$opt" == x-systemd.makefs ]]; then
+ # In RHEL8 the unit is called systemd-mkfs@.service, see
+ # 804f8e1729e7663c75a88fcf0997539442b891d7
+ service="$(systemd-escape --template=systemd-mkfs@.service --path "$what")"
+ test -e "$out_dir/$service"
+ link_eq "$out_dir/${unit}.requires/$service" "../$service"
+ elif [[ "$opt" == x-systemd.rw-only ]]; then
+ grep -qE "^ReadWriteOnly=yes$" "$out_dir/$unit"
+ elif [[ "$opt" == x-systemd.growfs ]]; then
+ service="$(systemd-escape --template=systemd-growfs@.service --path "$where")"
+ # Another deviation from upstream, see 50072ccf1bfee8a53563a083a3a52b26f0d5678f
+ link_eq "$out_dir/${unit}.wants/$service" "../$service"
+ elif [[ "$opt" == bg ]] && [[ "$fstype" =~ ^(nfs|nfs4)$ ]]; then
+ # We "convert" nfs bg mounts to fg, so we can do the job-control
+ # ourselves
+ grep -qE "^Options=.*\bx-systemd.mount-timeout=infinity\b" "$out_dir/$unit"
+ grep -qE "^Options=.*\bfg\b.*" "$out_dir/$unit"
+ elif [[ "$opt" =~ ^x-systemd\. ]]; then
+ echo >&2 "Unhandled mount option: $opt"
+ exit 1
+ fi
+ done
+ done
+}
+
+: "fstab-generator: regular"
+printf "%s\n" "${FSTAB_GENERAL_ROOT[@]}" >"$FSTAB"
+cat "$FSTAB"
+SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+check_fstab_mount_units FSTAB_GENERAL_ROOT "$OUT_DIR"
+
+# Skip the rest when running in a container, as it makes little sense to check
+# initrd-related stuff there and fstab-generator might have a bit strange
+# behavior during certain tests, like https://github.com/systemd/systemd/issues/27156
+if in_container; then
+ echo "Running in a container, skipping the rest of the fstab-generator tests..."
+ exit 0
+fi
+
+# In this mode we treat the entries as "regular" ones
+: "fstab-generator: initrd - initrd fstab"
+printf "%s\n" "${FSTAB_GENERAL[@]}" >"$FSTAB"
+cat "$FSTAB"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_SYSROOT_FSTAB=/dev/null run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_SYSROOT_FSTAB=/dev/null check_fstab_mount_units FSTAB_GENERAL "$OUT_DIR"
+
+# In this mode we prefix the mount target with /sysroot and ignore all mounts
+# that don't have the x-initrd.mount flag
+: "fstab-generator: initrd - host fstab"
+printf "%s\n" "${FSTAB_GENERAL_ROOT[@]}" >"$FSTAB"
+cat "$FSTAB"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_GENERAL_ROOT "$OUT_DIR"
+
+# Check the default stuff that we (almost) always create in initrd
+: "fstab-generator: initrd default"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+test -e "$OUT_DIR/normal/sysroot.mount"
+test -e "$OUT_DIR/normal/systemd-fsck-root.service"
+link_eq "$OUT_DIR/normal/initrd-root-fs.target.requires/sysroot.mount" "../sysroot.mount"
+link_eq "$OUT_DIR/normal/initrd-root-fs.target.requires/sysroot.mount" "../sysroot.mount"
+
+# systemd-sysroot-fstab-check is not in RHEL 8
+
+: "fstab-generator: duplicate"
+printf "%s\n" "${FSTAB_DUPLICATE[@]}" >"$FSTAB"
+cat "$FSTAB"
+(! SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR")
+
+: "fstab-generator: invalid"
+printf "%s\n" "${FSTAB_INVALID[@]}" >"$FSTAB"
+cat "$FSTAB"
+# Don't care about the exit code here
+SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR" || :
+# No mounts should get created here
+[[ "$(find "$OUT_DIR" -name "*.mount" | wc -l)" -eq 0 ]]
+
+: "fstab-generator: kernel args - fstab=0"
+printf "%s\n" "${FSTAB_MINIMAL[@]}" >"$FSTAB"
+SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+(! SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR")
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+(! SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR")
+
+: "fstab-generator: kernel args - rd.fstab=0"
+printf "%s\n" "${FSTAB_MINIMAL[@]}" >"$FSTAB"
+SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="rd.fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="rd.fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+(! SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR")
+
+# systemd.swap kernel cmdline arguments is not supported on RHEL 8, see
+# 567a5307601728c618546c584f63307283fa8def
+
+# Possible TODO
+# - combine the rootfs & usrfs arguments and mix them with fstab entries
+# - systemd.volatile=
+: "fstab-generator: kernel args - root= + rootfstype= + rootflags="
+# shellcheck disable=SC2034
+EXPECTED_FSTAB=(
+ "/dev/disk/by-label/rootfs / ext4 noexec,ro 0 1"
+)
+CMDLINE="root=LABEL=rootfs rootfstype=ext4 rootflags=noexec"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+# The /proc/cmdline here is a dummy value to tell the in_initrd_host() function
+# we're parsing host's fstab, but it's all on the kernel cmdline instead
+SYSTEMD_IN_INITRD=1 SYSTEMD_SYSROOT_FSTAB=/proc/cmdline check_fstab_mount_units EXPECTED_FSTAB "$OUT_DIR"
+
+# This is a very basic sanity test that involves manual checks, since adding it
+# to the check_fstab_mount_units() function would make it way too complex
+# (yet another possible TODO)
+: "fstab-generator: kernel args - mount.usr= + mount.usrfstype= + mount.usrflags="
+CMDLINE="mount.usr=UUID=be780f43-8803-4a76-9732-02ceda6e9808 mount.usrfstype=ext4 mount.usrflags=noexec,nodev"
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
+cat "$OUT_DIR/normal/sysroot-usr.mount"
+# We don't do the /sysusr/usr/ -> /sysroot/usr/ dance on RHEL 8, see
+# 29a24ab28e9790680348b1ffab653a321fa49a67
+grep -qE "^What=/dev/disk/by-uuid/be780f43-8803-4a76-9732-02ceda6e9808$" "$OUT_DIR/normal/sysroot-usr.mount"
+grep -qE "^Where=/sysroot/usr$" "$OUT_DIR/normal/sysroot-usr.mount"
+grep -qE "^Type=ext4$" "$OUT_DIR/normal/sysroot-usr.mount"
+grep -qE "^Options=noexec,nodev,ro$" "$OUT_DIR/normal/sysroot-usr.mount"
+link_eq "$OUT_DIR/normal/initrd-fs.target.requires/sysroot-usr.mount" "../sysroot-usr.mount"
diff --git a/test/TEST-81-GENERATORS/testsuite.sh b/test/TEST-81-GENERATORS/testsuite.sh
new file mode 100755
index 0000000000..13c767e490
--- /dev/null
+++ b/test/TEST-81-GENERATORS/testsuite.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -eux
+set -o pipefail
+
+: >/failed
+
+for script in "${0%.sh}".*.sh; do
+ echo "Running $script"
+ "./$script"
+done
+
+touch /testok
+rm /failed
diff --git a/test/test-functions b/test/test-functions
index f0cf6f8575..2345ab6e8a 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -23,7 +23,7 @@ fi
PATH_TO_INIT=$ROOTLIBDIR/systemd
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff"
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff dirname readlink"
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"

View File

@ -0,0 +1,37 @@
From c3a86a3ab06713e865db694a80c0c5034ab902af Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Wed, 20 Dec 2023 16:44:14 +0100
Subject: [PATCH] resolved: actually check authenticated flag of SOA
transaction
Fixes #25676
(cherry picked from commit 3b4cc1437b51fcc0b08da8cc3f5d1175eed25eb1)
Resolves: RHEL-6213
---
src/resolve/resolved-dns-transaction.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index c975215468..6f614d7493 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -2520,7 +2520,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord *
if (r == 0)
continue;
- return t->answer_authenticated;
+ return dt->answer_authenticated;
}
return true;
@@ -2550,7 +2550,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord *
* RR for us. This means we are not at a zone cut. In
* this case, we require authentication if the SOA
* lookup was authenticated too. */
- return t->answer_authenticated;
+ return dt->answer_authenticated;
}
return true;

View File

@ -13,7 +13,7 @@
Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
Version: 239
Release: 78%{?dist}
Release: 79%{?dist}
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: System and Service Manager
@ -1029,6 +1029,16 @@ Patch0976: 0976-tmpfiles-don-t-complain-if-we-can-t-enable-pstore-in.patch
Patch0977: 0977-pstore-don-t-enable-crash_kexec_post_notifiers-by-de.patch
Patch0978: 0978-core-when-Delegate-yes-is-set-for-a-unit-run-ExecSta.patch
Patch0979: 0979-man-link-Delegate-documentation-up-with-the-markdown.patch
Patch0980: 0980-ci-Extend-source-git-automation.patch
Patch0981: 0981-ci-add-missing-configuration-for-commit-linter.patch
Patch0982: 0982-ci-add-Red-Hat-Enterprise-Linux-8-to-the-list-of-sup.patch
Patch0983: 0983-ci-enable-source-git-automation-to-validate-reviews-.patch
Patch0984: 0984-ci-remove-Mergify-config-replaced-by-Pull-Request-Va.patch
Patch0985: 0985-ci-enable-auto-merge-GH-Action.patch
Patch0986: 0986-fstab-generator-allow-overriding-etc-fstab-with-SYST.patch
Patch0987: 0987-fstab-generator-allow-overriding-path-to-sysroot-etc.patch
Patch0988: 0988-test-backport-TEST-81-GENERATORS-fstab-generator-onl.patch
Patch0989: 0989-resolved-actually-check-authenticated-flag-of-SOA-tr.patch
%ifarch %{ix86} x86_64 aarch64
%global have_gnu_efi 1
@ -1659,6 +1669,18 @@ fi
%files tests -f .file-list-tests
%changelog
* Mon Jan 08 2024 systemd maintenance team <systemd-maint@redhat.com> - 239-79
- ci: Extend source-git-automation (RHEL-1087)
- ci: add missing configuration for commit linter (RHEL-1087)
- ci: add `Red Hat Enterprise Linux 8` to the list of supported products (RHEL-1087)
- ci: enable source-git automation to validate reviews and ci results (RHEL-1087)
- ci: remove Mergify config - replaced by Pull Request Validator (RHEL-1087)
- ci: enable auto-merge GH Action (RHEL-1087)
- fstab-generator: allow overriding /etc/fstab with $SYSTEMD_FSTAB (RHEL-1087)
- fstab-generator: allow overriding path to /sysroot/etc/fstab too (RHEL-1087)
- test: backport TEST-81-GENERATORS (fstab-generator only) (RHEL-1087)
- resolved: actually check authenticated flag of SOA transaction (RHEL-6213)
* Tue Aug 22 2023 systemd maintenance team <systemd-maint@redhat.com> - 239-78
- login: add a missing error check for session_set_leader() (#2158167)
- logind: reset session leader if we know for a fact that it is gone (#2158167)