WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Making extension for NUT with usb support. Problems with permissions (udev)  (Read 4751 times)

Offline rabtux

  • Newbie
  • *
  • Posts: 6
Hi!
I am making a tiny core extension for Network UPS Tools (NUT) with support for usbhid-ups driver (connecting to ups over usb).
(www.networkupstools.org)

I have compiled it for tiny core, but I have some permission problems.
I have installed it from source and configured it to run as user=ups and group=nut (./configure --with-user=ups --with-group=nut)
I have also made this user on the tiny core machine.

If I try to start, it won't work:
Code: [Select]
root@Dalen:/usr/local/ups/bin/upsdrvctl start eaton
I get this error message:

Network UPS Tools - UPS driver controller 2.6.4
Network UPS Tools - Generic HID driver 0.37 (2.6.4)
USB communication driver 0.31
No matching HID UPS found
Driver failed to start (exit status=1)

If I run the driver itself as user=ups I get this error
Code: [Select]
root@Dalen:/home/tc# /usr/local/ups/bin/usbhid-ups -u ups -DD -a eaton
Network UPS Tools - Generic HID driver 0.37 (2.6.4)
USB communication driver 0.31
   0.000000 debug level is '2'
   0.001697 upsdrv_initups...
   0.119706 Checking device (1D6B/0002) (001/001)
   0.120568 Failed to open device, skipping. (Permission denied)
   0.121018 Checking device (18A5/0302) (001/002)
   0.121344 Failed to open device, skipping. (Permission denied)
   0.121647 Checking device (1D6B/0001) (002/001)
   0.122122 Failed to open device, skipping. (Permission denied)
   0.122582 Checking device (1D6B/0001) (003/001)
   0.122956 Failed to open device, skipping. (Permission denied)
   0.123201 Checking device (1D6B/0001) (004/001)
   0.123456 Failed to open device, skipping. (Permission denied)
   0.123697 Checking device (1D6B/0001) (005/001)
   0.123953 Failed to open device, skipping. (Permission denied)
   0.124193 Checking device (0463/FFFF) (005/002)
   0.124447 Failed to open device, skipping. (Permission denied)
   0.124685 No appropriate HID device found
   0.124815 No matching HID UPS found
root@Dalen:/home/tc#

If I run as root the the driver connect works and connect to the ups.


I asked on the mailing list for Network UPS tools and I learned that access rights is addressed on Linux through udev. I was told that running
Code: [Select]
$ udevadm trigger --subsystem-match=usb --action=change and unplug/replug usb cable should solve the problem, but with no luck.
I have also tried running
Code: [Select]
udevadm control --reload-rules with no luck.

For just to check that the program is working and its a permission problem I tried this:
chmod 0777 directly on usb bus that the ups is connected to the root@Dalen:/usr/local/ups/bin/upsdrvctl start eaton will start and I can start the upsd deamon and everything is working


Does anyone have any ideas whats wrong? Is it possible that something is wrong with the udev rule or maybe the rule is not loaded?


the udev rule is placed in:
Code: [Select]
root@Dalen:/etc/udev/rules.d# ls -la
total 60
drwxr-xr-x    2 root     root           360 Jul 18 02:06 .
drwxr-xr-x    3 root     root            60 Jul 18 02:06 ..
-rw-r--r--    1 root     root           764 Aug 10  2011 42-qemu-usb.rules
-rw-r--r--    1 root     root           277 Aug 10  2011 50-firmware.rules
-rw-r--r--    1 root     root          3816 Oct  8  2011 50-udev-default.rules
lrwxrwxrwx    1 root     root            52 Jul 28 08:06 52-nut-usbups.rules -> /tmp/tcloop/nut/etc/udev/rules.d/52-nut-usbups.rules
-rw-r--r--    1 root     root           167 Aug 10  2011 55-tc.rules
-rw-r--r--    1 root     root           104 Oct  8  2011 56-lsusb.rules
-rw-r--r--    1 root     root           308 Aug 10  2011 60-cdrom_id.rules
-rw-r--r--    1 root     root          1060 Aug 10  2011 60-pcmcia.rules
-rw-r--r--    1 root     root           616 Aug 10  2011 60-persistent-alsa.rules
-rw-r--r--    1 root     root          2400 Aug 10  2011 60-persistent-input.rules
-rw-r--r--    1 root     root           947 Aug 10  2011 60-persistent-serial.rules
-rw-r--r--    1 root     root          2669 Aug 10  2011 60-persistent-storage.rules
-rw-r--r--    1 root     root           239 Aug 10  2011 75-cd-dvd.rules
-rw-r--r--    1 root     root           657 Aug 10  2011 80-drivers.rules
-rw-r--r--    1 root     root           155 Aug 10  2011 95-udev-late.rules
-rw-r--r--    1 root     root           294 Mar  4  2010 98-tc.rules
root@Dalen:/etc/udev/rules.d#


