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

Move passwd to str and use crypt.mksalt() to generate salt #2564 #2

Conversation

FroggyFlox
Copy link

After submitting first-login info, I get the following error:

            Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py", line 41, in _handle_exception
    yield
  File "/opt/rockstor/src/rockstor/storageadmin/views/user.py", line 193, in post
    usermod(invar["username"], invar["password"])
  File "/opt/rockstor/src/rockstor/system/users.py", line 189, in usermod
    crypted_passwd = crypt.crypt(passwd.encode("utf8"), salt_header + salt)
  File "/usr/lib64/python3.6/crypt.py", line 47, in crypt
    return _crypt.crypt(word, salt)
TypeError: crypt() argument 1 must be str, not bytes

As we can see, it seems crypt.crypt() now needs a str and not a byte object. I thought I would give this one a shot and submit the changes as PR in case it helps.

This commit:

  • removes the prior manual encoding to convert from str to byte
  • implements the changes detailed in a listed TODO: switch to using crypt.mksalt() to generate the salt
  • further simplifies this function by calling system.run_command() instead of manually calling subprocess.Popen() again

I've left the previous code commented out to ease comparison at first glance (without diff).

With this commit in, I can successfully submit the first login form and get to Rockstor's dashboard.

@phillxnet
Copy link
Owner

@FroggyFlox I'd forgotten all about this TODO! Thanks for the tidy up here. Nice.

I'll merge and push on with that branch. Thanks again for smoothing our way here.
We wan reference these secondary pull requests (on my working branch) for attribution is what I'm thinking.

@phillxnet phillxnet merged commit 5525d6c into phillxnet:2564_Update_pyproject.toml_and_poetry.lock_for_python_3.6 Jun 5, 2023
@FroggyFlox FroggyFlox deleted the 2564_Update_pyproject.toml_and_poetry.lock_for_python_3.6 branch June 5, 2023 13:17
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.

2 participants