- CheckMates
- :
- Products
- :
- General Topics
- :
- Re: Firewall and SecureXL Mode: User / Kernel
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Firewall and SecureXL Mode: User / Kernel
Here is a oneliner to show the Firewall and SecureXL mode (User or Kernel):
M=`cpprod_util FwIsUsermode`; [ $M == 1 ] && { M="User Mode"; } || { M="Kernel Mode"; }; echo "Firewall is: $M"; M=`cpprod_util SxlIsUsermode`; [ $M == 1 ] && { M="User Mode"; } || { M="Kernel Mode"; }; echo "SecureXL is: $M" |
The output for example:
Firewall is: User Mode SecureXL is: Kernel Mode |
This oneliner is based on Heiko's earlier oneliner found here: Firewall Mode: User / Kernel - Check Point CheckMates
Finding the SecureXL mode is much more easy now instead of interpreting the output of the command: fwaccel stat (UPPAK or KPPAK)
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two fairly minor notes:
Backticks are a bad way to work with subshells. The recommended way to run a command in a subshell for substitution purposes is $(...), because then it's unambiguous where the subshell's input ends. Makes it easier to nest this chunk of code in a larger script.
You don't actually need the braces and semicolons in the then and else clauses.
Here are the lines with those two changes applied:
[Expert@TestFW]# M=$(cpprod_util FwIsUsermode);[ $M == 1 ] && M="User Mode" || M="Kernel Mode";echo "Firewall is: $M"
Firewall is: User Mode
[Expert@TestFW]# M=$(cpprod_util SxlIsUsermode);[ $M == 1 ] && M="User Mode" || M="Kernel Mode";echo "SecureXL is: $M"
SecureXL is: Kernel Mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nice, just tried it in the lab.
Awesome.
Andy
[Expert@CP-GW:0]# M=`cpprod_util FwIsUsermode`; [ $M == 1 ] && { M="User Mode"; } || { M="Kernel Mode"; }; echo "Firewall is: $M"; M=`cpprod_util SxlIsUsermode`; [ $M == 1 ] && { M="User Mode"; } || { M="Kernel Mode"; }; echo "SecureXL is: $M"
Firewall is: User Mode
SecureXL is: Kernel Mode
[Expert@CP-GW:0]#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two fairly minor notes:
Backticks are a bad way to work with subshells. The recommended way to run a command in a subshell for substitution purposes is $(...), because then it's unambiguous where the subshell's input ends. Makes it easier to nest this chunk of code in a larger script.
You don't actually need the braces and semicolons in the then and else clauses.
Here are the lines with those two changes applied:
[Expert@TestFW]# M=$(cpprod_util FwIsUsermode);[ $M == 1 ] && M="User Mode" || M="Kernel Mode";echo "Firewall is: $M"
Firewall is: User Mode
[Expert@TestFW]# M=$(cpprod_util SxlIsUsermode);[ $M == 1 ] && M="User Mode" || M="Kernel Mode";echo "SecureXL is: $M"
SecureXL is: Kernel Mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With some more (performance) optimization, as real oneliner and without a M variable 😉
[[ $(cpprod_util FwIsUsermode) -eq 1 ]] && echo Firewall is: User Mode || echo Firewall is: Kernel Mode
[[ $(cpprod_util SxlIsUsermode) -eq 1 ]] && echo SecureXL is: User Mode || echo SecureXL is: Kernel Mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Excellent additions guys!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're going to go that far, you may as well extract the common parts of the echo and use a second level of subshell (which shows why $(...) is preferred over backticks):
echo "Firewall is $([ $(cpprod_util FwIsUsermode) == 1 ] && echo User || echo Kernel) Mode"
echo "SecureXL is $([ $(cpprod_util SxlIsUsermode) == 1 ] && echo User || echo Kernel) Mode"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Bob_Zimmerman I had thought about that too, but you are going to loos a few ticks to create a second subshell, but with GHz CPUs it's just a theoretical problem....