and looks like this:
Code: [Select]
# This file is generated and installed by the Network UPS Tools package.

ACTION!="add|change", GOTO="nut-usbups_rules_end"
SUBSYSTEM=="usb_device", GOTO="nut-usbups_rules_real"
SUBSYSTEM=="usb", GOTO="nut-usbups_rules_real"
SUBSYSTEM!="usb", GOTO="nut-usbups_rules_end"

LABEL="nut-usbups_rules_real"
#  Krauler UP-M500VA  - blazer_usb
ATTR{idVendor}=="0001", ATTR{idProduct}=="0000", MODE="664", GROUP="nut"

# Hewlett Packard
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="0001", MODE="664", GROUP="nut"
#  T500  - bcmxcp_usb
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f01", MODE="664", GROUP="nut"
#  T750  - bcmxcp_usb
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f02", MODE="664", GROUP="nut"
#  HP T750 INTL  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f06", MODE="664", GROUP="nut"
#  HP T1000 INTL  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f08", MODE="664", GROUP="nut"
#  HP T1500 INTL  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f09", MODE="664", GROUP="nut"
#  HP R/T 2200 INTL (like SMART2200RMXL2U)  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f0a", MODE="664", GROUP="nut"
#  HP R1500 G2 and G3 INTL  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe0", MODE="664", GROUP="nut"
#  HP T750 G2  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe1", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe2", MODE="664", GROUP="nut"
#  HP T1500 G3  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe3", MODE="664", GROUP="nut"
#  R/T3000  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe5", MODE="664", GROUP="nut"
#  R/T3000  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe6", MODE="664", GROUP="nut"
#  various models  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe7", MODE="664", GROUP="nut"
#  various models  - usbhid-ups
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1fe8", MODE="664", GROUP="nut"

# Eaton
#  various models  - usbhid-ups
ATTR{idVendor}=="0463", ATTR{idProduct}=="0001", MODE="664", GROUP="nut"
#  various models  - usbhid-ups
ATTR{idVendor}=="0463", ATTR{idProduct}=="ffff", MODE="664", GROUP="nut"

# Dell
#  various models  - usbhid-ups
ATTR{idVendor}=="047c", ATTR{idProduct}=="ffff", MODE="664", GROUP="nut"

# Belkin
#  F6H375-USB  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0375", MODE="664", GROUP="nut"
#  F6C550-AVR  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0551", MODE="664", GROUP="nut"
#  F6C1250-TW-RK  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0750", MODE="664", GROUP="nut"
#  F6C1500-TW-RK  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0751", MODE="664", GROUP="nut"
#  F6C900-UNV  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0900", MODE="664", GROUP="nut"
#  F6C100-UNV  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0910", MODE="664", GROUP="nut"
#  F6C120-UNV  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0912", MODE="664", GROUP="nut"
#  F6C800-UNV  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="0980", MODE="664", GROUP="nut"
#  F6C1100-UNV, F6C1200-UNV  - usbhid-ups
ATTR{idVendor}=="050d", ATTR{idProduct}=="1100", MODE="664", GROUP="nut"

# APC
#  various models  - usbhid-ups
ATTR{idVendor}=="051d", ATTR{idProduct}=="0002", MODE="664", GROUP="nut"
#  various 5G models  - usbhid-ups
ATTR{idVendor}=="051d", ATTR{idProduct}=="0003", MODE="664", GROUP="nut"

