X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fstropts.c;h=cc13325750aa1eb22e542c6c7911a8333e770838;hp=ca79ce081aac2cea3634ba192d7d83a6753be6b4;hb=60fd6cd0ada4f501d6d6bcbc3e14950d453c428d;hpb=6ba0c8306ff8ed0e1233e593bf55d56b017e922b diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index ca79ce0..cc13325 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -130,7 +130,7 @@ static int get_my_ipv4addr(char *ip_addr, int len) /* * Walk through our mount options string, and indicate the presence - * of 'bg', 'retry=', and 'clientaddr='. + * of 'bg', 'retry=', 'addr=', and 'clientaddr='. */ static void extract_interesting_options(char *opts) { @@ -161,13 +161,14 @@ static void extract_interesting_options(char *opts) } /* - * Append the "addr=" option to the options string. + * Append the 'addr=' option to the options string. * - * We always add our own addr= to the end of the options string. + * Returns 1 if 'addr=' option created successfully; + * otherwise zero. */ static int append_addr_opt(const char *spec, char **extra_opts) { - static char hostdir[1024], new_opts[1024], ip_addr[255]; + static char hostdir[1024], new_opts[1024]; char *hostname, *dirname, *s, *old_opts; struct sockaddr_in addr; @@ -185,8 +186,6 @@ static int append_addr_opt(const char *spec, char **extra_opts) if (!fill_ipv4_sockaddr(hostname, &addr)) return 0; - if (!get_my_ipv4addr(ip_addr, sizeof(ip_addr))) - return 0; /* add IP address to mtab options for use when unmounting */ s = inet_ntoa(addr.sin_addr); @@ -206,9 +205,9 @@ static int append_addr_opt(const char *spec, char **extra_opts) } /* - * Append the "clientaddr=" option to the options string. + * Append the 'clientaddr=' option to the options string. * - * Returns 1 if clientaddr option created successfully; + * Returns 1 if 'clientaddr=' option created successfully; * otherwise zero. */ static int append_clientaddr_opt(const char *spec, char **extra_opts) @@ -257,7 +256,12 @@ int nfsmount_s(const char *spec, const char *node, int flags, extract_interesting_options(*extra_opts); - if (!addr_opt && !append_addr_opt(spec, extra_opts)) + if (!bg && addr_opt) { + nfs_error(_("%s: Illegal option: 'addr='"), progname); + goto fail; + } + + if (!append_addr_opt(spec, extra_opts)) goto fail; if (verbose) @@ -299,10 +303,20 @@ int nfs4mount_s(const char *spec, const char *node, int flags, extract_interesting_options(*extra_opts); - if (!addr_opt && !append_addr_opt(spec, extra_opts)) + if (addr_opt) { + nfs_error(_("%s: Illegal option: 'addr='"), progname); + goto fail; + } + + if (ca_opt) { + nfs_error(_("%s: Illegal option: 'clientaddr='"), progname); + goto fail; + } + + if (!append_addr_opt(spec, extra_opts)) goto fail; - if (!ca_opt && !append_clientaddr_opt(spec, extra_opts)) + if (!append_clientaddr_opt(spec, extra_opts)) goto fail; if (verbose)