diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index 53f09439..537d05ae 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -3123,9 +3123,11 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni, enter_securid(scx, uid, gid, mode, ni->security_id); +#if CACHE_LEGACY_SIZE /* also invalidate legacy cache */ if (isdir && !ni->security_id) invalidate_legacy(scx, ni); +#endif } free(newattr); } else { @@ -3328,7 +3330,7 @@ int ntfs_allowed_access(struct SECURITY_CONTEXT *scx, break; } if (!allow) - errno = EPERM; + errno = EACCES; } return (allow); } @@ -3434,12 +3436,10 @@ int ntfs_set_owner(struct SECURITY_CONTEXT *scx, res = -1; } if (!res) { - /* check requested by owner or root */ + /* check requested by root */ /* for chgrp, group must match owner's */ if (!scx->uid - || ((fileuid == scx->uid) - && (((int)gid < 0) - || (filegid == scx->gid)))) { + && (((int)gid < 0) || (filegid == scx->gid))) { /* replace by the new usid and gsid */ /* or reuse old gid and sid for cacheing */ if ((int)uid < 0) diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index e2afb00b..252f86de 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -381,6 +381,8 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) struct SECURITY_CONTEXT security; vol = ctx->vol; +if (!strcmp(org_path,"/dump")) +dumpall(vol); stream_name_len = ntfs_fuse_parse_path(org_path, &path, &stream_name); if (stream_name_len < 0) return stream_name_len; @@ -896,13 +898,15 @@ static int ntfs_fuse_chown(const char *path, uid_t uid, gid_t gid) return -EOPNOTSUPP; } else { /* parent directory must be executable */ + res = 0; if (ntfs_allowed_dir_access(&security,path,S_IEXEC)) { ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); if (!ni) res = -errno; else { - res = ntfs_set_owner(&security, - path,ni,uid,gid); + if (ntfs_set_owner(&security, + path,ni,uid,gid)) + res = -errno; if (ntfs_inode_close(ni)) set_fuse_error(&res); } @@ -1053,7 +1057,8 @@ static int ntfs_fuse_create(const char *org_path, dev_t typemode, dev_t dev, } else res = -errno; - } + } else + res = -errno; free(path); exit: @@ -1179,7 +1184,7 @@ static int ntfs_fuse_ln(const char *old_path, const char *new_path, int mtime) res = -errno; goto exit; } - + if (!mtime) NInoSetNoMtimeUpdate(ni); @@ -2507,7 +2512,7 @@ int main(int argc, char *argv[]) fc = try_fuse_mount(parsed_options); if (!fc) goto err_out; - + fh = (struct fuse *)1; /* Cast anything except NULL to handle errors. */ if (fuse_opt_add_arg(&margs, "") == -1 || fuse_opt_add_arg(&margs, "-o") == -1)