The scope of a firewall rule is set back to default after installing an update pack - Advanced Installer Community
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

The scope of a firewall rule is set back to default after installing an update pack

Dear Advanced Installer Support Team,

Let me forward an issue to your reported by a customer: he modified the Scope tab of a Firewall Inbound Rule added by our product, but the rules has been set back to default after he installed an update pack (next version) for our product.

Our product contains a service (EXE) and our Advanced Installer product adds a Firewall exception for this EXE. We managed to achieve this by navigating to the "Windows Firewall" tab in AI and added the EXE wit the following condition "Not VersionNT64 AND (&EXEFeature=3 OR !EXEFeature=3)". The scrope of the exception is set to "Local subnet".

Is it normal that each executable we prepare by this AI projcect overwrites the scope settings of the customer? Is there a way of preventing this? For example if the installer finds a Firewall exception with the same name, then the rule is skipped and not added once more?

Thanks in advance for your answer!

Best regards,
Zsolt
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: The scope of a firewall rule is set back to default after installing an update pack

Hello Zsolt,

To achieve what you want you can configure your setup to install the firewall rule only when a first time install is performed. And also to uninstall the firewall rule only when there is performed a regular uninstall, to skip the firewall rule removal during an upgrade installation.

Here is what settings you can try:
1. go to "Windows Firewall" page and use the following condition for your rule:

Code: Select all

(NOT OLDPRODUCTS)
2. go to "Table Editor" page and select the "InstallExecuteSequnce" table
3. edit the "Condition" column of the "AI_FwUninstall" action row like this:

Code: Select all

(VersionNT >= 501) AND (REMOVE="ALL") AND (NOT UPGRADINGPRODUCTCODE)
4. rebuild and test again your setup project

You should configure all of your setup project versions like that. Also, please note that in order to be able to use our "Table Editor" feature you should use at least an "Enterprise" project type.

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hello Daniel,

I followed your instructions and the new results is: the firewall rule is getting removed, but it did not put back, so it's simply missing after I install the modified version of our EXE.

Could you please advise me something, what can be wrong?

Best regards,
Zsolt
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hello Daniel,

