A customer has an amd64 classic project whose gadget snap will use the Serial Vault.
We’d like the prepare-device hook to set a unique serial number  on each system (even if this is not currently an enforced requirement).
One method to obtain a unique serial number in the prepare-device hook may be:
$ cat /sys/devices/virtual/dmi/id/product_serial
Does this require declaring a plug or will it just work (the gadget is strict confinement)? (I don’t have spare hw to test this on.)
Is this a recommended approach or is there something better?
 snapctl set registration.proposed-serial=UNIQUE
Yes, you would need a plug (hardware-observe might work by skimming what we have available),
are they flashing this at manufacturing? or is just “defaults” from the board they use? if they are flashing it it might be reasonable.
Also afaict that can in principle contain spaces or other special chars, that’s not a problem as such, but means one need to be careful with quoting for the snapctl command if the hook is a shell script.
Also if relevant ‘/’ cannot appear in a serial (or any other primary key of assertions).
hardware_observe does not auto connect.  We are using a brand store.
Can they configure this to auto-connect in the brand store?
Are there documented instructions for configuring a snap-declaration to auto-connect in a brand store?
Not sure where the image is flashed. (Not sure why that matters.)
no, I’m talking whether they flash the product_serial/dmi values? it’s a potentially bad idea to use something they don’t control. are we even sure it’s really unique?
No, not sure.
This is why the initial post included: “Is this a recommended approach or is there something better?”
I would like some help/recommendations for how customers can ensure they use unique serial numbers (because there has been consideration in the past and for the future of denying serial assertions for duplicate serial numbers).
I don’t think there’s a general answer.
You need to ask what kind of customisation they do at manufacturing? do they set sane values for DMI/SMBIOS data? yes, no? have something else around?
If they do some sane customisation they probably want the snapd serial to match their notion of product serial.
Otherwise you can always generate a random serial otherwise.
ok, that seems reasonable. thanks!
Has there been any thought to a process to ensure and advise customers on the importance and how they should generate unique serial numbers for their devices? It seems to me that this could become a hairy mess for some customers, especially if they ever let certain devices sit on a shelf disconnected for a length period of time and then bring the device back online, potentially with a duplicate serial number to an existing device.
I’m not sure why sitting on a shelf is relevant to this?
It’s just an example. Say a device were sitting on the shelf with a certain serial number. Because we haven’t really advised the customer on how they should go about coming up with serial numbers for their devices and the importance of each being unique to their context, it’s possible that they might give another device the same one as the device sitting on the shelf since they forgot about it for some reason. It’s just a hypothetical example, but it’s important not to do.
Another reason “sitting on a shelf” may matter is protecting today’s deployments from possible future requirements of serial number uniqueness.
The Serial Vault previously did enforce uniqueness (AIUI). This was turned off, but not definitively for all time (AIUI). If a device is sitting on a shelf today with a non-unique serial number, and later the Serial Vault turns on enforcement of uniqueness, that system will never obtain a serial assertion and will never be able to install from a secure brand store. Perhaps other currently unimagined software will (reasonably) assume that a serial number uniquely describes a device (isn’t that fundamental to the idea of a serial number?).
So today, we do not forcefully warn/advise: Ensure your serial numbers are unique! (within the project domain). I worry this can set up for problems later.
I can add some wording here Gadget snaps , don’t know if it’s enough/the most relevant place
That’s a start and probably worth doing. Thanks for volunteering to do that Samuel.
I added this there (Gadget snaps):
If the device service (typically the serial-vault) requires to set registration.proposed-serial to use as the “serial number” (a string, not necessarly a number) part of the identification, then this must be set to a value that is unique across all devices of the brand and model. This also cannot contain
The serial vault as I understand it does not now require a unique serial number. It does issue a serial assertion with the revision incremented for duplicate serial numbers. But, the SV did at one time require serial number uniqueness. I suppose it might again someday require uniqueness (non-unique serial numbers does not make much sense on the face of it.)
So the above added text does yet not seem to me to give enough advice.
I’m probably not understanding which part of my addition is unclear/insufficient. My advice there is basically:
- if must set registration.proposed-serial (which ATM is alway the case with the serial vault)
- then must set to something unique
On reread, I see that you are saying set it uniquely. But this follows a complex “if”. It is not clear to me that users can answer the “if” very easily.
Can we not simply say something like: Ensure the serial number is unique across brand/model…
I tried to turn the sentence(s) around, hopefully it’s clearer:
One must ensure that
registration.proposed-serial is set to a value unique across all devices of the brand and model and that it does not contain a
/. It is going to be used as the “serial number” (a string, not necessarily a number) part of the identification in case the device service supports setting it or requires it, as is the case with the serial-vault.
Hi @pedronis @kyleN ,
This serial is supposed to be unique for every robot right?
But this serial is given during building the gadget.
So there should be a way to change
registration.proposed-serial after flashing the image, how do i do that?