This file is indexed.

/usr/lib/plainbox-providers-1/checkbox/bin/floppy_test is in plainbox-provider-checkbox 0.3-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#!/usr/bin/env python3

import os
import sys
import filecmp
import subprocess
import posixpath

DEFAULT_DIR = "/tmp/checkbox.floppy"
DEFAULT_DEVICE_DIR = "floppy_device"
DEFAULT_IMAGE_DIR = "floppy_image"
DEFAULT_IMAGE = "floppy.img"


class FloppyTest(object):

    def __init__(self, device):
        self.device = device
        self.device_dir = os.path.join(DEFAULT_DIR, DEFAULT_DEVICE_DIR)
        self.image_dir = os.path.join(DEFAULT_DIR, DEFAULT_IMAGE_DIR)
        self.image = os.path.join(DEFAULT_DIR, DEFAULT_IMAGE)
        self.interactive = True

        for dir in (self.device_dir, self.image_dir):
            if not posixpath.exists(dir):
                os.makedirs(dir)

    def run(self):
        floppyDevice = self.device
        if floppyDevice:
            print("  Testing on floppy drive %s " % floppyDevice)
        else:
            print("  Error ! No floppy drive found !")
            return 1
        # remove temp files if they exist
        os.system("umount /media/floppy 2>/dev/null")
        if (os.path.exists(self.device_dir)
            or os.path.exists(self.image_dir)
            or os.path.exists(self.image)):
            os.system("umount %s %s 2>/dev/null"
                      % (self.device_dir, self.image_dir))
            os.system("rm -rf %s %s %s 2>/dev/null"
                      % (self.device_dir, self.image_dir, self.image))
        # Create the test images
        os.mkdir(self.device_dir)
        os.mkdir(self.image_dir)
        os.system("dd if=/dev/zero of=%s bs=1k count=1440" % self.image)
        os.system("mkdosfs %s" % self.image)
        os.system("mount -o loop %s %s" % (self.image, self.image_dir))
        os.system("cp -a /etc/*.conf %s 2> /dev/null" % self.image_dir)
        os.system("umount %s" % self.image_dir)
        # start testing
        (noFloppyDisk, junkOutput1) = \
            subprocess.getstatusoutput("dd bs=1c if=%s count=0 2>/dev/null"
                                     % floppyDevice)
        if noFloppyDisk != 0:
            print("Error ! No floppy disc or bad media in %s !" % floppyDevice)
            return 1
        else:
            # writing files
            print("  Writing data to floppy disc ... ")
            (ddStatus, ddOutput) = \
                subprocess.getstatusoutput("dd if=%s of=%s bs=1k count=1440"
                                         % (self.image, floppyDevice))
            if ddStatus == 0:
                print("  Write data to floppy disc done ! ")
            else:
                print("  Error ! Write data to floppy disc error ! ")
                print("  Please check if your floppy disc is write-protected !")
                return 1
            # comparing files
            os.system("mount %s %s" % (floppyDevice, self.device_dir))
            os.system("mount -o loop %s %s" % (self.image, self.image_dir))
            print("  Comparing files ... ")
            fileList = os.listdir(self.image_dir)
            returnValue = 0
            for textFile in fileList:
                file1 = os.path.join(self.device_dir, textFile)
                file2 = os.path.join(self.image_dir, textFile)
                if filecmp.cmp(file1, file2):
                    print("        comparing file %s" % textFile)
                else:
                    print("  --  Error ! File %s comparison failed ! -- "
                          % textFile)
                    returnValue = 1
            print("  File comparison done ! ")
            # remove temp files
            os.system("umount /media/floppy 2>/dev/null")
            os.system("umount %s %s " % (self.image_dir, self.device_dir))
            os.system("rm -rf %s %s %s"
                      % (self.device_dir, self.image_dir, self.image))
            print("Done !")
            return returnValue


def main(args):
    return_values = []
    for device in args:
        test = FloppyTest(device)
        return_values.append(test.run())

    return 1 in return_values

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))