Skip to content

fix(changepasswd): consistent connect logging and connection timeout across all protocols - #2291

Merged
alexisbalbachan merged 6 commits into
fortra:masterfrom
n3rada:fix/changepasswd
Oct 28, 2026
Merged

alexisbalbachan merged 6 commits into
fortra:masterfrom
n3rada:fix/changepasswd

Conversation

@n3rada

@n3rada n3rada commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

changepasswd.py could go straight from "connecting" to success or failure, with no way to tell which step a hang was stuck on, and no way to bound how long it waited.

Building on #2217 (LDAP timeout) and #2253 (Kerberos/kpasswd timeout), and depending on #2290 (endpoint mapper timeout), which should land first:

  • All four protocol handlers (smb-samr, rpc-samr, kpasswd, ldap) now log a connect step before the actual network call, and a -timeout flag is wired through to all of them.
  • LdapPassword.connect() splits connecting and authenticating into two separate log lines, and catches OSError so an unreachable or filtered DC fails cleanly instead of a raw traceback.
  • KPassword logs before requesting the TGT and before sending the actual kpasswd request (a different host/port from the KDC), and kpasswd.setPassword() logs the same on the library side.
  • SamrPassword.authenticate() now calls set_connect_timeout() on the RPC transport, and connect() catches connection-level failures (OSError, and DCERPCException for the RPC-over-TCP path) cleanly.
  • RpcPassword.rpctransport() forwards timeout into hept_map(), closing the last gap: the endpoint mapper lookup on TCP/135.

Tested against an unreachable host for each protocol: all four fail cleanly at roughly the given -timeout value instead of hanging (or, for SAMR, hitting the hardcoded 30 second default) or crashing with a raw traceback.

Regards

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Sep 16, 2026
@alexisbalbachan

Copy link
Copy Markdown
Collaborator

Hey, i've been reviewing this PR and found some issues that need correcting:

  • Reject zero or negative timeout values passed to the -timeout flag
  • Default timeout value of None is correctly interpreted as blocking connections for ldap/kpasswd but not for smb-samr/rpc-samr, on which a None value will skip overriding their default timeout values (30 seconds). Default values are set here and here, while overriding them happens conditionally (when timeout is not None) here and here.
  • LDAP connections will clear the timeout values here and here. So the timeout flag only applies to the TCP connection establishment, not TLS negotiation, authentication, or later LDAP operations. I don't think we can remove those overrides so maybe we could reduce the scope (and description of the PR) to only honor the timeout for TCP connection establishment in case of LDAP connections?
  • Finally, it would be great to add unit tests verifying that the timeout value is correctly propagated through the LDAP, kpasswd, SMB-SAMR, RPC-SAMR, and endpoint-mapper connection path

@alexisbalbachan alexisbalbachan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@alexisbalbachan alexisbalbachan added waiting for response Further information is needed from people who opened the issue or pull request and removed in review This issue or pull request is being analyzed labels Oct 21, 2026
@n3rada

n3rada commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

That is a good catch for the 0 timeout value. I was not aware that it makes the socket non-blocking. However, I think that will also need me to change in the code of the three other PRs no? #2217 #2253 #2290

@n3rada n3rada changed the title fix(changepasswd): consistent connect logging and timeout across all protocols fix(changepasswd): consistent connect logging and connection timeout across all protocols Oct 21, 2026
@alexisbalbachan

Copy link
Copy Markdown
Collaborator

Hi, everything looks good and ready to merge, about your question, there's no need to change the timeout 0 value behavior in the scope of those PRs, the change can be introduced in a follow up PR

@alexisbalbachan
alexisbalbachan merged commit 3ee67be into fortra:master Oct 28, 2026
8 checks passed
@n3rada

n3rada commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks! But #2290 should be merged to make this one usable no? Or now closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting for response Further information is needed from people who opened the issue or pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants