From patchwork Mon Jun 3 01:00:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 2650411 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id EA0003FD4E for ; Mon, 3 Jun 2013 01:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755343Ab3FCBBF (ORCPT ); Sun, 2 Jun 2013 21:01:05 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36002 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755253Ab3FCBBE (ORCPT ); Sun, 2 Jun 2013 21:01:04 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8A3B0A51BB; Mon, 3 Jun 2013 03:01:03 +0200 (CEST) From: Neil Brown To: Steve Dickson Date: Mon, 03 Jun 2013 11:00:22 +1000 Subject: [PATCH 2/3] krb5_util: don't give up on machine credential if hostname not available. Cc: linux-nfs@vger.kernel.org, Chuck Lever Message-ID: <20130603010021.20080.11239.stgit@notabene.brown> In-Reply-To: <20130603005219.20080.1927.stgit@notabene.brown> References: <20130603005219.20080.1927.stgit@notabene.brown> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org krb5_util tries various different credential names in order to find the machine credential, not all of them use the full host name of the current host. So if getting the full host name fails, don't give up completely, still try the other options. Signed-off-by: NeilBrown --- utils/gssd/krb5_util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c index 9ef80f0..5e84481 100644 --- a/utils/gssd/krb5_util.c +++ b/utils/gssd/krb5_util.c @@ -825,8 +825,10 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname, myhostad[i+1] = 0; retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname)); - if (retval) - goto out; + if (retval) { + /* Don't use myhostname */ + myhostname[0] = 0; + } code = krb5_get_default_realm(context, &default_realm); if (code) { @@ -883,6 +885,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname, myhostad, NULL); } else { + if (!myhostname[0]) + continue; snprintf(spn, sizeof(spn), "%s/%s@%s", svcnames[j], myhostname, realm); code = krb5_build_principal_ext(context, &princ,