X-Git-Url: https://git.siccegge.de//index.cgi?p=forks%2Fvmdebootstrap.git;a=blobdiff_plain;f=vmdebootstrap;h=f270e5a4c24700f209181c7c44b3c74b9d35ba19;hp=ce163b4f47a474112e4087e8b68d5f2adf18c05c;hb=06cb1395c7a8485895f64e689f1b724e4dbd73ba;hpb=4fd56fa3e858c58a95f8f6d2dce3c6642a8fc0d1 diff --git a/vmdebootstrap b/vmdebootstrap index ce163b4..f270e5a 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -15,6 +15,7 @@ # along with this program. If not, see . import cliapp +import crypt import logging import os import re @@ -56,6 +57,9 @@ class VmDebootstrap(cliapp.Application): 'install PACKAGE onto system') self.settings.add_boolean_setting(['enable-dhcp'], 'enable DHCP on eth0') + self.settings.add_string_setting(['root-password'], + 'set root password', + metavar='PASSWORD') def process_args(self, args): if not self.settings['image']: @@ -166,8 +170,14 @@ class VmDebootstrap(cliapp.Application): self.settings['mirror']]) def set_root_password(self, rootdir): - self.message('Removing root password') - self.runcmd(['chroot', rootdir, 'passwd', '-d', 'root']) + if self.settings['root-password']: + self.message('Setting root password') + encrypted = crypt.crypt(self.settings['root-password'], '..') + self.runcmd(['chroot', rootdir, 'usermod', '-p', encrypted, + 'root']) + else: + self.message('Locking root password') + self.runcmd(['chroot', rootdir, 'passwd', '-l', 'root']) def remove_udev_persistent_rules(self, rootdir): self.message('Removing udev persistent cd and net rules')