[pbs-devel] [RFC PATCH proxmox-backup] pbs-tools: zip: add EFS flag to zip files

Dominik Csapak d.csapak at proxmox.com
Fri Sep 10 11:09:48 CEST 2021


this flag marks the file names as 'UTF-8' encoded.

By default, encoding of file names in zips are defined as code page 437,
but we save the filenames as bytes (like in linux fs).

For linux systems this neither would be a problem since most tools
simply use the filenames as bytes, but for the zip utility under
windows it's important since NTFS uses UTF-16 for file names.

Since we generate zips only on pxars (file based backup on linux) or
via file-restore-daemons (linux; ntfs mounted as UTF-8), it's a fair
assumption that we can mark most filenames as UTF-8.

For zips generated from linux backups to be extracted on windows it is
impossible to do the correct thing anyway, since windows can not have
arbitrary bytes in file names, and for each encoding chosen, there is
some file that cannot be shown correctly.
so either all filenames are decoded as CP437 ('ö' -> '├╢')
or non UTF-8 encoded file-names have garbage characters in them (�)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
sending as RFC since there is no way to have it correct in all cases,
and we have to decide if we want CP437 or UTF-8 by default

 pbs-tools/src/zip.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pbs-tools/src/zip.rs b/pbs-tools/src/zip.rs
index 605480a8..88eea07b 100644
--- a/pbs-tools/src/zip.rs
+++ b/pbs-tools/src/zip.rs
@@ -34,6 +34,8 @@ const VERSION_MADE_BY: u16 = 0x032d;
 const ZIP64_EOCD_RECORD: u32 = 0x06064B50;
 const ZIP64_EOCD_LOCATOR: u32 = 0x07064B50;
 
+const GENERAL_PURUPOSE_FLAGS: u16 = (1 << 3) | (1 << 11); // EFS + Data Descriptor
+
 // bits for time:
 // 0-4: day of the month (1-31)
 // 5-8: month: (1 = jan, etc.)
@@ -249,7 +251,7 @@ impl ZipEntry {
             LocalFileHeader {
                 signature: LOCAL_FH_SIG,
                 version_needed: 0x2d,
-                flags: 1 << 3,
+                flags: GENERAL_PURUPOSE_FLAGS,
                 compression: 0x8,
                 time,
                 date,
@@ -332,7 +334,7 @@ impl ZipEntry {
                 signature: CENTRAL_DIRECTORY_FH_SIG,
                 version_made_by: VERSION_MADE_BY,
                 version_needed: VERSION_NEEDED,
-                flags: 1 << 3,
+                flags: GENERAL_PURUPOSE_FLAGS,
                 compression: 0x8,
                 time,
                 date,
-- 
2.30.2






More information about the pbs-devel mailing list