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 dfe0c85ae908b4afbbd014cbf8bcf4e9b81c066d 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..f0d9401 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 not os.path.isfile(filename):
+        raise errors.FileError(reason=_('Expected file but %(fname)s is not a '
+                                        'regular file' % dict(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

Reply via email to