summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 2ca4e9b8a60..b6a8a99682d 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -1531,7 +1531,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.
*/
@@ -3973,15 +3973,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);
@@ -4017,6 +4039,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");
@@ -4335,6 +4359,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) {
@@ -4446,10 +4474,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} }
};