]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Add --root-password option.
authorLars Wirzenius <liw@liw.fi>
Sun, 15 May 2011 10:45:54 +0000 (11:45 +0100)
committerLars Wirzenius <liw@liw.fi>
Sun, 15 May 2011 10:45:54 +0000 (11:45 +0100)
Default is now to lock the root password, rather than having no password.

vmdebootstrap
vmdebootstrap.8

index ce163b4f47a474112e4087e8b68d5f2adf18c05c..f270e5a4c24700f209181c7c44b3c74b9d35ba19 100755 (executable)
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 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')
index d1793dc8bf209e2c26fb31633d616dc386183f2a..ba3108e89bdc81f877bca849e7b587b384a91a1e 100644 (file)
@@ -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