From patchwork Fri Jan 7 14:11:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 463991 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p07ECHT8020473 for ; Fri, 7 Jan 2011 14:12:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753029Ab1AGOLx (ORCPT ); Fri, 7 Jan 2011 09:11:53 -0500 Received: from mail-vw0-f46.google.com ([209.85.212.46]:41933 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753372Ab1AGOLw (ORCPT ); Fri, 7 Jan 2011 09:11:52 -0500 Received: by mail-vw0-f46.google.com with SMTP id 16so7137210vws.19 for ; Fri, 07 Jan 2011 06:11:52 -0800 (PST) Received: by 10.220.192.202 with SMTP id dr10mr5809925vcb.67.1294409512018; Fri, 07 Jan 2011 06:11:52 -0800 (PST) Received: from salusa.poochiereds.net (cpe-071-070-153-003.nc.res.rr.com [71.70.153.3]) by mx.google.com with ESMTPS id e18sm9784812vbm.5.2011.01.07.06.11.51 (version=SSLv3 cipher=RC4-MD5); Fri, 07 Jan 2011 06:11:51 -0800 (PST) From: Jeff Layton To: linux-cifs@vger.kernel.org Cc: niallain@gmail.com Subject: [PATCH 1/5] cifs.upcall: consolidate find_krb5_cc calls Date: Fri, 7 Jan 2011 09:11:41 -0500 Message-Id: <1294409505-2999-2-git-send-email-jlayton@samba.org> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1294409505-2999-1-git-send-email-jlayton@samba.org> References: <1294409505-2999-1-git-send-email-jlayton@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 07 Jan 2011 14:12:18 +0000 (UTC) diff --git a/cifs.upcall.c b/cifs.upcall.c index 34b0638..33b7e4c 100644 --- a/cifs.upcall.c +++ b/cifs.upcall.c @@ -675,6 +675,7 @@ int main(const int argc, char *const argv[]) char hostbuf[NI_MAXHOST], *host; struct decoded_args arg; const char *oid; + uid_t uid; hostbuf[0] = '\0'; memset(&arg, 0, sizeof(arg)); @@ -748,27 +749,24 @@ int main(const int argc, char *const argv[]) goto out; } - if (!legacy_uid && (have & DKD_HAVE_CREDUID)) { - rc = setuid(arg.creduid); - if (rc == -1) { - syslog(LOG_ERR, "setuid: %s", strerror(errno)); - goto out; - } - ccname = find_krb5_cc(CIFS_DEFAULT_KRB5_DIR, arg.creduid); - } else if (have & DKD_HAVE_UID) { - rc = setuid(arg.uid); - if (rc == -1) { - syslog(LOG_ERR, "setuid: %s", strerror(errno)); - goto out; - } - ccname = find_krb5_cc(CIFS_DEFAULT_KRB5_DIR, arg.uid); - } else { + if (!legacy_uid && (have & DKD_HAVE_CREDUID)) + uid = arg.creduid; + else if (have & DKD_HAVE_UID) + uid = arg.uid; + else { /* no uid= or creduid= parm -- something is wrong */ syslog(LOG_ERR, "No uid= or creduid= parm specified"); rc = 1; goto out; } + rc = setuid(uid); + if (rc == -1) { + syslog(LOG_ERR, "setuid: %s", strerror(errno)); + goto out; + } + ccname = find_krb5_cc(CIFS_DEFAULT_KRB5_DIR, uid); + host = arg.hostname; // do mech specific authorization