]> arthur.barton.de Git - netatalk.git/commitdiff
Enhance handling of nested volume paths
authorFrank Lahm <franklahm@googlemail.com>
Tue, 13 Nov 2012 09:17:36 +0000 (10:17 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Thu, 15 Nov 2012 08:42:05 +0000 (09:42 +0100)
Force cnidscheme "last" and read-only behaviour for volumes whos
volume path is a subdirectory (nested) of another volume.

In case cnid scheme is not last, a message is logged with a logvel
of log_note.

libatalk/util/netatalk_conf.c

index fd7ebfd124777e99af77c2748f4f59ca7814e319..8b060e5f6949573e14e18e337535340dff1f5d52 100644 (file)
@@ -571,6 +571,9 @@ static struct vol *creatvol(AFPObj *obj,
     uint16_t    flags;
     const char  *val;
     char        *p, *q;
+    bool        new_vol_nested = false; /* flag whether the new volume path is a subdirectory
+                                        *  of an existing directory in which case we force
+                                        * "last" cnidsheme and read only behaviour */
 
     strlcpy(path, path_in, MAXPATHLEN);
 
@@ -610,12 +613,21 @@ static struct vol *creatvol(AFPObj *obj,
                     shorter_path = path;
                     longer_path = vol->v_path;
                 } else {
+                    new_vol_nested = true;
                     shorter_len = another_pathlen;
                     shorter_path = vol->v_path;
                     longer_path = path;
                 }
-                if (longer_path[shorter_len] == '/')
-                    LOG(log_info, logtype_afpd, "volume \"%s\" paths are nested: \"%s\" and \"%s\"", name, path, vol->v_path);
+                if (longer_path[shorter_len] == '/') {
+                    if (!new_vol_nested && STRCMP(vol->v_cnidscheme, !=, "last")) {
+                        /* the volume "vol" is nested, we must force cnidscheme "last" and read-only */
+                        LOG(log_warning, logtype_afpd, "volume \"%s\" path \"%s\" is nested, set to read-only",
+                            vol->v_configname, vol->v_path);
+                        vol->v_flags = AFPVOL_RO;
+                        free(vol->v_cnidscheme);
+                        vol->v_cnidscheme = strdup("last");
+                    }
+                }
             }
         }
     }
@@ -783,6 +795,14 @@ static struct vol *creatvol(AFPObj *obj,
     if (getoption_bool(obj->iniconfig, section, "root preexec close", preset, 0))
         volume->v_root_preexec_close = 1;
 
+    /* Fixup for nested volume */
+    if (new_vol_nested && strcmp(volume->v_cnidscheme, "last")) {
+        LOG(log_note, logtype_afpd, "volume \"%s\" is changed into cnid last and read only. path is nested: \"%s\"",
+            name, path);
+        free(volume->v_cnidscheme);
+        volume->v_cnidscheme = strdup("last");
+    }
+
     /*
      * Handle read-only behaviour. semantics:
      * 1) neither the rolist nor the rwlist exist -> rw