[SOLVED] absolutely no /etc/udev rules ever worked

Kernels & Hardware, configuring network, installing services

[SOLVED] absolutely no /etc/udev rules ever worked

Postby jrobin28260 » 2018-12-19 17:53

Hi, here is my problem

I'm trying to create some rule, triggered on the connection of an USB device, but let's say that at this moment, now, I would be grateful if I could create ANY working rule that would do any working action (even something stupid), even triggered from anything, or even everything, because it's like everything that could be written inside /etc/udev/ had absolutely no effect during the past 3 hours... yes.

Here is the set of operation I did after every try :
update-initramfs -u
udevadm control -R
udevadm control --reload
udevadm control --reload-rules
update-initramfs -u
reboot

Here is everything I've tried to place into the /etc/udev/udev.conf file. Absolutely none of these did anything.
I also tried to put them into rules.d and hwdb.d subfolder with the same effect : nothing after more than 3 hours !

I guess there is something wrong with that. But I'm becoming too tired to find out what.

ACTION=="add", ATTRS{manufacturer}=="STIL", MODE="0666"
ACTION=="remove", ATTRS{manufacturer}=="STIL", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"


ACTION=="add", ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"
ACTION=="remove", ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666", GROUP="plugdev"



ACTION=="add", ATTRS{manufacturer}=="STIL", GROUP="plugdev"
ACTION=="remove", ATTRS{manufacturer}=="STIL", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", GROUP="plugdev"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", GROUP="plugdev"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", GROUP="plugdev"

ACTION=="add", MODE="0666", GROUP="plugdev"
ACTION=="remove", MODE="0666", GROUP="plugdev"

ACTION=="add", MODE="0666"
ACTION=="remove", MODE="0666"

ACTION=="add", GROUP="plugdev"
ACTION=="remove", GROUP="plugdev"

ACTION=="add", ATTRS{manufacturer}=="STIL", MODE="0666"
ACTION=="remove", ATTRS{manufacturer}=="STIL", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"

ACTION=="add", MODE="0666"
ACTION=="remove", MODE="0666"
SUBSYSTEM=="usb", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", GROUP="plugdev"
SUBSYSTEM=="usb", MODE="0666"

ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"
ATTRS{manufacturer}=="STIL", GROUP="plugdev"
ATTRS{manufacturer}=="STIL", MODE="0666"



ACTION=="add", ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"
ACTION=="remove", ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", RUN+="/sbin/reboot"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", RUN+="/sbin/reboot"

ACTION=="add", RUN+="/sbin/reboot"
ACTION=="remove", RUN+="/sbin/reboot"



SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666", GROUP="plugdev"

SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"

SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", GROUP="plugdev"

SUBSYSTEM=="usb", GROUP="plugdev"

SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", MODE="0666"

SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", MODE="0666"
SUBSYSTEM=="usb", MODE="0666"

ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"
ATTRS{manufacturer}=="STIL", MODE="0666", GROUP="plugdev"

ATTRS{manufacturer}=="STIL", MODE="0666"
ATTRS{manufacturer}=="STIL", MODE="0666"

SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"
SUBSYSTEM=="usb", ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"

SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{manufacturer}=="STIL", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"

SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", ATTRS{idProduct}=="0000", RUN+="/sbin/reboot"

SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", RUN+="/sbin/reboot"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b3e", RUN+="/sbin/reboot"

SUBSYSTEM=="usb", RUN+="/sbin/reboot"


ATTRS{manufacturer}=="STIL", GROUP="plugdev"
ATTRS{manufacturer}=="STIL", RUN+="/sbin/reboot"

SUBSYSTEM=="usb", RUN+="/sbin/reboot"


MODE="0666", GROUP="plugdev"
MODE="0666"
GROUP="plugdev"
RUN+="/sbin/reboot"





If even RUN+="/sbin/reboot" with absolutely no filter does nothing, then I cannot do anything else.
Is somebody able to see what I should do now ?
Last edited by jrobin28260 on 2018-12-22 20:10, edited 1 time in total.
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: absolutely no /etc/udev rules ever worked

Postby Dai_trying » 2018-12-19 20:30

I recall having a lot of problems trying to run root commands via a udev rule, the easiest way would be to run a script from the udev rule similar to this..
Code: Select all
ACTION=="add", SUBSYSTEM=="hid", RUN+="/usr/local/bin/script_to_shutdown.sh"

