X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libatalk%2Futil%2Fnetatalk_conf.c;h=a08ddebd44dafacaf84a7d8b87fc735e627392a3;hb=be799718387d2e6029cccee369b25ba85bb2fade;hp=fdb18f27e5cd2d1a3e113d9b24a89f99d502bc6d;hpb=244bdfbbc36eccfa157056122e466ce2450b02a2;p=netatalk.git diff --git a/libatalk/util/netatalk_conf.c b/libatalk/util/netatalk_conf.c index fdb18f27..a08ddebd 100644 --- a/libatalk/util/netatalk_conf.c +++ b/libatalk/util/netatalk_conf.c @@ -562,8 +562,8 @@ static struct vol *creatvol(AFPObj *obj, { EC_INIT; struct vol *volume = NULL; - int suffixlen, vlen, tmpvlen, u8mvlen, macvlen; - char tmpname[AFPVOL_U8MNAMELEN+1]; + int i, suffixlen, vlen, tmpvlen, u8mvlen, macvlen; + char *tmpname; ucs2_t u8mtmpname[(AFPVOL_U8MNAMELEN+1)*2], mactmpname[(AFPVOL_MACNAMELEN+1)*2]; char suffix[6]; /* max is #FFFF */ uint16_t flags; @@ -642,9 +642,14 @@ static struct vol *creatvol(AFPObj *obj, else EC_NULL( volume->v_maccodepage = strdup(obj->options.maccodepage) ); + vlen = strlen(name); + tmpname = strdup(name); + for(i = 0; i < vlen; i++) + if(tmpname[i] == '/') tmpname[i] = ':'; + bstring dbpath; EC_NULL_LOG( val = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "vol dbpath", _PATH_STATEDIR "CNID/") ); - EC_NULL_LOG( dbpath = bformat("%s/%s/", val, name) ); + EC_NULL_LOG( dbpath = bformat("%s/%s/", val, tmpname) ); EC_NULL_LOG( volume->v_dbpath = strdup(bdata(dbpath)) ); bdestroy(dbpath); @@ -795,12 +800,9 @@ static struct vol *creatvol(AFPObj *obj, /* because v_vid has not been decided yet. */ suffixlen = sprintf(suffix, "#%X", lastvid + 1 ); - - vlen = strlen( name ); - /* Unicode Volume Name */ /* Firstly convert name from unixcharset to UTF8-MAC */ - flags = CONV_IGNORE; + flags = CONV_IGNORE | CONV_ALLOW_SLASH; tmpvlen = convert_charset(obj->options.unixcharset, CH_UTF8_MAC, 0, name, vlen, tmpname, AFPVOL_U8MNAMELEN, &flags); if (tmpvlen <= 0) { strcpy(tmpname, "???"); @@ -810,7 +812,7 @@ static struct vol *creatvol(AFPObj *obj, /* Do we have to mangle ? */ if ( (flags & CONV_REQMANGLE) || (tmpvlen > obj->options.volnamelen)) { if (tmpvlen + suffixlen > obj->options.volnamelen) { - flags = CONV_FORCE; + flags = CONV_FORCE | CONV_ALLOW_SLASH; tmpvlen = convert_charset(obj->options.unixcharset, CH_UTF8_MAC, 0, name, vlen, tmpname, obj->options.volnamelen - suffixlen, &flags); tmpname[tmpvlen >= 0 ? tmpvlen : 0] = 0; } @@ -826,7 +828,7 @@ static struct vol *creatvol(AFPObj *obj, /* Maccharset Volume Name */ /* Firsty convert name from unixcharset to maccharset */ - flags = CONV_IGNORE; + flags = CONV_IGNORE | CONV_ALLOW_SLASH; tmpvlen = convert_charset(obj->options.unixcharset, obj->options.maccharset, 0, name, vlen, tmpname, AFPVOL_U8MNAMELEN, &flags); if (tmpvlen <= 0) { strcpy(tmpname, "???"); @@ -836,7 +838,7 @@ static struct vol *creatvol(AFPObj *obj, /* Do we have to mangle ? */ if ( (flags & CONV_REQMANGLE) || (tmpvlen > AFPVOL_MACNAMELEN)) { if (tmpvlen + suffixlen > AFPVOL_MACNAMELEN) { - flags = CONV_FORCE; + flags = CONV_FORCE | CONV_ALLOW_SLASH; tmpvlen = convert_charset(obj->options.unixcharset, obj->options.maccharset, 0, @@ -891,16 +893,16 @@ static struct vol *creatvol(AFPObj *obj, initvol_vfs(volume); /* get/store uuid from file in afpd master*/ - if (!(pwd) && (volume->v_flags & AFPVOL_TM)) { - char *uuid = get_vol_uuid(obj, volume->v_localname); - if (!uuid) { - LOG(log_error, logtype_afpd, "Volume '%s': couldn't get UUID", - volume->v_localname); - } else { - volume->v_uuid = uuid; - LOG(log_debug, logtype_afpd, "Volume '%s': UUID '%s'", - volume->v_localname, volume->v_uuid); - } + become_root(); + char *uuid = get_vol_uuid(obj, volume->v_localname); + unbecome_root(); + if (!uuid) { + LOG(log_error, logtype_afpd, "Volume '%s': couldn't get UUID", + volume->v_localname); + } else { + volume->v_uuid = uuid; + LOG(log_debug, logtype_afpd, "Volume '%s': UUID '%s'", + volume->v_localname, volume->v_uuid); } /* no errors shall happen beyond this point because the cleanup would mess the volume chain up */ @@ -1025,6 +1027,10 @@ static int readvolfile(AFPObj *obj, const struct passwd *pwent) LOG(log_warning, logtype_afpd, "home name must contain $u."); p = "$u's home"; } + if (strchr(p, ':') != NULL) { + LOG(log_warning, logtype_afpd, "home name must not contain \":\"."); + p = "$u's home"; + } strlcpy(tmp, p, MAXPATHLEN); } else { strlcpy(tmp, secname, AFPVOL_U8MNAMELEN);