Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On macOS ZigStarGW-MT does not run unless it is run as root (sudo) #28

Open
tjuerges opened this issue Dec 31, 2024 · 1 comment
Open

Comments

@tjuerges
Copy link

Hi @xyzroe . Thanks for the flashing tool.

I have downloaded the macOS version from the 0.4.2 release page in order to flash an UZG-01 device. Unfortunately the tool does not work out of the box. This is the error that I see every time I start the tool:

foo@bar ~ 1: /Applications/ZigStarGW-MT.app/Contents/MacOS/ZigStarGW-MT
Traceback (most recent call last):
  File "ZigStarGW-MT.py", line 483, in <module>
  File "ZigStarGW-MT.py", line 478, in main
  File "ZigStarGW-MT.py", line 191, in __init__
  File "zeroconf/_core.py", line 181, in __init__
  File "zeroconf/_utils/net.py", line 358, in create_sockets
  File "zeroconf/_utils/net.py", line 248, in new_socket
OSError: [Errno 48] Address already in use
[45431] Failed to execute script 'ZigStarGW-MT' due to unhandled exception: [Errno 48] Address already in use
[45431] Traceback:
Traceback (most recent call last):
  File "ZigStarGW-MT.py", line 483, in <module>
  File "ZigStarGW-MT.py", line 478, in main
  File "ZigStarGW-MT.py", line 191, in __init__
  File "zeroconf/_core.py", line 181, in __init__
  File "zeroconf/_utils/net.py", line 358, in create_sockets
  File "zeroconf/_utils/net.py", line 248, in new_socket
OSError: [Errno 48] Address already in use

The reason for the error is that macOS already runs services as user root with UID 0 on port 5353 (mDNSResponder) which are responsible for unicast and multicast mDNS.

On macOS port sharing is possible. But it is only allowed when a port is (re-)opened with the appropriate options (Zeroconf already takes care of it) and that the process that wants to open an already used port (here ZigStarGW-MT's Zeroconf instance) shares the same UID with the port owner's process. This is not the case when one runs ZigStarGW-MT as "normal" user and not root.

Solutions:

  • Either catch the exception, tell the user and exit.
  • Or start ZigStarGW-MT with sudo which runs ZigStarGW-MT as root with UID 0:
foo@bar ~ 24: sudo /Applications/ZigStarGW-MT.app/Contents/MacOS/ZigStarGW-MT
Password:
2024-12-31 09:36:29.828 ZigStarGW-MT[57453:4791261] +[IMKClient subclass]: chose IMKClient_Modern
2024-12-31 09:36:29.828 ZigStarGW-MT[57453:4791261] +[IMKInputSession subclass]: chose IMKInputSession_Modern
Opening port socket://192.168.222.66:6638, baud 500000
Connecting to target...
[...]

Starting ZigStarGW-MT with sudo allows the new process, which is now run as root i.e. with the same UID 0 that mDNSResponder is already run with, to share the port that mDNSResponder is already using.

It would be very helpful if this could be documented on the web page.

@xyzroe
Copy link
Owner

xyzroe commented Dec 31, 2024

Hi @tjuerges ,

Thank you for your feedback! Would you consider submitting a pull request with the suggested changes to either the program or the documentation? This would help improve the tool for all users.

Regarding flashing the UZG-01: most users now prefer the XZG firmware, which allows the Zigbee module to be flashed directly through the web interface without the need for additional utilities.

Let me know if you need further assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants