Exemple #1
0
    def process(self):
        for model in self.consume(RemovedPAMModules):
            for path in PAM.files:
                content = read_file(path)
                if not content:  # Nothing to do if no content?
                    continue

                with open(path, 'w') as f:
                    f.write(comment_modules(model.modules, content))
            break
Exemple #2
0
def test_comment_modules__none():
    pam = get_config('''
    auth sufficient pam_unix.so
    auth sufficient pam_pkcs11.so
    auth sufficient pam_krb5.so
    auth sufficient pam_sss.so
    auth required pam_deny.so
    ''')
    expected = pam

    content = comment_modules([], pam)
    assert content == expected
Exemple #3
0
def test_comment_modules__replaced_single():
    pam = get_config('''
    auth sufficient pam_unix.so
    auth sufficient pam_pkcs11.so
    auth sufficient pam_sss.so
    auth required pam_deny.so
    ''')
    expected = get_config('''
    auth sufficient pam_unix.so
    #auth sufficient pam_pkcs11.so
    auth sufficient pam_sss.so
    auth required pam_deny.so
    ''')

    content = comment_modules(['pam_pkcs11', 'pam_krb5'], pam)
    assert content == expected