summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-09-02 15:22:34 +0530
committerAnand Avati <avati@redhat.com>2012-09-14 01:29:27 -0700
commit2635c4a68d82be731461bb3c31188e5dd0093e7d (patch)
tree0f5c7fdc944d0c858c5b883e882a897e139ad727
parent80ef34fea4a8850b6f34dc59dcdfaef989d7b9e5 (diff)
storage/posix: Option to set brick(of a volume)'s root dir's uid/gid
CLI --- gluster volume set VOLNAME owner-uid uid gluster volume set VOLNAME owner-gid gid where uid,gid are the owner's user id and group id respectively that would be set on the root of all brick (backend) fs. TODO: uid/gid should not be -1. Today we don't validate that in CLI. Change-Id: Ib6a2fb5e404691c5fe105a89faaeff3e1ab72e91 BUG: 853842 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/3939 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c4
-rw-r--r--xlators/storage/posix/src/posix.c48
2 files changed, 46 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 81f5ddaf6..c10c8e410 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -228,8 +228,10 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"features.lock-heal", "protocol/server", "lk-heal", NULL, DOC, 0},
{"features.grace-timeout", "protocol/client", "grace-timeout", NULL, NO_DOC, 0},
{"features.grace-timeout", "protocol/server", "grace-timeout", NULL, DOC, 0},
- {"feature.read-only", "features/read-only", "!read-only", "off", DOC, 0},
+ {"features.read-only", "features/read-only", "!read-only", "off", DOC, 0},
{"storage.linux-aio", "storage/posix", NULL, NULL, DOC, 0},
+ {"storage.owner-uid", "storage/posix", "brick-uid", NULL, DOC, 0},
+ {"storage.owner-gid", "storage/posix", "brick-gid", NULL, DOC, 0},
{NULL, }
};
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 9082b4007..dc4fe153e 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -1539,7 +1539,7 @@ posix_link (call_frame_t *frame, xlator_t *this,
/*
* On most systems (Linux being the notable exception), link(2)
* first resolves symlinks. If the target is a directory or
- * is nonexistent, it will fail. linkat(2) operates on the
+ * is nonexistent, it will fail. linkat(2) operates on the
* symlink instead of its target when the AT_SYMLINK_FOLLOW
* flag is not supplied.
*/
@@ -3961,15 +3961,37 @@ mem_acct_init (xlator_t *this)
return ret;
}
+static int
+posix_set_owner (xlator_t *this, uid_t uid, gid_t gid)
+{
+ struct posix_private *priv = NULL;
+ int ret = -1;
+
+ priv = this->private;
+
+ ret = sys_chown (priv->base_path, uid, gid);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ "uid/gid for brick path %s, %s",
+ priv->base_path, strerror (errno));
+
+ return ret;
+}
int
reconfigure (xlator_t *this, dict_t *options)
{
int ret = -1;
struct posix_private *priv = NULL;
+ uid_t uid = -1;
+ gid_t gid = -1;
priv = this->private;
+ GF_OPTION_RECONF ("brick-uid", uid, options, uint32, out);
+ GF_OPTION_RECONF ("brick-gid", gid, options, uint32, out);
+ posix_set_owner (this, uid, gid);
+
GF_OPTION_RECONF ("linux-aio", priv->aio_configured,
options, bool, out);
@@ -4005,6 +4027,8 @@ init (xlator_t *this)
uuid_t gfid = {0,};
uuid_t rootgfid = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
char *guuid = NULL;
+ uid_t uid = -1;
+ gid_t gid = -1;
dir_data = dict_get (this->options, "directory");
@@ -4329,6 +4353,10 @@ init (xlator_t *this)
_private->aio_init_done = _gf_false;
_private->aio_capable = _gf_false;
+ GF_OPTION_INIT ("brick-uid", uid, uint32, out);
+ GF_OPTION_INIT ("brick-gid", gid, uint32, out);
+ posix_set_owner (this, uid, gid);
+
GF_OPTION_INIT ("linux-aio", _private->aio_configured, bool, out);
if (_private->aio_configured) {
@@ -4440,10 +4468,20 @@ struct volume_options options[] = {
{ .key = {"glusterd-uuid"},
.type = GF_OPTION_TYPE_STR },
{
- .key = {"linux-aio"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
- .description = "Support for native Linux AIO"
+ .key = {"linux-aio"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .description = "Support for native Linux AIO"
},
+ {
+ .key = {"brick-uid"},
+ .type = GF_OPTION_TYPE_INT,
+ .description = "Support for setting uid of brick's root"
+ },
+ {
+ .key = {"brick-gid"},
+ .type = GF_OPTION_TYPE_INT,
+ .description = "Support for setting gid of brick's root"
+ },
{ .key = {NULL} }
};