1 autofs-5.0.4 - add nfs mount protocol default configuration option
3 From: Ian Kent <raven@themaw.net>
5 Add configuration option MOUNT_NFS_DEFAULT_PROTOCOL with default of 3.
6 Since the default mount protocol used by mount.nfs(8) will change to
7 NFS version 4 at some point, and because we can't identify the default
8 automatically, we need to be able to set it in our configuration.
9 This will only make a difference for replicated map entries as
10 availability probing isn't used for single host map entries.
14 include/defaults.h | 2 ++
15 lib/defaults.c | 15 ++++++++++++++-
16 man/auto.master.5.in | 6 ++++++
17 modules/mount_nfs.c | 8 +++++---
18 redhat/autofs.sysconfig.in | 10 ++++++++++
19 samples/autofs.conf.default.in | 10 ++++++++++
20 7 files changed, 48 insertions(+), 4 deletions(-)
23 diff --git a/CHANGELOG b/CHANGELOG
24 index ad74b7d..0ce2a56 100644
28 - add check for alternate libtirpc library for libtirpc tsd workaround.
29 - cleanup configure defines for libtirpc.
30 - add WITH_LIBTIRPC to -V status report.
31 +- add nfs mount protocol default configuration option.
33 4/11/2008 autofs-5.0.4
34 -----------------------
35 diff --git a/include/defaults.h b/include/defaults.h
36 index 9a2430f..9bf16e5 100644
37 --- a/include/defaults.h
38 +++ b/include/defaults.h
40 #define DEFAULT_ENTRY_ATTR "cn"
41 #define DEFAULT_VALUE_ATTR "nisMapEntry"
43 +#define DEFAULT_NFS_MOUNT_PROTOCOL 3
44 #define DEFAULT_APPEND_OPTIONS 1
45 #define DEFAULT_AUTH_CONF_FILE AUTOFS_MAP_DIR "/autofs_ldap_auth.conf"
47 @@ -61,6 +62,7 @@ struct ldap_schema *defaults_get_default_schema(void);
48 struct ldap_schema *defaults_get_schema(void);
49 struct ldap_searchdn *defaults_get_searchdns(void);
50 void defaults_free_searchdns(struct ldap_searchdn *);
51 +unsigned int defaults_get_mount_nfs_default_proto(void);
52 unsigned int defaults_get_append_options(void);
53 unsigned int defaults_get_umount_wait(void);
54 const char *defaults_get_auth_conf_file(void);
55 diff --git a/lib/defaults.c b/lib/defaults.c
56 index e507a59..17164bd 100644
60 #define ENV_NAME_ENTRY_ATTR "ENTRY_ATTRIBUTE"
61 #define ENV_NAME_VALUE_ATTR "VALUE_ATTRIBUTE"
63 +#define ENV_MOUNT_NFS_DEFAULT_PROTOCOL "MOUNT_NFS_DEFAULT_PROTOCOL"
64 #define ENV_APPEND_OPTIONS "APPEND_OPTIONS"
65 #define ENV_UMOUNT_WAIT "UMOUNT_WAIT"
66 #define ENV_AUTH_CONF_FILE "AUTH_CONF_FILE"
67 @@ -326,7 +327,8 @@ unsigned int defaults_read_config(unsigned int to_syslog)
68 check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) ||
69 check_set_config_value(key, ENV_UMOUNT_WAIT, value, to_syslog) ||
70 check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog) ||
71 - check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog))
72 + check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog) ||
73 + check_set_config_value(key, ENV_MOUNT_NFS_DEFAULT_PROTOCOL, value, to_syslog))
77 @@ -643,6 +645,17 @@ struct ldap_schema *defaults_get_schema(void)
81 +unsigned int defaults_get_mount_nfs_default_proto(void)
85 + proto = get_env_number(ENV_MOUNT_NFS_DEFAULT_PROTOCOL);
86 + if (proto < 2 || proto > 4)
87 + proto = DEFAULT_NFS_MOUNT_PROTOCOL;
89 + return (unsigned int) proto;
92 unsigned int defaults_get_append_options(void)
95 diff --git a/man/auto.master.5.in b/man/auto.master.5.in
96 index 9cc5f02..aaa6324 100644
97 --- a/man/auto.master.5.in
98 +++ b/man/auto.master.5.in
99 @@ -183,6 +183,12 @@ but it is the best we can do.
101 Maps are browsable by default (program default "yes").
103 +.B MOUNT_NFS_DEFAULT_PROTOCOL
104 +Specify the default protocol used by mount.nfs(8) (program default 3). Since
105 +we can't identify this default automatically we need to set it in the autofs
106 +configuration. This option will only make a difference for replicated map
107 +entries as availability probing isn't used for single host map entries.
110 Determine whether global options, given on the command line or per mount
111 in the master map, are appended to map entry options or if the map entry
112 diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
113 index 4f3f514..14d3850 100644
114 --- a/modules/mount_nfs.c
115 +++ b/modules/mount_nfs.c
116 @@ -61,7 +61,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
117 char fullpath[PATH_MAX];
118 char buf[MAX_ERR_BUF];
119 struct host *this, *hosts = NULL;
121 + unsigned int mount_default_proto, vers;
122 char *nfsoptions = NULL;
123 unsigned int random_selection = ap->flags & MOUNT_FLAG_RANDOM_SELECT;
124 int len, status, err, existed = 1;
125 @@ -130,10 +130,12 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
126 nfsoptions, nosymlink, ro);
129 + mount_default_proto = defaults_get_mount_nfs_default_proto();
130 + vers = NFS_VERS_MASK | NFS_PROTO_MASK;
131 if (strcmp(fstype, "nfs4") == 0)
132 vers = NFS4_VERS_MASK | TCP_SUPPORTED;
134 - vers = NFS_VERS_MASK | NFS_PROTO_MASK;
135 + else if (mount_default_proto == 4)
136 + vers = vers | NFS4_VERS_MASK;
138 if (!parse_location(ap->logopt, &hosts, what)) {
139 info(ap->logopt, MODPREFIX "no hosts available");
140 diff --git a/redhat/autofs.sysconfig.in b/redhat/autofs.sysconfig.in
141 index fe36f45..04e521c 100644
142 --- a/redhat/autofs.sysconfig.in
143 +++ b/redhat/autofs.sysconfig.in
144 @@ -22,6 +22,16 @@ TIMEOUT=300
148 +# MOUNT_NFS_DEFAULT_PROTOCOL - specify the default protocol used by
149 +# mount.nfs(8). Since we can't identify
150 +# the default automatically we need to
151 +# set it in our configuration. This will
152 +# only make a difference for replicated
153 +# map entries as availability probing isn't
154 +# used for single host map entries.
156 +#MOUNT_NFS_DEFAULT_PROTOCOL=3
158 # APPEND_OPTIONS - append to global options instead of replace.
160 #APPEND_OPTIONS="yes"
161 diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
162 index 4496738..52d18ec 100644
163 --- a/samples/autofs.conf.default.in
164 +++ b/samples/autofs.conf.default.in
165 @@ -22,6 +22,16 @@ TIMEOUT=300
169 +# MOUNT_NFS_DEFAULT_PROTOCOL - specify the default protocol used by
170 +# mount.nfs(8). Since we can't identify
171 +# the default automatically we need to
172 +# set it in our configuration. This will
173 +# only make a difference for replicated
174 +# map entries as availability probing isn't
175 +# used for single host map entries.
177 +#MOUNT_NFS_DEFAULT_PROTOCOL=3
179 # APPEND_OPTIONS - append to global options instead of replace.
181 #APPEND_OPTIONS="yes"