[pbs-devel] [PATCH proxmox-backup v2] client: mount: flush output before exiting

Friedrich Weber f.weber at proxmox.com
Tue Jun 18 13:20:31 CEST 2024


Thanks for tackling this! I ran into this issue (sometimes missing error
output) when I was running `sudo proxmox-backup-client mount [...]` and
forgot that PBS_REPOSITORY was not passed through by sudo. It looks like
in this case, the patch doesn't completely fix this issue -- seems like
I'm still missing the error output sometimes:

$ sudo ./proxmox-backup-client mount \
        "$SNAPSHOT" $FILE $PATH \
        --keyfile $KEYFILE --ns $NS
$ sudo ./proxmox-backup-client mount \
        "$SNAPSHOT" $FILE $PATH \
        --keyfile $KEYFILE --ns $NS
$ sudo ./proxmox-backup-client mount \
        "$SNAPSHOT" $FILE $PATH \
        --keyfile $KEYFILE --ns $NS
Error: unable to get (default) repository

On 14/06/2024 11:39, Gabriel Goller wrote:
> When using the `proxmox-backup-client mount` command, the parent sometimes
> exits before we can print any error message. Most notably this happens
> when no PBS_REPOSITORY is passed, as this is the first option checked.
> Flush the stdout and stderr so that we can guarantee the output.
> 
> Reported-by: Friedrich Weber <f.weber at proxmox.com>
> Suggested-by: Christian Ebner <c.ebner at proxmox.com>
> Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
> ---
> 
> v2, thanks @Christian:
>  - Removed unneeded pw.try_clone()
> 
>  proxmox-backup-client/src/mount.rs | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/proxmox-backup-client/src/mount.rs b/proxmox-backup-client/src/mount.rs
> index b69e7e80..e7718b84 100644
> --- a/proxmox-backup-client/src/mount.rs
> +++ b/proxmox-backup-client/src/mount.rs
> @@ -1,6 +1,7 @@
>  use std::collections::HashMap;
>  use std::ffi::OsStr;
>  use std::hash::BuildHasher;
> +use std::io::{self, Write};
>  use std::os::unix::io::{AsRawFd, OwnedFd};
>  use std::path::{Path, PathBuf};
>  use std::sync::Arc;
> @@ -189,7 +190,10 @@ fn mount(
>          Ok(ForkResult::Child) => {
>              drop(pr);
>              nix::unistd::setsid().unwrap();
> -            proxmox_async::runtime::main(mount_do(param, Some(pw)))
> +            let result = proxmox_async::runtime::main(mount_do(param, Some(pw)));
> +            io::stdout().flush()?;
> +            io::stderr().flush()?;
> +            result
>          }
>          Err(_) => bail!("failed to daemonize process"),
>      }




More information about the pbs-devel mailing list