Skip to content

Add fallbacks for import crypt#2156

Open
norakoiralamsft wants to merge 4 commits intomasterfrom
norakoirala/vmaccess-crypt
Open

Add fallbacks for import crypt#2156
norakoiralamsft wants to merge 4 commits intomasterfrom
norakoirala/vmaccess-crypt

Conversation

@norakoiralamsft
Copy link
Copy Markdown
Contributor

@norakoiralamsft norakoiralamsft commented Mar 30, 2026

This PR is aimed to add fallbacks for importing the cypt library with was deprecated in python 3.11, takes a similar approach as to Linux Agent, first trying to import crypt (which includes crypt + crypt_r), legacycrypt, and finally passlib.

This was chosen over the crypt_fallback that was introduced in this PR because we want to continue supporting older distros that may not have cyptes available, and Canocial raised concerns about the crypt_r lib as well, and have ensured that passlib will be available on Ubuntu.

@norakoiralamsft norakoiralamsft requested review from a team, D1v38om83r and nkuchta as code owners March 30, 2026 18:49
jscalev
jscalev previously approved these changes Mar 30, 2026
@norakoiralamsft norakoiralamsft changed the title Import crypt fallback Add fallbacks for import crypt Apr 1, 2026
Comment on lines +34 to +36
if cryptImported == False:
try:
from passlib.hash import sha512_crypt
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

question for my understanding: why do we not try to import passlib right away after crypt fails? why is it our second fallback, not our first? what benefits does legacycrypt have?

return crypt.crypt(password, salt)

if cryptImported:
return crypt(password, salt)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe a dumb question, but is crypt() a different or the same algorithm as sha512_crypt()? why do we prefer to use one over the other?

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.

3 participants