Obviously you would need to add your attributes etc to this (It is only a general reference) and using udevadm monitor will give you information on devices as they are plugged in/removed to ensure correct attributes.
And then place your shutdown commands in the script (use sudo or gksudo or even pkexec), I ran into some problems like this when I wanted a udev rule to disable my touchpad when using usb mouse, you will also very likely be required to enter your password depending on how your security is set up although this can be avoided but with the downside being system security.
Dai_trying
 
Posts: 577
Joined: 2016-01-07 12:25

Re: absolutely no /etc/udev rules ever worked

Postby jrobin28260 » 2018-12-20 13:46

Hi, thank you for your answer

Here is what I get when I look at udevadm monitor and when I connect my USB device
Code: Select all
KERNEL[354.765987] add      /devices/pci0000:00/0000:00:14.0/usb1/1-3 (usb)
KERNEL[354.766417] add      /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0 (usb)
UDEV  [354.776496] add      /devices/pci0000:00/0000:00:14.0/usb1/1-3 (usb)
UDEV  [354.778444] add      /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0 (usb)



here is, also, the content of my /etc/udev/udev.conf file

Code: Select all
# see udev.conf(5) for details
#
# udevd is started in the initramfs, so when this file is modified the
# initramfs should be rebuilt.

#udev_log="info"
ACTION=="add", SUBSYSTEM=="usb", RUN+="/test/test.sh"


/test is a 777 folder
/test/test.sh is a 777 file containing :

Code: Select all
#!/bin/sh
echo "test" >> out.txt


And of course, I already tried it manually (it creates the out.txt file and places the word "test" in it).

After having tried everything, here I am again : the out.txt file didn't appear.
I think that writing into the /etc/udev/udev.conf file will never do anything, as Yesterday it already proved doing nothing.

Of course I tried to play the entire list of available command found on the Internet :
update-initramfs -u
udevadm control -R
udevadm control --reload
udevadm control --reload-rules
update-initramfs -u
reboot

But it's still doing nothing.

But I don't know where I have to look at, now.
Any idea ?
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: absolutely no /etc/udev rules ever worked

Postby peter_irich » 2018-12-20 18:03

Own rules must be in /etc/udev/rules.d and look like in /lib/udev/rules.d/.

Peter.
peter_irich
 
Posts: 1239
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: absolutely no /etc/udev rules ever worked

Postby Dai_trying » 2018-12-20 19:13

peter_irich wrote:Own rules must be in /etc/udev/rules.d and look like in /lib/udev/rules.d/.


Very good point and probably something I should have mentioned but I didn't realize Op was using the wrong file, well spotted :D
Dai_trying
 
Posts: 577
Joined: 2016-01-07 12:25

Re: absolutely no /etc/udev rules ever worked

Postby jrobin28260 » 2018-12-20 19:36

Yes !!
Thank you !

There was several problems :
-> things that I was writing into /etc/udev/udev.conf were ignored
-> it should be placed into the "rules.d" subfolder but it is not enough
-> the file extention SHOULD be ".rules", if not, it is ignored
-> several lines I was trying weren't working, even with all those conditions being satisfied... and I don't know why ! My test script for example didn't worked.

So as I didn't met all those requirement at once at each try, I had completely nothing even by trying everything...

The only 2 lines that I got working are :

SUBSYSTEM=="usb", ATTRS{idProduct}=="0000", ATTRS{idVendor}=="1b3e", MODE="0660", GROUP="plugdev"
or
SUBSYSTEMS=="usb", MODE="0660", GROUP="plugdev"

This line didn't worked :
SUBSYSTEM=="usb", ATTR{idProduct}=="0000", ATTR{idVendor}=="1b3e, MODE="0660", GROUP="plugdev"

I haven't the courage anymore to try back all the previous lines but here I am : something that I was trying is now successful. I have my sensor, connected trough USB and my app using "libusb" is now able to receive and send messages to the sensor using it's differents "endpoints" (0x82 and 0x06 for bulk stream reception and bulk message writes), bye RS232 Serial Port !
In that way, access to serial ports converters (dialout group) and access to USB devices (plugdev group) is now possible for members of the groups.

I guess having the user able to access in a "raw" way any USB device is a bad thing because it could short-circuit others permissions ? Like "disk" group access from a normal user, being able to read/write anything anywhere on the disk. Keyboards... Well, I think I'll be using the line in which there is a precise description of the VID:PID that is going to be available for user.

Thanks !
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30


Return to System configuration

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable