NFSv3: match sec= flavor against server list
Subsystems (2)
PATCH 1/1 NFSv3: match sec= flavor against server list
Older linux clients match the 'sec=' mount option flavor against the server's flavor list (if available) and return EPERM if the specified flavor or AUTH_NULL (which "matches" any flavor) is not found.
Recent changes skip this step and allow the vfs mount even though no operations will succeed, creating a 'dud' mount.
This patch reverts back to the old behavior of matching specified flavors against the server list and also returns EPERM when no sec= is specified and none of the flavors returned by the server are supported by the client.
Example of behavior change:
the server's /etc/exports:
/export/krb5 *(sec=krb5,rw,no_root_squash)
old client behavior:
$ uname -a Linux one.apikia.fake 3.8.8-202.fc18.x86_64 #1 SMP Wed Apr 17 23:25:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:32:04 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 mount.nfs: mount(2): Permission denied mount.nfs: access denied by server while mounting zero:/export/krb5
recently changed behavior:
$ uname -a Linux one.apikia.fake 3.9.0-testing+ #2 SMP Fri May 3 20:29:32 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:37:17 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 $ ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo df /mnt df: ‘/mnt’: Permission denied df: no file systems processed $ sudo umount /mnt $
---
Version 2:
- now just uses specified flavor when:
- AUTH_NULL is in the server list
- flavor is in the server list
- now returns EPERM when no sec= specified and no client supported flavors are in the server list
- includes example in the changelog
fs/nfs/super.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
fs/nfs/super.c +30 -7
@@ -1611,14 +1611,12 @@ out_security_failure:* Select a security flavor for this mount. The selected flavor * is planted in args->auth_flavors[0]. */ -static void nfs_select_flavor (struct nfs_parsed_mount_data *args, +static int nfs_select_flavor (struct nfs_parsed_mount_data *args,struct nfs_mount_request *request) {unsigned int i, count = *(request->auth_flav_len);rpc_authflavor_t flavor; - -if (args->auth_flavors[0 ] !=RPC_AUTH_MAXFLAVOR ) - goto out; +bool auth_null_seen = false;/* * The NFSv2 MNT operation does not return a flavor list.
@@ -1634,6 +1632,21 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args, goto out_default;/* +* If the sec= mount option is used, the specified flavor or AUTH_NULL +* must be in the list returned by the server. +*/ +if (args->auth_flavors[0 ] !=RPC_AUTH_MAXFLAVOR ) { +for (i =0 ; i < count; i++) { +if (args->auth_flavors[0 ] == request->auth_flavs[i] || + request->auth_flavs[i] ==RPC_AUTH_NULL ) + goto out; + } +dfprintk (MOUNT ,"NFS: auth flavor %d not supported server\n" , + args->auth_flavors[0 ]); + goto out_err; + } + +/* * RFC 2623, section 2.7 suggests we SHOULD prefer the * flavor listed first. However, some servers list * AUTH_NULL first. Avoid ever choosing AUTH_NULL.
@@ -1646,6 +1659,7 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args,case RPC_AUTH_UNIX : goto out_set;case RPC_AUTH_NULL : + auth_null_seen = true;continue ;default :if (rpcauth_get_gssinfo (flavor, &info) ==0 )
@@ -1653,12 +1667,22 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args, } } +if (!auth_null_seen) { +dfprintk (MOUNT ,"NFS: no auth flavors in common with server\n" ); + goto out_err; + } + out_default: - flavor =RPC_AUTH_UNIX ; +/* use default if flavor not already set */ + flavor = (args->auth_flavors[0 ] ==RPC_AUTH_MAXFLAVOR ) ? +RPC_AUTH_UNIX : args->auth_flavors[0 ]; out_set: args->auth_flavors[0 ] = flavor; out:dfprintk (MOUNT ,"NFS: using auth flavor %d\n" , args->auth_flavors[0 ]); +return 0 ; +out_err: +return -EPERM ; }/*
@@ -1721,8 +1745,7 @@ static int nfs_request_mount(struct nfs_parsed_mount_data *args,return status; } -nfs_select_flavor (args, &request); -return 0 ; +return nfs_select_flavor (args, &request); } struct dentry *nfs_try_mount(int flags, const char *dev_name,
Signature · 1 line
1.7.12.4 (Apple Git-37)
T24gTW9uLCAyMDEzLTA1LTA2IGF0IDE1OjQxIC0wNDAwLCBXZXN0b24gQW5kcm9zIEFkYW1zb24g d3JvdGU6DQo+IE9sZGVyIGxpbnV4IGNsaWVudHMgbWF0Y2ggdGhlICdzZWM9JyBtb3VudCBvcHRp b24gZmxhdm9yIGFnYWluc3QgdGhlIHNlcnZlcidzDQo+IGZsYXZvciBsaXN0IChpZiBhdmFpbGFi bGUpIGFuZCByZXR1cm4gRVBFUk0gaWYgdGhlIHNwZWNpZmllZCBmbGF2b3Igb3IgQVVUSF9OVUxM DQo+ICh3aGljaCAibWF0Y2hlcyIgYW55IGZsYXZvcikgaXMgbm90IGZvdW5kLg0KPiANCj4gUmVj ZW50IGNoYW5nZXMgc2tpcCB0aGlzIHN0ZXAgYW5kIGFsbG93IHRoZSB2ZnMgbW91bnQgZXZlbiB0 aG91Z2ggbm8gb3BlcmF0aW9ucw0KPiB3aWxsIHN1Y2NlZWQsIGNyZWF0aW5nIGEgJ2R1ZCcgbW91 bnQuDQo+IA0KPiBUaGlzIHBhdGNoIHJldmVydHMgYmFjayB0byB0aGUgb2xkIGJlaGF2aW9yIG9m IG1hdGNoaW5nIHNwZWNpZmllZCBmbGF2b3JzDQo+IGFnYWluc3QgdGhlIHNlcnZlciBsaXN0IGFu ZCBhbH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5IC9tbnQ6IFBlcm1pc3Npb24gZGVuaWVkDQo+ICQgc3VkbyBscyAvbW50DQo+IGxzOiBj YW5ub3Qgb3BlbiBkaXJlY3RvcnkgL21udDogUGVybWlzc2lvbiBkZW5pZWQNCj4gJCBzdWRvIGRm IC9tbnQNCj4gZGY6IOKAmC9tbnTigJk6IFBlcm1pc3Npb24gZGVuaWVkDQo+IGRmOiBubyBmaWxl IHN5c3RlbXMgcHJvY2Vzc2VkDQo+ICQgc3VkbyB1bW91bnQgL21udA0KPiAkDQo+IA0KPiBTaWdu ZWQtb2ZmLWJ5OiBXZXN0b24gQW5kcm9zIEFkYW1zb24gPGRyb3NAbmV0YXBwLmNvbT4NCj4gLS0t DQo+IA0KPiBWZXJzaW9uIDI6DQo+ICAtIG5vdyBqdXN0IHVzZXMgc3BlY2lmaWVkIGZsYXZvciB3 aGVuOg0KPiAgICAtIEFVVEhfTlVMTCBpcyBpbiB0aGUgc2VydmVyIGxpc3QNCj4gICAgLSBmbGF2 b3IgaXMgaW4gdGhlIHNlcnZlciBsaXN0DQo+IA0KPiAgLSBub3cgcmV0dXJucyBFUEVSTSB3aGVu IG5vIHNlYz0gc3BlY2lmaWVkIGFuZCBubyBjbGllbnQgc3VwcG9ydGVkIGZsYXZvcnMgYXJlDQo+ ICAgIGluIHRoZSBzZXJ2ZXIgbGlzdA0KPiANCg0KU2hvdWxkbid0IHRoYXQgYmUgRUFDQ0VTPw0K DQotLSANClRyb25kIE15a2xlYnVzdA0KTGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5l dEFwcA0KVHJvbmQuTXlrbGVidXN0QG5ldGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQo=
Quoted 61 lines · Trond
Quoted 60 lines · Weston Andros Adamson
Older linux clients match the 'sec=' mount option flavor against the server's flavor list (if available) and return EPERM if the specified flavor or
AUTH_NULL(which "matches" any flavor) is not found.Recent changes skip this step and allow the vfs mount even though no operations will succeed, creating a 'dud' mount.
This patch reverts back to the old behavior of matching specified flavors against the server list and also returns EPERM when no sec= is specified and none of the flavors returned by the server are supported by the client.
Example of behavior change:
the server's
/etc/exports:/export/krb5 *(sec=krb5,rw,no_root_squash)
old client behavior:
$ uname -a Linux one.apikia.fake 3.8.8-202.fc18.x86_64 #1 SMP Wed Apr 17 23:25:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:32:04 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 mount.nfs: mount(2): Permission denied mount.nfs: access denied by server while mounting zero:/export/krb5recently changed behavior:
$ uname -a Linux one.apikia.fake 3.9.0-testing+ #2 SMP Fri May 3 20:29:32 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:37:17 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 $ ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo df /mnt df: ‘/mnt’: Permission denied df: no file systems processed $ sudo umount /mnt $Signed-off-by Weston Andros Adamson <[email protected]>---
Version 2:
- now just uses specified flavor when:
-AUTH_NULLis in the server list
- flavor is in the server list
Quoted 5 lines
Quoted 3 lines
- now returns EPERM when no sec= specified and no client supported flavors are in the server list
Shouldn't that be EACCES?
Yes. I think both cases should be EACCES.
Will test and repost
-dros
Quoted 8 lines
Signature · 7 lines
-- Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Quoted 52 lines · Weston Andros Adamson
Older linux clients match the 'sec=' mount option flavor against the server's flavor list (if available) and return EPERM if the specified flavor or
AUTH_NULL(which "matches" any flavor) is not found.Recent changes skip this step and allow the vfs mount even though no operations will succeed, creating a 'dud' mount.
This patch reverts back to the old behavior of matching specified flavors against the server list and also returns EPERM when no sec= is specified and none of the flavors returned by the server are supported by the client.
Example of behavior change:
the server's
/etc/exports:/export/krb5 *(sec=krb5,rw,no_root_squash)
old client behavior:
$ uname -a Linux one.apikia.fake 3.8.8-202.fc18.x86_64 #1 SMP Wed Apr 17 23:25:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:32:04 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 mount.nfs: mount(2): Permission denied mount.nfs: access denied by server while mounting zero:/export/krb5recently changed behavior:
$ uname -a Linux one.apikia.fake 3.9.0-testing+ #2 SMP Fri May 3 20:29:32 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:37:17 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 $ ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo df /mnt df: ‘/mnt’: Permission denied df: no file systems processed $ sudo umount /mnt $
Quoted 1 line
Signed-off-by Weston Andros Adamson <[email protected]>
I don't have any hard objections to this patch, so barring the change to return EACCES,
Just a nit, perhaps, but...
I think that the optimization of setting the boolean, so that only one walk through the server list is needed, is premature. It might be more clear if each test was done independently of the next to make it easier to reorder the tests, fix bugs in each test, and for readers to see exactly what each of these tests do.
This code is really our only documentation of the security flavor selection process, so making it as clear as possible should be a priority, IMO, over saving a few CPU cycles.
Quoted 107 lines
---
Version 2:
- now just uses specified flavor when:
-AUTH_NULLis in the server list
- flavor is in the server list- now returns EPERM when no sec= specified and no client supported flavors are in the server list
- includes example in the changelog
fs/nfs/super.c| 37 ++++++++++++++++++++++++++++++-------1 file changed, 30 insertions(+), 7 deletions(-)fs/nfs/super.c +23
-4@@ -1611,14 +1611,12 @@ out_security_failure:* Select a security flavor for this mount. The selected flavor * is planted in args->auth_flavors[0]. */ -static void nfs_select_flavor (struct nfs_parsed_mount_data *args, +static int nfs_select_flavor (struct nfs_parsed_mount_data *args,struct nfs_mount_request *request) {unsigned int i, count = *(request->auth_flav_len);rpc_authflavor_t flavor; - -if (args->auth_flavors[0 ] !=RPC_AUTH_MAXFLAVOR ) - goto out; +bool auth_null_seen = false;/* * The NFSv2 MNT operation does not return a flavor list. @@ -1634,6 +1632,21 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args, goto out_default;/* +* If the sec= mount option is used, the specified flavor or AUTH_NULL +* must be in the list returned by the server. +*/ +if (args->auth_flavors[0 ] !=RPC_AUTH_MAXFLAVOR ) { +for (i =0 ; i < count; i++) { +if (args->auth_flavors[0 ] == request->auth_flavs[i] || + request->auth_flavs[i] ==RPC_AUTH_NULL ) + goto out; + } +dfprintk (MOUNT ,"NFS: auth flavor %d not supported server\n" , + args->auth_flavors[0 ]); + goto out_err; + } + +/* * RFC 2623, section 2.7 suggests we SHOULD prefer the * flavor listed first. However, some servers list * AUTH_NULL first. Avoid ever choosing AUTH_NULL. @@ -1646,6 +1659,7 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args,case RPC_AUTH_UNIX : goto out_set;case RPC_AUTH_NULL : + auth_null_seen = true;continue ;default :if (rpcauth_get_gssinfo (flavor, &info) ==0 )@@ -1653,12 +1667,22 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args, } } +if (!auth_null_seen) { +dfprintk (MOUNT ,"NFS: no auth flavors in common with server\n" ); + goto out_err; + } +
out_default:fs/nfs/super.c +3
-1- flavor =RPC_AUTH_UNIX ; +/* use default if flavor not already set */ + flavor = (args->auth_flavors[0 ] ==RPC_AUTH_MAXFLAVOR ) ? +RPC_AUTH_UNIX : args->auth_flavors[0 ];
out_set:args->auth_flavors[0] = flavor; out: dfprintk(MOUNT, "NFS: using auth flavor %d\n", args->auth_flavors[0]);fs/nfs/super.c +3
-0+return 0 ; +out_err: +return -EPERM ;}
/*
fs/nfs/super.c +1
-2@@ -1721,8 +1745,7 @@ static int nfs_request_mount(struct nfs_parsed_mount_data *args,return status; } -nfs_select_flavor (args, &request); -return 0 ; +return nfs_select_flavor (args, &request); } struct dentry *nfs_try_mount(int flags, const char *dev_name,Signature · 6 lines
1.7.12.4 (Apple Git-37) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Quoted 59 lines · Chuck Lever
Quoted 52 lines · Weston Andros Adamson
Older linux clients match the 'sec=' mount option flavor against the server's flavor list (if available) and return EPERM if the specified flavor or
AUTH_NULL(which "matches" any flavor) is not found.Recent changes skip this step and allow the vfs mount even though no operations will succeed, creating a 'dud' mount.
This patch reverts back to the old behavior of matching specified flavors against the server list and also returns EPERM when no sec= is specified and none of the flavors returned by the server are supported by the client.
Example of behavior change:
the server's
/etc/exports:/export/krb5 *(sec=krb5,rw,no_root_squash)
old client behavior:
$ uname -a Linux one.apikia.fake 3.8.8-202.fc18.x86_64 #1 SMP Wed Apr 17 23:25:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:32:04 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 mount.nfs: mount(2): Permission denied mount.nfs: access denied by server while mounting zero:/export/krb5recently changed behavior:
$ uname -a Linux one.apikia.fake 3.9.0-testing+ #2 SMP Fri May 3 20:29:32 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux $ sudo mount -v -o sec=sys,vers=3 zero:/export/krb5 /mnt mount.nfs: timeout set for Sun May 5 17:37:17 2013 mount.nfs: trying text-based options 'sec=sys,vers=3,addr=192.168.100.10' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 192.168.100.10 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=17 mount.nfs: trying 192.168.100.10 prog 100005 vers 3 prot UDP port 20048 $ ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo ls /mnt ls: cannot open directory /mnt: Permission denied $ sudo df /mnt df: ‘/mnt’: Permission denied df: no file systems processed $ sudo umount /mnt $Quoted 1 line
Signed-off-by Weston Andros Adamson <[email protected]>I don't have any hard objections to this patch, so barring the change to return EACCES,
Quoted 8 lines
Acked-by Chuck Lever <[email protected]>Just a nit, perhaps, but...
I think that the optimization of setting the boolean, so that only one walk through the server list is needed, is premature. It might be more clear if each test was done independently of the next to make it easier to reorder the tests, fix bugs in each test, and for readers to see exactly what each of these tests do.
This code is really our only documentation of the security flavor selection process, so making it as clear as possible should be a priority, IMO, over saving a few CPU cycles.
I have no problem with this. Will post a v4 patch.
-dros
Quoted 116 lines
Quoted 108 lines
---
Version 2:
- now just uses specified flavor when:
-AUTH_NULLis in the server list
- flavor is in the server list- now returns EPERM when no sec= specified and no client supported flavors are in the server list
- includes example in the changelog
fs/nfs/super.c| 37 ++++++++++++++++++++++++++++++-------1 file changed, 30 insertions(+), 7 deletions(-)fs/nfs/super.c +23
-4@@ -1611,14 +1611,12 @@ out_security_failure:* Select a security flavor for this mount. The selected flavor * is planted in args->auth_flavors[0]. */ -static void nfs_select_flavor (struct nfs_parsed_mount_data *args, +static int nfs_select_flavor (struct nfs_parsed_mount_data *args,struct nfs_mount_request *request) {unsigned int i, count = *(request->auth_flav_len);rpc_authflavor_t flavor; - -if (args->auth_flavors[0 ] !=RPC_AUTH_MAXFLAVOR ) - goto out; +bool auth_null_seen = false;/* * The NFSv2 MNT operation does not return a flavor list. @@ -1634,6 +1632,21 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args, goto out_default;/* +* If the sec= mount option is used, the specified flavor or AUTH_NULL +* must be in the list returned by the server. +*/ +if (args->auth_flavors[0 ] !=RPC_AUTH_MAXFLAVOR ) { +for (i =0 ; i < count; i++) { +if (args->auth_flavors[0 ] == request->auth_flavs[i] || + request->auth_flavs[i] ==RPC_AUTH_NULL ) + goto out; + } +dfprintk (MOUNT ,"NFS: auth flavor %d not supported server\n" , + args->auth_flavors[0 ]); + goto out_err; + } + +/* * RFC 2623, section 2.7 suggests we SHOULD prefer the * flavor listed first. However, some servers list * AUTH_NULL first. Avoid ever choosing AUTH_NULL. @@ -1646,6 +1659,7 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args,case RPC_AUTH_UNIX : goto out_set;case RPC_AUTH_NULL : + auth_null_seen = true;continue ;default :if (rpcauth_get_gssinfo (flavor, &info) ==0 )@@ -1653,12 +1667,22 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args, } } +if (!auth_null_seen) { +dfprintk (MOUNT ,"NFS: no auth flavors in common with server\n" ); + goto out_err; + } +
out_default:fs/nfs/super.c +3
-1- flavor =RPC_AUTH_UNIX ; +/* use default if flavor not already set */ + flavor = (args->auth_flavors[0 ] ==RPC_AUTH_MAXFLAVOR ) ? +RPC_AUTH_UNIX : args->auth_flavors[0 ];
out_set:args->auth_flavors[0] = flavor; out: dfprintk(MOUNT, "NFS: using auth flavor %d\n", args->auth_flavors[0]);fs/nfs/super.c +3
-0+return 0 ; +out_err: +return -EPERM ;}
/*
fs/nfs/super.c +1
-2@@ -1721,8 +1745,7 @@ static int nfs_request_mount(struct nfs_parsed_mount_data *args,return status; } -nfs_select_flavor (args, &request); -return 0 ; +return nfs_select_flavor (args, &request); } struct dentry *nfs_try_mount(int flags, const char *dev_name,Signature · 6 lines
1.7.12.4 (Apple Git-37) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com