public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [RFC PATCH proxmox-backup] pbs-tools: zip: add EFS flag to zip files
@ 2021-09-10  9:09 Dominik Csapak
  2021-09-11 15:08 ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Csapak @ 2021-09-10  9:09 UTC (permalink / raw)
  To: pbs-devel

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@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-13  7:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  9:09 [pbs-devel] [RFC PATCH proxmox-backup] pbs-tools: zip: add EFS flag to zip files Dominik Csapak
2021-09-11 15:08 ` Thomas Lamprecht
2021-09-13  7:14   ` Dominik Csapak
2021-09-13  7:25     ` Thomas Lamprecht
2021-09-13  7:53       ` Dominik Csapak
2021-09-13  7:57         ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal