Your message dated Sun, 03 Jun 2012 03:36:05 +0000
with message-id <[email protected]>
and subject line Bug#626509: fixed in libpam-krb5 4.6-1
has caused the Debian Bug report #626509,
regarding libpam-krb5: Automatically create FAST armor cache by using anonymous 
user
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
626509: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626509
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libpam-krb5
Version: 4.4-1
Severity: wishlist
Tags: upstream patch


When using FAST a ticket cache should be available beforehand. On some
situations there is no such cache or it is not readable. 

Is it possible to add an option to automatically create this ticket cache by
using the anonymous user? i.e. like calling 'kinit -n' before kinit. The
attached patch suppose to do this by adding anon_fast option, but I'm not sure
if there are any security issues.

Thanks,
    Yair.

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38.4-rt-1 (SMP w/6 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libpam-krb5 depends on:
ii  krb5-config                2.2           Configuration files for Kerberos V
ii  libc6                      2.11.2-11     Embedded GNU C Library: Shared lib
ii  libkrb5-3                  1.9+dfsg-1+b1 MIT Kerberos runtime libraries
ii  libpam-runtime             1.1.2-2       Runtime support for the PAM librar
ii  libpam0g                   1.1.2-2       Pluggable Authentication Modules l

libpam-krb5 recommends no packages.

libpam-krb5 suggests no packages.

-- no debconf information
diff --git a/auth.c b/auth.c
index 0643505..d857356 100644
--- a/auth.c
+++ b/auth.c
@@ -131,34 +131,127 @@ set_fast_options(struct pam_args *args, krb5_get_init_creds_opt *opts)
     krb5_context c = args->ctx->context;
     krb5_error_code k5_errno;
     krb5_principal princ = NULL;
+    krb5_principal princ2 = NULL;
     krb5_ccache fast_ccache = NULL;
+    krb5_creds *fast_creds = NULL;
+    char armor_name[] = "/tmp/krb5cc_pam_armor_XXXXXX";
+    char* fast_cache_name = (char*)&armor_name;
+    int pamret;
+    krb5_get_init_creds_opt *fast_opts = NULL;
 
-    if (!args->fast_ccache)
-        return;
-    k5_errno = krb5_cc_resolve(c, args->fast_ccache, &fast_ccache);
-    if (k5_errno != 0) {
-        pamk5_debug_krb5(args, k5_errno, "failed resolving fast ccache %s",
-                         args->fast_ccache);
-        goto done;
+    /*
+     * If fast_ccache was given, we don't need anonymous.
+     */
+    if (!args->fast_ccache) {
+        if (!args->anon_fast)
+            return;
+
+        fast_creds = calloc(1, sizeof(krb5_creds));
+        if (fast_creds == NULL) {
+            pamk5_err(args, "cannot allocate memory: %s, not using fast",
+                      strerror(errno));
+            goto done;
+        }
+
+        k5_errno = krb5_build_principal_ext(c, &princ,
+                                            strlen(args->realm), args->realm,
+                                            strlen(KRB5_WELLKNOWN_NAMESTR),
+                                            KRB5_WELLKNOWN_NAMESTR,
+                                            strlen(KRB5_ANONYMOUS_PRINCSTR),
+                                            KRB5_ANONYMOUS_PRINCSTR,
+                                            NULL);
+        if (k5_errno != 0) {
+            pamk5_debug_krb5(args, k5_errno,
+                             "cannot create anonymous principal");
+            goto done;
+        }
+
+        k5_errno = krb5_get_init_creds_opt_alloc(c, &fast_opts);
+        if (k5_errno != 0) {
+            pamk5_err_krb5(args, k5_errno,
+                           "cannot allocate memory, not using fast");
+            goto done;
+        }
+        
+        krb5_get_init_creds_opt_set_anonymous(fast_opts, 1);
+        
+        k5_errno = krb5_get_init_creds_password(c, fast_creds, princ, NULL,
+                                                NULL, NULL, 0, NULL,
+                                                fast_opts);
+        if (k5_errno != 0) {
+            pamk5_debug_krb5(args, k5_errno, "failed getting initial "
+                             "credentials for anonymous user");
+            goto done;
+        }
+
+        /*
+         * same as pamk5_cache_init_random, but differnt name and different
+         * environment, and need to swap principals
+         */
+        pamret = pamk5_cache_mkstemp(args, fast_cache_name);
+        if (pamret != PAM_SUCCESS)
+            goto done;
+        
+        /*
+         * write cache file. pamk5_cache_init uses args->ctx->princ to
+         * initialize the cache, so it is temporarily swapped.
+         */
+        princ2 = args->ctx->princ;
+        args->ctx->princ = fast_creds->client;
+        pamret = pamk5_cache_init(args, fast_cache_name, fast_creds,
+                                  &fast_ccache);
+        args->ctx->princ = princ2;
+        if (pamret != PAM_SUCCESS)
+            goto done;
+
+        pamret = pamk5_set_krb5ccname(args, fast_cache_name,
+                                      "PAM_FAST_KRB5CCNAME");
+        if (pamret != PAM_SUCCESS) {
+            pamk5_debug_pam(args, pamret,
+                            "cannot save temporary fast cache name");
+        }
+        
+        
+        krb5_free_principal(c, princ);
+        princ = NULL;
+    } else {
+        fast_cache_name = args->fast_ccache;
+        k5_errno = krb5_cc_resolve(c, fast_cache_name, &fast_ccache);
+        if (k5_errno != 0) {
+            pamk5_debug_krb5(args, k5_errno, "failed resolving fast ccache %s",
+                             fast_cache_name);
+            goto done;
+        }
     }
+    
     k5_errno = krb5_cc_get_principal(c, fast_ccache, &princ);
     if (k5_errno != 0) {
         pamk5_debug_krb5(args, k5_errno,
                          "failed to get principal from fast ccache %s",
-                         args->fast_ccache);
+                         fast_cache_name);
         goto done;
     }
     k5_errno = krb5_get_init_creds_opt_set_fast_ccache_name(c, opts,
-                                                            args->fast_ccache);
+                                                            fast_cache_name);
     if (k5_errno != 0)
         pamk5_err_krb5(args, k5_errno, "failed setting fast ccache to %s",
-                       args->fast_ccache);
+                       fast_cache_name);
 
 done:
-    if (fast_ccache != NULL)
-        krb5_cc_close(c, fast_ccache);
+    if (fast_creds != NULL) {
+        krb5_free_cred_contents(c, fast_creds);
+        free(fast_creds);
+    }
+    if (fast_ccache != NULL) {
+        if (args->anon_fast && k5_errno != 0)
+            krb5_cc_destroy(c, fast_ccache);
+        else
+            krb5_cc_close(c, fast_ccache);
+    }
     if (princ != NULL)
         krb5_free_principal(c, princ);
+    if (fast_opts != NULL)
+        krb5_get_init_creds_opt_free(c, fast_opts);
 }
 #else /* !HAVE_KRB5_GET_INIT_CREDS_OPT_SET_FAST_CCACHE_NAME */
 # define set_fast_options(a, o) /* empty */
@@ -596,6 +689,8 @@ pamk5_password_auth(struct pam_args *args, const char *service,
     int do_only_alt = 0;
     char *pass = NULL;
     int authtok = (service == NULL) ? PAM_AUTHTOK : PAM_OLDAUTHTOK;
+    const char* fast_cache_name;
+    krb5_ccache fast_cache;
 
     /* Sanity check and initialization. */
     if (args->ctx == NULL)
@@ -823,5 +918,30 @@ done:
     }
     if (opts != NULL)
         pamk5_compat_opt_free(ctx->context, opts);
+
+    /*
+     * Whatever the results, destroy the anonymous fast armor cache
+     */
+    if (args->anon_fast) {
+        fast_cache_name = pamk5_get_krb5ccname(args, "PAM_FAST_KRB5CCNAME");
+        if (fast_cache_name != NULL) {
+
+            success = krb5_cc_resolve(ctx->context, fast_cache_name,
+                                      &fast_cache);
+            if (success != 0) {
+                pamk5_debug_krb5(args, success,
+                                 "cannot resolve temporary fast cache %s",
+                                 fast_cache_name);
+            } else {
+
+                krb5_cc_destroy(ctx->context, fast_cache);
+            
+                if (pam_putenv(args->pamh, "PAM_FAST_KRB5CCNAME") !=
+                    PAM_SUCCESS)
+                    pam_putenv(args->pamh, "PAM_FAST_KRB5CCNAME=");
+            }
+        }
+    }
+    
     return retval;
 }
diff --git a/internal.h b/internal.h
index c54c444..b3c2254 100644
--- a/internal.h
+++ b/internal.h
@@ -58,6 +58,7 @@ struct context {
  * functions.
  */
 struct pam_args {
+    int anon_fast;              /* sets up an anonymous fast armor cache */
     char *banner;               /* Addition to password changing prompts. */
     char *ccache;               /* Path to write ticket cache to. */
     char *ccache_dir;           /* Directory for ticket cache. */
diff --git a/options.c b/options.c
index 9aabf4a..52fb807 100644
--- a/options.c
+++ b/options.c
@@ -291,6 +291,7 @@ pamk5_args_parse(pam_handle_t *pamh, int flags, int argc, const char **argv)
             krb5_get_default_realm(c, &args->realm);
         if (args->realm != NULL)
             pamk5_compat_set_realm(args, args->realm);
+        default_boolean(args, c, "anon_fast", 0, &args->anon_fast);
         default_string(args, c, "alt_auth_map", NULL, &args->alt_auth_map);
         default_string(args, c, "banner", "Kerberos", &args->banner);
         default_string(args, c, "ccache", NULL, &args->ccache);
@@ -337,6 +338,8 @@ pamk5_args_parse(pam_handle_t *pamh, int flags, int argc, const char **argv)
      * sense in krb5.conf.
      */
     for (i = 0; i < argc; i++) {
+        if (strcmp(argv[i], "anon_fast") == 0)
+            args->anon_fast = 1;
         if (strncmp(argv[i], "alt_auth_map=", 12) == 0) {
             if (args->alt_auth_map != NULL)
                 free(args->alt_auth_map);
@@ -505,9 +508,9 @@ pamk5_args_parse(pam_handle_t *pamh, int flags, int argc, const char **argv)
 
     /* Warn if the FAST option was set and FAST isn't supported. */
 #ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_FAST_CCACHE_NAME
-    if (args->fast_ccache)
-        pamk5_err(args, "fast_ccache requested but FAST not supported by"
-                  " Kerberos libraries");
+    if (args->fast_ccache || args->anon_fast)
+        pamk5_err(args, "fast_ccache or anon_fast requested but FAST not"
+                  " supported by Kerberos libraries");
 #endif
 
     return args;
diff --git a/pam_krb5.pod b/pam_krb5.pod
index 8cc1a93..a4597f4 100644
--- a/pam_krb5.pod
+++ b/pam_krb5.pod
@@ -313,6 +313,15 @@ group.
 
 =over 4
 
+=item anon_fast
+
+Attempt to use Flexible Authentication Secure Tunneling (FAST) by first
+authenticating as the anonymous user (WELLKNOWN/ANONYMOUS) and using its
+credentials as the FAST armor. The operation is the same as if using the
+I<fast_ccache> option, but the cache is created and destroyed automatically. If
+both I<fast_ccache> and I<anon_fast> options are used, the I<fast_ccache> takes
+precedent and no anonymous authentication is done.
+
 =item fast_ccache=<ccache_name>
 
 Attempt to use Flexible Authenticatin Secure Tunneling (FAST) to protect

--- End Message ---
--- Begin Message ---
Source: libpam-krb5
Source-Version: 4.6-1

We believe that the bug you reported is fixed in the latest version of
libpam-krb5, which is due to be installed in the Debian FTP archive:

libpam-heimdal_4.6-1_i386.deb
  to main/libp/libpam-krb5/libpam-heimdal_4.6-1_i386.deb
libpam-krb5_4.6-1.debian.tar.xz
  to main/libp/libpam-krb5/libpam-krb5_4.6-1.debian.tar.xz
libpam-krb5_4.6-1.dsc
  to main/libp/libpam-krb5/libpam-krb5_4.6-1.dsc
libpam-krb5_4.6-1_i386.deb
  to main/libp/libpam-krb5/libpam-krb5_4.6-1_i386.deb
libpam-krb5_4.6.orig.tar.xz
  to main/libp/libpam-krb5/libpam-krb5_4.6.orig.tar.xz



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Russ Allbery <[email protected]> (supplier of updated libpam-krb5 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Sat, 02 Jun 2012 19:20:27 -0700
Source: libpam-krb5
Binary: libpam-krb5 libpam-heimdal
Architecture: source i386
Version: 4.6-1
Distribution: unstable
Urgency: low
Maintainer: Russ Allbery <[email protected]>
Changed-By: Russ Allbery <[email protected]>
Description: 
 libpam-heimdal - PAM module for Heimdal Kerberos
 libpam-krb5 - PAM module for MIT Kerberos
Closes: 626506 626509
Changes: 
 libpam-krb5 (4.6-1) unstable; urgency=low
 .
   * New upstream release.
     - New anon_fast option to attempt anonymous authentication and use
       those credentials to provide FAST armor.  (Closes: #626509)
     - New user_realm option to set the realm for unqualified user
       principals without changing the default realm for all other
       operations.
     - New no_prompt option to suppress PAM prompting in favor of letting
       the Kerberos library handle it.  (Closes: #626506)
     - New silent option that duplicates the behavior of PAM_SILENT.
     - New trace option for preliminary support of Kerberos trace logging.
     - Fix the doubled colon in password prompts from Heimdal.
     - Preserve the realm of the authentication identity when forming an
       alt_auth_map identity.
     - Allow the alt_auth_map format to contain a realm to force all mapped
       principals to be in that realm.
     - Avoid a NULL pointer dereference if krb5_init_context fails.
       (LP: #998525)
     - Close memory leaks in search_k5login and alt_auth_map.
     - Suppress bogus error messages about the realm option.
     - Retry authentication under try_first_pass for several other error
       conditions.
   * Regenerate the Autotools build system with dh-autoreconf.
   * Add krb5-config to Build-Depends so that the test programs don't abort
     with errors about not having a Kerberos configuration.
   * Switch to xz compression for the upstream and Debian tarballs.
   * Enable parallel builds.
   * Update standards version to 3.9.3 (no changes required).
Checksums-Sha1: 
 d7e4075f7d67b1ef90f4a7801961d77a83276680 1709 libpam-krb5_4.6-1.dsc
 25bf04e8a4aeafa35eaa9791e7d0c2fc792f9551 365272 libpam-krb5_4.6.orig.tar.xz
 069dbdaf64b81f700a853d08eccd10b23f3794cc 17856 libpam-krb5_4.6-1.debian.tar.xz
 c7d97a2077f815aef7ed7520c3345c4afe123cf1 89780 libpam-krb5_4.6-1_i386.deb
 87bf02de66184f3f307598e45beceb9571697652 86696 libpam-heimdal_4.6-1_i386.deb
Checksums-Sha256: 
 fc2c69b68cd85a702f4f130111ebf93fc250dcb5fba539f09ed81092aaac1b34 1709 
libpam-krb5_4.6-1.dsc
 2f6f8a664ce0cedc0419894b4f98668e87fe4d01c7c882019e242a3f993881a7 365272 
libpam-krb5_4.6.orig.tar.xz
 5af83be9a09a6ca18e17d1aa615d2b018dea8618d5b33f6d4180ef899994af7f 17856 
libpam-krb5_4.6-1.debian.tar.xz
 5075f13a4b5886d6ad68f45fdc1ae57eea7dcc3e258499504922bbb381b1f34d 89780 
libpam-krb5_4.6-1_i386.deb
 481040e8c13fee55af855b39a0e7b86b49001112ac0cd24d600233610f9f4463 86696 
libpam-heimdal_4.6-1_i386.deb
Files: 
 0a4055290c7ae7eb86d076e21365f251 1709 admin optional libpam-krb5_4.6-1.dsc
 9c24d6b5c7205bd6d3224f0ee821e45a 365272 admin optional 
libpam-krb5_4.6.orig.tar.xz
 f58cc0577474f766bb518d20bce627dc 17856 admin optional 
libpam-krb5_4.6-1.debian.tar.xz
 bd86f122a06dff2e82607e5c5100b793 89780 admin optional 
libpam-krb5_4.6-1_i386.deb
 8784ddeaf8e3f4a3e17950fea3d737f8 86696 admin extra 
libpam-heimdal_4.6-1_i386.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBCAAGBQJPysyzAAoJEH2AMVxXNt516XAIAK19HGEbGMq+IIaszK2xz2nC
KKBJxnHm7oOHcSbbDrna6WrWp0Y/zHRQN/Ef+cCCTNWCMzmrBl2LtoZsB4Ucjydm
whpFD82a36ftqsfavkll+OdfTeCOC17C5+trGWMSEs0r3zxJ3sJGVcLcCGpeoHre
kR1OfbjRiezBc9F/dn7yKBJ3wGRyp8mty6is2EKrUVoSUPprcWnyJkyM0R5H/ADq
4rrrd7EGZVhQkdgGDdW9QupXM/CF5z7RP0pEkUwN1kiZP/mVpx3LodI6BznV1mVO
v+UTFLCVGbLC2tbEP9KC8PzNH4hNCcbz9RCmeOaiqePVPNsGdjJ3/m3aLjk0+1A=
=zwUg
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to