aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/super.c143
1 files changed, 78 insertions, 65 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ebed63e0ff8e..6eb145ea71ac 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -854,6 +854,82 @@ static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
854} 854}
855 855
856/* 856/*
857 * Parse the value of the 'sec=' option.
858 *
859 * The flags setting is for v2/v3. The flavor_len setting is for v4.
860 * v2/v3 also need to know the difference between NULL and UNIX.
861 */
862static int nfs_parse_security_flavors(char *value,
863 struct nfs_parsed_mount_data *mnt)
864{
865 substring_t args[MAX_OPT_ARGS];
866
867 dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value);
868
869 switch (match_token(value, nfs_secflavor_tokens, args)) {
870 case Opt_sec_none:
871 mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
872 mnt->auth_flavor_len = 0;
873 mnt->auth_flavors[0] = RPC_AUTH_NULL;
874 break;
875 case Opt_sec_sys:
876 mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
877 mnt->auth_flavor_len = 0;
878 mnt->auth_flavors[0] = RPC_AUTH_UNIX;
879 break;
880 case Opt_sec_krb5:
881 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
882 mnt->auth_flavor_len = 1;
883 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
884 break;
885 case Opt_sec_krb5i:
886 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
887 mnt->auth_flavor_len = 1;
888 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
889 break;
890 case Opt_sec_krb5p:
891 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
892 mnt->auth_flavor_len = 1;
893 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
894 break;
895 case Opt_sec_lkey:
896 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
897 mnt->auth_flavor_len = 1;
898 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
899 break;
900 case Opt_sec_lkeyi:
901 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
902 mnt->auth_flavor_len = 1;
903 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
904 break;
905 case Opt_sec_lkeyp:
906 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
907 mnt->auth_flavor_len = 1;
908 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
909 break;
910 case Opt_sec_spkm:
911 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
912 mnt->auth_flavor_len = 1;
913 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
914 break;
915 case Opt_sec_spkmi:
916 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
917 mnt->auth_flavor_len = 1;
918 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
919 break;
920 case Opt_sec_spkmp:
921 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
922 mnt->auth_flavor_len = 1;
923 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
924 break;
925 default:
926 return 0;
927 }
928
929 return 1;
930}
931
932/*
857 * Error-check and convert a string of mount options from user space into 933 * Error-check and convert a string of mount options from user space into
858 * a data structure 934 * a data structure
859 */ 935 */
@@ -1054,73 +1130,10 @@ static int nfs_parse_mount_options(char *raw,
1054 string = match_strdup(args); 1130 string = match_strdup(args);
1055 if (string == NULL) 1131 if (string == NULL)
1056 goto out_nomem; 1132 goto out_nomem;
1057 token = match_token(string, nfs_secflavor_tokens, args); 1133 rc = nfs_parse_security_flavors(string, mnt);
1058 kfree(string); 1134 kfree(string);
1059 1135 if (!rc)
1060 /*
1061 * The flags setting is for v2/v3. The flavor_len
1062 * setting is for v4. v2/v3 also need to know the
1063 * difference between NULL and UNIX.
1064 */
1065 switch (token) {
1066 case Opt_sec_none:
1067 mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
1068 mnt->auth_flavor_len = 0;
1069 mnt->auth_flavors[0] = RPC_AUTH_NULL;
1070 break;
1071 case Opt_sec_sys:
1072 mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
1073 mnt->auth_flavor_len = 0;
1074 mnt->auth_flavors[0] = RPC_AUTH_UNIX;
1075 break;
1076 case Opt_sec_krb5:
1077 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1078 mnt->auth_flavor_len = 1;
1079 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
1080 break;
1081 case Opt_sec_krb5i:
1082 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1083 mnt->auth_flavor_len = 1;
1084 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
1085 break;
1086 case Opt_sec_krb5p:
1087 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1088 mnt->auth_flavor_len = 1;
1089 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
1090 break;
1091 case Opt_sec_lkey:
1092 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1093 mnt->auth_flavor_len = 1;
1094 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
1095 break;
1096 case Opt_sec_lkeyi:
1097 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1098 mnt->auth_flavor_len = 1;
1099 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
1100 break;
1101 case Opt_sec_lkeyp:
1102 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1103 mnt->auth_flavor_len = 1;
1104 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
1105 break;
1106 case Opt_sec_spkm:
1107 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1108 mnt->auth_flavor_len = 1;
1109 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
1110 break;
1111 case Opt_sec_spkmi:
1112 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1113 mnt->auth_flavor_len = 1;
1114 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
1115 break;
1116 case Opt_sec_spkmp:
1117 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1118 mnt->auth_flavor_len = 1;
1119 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
1120 break;
1121 default:
1122 goto out_unrec_sec; 1136 goto out_unrec_sec;
1123 }
1124 break; 1137 break;
1125 case Opt_proto: 1138 case Opt_proto:
1126 string = match_strdup(args); 1139 string = match_strdup(args);