di_installcmdline_core
di_vg_name
debian_dhcp_rofs_fix
+ debian_write_random_seed_command
);
%EXPORT_TAGS = ( );
END
}
+ my $cmd = debian_write_random_seed_command('/target');
+ preseed_hook_command($ho, 'late_command', $sfx, <<END);
+#!/bin/sh
+set -ex
+$cmd
+END
+
$preseed_file .= preseed_hook_cmds();
return create_webfile($ho, "preseed$sfx", $preseed_file);
END
}
+sub debian_write_random_seed_command ($) {
+ my ($mountpoint) = @_;
+ my $dir = "$mountpoint/var/lib/systemd";
+ return <<END;
+ umask 077
+ test -d $dir || mkdir -m 0755 $dir
+ dd if=/dev/urandom of=$dir/random-seed bs=1k count=1
+END
+}
+
1;
--- /dev/null
+#!/usr/bin/perl -w
+use strict;
+
+open R, '>', '/dev/random' or die "open /dev/random: $!\n";
+R->autoflush(1);
+
+sub rndaddtoentcnt ($) {
+ my ($bits) = @_;
+ my $x = pack 'L', $bits;
+ my $r = ioctl R, 0x40045201, $x;
+ defined $r or die "RNDADDTOENTCNT: $!\n";
+}
+
+sub process_stdin ($) {
+ my ($f) = @_;
+ my $got = read STDIN, $_, 512;
+ defined $got or die "read $f: $!\n";
+ last if !$got;
+ print R $_ or die "write /dev/random: $!\n";
+ my $bits = length($_) * 8;
+ rndaddtoentcnt($bits);
+}
+
+if (!@ARGV) {
+ process_stdin('stdin');
+} else {
+ die "no options supported\n" if $ARGV[0] =~ m/^\-/;
+ foreach my $f (@ARGV) {
+ open STDIN, '<', $f or die "open for reading $f: $!\n";
+ process_stdin($f);
+ }
+}
+