Patchwork [01/19] mount.cifs: declare new struct for holding parsed mount info

login
register
mail settings
Submitter Jeff Layton
Date March 26, 2010, 2:25 p.m.
Message ID <1269613542-6402-2-git-send-email-jlayton@samba.org>
Download mbox | patch
Permalink /patch/48633/
State New
Headers show

Comments

Jeff Layton - March 26, 2010, 2:25 p.m.
From: Jeff Layton <jlayton@redhat.com>

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 <jlayton@redhat.com>
---
 mount.cifs.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

Patch

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;