]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nfs/exports.c
Merge branch 'upstream'
[nfs-utils.git] / support / nfs / exports.c
index 1048c8074514dfe0167400f07cd7663b2d5cd2f5..e6de71aebfbce484e4c5aae3bf99b87c979408ea 100644 (file)
@@ -14,7 +14,9 @@
  *             as is, with no warranty expressed or implied.
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <sys/param.h>
 #include <stdlib.h>
@@ -67,7 +69,7 @@ struct exportent *
 getexportent(int fromkernel, int fromexports)
 {
        static struct exportent ee;
-       char            exp[512];
+       char            exp[512], *hostname;
        char            rpath[MAXPATHLEN+1];
        char            *opt, *sp;
        int             ok;
@@ -87,8 +89,8 @@ getexportent(int fromkernel, int fromexports)
                ee.e_flags &= ~NFSEXP_GATHERED_WRITES;
        }
        ee.e_maptype = CLE_MAP_IDENT;
-       ee.e_anonuid = -2;
-       ee.e_anongid = -2;
+       ee.e_anonuid = 65534;
+       ee.e_anongid = 65534;
        ee.e_squids = NULL;
        ee.e_sqgids = NULL;
        ee.e_mountpoint = NULL;
@@ -113,9 +115,13 @@ getexportent(int fromkernel, int fromexports)
        /* Check for default client */
        if (ok == 0)
                exp[0] = '\0';
+
+       hostname = exp;
        if ((opt = strchr(exp, '(')) != NULL) {
-               if (opt == exp) 
+               if (opt == exp) {
                        xlog(L_WARNING, "No host name given with %s %s, suggest *%s to avoid warning", ee.e_path, exp, exp);
+                       hostname = "*";
+               }
                *opt++ = '\0';
                if (!(sp = strchr(opt, ')')) || sp[1] != '\0') {
                        syntaxerr("bad option list");
@@ -126,12 +132,12 @@ getexportent(int fromkernel, int fromexports)
        } else {
            xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp);
        }
-       if (strlen(exp) >= sizeof(ee.e_hostname)) {
+       if (strlen(hostname) >= sizeof(ee.e_hostname)) {
                syntaxerr("client name too long");
                export_errno = EINVAL;
                return NULL;
        }
-       strncpy(ee.e_hostname, exp, sizeof (ee.e_hostname) - 1);
+       strncpy(ee.e_hostname, hostname, sizeof (ee.e_hostname) - 1);
        ee.e_hostname[sizeof (ee.e_hostname) - 1] = '\0';
 
        if (parseopts(opt, &ee, fromexports) < 0)
@@ -161,7 +167,7 @@ putexportent(struct exportent *ep)
 
        fp = efp->x_fp;
        for (i=0; esc[i]; i++)
-               if (iscntrl(esc[i]) || esc[i] == '"' || esc[i] == '\\'|| isspace(esc[i]))
+               if (iscntrl(esc[i]) || esc[i] == '"' || esc[i] == '\\' || esc[i] == '#' || isspace(esc[i]))
                        fprintf(fp, "\\%03o", esc[i]);
                else
                        fprintf(fp, "%c", esc[i]);
@@ -265,8 +271,8 @@ mkexportent(char *hname, char *path, char *options)
 
        ee.e_flags = EXPORT_DEFAULT_FLAGS;
        ee.e_maptype = CLE_MAP_IDENT;
-       ee.e_anonuid = -2;
-       ee.e_anongid = -2;
+       ee.e_anonuid = 65534;
+       ee.e_anongid = 65534;
        ee.e_squids = NULL;
        ee.e_sqgids = NULL;
        ee.e_mountpoint = NULL;