#include <atalk/errchk.h>
#include <atalk/globals.h>
#include <atalk/fce_api.h>
+#include <atalk/netatalk_conf.h>
#include "directory.h"
#include "dircache.h"
* 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 )
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;
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 ));
char *upath;
struct dir *dir;
- int bit, isad = 1;
+ int bit, isad = 0;
int cdate, bdate;
int owner, group;
uint16_t ashort, bshort, oshort;
mode_t mpriv = 0;
bool set_upriv = false, set_maccess = false;
- LOG(log_debug, logtype_afpd, "setdirparams(%s)", path->u_name);
+ LOG(log_debug, logtype_afpd, "setdirparams(\"%s\", bitmap: %02x)", path->u_name, bitmap);
bit = 0;
upath = path->u_name;
bitmap = bitmap>>1;
bit++;
}
- ad_init(&ad, vol);
- if (ad_open(&ad, upath, ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_CREATE | ADFLAGS_RDWR, 0777) != 0) {
- /*
- * Check to see what we're trying to set. If it's anything
- * but ACCESS, UID, or GID, give an error. If it's any of those
- * three, we don't need the ad to be open, so just continue.
- *
- * note: we also don't need to worry about mdate. also, be quiet
- * if we're using the noadouble option.
- */
-
- if (d_bitmap & ~((1<<DIRPBIT_ACCESS)
- | (1<<DIRPBIT_UNIXPR)
- | (1<<DIRPBIT_UID)
- | (1<<DIRPBIT_GID)
- | (1<<DIRPBIT_MDATE)
- | (1<<DIRPBIT_PDINFO))) {
+ if (d_bitmap & ((1<<DIRPBIT_ATTR) | (1<<DIRPBIT_CDATE) | (1<<DIRPBIT_BDATE) | (1<<DIRPBIT_FINFO))) {
+ ad_init(&ad, vol);
+ if (ad_open(&ad, upath, ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_CREATE | ADFLAGS_RDWR, 0777) != 0) {
+ LOG(log_debug, logtype_afpd, "setdirparams(\"%s\", bitmap: %02x): need adouble", path->u_name, d_bitmap);
return AFPERR_ACCESS;
}
-
- isad = 0;
- } else {
- /*
- * Check to see if a create was necessary. If it was, we'll want
- * to set our name, etc.
- */
- if ( (ad_get_MD_flags( &ad ) & O_CREAT)) {
+ if ((ad_get_MD_flags(&ad) & O_CREAT)) {
ad_setname(&ad, cfrombstr(curdir->d_m_name));
}
+ isad = 1;
}
bit = 0;
utime(upath, &ut);
}
- if ( isad ) {
+ if (isad) {
if (path->st_valid && !path->st_errno) {
struct stat *st = &path->st;
-
if (dir && dir->d_pdid) {
ad_setid(&ad, st->st_dev, st->st_ino, dir->d_did, dir->d_pdid, vol->v_stamp);
}
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);
+ }
}
}