From 949ba93384843d13099dd467aefc61e3b7185997 Mon Sep 17 00:00:00 2001 From: Frank Lahm Date: Tue, 13 Nov 2012 10:17:36 +0100 Subject: [PATCH] Enhance handling of nested volume paths 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 | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libatalk/util/netatalk_conf.c b/libatalk/util/netatalk_conf.c index fd7ebfd1..8b060e5f 100644 --- a/libatalk/util/netatalk_conf.c +++ b/libatalk/util/netatalk_conf.c @@ -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 -- 2.39.2