After some more testing I can say that:
1. Using the "NOT OLDPRODUCTS" condition at Windows Firewall page is working as expected. Depending on this condition the firewall rule is installed or not.
2. The problem is that our firewall rules are always removed, although we just upgrading our product. No matter what we use as a condition for AI_FwUninstall in "Table Editor" -> "InstallExecuteSequnce", the firewall rules are always gone.
- I tried out your combination: (VersionNT >= 501) AND (REMOVE="ALL") AND (NOT UPGRADINGPRODUCTCODE) but it´s not working
- I also tried out to use "0" (false) as a condition -> our firewall rules were just removed on upgrade.
- I also tried out another false condition (1=2) proposed in one of your AI tickets (http://www.advancedinstaller.com/forums ... hp?t=30750), but the result is still the same: our firewall rules are just gone.

Obviously we have to convince the installer to keep our firewall rules, otherwise all the custom settings of the user (IPs under the Scope tab) will be gone.

Could you please advise us something?

Best regards,
Zsolt
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: The scope of a firewall rule is set back to default after installing an update pack

Hello Zsolt,

This may happen if you didn't add the same changes to the old version of your setup project. Please note that the workaround I previously exposed works only if it is implemented for ALL versions (old and upgraded) of your setup project.

If you already released the old version of your setup package, then as another solution you could develop your own custom action to copy the scheduled task settings of the old version and recreate the old scheduled task.

Also, another solution you can try will be to build a patch which will include the above changes I mentioned and then make sure the patch is applied to the old version of your setup before upgrading it to a newer version implementing the scheduled task install/uninstall conditions.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hi Daniel,

I've just tried out what you've suggested:
1. Created a package which contains the changes you proposed in your first email (changed the condition of my firewall rule under Windows Firewall tab as well as changed the condition of the AI_FwUninstall action of InstallExecuteSequence table under Table Editor tab)
2. Created a newer package (increased version number and product code) with the same changes applied
3. Installed the old package on a Virtual Machine + define some fake IP addressed in "Windows Firewall with Advanced Security"->Inbound Rules -> our_service -> Properties -> Scope tab
4. Installed the new package over the old one -> unfortunately our rule has been again removed and re-added, so the IPs I defined under the Scope tab are again lost. I enabled logging while installing the new package, as far as I can see AI _FwRemove is the action which removes our rules - at least I see the name of our inbound rule at the same line. I had an idea of disabling AI_FwRemove action too in case of upgrading the product, but I could not find such an entry in the InstallExecuteSequence table.

I'm attaching a logfile which contains the relevant section, could you please check why the inbound rule exception for our service is getting removed?

Thanks in advance!

Best regards,
Zsolt
Attachments
FWLog_Snipplet.txt
(4.91 KiB) Downloaded 704 times
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: The scope of a firewall rule is set back to default after installing an update pack

Hello Zsolt,

I'm not aware why this happens. Could you please send the complete verbose log file and the AIPs (project files) of the old and new package version to support at advancedinstaller dot com so I can fully test and investigate them?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Dear Daniel,

One of our customers just reported that his settings under the Scope tab of our Firewall rule is again missing after he installed our latest update package. Since I was testing it a lot, I could not imagine why it happens on his side, but not happening on my side. Finally I managed to understand the difference:

In my preliminary tests:
1. I modified our OLD_PRODUCT based on your proposal and created an EXE.
2. After that I created a NEW_PRODUCT with a DIFFERENT product code (Generate new) and modified NEW_PRODUCT as well based on your proposal.
3. I installed OLD_PRODUCT on a random PC
4. I defined some new IP addresses on the Scope tab of our Firewall inbound rule
5. I installed NEW_PRODUCT over the old one
Result: IPs were kept under Scope tab -> this is what we wanted to achieve.

This is what happened in reality:
1. I modified our OLD_PRODUCT based on your proposal and created an EXE.
2. After that I created a NEW_PRODUCT with the SAME product code (Keep existing) and modified NEW_PRODUCT as well based on your proposal. We decided to release our update pack as a minor update only, we didn´t expect this to have an effect on the firewall solution.
3-5. These steps are the same.
Result: IPs are gone after installing the update pack.

Could you please improve the solution you proposed to work with minor update too? That would be highly appreciated! Please consider this thread as an important one as we need to get back to our customer asap.

Thanks in advance!

Best regards,
Zsolt
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: The scope of a firewall rule is set back to default after installing an update pack

Hello Zsolt,

Can you please edit the first step like this:

1. go to "Windows Firewall" page and use the following condition for your rule:

Code: Select all

(NOT OLDPRODUCTS) AND (NOT AI_DETECTED_MINOR_UPGRADE)
and let us know if this helped?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hi Daniel,

Thanks for the tip, I'm going to try this out.

Best regards,
Zsolt
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: The scope of a firewall rule is set back to default after installing an update pack

You're welcome Zsolt.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hi Daniel,

One more issue we just noticed: under special circumstances our custom firewall rules are not removed on uninstall. The following 2 scenarios might help you in better understanding the problem:

Scenario 1:
1. Both PRODUCT_1.EXE and PRODUDCT_2.EXE are generated with your code snippets - improved condition for adding the FW rules as well as special condition for AI_FWUININSTALL custom action - add to the project.
2. PROCUCT_2 is a MINOR update, i.e. PRODUCT_1 and PRODUCT_2 has the same product code.
3. PRODUCT_1 is installed and some custom IP addresses are added to the Scope of the new FW rules.
4. PRORUCT_2 is installed over PRODUCT_1 -> FW rules were not removed and re-added -> custom IPs are still visible under Scope tab -> everything is as per expected.
5. Uninstall PRODUCT 2 -> our FW rules are removed from the list of incoming rules -> everything is as per expected.

Scenario 2:
Do everything in the exact same way like in Scenario 1 with one difference: PRODUCT_2 has to be a MAJOR update with different product code.
After Step 5 (uninstallation) our FW rules are not removed by the installer, they are still in the incoming rules list -> this is the problem, because we don't want to leave our garbage on the customer's PC.

Could you please also check the uninstallation logfiles for each scenario? In minor_log.log you will see some AI_FwRemove actions which are running for each individual rule. Those lines are missing in major_log.log.

Could you please help us in improving the FW related conditions?

Best regards,
Zsolt
Attachments
major_log.zip
(875.4 KiB) Downloaded 716 times
minor_log.zip
(861.09 KiB) Downloaded 609 times
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hi Daniel,

In my previous post I reported a scenario which leaves FW rules in incoming rules list on uninstall. Let me please extend that with a new scenario.

The previous one happend when I completely uninstall a major update pack from the PC, the current one happens when I just remove features from the existing project.

For example I have a feature called TheWebAccess and a firewall rule for it with this install condition:
"(&TheWebAccess=3 OR !TheWebAccess=3)"
Note: AI_FWUninstall condition in table editor has not been overwritten yet, the product that I use for testing is one of our previous releases without an FW related changes added to it.

After I install the product on a PC, go to Programs and Features and remove the feature called TheWebAccess, I´d expect the belonging FW rule to be removed. But unfortunately it´s not being removed.

Could you please have a look at both uninstall related issues I just posted? I attach a logfile for this uninstall operation too.

Thanks in advance!

Kind regards,
Zsolt
Attachments
uninstall_feature.log.zip
(358.9 KiB) Downloaded 658 times
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: The scope of a firewall rule is set back to default after installing an update pack

Hi Zsolt,

I tested your both scenario and here is what I noticed:
Scenario 2:
Do everything in the exact same way like in Scenario 1 with one difference: PRODUCT_2 has to be a MAJOR update with different product code.
After Step 5 (uninstallation) our FW rules are not removed by the installer, they are still in the incoming rules list -> this is the problem, because we don't want to leave our garbage on the customer's PC.

Could you please also check the uninstallation logfiles for each scenario? In minor_log.log you will see some AI_FwRemove actions which are running for each individual rule. Those lines are missing in major_log.log.
The firewall rules were removed as expected during the uninstall. Furthermore, I noticed that both major and minor log files contain similar lines about the "AI_FwUninstall" custom action.

Do you reproduce the problem on multiple clean machines? If so, can you please send me a sample project that reproduces the problem?
For example I have a feature called TheWebAccess and a firewall rule for it with this install condition:
"(&TheWebAccess=3 OR !TheWebAccess=3)"
Note: AI_FWUninstall condition in table editor has not been overwritten yet, the product that I use for testing is one of our previous releases without an FW related changes added to it.

After I install the product on a PC, go to Programs and Features and remove the feature called TheWebAccess, I´d expect the belonging FW rule to be removed. But unfortunately it´s not being removed.
Please note that the uninstall firewall rules custom action is executed only on a full uninstall of the package, not on the removal of individual features.

If you want to achieve this for a feature, you can go in the "InstallExecuteSequence" table from the "Table Editor" page and set the following condition for the "AI_FwUninstall" row: (VersionNT >= 501) AND (REMOVE="ALL") OR ((&TheWebAccess = 2) AND (!TheWebAccess = 3))

Let me know if this helped.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: The scope of a firewall rule is set back to default after installing an update pack

Hi Eusebiu,

For Scenario 2 I just sent you a mail and attached my .aip project. With that project I can always repro the issue. The FW rules are not removed by the uninstall operation of the product if it was a minor update pack.
Regarding the "AI_FwUninstall" custom action occurrences: you are right those ones are the same, but I pointed you to the lines of AI_FWRemove.

For the "WebAccess" part: Thanks for the tip, we´ll try it out.

Best regards,
Zsolt

Return to “Common Problems”