X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=bin%2Fad%2Fad_util.c;h=27f42b052cec9faff446681358ede8d251d8c557;hp=d994f74f56afa666fe8376d142c882fcf6a83aaa;hb=5eb3b5ac51c8221009041928a5a08c101d2be743;hpb=fbd6b007f0121c117e86d02efa0a88e1e5ff6676 diff --git a/bin/ad/ad_util.c b/bin/ad/ad_util.c index d994f74f..27f42b05 100644 --- a/bin/ad/ad_util.c +++ b/bin/ad/ad_util.c @@ -51,6 +51,9 @@ #ifdef HAVE_SOLARIS_ACLS #include #endif /* HAVE_SOLARIS_ACLS */ +#ifdef HAVE_FREEBSD_SUNACL +#include +#endif #ifdef HAVE_POSIX_ACLS #include @@ -121,12 +124,9 @@ int openvol(AFPObj *obj, const char *path, afpvol_t *vol) if ((vol->vol->v_flags & AFPVOL_NODEV)) flags |= CNID_FLAG_NODEV; - if ((vol->vol->v_cdb = cnid_open(vol->vol->v_path, - 0000, + if ((vol->vol->v_cdb = cnid_open(vol->vol, "dbd", - flags, - vol->vol->v_cnidserver, - vol->vol->v_cnidport)) == NULL) + flags)) == NULL) ERROR("Cant initialize CNID database connection for %s", vol->vol->v_path); cnid_getstamp(vol->vol->v_cdb, @@ -138,9 +138,11 @@ int openvol(AFPObj *obj, const char *path, afpvol_t *vol) void closevol(afpvol_t *vol) { - if (vol->vol->v_cdb) { - cnid_close(vol->vol->v_cdb); - vol->vol->v_cdb = NULL; + if (vol->vol) { + if (vol->vol->v_cdb) { + cnid_close(vol->vol->v_cdb); + vol->vol->v_cdb = NULL; + } } memset(vol, 0, sizeof(afpvol_t)); } @@ -211,20 +213,12 @@ int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol, char *path if ( ! svol->vol->v_path) { /* no source volume: escape special chars (eg ':') */ from = dvol->vol->v_volcharset; /* src = dst charset */ - flags |= CONV_ESCAPEHEX; + if (dvol->vol->v_adouble == AD_VERSION2) + flags |= CONV_ESCAPEHEX; } else { from = svol->vol->v_volcharset; } - if ( (svol->vol->v_path) - && ! (svol->vol->v_flags & AFPVOL_USEDOTS) - && (dvol->vol->v_flags & AFPVOL_USEDOTS)) { - /* source is without dots, destination is with */ - flags |= CONV_UNESCAPEHEX; - } else if (! (dvol->vol->v_flags & AFPVOL_USEDOTS)) { - flags |= CONV_ESCAPEDOTS; - } - int len = convert_charset(from, dvol->vol->v_volcharset, dvol->vol->v_maccharset, @@ -239,73 +233,6 @@ int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol, char *path return 0; } -/*! - * ResolvesCNID of a given paths - * - * path might be: - * (a) relative: - * "dir/subdir" with cwd: "/afp_volume/topdir" - * (b) absolute: - * "/afp_volume/dir/subdir" - * - * path MUST be pointing inside vol, this is usually the case as vol has been build from - * path using loadvolinfo and friends. - * - * @param vol (r) pointer to afpvol_t - * @param path (r) path, see above - * @param did (rw) parent CNID of returned CNID - * - * @returns CNID of path - */ -cnid_t cnid_for_path(const afpvol_t *vol, - const char *path, - cnid_t *did) -{ - EC_INIT; - - cnid_t cnid; - bstring rpath = NULL; - bstring statpath = NULL; - struct bstrList *l = NULL; - struct stat st; - - cnid = htonl(2); - - EC_NULL(rpath = rel_path_in_vol(path, vol->vol->v_path)); - EC_NULL(statpath = bfromcstr(vol->vol->v_path)); - EC_ZERO(bcatcstr(statpath, "/")); - - l = bsplit(rpath, '/'); - for (int i = 0; i < l->qty ; i++) { - *did = cnid; - - EC_ZERO(bconcat(statpath, l->entry[i])); - EC_ZERO_LOGSTR(lstat(cfrombstr(statpath), &st), - "lstat(rpath: %s, elem: %s): %s: %s", - cfrombstr(rpath), cfrombstr(l->entry[i]), - cfrombstr(statpath), strerror(errno)); - - if ((cnid = cnid_add(vol->vol->v_cdb, - &st, - *did, - cfrombstr(l->entry[i]), - blength(l->entry[i]), - 0)) == CNID_INVALID) { - EC_FAIL; - } - EC_ZERO(bcatcstr(statpath, "/")); - } - -EC_CLEANUP: - bdestroy(rpath); - bstrListDestroy(l); - bdestroy(statpath); - if (ret != 0) - return CNID_INVALID; - - return cnid; -} - /*! * Resolves CNID of a given paths parent directory *