Example #1
0
def load_policy(opts):
    PWD = getcwd()
    chdir(TEMPLATES_STORE)

    if opts['LoadModules']:
        handle = semanage.semanage_handle_create()
        semanage.semanage_connect(handle)

        for template in templates_to_load:
            semanage.semanage_module_install_file(handle, template + '.cil')

        chdir(PWD)

        semanage.semanage_module_install_file(handle,
                                              opts['ContainerName'] + '.cil')

        semanage.semanage_commit(handle)
    else:
        templates = list_templates_to_string(templates_to_load)
        if len(templates_to_load) > 1:
            print('\nPlease load these modules using: \n# semodule -i ' +
                  opts['ContainerName'] + '.cil ' + TEMPLATES_STORE + "/{" +
                  templates + '}')
        else:
            print('\nPlease load these modules using: \n# semodule -i ' +
                  opts['ContainerName'] + '.cil ' + TEMPLATES_STORE + "/" +
                  templates + '')

        chdir(PWD)
Example #2
0
def load_policy(opts):
    PWD = getcwd()
    chdir(TEMPLATES_STORE)

    if opts["LoadModules"]:
        handle = semanage.semanage_handle_create()
        semanage.semanage_connect(handle)

        for template in templates_to_load:
            semanage.semanage_module_install_file(handle, template + ".cil")

        chdir(PWD)

        semanage.semanage_module_install_file(handle,
                                              opts["ContainerName"] + ".cil")

        semanage.semanage_commit(handle)
    else:
        templates = list_templates_to_string(templates_to_load)
        if len(templates_to_load) > 1:
            print("\nPlease load these modules using: \n# semodule -i " +
                  opts["ContainerName"] + ".cil " + TEMPLATES_STORE + "/{" +
                  templates + "}")
        else:
            print("\nPlease load these modules using: \n# semodule -i " +
                  opts["ContainerName"] + ".cil " + TEMPLATES_STORE + "/" +
                  templates + "")

        chdir(PWD)