diff mbox

[1/5] cifs.upcall: consolidate find_krb5_cc calls

Message ID 1294409505-2999-2-git-send-email-jlayton@samba.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Jan. 7, 2011, 2:11 p.m. UTC
None
diff mbox

Patch

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