]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
In ksu, handle typeless default_ccache_name values
authorNalin Dahyabhai <nalin@redhat.com>
Mon, 8 Sep 2014 17:15:40 +0000 (13:15 -0400)
committerGreg Hudson <ghudson@mit.edu>
Mon, 8 Sep 2014 18:50:36 +0000 (14:50 -0400)
When a configured or compiled-in default ccache name doesn't contain a
cache type and ':' as a prefix, add one to the writeable value that we
construct when we go to look it up.  This lets the rest of the
application always assume that it'll be there.

[ghudson@mit.edu: minor style changes]

ticket: 8007 (new)
target_version: 1.13
tags: pullup

src/clients/ksu/main.c

index 47fa8203e24d3f513bf184e6b41f03e39e4ef10a..622c36af4a2b8bbdd8f548aa6375d4984ca41859 100644 (file)
@@ -819,7 +819,7 @@ get_configured_defccname(krb5_context context, char **target_out)
 {
     krb5_error_code retval;
     const char *defname;
-    char *target;
+    char *target = NULL;
 
     *target_out = NULL;
 
@@ -838,7 +838,14 @@ get_configured_defccname(krb5_context context, char **target_out)
     }
 
     defname = krb5_cc_default_name(context);
-    target = (defname == NULL) ? NULL : strdup(defname);
+    if (defname != NULL) {
+        if (strchr(defname, ':') != NULL) {
+            target = strdup(defname);
+        } else {
+            if (asprintf(&target, "FILE:%s", defname) < 0)
+                target = NULL;
+        }
+    }
     if (target == NULL) {
         com_err(prog_name, ENOMEM, _("while determining target ccache name"));
         return ENOMEM;