Marc O'Morain wrote:
> Hi there,
> 
> I am currently writing an application that I want to run as
> unprivileged user, but I want to read raw data from a block device
> such as /dev/sda (the usual block device for USB memory sticks).

sda is also the usual device if your primary harddisk is a SATA or SCSI
disk, so don't assume it is always sda!

> The problem is that users do not have privileges to read from
> /dev/sda.

on modern Linux systems with udev, the udev daemon should (if configured
properly) use different permissions for sda if sda happens to a USB
memory stick. Other platforms might use a different way to change the
permissions. The permission issue, however, is not an issue that should
be solved on the application level, but is an issue that the platform
should resolve.

> So I will need my application to gain root privileges to
> read from this device.

you could, as temporary solution for old systems, call a script with
sudo that changes the permissions of the device. This way you do not
need any complex architecture in your application (which is prone to
security bugs). Your application would, furthermore, integrate better
with modern systems on which the permission of devices may dynamically
change with the type of device connected.

regards,
        Olivier Sessink
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to