]> eyrie.org Git - kerberos/kstart.git/commitdiff
Fix another place where a temporary cache wasn't removed
authorRuss Allbery <eagle@eyrie.org>
Thu, 3 Jul 2014 17:59:06 +0000 (10:59 -0700)
committerRuss Allbery <eagle@eyrie.org>
Thu, 3 Jul 2014 17:59:06 +0000 (10:59 -0700)
If fchmod of the temporary ticket cache failed, the file wasn't
deleted.  Add in code to do that.

k5start.c

index ac9792069aa74f5e2cfb0980d5f162eb07f5b0e1..19453935d6d0f92788d7a096b0244fb971aa6713 100644 (file)
--- a/k5start.c
+++ b/k5start.c
@@ -12,7 +12,7 @@
  * Originally written by Robert Morgan and Booker C. Bense.
  * Substantial updates by Russ Allbery <eagle@eyrie.org>
  * Copyright 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007,
- *     2008, 2009, 2010, 2011, 2012
+ *     2008, 2009, 2010, 2011, 2012, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * See LICENSE for licensing terms.
@@ -167,6 +167,7 @@ authenticate(krb5_context ctx, struct config *config,
     krb5_creds creds;
     const char *cache = config->cache;
     krb5_ccache ccache = NULL;
+    int oerrno;
 
     /*
      * If we have owner, group, or mode information, we have to create a
@@ -186,7 +187,9 @@ authenticate(krb5_context ctx, struct config *config,
         }
         if (fchmod(fd, 0600) < 0) {
             syswarn("cannot chmod temporary ticket cache file");
-            return errno;
+            oerrno = errno;
+            unlink(tmp);
+            return oerrno;
         }
         close(fd);
         cache = tmp;