From d6c51fc7fa46b29bcd60a93dc9d945ef0e44725b Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 2 Sep 2013 22:52:28 -0700 Subject: [PATCH] Save only 512 bytes and use different file paths for debian/rhel --- cloudinit/distros/__init__.py | 5 +++-- cloudinit/distros/debian.py | 1 + cloudinit/distros/rhel.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 49b129ae..3c536f2b 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -52,7 +52,7 @@ class Distro(object): ci_sudoers_fn = "/etc/sudoers.d/90-cloud-init-users" hostname_conf_fn = "/etc/hostname" tz_zone_dir = "/usr/share/zoneinfo" - random_seed_fn = "/var/lib/random-seed" + random_seed_fn = None def __init__(self, name, cfg, paths): self._paths = paths @@ -172,7 +172,8 @@ class Distro(object): def set_random_seed(self, seed): if self.random_seed_fn: - util.write_file(self.random_seed_fn, seed, mode=0600) + # Ensure we only write 512 bytes worth + util.write_file(self.random_seed_fn, seed[0:512], mode=0600) def update_hostname(self, hostname, fqdn, prev_hostname_fn): applying_hostname = hostname diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index 8fe49cbe..db4afc76 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -44,6 +44,7 @@ class Distro(distros.Distro): network_conf_fn = "/etc/network/interfaces" tz_conf_fn = "/etc/timezone" tz_local_fn = "/etc/localtime" + random_seed_fn = "/var/lib/urandom/random-seed" def __init__(self, name, cfg, paths): distros.Distro.__init__(self, name, cfg, paths) diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index 30195384..96df9ae2 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -49,6 +49,7 @@ class Distro(distros.Distro): network_script_tpl = '/etc/sysconfig/network-scripts/ifcfg-%s' resolve_conf_fn = "/etc/resolv.conf" tz_local_fn = "/etc/localtime" + random_seed_fn = "/var/lib/random-seed" def __init__(self, name, cfg, paths): distros.Distro.__init__(self, name, cfg, paths)