]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mountd/v4root.c
4set_root: force "fsid=0" for all exports of '/'
[nfs-utils.git] / utils / mountd / v4root.c
index 7fd6af3dd4592462addb005c3986031d8f5020ad..b4fdcce611d1fe3e6e7662d8731dc87693e58224 100644 (file)
@@ -83,7 +83,7 @@ v4root_create(char *path, nfs_export *export)
        struct exportent *curexp = &export->m_export;
 
        dupexportent(&eep, &pseudo_root.m_export);
-       eep.e_hostname = strdup(curexp->e_hostname);
+       eep.e_hostname = curexp->e_hostname;
        strncpy(eep.e_path, path, sizeof(eep.e_path));
        if (strcmp(path, "/") != 0)
                eep.e_flags &= ~NFSEXP_FSID;
@@ -144,8 +144,11 @@ static int v4root_add_parents(nfs_export *exp)
        char *ptr;
 
        path = strdup(exp->m_export.e_path);
-       if (!path)
+       if (!path) {
+               xlog(L_WARNING, "v4root_add_parents: Unable to create "
+                               "pseudo export for '%s'", exp->m_export.e_path);
                return -ENOMEM;
+       }
        for (ptr = path + 1; ptr; ptr = strchr(ptr, '/')) {
                int ret;
                char saved;
@@ -173,7 +176,7 @@ void
 v4root_set()
 {
        nfs_export      *exp;
-       int     i, ret;
+       int     i;
 
        if (!v4root_needed)
                return;
@@ -189,7 +192,14 @@ v4root_set()
                                 */
                                continue;
 
-                       ret = v4root_add_parents(exp);
+                       if (strcmp(exp->m_export.e_path, "/") == 0 &&
+                           !(exp->m_export.e_flags & NFSEXP_FSID)) {
+                               /* Force '/' to be exported as fsid == 0*/
+                               exp->m_export.e_flags |= NFSEXP_FSID;
+                               exp->m_export.e_fsid = 0;
+                       }
+
+                       v4root_add_parents(exp);
                        /* XXX: error handling! */
                }
        }