0

I've been learning to use udev and noticed that when I run udevadm test --action="add" /sys/block/sdc I see the following:

GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:59
IMPORT 'scsi_id --export --whitelisted -d /dev/sdc' /usr/lib/udev/rules.d/60-persistent-storage.rules:50
starting 'scsi_id --export --whitelisted -d /dev/sdc'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_SCSI=1'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_VENDOR=NVMe'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_VENDOR_ENC=NVMe\x20\x20\x20\x20'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_MODEL=Dell_Ent_NVMe_v2'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_MODEL_ENC=Dell\x20Ent\x20NVMe\x20v2'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_REVISION=.2.0'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_TYPE=disk'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_SERIAL=236435330529024120025384100000002'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_SERIAL_SHORT=36435330529024120025384100000002'
'scsi_id --export --whitelisted -d /dev/sdc'(out) 'ID_SCSI_SERIAL=S6CSNA0R902412      '
Process 'scsi_id --export --whitelisted -d /dev/sdc' succeeded.

sdc in this case is a virtual disk sitting on a PERC H755. I have not yet changed anything in udev.

The above is what you see when using a RAID0 (passthrough/JBOD mode). If you create a RAID 5 you see

probe /dev/sda raid offset=0
LINK 'disk/by-id/wwn-0x6f4ee080160bd5002ab7652100a1691a' /usr/lib/udev/rules.d/60-persistent-storage.rules:97
IMPORT '/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw' /usr/lib/udev/rules.d/61-scsi-sg3_id.rules:17
starting '/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_TPGS=0'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_TYPE=disk'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_VENDOR=DELL'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_VENDOR_ENC=DELL\x20\x20\x20\x20'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_MODEL=PERC_H755N_Front'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_MODEL_ENC=PERC\x20H755N\x20Front'
'/usr/bin/sg_inq --export --inhex=/sys/block/sda/device/inquiry --raw'(out) 'SCSI_REVISION=5.16'

My question is how is udev "deciding" to whitelist the PERC and what is the function of whitelisting?

Research Done

  • Read through this post on whitelisting for USB drives but this seems to be used when someone makes the decision to manually disallow all USB devices except certain targets which isn't applicable here.
  • This tutorial on writing udev scripts but it didn't answer any of my questions about whitelisting.
  • The udev Wikipedia but while that gave me a better architectural understanding it didn't help me with whitelisting
  • The man page for udev - helpful but no mention of whitelisting.

In general I tried Googling for results related to udev whitelisting but the only results I could find were all about whitelisting USB devices rather than how whitelisting generally functions.

1 Answer 1

2

The --whitelisted option appears to do a "wet run" (as opposed to "dry run") because without it scsi_id does not appear to be doing anything at all.

see source: https://github.com/systemd/systemd/blob/bab787396444466e5a71e5f01b1924646959f6e0/src/udev/scsi_id/scsi_id.c#L407

static int scsi_id(char *maj_min_dev) {
        int good_dev;
        (...)

        per_dev_options(&dev_scsi, &good_dev, &page_code);
        if (!good_dev) {
                retval = 1;
                goto out;
        }
        (...)
out:
        return retval;


static int per_dev_options(struct scsi_id_device *dev_scsi, int *good_bad, int *page_code) {

        (...)

        while (retval == 0) {
                option = getopt_long(newargc, newargv, "bgp:", options, NULL);
                if (option == -1)
                        break;

                switch (option) {
                case 'b':
                        *good_bad = 0;
                        break;

                case 'g':
                        *good_bad = 1;
                        break;


static void help(void) {
               (...)
               "  -b --blacklisted                 Treat device as blacklisted\n"
               "  -g --whitelisted                 Treat device as whitelisted\n"
               (...)

this is from a ubuntu 22 system:

root@trybase:~# /usr/lib/udev/scsi_id /dev/sdc 
root@trybase:~# /usr/lib/udev/scsi_id  --whitelisted /dev/sdc 
35000c500c7869d5b

5
  • How did you know that scsi_id was associated with systemd? Commented Sep 16, 2022 at 17:32
  • 1
    locate scsi_id gave me this: /home/jaroslav/src/github.com/systemd/systemd/src/udev/scsi_id. I had a copy of systemd checked out for some reason... You could have had some luck with: apt-file search scsi_id (debian), e-file scsi_id (gentoo) Commented Sep 16, 2022 at 17:36
  • 1
    I think systemd just has a clone of udev in the source, so the scsi_id program is actually from udev, not systemd. Commented Sep 16, 2022 at 17:38
  • 2
    @ЯрославРахматуллин udev is part of systemd. Commented Sep 16, 2022 at 18:46
  • Good to know! thanks. Commented Sep 16, 2022 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .