Don't check the token if -t is not defined
[snf-image-creator] / image_creator / bundle_volume.py
index e32d90b..a6fc27a 100644 (file)
@@ -143,9 +143,9 @@ class BundleVolume(object):
             # Copy the Secondary GPT Header
             table = GPTPartitionTable(self.disk.device.path)
             dd('if=%s' % self.disk.device.path, 'of=%s' % image,
             # Copy the Secondary GPT Header
             table = GPTPartitionTable(self.disk.device.path)
             dd('if=%s' % self.disk.device.path, 'of=%s' % image,
-            'bs=%d' % self.disk.device.sectorSize, 'conv=notrunc',
-            'seek=%d' % table.primary.last_usable_lba,
-            'skip=%d' % table.primary.last_usable_lba)
+               'bs=%d' % self.disk.device.sectorSize, 'conv=notrunc',
+               'seek=%d' % table.primary.last_usable_lba,
+               'skip=%d' % table.primary.last_usable_lba)
 
         # Create the Extended boot records (EBRs) in the image
         extended = self.disk.getExtendedPartition()
 
         # Create the Extended boot records (EBRs) in the image
         extended = self.disk.getExtendedPartition()
@@ -401,9 +401,21 @@ class BundleVolume(object):
                 for excl in excluded:
                     dirname = os.path.dirname(excl)
                     stat = os.stat(dirname)
                 for excl in excluded:
                     dirname = os.path.dirname(excl)
                     stat = os.stat(dirname)
-                    os.mkdir(target + excl, stat.st_mode)
+                    os.mkdir(target + excl)
+                    os.chmod(target + excl, stat.st_mode)
                     os.chown(target + excl, stat.st_uid, stat.st_gid)
 
                     os.chown(target + excl, stat.st_uid, stat.st_gid)
 
+                # /tmp and /var/tmp are special cases. We exclude then even if
+                # they aren't mountpoints. Restore their permissions.
+                for excl in ('/tmp', '/var/tmp'):
+                    if self._is_mpoint(excl):
+                        os.chmod(target + excl, 041777)
+                        os.chown(target + excl, 0, 0)
+                    else:
+                        stat = os.stat(excl)
+                        os.chmod(target + excl, stat.st_mode)
+                        os.chown(target + excl, stat.st_uid, stat.st_gid)
+
                 # We need to replace the old UUID referencies with the new
                 # ones in grub configuration files and /etc/fstab for file
                 # systems that have been recreated.
                 # We need to replace the old UUID referencies with the new
                 # ones in grub configuration files and /etc/fstab for file
                 # systems that have been recreated.