#include <atalk/errchk.h>
#include <atalk/globals.h>
#include <atalk/fce_api.h>
+#include <atalk/netatalk_conf.h>
#include "directory.h"
#include "dircache.h"
char *t;
cnid_t fileid = 0;
- if (afp_version >= 30) {
+ if (vol->v_obj->afp_version >= 30) {
if (toUTF8) {
if (dir->d_did == DIRDID_ROOT_PARENT) {
/*
/* duplicate work but we can't reuse all convert_char we did in demangle_osx
* flags weren't the same
*/
- if ( (t = utompath(vol, ret->u_name, fileid, utf8_encoding())) ) {
+ if ( (t = utompath(vol, ret->u_name, fileid, utf8_encoding(vol->v_obj))) ) {
/* at last got our view of mac name */
strcpy(ret->m_name, t);
}
/* If we haven't got it by now, get it */
if (ret->u_name == NULL) {
- if ((ret->u_name = mtoupath(vol, ret->m_name, dir->d_did, utf8_encoding())) == NULL) {
+ if ((ret->u_name = mtoupath(vol, ret->m_name, dir->d_did, utf8_encoding(vol->v_obj))) == NULL) {
afp_errno = AFPERR_PARAM;
return -1;
}
goto exit;
}
- utf8 = utf8_encoding();
+ utf8 = utf8_encoding(vol->v_obj);
maxpath = (utf8) ? MAXPATHLEN - 7 : 255;
/* Get it from the database */
return NULL;
}
- if (convert_string_allocate( (utf8_encoding()) ? CH_UTF8_MAC : vol->v_maccharset,
+ if (convert_string_allocate( (utf8_encoding(vol->v_obj)) ? CH_UTF8_MAC : vol->v_maccharset,
CH_UCS2,
m_name,
-1, (char **)&dir->d_m_name_ucs2) == (size_t)-1 ) {
/* Get macname from unixname */
if (path->m_name == NULL) {
- if ((path->m_name = utompath(vol, path->u_name, id, utf8_encoding())) == NULL) {
+ if ((path->m_name = utompath(vol, path->u_name, id, utf8_encoding(vol->v_obj))) == NULL) {
LOG(log_error, logtype_afpd, "dir_add(\"%s\"): can't assign macname", path->u_name);
err = 2;
goto exit;
data++;
len = (unsigned char) *data++;
size = 2;
- if (afp_version >= 30) {
+ if (vol->v_obj->afp_version >= 30) {
ret.m_type = 3;
toUTF8 = 1;
}
break;
case 3:
- if (afp_version >= 30) {
+ if (vol->v_obj->afp_version >= 30) {
data++;
memcpy(&hint, data, sizeof(hint));
hint = ntohl(hint);
* If we aren't the file's owner we can't change its perms when moving it and smb
* nfs,... don't even try.
*/
-#define AFP_CHECK_ACCESS
-
-int check_access(char *path, int mode)
+int check_access(const AFPObj *obj, struct vol *vol, char *path, int mode)
{
-#ifdef AFP_CHECK_ACCESS
struct maccess ma;
char *p;
if (!p)
return -1;
- accessmode(current_vol, p, &ma, curdir, NULL);
+ accessmode(obj, vol, p, &ma, curdir, NULL);
if ((mode & OPENACC_WR) && !(ma.ma_user & AR_UWRITE))
return -1;
if ((mode & OPENACC_RD) && !(ma.ma_user & AR_UREAD))
return -1;
-#endif
+
return 0;
}
/* --------------------- */
-int file_access(struct path *path, int mode)
+int file_access(const AFPObj *obj, struct vol *vol, struct path *path, int mode)
{
struct maccess ma;
- accessmode(current_vol, path->u_name, &ma, curdir, &path->st);
+ accessmode(obj, vol, path->u_name, &ma, curdir, &path->st);
LOG(log_debug, logtype_afpd, "file_access(\"%s\"): mapped user mode: 0x%02x",
path->u_name, ma.ma_user);
(name, dir) with curdir:name == dir, from afp_enumerate
*/
-int getdirparams(const struct vol *vol,
+int getdirparams(const AFPObj *obj,
+ const struct vol *vol,
uint16_t bitmap, struct path *s_path,
struct dir *dir,
char *buf, size_t *buflen )
if ((s_path->m_name = utompath(vol,
upath,
dir->d_did,
- utf8_encoding())) == NULL) {
+ utf8_encoding(obj))) == NULL) {
LOG(log_error, logtype_afpd,
"getdirparams(\"%s\"): can't assign macname",
cfrombstr(dir->d_fullpath));
break;
case DIRPBIT_ACCESS :
- accessmode(vol, upath, &ma, dir , st);
+ accessmode(obj, vol, upath, &ma, dir , st);
*data++ = ma.ma_user;
*data++ = ma.ma_world;
Just pass back the same basic block for all
directories. <shirsch@ibm.net> */
case DIRPBIT_PDINFO :
- if (afp_version >= 30) { /* UTF8 name */
+ if (obj->afp_version >= 30) { /* UTF8 name */
utf8 = kTextEncodingUTF8;
if (dir->d_m_name) /* root of parent can have a null name */
utf_nameoff = data;
case DIRPBIT_UNIXPR :
/* accessmode may change st_mode with ACLs */
- accessmode(vol, upath, &ma, dir, st);
+ accessmode(obj, vol, upath, &ma, dir, st);
aint = htonl(st->st_uid);
memcpy( data, &aint, sizeof( aint ));
ProDOS information block. Skip over the data and
report nothing amiss. <shirsch@ibm.net> */
case DIRPBIT_PDINFO :
- if (afp_version < 30) {
+ if (vol->v_obj->afp_version < 30) {
buf += 6;
}
else {
case DIRPBIT_ACCESS :
break;
case DIRPBIT_PDINFO :
- if (afp_version >= 30) {
+ if (vol->v_obj->afp_version >= 30) {
err = AFPERR_BITMAP;
goto setdirparam_done;
}
goto setprivdone;
}
}
- if (setdirmode(vol, upath, mpriv) < 0)
+ if (setdirunixmode(vol, upath, mpriv) < 0) {
+ LOG(log_info, logtype_afpd, "setdirparams(\"%s\"): setdirunixmode: %s",
+ fullpathname(upath), strerror(errno));
err = set_dir_errors(path, "setdirmode", errno);
+ }
}
if ((set_upriv == true) && vol_unix_priv(vol)) {
if (dir->d_did == DIRDID_ROOT) {
}
if (setdirowner(vol, upath, -1, ntohl(group)) < 0) {
+ LOG(log_info, logtype_afpd, "setdirparams(\"%s\"): setdirowner: %s",
+ fullpathname(upath), strerror(errno));
err = set_dir_errors(path, "setdirowner", errno);
goto setprivdone;
}
-
- if (setdirunixmode(vol, upath, upriv) < 0)
+ if (setdirunixmode(vol, upath, upriv) < 0) {
+ LOG(log_info, logtype_afpd, "setdirparams(\"%s\"): setdirunixmode: %s",
+ fullpathname(upath), strerror(errno));
err = set_dir_errors(path, "setdirunixmode", errno);
+ }
}
}
err = vol->vfs->vfs_deletecurdir(vol);
if (err) {
LOG(log_error, logtype_afpd, "deletecurdir: error deleting .AppleDouble in \"%s\"",
- curdir->d_fullpath);
+ cfrombstr(curdir->d_fullpath));
return err;
}
*rbuflen = 0;
if (sfunc >= 3 && sfunc <= 6) {
- if (afp_version < 30) {
+ if (obj->afp_version < 30) {
return( AFPERR_PARAM );
}
utf8 = 1;
case 5 : /* UUID -> username */
case 6 : /* UUID -> groupname */
- if ((afp_version < 32) || !(obj->options.flags & OPTION_UUID ))
+ if ((obj->afp_version < 32) || !(obj->options.flags & OPTION_UUID ))
return AFPERR_PARAM;
LOG(log_debug, logtype_afpd, "afp_mapid: valid UUID request");
uuidtype_t type;
return( AFP_OK );
}
-int afp_mapname(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
+int afp_mapname(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
{
struct passwd *pw;
struct group *gr;
ibuf++;
sfunc = (unsigned char) *ibuf++;
*rbuflen = 0;
- LOG(log_debug, logtype_afpd, "afp_mapname: sfunc: %d, afp_version: %d", sfunc, afp_version);
+ LOG(log_debug, logtype_afpd, "afp_mapname: sfunc: %d", sfunc);
switch ( sfunc ) {
case 1 :
case 2 : /* unicode */
- if (afp_version < 30) {
+ if (obj->afp_version < 30) {
return( AFPERR_PARAM );
}
memcpy(&ulen, ibuf, sizeof(ulen));
break;
case 5 : /* username -> UUID */
case 6 : /* groupname -> UUID */
- if ((afp_version < 32) || !(obj->options.flags & OPTION_UUID ))
+ if ((obj->afp_version < 32) || !(obj->options.flags & OPTION_UUID ))
return AFPERR_PARAM;
memcpy(&ulen, ibuf, sizeof(ulen));
len = ntohs(ulen);