X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fdirectory.c;h=17f9c754ebfa498019586f6a31e9a510bbd18bbe;hb=b501c0b10a93f0740a0f5d3e82b56c9a047e5334;hp=1f2eda1f9f0be9f73e5cb504e9f809d3962807c2;hpb=05701d289025c26cea41937d69109ad58e24437b;p=netatalk.git diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 1f2eda1f..17f9c754 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.85 2008-05-23 06:35:49 didg Exp $ + * $Id: directory.c,v 1.86 2008-08-31 13:25:57 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -601,86 +601,6 @@ struct dir *dir; return pdir; } -#define ENUMVETO "./../Network Trash Folder/TheVolumeSettingsFolder/TheFindByContentFolder/:2eDS_Store/Contents/Desktop Folder/Trash/Benutzer/" - -int -caseenumerate(const struct vol *vol, struct path *path, struct dir *dir) -{ - DIR *dp; - struct dirent *de; - int ret; - static u_int32_t did = 0; - static char cname[MAXPATHLEN]; - static char lname[MAXPATHLEN]; - ucs2_t u2_path[MAXPATHLEN]; - ucs2_t u2_dename[MAXPATHLEN]; - char *tmp, *savepath; - - if (veto_file(ENUMVETO, path->u_name)) - return -1; - - savepath = path->u_name; - - /* very simple cache */ - if ( dir->d_did == did && strcmp(lname, path->u_name) == 0) { - path->u_name = cname; - path->d_dir = NULL; - if (of_stat( path ) == 0 ) { - return 0; - } - /* something changed, we cannot stat ... */ - did = 0; - } - - if (NULL == ( dp = opendir( "." )) ) { - LOG(log_debug, logtype_afpd, "caseenumerate: opendir failed: %s", dir->d_u_name); - return -1; - } - - - /* LOG(log_debug, logtype_afpd, "caseenumerate: for %s", path->u_name); */ - if ((size_t) -1 == convert_string(vol->v_volcharset, CH_UCS2, path->u_name, strlen(path->u_name), u2_path, sizeof(u2_path)) ) - LOG(log_debug, logtype_afpd, "caseenumerate: conversion failed for %s", path->u_name); - - /*LOG(log_debug, logtype_afpd, "caseenumerate: dir: %s, path: %s", dir->d_u_name, path->u_name); */ - ret = -1; - for ( de = readdir( dp ); de != NULL; de = readdir( dp )) { - if (NULL == check_dirent(vol, de->d_name)) - continue; - - if ((size_t) -1 == convert_string(vol->v_volcharset, CH_UCS2, de->d_name, strlen(de->d_name), u2_dename, sizeof(u2_dename)) ) - continue; - - if (strcasecmp_w( u2_path, u2_dename) == 0) { - tmp = path->u_name; - strlcpy(cname, de->d_name, sizeof(cname)); - path->u_name = cname; - path->d_dir = NULL; - if (of_stat( path ) == 0 ) { - LOG(log_debug, logtype_afpd, "caseenumerate: using dir: %s, path: %s", de->d_name, path->u_name); - strlcpy(lname, tmp, sizeof(lname)); - did = dir->d_did; - ret = 0; - break; - } - else - path->u_name = tmp; - } - - } - closedir(dp); - - if (ret) { - /* invalidate cache */ - memset(cname, 0, sizeof(cname)); - did = 0; - path->u_name = savepath; - } - /* LOG(log_debug, logtype_afpd, "caseenumerate: path on ret: %s", path->u_name); */ - return ret; -} - - /* * attempt to extend the current dir. tree to include path * as a side-effect, movecwd to that point and return the new dir @@ -698,10 +618,7 @@ struct path *path; return NULL; } if (of_stat( path ) != 0 ) { - if (!(vol->v_flags & AFPVOL_CASEINSEN)) - return NULL; - else if(caseenumerate(vol, path, dir) != 0) - return(NULL); + return NULL; } if (!S_ISDIR(path->st.st_mode)) { @@ -1252,7 +1169,7 @@ const struct vol *vol; struct dir *dir; char **cpath; { - struct dir *cdir, *scdir=NULL; + struct dir *cdir; static char path[ MAXPATHLEN + 1]; static struct path ret; @@ -1384,51 +1301,19 @@ char **cpath; } } if ( !extend ) { - ucs2_t *tmpname; - cdir = dir->d_child; - scdir = NULL; - if ( cdir && (vol->v_flags & AFPVOL_CASEINSEN) && - (size_t)-1 != convert_string_allocate(((ret.m_type == 3)?CH_UTF8_MAC:vol->v_maccharset), - CH_UCS2, path, strlen(path), (char **)&tmpname) ) - { - while (cdir) { - if (!cdir->d_m_name_ucs2) { - LOG(log_error, logtype_afpd, "cname: no UCS2 name for %s (did %u)!!!", cdir->d_m_name, ntohl(cdir->d_did) ); - /* this shouldn't happen !!!! */ - goto noucsfallback; - } - - if ( strcmp_w( cdir->d_m_name_ucs2, tmpname ) == 0 ) { - break; - } - if ( strcasecmp_w( cdir->d_m_name_ucs2, tmpname ) == 0 ) { - scdir = cdir; - } - cdir = (cdir == dir->d_child->d_prev) ? NULL :cdir->d_next; - } - free(tmpname); - } - else { -noucsfallback: - if (dir->d_did == DIRDID_ROOT_PARENT) { + if (dir->d_did == DIRDID_ROOT_PARENT) { /* root parent has only one child and d_m_name is *NOT* utm (d_u_name) * d_m_name is the Mac volume name * d_u_name is the volume unix directory name * */ - cdir = NULL; - if (!strcmp(vol->v_dir->d_m_name, ret.m_name)) { + cdir = NULL; + if (!strcmp(vol->v_dir->d_m_name, ret.m_name)) { cdir = vol->v_dir; - } - } - else { - cdir = dirsearch_byname(vol, dir, ret.u_name); } } - - if (cdir == NULL && scdir != NULL) { - cdir = scdir; - /* LOG(log_debug, logtype_afpd, "cname: using casediff for %s, (%s = %s)", fullpathname(cdir->d_u_name), cdir->d_m_name, path ); */ + else { + cdir = dirsearch_byname(vol, dir, ret.u_name); } if ( cdir == NULL ) {