From 0eb23798d5e8ad52d4a17e2de5f27b70a4f5b43b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 12 Oct 2022 14:53:48 +0200 Subject: [PATCH] repart: Fail early if no sources are provided for a read-only filesystem --- src/partition/repart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/partition/repart.c b/src/partition/repart.c index 494a3100b7..4e309ab214 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1599,6 +1599,10 @@ static int partition_read_definition(Partition *p, const char *path, const char "Need to be root to populate %s filesystems with CopyFiles=/MakeDirectories=", p->format); + if (p->format && fstype_is_ro(p->format) && strv_isempty(p->copy_files) && strv_isempty(p->make_directories)) + return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL), + "Cannot format %s filesystem without source files, refusing", p->format); + if (p->verity != VERITY_OFF || p->encrypt != ENCRYPT_OFF) { r = dlopen_cryptsetup(); if (r < 0) -- 2.25.1