887953
From 39bf395e91021dd51d53c312d6e02638267c3a6b Mon Sep 17 00:00:00 2001
887953
From: Kotresh HR <khiremat@redhat.com>
887953
Date: Tue, 20 Nov 2018 12:36:55 +0530
887953
Subject: [PATCH 516/529] geo-rep: Fix permissions with non-root setup
887953
887953
Problem:
887953
In non-root fail-over/fail-back(FO/FB), when slave is
887953
promoted as master, the session goes to 'Faulty'
887953
887953
Cause:
887953
The command 'gluster-mountbroker <mountbroker-root> <group>'
887953
is run as a pre-requisite on slave in non-root setup.
887953
It modifies the permission and group of following required
887953
directories and files recursively
887953
887953
  [1] /var/lib/glusterd/geo-replication
887953
  [2] /var/log/glusterfs/geo-replication-slaves
887953
887953
In a normal setup, this is executed on slave node and hence
887953
doing it recursively is not an issue on [1]. But when original
887953
master becomes slave in non-root during FO/FB, it contains
887953
ssh public keys and modifying permissions on them causes
887953
geo-rep to fail with incorrect permissions.
887953
887953
Fix:
887953
Don't do permission change recursively. Fix permissions for
887953
required files.
887953
887953
Backport of:
887953
 > Patch: https://review.gluster.org/#/c/glusterfs/+/21689/
887953
 > BUG: bz#1651498
887953
 > Change-Id: I68a744644842e3b00abc26c95c06f123aa78361d
887953
 > Signed-off-by: Kotresh HR <khiremat@redhat.com>
887953
887953
BUG: 1510752
887953
Change-Id: I68a744644842e3b00abc26c95c06f123aa78361d
887953
Signed-off-by: Kotresh HR <khiremat@redhat.com>
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/162463
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
887953
---
887953
 geo-replication/src/peer_mountbroker.py.in | 12 +++++++++---
887953
 1 file changed, 9 insertions(+), 3 deletions(-)
887953
887953
diff --git a/geo-replication/src/peer_mountbroker.py.in b/geo-replication/src/peer_mountbroker.py.in
887953
index be182c5..5be16a2 100644
887953
--- a/geo-replication/src/peer_mountbroker.py.in
887953
+++ b/geo-replication/src/peer_mountbroker.py.in
887953
@@ -8,6 +8,7 @@ from gluster.cliutils import (execute, Cmd, node_output_ok,
887953
 from prettytable import PrettyTable
887953
 
887953
 LOG_DIR = "@localstatedir@/log/glusterfs/geo-replication-slaves"
887953
+CLI_LOG = "@localstatedir@/log/glusterfs/cli.log"
887953
 GEOREP_DIR = "@GLUSTERD_WORKDIR@/geo-replication"
887953
 GLUSTERD_VOLFILE = "@GLUSTERD_VOLFILE@"
887953
 
887953
@@ -142,7 +143,7 @@ class NodeSetup(Cmd):
887953
     # chgrp -R <grp> /var/log/glusterfs/geo-replication-slaves
887953
     # chgrp -R <grp> /var/lib/glusterd/geo-replication
887953
     # chmod -R 770 /var/log/glusterfs/geo-replication-slaves
887953
-    # chmod -R 770 /var/lib/glusterd/geo-replication
887953
+    # chmod 770 /var/lib/glusterd/geo-replication
887953
     # mkdir -p <mnt_root>
887953
     # chmod 0711 <mnt_root>
887953
     # If selinux,
887953
@@ -192,8 +193,13 @@ class NodeSetup(Cmd):
887953
 
887953
         execute(["chgrp", "-R", args.group, GEOREP_DIR])
887953
         execute(["chgrp", "-R", args.group, LOG_DIR])
887953
-        execute(["chmod", "-R", "770", GEOREP_DIR])
887953
-        execute(["chmod", "-R", "770", args.group, LOG_DIR])
887953
+        execute(["chgrp", args.group, CLI_LOG])
887953
+        execute(["chmod", "770", args.group, GEOREP_DIR])
887953
+        execute(["find", LOG_DIR, "-type", "d", "-exec", "chmod", "770", "{}",
887953
+                 "+"])
887953
+        execute(["find", LOG_DIR, "-type", "f", "-exec", "chmod", "660", "{}",
887953
+                 "+"])
887953
+        execute(["chmod", "660", CLI_LOG])
887953
 
887953
         m.set_mount_root_and_group(args.mount_root, args.group)
887953
         m.save()
887953
-- 
887953
1.8.3.1
887953