From patchwork Fri Mar 26 14:25:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 48633 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 ozlabs.org (Postfix) with ESMTP id AEA5DB7CCD for ; Sat, 27 Mar 2010 01:25:46 +1100 (EST) Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 47B404664B; Fri, 26 Mar 2010 08:25:46 -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=-9.9 required=3.8 tests=BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_NEUTRAL autolearn=ham version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by lists.samba.org (Postfix) with ESMTP id 035304663C for ; Fri, 26 Mar 2010 08:25:41 -0600 (MDT) Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2QEPfoh025273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Mar 2010 10:25:41 -0400 Received: from localhost.localdomain (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2QEPdCW026868 for ; Fri, 26 Mar 2010 10:25:40 -0400 From: Jeff Layton To: linux-cifs-client@lists.samba.org Date: Fri, 26 Mar 2010 10:25:24 -0400 Message-Id: <1269613542-6402-2-git-send-email-jlayton@samba.org> In-Reply-To: <1269613542-6402-1-git-send-email-jlayton@samba.org> References: <1269613542-6402-1-git-send-email-jlayton@samba.org> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Subject: [linux-cifs-client] [PATCH 01/19] mount.cifs: declare new struct for holding parsed mount info 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 From: Jeff Layton Currently mount.cifs puts mount info into a disparate series of dynamically sized buffers. Declate a new struct that holds a set of fixed-size buffers. The option and UNC parsing routines can place their results in this struct. This should make it easier to implement privilege separation using shared memory to pass data between processes. Signed-off-by: Jeff Layton --- mount.cifs.c | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mount.cifs.c b/mount.cifs.c index 4211b4d..f9a46d9 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -60,6 +60,19 @@ /* I believe that the kernel limits options data to a page */ #define MAX_OPTIONS_LEN 4096 +/* + * Maximum length of "share" portion of a UNC. I have no idea if this is at + * all valid. According to MSDN, the typical max length of any component is + * 255, so use that here. + */ +#define MAX_SHARE_LEN 256 + +/* currently maximum length of IPv6 address string */ +#define MAX_ADDRESS_LEN INET6_ADDRSTRLEN + +/* limit list of addresses to 16 max-size addrs */ +#define MAX_ADDR_LIST_LEN (MAX_ADDRESS_LEN * 16) + #ifndef SAFE_FREE #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) #endif @@ -67,9 +80,6 @@ #define MOUNT_PASSWD_SIZE 128 #define DOMAIN_SIZE 64 -/* currently maximum length of IPv6 address string */ -#define MAX_ADDRESS_LEN INET6_ADDRSTRLEN - /* * value of the ver= option that gets passed to the kernel. Used to indicate * behavioral changes introduced in the mount helper. @@ -108,6 +118,16 @@ */ #define CIFS_SETUID_FLAGS (MS_NOSUID|MS_NODEV) +/* struct for holding parsed mount info for use by privleged process */ +struct parsed_mount_info { + unsigned long flags; + char host[NI_MAXHOST]; + char share[MAX_SHARE_LEN]; + char prefix[PATH_MAX]; + char options[MAX_OPTIONS_LEN]; + char address_list[MAX_ADDR_LIST_LEN]; +}; + const char *thisprogram; int verboseflag = 0; int fakemnt = 0;