if ( uid != sb.st_uid )
{
seteuid(0);
- if (lchown(upath, sb.st_uid, sb.st_gid) < 0)
+ if (ochown(upath, sb.st_uid, sb.st_gid, vol_syml_opt(vol)) < 0)
{
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error changing owner/gid: %s",
upath, strerror(errno));
ret = AFPERR_ACCESS;
}
- else if ((!S_ISLNK(st->st_mode)) && (chmod_acl(upath,(st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0))
- {
+ else if (ochmod(upath,
+ (st.st_mode & ~default_options.umask) | S_IRGRP | S_IROTH,
+ &sb,
+ vol_syml_opt(vol) | O_NETATALK_ACL) < 0) {
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error adding file read permissions: %s",
upath, strerror(errno));
ret = AFPERR_ACCESS;
}
- else if (lchown(adpath, sb.st_uid, sb.st_gid) < 0)
+ else if (ochown(adpath, sb.st_uid, sb.st_gid, vol_syml_opt(vol)) < 0)
{
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error changing AppleDouble owner/gid: %s",
adpath, strerror(errno));
ret = AFPERR_ACCESS;
}
- else if (chmod_acl(adpath, (st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
+ else if (ochmod(adpath,
+ (st.st_mode & ~default_options.umask) | S_IRGRP| S_IROTH,
+ &st,
+ vol_syml_opt(vol) | O_NETATALK_ACL) < 0)
{
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error adding AD file read permissions: %s",
if ( !isdir ) {
path.st_valid = 1;
path.st_errno = errno;
- if (of_findname(&path)) {
+ if (of_findname(vol, &path)) {
rc = AFPERR_EXIST; /* was AFPERR_BUSY; */
} else {
rc = renamefile(vol, sdir_fd, oldunixname, upath, newname, adp );
fce_register_delete_dir(cfrombstr(dname));
bdestroy(dname);
}
- } else if (of_findname(s_path)) {
+ } else if (of_findname(vol, s_path)) {
rc = AFPERR_BUSY;
} else {
/* it's a file st_valid should always be true
if (!isdir && !vol_unix_priv(vol)) {
int admode = ad_mode("", 0777) | vol->v_fperm;
- setfilmode(upath, admode, NULL, vol->v_umask);
- vol->vfs->vfs_setfilmode(vol, upath, admode, NULL);
+ setfilmode(vol, upath, admode, path->st_valid ? &path->st : NULL);
+ vol->vfs->vfs_setfilmode(vol, upath, admode, path->st_valid ? &path->st : NULL);
}
setvoltime(obj, vol );
}