return res;
}
-int Client::_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid,
- InodeRef *inp)
+int Client::_setattr(Inode *in, struct stat *attr, int mask,
+ const UserPerm& perms, InodeRef *inp)
{
- // FIXME
- UserPerm perms(uid, gid);
int ret = _do_setattr(in, attr, mask, perms, inp);
if (ret < 0)
return ret;
return ret;
}
-int Client::_setattr(InodeRef &in, struct stat *attr, int mask)
+int Client::_setattr(InodeRef &in, struct stat *attr, int mask,
+ const UserPerm& perms)
{
mask &= (CEPH_SETATTR_MODE | CEPH_SETATTR_UID |
CEPH_SETATTR_GID | CEPH_SETATTR_MTIME |
CEPH_SETATTR_ATIME | CEPH_SETATTR_SIZE |
CEPH_SETATTR_CTIME);
if (cct->_conf->client_permissions) {
- int r = may_setattr(in.get(), attr, mask);
+ int r = may_setattr(in.get(), attr, mask, perms);
if (r < 0)
return r;
}
- return _setattr(in.get(), attr, mask);
+ return _setattr(in.get(), attr, mask, perms);
}
-int Client::setattr(const char *relpath, struct stat *attr, int mask)
+int Client::setattr(const char *relpath, struct stat *attr, int mask,
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
tout(cct) << "setattr" << std::endl;
filepath path(relpath);
InodeRef in;
- int r = path_walk(path, &in);
+ int r = path_walk(path, &in, perms);
if (r < 0)
return r;
- return _setattr(in, attr, mask);
+ return _setattr(in, attr, mask, perms);
}
-int Client::fsetattr(int fd, struct stat *attr, int mask)
+int Client::fsetattr(int fd, struct stat *attr, int mask,
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
tout(cct) << "fsetattr" << std::endl;
if (f->flags & O_PATH)
return -EBADF;
#endif
- return _setattr(f->inode, attr, mask);
+ return _setattr(f->inode, attr, mask, perms);
}
int Client::stat(const char *relpath, struct stat *stbuf,
{
struct stat attr;
attr.st_size = length;
- return setattr(relpath, &attr, CEPH_SETATTR_SIZE);
+ // FIXME
+ UserPerm perms(get_uid(), get_gid());
+ return setattr(relpath, &attr, CEPH_SETATTR_SIZE, perms);
}
int Client::ftruncate(int fd, loff_t length)
const UserPerm& perms, InodeRef *inp = 0);
int _do_setattr(Inode *in, struct stat *attr, int mask, const UserPerm& perms,
InodeRef *inp);
- int _setattr(Inode *in, struct stat *attr, int mask, int uid=-1, int gid=-1, InodeRef *inp = 0);
int _setattr(Inode *in, struct stat *attr, int mask, const UserPerm& perms,
+ InodeRef *inp = 0);
+ int _setattr(Inode *in, struct stat *attr, int mask, int uid=-1, int gid=-1,
InodeRef *inp = 0) {
- return _setattr(in, attr, mask, perms.uid(), perms.gid(), inp);
+ UserPerm perms(uid, gid);
+ return _setattr(in, attr, mask, perms, inp);
+ }
+ int _setattr(InodeRef &in, struct stat *attr, int mask,
+ const UserPerm& perms);
+ int _setattr(InodeRef &in, struct stat *attr, int mask) {
+ UserPerm perms(get_uid(), get_gid());
+ return _setattr(in, attr, mask, perms);
}
- int _setattr(InodeRef &in, struct stat *attr, int mask);
int _getattr(Inode *in, int mask, int uid=-1, int gid=-1, bool force=false);
int _getattr(InodeRef &in, int mask, int uid=-1, int gid=-1, bool force=false) {
return _getattr(in.get(), mask, uid, gid, force);
int lstat(const char *path, struct stat *stbuf, frag_info_t *dirstat=0, int mask=CEPH_STAT_CAP_INODE_ALL);
int lstatlite(const char *path, struct statlite *buf);
- int setattr(const char *relpath, struct stat *attr, int mask);
- int fsetattr(int fd, struct stat *attr, int mask);
+ int setattr(const char *relpath, struct stat *attr, int mask, const UserPerm& perms);
+ int fsetattr(int fd, struct stat *attr, int mask, const UserPerm& perms);
int chmod(const char *path, mode_t mode);
int fchmod(int fd, mode_t mode);
int lchmod(const char *path, mode_t mode);
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->get_client()->setattr(relpath, attr, mask);
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_client()->setattr(relpath, attr, mask, perms);
}
// *xattr() calls supporting samba/vfs