|
|
1b6200f |
|
|
|
1b6200f |
Thi patch avoid the collision between commas in security contexts and the
|
|
|
1b6200f |
delimiter betweeen mount options.
|
|
|
1b6200f |
|
|
|
1b6200f |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
1b6200f |
Signed-off-by: Cory Olmo <colmo@TrustedCS.com>
|
|
|
1b6200f |
|
|
|
1b6200f |
--- nfs-utils-1.0.9/utils/mount/nfsmount.c.kzak 2006-12-18 23:52:37.000000000 +0100
|
|
|
1b6200f |
+++ nfs-utils-1.0.9/utils/mount/nfsmount.c 2006-12-18 23:59:34.000000000 +0100
|
|
|
1b6200f |
@@ -548,15 +548,31 @@
|
|
|
1b6200f |
struct pmap *mnt_pmap = &mnt_server->pmap;
|
|
|
1b6200f |
struct pmap *nfs_pmap = &nfs_server->pmap;
|
|
|
1b6200f |
int len;
|
|
|
1b6200f |
- char *opt, *opteq;
|
|
|
1b6200f |
+ char *opt, *opteq, *p, *opt_b;
|
|
|
1b6200f |
char *mounthost = NULL;
|
|
|
1b6200f |
char cbuf[128];
|
|
|
1b6200f |
+ int open_quote = 0;
|
|
|
1b6200f |
|
|
|
1b6200f |
data->flags = 0;
|
|
|
1b6200f |
*bg = 0;
|
|
|
1b6200f |
|
|
|
1b6200f |
len = strlen(new_opts);
|
|
|
1b6200f |
- for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) {
|
|
|
1b6200f |
+ for (p=old_opts, opt_b=NULL; p && *p; p++) {
|
|
|
1b6200f |
+ if (!opt_b)
|
|
|
1b6200f |
+ opt_b = p; /* begin of the option item */
|
|
|
1b6200f |
+ if (*p == '"')
|
|
|
1b6200f |
+ open_quote ^= 1; /* reverse the status */
|
|
|
1b6200f |
+ if (open_quote)
|
|
|
1b6200f |
+ continue; /* still in quoted block */
|
|
|
1b6200f |
+ if (*p == ',')
|
|
|
1b6200f |
+ *p = '\0'; /* terminate the option item */
|
|
|
1b6200f |
+ if (*p == '\0' || *(p+1) == '\0') {
|
|
|
1b6200f |
+ opt = opt_b; /* opt is useful now */
|
|
|
1b6200f |
+ opt_b = NULL;
|
|
|
1b6200f |
+ }
|
|
|
1b6200f |
+ else
|
|
|
1b6200f |
+ continue; /* still somewhere in the option item */
|
|
|
1b6200f |
+
|
|
|
1b6200f |
if (strlen(opt) >= sizeof(cbuf))
|
|
|
1b6200f |
goto bad_parameter;
|
|
|
1b6200f |
if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) {
|
|
|
1b6200f |
@@ -671,13 +687,23 @@
|
|
|
1b6200f |
strcspn(opteq+1," \t\n\r,"));
|
|
|
1b6200f |
else if (!strcmp(opt, "context")) {
|
|
|
1b6200f |
char *context = opteq + 1;
|
|
|
1b6200f |
+ int ctxlen = strlen(context);
|
|
|
1b6200f |
|
|
|
1b6200f |
- if (strlen(context) > NFS_MAX_CONTEXT_LEN) {
|
|
|
1b6200f |
+ if (ctxlen > NFS_MAX_CONTEXT_LEN) {
|
|
|
1b6200f |
printf(_("context parameter exceeds limit of %d\n"),
|
|
|
1b6200f |
NFS_MAX_CONTEXT_LEN);
|
|
|
1b6200f |
goto bad_parameter;
|
|
|
1b6200f |
}
|
|
|
1b6200f |
- strncpy(data->context, context, NFS_MAX_CONTEXT_LEN);
|
|
|
1b6200f |
+ /* The context string is in the format of
|
|
|
1b6200f |
+ * "system_u:object_r:...". We only want
|
|
|
1b6200f |
+ * the context str between the quotes.
|
|
|
1b6200f |
+ */
|
|
|
1b6200f |
+ if (*context == '"')
|
|
|
1b6200f |
+ strncpy(data->context, context+1,
|
|
|
1b6200f |
+ ctxlen-2);
|
|
|
1b6200f |
+ else
|
|
|
1b6200f |
+ strncpy(data->context, context,
|
|
|
1b6200f |
+ NFS_MAX_CONTEXT_LEN);
|
|
|
1b6200f |
} else if (!sloppy)
|
|
|
1b6200f |
goto bad_parameter;
|
|
|
1b6200f |
sprintf(cbuf, "%s=%s,", opt, opteq+1);
|
|
|
1b6200f |
--- nfs-utils-1.0.9/utils/mount/mount.c.kzak 2006-12-18 23:52:37.000000000 +0100
|
|
|
1b6200f |
+++ nfs-utils-1.0.9/utils/mount/mount.c 2006-12-18 23:52:37.000000000 +0100
|
|
|
1b6200f |
@@ -289,18 +289,30 @@
|
|
|
1b6200f |
{
|
|
|
1b6200f |
if (options != NULL) {
|
|
|
1b6200f |
char *opts = xstrdup(options);
|
|
|
1b6200f |
- char *opt;
|
|
|
1b6200f |
- int len = strlen(opts) + 20;
|
|
|
1b6200f |
-
|
|
|
1b6200f |
+ char *opt, *p;
|
|
|
1b6200f |
+ int len = strlen(opts) + 256;
|
|
|
1b6200f |
+ int open_quote = 0;
|
|
|
1b6200f |
+
|
|
|
1b6200f |
*extra_opts = xmalloc(len);
|
|
|
1b6200f |
**extra_opts = '\0';
|
|
|
1b6200f |
|
|
|
1b6200f |
- for (opt = strtok(opts, ","); opt; opt = strtok(NULL, ","))
|
|
|
1b6200f |
- parse_opt(opt, flags, *extra_opts, len);
|
|
|
1b6200f |
-
|
|
|
1b6200f |
+ for (p=opts, opt=NULL; p && *p; p++) {
|
|
|
1b6200f |
+ if (!opt)
|
|
|
1b6200f |
+ opt = p; /* begin of the option item */
|
|
|
1b6200f |
+ if (*p == '"')
|
|
|
1b6200f |
+ open_quote ^= 1; /* reverse the status */
|
|
|
1b6200f |
+ if (open_quote)
|
|
|
1b6200f |
+ continue; /* still in quoted block */
|
|
|
1b6200f |
+ if (*p == ',')
|
|
|
1b6200f |
+ *p = '\0'; /* terminate the option item */
|
|
|
1b6200f |
+ /* end of option item or last item */
|
|
|
1b6200f |
+ if (*p == '\0' || *(p+1) == '\0') {
|
|
|
1b6200f |
+ parse_opt(opt, flags, *extra_opts, len);
|
|
|
1b6200f |
+ opt = NULL;
|
|
|
1b6200f |
+ }
|
|
|
1b6200f |
+ }
|
|
|
1b6200f |
free(opts);
|
|
|
1b6200f |
}
|
|
|
1b6200f |
-
|
|
|
1b6200f |
}
|
|
|
1b6200f |
|
|
|
1b6200f |
/*
|