From: J. Bruce Fields Date: Thu, 5 Jul 2007 17:45:52 +0000 (-0400) Subject: move pseudoflavor information to common code X-Git-Tag: nfs-utils-1-1-1~157 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e9b0bed761bc77ba046f53be2ec324c4b61357ff;p=nfs-utils.git move pseudoflavor information to common code 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" Signed-off-by: Neil Brown --- diff --git a/support/nfs/exports.c b/support/nfs/exports.c index 0baa5d0..ea96400 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -30,10 +30,29 @@ #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; diff --git a/utils/mount/nfs4_mount.h b/utils/mount/nfs4_mount.h index 2fcca6d..58e311e 100644 --- a/utils/mount/nfs4_mount.h +++ b/utils/mount/nfs4_mount.h @@ -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); diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c index 0376f32..4f6fc5f 100644 --- a/utils/mount/nfs4mount.c +++ b/utils/mount/nfs4mount.c @@ -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;