From patchwork Wed Sep 23 14:30:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 7250161 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69390BEEC1 for ; Wed, 23 Sep 2015 14:31:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0284F205E6 for ; Wed, 23 Sep 2015 14:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D3AC205E9 for ; Wed, 23 Sep 2015 14:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755089AbbIWOa7 (ORCPT ); Wed, 23 Sep 2015 10:30:59 -0400 Received: from mx144.netapp.com ([216.240.21.25]:25245 "EHLO mx144.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755233AbbIWOa6 (ORCPT ); Wed, 23 Sep 2015 10:30:58 -0400 X-IronPort-AV: E=Sophos;i="5.17,577,1437462000"; d="scan'208";a="69743194" Received: from vmwexchts03-prd.hq.netapp.com ([10.122.105.31]) by mx144-out.netapp.com with ESMTP; 23 Sep 2015 07:30:54 -0700 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS03-PRD.hq.netapp.com (10.122.105.31) with Microsoft SMTP Server id 15.0.1104.5; Wed, 23 Sep 2015 07:30:54 -0700 Received: from andros-new.local.com (andros-new.vpn.netapp.com [10.55.68.57]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id t8NEUn3e019071; Wed, 23 Sep 2015 07:30:53 -0700 (PDT) From: To: CC: , , Andy Adamson Subject: [PATCH Version 2 4/4] GSSD: clean up machine credentials Date: Wed, 23 Sep 2015 10:30:16 -0400 Message-ID: <1443018616-1335-5-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.9.3 (Apple Git-50) In-Reply-To: <1443018616-1335-1-git-send-email-andros@netapp.com> References: <1443018616-1335-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson Since we no longer fork for uid 0, gssd_atexit() is only called when uid != 0, and fails as permissions on the /tmp/krb5ccmachine_REALM file prohibit the clean up of machine credentials (as it should). Move the reaping of machine credentials back into a SIGINT sighandler so that destroyes machine credentials. Signed-off-by: Andy Adamson --- utils/gssd/gssd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c index 2a768ea..e480349 100644 --- a/utils/gssd/gssd.c +++ b/utils/gssd/gssd.c @@ -729,10 +729,12 @@ found: } static void -gssd_atexit(void) +sig_die(int signal) { if (root_uses_machine_creds) gssd_destroy_krb5_machine_creds(); + printerr(1, "exiting on signal %d\n", signal); + exit(0); } static void @@ -892,17 +894,14 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (atexit(gssd_atexit)) { - printerr(1, "ERROR: atexit failed: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - inotify_fd = inotify_init1(IN_NONBLOCK); if (inotify_fd == -1) { printerr(1, "ERROR: inotify_init1 failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } + signal(SIGINT, sig_die); + signal(SIGTERM, sig_die); signal_set(&sighup_ev, SIGHUP, gssd_scan_cb, NULL); signal_add(&sighup_ev, NULL); event_set(&inotify_ev, inotify_fd, EV_READ | EV_PERSIST, gssd_inotify_cb, NULL);