Skip to content

Commit

Permalink
Merge pull request #11526 from ukernel/wip-17591
Browse files Browse the repository at this point in the history
client: get caller's uid/gid on every libcephfs operation

Reviewed-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Greg Farnum <gfarnum@redhat.com>
  • Loading branch information
gregsfortytwo committed Oct 20, 2016
2 parents d77fae5 + 91a46b1 commit 71d4043
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/client/Client.h
Expand Up @@ -292,14 +292,14 @@ class Client : public Dispatcher, public md_config_obs_t {
void tick();

UserPerm pick_my_perms() {
uid_t uid = user_id >= 0 ? user_id : ::geteuid();
gid_t gid = group_id >= 0 ? group_id : ::getegid();
uid_t uid = user_id >= 0 ? user_id : -1;
gid_t gid = group_id >= 0 ? group_id : -1;
return UserPerm(uid, gid);
}

static UserPerm pick_my_perms(CephContext *c) {
uid_t uid = c->_conf->client_mount_uid >= 0 ? c->_conf->client_mount_uid : ::geteuid();
gid_t gid = c->_conf->client_mount_gid >= 0 ? c->_conf->client_mount_gid : ::getegid();
uid_t uid = c->_conf->client_mount_uid >= 0 ? c->_conf->client_mount_uid : -1;
gid_t gid = c->_conf->client_mount_gid >= 0 ? c->_conf->client_mount_gid : -1;
return UserPerm(uid, gid);
}
protected:
Expand Down
4 changes: 2 additions & 2 deletions src/client/UserPerm.h
Expand Up @@ -65,8 +65,8 @@ struct UserPerm
return *this;
}

uid_t uid() const { return m_uid; }
gid_t gid() const { return m_gid; }
uid_t uid() const { return m_uid != (uid_t)-1 ? m_uid : ::geteuid(); }
gid_t gid() const { return m_gid != (gid_t)-1 ? m_gid : ::getegid(); }
bool gid_in_groups(gid_t gid) const {
if (gid == m_gid) return true;
for (int i = 0; i < gid_count; ++i) {
Expand Down

0 comments on commit 71d4043

Please sign in to comment.