[Lazarus] run program in ide with sudo for debug purpose

Sven Barth pascaldragon at googlemail.com
Mon Feb 27 13:50:35 CET 2012


Am 27.02.2012 12:13, schrieb Mark Morgan Lloyd:
> Sven Barth wrote:
>> Am 27.02.2012 11:07, schrieb Mark Morgan Lloyd:
>
>>> I'd be happy to be proven wrong, but my understanding is that you do
>>> since there is one specific kernel call (in effect, telling the kernel
>>> to release an unrecognised device to an unprivileged program) that won't
>>> work otherwise.
>>>
>>
>> I already managed the following some time ago for a scanner that was
>> not supported by SANE:
>> * setup a Windows VM in QEMU
>> * tell QEMU to pass the scanner to the VM
>>
>> If I now started the VM I became a "permission denied" error when it
>> tried to open the corresponding dev node. Now I simply changed (at
>> that time without udev rules, because they somehow didn't work as I
>> wanted them to) the group of the corresponding device file
>> (/dev/usb/{bus}/{device}) to a group my user is part of and Tada! it
>> worked. So no, you don't need Root access for an unrecognized device.
>
> The reason it didn't work as expected might have been because the
> insertion of otherwise-unrecognised devices in /dev/usb is a
> comparatively recent feature. Checking, it's not in 2.6.18 (Debian Etch)
> but is in 2.6.32 (Debian Lenny). Allow for a few kernel steppings for it
> to actually /work/ :-)

At the time I tested this I run a 2.6.40 or so kernel (ArchLinux) so 
this was definitely not the problem ;) Nevertheless: though the udev 
rules failed the manual changing of the ownership on the host computer 
worked.

> But to make those changes (and were they in the host or the guest?) you
> needed root access. So you've moved the problem rather than fixing it
> permanently.
>

These changes were on the host and the ownership only needs to be 
changed once after the scanner was plugged in (udev would have done that 
automatically, but as I didn't need the scanner that often the manual 
route was sufficient) otherwise QEMU will complain that it can't open 
the USB device file.

Note: I did never look why my udev rule didn't work. Today this is no 
longer important as I now have a scanner that works with SANE.

Also I don't see what you want to imply with "moved the problem". The 
solution for accessing hardware devices without root access is to change 
their permissions one way or the other. You can do that either by udev 
rules, manually or in a startup script which is always run (and is run 
as root - like /etc/rc.local on ArchLinux) though in the last case the 
device needs ot be plugged in at startup.

Regards,
Sven




More information about the Lazarus mailing list