move pseudoflavor information to common code
authorJ. Bruce Fields <bfields@citi.umich.edu>
Thu, 5 Jul 2007 17:45:52 +0000 (13:45 -0400)
committerNeil Brown <neilb@suse.de>
Tue, 10 Jul 2007 00:37:38 +0000 (10:37 +1000)
I'd like to be able to use the same pseudoflavor data in exportfs and
mountd; so move it to nfslib and a common include.

Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
support/nfs/exports.c
utils/mount/nfs4_mount.h
utils/mount/nfs4mount.c

index 0baa5d0..ea96400 100644 (file)
 #include "xmalloc.h"
 #include "xlog.h"
 #include "xio.h"
+#include "pseudoflavors.h"
 
 #define EXPORT_DEFAULT_FLAGS   \
   (NFSEXP_READONLY|NFSEXP_ROOTSQUASH|NFSEXP_GATHERED_WRITES|NFSEXP_NOSUBTREECHECK)
 
+struct flav_info flav_map[] = {
+       { "krb5",       RPC_AUTH_GSS_KRB5       },
+       { "krb5i",      RPC_AUTH_GSS_KRB5I      },
+       { "krb5p",      RPC_AUTH_GSS_KRB5P      },
+       { "lipkey",     RPC_AUTH_GSS_LKEY       },
+       { "lipkey-i",   RPC_AUTH_GSS_LKEYI      },
+       { "lipkey-p",   RPC_AUTH_GSS_LKEYP      },
+       { "spkm3",      RPC_AUTH_GSS_SPKM       },
+       { "spkm3i",     RPC_AUTH_GSS_SPKMI      },
+       { "spkm3p",     RPC_AUTH_GSS_SPKMP      },
+       { "unix",       AUTH_UNIX               },
+       { "sys",        AUTH_SYS                },
+       { "null",       AUTH_NULL               },
+       { "none",       AUTH_NONE               },
+};
+
+const int flav_map_size = sizeof(flav_map)/sizeof(flav_map[0]);
+
 int export_errno;
 
 static char    *efname = NULL;
index 2fcca6d..58e311e 100644 (file)
@@ -68,18 +68,6 @@ struct nfs4_mount_data {
 #define NFS4_MOUNT_UNSHARED    0x8000  /* 5 */
 #define NFS4_MOUNT_FLAGMASK    0xFFFF
 
-/* pseudoflavors: */
-
-#define RPC_AUTH_GSS_KRB5       390003
-#define RPC_AUTH_GSS_KRB5I      390004
-#define RPC_AUTH_GSS_KRB5P      390005
-#define RPC_AUTH_GSS_LKEY       390006
-#define RPC_AUTH_GSS_LKEYI      390007
-#define RPC_AUTH_GSS_LKEYP      390008
-#define RPC_AUTH_GSS_SPKM       390009
-#define RPC_AUTH_GSS_SPKMI      390010
-#define RPC_AUTH_GSS_SPKMP      390011
-
 int nfs4mount(const char *, const char *, int *, char **,
        char **, int);
 
index 0376f32..4f6fc5f 100644 (file)
@@ -36,6 +36,7 @@
 #define nfsstat nfs_stat
 #endif
 
+#include "pseudoflavors.h"
 #include "nls.h"
 #include "conn.h"
 #include "xcommon.h"
@@ -71,26 +72,6 @@ char *GSSDLCK = DEFAULT_DIR "/rpcgssd";
 #define NFS_PORT 2049
 #endif
 
-struct {
-       char    *flavour;
-       int     fnum;
-} flav_map[] = {
-       { "krb5",       RPC_AUTH_GSS_KRB5       },
-       { "krb5i",      RPC_AUTH_GSS_KRB5I      },
-       { "krb5p",      RPC_AUTH_GSS_KRB5P      },
-       { "lipkey",     RPC_AUTH_GSS_LKEY       },
-       { "lipkey-i",   RPC_AUTH_GSS_LKEYI      },
-       { "lipkey-p",   RPC_AUTH_GSS_LKEYP      },
-       { "spkm3",      RPC_AUTH_GSS_SPKM       },
-       { "spkm3i",     RPC_AUTH_GSS_SPKMI      },
-       { "spkm3p",     RPC_AUTH_GSS_SPKMP      },
-       { "unix",       AUTH_UNIX               },
-       { "sys",        AUTH_SYS                },
-       { "null",       AUTH_NULL               },
-       { "none",       AUTH_NONE               },
-};
-
-#define FMAPSIZE               (sizeof(flav_map)/sizeof(flav_map[0]))
 #define MAX_USER_FLAVOUR       16
 
 static int parse_sec(char *sec, int *pseudoflavour)
@@ -104,13 +85,13 @@ static int parse_sec(char *sec, int *pseudoflavour)
                                  "exceeded\n"));
                        return 0;
                }
-               for (i = 0; i < FMAPSIZE; i++) {
+               for (i = 0; i < flav_map_size; i++) {
                        if (strcmp(sec, flav_map[i].flavour) == 0) {
                                pseudoflavour[num_flavour++] = flav_map[i].fnum;
                                break;
                        }
                }
-               if (i == FMAPSIZE) {
+               if (i == flav_map_size) {
                        fprintf(stderr,
                                _("mount: unknown security type %s\n"), sec);
                        return 0;
@@ -405,7 +386,7 @@ int nfs4mount(const char *spec, const char *node, int *flags,
 
                printf("sec = ");
                for (pf_cnt = 0; pf_cnt < num_flavour; pf_cnt++) {
-                       for (i = 0; i < FMAPSIZE; i++) {
+                       for (i = 0; i < flav_map_size; i++) {
                                if (flav_map[i].fnum == pseudoflavour[pf_cnt]) {
                                        printf("%s", flav_map[i].flavour);
                                        break;