X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmount%2Fnfsmount.c;h=815064a593e4ad917fe18a09124e6d0ee7e53c62;hb=de6497fce274e35a0c7aeac14dbfff476b012e37;hp=eac9590f5610d836045fcb2aeaf60e54f86804d7;hpb=3eb4c9aaa218f2af4bbea2073f02e419c50d3d3d;p=nfs-utils.git diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c index eac9590..815064a 100644 --- a/utils/mount/nfsmount.c +++ b/utils/mount/nfsmount.c @@ -293,14 +293,14 @@ int nfs_gethostbyname(const char *hostname, struct sockaddr_in *saddr) * instead of reserve ports since reserve ports * are not needed for pmap requests. */ -static u_short +u_short getport( struct sockaddr_in *saddr, u_long prog, u_long vers, u_int prot) { - u_short port; + u_short port = 0; int socket; CLIENT *clnt = NULL; struct pmap parms; @@ -548,15 +548,31 @@ parse_options(char *old_opts, struct nfs_mount_data *data, struct pmap *mnt_pmap = &mnt_server->pmap; struct pmap *nfs_pmap = &nfs_server->pmap; int len; - char *opt, *opteq; + char *opt, *opteq, *p, *opt_b; char *mounthost = NULL; char cbuf[128]; + int open_quote = 0; data->flags = 0; *bg = 0; len = strlen(new_opts); - for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) { + for (p=old_opts, opt_b=NULL; p && *p; p++) { + if (!opt_b) + opt_b = p; /* begin of the option item */ + if (*p == '"') + open_quote ^= 1; /* reverse the status */ + if (open_quote) + continue; /* still in a quoted block */ + if (*p == ',') + *p = '\0'; /* terminate the option item */ + if (*p == '\0' || *(p+1) == '\0') { + opt = opt_b; /* opt is useful now */ + opt_b = NULL; + } + else + continue; /* still somewhere in the option item */ + if (strlen(opt) >= sizeof(cbuf)) goto bad_parameter; if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) { @@ -680,14 +696,24 @@ parse_options(char *old_opts, struct nfs_mount_data *data, mounthost=xstrndup(opteq+1, strcspn(opteq+1," \t\n\r,")); else if (!strcmp(opt, "context")) { - char *context = opteq + 1; - - if (strlen(context) > NFS_MAX_CONTEXT_LEN) { - printf(_("context parameter exceeds limit of %d\n"), - NFS_MAX_CONTEXT_LEN); + char *context = opteq + 1; + int ctxlen = strlen(context); + + if (ctxlen > NFS_MAX_CONTEXT_LEN) { + printf(_("context parameter exceeds limit of %d\n"), + NFS_MAX_CONTEXT_LEN); goto bad_parameter; - } - strncpy(data->context, context, NFS_MAX_CONTEXT_LEN); + } + /* The context string is in the format of + * "system_u:object_r:...". We only want + * the context str between the quotes. + */ + if (*context == '"') + strncpy(data->context, context+1, + ctxlen-2); + else + strncpy(data->context, context, + NFS_MAX_CONTEXT_LEN); } else if (sloppy) continue; else @@ -774,6 +800,10 @@ parse_options(char *old_opts, struct nfs_mount_data *data, data->flags &= ~NFS_MOUNT_NOACL; if (!val) data->flags |= NFS_MOUNT_NOACL; + } else if (!strcmp(opt, "rdirplus")) { + data->flags &= ~NFS_MOUNT_NORDIRPLUS; + if (!val) + data->flags |= NFS_MOUNT_NORDIRPLUS; #endif } else { bad_option: @@ -957,6 +987,7 @@ nfsmount(const char *spec, const char *node, int *flags, #endif #if NFS_MOUNT_VERSION >= 5 printf("sec = %u ", data.pseudoflavor); + printf("readdirplus = %d ", (data.flags & NFS_MOUNT_NORDIRPLUS) != 0); #endif printf("\n"); #endif