From patchwork Fri Aug 7 19:43:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 30967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by bilbo.ozlabs.org (Postfix) with ESMTP id D66EEB7B3E for ; Sat, 8 Aug 2009 05:43:32 +1000 (EST) Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id B3C26AD0B2; Fri, 7 Aug 2009 13:39:12 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=3.8 tests=AWL, BAYES_00, NO_MORE_FUNN, SPF_PASS autolearn=no version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.121]) by lists.samba.org (Postfix) with ESMTP id C8AA9AD03A; Fri, 7 Aug 2009 13:39:01 -0600 (MDT) Received: from mail.poochiereds.net ([71.70.153.3]) by cdptpa-omta02.mail.rr.com with ESMTP id <20090807194318092.MEQX22035@cdptpa-omta02.mail.rr.com>; Fri, 7 Aug 2009 19:43:18 +0000 Received: by mail.poochiereds.net (Postfix, from userid 4447) id AFB4F5813F; Fri, 7 Aug 2009 15:43:17 -0400 (EDT) From: Jeff Layton To: linux-cifs-client@lists.samba.org, samba-technical@lists.samba.org Date: Fri, 7 Aug 2009 15:43:12 -0400 Message-Id: <1249674197-1065-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1249674197-1065-1-git-send-email-jlayton@redhat.com> References: <1249674197-1065-1-git-send-email-jlayton@redhat.com> Subject: [linux-cifs-client] [PATCH 2/7] cifs.upcall: formatting cleanup X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org Clean up some unneeded curly braces, and fix some indentation. Signed-off-by: Jeff Layton --- client/cifs.upcall.c | 84 ++++++++++++++++++++++---------------------------- 1 files changed, 37 insertions(+), 47 deletions(-) diff --git a/client/cifs.upcall.c b/client/cifs.upcall.c index da6b1b8..926ec20 100644 --- a/client/cifs.upcall.c +++ b/client/cifs.upcall.c @@ -113,7 +113,7 @@ get_krb5_ccname(pid_t pid) * sess_key- pointer for SessionKey data to be stored * * ret: 0 - success, others - failure -*/ + */ static int handle_krb5_mech(const char *oid, const char *principal, DATA_BLOB *secblob, DATA_BLOB *sess_key, const char *ccname) @@ -169,11 +169,11 @@ decode_key_description(const char *desc, int *ver, secType_t *sec, if (strncmp(tkn, "host=", 5) == 0) { int len; - if (pos == NULL) { + if (pos == NULL) len = strlen(tkn); - } else { + else len = pos - tkn; - } + len -= 4; SAFE_FREE(*hostname); *hostname = SMB_XMALLOC_ARRAY(char, len); @@ -257,11 +257,11 @@ cifs_resolver(const key_serial_t key, const char *key_descr) } /* conver ip to string form */ - if (addr->ai_family == AF_INET) { + if (addr->ai_family == AF_INET) p = &(((struct sockaddr_in *)addr->ai_addr)->sin_addr); - } else { + else p = &(((struct sockaddr_in6 *)addr->ai_addr)->sin6_addr); - } + if (!inet_ntop(addr->ai_family, p, ip, sizeof(ip))) { syslog(LOG_ERR, "%s: inet_ntop: %s", __func__, strerror(errno)); freeaddrinfo(addr); @@ -301,25 +301,22 @@ int main(const int argc, char *const argv[]) pid_t pid = 0; int kernel_upcall_version = 0; int c, use_cifs_service_prefix = 0; - char *buf, *ccname = NULL, *hostname = NULL; + char *buf, *princ, *ccname = NULL, *hostname = NULL; const char *oid; openlog(prog, 0, LOG_DAEMON); while ((c = getopt(argc, argv, "cv")) != -1) { switch (c) { - case 'c':{ + case 'c': use_cifs_service_prefix = 1; break; - } - case 'v':{ + case 'v': printf("version: %s\n", CIFSSPNEGO_VERSION); goto out; - } - default:{ + default: syslog(LOG_ERR, "unknown option: %c", c); goto out; - } } } @@ -386,45 +383,38 @@ int main(const int argc, char *const argv[]) // do mech specific authorization switch (sectype) { case MS_KRB5: - case KRB5:{ - char *princ; - size_t len; - - /* for "cifs/" service name + terminating 0 */ - len = strlen(hostname) + 5 + 1; - princ = SMB_XMALLOC_ARRAY(char, len); - if (!princ) { - rc = 1; - break; - } - if (use_cifs_service_prefix) { - strlcpy(princ, "cifs/", len); - } else { - strlcpy(princ, "host/", len); - } - strlcpy(princ + 5, hostname, len - 5); - - if (sectype == MS_KRB5) - oid = OID_KERBEROS5_OLD; - else - oid = OID_KERBEROS5; - - rc = handle_krb5_mech(oid, princ, &secblob, &sess_key, - ccname); - SAFE_FREE(princ); - break; - } - default:{ - syslog(LOG_ERR, "sectype: %d is not implemented", - sectype); + case KRB5: + /* for "cifs/" service name + terminating 0 */ + datalen = strlen(hostname) + 5 + 1; + princ = SMB_XMALLOC_ARRAY(char, datalen); + if (!princ) { rc = 1; break; } + + if (use_cifs_service_prefix) + strlcpy(princ, "cifs/", datalen); + else + strlcpy(princ, "host/", datalen); + + strlcpy(princ + 5, hostname, datalen - 5); + + if (sectype == MS_KRB5) + oid = OID_KERBEROS5_OLD; + else + oid = OID_KERBEROS5; + + rc = handle_krb5_mech(oid, princ, &secblob, &sess_key, ccname); + SAFE_FREE(princ); + break; + default: + syslog(LOG_ERR, "sectype: %d is not implemented", sectype); + rc = 1; + break; } - if (rc) { + if (rc) goto out; - } /* pack SecurityBLob and SessionKey into downcall packet */ datalen =