From bf2e030ea6a0417939b28d65492a266d354d7085 Mon Sep 17 00:00:00 2001 From: doron zarhi Date: Tue, 1 Mar 2022 09:28:28 +0200 Subject: [PATCH] darwin: syslog: bugfix: set_har_capture_global option --- src/rpcclient/rpcclient/darwin/syslog.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rpcclient/rpcclient/darwin/syslog.py b/src/rpcclient/rpcclient/darwin/syslog.py index cefe772f..a8e237cb 100644 --- a/src/rpcclient/rpcclient/darwin/syslog.py +++ b/src/rpcclient/rpcclient/darwin/syslog.py @@ -1,5 +1,7 @@ import datetime +from rpcclient.exceptions import BadReturnValueError + class Syslog: """" manage syslog """ @@ -21,6 +23,14 @@ def set_har_capture_global(self, enable: bool = True): enable/disable HAR logging https://github.com/doronz88/harlogger """ - self._client.preferences.cf.set('har-capture-global', - self._client.cf(datetime.datetime(9999, 12, 31, 23, 59, 59)), - 'com.apple.CFNetwork') + if enable: + self._client.preferences.cf.set('har-capture-global', + self._client.cf(datetime.datetime(9999, 12, 31, 23, 59, 59)), + 'com.apple.CFNetwork') + else: + self._client.preferences.cf.set('har-capture-global', + self._client.cf(datetime.datetime(1970, 1, 1, 1, 1, 1)), + 'com.apple.CFNetwork') + + if self._client.symbols.notify_post('com.apple.CFNetwork.har-capture-update'): + raise BadReturnValueError('notify_post() failed')