X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fexports.c;h=ea96400d79ca73f9292855a06d593c9ae3eea716;hp=9b010dc6901e6e7ef51e4f865c778ae522676233;hb=e9b0bed761bc77ba046f53be2ec324c4b61357ff;hpb=b5a542ab44c4d3430cf68dcacc60f06a204b15cd diff --git a/support/nfs/exports.c b/support/nfs/exports.c index 9b010dc..ea96400 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -30,9 +30,28 @@ #include "xmalloc.h" #include "xlog.h" #include "xio.h" +#include "pseudoflavors.h" #define EXPORT_DEFAULT_FLAGS \ - (NFSEXP_READONLY|NFSEXP_ROOTSQUASH|NFSEXP_GATHERED_WRITES) + (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; @@ -48,7 +67,6 @@ static int getpath(char *path, int len); static int parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr); static int parsesquash(char *list, int **idp, int *lenp, char **ep); static int parsenum(char **cpp); -static int parsemaptype(char *type); static void freesquash(void); static void syntaxerr(char *msg); @@ -94,12 +112,13 @@ getexportent(int fromkernel, int fromexports) def_ee.e_flags &= ~NFSEXP_ASYNC; def_ee.e_flags &= ~NFSEXP_GATHERED_WRITES; } - def_ee.e_maptype = CLE_MAP_IDENT; def_ee.e_anonuid = 65534; def_ee.e_anongid = 65534; def_ee.e_squids = NULL; def_ee.e_sqgids = NULL; def_ee.e_mountpoint = NULL; + def_ee.e_fslocmethod = FSLOC_NONE; + def_ee.e_fslocdata = NULL; def_ee.e_nsquids = 0; def_ee.e_nsqgids = 0; @@ -220,24 +239,28 @@ putexportent(struct exportent *ep) if (ep->e_flags & NFSEXP_FSID) { fprintf(fp, "fsid=%d,", ep->e_fsid); } + if (ep->e_uuid) + fprintf(fp, "fsid=%s,", ep->e_uuid); if (ep->e_mountpoint) fprintf(fp, "mountpoint%s%s,", ep->e_mountpoint[0]?"=":"", ep->e_mountpoint); - - fprintf(fp, "mapping="); - switch (ep->e_maptype) { - case CLE_MAP_IDENT: - fprintf(fp, "identity,"); + switch (ep->e_fslocmethod) { + case FSLOC_NONE: + break; + case FSLOC_REFER: + fprintf(fp, "refer=%s,", ep->e_fslocdata); break; - case CLE_MAP_UGIDD: - fprintf(fp, "ugidd,"); + case FSLOC_REPLICA: + fprintf(fp, "replicas=%s,", ep->e_fslocdata); break; - case CLE_MAP_FILE: - fprintf(fp, "file,"); +#ifdef DEBUG + case FSLOC_STUB: + fprintf(fp, "fsloc=stub,"); break; +#endif default: - xlog(L_ERROR, "unknown mapping type for %s:%s", - ep->e_hostname, ep->e_path); + xlog(L_ERROR, "unknown fsloc method for %s:%s", + ep->e_hostname, ep->e_path); } if ((id = ep->e_squids) != NULL) { fprintf(fp, "squash_uids="); @@ -286,6 +309,8 @@ dupexportent(struct exportent *dst, struct exportent *src) } if (src->e_mountpoint) dst->e_mountpoint = strdup(src->e_mountpoint); + if (src->e_fslocdata) + dst->e_fslocdata = strdup(src->e_fslocdata); } struct exportent * @@ -294,14 +319,16 @@ mkexportent(char *hname, char *path, char *options) static struct exportent ee; ee.e_flags = EXPORT_DEFAULT_FLAGS; - ee.e_maptype = CLE_MAP_IDENT; ee.e_anonuid = 65534; ee.e_anongid = 65534; ee.e_squids = NULL; ee.e_sqgids = NULL; ee.e_mountpoint = NULL; + ee.e_fslocmethod = FSLOC_NONE; + ee.e_fslocdata = NULL; ee.e_nsquids = 0; ee.e_nsqgids = 0; + ee.e_uuid = NULL; if (strlen(hname) >= sizeof(ee.e_hostname)) { xlog(L_WARNING, "client name %s too long", hname); @@ -330,6 +357,17 @@ updateexportent(struct exportent *eep, char *options) return 1; } + +static int valid_uuid(char *uuid) +{ + /* must have 32 hex digits */ + int cnt; + for (cnt = 0 ; *uuid; uuid++) + if (isxdigit(*uuid)) + cnt++; + return cnt == 32; +} + /* * Parse option string pointed to by cp and set mount options accordingly. */ @@ -410,12 +448,6 @@ parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr) ep->e_flags &= ~NFSEXP_NOACL; else if (strcmp(opt, "no_acl") == 0) ep->e_flags |= NFSEXP_NOACL; - else if (strncmp(opt, "mapping=", 8) == 0) - ep->e_maptype = parsemaptype(opt+8); - else if (strcmp(opt, "map_identity") == 0) /* old style */ - ep->e_maptype = CLE_MAP_IDENT; - else if (strcmp(opt, "map_daemon") == 0) /* old style */ - ep->e_maptype = CLE_MAP_UGIDD; else if (strncmp(opt, "anonuid=", 8) == 0) { char *oe; ep->e_anonuid = strtol(opt+8, &oe, 10); @@ -445,13 +477,21 @@ bad_option: } } else if (strncmp(opt, "fsid=", 5) == 0) { char *oe; - ep->e_fsid = strtoul(opt+5, &oe, 0); - if (opt[5]=='\0' || *oe != '\0') { - xlog(L_ERROR, "%s: %d: bad fsid \"%s\"\n", - flname, flline, opt); - goto bad_option; + if (strcmp(opt+5, "root") == 0) { + ep->e_fsid = 0; + ep->e_flags |= NFSEXP_FSID; + } else { + ep->e_fsid = strtoul(opt+5, &oe, 0); + if (opt[5]!='\0' && *oe == '\0') + ep->e_flags |= NFSEXP_FSID; + else if (valid_uuid(opt+5)) + ep->e_uuid = strdup(opt+7); + else { + xlog(L_ERROR, "%s: %d: bad fsid \"%s\"\n", + flname, flline, opt); + goto bad_option; + } } - ep->e_flags |= NFSEXP_FSID; } else if (strcmp(opt, "mountpoint")==0 || strcmp(opt, "mp") == 0 || strncmp(opt, "mountpoint=", 11)==0 || @@ -461,6 +501,22 @@ bad_option: ep->e_mountpoint = strdup(mp+1); else ep->e_mountpoint = strdup(""); +#ifdef DEBUG + } else if (strncmp(opt, "fsloc=", 6) == 0) { + if (strcmp(opt+6, "stub") == 0) + ep->e_fslocmethod = FSLOC_STUB; + else { + xlog(L_ERROR, "%s:%d: bad option %s\n", + flname, flline, opt); + goto bad_option; + } +#endif + } else if (strncmp(opt, "refer=", 6) == 0) { + ep->e_fslocmethod = FSLOC_REFER; + ep->e_fslocdata = strdup(opt+6); + } else if (strncmp(opt, "replicas=", 9) == 0) { + ep->e_fslocmethod = FSLOC_REPLICA; + ep->e_fslocdata = strdup(opt+9); } else { xlog(L_ERROR, "%s:%d: unknown keyword \"%s\"\n", flname, flline, opt); @@ -480,8 +536,8 @@ bad_option: out: if (warn && !had_subtree_opt) xlog(L_WARNING, "%s [%d]: Neither 'subtree_check' or 'no_subtree_check' specified for export \"%s:%s\".\n" - " Assuming default behaviour ('subtree_check').\n" - " NOTE: this default will change with nfs-utils version 1.1.0\n", + " Assuming default behaviour ('no_subtree_check').\n" + " NOTE: this default has changed since nfs-utils version 1.0.x\n", flname, flline, ep->e_hostname, ep->e_path); @@ -563,19 +619,6 @@ parsenum(char **cpp) return num; } -static int -parsemaptype(char *type) -{ - if (!strcmp(type, "identity")) - return CLE_MAP_IDENT; - if (!strcmp(type, "ugidd")) - return CLE_MAP_UGIDD; - if (!strcmp(type, "file")) - return CLE_MAP_FILE; - syntaxerr("invalid map type"); - return CLE_MAP_IDENT; /* default */ -} - static int getpath(char *path, int len) {