]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Cleanups and --lock-root-password and no default root password
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>
Mon, 16 Jul 2012 13:31:53 +0000 (14:31 +0100)
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>
Mon, 16 Jul 2012 13:31:53 +0000 (14:31 +0100)
vmdebootstrap

index 295bdc74f7017ef4e551c431a1f16baf6d030610..c8fc426c1d8ec295fc150069beb63980a7cdac43 100755 (executable)
@@ -55,6 +55,8 @@ class VmDebootstrap(cliapp.Application):
         self.settings.boolean(['enable-dhcp'], 'enable DHCP on eth0')
         self.settings.string(['root-password'], 'set root password',
                              metavar='PASSWORD')
+        self.settings.boolean(['lock-root-password'], 
+                              'lock root account so they cannot login?')
         self.settings.string(['customize'],
                              'run SCRIPT after setting up system',
                              metavar='SCRIPT')
@@ -99,10 +101,10 @@ class VmDebootstrap(cliapp.Application):
             self.customize(rootdir)
         except BaseException, e:
             self.message('EEEK! Something bad happened...')
-            self.cleanup()
+            self.cleanup_system()
             raise
         else:
-            self.cleanup()
+            self.cleanup_system()
 
     def message(self, msg):
         if self.settings['verbose']:
@@ -230,9 +232,12 @@ class VmDebootstrap(cliapp.Application):
         if self.settings['root-password']:
             self.message('Setting root password')
             self.set_password(rootdir, 'root', self.settings['root-password'])
-        else:
+        elif self.settings['lock-root-password']:
             self.message('Locking root password')
             self.runcmd(['chroot', rootdir, 'passwd', '-l', 'root'])
+        else:
+            self.message('Give root an empty password')
+            self.runcmd(['chroot', rootdir, 'passwd', '-d', 'root'])
 
     def create_users(self, rootdir):
         def create_user(user):
@@ -327,7 +332,7 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro quiet %(kserial)s
         self.runcmd(['sync'])
         import time; time.sleep(2)
         
-    def cleanup(self):
+    def cleanup_system(self):
         # Clean up after any errors.
 
         self.message('Cleaning up')