[pve-devel] [PATCH common 1/4] pty: introduce read_line() function

Stoiko Ivanov s.ivanov at proxmox.com
Mon Sep 22 11:45:58 CEST 2025


tested this patch with the patches for PMG from:
https://lore.proxmox.com/pmg-devel/20250918142052.131956-1-f.ebner@proxmox.com/T/#t

worked for me when creating an acme account with custom ACME provider, and
when joining a cluster.

Consider this:
Reviewed-by: Stoiko Ivanov <s.ivanov at proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov at proxmox.com>

On Thu, 18 Sep 2025 15:50:53 +0200
Fiona Ebner <f.ebner at proxmox.com> wrote:

> From: Stefan Hrdlicka <s.hrdlicka at proxmox.com>
> 
> Originally-by: Stefan Hrdlicka <s.hrdlicka at proxmox.com>
> [FE: avoid changes to read_password()
>      rename from read_input() to read_line()
>      avoid undef warning if there is no input by avoiding chomp then
>      print prompt even if not reading from interactive for better log]
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
>  src/PVE/PTY.pm | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/src/PVE/PTY.pm b/src/PVE/PTY.pm
> index 5d7d697..1db4863 100644
> --- a/src/PVE/PTY.pm
> +++ b/src/PVE/PTY.pm
> @@ -163,6 +163,23 @@ sub tcsetsize($$$) {
>          or die "failed to set window size: $!\n";
>  }
>  
> +sub read_line($;$$) {
> +    my ($query, $infd, $outfd) = @_;
> +
> +    $infd //= \*STDIN;
> +    $outfd //= \*STDOUT;
> +
> +    my $msg = -t $infd ? $query : "$query\n";
> +    print $outfd $msg;
> +
> +    my $input = '';
> +    local $/ = "\n";
> +    $input = <$infd>;
> +    chomp $input if $input;
> +
> +    return $input;
> +}
> +
>  sub read_password($;$$) {
>      my ($query, $infd, $outfd) = @_;
>  





More information about the pve-devel mailing list