diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-08-24 13:11:16 -0400 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2007-08-25 08:19:32 +1000 |
commit | fb874be0226ae35367f10f260353a76716da9346 (patch) | |
tree | 42451c1bcf5145121ae4de8041a62b950419ffb8 | |
parent | 6ba0c8306ff8ed0e1233e593bf55d56b017e922b (diff) | |
download | nfs-utils-fb874be0226ae35367f10f260353a76716da9346.tar.gz nfs-utils-fb874be0226ae35367f10f260353a76716da9346.tar.xz nfs-utils-fb874be0226ae35367f10f260353a76716da9346.zip |
mount.nfs: Don't allow the user to specify addr= or clientaddr=.
The current mount.nfs implementation doesn't allow users to specify their
own addr= or clientaddr= option. The new string-based interface does
allow this, even though nfs(5) does not document 'addr=' and specifically
forbids adding 'clientaddr='.
Make the addition of either option by the user a permanent error.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r-- | utils/mount/stropts.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index ca79ce0..e43bbf4 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,9 +161,10 @@ 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) { @@ -206,9 +207,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 +258,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 +305,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) |