]> git.proxmox.com Git - pve-manager.git/commitdiff
encrypt container password (sha1)
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 5 Oct 2011 06:08:01 +0000 (08:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 5 Oct 2011 06:08:01 +0000 (08:08 +0200)
PVE/OpenVZ.pm

index 3c906fa528cd61c04810712da698e9bffb00e4aa..43ef2de1666e41f26f7d74787b5194340cad7fee 100644 (file)
@@ -12,6 +12,8 @@ use PVE::Cluster qw(cfs_register_file cfs_read_file);
 use PVE::SafeSyslog;
 use PVE::INotify;
 use PVE::JSONSchema;
+use Digest::SHA1;
+use Encode;
 
 my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
 my $nodename = PVE::INotify::nodename();
@@ -1045,6 +1047,11 @@ sub set_rootpasswd {
 
     my $shadow = "$vmdir/etc/shadow";
 
+    if ($opt_rootpasswd !~ m/^\$/) {
+       my $time = substr (Digest::SHA1::sha1_base64 (time), 0, 8);
+       $opt_rootpasswd = crypt(encode("utf8", $opt_rootpasswd), "\$1\$$time\$");
+    };
+
     if (-f $shadow) {
        replacepw ($shadow, $opt_rootpasswd);
        replacepw ($pwfile, 'x');