// ----------
// xattrs
-int Client::getxattr(const char *path, const char *name, void *value, size_t size)
+int Client::getxattr(const char *path, const char *name, void *value, size_t size,
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
InodeRef in;
- int r = Client::path_walk(path, &in, true);
+ int r = Client::path_walk(path, &in, perms, true);
if (r < 0)
return r;
- return _getxattr(in, name, value, size);
+ return _getxattr(in, name, value, size, perms);
}
-int Client::lgetxattr(const char *path, const char *name, void *value, size_t size)
+int Client::lgetxattr(const char *path, const char *name, void *value, size_t size,
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
InodeRef in;
- int r = Client::path_walk(path, &in, false);
+ int r = Client::path_walk(path, &in, perms, false);
if (r < 0)
return r;
- return _getxattr(in, name, value, size);
+ return _getxattr(in, name, value, size, perms);
}
-int Client::fgetxattr(int fd, const char *name, void *value, size_t size)
+int Client::fgetxattr(int fd, const char *name, void *value, size_t size,
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
- return _getxattr(f->inode, name, value, size);
+ return _getxattr(f->inode, name, value, size, perms);
}
int Client::listxattr(const char *path, char *list, size_t size)
}
int Client::_getxattr(Inode *in, const char *name, void *value, size_t size,
- int uid, int gid)
+ const UserPerm& perms)
{
int r;
goto out;
}
- r = _getattr(in, CEPH_STAT_CAP_XATTR, uid, gid, in->xattr_version == 0);
+ r = _getattr(in, CEPH_STAT_CAP_XATTR, perms, in->xattr_version == 0);
if (r == 0) {
string n(name);
r = -ENODATA;
- if (in->xattrs.count(n)) {
+ if (in->xattrs.count(n)) {
r = in->xattrs[n].length();
if (r > 0 && size != 0) {
if (size >= (unsigned)r)
return r;
}
-int Client::_getxattr(InodeRef &in, const char *name, void *value, size_t size)
+int Client::_getxattr(InodeRef &in, const char *name, void *value, size_t size,
+ const UserPerm& perms)
{
if (cct->_conf->client_permissions) {
int r = xattr_permission(in.get(), name, MAY_READ);
if (r < 0)
return r;
}
- UserPerm perms(0, 0); // FIXME
return _getxattr(in.get(), name, value, size, perms);
}
}
int _readlink(Inode *in, char *buf, size_t size);
int _getxattr(Inode *in, const char *name, void *value, size_t len,
- int uid=-1, int gid=-1);
- int _getxattr(InodeRef &in, const char *name, void *value, size_t len);
- int _getxattr(Inode *in, const char *name, void *value, size_t len,
- const UserPerm& perms) {
- return _getxattr(in, name, value, len, perms.uid(), perms.gid());
- }
+ const UserPerm& perms);
+ int _getxattr(InodeRef &in, const char *name, void *value, size_t len,
+ const UserPerm& perms);
int _listxattr(Inode *in, char *names, size_t len, int uid=-1, int gid=-1);
int _listxattr(Inode *in, char *names, size_t len, const UserPerm& perms) {
return _listxattr(in, names, len, perms.uid(), perms.gid());
int fallocate(int fd, int mode, loff_t offset, loff_t length);
// full path xattr ops
- int getxattr(const char *path, const char *name, void *value, size_t size);
- int lgetxattr(const char *path, const char *name, void *value, size_t size);
- int fgetxattr(int fd, const char *name, void *value, size_t size);
+ int getxattr(const char *path, const char *name, void *value, size_t size,
+ const UserPerm& perms);
+ int lgetxattr(const char *path, const char *name, void *value, size_t size,
+ const UserPerm& perms);
+ int fgetxattr(int fd, const char *name, void *value, size_t size,
+ const UserPerm& perms);
int listxattr(const char *path, char *list, size_t size);
int llistxattr(const char *path, char *list, size_t size);
int flistxattr(int fd, char *list, size_t size);
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->get_client()->getxattr(path, name, value, size);
+
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_client()->getxattr(path, name, value, size, perms);
}
extern "C" int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->get_client()->lgetxattr(path, name, value, size);
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_client()->lgetxattr(path, name, value, size, perms);
}
extern "C" int ceph_fgetxattr(struct ceph_mount_info *cmount, int fd, const char *name, void *value, size_t size)
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->get_client()->fgetxattr(fd, name, value, size);
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_client()->fgetxattr(fd, name, value, size, perms);
}