On 05/03/18 12:40, 'Luther Goh Lu Feng' via BeagleBoard wrote:
> As shared by Robert [1], the command to retrieve the serial number is as
> follows:
>
> sudo hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/0-0050/eeprom -n 28 |
> cut -b 5-28
>
> Is there anyway to get the serial number without using sudo? My use case
> is that I wish to let other programs use the serial number, but I do not
> wish for these progams to have sudo privilege. What are the possible
> approaches?
You could make a script, /usr/local/bin/getserial:
#!/bin/sh
hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/0-0050/eeprom -n 28 | cut -b 5-28
Create a group of users allowed to see the serial
# groupadd serialnumber
Then in /etc/sudoers:
@serialnumber ALL = NOPASSWD:/usr/local/bin/getserial
Any user in @serialnumber, is allowed to run /usr/local/bin/getserial
via `sudo`, but `sudo` will reject anything else.
--
Stuart Longland (aka Redhatter, VK4MSL)
I haven't lost my mind...
...it's backed up on a tape somewhere.