@@ -1457,15 +1457,47 @@ read_nfsd_conf(void)
xlog_set_debug("nfsd");
}
-static void configure_versions(void)
+static int configure_versions(void)
{
- bool v4 = conf_get_bool("nfsd", "vers4", true);
+ int i, j, max_minor = get_max_minorversion();
+ bool found_one = false;
+ char tag[20];
+
+ for (i = 2; i <= 4; ++i) {
+ sprintf(tag, "vers%d", i);
+ if (!conf_get_bool("nfsd", tag, true)) {
+ update_nfsd_version(i, 0, false);
+ if (i == 4)
+ for (j = 0; j <= max_minor; ++j)
+ update_nfsd_version(4, j, false);
+ }
+ if (conf_get_bool("nfsd", tag, false)) {
+ update_nfsd_version(i, 0, true);
+ if (i == 4)
+ for (j = 0; j <= max_minor; ++j)
+ update_nfsd_version(4, j, true);
+ }
+ }
- update_nfsd_version(2, 0, conf_get_bool("nfsd", "vers2", false));
- update_nfsd_version(3, 0, conf_get_bool("nfsd", "vers3", true));
- update_nfsd_version(4, 0, v4 && conf_get_bool("nfsd", "vers4.0", true));
- update_nfsd_version(4, 1, v4 && conf_get_bool("nfsd", "vers4.1", true));
- update_nfsd_version(4, 2, v4 && conf_get_bool("nfsd", "vers4.2", true));
+ for (i = 0; i <= max_minor; ++i) {
+ sprintf(tag, "vers4.%d", i);
+ if (!conf_get_bool("nfsd", tag, true))
+ update_nfsd_version(4, i, false);
+ if (conf_get_bool("nfsd", tag, false))
+ update_nfsd_version(4, i, true);
+ }
+
+ for (i = 0; i < MAX_NFS_VERSIONS; ++i) {
+ if (nfsd_versions[i].enabled) {
+ found_one = true;
+ break;
+ }
+ }
+ if (!found_one) {
+ xlog(L_ERROR, "no version specified");
+ return 1;
+ }
+ return 0;
}
static void configure_listeners(void)
@@ -1556,7 +1588,9 @@ static int autostart_func(struct nl_sock *sock, int argc, char ** argv)
ret = fetch_nfsd_versions(sock);
if (ret)
return ret;
- configure_versions();
+ ret = configure_versions();
+ if (ret)
+ return ret;
ret = set_nfsd_versions(sock);
if (ret)
return ret;
I noticed I was getting different results when comparing nfsdctl's config file handling versus rpc.nfsd's. First, the vers4 config option was being treated as a mask, e.g. if vers4=n and vers4.2=y then end result was still that all minorversions were disabled. Change it so that vers4=n would initially toggle off all minorversions, but individual v4.x=y would turn that minorversion back on. Second, don't make assumptions about what default should be passed to conf_get_bool. Instead, test both possible values and only update the nfsd_versions array if an option was explicitly specified. Finally, add a check so that 'nfsdctl autostart' will error out if no versions or minorversions are enabled. Signed-off-by: Scott Mayhew <smayhew@redhat.com> --- utils/nfsdctl/nfsdctl.c | 50 ++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-)