]> git.proxmox.com Git - pve-client.git/blobdiff - PVE/APIClient/Config.pm
lxc enter: handle writes with select
[pve-client.git] / PVE / APIClient / Config.pm
index 8a7784896f7d881fc93fef3eb7d4bf3cc91658ed..8fa769140390061045b6e40c577c344086071c54 100644 (file)
@@ -4,7 +4,6 @@ use strict;
 use warnings;
 use JSON;
 
-use File::HomeDir ();
 use PVE::JSONSchema qw(register_standard_option get_standard_option);
 use PVE::SectionConfig;
 use PVE::Tools qw(file_get_contents file_set_contents);
@@ -77,7 +76,7 @@ sub options {
        host => { optional => 0 },
        comment => { optional => 1 },
        username => { optional => 0 },
-       password => { optional => 0 },
+       password => { optional => 1 },
        port => { optional => 1 },
        fingerprint => { optional => 1 },
    };
@@ -90,7 +89,11 @@ sub private {
 sub config_filename {
     my ($class) = @_;
 
-    return File::HomeDir::home() . '/.pveclient';
+    my $home = $ENV{HOME};
+
+    die "environment HOME not set\n" if !defined($home);
+
+    return "$home/.pveclient";
 }
 
 sub load {
@@ -135,11 +138,17 @@ sub remote_conn {
     my ($class, $cfg, $remote) = @_;
 
     my $section = $class->lookup_remote($cfg, $remote);
+
+    my $password = $section->{password};
+    if (!defined($password)) {
+       $password = PVE::PTY::read_password("Remote password: ")
+    }
+
     my $conn = PVE::APIClient::LWP->new(
        username                => $section->{username},
-       password                => $section->{password},
+       password                => $password,
        host                    => $section->{host},
-       port                    => $section->{port},
+       port                    => $section->{port} // 8006,
        cached_fingerprints     => {
            $section->{fingerprint} => 1,
        }