Need help in writing Analysis Relevance for Linux Folder permission

Requirement : Need to check what permissions are set on Linux Directories like /var, /etc.
Need get those values in Linux fixlets Analysis section.

We’ve a number of inspectors available for filesystem objects in Linux. For reference, please see https://developer.bigfix.com/relevance/search/?query=filesystem%20object&platform=aix%2Chp-ux%2Cmac%2Credhat%2Csuse%2Csolaris%2Cdebian%2Cubuntu%2Craspbian

Are there specific permissions you are looking to query? How would you like the output to look? Without knowing more, below are some examples.

This example returns True/False for each permission bit for read, write, execute across users, groups, and other for the folder or directory “/var”:

((user read of it, user write of it, user execute of it, group read of it, group write of it, group execute of it, other read of it, other write of it, other execute of it) of folder "/var")

If can of course be limited to the specific permission bits of interest.

Here’s an example that performs a simple conversion of the above’s output to symbolic notation:

(((if item 0 of it then "r" else "-") & (if item 1 of it then "w" else "-") & (if item 2 of it then "x" else "-")) & ((if item 3 of it then "r" else "-") & (if item 4 of it then "w" else "-") & (if item 5 of it then "x" else "-")) & ((if item 6 of it then "r" else "-") & (if item 7 of it then "w" else "-") & (if item 8 of it then "x" else "-")) as string) of ((user read of it, user write of it, user execute of it, group read of it, group write of it, group execute of it, other read of it, other write of it, other execute of it) of folder "/var")

Here’s another example that performs a simple conversion of the above’s output to numeric notation:

(((if item 0 of it then 4 else 0) + (if item 1 of it then 2 else 0) + (if item 2 of it then 1 else 0)) as string & ((if item 3 of it then 4 else 0) + (if item 4 of it then 2 else 0) + (if item 5 of it then 1 else 0)) as string & ((if item 6 of it then 4 else 0) + (if item 7 of it then 2 else 0) + (if item 8 of it then 1 else 0)) as string) of ((user read of it, user write of it, user execute of it, group read of it, group write of it, group execute of it, other read of it, other write of it, other execute of it) of folder "/var")

I learnt this just last week which might be a format Linux sysadmins are more used to

Q: mode of folder "/var" as octal string
A: 0755
T: 79
3 Likes

I knew there had to be an easier conversion than what I was doing :slight_smile: Thanks for sharing!

2 Likes