]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/cert.c
Merge changes from CUPS 1.4svn-r7696.
[thirdparty/cups.git] / scheduler / cert.c
index 8a0d7a16164552abdf190203037e8514deb2283b..650363401d42302f897c118912426a819a5f523c 100644 (file)
@@ -1,26 +1,17 @@
 /*
- * "$Id: cert.c 5381 2006-04-07 14:39:46Z mike $"
+ * "$Id: cert.c 7673 2008-06-18 22:31:26Z mike $"
  *
  *   Authentication certificate routines for the Common UNIX
  *   Printing System (CUPS).
  *
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * Contents:
  *
@@ -51,7 +42,8 @@
 
 void
 cupsdAddCert(int        pid,           /* I - Process ID */
-             const char *username)     /* I - Username */
+             const char *username,     /* I - Username */
+             void       *ccache)       /* I - Kerberos credentials or NULL */
 {
   int          i;                      /* Looping var */
   cupsd_cert_t *cert;                  /* Current certificate */
@@ -252,6 +244,16 @@ cupsdAddCert(int        pid,               /* I - Process ID */
   write(fd, cert->certificate, strlen(cert->certificate));
   close(fd);
 
+ /*
+  * Add Kerberos credentials as needed...
+  */
+
+#ifdef HAVE_GSSAPI
+  cert->ccache = (krb5_ccache)ccache;
+#else
+  (void)ccache;
+#endif /* HAVE_GSSAPI */
+
  /*
   * Insert the certificate at the front of the list...
   */
@@ -291,6 +293,15 @@ cupsdDeleteCert(int pid)           /* I - Process ID */
       else
         prev->next = cert->next;
 
+#ifdef HAVE_GSSAPI
+     /*
+      * Release Kerberos credentials as needed...
+      */
+
+      if (cert->ccache)
+       krb5_cc_destroy(KerberosContext, cert->ccache);
+#endif /* HAVE_GSSAPI */
+
       free(cert);
 
      /*
@@ -300,7 +311,7 @@ cupsdDeleteCert(int pid)            /* I - Process ID */
       snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, pid);
       if (unlink(filename))
        cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "cupsdDeleteCert: Unable to remove %s!\n", filename);
+                       "cupsdDeleteCert: Unable to remove %s!", filename);
 
       return;
     }
@@ -332,7 +343,7 @@ cupsdDeleteAllCerts(void)
     snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, cert->pid);
     if (unlink(filename))
       cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "cupsdDeleteAllCerts: Unable to remove %s!\n", filename);
+                      "cupsdDeleteAllCerts: Unable to remove %s!", filename);
 
    /*
     * Free memory...
@@ -351,7 +362,7 @@ cupsdDeleteAllCerts(void)
  * 'cupsdFindCert()' - Find a certificate.
  */
 
-const char *                           /* O - Matching username or NULL */
+cupsd_cert_t *                         /* O - Matching certificate or NULL */
 cupsdFindCert(const char *certificate) /* I - Certificate */
 {
   cupsd_cert_t *cert;                  /* Current certificate */
@@ -362,7 +373,7 @@ cupsdFindCert(const char *certificate)      /* I - Certificate */
     if (!strcasecmp(certificate, cert->certificate))
     {
       DEBUG_printf(("    returning %s...\n", cert->username));
-      return (cert->username);
+      return (cert);
     }
 
   DEBUG_puts("    certificate not found!");
@@ -421,10 +432,10 @@ cupsdInitCerts(void)
   */
 
   if (!RunUser)
-    cupsdAddCert(0, "root");
+    cupsdAddCert(0, "root", NULL);
 }
 
 
 /*
- * End of "$Id: cert.c 5381 2006-04-07 14:39:46Z mike $".
+ * End of "$Id: cert.c 7673 2008-06-18 22:31:26Z mike $".
  */