tis-config-thunderbird

68.0-4
Configuration for Mozilla Thunderbird - The package will not have any effect if an ADMX GPO for Thunderbird is applied
66 downloads
Download

  Description 

  • package : tis-config-thunderbird
  • version : 68.0-4
  • architecture : all
  • categories : System and network
  • maintainer : WAPT Team, Tranquil IT, Jimmy PELÉ
  • description : Configuration for Mozilla Thunderbird - The package will not have any effect if an ADMX GPO for Thunderbird is applied
  • locale : all
  • target_os : windows
  • min_os_version :
  • max_os_version :
  • min_wapt_version : 1.8
  • sources : https://github.com/mozilla/policy-templates/
  • installed_size :
  • impacted_process :
  • description_fr :
  • description_pl :
  • description_de :
  • description_es :
  • description_pt :
  • description_it :
  • description_nl :
  • description_ru :
  • editor : Mozilla Foundation
  • licence : MPL-2.0
  • signature_date : 2021-01-05T15:31:44.032366
  • Homepage : https://support.mozilla.org/kb/customizing-firefox-using-policiesjson
  • Depends :

  Setup.py 

# -*- coding: UTF-8 -*-
from setuphelpers import *
#import json

uninstallkey = []

""" 
Installation procedure: https://support.mozilla.org/kb/customizing-firefox-using-policiesjson
https://github.com/thundernest/policy-templates
https://github.com/mozilla/policy-templates/
https://klaus-hartnegg.de/gpo/2018-05-26-Firefox-Policies.html

"""

# Defining variables
app_name ='Mozilla Thunderbird'
policies_file = 'policies.json'
#ext_dir = 'extensions'


def install():
    # Installing the package
    for thund in installed_softwares(name=app_name):
        # Initializing variables
        thund_dir = thund['install_location']
        thund_dist_dir = makepath(thund_dir,'distribution')
        policies_path = makepath(thund_dist_dir,policies_file)
        basedir_policies_file = makepath(basedir,policies_file)

        # Writing Thunderbird configuration file
        if not isdir(thund_dist_dir):
            mkdirs(thund_dist_dir)
        print("Writing Thunderbird configuration file: %s" % policies_path)
        """ # Merging actual Thunderbird configuration file with defined one (may fail)
        if isfile(policies_path):
            old_data = json_load(policies_path)
            new_data = json_load(basedir_policies_file)
            data = data_merge(old_data,new_data)
            json_write(policies_path, data, indent=2)
        else:
            data = json_load(basedir_policies_file)
            json_write(policies_path, data, indent=2) """

        # Forcing package Thunderbird configuration
        if isfile(policies_path):
            remove_file(policies_path)
            filecopyto(basedir_policies_file, policies_path)
        else:
            filecopyto(basedir_policies_file, policies_path)

    # Removing policies from registry since it bypass the policies.json file (source: https://support.mozilla.org/bm/questions/1236197)
    if reg_key_exists(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird'):
        registry_deletekey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Policies\Mozilla\Thunderbird', '',force=True)


def uninstall():
    # Uninstalling the package
    for thund in installed_softwares(name=app_name):
        # Initializing variables
        thund_dir = thund['install_location']
        thund_dist_dir = makepath(thund_dir,'distribution')
        policies_path = makepath(thund_dist_dir,policies_file)

        # Removing Thunderbird configuration
        if isfile(policies_path):
            remove_file(policies_path)


def audit():
    # Verifying that the configuration is applied
    for thund in installed_softwares(name=app_name):
        # Initializing variables
        thund_dir = thund['install_location']
        thund_dist_dir = makepath(thund_dir,'distribution')
        policies_path = makepath(thund_dist_dir,policies_file)
        if not isfile(policies_path):
            # Re-executiong the package
            print("Configuration is NOT applied for %s" % thund['name'])
            return "WARNING"
        else:
            print("Configuration is correctly applied for %s" % thund['name'])
            return "OK"


def update_package():
    # Initializing variables
    version = control.version.split('-')[0]

    # Incrementing version of the package
    control.version = '%s-%s'%(version,int(control.version.split('-')[-1])+1)
    control.save_control_to_wapt()
    print('Changing package version to: %s in WAPT\\control' % control.version)




def json_load(json_file):
    with open(json_file) as read_file:
        data = json.load(read_file)
    return data


def json_write(json_file,data,sort_keys=True, indent=4):
    import codecs
    with codecs.open(json_file, 'w', encoding='utf-8') as write_file:
        json.dump(data, write_file, sort_keys=sort_keys, indent=indent)


def data_merge(a, b):
    """merges b into a and return merged result

    NOTE: tuples and arbitrary objects are not handled as it is totally ambiguous what should happen"""
    key = None
    # ## debug output
    # sys.stderr.write("DEBUG: %s to %s\n" %(b,a))
    try:
        if a is None or isinstance(a, str) or isinstance(a, unicode) or isinstance(a, int) or isinstance(a, long) or isinstance(a, float):
            # border case for first run or if a is a primitive
            a = b
        elif isinstance(a, list):
            # lists can be only appended
            if isinstance(b, list):
                # merge lists
                a.extend(b)
            else:
                # append to list
                a.append(b)
        elif isinstance(a, dict):
            # dicts must be merged
            if isinstance(b, dict):
                for key in b:
                    if key in a:
                        a[key] = data_merge(a[key], b[key])
                    else:
                        a[key] = b[key]
    except TypeError as e:
        raise Exception('TypeError "%s" in key "%s" when merging "%s" into "%s"' % (e, key, b, a))
    return a


										

  Changelog 


No changelog
  manifest.sha256 
[["policies.json","5e0a07f78ea0b5c7d22685c542e95ef022686e4e2d485c78c4755b7ebf35a87a"],["setup.py","e60cefa23453405615c291218b7f0b54484dca50f7036f7f718e0070b5da553f"],["WAPT/certificate.crt","a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf"],["WAPT/control","d53b49b3ea19018394937e7e165fa8ce40aff7f1f81cd12c8a9bfd106a328c47"]]