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

Method of generating password causes problems if compute node locale is not UTF8 #91

Closed
ericfranz opened this issue Aug 2, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@ericfranz
Copy link
Contributor

commented Aug 2, 2018

See https://listsprd.osu.edu/pipermail/ood-users/2018-August/000206.html

Perhaps we should use a different approach that would reliably work, even when the locale on the compute nodes is en_US instead of en_US.UTF-8

@ericfranz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 2, 2018

The code:

create_passwd () {
tr -cd '[:alnum:]' < /dev/urandom 2> /dev/null | head -c${1:-#{passwd_size}}
}
export -f create_passwd

Alternatives? Perhaps instead of tr -cd '[:alnum:]' we should be more explicit and do tr -cd 'A-Za-z0-9'.

@ericfranz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 2, 2018

An easy way to test would be to find offending characters, put it in a file and then do:

tr -cd '[:alnum:]' < /path/to/big/file/with/offending/characters 2> /dev/null | head -c${1:-#{passwd_size}} 

Then we can experiment/test/verify the difference. Or the create_passwd function accepts an optional argument and the file used in the function is either /dev/urandom or the file specified by the argument.

@ke3vin

This comment has been minimized.

Copy link

commented Aug 2, 2018

You can also experiment just by setting LANG (or LC_CTYPE) prior to running your test.
It appears that with LANG set to en_US, the [:alnum:] argument to tr generates a bunch of characters with their high bit set, I'm not sure why. If LANG is set to en_US.UTF_8, it works correctly.
Using tr -cd 'A-Za-z0-9' works correctly in both cases.

@ericfranz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 22, 2018

#94 uses tr -cd 'A-Za-z0-9' to fix the problem. Thank you @ke3vin for the help!

@ericfranz ericfranz closed this Aug 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.