Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Jones
Collaborator
Collaborator
Jump to solution

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)

1 Solution

Accepted Solutions
Bob_Zimmerman
Authority
Authority

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

View solution in original post

0 Kudos
6 Replies
the_rock
Legend
Legend

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]#

0 Kudos
Bob_Zimmerman
Authority
Authority

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
0 Kudos
Daniel_
Advisor

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

 

Jones
Collaborator
Collaborator

Excellent additions guys!

0 Kudos
Bob_Zimmerman
Authority
Authority

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"
0 Kudos
Daniel_
Advisor

@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....

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events