Skip to content

Fix regression from PR233 to allow hyphen in sftpsubsys usernames again #262

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

Open
wants to merge 2 commits into
base: edge
Choose a base branch
from

Conversation

jonasbardino
Copy link
Contributor

Fix regression from PR233 which caused sftpsubsys to reject usernames with hyphen (-) in them. Dropped the unnecessary escaping of chars and moved hyphen last in line with the standard requirement for regex patterns.

… with

hyphen (-) in them. Dropped the unnecessary escaping of chars and moved hyphen
last in line with the standard requirement for regex patterns.
@jonasbardino jonasbardino requested a review from a team June 13, 2025 09:08
@jonasbardino jonasbardino self-assigned this Jun 13, 2025
@jonasbardino jonasbardino added the bug Something isn't working label Jun 13, 2025
@jonasbardino jonasbardino linked an issue Jun 13, 2025 that may be closed by this pull request
@@ -29,7 +29,7 @@ MIG_DEFAULTS=-D'MIG_UID=$(shell id -u mig)' \
-D'PASSWORD_MIN_CLASSES=3' \
-D'SHARELINK_HOME="$(shell ~mig/mig/server/readconfval.py sharelink_home)"' \
-D'SHARELINK_LENGTH=10' \
-D'USERNAME_REGEX="^[a-zA-Z0-9][a-zA-Z0-9.@_\\-\\ ]{0,127}$$"'
-D'USERNAME_REGEX="^[a-zA-Z0-9][a-zA-Z0-9.@_ -]{0,127}$$"'
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just add a note that highlights that the hyphen must be at the end, and you have to be careful that it is not being interpreted as part of a range when changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, we could move the hyphen to the front of the pattern (as in [-a-zA-Z... ]) to avoid any such append confusion, but it is a completely standard regex rule, which we use in hundreds of places and you will encounter elsewhere in the code, in logcheck rules, etc. So I think that's really just one of those need to know things.

Copy link
Contributor

@rasmunk rasmunk Jun 13, 2025

Choose a reason for hiding this comment

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

Then I would approve of moving it to the front to avoid the append confusion, because you typically append to the pattern when adding characters. It is a need to know, but often haven to be relearned with time as this PR sort of highlights, so its just to reduce time spent on these

@rasmunk rasmunk self-requested a review June 13, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usernames with hyphen are rejected in sftpsubsys
2 participants