glusterd: avoid using glusterd's working directory as a brick

Adding checks for avoiding glusterd's working directory used as
a brick for volume creation.

fixes: bz#853601
Change-Id: I4b16a05f752e92216aa628f542a4fdbf59b3c669
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
This commit is contained in:
Sanju Rakonde 2018-09-03 16:26:56 +05:30
parent a880d6f6aa
commit 44e4db05a9
2 changed files with 18 additions and 0 deletions

View File

@ -270,4 +270,13 @@ pkill glusterfsd;
TEST glusterd
TEST $CLI volume status $V1
#bug-853601 - Avoid using /var/lib/glusterd as a brick
TEST ! $CLI volume create "test" $H0:/var/lib/glusterd
TEST ! $CLI volume create "test" $H0:/var/lib/glusterd force
TEST ! $CLI volume create "test" $H0:/var/lib/glusterd/abc
TEST ! $CLI volume create "test" $H0:/var/lib/glusterd/abc force
mkdir -p /xyz/var/lib/glusterd/abc
TEST $CLI volume create "test" $H0:/xyz/var/lib/glusterd/abc
EXPECT 'Created' volinfo_field "test" 'Status';
cleanup

View File

@ -1541,6 +1541,15 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
goto out;
}
if (sizeof(GLUSTERD_DEFAULT_WORKDIR) <= (strlen(brickinfo->path) + 1) &&
!strncmp(brickinfo->path, GLUSTERD_DEFAULT_WORKDIR,
(sizeof(GLUSTERD_DEFAULT_WORKDIR) - 1))) {
len = snprintf (msg, sizeof (msg), "Brick isn't allowed to be "
"created inside glusterd's working directory.");
ret = -1;
goto out;
}
if (!is_force) {
if (brick_st.st_dev != parent_st.st_dev) {
len = snprintf (msg, sizeof (msg), "The brick %s:%s "