]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Fail early if no sources are provided for a read-only filesystem
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 12 Oct 2022 12:53:48 +0000 (14:53 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 15 Nov 2022 19:23:51 +0000 (20:23 +0100)
src/partition/repart.c

index 494a3100b78df2b4fd17f21475eb0ba6d35222d3..4e309ab214e4a7efba9ce5924fc560854ad5eab2 100644 (file)
@@ -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)