almeidajeff commented on code in PR #3729: URL: https://github.com/apache/ambari/pull/3729#discussion_r1287658599
########## ambari-server/src/main/python/ambari_server/serverSetup.py: ########## @@ -846,11 +847,11 @@ def adjust_jce_permissions(self, jdk_path): cmd = " && ".join(cmds) - process = subprocess32.Popen(cmd, + process = subprocess32.Popen(shlex.split(cmd), Review Comment: In this part of the code it is possible to get an error due to the fact that the && character is used to chain multiple commands together in a shell environment (like bash on Linux), but when you pass your command to subprocess32.Popen it does not will be interpreted by a shell, so the && will not be recognized as a valid operator. In addition to the command being used '*' and this can be a problem with the use of shlex, so I suggest using the glob module. As a suggestion, you have the code below that I developed ``` if ambari_user: cmds.append(self.SET_JCE_PERMISSIONS.format(ambari_user, jdk_path, configDefaults.JDK_SECURITY_DIR)) cmds.append(self.SET_JCE_FILE_MODE.format(jdk_path, configDefaults.JDK_SECURITY_DIR, "*")) cmds.append(self.SET_JCE_JAR_MODE.format(jdk_path, configDefaults.JDK_SECURITY_DIR, "*.jar")) for cmd in cmds: if '*' in cmd: try: cmd_parts = shlex.split(cmd) files_to_process = glob.glob(cmd_parts[-1]) for file_path in files_to_process: cmd_parts[-1] = file_path process = subprocess32.Popen(cmd_parts, stdout=subprocess32.PIPE, stdin=subprocess32.PIPE, stderr=subprocess32.PIPE, shell=False ) (stdoutdata, stderrdata) = process.communicate() if process.returncode != 0: print("Failed to change permissions for '{0}'. Stderr: {1}".format(file_path, stderrdata)) except Exception as e: print("Error executing command: {0}".format(str(e))) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@ambari.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ambari.apache.org For additional commands, e-mail: dev-h...@ambari.apache.org