|
|
40fde1 |
From 1f82a2588ac4c8975de0ebe52ad84393b8420e5b Mon Sep 17 00:00:00 2001
|
|
|
40fde1 |
From: Germano Percossi <germano.percossi@citrix.com>
|
|
|
40fde1 |
Date: Fri, 18 Nov 2016 18:54:51 +0000
|
|
|
40fde1 |
Subject: [PATCH 10/12] mount.cifs: Fixed command line parsing and aligned with
|
|
|
40fde1 |
kernel
|
|
|
40fde1 |
|
|
|
40fde1 |
The way token matching was done was consuming the parameters namespace
|
|
|
40fde1 |
quickly. For example, anything starting with "dom" was interpreted with
|
|
|
40fde1 |
domain, while it could have been a completely different word. The same
|
|
|
40fde1 |
is true even for "ro".
|
|
|
40fde1 |
|
|
|
40fde1 |
Moreover, many perfectly valid options like "addr" where not accepted.
|
|
|
40fde1 |
|
|
|
40fde1 |
The cifs kernel module is very strict when it comes to names: 'dom' and
|
|
|
40fde1 |
'domain' are valid while 'domai' is not, so the userspace tool needs to
|
|
|
40fde1 |
comply otherwise it becomes very difficult to come up with new names for
|
|
|
40fde1 |
options.
|
|
|
40fde1 |
|
|
|
40fde1 |
Now, checking is strict and as close as possible to kernel. When it is
|
|
|
40fde1 |
not, it is just to avoid breaking compatibility with some users.
|
|
|
40fde1 |
However, workg has been removed because it is too lazy and undocumented.
|
|
|
40fde1 |
|
|
|
40fde1 |
The only variable left without strict checking is 'x-' because the
|
|
|
40fde1 |
intent is to ignore anything starting in that way
|
|
|
40fde1 |
|
|
|
40fde1 |
Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
|
|
|
40fde1 |
(cherry picked from commit a1f3acd40b265f134a97a739a6898b3958d206b9)
|
|
|
40fde1 |
|
|
|
40fde1 |
Resolves bz: 1427337
|
|
|
40fde1 |
|
|
|
40fde1 |
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
|
|
|
40fde1 |
---
|
|
|
40fde1 |
mount.cifs.c | 82 ++++++++++++++++++++++++++++++++++--------------------------
|
|
|
40fde1 |
1 file changed, 47 insertions(+), 35 deletions(-)
|
|
|
40fde1 |
|
|
|
40fde1 |
diff --git a/mount.cifs.c b/mount.cifs.c
|
|
|
40fde1 |
index 88a3618..6eb0e6b 100644
|
|
|
40fde1 |
--- a/mount.cifs.c
|
|
|
40fde1 |
+++ b/mount.cifs.c
|
|
|
40fde1 |
@@ -689,73 +689,85 @@ static int parse_opt_token(const char *token)
|
|
|
40fde1 |
if (token == NULL)
|
|
|
40fde1 |
return OPT_ERROR;
|
|
|
40fde1 |
|
|
|
40fde1 |
- if (strncmp(token, "users", 5) == 0)
|
|
|
40fde1 |
+ /*
|
|
|
40fde1 |
+ * token is NULL terminated and contains exactly the
|
|
|
40fde1 |
+ * keyword so we can match exactly
|
|
|
40fde1 |
+ */
|
|
|
40fde1 |
+ if (strcmp(token, "users") == 0)
|
|
|
40fde1 |
return OPT_USERS;
|
|
|
40fde1 |
- if (strncmp(token, "user_xattr", 10) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "user_xattr") == 0)
|
|
|
40fde1 |
return OPT_USER_XATTR;
|
|
|
40fde1 |
- if (strncmp(token, "user", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "user") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "username") == 0)
|
|
|
40fde1 |
return OPT_USER;
|
|
|
40fde1 |
- if (strncmp(token, "pass", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "pass") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "password") == 0)
|
|
|
40fde1 |
return OPT_PASS;
|
|
|
40fde1 |
- if (strncmp(token, "sec", 3) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "sec") == 0)
|
|
|
40fde1 |
return OPT_SEC;
|
|
|
40fde1 |
- if (strncmp(token, "ip", 2) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "ip") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "addr") == 0)
|
|
|
40fde1 |
return OPT_IP;
|
|
|
40fde1 |
- if (strncmp(token, "unc", 3) == 0 ||
|
|
|
40fde1 |
- strncmp(token, "target", 6) == 0 ||
|
|
|
40fde1 |
- strncmp(token, "path", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "unc") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "target") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "path") == 0)
|
|
|
40fde1 |
return OPT_UNC;
|
|
|
40fde1 |
- if (strncmp(token, "dom", 3) == 0 || strncmp(token, "workg", 5) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "dom") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "domain") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "workgroup") == 0)
|
|
|
40fde1 |
return OPT_DOM;
|
|
|
40fde1 |
- if (strncmp(token, "cred", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "cred") == 0 || /* undocumented */
|
|
|
40fde1 |
+ strcmp(token, "credentials") == 0)
|
|
|
40fde1 |
return OPT_CRED;
|
|
|
40fde1 |
- if (strncmp(token, "uid", 3) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "uid") == 0)
|
|
|
40fde1 |
return OPT_UID;
|
|
|
40fde1 |
- if (strncmp(token, "cruid", 5) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "cruid") == 0)
|
|
|
40fde1 |
return OPT_CRUID;
|
|
|
40fde1 |
- if (strncmp(token, "gid", 3) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "gid") == 0)
|
|
|
40fde1 |
return OPT_GID;
|
|
|
40fde1 |
- if (strncmp(token, "fmask", 5) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "fmask") == 0)
|
|
|
40fde1 |
return OPT_FMASK;
|
|
|
40fde1 |
- if (strncmp(token, "file_mode", 9) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "file_mode") == 0)
|
|
|
40fde1 |
return OPT_FILE_MODE;
|
|
|
40fde1 |
- if (strncmp(token, "dmask", 5) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "dmask") == 0)
|
|
|
40fde1 |
return OPT_DMASK;
|
|
|
40fde1 |
- if (strncmp(token, "dir_mode", 4) == 0 || strncmp(token, "dirm", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "dir_mode") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "dirm") == 0)
|
|
|
40fde1 |
return OPT_DIR_MODE;
|
|
|
40fde1 |
- if (strncmp(token, "nosuid", 6) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "nosuid") == 0)
|
|
|
40fde1 |
return OPT_NO_SUID;
|
|
|
40fde1 |
- if (strncmp(token, "suid", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "suid") == 0)
|
|
|
40fde1 |
return OPT_SUID;
|
|
|
40fde1 |
- if (strncmp(token, "nodev", 5) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "nodev") == 0)
|
|
|
40fde1 |
return OPT_NO_DEV;
|
|
|
40fde1 |
- if (strncmp(token, "nobrl", 5) == 0 || strncmp(token, "nolock", 6) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "nobrl") == 0 ||
|
|
|
40fde1 |
+ strcmp(token, "nolock") == 0)
|
|
|
40fde1 |
return OPT_NO_LOCK;
|
|
|
40fde1 |
- if (strncmp(token, "mand", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "mand") == 0)
|
|
|
40fde1 |
return OPT_MAND;
|
|
|
40fde1 |
- if (strncmp(token, "nomand", 6) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "nomand") == 0)
|
|
|
40fde1 |
return OPT_NOMAND;
|
|
|
40fde1 |
- if (strncmp(token, "dev", 3) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "dev") == 0)
|
|
|
40fde1 |
return OPT_DEV;
|
|
|
40fde1 |
- if (strncmp(token, "noexec", 6) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "noexec") == 0)
|
|
|
40fde1 |
return OPT_NO_EXEC;
|
|
|
40fde1 |
- if (strncmp(token, "exec", 4) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "exec") == 0)
|
|
|
40fde1 |
return OPT_EXEC;
|
|
|
40fde1 |
- if (strncmp(token, "guest", 5) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "guest") == 0)
|
|
|
40fde1 |
return OPT_GUEST;
|
|
|
40fde1 |
- if (strncmp(token, "ro", 2) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "ro") == 0)
|
|
|
40fde1 |
return OPT_RO;
|
|
|
40fde1 |
- if (strncmp(token, "rw", 2) == 0 && strlen(token) == 2)
|
|
|
40fde1 |
+ if (strcmp(token, "rw") == 0)
|
|
|
40fde1 |
return OPT_RW;
|
|
|
40fde1 |
- if (strncmp(token, "remount", 7) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "remount") == 0)
|
|
|
40fde1 |
return OPT_REMOUNT;
|
|
|
40fde1 |
- if (strncmp(token, "_netdev", 7) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "_netdev") == 0)
|
|
|
40fde1 |
return OPT_IGNORE;
|
|
|
40fde1 |
- if (strncmp(token, "backupuid", 9) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "backupuid") == 0)
|
|
|
40fde1 |
return OPT_BKUPUID;
|
|
|
40fde1 |
- if (strncmp(token, "backupgid", 9) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "backupgid") == 0)
|
|
|
40fde1 |
return OPT_BKUPGID;
|
|
|
40fde1 |
- if (strncmp(token, "nofail", 6) == 0)
|
|
|
40fde1 |
+ if (strcmp(token, "nofail") == 0)
|
|
|
40fde1 |
return OPT_NOFAIL;
|
|
|
40fde1 |
if (strncmp(token, "x-", 2) == 0)
|
|
|
40fde1 |
return OPT_IGNORE;
|
|
|
40fde1 |
--
|
|
|
40fde1 |
2.9.3
|
|
|
40fde1 |
|