Open-AudIT
https://www.open-audit.org/phpBB3/

OSX Audit script Bug in 1.4
https://www.open-audit.org/phpBB3/viewtopic.php?f=20&t=6356
Page 1 of 1

Author:  Oeser [ Tue Aug 26, 2014 1:44 am ]
Post subject:  OSX Audit script Bug in 1.4

I found a bug in the current OSX Script 1.4. I got a parse error when the script checked the hard drive size. I found out that the bc command get two numbers with a comma and the command fails. So my solution is to include the commands with a replacment of the comma to a point. Something like that should it be:

partition_size=`echo "$vol" | cut -d":" -f2 | cut -d" " -f2 | sed 's/^ *//g' | sed 's/ *$//g' |[color=#FF0000] tr , .[/color]`
partition_free_space=`echo "$vol" | cut -d":" -f2 | cut -d" " -f2 | sed 's/^ *//g' | sed 's/ *$//g' |[color=#FF0000] tr , .[/color]`
hard_drive_size=`echo "$line" | cut -d":" -f2 | cut -d" " -f2 | sed 's/^ *//g' | sed 's/ *$//g' | [color=#FF0000]tr , .[/color]`

Note: There are multiple sections where you have to add the command.

Author:  shanimal [ Sat Sep 20, 2014 6:18 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

When I made this change, the script stopped working (it wouldn't get a successful audit). The error is

tr,.: command not found

Author:  jpa [ Sat Sep 20, 2014 7:22 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

Probably "tr , ." not "tr,.". Lost some spaces in there.

Author:  shanimal [ Thu Sep 25, 2014 6:06 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

Ok, with those extra spaces in there, the script doesn't work anymore. Here is the error

Attachments:
OSX-FAIL.JPG
OSX-FAIL.JPG [ 44.71 KiB | Viewed 13403 times ]

Author:  jpa [ Thu Sep 25, 2014 6:23 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

I should have said I'm totally guessing and suck at CLI stuff.

How about if you try "tr ',' '.'" instead?

[code]partition_size=`echo "$vol" | cut -d":" -f2 | cut -d" " -f2 | sed 's/^ *//g' | sed 's/ *$//g' | tr ',' '.'`[/code]

Also, I don't have a MacOS machine to test so I'm not even sure what the root problem is. I would guess that it is a localization thing where Oeser's computer is reporting "3000,00" instead of "3000.00" which then breaks a later calculation.

Author:  jpa [ Thu Sep 25, 2014 6:36 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

Although now that I actually look at the error message I wonder how adding the tr stuff could have caused the given error.

Author:  shanimal [ Fri Sep 26, 2014 5:40 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

I probably hosed the script when trying to edit it in OSX which seems to have the most lame text editor. Doesn't even list what line you are on. I'm going to try to find some time to start over. Here is what I get for disk info with the current script before I blew it up trying to make these edits. I wonder if oeser could post his script with his changes?

Attachments:
OSX-Disk.JPG
OSX-Disk.JPG [ 33.82 KiB | Viewed 13393 times ]

Author:  Mark [ Fri Sep 26, 2014 7:33 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

My OSX disks looks like the below.
BTW - Sublime Text is a great editor and available on OSX, Linux and Windows...

[attachment=0] osx_disks.png
osx_disks.png [ 221.81 KiB | Viewed 13391 times ]

Author:  shanimal [ Sat Sep 27, 2014 5:08 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

I had a chance to try again with the clean 1.4 script. I also audited another OSX server. Here is what I found:

- system running OSX 10.9.5 still has blank disk space info (same as the pic I posted previously)

- system running OSX 10.8.5 audited fine, got similar results to what Mark posted here

I haven't tried to edit the script again yet with these changes, but I did install Sublime text (thanks for that tip, Mark) looks MUCH better that the default text editor.

Author:  Mark [ Mon Sep 29, 2014 9:28 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

Make sure you run the script as root (use sudo).
Check out the extensions using PackageControl (for SublimeText) at [url]https://sublime.wbond.net/[/url].

Author:  shanimal [ Thu Dec 18, 2014 5:19 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

Just audited using version 1.5.2 and OSX 10.8.5 works fine, the disk info is accurate. With OSX 10.9.5 the system audits, but the disk info isn't showing, and there is an error concerning volumes (see attached)

Attachments:
volumes.JPG
volumes.JPG [ 90.86 KiB | Viewed 12908 times ]

Author:  Mark [ Thu Dec 18, 2014 9:36 am ]
Post subject:  Re: OSX Audit script Bug in 1.4

I have fixed the undefined variable $volumes. It will be in the 1.5.3 (next) release.

I've also added [code]| sed 's/,/./g'[/code] to the end of any code (in audit_osx.sh) that retrieves a number that we then need to calculate. Again, this will be in 1.5.3.

Page 1 of 1 All times are UTC + 10 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/