static char errbuf[BUFSIZ];
static char *erreob = &errbuf[BUFSIZ];
extern int verbose;
+extern int sloppy;
/* Convert RPC errors into strings */
int rpc_strerror(int);
* 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;
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])) {
} else if (!strcmp(opt, "namlen")) {
if (nfs_mount_version >= 2)
data->namlen = val;
+ else if (sloppy)
+ continue;
else
goto bad_parameter;
#endif
} else if (!strcmp(opt, "addr")) {
/* ignore */;
continue;
- } else
+ } else if (sloppy)
+ continue;
+ else
goto bad_parameter;
sprintf(cbuf, "%s=%s,", opt, opteq+1);
} else if (opteq) {
mnt_pmap->pm_prot = IPPROTO_TCP;
data->flags |= NFS_MOUNT_TCP;
#endif
- } else
+ } else if (sloppy)
+ continue;
+ else
goto bad_parameter;
#if NFS_MOUNT_VERSION >= 5
} else if (!strcmp(opt, "sec")) {
data->pseudoflavor = AUTH_GSS_SPKMI;
else if (!strcmp(secflavor, "spkm3p"))
data->pseudoflavor = AUTH_GSS_SPKMP;
+ else if (sloppy)
+ continue;
else {
printf(_("Warning: Unrecognized security flavor %s.\n"),
secflavor);
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);
- } else
+ }
+ /* 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
goto bad_parameter;
sprintf(cbuf, "%s=%s,", opt, opteq+1);
} else {
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:
+ if (sloppy)
+ continue;
printf(_("Unsupported nfs mount option: "
"%s%s\n"), val ? "" : "no", opt);
goto out_bad;
int
nfsmount(const char *spec, const char *node, int *flags,
- char **extra_opts, char **mount_opts, int *nfs_mount_vers,
- int running_bg)
+ char **extra_opts, char **mount_opts,
+ int running_bg, int *need_statd)
{
static char *prev_bg_host;
char hostdir[1024];
time_t prevt;
time_t timeout;
- /* The version to try is either specified or 0
- In case it is 0 we tell the caller what we tried */
- if (!*nfs_mount_vers)
- *nfs_mount_vers = find_kernel_nfs_mount_version();
- nfs_mount_version = *nfs_mount_vers;
+ nfs_mount_version = find_kernel_nfs_mount_version();
if (strlen(spec) >= sizeof(hostdir)) {
fprintf(stderr, _("mount: "
#if NFS_MOUNT_VERSION >= 2
data.namlen = NAME_MAX;
#endif
- data.pseudoflavor = AUTH_SYS;
bg = 0;
retry = 10000; /* 10000 minutes ~ 1 week */
#endif
#if NFS_MOUNT_VERSION >= 5
printf("sec = %u ", data.pseudoflavor);
+ printf("readdirplus = %d ", (data.flags & NFS_MOUNT_NORDIRPLUS) != 0);
#endif
printf("\n");
#endif
flavor = mountres->auth_flavors.auth_flavors_val;
while (--i >= 0) {
+ /* If no flavour requested, use first simple
+ * flavour that is offered.
+ */
+ if (! (data.flags & NFS_MOUNT_SECFLAVOUR) &&
+ (flavor[i] == AUTH_SYS ||
+ flavor[i] == AUTH_NONE)) {
+ data.pseudoflavor = flavor[i];
+ data.flags |= NFS_MOUNT_SECFLAVOUR;
+ }
if (flavor[i] == data.pseudoflavor)
yum = 1;
#ifdef NFS_MOUNT_DEBUG
"mount: %s:%s failed, "
"security flavor not supported\n",
hostname, dirname);
- /* server has registered us in mtab, send umount */
+ /* server has registered us in rmtab, send umount */
nfs_call_umount(&mnt_server, &dirname);
goto fail;
}
strcat(new_opts, cbuf);
*extra_opts = xstrdup(new_opts);
+ *need_statd = ! (data.flags & NFS_MOUNT_NONLM);
return 0;
/* abort */