Skip to content

Rework client password input#3488

Draft
dougnazar wants to merge 2 commits into
networkupstools:masterfrom
dougnazar:rework_client_password_input
Draft

Rework client password input#3488
dougnazar wants to merge 2 commits into
networkupstools:masterfrom
dougnazar:rework_client_password_input

Conversation

@dougnazar

Copy link
Copy Markdown
Contributor

Couple simple changes to password handling for the clients, mainly because I don't want to specify the password on a command line for my weekly battery tests. Cleaned up the usage of deprecated getpass() while I was at it.

  • clients: Use readpassphrase() if available
  • clients: Add option to read password from a file

Signed-off-by: Doug Nazar <nazard@nazar.ca>
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit 86ca800 is temporarily available: NUT-tarballs-PR-3488.zip.

@AppVeyorBot

Copy link
Copy Markdown

@dougnazar dougnazar force-pushed the rework_client_password_input branch from 13b427c to 974e00b Compare June 17, 2026 21:32
Comment thread clients/common-clients.c
if (fp == NULL)
return NULL;

p = fgets(buffer, buffer_size, fp);
Signed-off-by: Doug Nazar <nazard@nazar.ca>
@jimklimov

jimklimov commented Jun 17, 2026

Copy link
Copy Markdown
Member

Gotta review actual changes, but at face value seems similar to a solution for issue #3329 that is in dev/CI loops for a few weeks now (and cooking dependent branches for further binding/client support.

Rework of getpass*() may be bringing orthogonal value to that though.

@AppVeyorBot

Copy link
Copy Markdown

@dougnazar dougnazar force-pushed the rework_client_password_input branch from 974e00b to 86ca800 Compare June 17, 2026 23:52
@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.4842-master completed (commit b1ae1a9df0 by @dougnazar)

@AppVeyorBot

Copy link
Copy Markdown

@dougnazar

Copy link
Copy Markdown
Contributor Author

Oops. I did a quick search for password before submitting but nothing showed up. I did see the other patch a while ago but thought it was just about client SSL support, and didn't include passwords.

Looks like I can do what I want with that patch, although it feels a little awkward to me. If I have a system file and a user file it'll only read the system file if I include it. Perhaps the system file should always be read, with any user/specified file overriding it. Then you could force system-wide various SSL defaults and then per-user have the login credentials.

Anyways, feel free to close, I'm happy with either solution.

@jimklimov jimklimov marked this pull request as draft June 18, 2026 07:56
@jimklimov

Copy link
Copy Markdown
Member

Actually, per upscli_read_authconf_file() in that PR, following dedicated envvars goes first, then looking under $HOME of the user, and only the last option is a system-wide file.

Whichever is found is the only one parsed (but it may INCLUDE others explicitly).

Note that the system-wide file may be generally not readable by user accounts (the few admin accounts can be part of a POSIX group allowed to read it though).

@jimklimov

Copy link
Copy Markdown
Member

UPDATE: I realized that #3329 did not seem like related to "authconf", as the comment with config file design got hidden by github. Reworded that issue and added links to make it clearer in hindsight :)

@dougnazar

Copy link
Copy Markdown
Contributor Author

Actually, per upscli_read_authconf_file() in that PR, following dedicated envvars goes first, then looking under $HOME of the user, and only the last option is a system-wide file.

Whichever is found is the only one parsed (but it may INCLUDE others explicitly).

However if a user creates a authconf file, they may not know to include a system default file or where the CA file is or that they should force SSL.

Also, with a system default file, you wouldn't need to always specify -A default. If you leave the file blank, everything works the same as before. Only if you add/uncomment some lines does it start to use those settings.

Note that the system-wide file may be generally not readable by user accounts (the few admin accounts can be part of a POSIX group allowed to read it though).

The way I'd handle this is a world readable system default file that INCLUDEs a protected system file. That should gracefully fail for unprivileged users.

For instance, vim, nano, jed all load a system file first, then look for a user file. So that's probably why it feels more natural for me. I'm sure there are many counter examples too.

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

Successfully merging this pull request may close these issues.

4 participants