[SSSD] [PATCH] Return right directory name for dircache

Lukas Slebodnik lslebodn at redhat.com
Wed Jul 10 17:15:01 UTC 2013


On (10/07/13 18:13), Jakub Hrozek wrote:
>On Fri, Jun 28, 2013 at 05:07:29PM +0200, Lukas Slebodnik wrote:
>> ehlo,
>> 
>> Dircache can be either file or directory. Wrong value was used
>> when dircache was itself directory.
>> 
>> https://fedorahosted.org/sssd/ticket/2002
>> 
>> Patch is attached.
>> 
>> LS
>This would work but maybe it would be easier to just take a look if
>the ccache starts with "DIR:" or "DIR::" and avoid the stat..

lstat is called inside the function cc_residual_is_used, so we can safely avoid
this.

Updated patch attached.

LS
-------------- next part --------------
>From cb62cfb023f90da9bf53bfcd0243245e7ce6acef Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Fri, 28 Jun 2013 16:06:38 +0200
Subject: [PATCH] Return right directory name for dircache

Dircache can be either file or directory. Wrong value was used
when dircache was itself directory.

https://fedorahosted.org/sssd/ticket/2002
---
 src/providers/krb5/krb5_utils.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c
index 4811a736ce9bfcb772d0d8abd44eed05b214463a..860c71b00d8364b80d8fef3ae953631bb46bb572 100644
--- a/src/providers/krb5/krb5_utils.c
+++ b/src/providers/krb5/krb5_utils.c
@@ -1046,12 +1046,16 @@ cc_dir_check_existing(const char *location, uid_t uid,
         goto done;
     }
 
-    dir = dirname(tmp);
-    if (!dir) {
-        DEBUG(SSSDBG_CRIT_FAILURE,
-              ("Cannot base get directory of %s\n", location));
-        ret = EINVAL;
-        goto done;
+    if (0 == strncmp(location, "DIR::", 5)) {
+        dir = dirname(tmp);
+        if (!dir) {
+            DEBUG(SSSDBG_CRIT_FAILURE,
+                  ("Cannot get base directory of %s.\n", tmp));
+            ret = EINVAL;
+            goto done;
+        }
+    } else {
+        dir = tmp;
     }
 
     ret = cc_residual_is_used(uid, dir, SSS_KRB5_TYPE_DIR, &active);
-- 
1.8.3.1



More information about the sssd-devel mailing list