URL: https://github.com/freeipa/freeipa/pull/726 Author: Akasurde Title: #726: Add check for directory name Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/726/head:pr726 git checkout pr726
From 94545b31ba360141626740fe76f466d3e2a1b43d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde <akasu...@redhat.com> Date: Fri, 21 Apr 2017 10:11:38 +0530 Subject: [PATCH] Add check for directory name 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 <akasu...@redhat.com> --- ipalib/util.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ipalib/util.py b/ipalib/util.py index e9d4105..62f704a 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -170,6 +170,10 @@ def check_writable_file(filename): """ if filename is None: raise errors.FileError(reason=_('Filename is empty')) + + if os.path.isdir(filename): + raise errors.FileError(reason=_('Expected file but {fname} is a ' + 'directory'.format(fname=filename))) try: if os.path.exists(filename): if not os.access(filename, os.W_OK):
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code