Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2761004rdb; Wed, 4 Oct 2023 10:33:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZPHwpSbw9a7z+zMhRUW42ngzj7fnAwMxhFcEiJlnxmyF7fZMnKPQ5hX59wvhB9ZtBdZYA X-Received: by 2002:a17:902:f802:b0:1c7:47f4:7c86 with SMTP id ix2-20020a170902f80200b001c747f47c86mr343058plb.15.1696440780101; Wed, 04 Oct 2023 10:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696440780; cv=none; d=google.com; s=arc-20160816; b=WjNlU/VFGESNvcUYEStKnJEJFjy7XNRiQ2g5xwvcGvXkz+Vu0I/iS0dRmzcAIGD3AL UsjdTh+aZQnUknkEGblOl15jUIBGTJ+uMUqHlU8kzqcpgsW0A1PbsMIEwz9Yt9mbiCHO YCzbJFCicEsbObKo08TZBtLFd5hM3qUKbmM7KqWCirfpWoFR+zNPe1GrLPzT7dPPc3c/ q8KT33fdN0P8OyHT2AVFqdQP0zxpqQOzjStPrqcMqlfxkcXesWeMn9QiLfZqGQYSkqbm xfA18S8j//3I9YW92/N6AE7lTQzJt7bAdSRemqgVNCc0//sceWE+wUBW2X/lP/vVrVGv LGAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2vtD2wllK/RrJHf1gxhgLPe7cHGISOLeuFKmzdk1jsI=; fh=uNRrSD0XciptfTJwyKJ3Qz1AkNjyaoXT9yPd2pM8S/o=; b=UtyYtwYtoEPZHxL8chnJpqUCpTU1qSOnS3ECIA0wGwBDVCRytqKfPBZjo6TqLgtMDm nSJ+NEcyZUdoMvhbQSTpfqxIIIV+UVb+ice7mAUYLFnnKLSIbEgi4bl1JMmsMhN/n5oe egY5lHOry6jr9TiKBdKSLjwO7UjpRnVWX7JB8y4vYECqAnaMx44vIhXCht1samyGD8TR 3B1Hho4tAWhHuuQt/zQXEY53Gflxt2Mnjxe98jxda0Nyo3FQDwwbTUDkJyOuQseO1YRm RW+j68ebRPA9SnyaslNCZnpO8mSm198NkWU3EhkHE7QX0M9TSPfQJ0qY641Z2E+G+BhO MS3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GPOeQARu; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id o11-20020a170903210b00b001b9736814b6si3669778ple.309.2023.10.04.10.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 10:33:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GPOeQARu; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 52A9E804A606; Wed, 4 Oct 2023 10:32:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243438AbjJDRcv (ORCPT + 99 others); Wed, 4 Oct 2023 13:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243498AbjJDRcu (ORCPT ); Wed, 4 Oct 2023 13:32:50 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2950A9 for ; Wed, 4 Oct 2023 10:32:45 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-35264dff796so136885ab.0 for ; Wed, 04 Oct 2023 10:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696440765; x=1697045565; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2vtD2wllK/RrJHf1gxhgLPe7cHGISOLeuFKmzdk1jsI=; b=GPOeQARu/5CgaEuCHDGme+X9MN0xXwusofyUjupHdbvIZXf2oUVGVaA7hzCLK5AtVx sdzb7PAN6qeWtgH+8ds5cHxBsvdtJDjSRP5+cPIyPpu6Xo3VofFHHS4raJlj9kziCeLr G2e8qRTcD2X5FeLziRXfpO7FjIGZqWpTyV4p392HHQFlRA6cxOrV5oQtYI3f7jwPqp/b AEP3HCbk1rCtPrbut5NjO0ZbGgTFJjP7QaxzgdIkFNILix8zK7A5m0JBnclng0mtFHZm Hig5xV/WiGfEl8kZKWQjZmODPSLFgGM9SqNA84yW4AYB34pIyM6yzgTf+PVGNWGZdaXl HpWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696440765; x=1697045565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2vtD2wllK/RrJHf1gxhgLPe7cHGISOLeuFKmzdk1jsI=; b=beyXW70flMRLdEkypaEJ0HLcXwWUzy4WerCsdxQ+Of3zzyjK45K0agXWWD0cY5/s5E Pc+t9f/tzXPa+iMfLMeBMmHfEhphkrFXnRGAn53/RroHld39wPk4HcMRIQwoxg28gxtn sidqVL/4YbrnPbxkky4rsARTzFIx0IYpQsYdNxtJ1v/a0FBfl48IshlfFk95GiVOjHrn iIIYUaahFdAKX1LCyrboDCK61KM5U1HNw20RF1bVLWSE7En9ZPSuZje9Q2sGIFF7Arut 0DYUGuRpLemG2XN/AtXqHigCeZ6a4Ab7mBITUAvTjZipdrEROa4i/eeYgXx4sRbo4o2n KGxA== X-Gm-Message-State: AOJu0YyKurBmK4jBUrynijiwLf81UvuvU+Uhh18I4bK0MyziQt9oZ3Q8 /WeZa5qShMulVMyCfcfSd2LhRu1dZrI= X-Received: by 2002:a05:6602:2e03:b0:792:6068:dcc8 with SMTP id o3-20020a0566022e0300b007926068dcc8mr3851138iow.2.1696440764919; Wed, 04 Oct 2023 10:32:44 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:d99c:94dd:ccd6:fb22]) by smtp.gmail.com with ESMTPSA id u23-20020a6be417000000b007870289f4fdsm1066598iog.51.2023.10.04.10.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 10:32:44 -0700 (PDT) From: Olga Kornievskaia To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] nfs-utils: gssd: enable forcing cred renewal using the keytab Date: Wed, 4 Oct 2023 13:32:37 -0400 Message-Id: <20231004173240.46924-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20231004173240.46924-1-olga.kornievskaia@gmail.com> References: <20231004173240.46924-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 04 Oct 2023 10:32:55 -0700 (PDT) From: Olga Kornievskaia Add a new function parameter "force_renewal" that callers could set to force service ticket renewal even if one exists already. This is needed in preparation for handling KRB5_AP_ERR_BAD_INTEGRITY when service's keytab changes while the client holds valid service ticket in the cache. Signed-off-by: Olga Kornievskaia --- utils/gssd/gssd_proc.c | 2 +- utils/gssd/krb5_util.c | 20 ++++++++++++-------- utils/gssd/krb5_util.h | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index ae568f15..4fb6b72d 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -571,7 +571,7 @@ krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, do { gssd_refresh_krb5_machine_credential(clp->servername, - service, srchost); + service, srchost, 0); /* * Get a list of credential cache names and try each * of them until one works or we've tried them all diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c index e3f270e9..f6ce1fec 100644 --- a/utils/gssd/krb5_util.c +++ b/utils/gssd/krb5_util.c @@ -165,7 +165,7 @@ static int select_krb5_ccache(const struct dirent *d); static int gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, const char **cctype, struct dirent **d); static int gssd_get_single_krb5_cred(krb5_context context, - krb5_keytab kt, struct gssd_k5_kt_princ *ple); + krb5_keytab kt, struct gssd_k5_kt_princ *ple, int force_renew); static int query_krb5_ccache(const char* cred_cache, char **ret_princname, char **ret_realm); @@ -391,7 +391,8 @@ gssd_check_if_cc_exists(struct gssd_k5_kt_princ *ple) static int gssd_get_single_krb5_cred(krb5_context context, krb5_keytab kt, - struct gssd_k5_kt_princ *ple) + struct gssd_k5_kt_princ *ple, + int force_renew) { #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS krb5_get_init_creds_opt *init_opts = NULL; @@ -421,7 +422,7 @@ gssd_get_single_krb5_cred(krb5_context context, */ now += 300; pthread_mutex_lock(&ple_lock); - if (ple->ccname && ple->endtime > now && !nocache) { + if (ple->ccname && ple->endtime > now && !nocache && !force_renew) { printerr(3, "%s(0x%lx): Credentials in CC '%s' are good until %s", __func__, tid, ple->ccname, ctime((time_t *)&ple->endtime)); code = 0; @@ -1155,7 +1156,8 @@ err_cache: static int gssd_refresh_krb5_machine_credential_internal(char *hostname, struct gssd_k5_kt_princ *ple, - char *service, char *srchost) + char *service, char *srchost, + int force_renew) { krb5_error_code code = 0; krb5_context context; @@ -1221,7 +1223,7 @@ gssd_refresh_krb5_machine_credential_internal(char *hostname, goto out_free_kt; } } - retval = gssd_get_single_krb5_cred(context, kt, ple); + retval = gssd_get_single_krb5_cred(context, kt, ple, force_renew); out_free_kt: krb5_kt_close(context, kt); out_free_context: @@ -1344,7 +1346,7 @@ gssd_get_krb5_machine_cred_list(char ***list) pthread_mutex_unlock(&ple_lock); /* Make sure cred is up-to-date before returning it */ retval = gssd_refresh_krb5_machine_credential_internal(NULL, ple, - NULL, NULL); + NULL, NULL, 0); pthread_mutex_lock(&ple_lock); if (gssd_k5_kt_princ_list == NULL) { /* Looks like we did shutdown... abort */ @@ -1456,10 +1458,12 @@ gssd_destroy_krb5_principals(int destroy_machine_creds) */ int gssd_refresh_krb5_machine_credential(char *hostname, - char *service, char *srchost) + char *service, char *srchost, + int force_renew) { return gssd_refresh_krb5_machine_credential_internal(hostname, NULL, - service, srchost); + service, srchost, + force_renew); } /* diff --git a/utils/gssd/krb5_util.h b/utils/gssd/krb5_util.h index 2415205a..62c91a0e 100644 --- a/utils/gssd/krb5_util.h +++ b/utils/gssd/krb5_util.h @@ -16,7 +16,8 @@ int gssd_get_krb5_machine_cred_list(char ***list); void gssd_free_krb5_machine_cred_list(char **list); void gssd_destroy_krb5_principals(int destroy_machine_creds); int gssd_refresh_krb5_machine_credential(char *hostname, - char *service, char *srchost); + char *service, char *srchost, + int force_renew); char *gssd_k5_err_msg(krb5_context context, krb5_error_code code); void gssd_k5_get_default_realm(char **def_realm); -- 2.39.1