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
Add check for directory name #726
Conversation
ipalib/util.py
Outdated
|
||
if os.path.isdir(filename): | ||
raise errors.FileError(reason=_('Directory name found instead of ' | ||
'Filename')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error does not say much and has F
in "filename" uppercased for some reason, could you rather go with something like "Expected file but {fname} is a directory".format(fname=filename)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must be %(fname)s
translation strings doesn't support format (in versions we need at least)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep forgetting that, thank you.
ipalib/util.py
Outdated
|
||
if os.path.isdir(filename): | ||
raise errors.FileError(reason=_('Expected file but {fname} is a ' | ||
'directory'.format(fname=filename)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing a parentheses.
What about other types that might cause trouble, e.g. socket, fifo, device files, dangling symlinks? |
@tiran Do you think we should allow only files here ? |
Fix adds check to verify if user provided input is not a directory when filename is required. Fixes: https://pagure.io/freeipa/issue/6883 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Obviously we can't push this until the tests pass. |
Fix adds check to verify if user provided input is not
a directory when filename is required.
Fixes: https://pagure.io/freeipa/issue/6883
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com