# Powerware
#  various models  - bcmxcp_usb
ATTR{idVendor}=="0592", ATTR{idProduct}=="0002", MODE="664", GROUP="nut"
#  PW 9140  - usbhid-ups
ATTR{idVendor}=="0592", ATTR{idProduct}=="0004", MODE="664", GROUP="nut"
#  Agiler UPS  - blazer_usb
ATTR{idVendor}=="05b8", ATTR{idProduct}=="0000", MODE="664", GROUP="nut"
#  Belkin F6C1200-UNV  - blazer_usb
ATTR{idVendor}=="0665", ATTR{idProduct}=="5161", MODE="664", GROUP="nut"

# Phoenixtec Power Co., Ltd
#  various models  - bcmxcp_usb
ATTR{idVendor}=="06da", ATTR{idProduct}=="0002", MODE="664", GROUP="nut"
#  Mustek Powermust  - blazer_usb
ATTR{idVendor}=="06da", ATTR{idProduct}=="0003", MODE="664", GROUP="nut"
#  Phoenixtec Innova 3/1 T  - blazer_usb
ATTR{idVendor}=="06da", ATTR{idProduct}=="0004", MODE="664", GROUP="nut"
#  Phoenixtec Innova RT  - blazer_usb
ATTR{idVendor}=="06da", ATTR{idProduct}=="0005", MODE="664", GROUP="nut"
#  Phoenixtec Innova T  - blazer_usb
ATTR{idVendor}=="06da", ATTR{idProduct}=="0201", MODE="664", GROUP="nut"
#  various models  - usbhid-ups
ATTR{idVendor}=="06da", ATTR{idProduct}=="ffff", MODE="664", GROUP="nut"

# iDowell
#  iDowell  - usbhid-ups
ATTR{idVendor}=="075d", ATTR{idProduct}=="0300", MODE="664", GROUP="nut"

# Cyber Power Systems
#  900AVR/BC900D, CP1200AVR/BC1200D  - usbhid-ups
ATTR{idVendor}=="0764", ATTR{idProduct}=="0005", MODE="664", GROUP="nut"
#  Dynex DX-800U?  - usbhid-ups
ATTR{idVendor}=="0764", ATTR{idProduct}=="0501", MODE="664", GROUP="nut"
#  OR2200LCDRM2U, OR700LCDRM1U, PR6000LCDRTXL5U  - usbhid-ups
ATTR{idVendor}=="0764", ATTR{idProduct}=="0601", MODE="664", GROUP="nut"
#  Sweex 1000VA  - richcomm_usb
ATTR{idVendor}=="0925", ATTR{idProduct}=="1234", MODE="664", GROUP="nut"

# TrippLite
#  e.g. OMNIVS1000, SMART550USB, ...  - tripplite_usb
ATTR{idVendor}=="09ae", ATTR{idProduct}=="0001", MODE="664", GROUP="nut"
#  e.g. TrippLite AVR550U  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="1003", MODE="664", GROUP="nut"
#  e.g. TrippLite AVR750U  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="1007", MODE="664", GROUP="nut"
#  e.g. TrippLite ECO550UPS  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="1008", MODE="664", GROUP="nut"
#  e.g. TrippLite ECO550UPS  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="1009", MODE="664", GROUP="nut"
#  e.g. TrippLite ECO550UPS  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="1010", MODE="664", GROUP="nut"
#  e.g. TrippLite OMNI1000LCD  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2005", MODE="664", GROUP="nut"
#  e.g. TrippLite OMNI900LCD  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2007", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2008", MODE="664", GROUP="nut"
#  e.g. TrippLite Smart1000LCD  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2009", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2010", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2011", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2012", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2013", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="2014", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3008", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3009", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3010", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3011", MODE="664", GROUP="nut"
#  e.g. TrippLite smart2200RMXL2U  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3012", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3013", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3014", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="3015", MODE="664", GROUP="nut"
#  e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?)  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4001", MODE="664", GROUP="nut"
#  e.g. TrippLite SmartOnline SU6000RT4U?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4002", MODE="664", GROUP="nut"
#  e.g. TrippLite SmartOnline SU1500RTXL2ua  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4003", MODE="664", GROUP="nut"
#  e.g. TrippLite SmartOnline SU1000XLA  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4004", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4005", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4006", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4007", MODE="664", GROUP="nut"
#  e.g. ?  - usbhid-ups
ATTR{idVendor}=="09ae", ATTR{idProduct}=="4008", MODE="664", GROUP="nut"

