From 4206f5498d6dde7999679aed420ac7a254e76eb8 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 9 Feb 2021 19:23:13 +0100 Subject: [PATCH] Cleanup and fix audit function --- setup.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index cc252f9..df0a820 100644 --- a/setup.py +++ b/setup.py @@ -89,11 +89,10 @@ def install(): copytree2(src=r'distribution', dst=makepath(programfiles, "Mozilla Thunderbird", "distribution")) # Disable Thunderbird Update - print("Disable Thunderbird Update") + print("Disable Thunderbird and Telemetry") key=reg_openkey_noredir(HKEY_LOCAL_MACHINE,r'SOFTWARE\Policies\Mozilla\Thunderbird',sam=KEY_WRITE, create_if_missing=True) - reg_setvalue(key,'DisableAppUpdate', 1, REG_DWORD) - reg_setvalue(key,'DisableTelemetry', 1, REG_DWORD) - + for value in ['DisableAppUpdate','DisableTelemetry']: + reg_setvalue(key,value, 1, REG_DWORD) else: error('This package is not compatible with your WAPT version. Please upgrade to WAPT 1.5 or more.') @@ -134,28 +133,30 @@ def update_package(): print('No update available') -if __name__ == '__main__': - update_package() - - def uninstall(): - print('uninstalling %s' % control.asrequirement()) + print('Uninstalling %s' % control.asrequirement()) for thunderbird in installed_softwares('Mozilla Thunderbird'): print('Uninstalling %s' % thunderbird['version']) run(uninstall_cmd(thunderbird['key'])) print('Removing registry entries') - registry_delete(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird', 'DisableAppUpdate') - registry_delete(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird', 'DisableTelemetry') + for value in ['DisableAppUpdate','DisableTelemetry']: + registry_delete(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird', value) def audit(): for reg in ['DisableAppUpdate','DisableTelemetry']: - if not registry_readstring(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird\%s' % reg): - print(r'Warning : SOFTWARE\Policies\Mozilla\Thunderbird\%s is missing !' % reg) - return "WARNING" - value = registry_readstring(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird\%s' % reg) - if value != "1" : - print("Warning : Thunderbird update is not disable !") - return "WARNING" \ No newline at end of file + print('Checking %s' % reg) + value = registry_readstring(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird', reg) + if not value: + print(r'Warning : SOFTWARE\Policies\Mozilla\Thunderbird\%s is missing' % reg) + return "ERROR" + elif value != 1: + print(r'Warning : SOFTWARE\Policies\Mozilla\Thunderbird\%s is %s instead of 1' % (reg,value)) + return "ERROR" + + return "OK" + +if __name__ == '__main__': + update_package() \ No newline at end of file