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

RFE: Enhance upsd to LISTEN host:port with one colon-separated parameter token #2424

Open
jimklimov opened this issue Apr 28, 2024 · 1 comment
Labels
augeas Configuration file parser (reader, writer) multi-tool for scripting, etc. enhancement Low-hanging fruit A proposal or issue that is good for newcomers to codebase or otherwise a quick win nutconf NUT configuration library and tool
Milestone

Comments

@jimklimov
Copy link
Member

jimklimov commented Apr 28, 2024

tcp6 0 0 :::3493 :::* LISTEN 1447/upsd
I remember being surprised by the space in the LISTEN directives ...

Thinking of it... might make sense to parse a single token on a LISTEN <token1>:<token2> (with at least one colon character), as an addr-colon-port so spelling of LISTEN :::3493 would get split into :: and 3493, and some LISTEN 127.0.0.1:3493 would become 127.0.0.1 and 3493.

That said, in ~25 years of NUT's existence I think this is the first time such issue was raised (to the best of my personal knowledge) - so I guess it is a rare surprise after all the RTFM :)

Originally posted by @jimklimov in #2417 (comment)

UPDATE: This could be easy in the server-side code; most of the problem would be to teach nutconf, augeas and similar upsd.conf parsers about two acceptable spellings.

UPDATE: While at it (although a separate issue): is there any perceived need to parse the port part (if its string is not representing a number) through the naming database for services to e.g. LISTEN localhost nut?

CC @aquette @clepple : WDYT ?

@jimklimov jimklimov added this to the 2.8.3 milestone Apr 28, 2024
@jimklimov jimklimov added Low-hanging fruit A proposal or issue that is good for newcomers to codebase or otherwise a quick win nutconf NUT configuration library and tool augeas Configuration file parser (reader, writer) multi-tool for scripting, etc. labels Apr 28, 2024
@jimklimov
Copy link
Member Author

For kicks, tried if it would just work - no, it does not; the whole single/first token is seen as an address, and the lack of second token causes an attempt to use the default port number:

:; rm -rf /tmp/nnnn ; mkdir -p /tmp/nnnn && touch /tmp/nnnn/{ups.conf,upsd.conf,upsd.users}
:; echo 'LISTEN :::3493' > /tmp/nnnn/upsd.conf
:; ALLOW_NO_DEVICE=yes NUT_STATEPATH=/tmp/nnnn NUT_CONFPATH=/tmp/nnnn ./server/upsd -DDDDDD ; echo $?
Network UPS Tools upsd 2.8.2-137-g3c19d79de
   0.000001     fopen /tmp/nnnn/upsd.pid: No such file or directory
   0.000043     Could not find PID file '/tmp/nnnn/upsd.pid' to see if previous upsd instance is already running!
   0.000208     /tmp/nnnn/upsd.conf is world readable
   0.000333     [D3] listen_add: added :::3493:3493
   0.000373     [D1] debug level is '6'
   0.000413     [D3] setuptcp: try to bind to :::3493 port 3493
   0.000530     getaddrinfo: Name or service not known

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
augeas Configuration file parser (reader, writer) multi-tool for scripting, etc. enhancement Low-hanging fruit A proposal or issue that is good for newcomers to codebase or otherwise a quick win nutconf NUT configuration library and tool
Projects
None yet
Development

No branches or pull requests

1 participant