# PowerCOM
#  PowerCOM BNT-xxxAP  - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="0004", MODE="664", GROUP="nut"
#  PowerCOM IMP - IMPERIAL Series  - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a2", MODE="664", GROUP="nut"
#  PowerCOM SKP - Smart KING Pro (all Smart series)  - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a3", MODE="664", GROUP="nut"
#  PowerCOM WOW  - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a4", MODE="664", GROUP="nut"
#  PowerCOM VGD - Vanguard  - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a5", MODE="664", GROUP="nut"
#  PowerCOM BNT - Black Knight Pro  - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a6", MODE="664", GROUP="nut"
#  Unitek Alpha 1200Sx  - blazer_usb
ATTR{idVendor}=="0f03", ATTR{idProduct}=="0001", MODE="664", GROUP="nut"

# Liebert
#  Liebert PowerSure PSA UPS  - usbhid-ups
ATTR{idVendor}=="10af", ATTR{idProduct}=="0001", MODE="664", GROUP="nut"
#  GE EP series  - blazer_usb
ATTR{idVendor}=="14f0", ATTR{idProduct}=="00c9", MODE="664", GROUP="nut"
#  Ablerex 625L USB  - blazer_usb
ATTR{idVendor}=="ffff", ATTR{idProduct}=="0000", MODE="664", GROUP="nut"

LABEL="nut-usbups_rules_end"


Regards,

rabtux

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
You could try configuring with user=tc and group=staff?

Offline rabtux

  • Newbie
  • *
  • Posts: 6
I tried configuring with user=tc and group er staff and it works.

but this is because of all the usb bus is owned by root:staff by default.

Code: [Select]
root@Dalen:/dev/bus/usb/001# ls -la
total 0
drwxr-xr-x    2 root     root            80 Jul 30 10:05 .
drwxr-xr-x    7 root     root           140 Jul 30 10:05 ..
crw-rw-r--    1 root     staff     189,   0 Jul 30 10:05 001
crw-rw-r--    1 root     staff     189,   1 Jul 30 10:05 002
root@Dalen:/dev/bus/usb/001# cd ../002/
root@Dalen:/dev/bus/usb/002# ls -la
total 0
drwxr-xr-x    2 root     root            60 Jul 30 10:05 .
drwxr-xr-x    7 root     root           140 Jul 30 10:05 ..
crw-rw-r--    1 root     staff     189, 128 Jul 30 10:05 001
root@Dalen:/dev/bus/usb/002# cd ../003
root@Dalen:/dev/bus/usb/003# ls -la
total 0
drwxr-xr-x    2 root     root            60 Jul 30 10:05 .
drwxr-xr-x    7 root     root           140 Jul 30 10:05 ..
crw-rw-r--    1 root     staff     189, 256 Jul 30 10:05 001
root@Dalen:/dev/bus/usb/003# cd ../004
root@Dalen:/dev/bus/usb/004# ls -la
total 0
drwxr-xr-x    2 root     root            60 Jul 30 10:05 .
drwxr-xr-x    7 root     root           140 Jul 30 10:05 ..
crw-rw-r--    1 root     staff     189, 384 Jul 30 10:05 001
root@Dalen:/dev/bus/usb/004# cd ../005
root@Dalen:/dev/bus/usb/005# ls -la
total 0
drwxr-xr-x    2 root     root            80 Jul 30 10:05 .
drwxr-xr-x    7 root     root           140 Jul 30 10:05 ..
crw-rw-r--    1 root     staff     189, 512 Jul 30 10:05 001
crw-rw-r--    1 root     staff     189, 513 Jul 30 18:44 002
root@Dalen:/dev/bus/usb/005#


it has nothing to do with udev. I deleted the udev rule and its still working...


Regards,

rabtux