[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: user perms



On Thu 16 Jun 2022 at 12:22:48 (+0300), Anssi Saari wrote:
> David Wright <deblis@lionunicorn.co.uk> writes:
> 
> > As it happens, I find I have (but don't use):
> 
> > $ grep -i ttyusb /lib/udev/rules.d/*
> 
> I actually found this in 50-udev-default.rules:
> 
> KERNEL=="tty[A-Z]*[0-9]|ttymxc[0-9]*|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout"
> 
> So that should set the group for ttySx and ttyUSBx also to dialout and
> in fact I see exactly that happening in my Debian 11 router which has
> devices ttyS0-ttyS3 and ttyUSB0-ttyUSB4:
> 
> $ ls -l /dev/ttyUSB* /dev/ttyS*
> crw-rw---- 1 root dialout   4, 64 Jun 13 12:12 /dev/ttyS0
> crw-rw---- 1 root dialout   4, 65 Jun 13 12:12 /dev/ttyS1
> crw-rw---- 1 root dialout   4, 66 Jun 13 12:12 /dev/ttyS2
> crw-rw---- 1 root dialout   4, 67 Jun 13 12:12 /dev/ttyS3
> crw-rw---- 1 root dialout 188,  0 Jun 13 12:12 /dev/ttyUSB0
> crw-rw---- 1 root dialout 188,  1 Jun 13 12:12 /dev/ttyUSB1
> crw-rw---- 1 root dialout 188,  2 Jun 13 12:12 /dev/ttyUSB2
> crw-rw---- 1 root dialout 188,  3 Jun 13 12:12 /dev/ttyUSB3
> crw-rw---- 1 root dialout 188,  4 Jun 13 12:12 /dev/ttyUSB4
> 
> I didn't find a rule which sets the perms for these to 0660 but
> something does that for me.
> 
> This rule comes with the udev package itself so it should be always
> installed in a Debian installation.
> 
> Still, it seems for Gene these are overwritten somehow but I don't know
> why or how. I have exactly one USB-to-serial cable I can try to plug in
> and see what happens. However it's a CP210x and I think Gene's stuff is
> FTDI.

I don't have any of these devices, so the closest I can manage is a
mouse that keeps disconnecting and reconnecting every few minutes,
which means it loses its acceleration settings.

I've run

$ udevadm monitor -k -p

and

$ udevadm monitor -u -p

in two xterms, dumping the output to files, and I've kept a copy of
the corresponding kern.log to match up with them. I need to find
time to peruse it all.

I was going to suggest to Gene to run these commands, to see where
the serial numbers of his two devices are given, and which attribute
gives them, as Gene plugs the devices into the ports.

If you have /lib/udev/rules.d/60-serial.rules, which runs after the
above, you can see some more specific rules for ttyUSB[0-9]* devices.
I need to read up on what IMPORT{builtin}="usb_id" does, as that's
a udev rule that I've not used before.

(Actually, /I/ need to read up on stuff like
IMPORT{builtin}="hwdb 'mouse:$env{ID_BUS}:v$attr{id/vendor}p$attr{id/product}:name:$attr{nam
e}:'", …
whatever that does, from 70-mouse.rules.)

But it looks as if a file /etc/udev/rules.d/60-serial.rules
could be coerced into creating symlinks called /dev/<serial-number>
for each device (solves the "swapping" problem), and setting
the group/permissions for the ttyUSBn itself. Of course, we
don't know what permissions /do/ work yet, from Gene's posts.

Gene needs to copy that file, and add a simple rule to do something,
anything, to check it works, like touching a file or creating a
symlink (named with a timestamp). Gene might get a feel for how udev
operates, by doing something simple like that.

Cheers,
David.


Reply to: