Thank you so much for your time. I know you have much better things to do than this. But I think we're getting there. Munki code seems absolutely fine. It appears to be user (permission?) related. I noticed that when I start a python shell with root priviledges, it does not fetch a time and then subtracts the time zone difference. That explains the negative value:
cd /usr/local/munki
sudo ./munki-python
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:25:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Foundation import NSDate, NSTimeZone
>>> from munkilib import reports
>>> the_date = NSDate.dateWithString_(reports.report.get('StartTime', reports.format_time()))
>>> print(the_date)
None
>>> timezone = NSTimeZone.defaultTimeZone()
>>> print(timezone)
Europe/Zurich (GMT+1) offset 3600
>>> seconds_offset = timezone.secondsFromGMTForDate_(the_date)
>>> print(seconds_offset)
3600
>>> new_date = NSDate.alloc().initWithTimeInterval_sinceDate_(seconds_offset, the_date)
>>> print(new_date)
-5877520-03-03 -8:-31:-23 +0000
>>>
Same as root user:
ash-3.2$ sudo -i
cd /user/local/munki
macmini2:munki root# ./munki-python
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:25:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Foundation import NSDate, NSTimeZone
>>> the_date = NSDate.dateWithString_(reports.report.get('StartTime', reports.format_time()))
>>> print(the_date)
>>> timezone = NSTimeZone.defaultTimeZone()
>>> print(timezone)
Europe/Zurich (GMT+1) offset 3600
>>> seconds_offset = timezone.secondsFromGMTForDate_(the_date)
>>> print(seconds_offset)
3600
>>> new_date = NSDate.alloc().initWithTimeInterval_sinceDate_(seconds_offset, the_date)
>>> print(new_date)
-5877520-03-03 -8:-31:-23 +0000
>>>
However:
(as local admin)
cd /usr/local/munki
./munki-python
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:25:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Foundation import NSDate, NSTimeZone
>>> from munkilib import reports
>>> the_date = NSDate.dateWithString_(reports.report.get('StartTime', reports.format_time()))
>>> print(the_date)
2022-02-03 22:20:53 +0000
ls -al /usr/local/munki
drwxr-xr-x 6 root wheel 192 3 Feb 21:58 Python.framework
-rwxr-xr-x 1 root wheel 8370 31 Jan 20:10 app_usage_monitor
-rwxr-xr-x 1 root wheel 12214 31 Jan 20:10 appusaged
-rwxr-xr-x 1 root wheel 16566 31 Jan 20:10 authrestartd
drwxrwxr-x 2 root wheel 64 3 Feb 21:59 cleanup
-rwxr-xr-x 1 root wheel 11101 31 Jan 20:10 iconimporter
-rwxr-xr-x 1 root wheel 2521 31 Jan 20:10 launchapp
-rwxr-xr-x 1 root wheel 8078 31 Jan 20:10 logouthelper
-rwxr-xr-x 1 root wheel 3743 31 Jan 20:10 makecatalogs
-rwxr-xr-x 1 root wheel 4929 31 Jan 20:10 makepkginfo
-rwxr-xr-x 1 root wheel 50153 31 Jan 20:10 managedsoftwareupdate
-rwxr-xr-x 1 root wheel 40957 31 Jan 20:10 manifestutil
lrwxr-xr-x 1 root wheel 45 3 Feb 21:58 munki-python -> Python.framework/Versions/Current/bin/python3
-rwxr-xr-x 1 root wheel 25062 31 Jan 20:10 munkiimport
drwxr-xr-x 43 root wheel 1376 3 Feb 21:58 munkilib
-rwxr-xr-x 1 root wheel 1618 31 Jan 20:10 precache_agent
-rwxr-xr-x 1 root wheel 3516 31 Jan 20:10 ptyexec
-rwxr-xr-x 1 root wheel 3542 31 Jan 20:10 removepackages
-rwxr-xr-x 1 root wheel 23348 31 Jan 20:10 repoclean
-rwxr-xr-x 1 root wheel 11987 31 Jan 20:10 supervisor
Since munki runs as root, this causes the problem. I tried to chown -R root:wheel 755 /usr/local/munki
Same result. This is beyond me 😵💫
Gregory Neagle schrieb am Donnerstag, 3. Februar 2022 um 22:18:41 UTC+1:
$ cd /usr/local/munki/
$ ./munki-python
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:25:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.