From: Lars Wirzenius Date: Sun, 15 May 2011 10:45:54 +0000 (+0100) Subject: Add --root-password option. X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=06cb1395c7a8485895f64e689f1b724e4dbd73ba;p=forks%2Fvmdebootstrap.git Add --root-password option. Default is now to lock the root password, rather than having no password. --- 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') diff --git a/vmdebootstrap.8 b/vmdebootstrap.8 index d1793dc..ba3108e 100644 --- a/vmdebootstrap.8 +++ b/vmdebootstrap.8 @@ -123,6 +123,10 @@ file that sets up DHCP on the eth0 interface. This means the system booted from the image will bring up networking automatically in typical environments. Without DHCP, only localhost networking is set up. +.TP +.BR \-\-root\-password =\fIPASSWORD +Set password for root. +The default is to disable root's password. .SH EXAMPLE To create an image for the stable release of Debian: .nf