Fix: gpexpand to automatically set data directory permissions to 0750 (#1848)

Injects logic into the `_configure_new_segments` method of `gpexpand`
to automatically correct segment data directory permissions during
cluster expansion.
diff --git a/gpMgmt/bin/gpexpand b/gpMgmt/bin/gpexpand
index dcbed91..1d36a5a 100755
--- a/gpMgmt/bin/gpexpand
+++ b/gpMgmt/bin/gpexpand
@@ -846,6 +846,24 @@
         # and mirror information
         update_pg_hba_on_segments(self.gparray, self.isHbaHostnames, self.batch_size, expanded_host_content)
 
+        new_segments = self.gparray.getExpansionSegDbList()
+        chmod_commands_by_host = defaultdict(list)
+
+        for seg in new_segments:
+            if seg.isSegmentMirror():
+                continue
+            datadir = seg.getSegmentDataDirectory()
+            hostname = seg.getSegmentHostName()
+            chmod_commands_by_host[hostname].append("chmod 0750 '%s'" % datadir)
+
+        for host, commands in chmod_commands_by_host.items():
+            if commands:
+                self.pool.addCommand(Command(name='gpexpand fix permissions on %s' % host,
+                                 cmdStr=" && ".join(commands), ctxt=REMOTE, remoteHost=host))
+
+        self.pool.join()
+        self.pool.check_results()
+
         self._start_new_primary_segments()
         self._stop_new_primary_segments()