DaanHoogland commented on code in PR #8530:
URL: https://github.com/apache/cloudstack/pull/8530#discussion_r1636377895


##########
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java:
##########
@@ -1128,17 +1126,19 @@ private void startAdditionalServices() {
         if (result != null) {
             LOGGER.warn("Error in stopping httpd service err=" + result);
         }
-        String port = 
Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT);
-        String intf = TemplateConstants.DEFAULT_TMPLT_COPY_INTF;
 
-        command = new Script("/bin/bash", LOGGER);
-        command.add("-c");
-        command.add("iptables -I INPUT -i " + intf + " -p tcp -m state --state 
NEW -m tcp --dport " + port + " -j ACCEPT;" + "iptables -I INPUT -i " + intf +
-                " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j 
ACCEPT;");
-
-        result = command.execute();
+        IpTablesHelper.addConditionally(IpTablesHelper.INPUT_CHAIN
+                , true
+                , "-i " + TemplateConstants.DEFAULT_TMPLT_COPY_INTF + " -p tcp 
-m state --state NEW -m tcp --dport " + 
TemplateConstants.DEFAULT_TMPLT_COPY_PORT + " -j ACCEPT"
+                , "Error in opening up apache2 port " + 
TemplateConstants.TMPLT_COPY_INTF_PRIVATE + " err=");
+        if (result != null) {

Review Comment:
   thanks, fixed



##########
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java:
##########
@@ -1128,17 +1126,19 @@ private void startAdditionalServices() {
         if (result != null) {
             LOGGER.warn("Error in stopping httpd service err=" + result);
         }
-        String port = 
Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT);
-        String intf = TemplateConstants.DEFAULT_TMPLT_COPY_INTF;
 
-        command = new Script("/bin/bash", LOGGER);
-        command.add("-c");
-        command.add("iptables -I INPUT -i " + intf + " -p tcp -m state --state 
NEW -m tcp --dport " + port + " -j ACCEPT;" + "iptables -I INPUT -i " + intf +
-                " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j 
ACCEPT;");
-
-        result = command.execute();
+        IpTablesHelper.addConditionally(IpTablesHelper.INPUT_CHAIN
+                , true
+                , "-i " + TemplateConstants.DEFAULT_TMPLT_COPY_INTF + " -p tcp 
-m state --state NEW -m tcp --dport " + 
TemplateConstants.DEFAULT_TMPLT_COPY_PORT + " -j ACCEPT"
+                , "Error in opening up apache2 port " + 
TemplateConstants.TMPLT_COPY_INTF_PRIVATE + " err=");
+        if (result != null) {
+            return;
+        }
+        IpTablesHelper.addConditionally(IpTablesHelper.INPUT_CHAIN
+                , true
+                , "-i " + TemplateConstants.DEFAULT_TMPLT_COPY_INTF + " -p tcp 
-m state --state NEW -m tcp --dport 443 -j ACCEPT;"
+                , "Error in opening up apache2 port 443 err=");
         if (result != null) {

Review Comment:
   fixed as well



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to