public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset
@ 2024-05-15  9:55 Dominik Csapak
  2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 2/3] restore daemon: log some errors for dir traversal Dominik Csapak
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dominik Csapak @ 2024-05-15  9:55 UTC (permalink / raw)
  To: pbs-devel

since the change in our restore image to ntfs3, non iso8859-1 filenames
were broken. Fix that by adding the 'iocharset' option to ntfs3.

Leave the ntfs option in place, so that if the image gets booted
with an older kernel for some reason, this still works.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
index bde459dd6..db96ced0b 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
@@ -37,6 +37,7 @@ lazy_static! {
         m.insert("ufs", "ufstype=ufs2");
 
         m.insert("ntfs", "utf8");
+        m.insert("ntfs3", "iocharset=utf8");
 
         m
     };
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* [pbs-devel] [PATCH proxmox-backup 2/3] restore daemon: log some errors for dir traversal
  2024-05-15  9:55 [pbs-devel] [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Dominik Csapak
@ 2024-05-15  9:55 ` Dominik Csapak
  2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial Dominik Csapak
  2024-05-16  9:51 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Fabian Grünbichler
  2 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2024-05-15  9:55 UTC (permalink / raw)
  To: pbs-devel

in case we cannot stat a file in the restore vm, log the path and reason
why. This should normally not happen, but when it does, the path and
error might help us find the issue.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 .../src/proxmox_restore_daemon/api.rs               | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index c20552225..cb7b53e11 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -182,12 +182,17 @@ fn list(
                         let mut full_path = PathBuf::new();
                         full_path.push(param_path_buf);
                         full_path.push(path);
-                        let entry = get_dir_entry(&full_vm_path);
-                        if let Ok(entry) = entry {
-                            res.push(ArchiveEntry::new(
+                        match get_dir_entry(&full_vm_path) {
+                            Ok(entry) => res.push(ArchiveEntry::new(
                                 full_path.as_os_str().as_bytes(),
                                 Some(&entry),
-                            ));
+                            )),
+                            Err(err) => {
+                                eprintln!(
+                                    "error getting entry: {:?} : {err}",
+                                    full_path.as_os_str()
+                                );
+                            }
                         }
                     }
                 }
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial
  2024-05-15  9:55 [pbs-devel] [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Dominik Csapak
  2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 2/3] restore daemon: log some errors for dir traversal Dominik Csapak
@ 2024-05-15  9:55 ` Dominik Csapak
  2024-05-16 10:04   ` Fabian Grünbichler
  2024-05-16  9:51 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Fabian Grünbichler
  2 siblings, 1 reply; 5+ messages in thread
From: Dominik Csapak @ 2024-05-15  9:55 UTC (permalink / raw)
  To: pbs-devel

the disk serial given to virtio disks only can be 20 characters, so
looking for a disk with a longer serial will always fail (like
'drive-tpmstate0-backup'). If the serial is longer, also try with the
truncated one. Leave the first try in place in case the limit changes.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 .../src/proxmox_restore_daemon/disk.rs        | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
index db96ced0b..4991479c2 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
@@ -634,12 +634,21 @@ impl DiskState {
             _ => bail!("no or invalid image in path"),
         };
 
-        let buckets = match self.disk_map.get_mut(
-            req_fidx
-                .strip_suffix(".img.fidx")
-                .unwrap_or_else(|| req_fidx.as_ref()),
-        ) {
+        let serial = req_fidx
+            .strip_suffix(".img.fidx")
+            .unwrap_or_else(|| req_fidx.as_ref());
+        let buckets = match self.disk_map.get_mut(serial) {
             Some(x) => x,
+            None if serial.len() > 20 => {
+                let (truncated_serial, _) = serial.split_at(20);
+                eprintln!(
+                    "given image '{req_fidx}' not found with '{serial}', trying with '{truncated_serial}'."
+                );
+                match self.disk_map.get_mut(truncated_serial) {
+                    Some(x) => x,
+                    None => bail!("given image '{req_fidx}' not found with '{truncated_serial}'"),
+                }
+            }
             None => bail!("given image '{req_fidx}' not found"),
         };
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* [pbs-devel] applied-series: [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset
  2024-05-15  9:55 [pbs-devel] [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Dominik Csapak
  2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 2/3] restore daemon: log some errors for dir traversal Dominik Csapak
  2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial Dominik Csapak
@ 2024-05-16  9:51 ` Fabian Grünbichler
  2 siblings, 0 replies; 5+ messages in thread
From: Fabian Grünbichler @ 2024-05-16  9:51 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion

On May 15, 2024 11:55 am, Dominik Csapak wrote:
> since the change in our restore image to ntfs3, non iso8859-1 filenames
> were broken. Fix that by adding the 'iocharset' option to ntfs3.
> 
> Leave the ntfs option in place, so that if the image gets booted
> with an older kernel for some reason, this still works.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
> index bde459dd6..db96ced0b 100644
> --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
> +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
> @@ -37,6 +37,7 @@ lazy_static! {
>          m.insert("ufs", "ufstype=ufs2");
>  
>          m.insert("ntfs", "utf8");
> +        m.insert("ntfs3", "iocharset=utf8");
>  
>          m
>      };
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* Re: [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial
  2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial Dominik Csapak
@ 2024-05-16 10:04   ` Fabian Grünbichler
  0 siblings, 0 replies; 5+ messages in thread
From: Fabian Grünbichler @ 2024-05-16 10:04 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion

On May 15, 2024 11:55 am, Dominik Csapak wrote:
> the disk serial given to virtio disks only can be 20 characters, so
> looking for a disk with a longer serial will always fail (like
> 'drive-tpmstate0-backup'). If the serial is longer, also try with the
> truncated one. Leave the first try in place in case the limit changes.

as we discussed briefly off-list, I think it might also be a good idea
to have a way to filter out images that we know are non-restorable.
since this lives in PBS here, it would probably make most sense to pass
this in somehow as an optional parameter?

the filter would then need to be respected both when constructing the
qemu commandline (we already skip archives not ending in '.img.fidx')
and when listing the archives.

then we could by default skip the efidisk and tpmstate, and any other
such special volumes/archives that might end up being needed in the
future..

> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  .../src/proxmox_restore_daemon/disk.rs        | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
> index db96ced0b..4991479c2 100644
> --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
> +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
> @@ -634,12 +634,21 @@ impl DiskState {
>              _ => bail!("no or invalid image in path"),
>          };
>  
> -        let buckets = match self.disk_map.get_mut(
> -            req_fidx
> -                .strip_suffix(".img.fidx")
> -                .unwrap_or_else(|| req_fidx.as_ref()),
> -        ) {
> +        let serial = req_fidx
> +            .strip_suffix(".img.fidx")
> +            .unwrap_or_else(|| req_fidx.as_ref());
> +        let buckets = match self.disk_map.get_mut(serial) {
>              Some(x) => x,
> +            None if serial.len() > 20 => {
> +                let (truncated_serial, _) = serial.split_at(20);
> +                eprintln!(
> +                    "given image '{req_fidx}' not found with '{serial}', trying with '{truncated_serial}'."
> +                );
> +                match self.disk_map.get_mut(truncated_serial) {
> +                    Some(x) => x,
> +                    None => bail!("given image '{req_fidx}' not found with '{truncated_serial}'"),
> +                }
> +            }

as an alternative to this here, we could also use a (truncated) hash as
the serial, and than map that back to the "readable" name. might make
logging awkward though, unless we pro-actively hand the map to the
restore daemon. and it might only really be relevant for custom usage of
all of this, if we implement the filtering above ;)

>              None => bail!("given image '{req_fidx}' not found"),
>          };
>  
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

end of thread, other threads:[~2024-05-16 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  9:55 [pbs-devel] [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Dominik Csapak
2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 2/3] restore daemon: log some errors for dir traversal Dominik Csapak
2024-05-15  9:55 ` [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial Dominik Csapak
2024-05-16 10:04   ` Fabian Grünbichler
2024-05-16  9:51 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/3] fix #5465: restore daemon: mount ntfs with utf8 charset Fabian Grünbichler

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