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.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/19e02b59-906d-b8a7-8707-a391eac46ca5%40longlandclan.id.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to